Slim recents [2/3]
@SKULSHADY: Cleanup, fixes and adapt for SettingsPreferenceFragment @rohanpurohit: bringup to 10 Change-Id: I7fa5703534c9eb76a555db9a6d3349cc2b6a2b2d Signed-off-by: rohan <purohit.rohan@gmail.com>
This commit is contained in:
29
res/layout/dialog_iconpack.xml
Normal file
29
res/layout/dialog_iconpack.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 ABC rom
|
||||
Copyright (C) 2014 The OmniROM Project
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="?android:attr/dialogPreferredPadding"
|
||||
android:paddingEnd="?android:attr/dialogPreferredPadding" >
|
||||
<ListView
|
||||
android:id="@+id/iconpack_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
39
res/layout/iconpack_view.xml
Normal file
39
res/layout/iconpack_view.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 The OmniROM Project
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@android:dimen/app_icon_size"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="8dp"
|
||||
android:contentDescription="@null" />
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="8dip"
|
||||
android:paddingStart="8dip"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="19sp" />
|
||||
</LinearLayout>
|
||||
45
res/layout/iconpack_view_radio.xml
Normal file
45
res/layout/iconpack_view_radio.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 ABC rom
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@android:dimen/app_icon_size"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="8dp"
|
||||
android:contentDescription="@null" />
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="8dip"
|
||||
android:paddingStart="8dip"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="19sp" />
|
||||
<RadioButton
|
||||
android:id="@+id/radio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="false"
|
||||
android:duplicateParentState="true"
|
||||
android:focusable="false"
|
||||
android:paddingEnd="8dip" />
|
||||
</LinearLayout>
|
||||
@@ -40,7 +40,7 @@
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Lockscreen clock style -->
|
||||
<string-array name="lockscreen_clock_titles">
|
||||
<item>@string/lockscreen_clock_hide</item>
|
||||
@@ -67,7 +67,7 @@
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Lockscreen date styles -->
|
||||
<string-array name="lockscreen_date_selection_entries" translatable="false">
|
||||
<item>@string/lockscreen_date_selection_default</item>
|
||||
@@ -92,7 +92,7 @@
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Statusbar Clock -->
|
||||
<string-array name="status_bar_clock_style_entries" translatable="false">
|
||||
<item>@string/status_bar_clock_style_left</item>
|
||||
@@ -155,7 +155,7 @@
|
||||
<item>EEEE MM/dd</item>
|
||||
<item>@string/clock_date_format_custom</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="clock_date_position_entries" translatable="false">
|
||||
<item>@string/clock_date_left</item>
|
||||
<item>@string/clock_date_right</item>
|
||||
@@ -213,7 +213,7 @@
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Network Traffic Type -->
|
||||
<string-array name="show_network_traffic_type_entries" translatable="false">
|
||||
<item>@string/show_network_traffic_up</item>
|
||||
@@ -226,7 +226,7 @@
|
||||
<item>2</item>
|
||||
<item>0</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- VoLTE Icon Type -->
|
||||
<string-array name="volte_icon_type_entries" translatable="false">
|
||||
<item>@string/volte_icon_asus</item>
|
||||
@@ -245,7 +245,7 @@
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Lockscreen Charging Animation options -->
|
||||
<string-array name="lockscreen_charging_animation_entries" translatable="false">
|
||||
<item>@string/lockscreen_charging_animation_off</item>
|
||||
@@ -264,7 +264,7 @@
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Themes -->
|
||||
<string-array name="theme_type_titles">
|
||||
<item>@string/theme_type_light</item>
|
||||
@@ -287,7 +287,7 @@
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Adaptive Playback -->
|
||||
<string-array name="adaptive_playback_timeout_entries" translatable="false">
|
||||
<item>@string/adaptive_playback_timeout_30_secs</item>
|
||||
@@ -303,4 +303,27 @@
|
||||
<item>300000</item>
|
||||
<item>600000</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Slim recents -->
|
||||
<string-array name="recent_panel_expanded_mode_entries">
|
||||
<item>@string/recent_panel_expanded_mode_auto</item>
|
||||
<item>@string/recent_panel_expanded_mode_always</item>
|
||||
<item>@string/recent_panel_expanded_mode_never</item>
|
||||
<item>@string/recent_panel_expanded_mode_disabled</item>
|
||||
</string-array>
|
||||
<string-array name="recent_panel_expanded_mode_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="slim_recents_enter_exit_animation_entries" translatable="false">
|
||||
<item>@string/slim_recents_enter_exit_animation_translate</item>
|
||||
<item>@string/slim_recents_enter_exit_animation_fade</item>
|
||||
</string-array>
|
||||
<string-array name="slim_recents_enter_exit_animation_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<string name="qs_brightness_position_bottom_summary">Show a brightness slider on bottom quick settings</string>
|
||||
<string name="enable_oneui">OneUI</string>
|
||||
<string name="enable_oneui_summary">Show spacer above settings actionbar for easier use with one hand\nNOTE: restart settings app to see effect</string>
|
||||
|
||||
|
||||
<!-- Lockscreen clock style -->
|
||||
<string name="lockscreen_clock_title">Clock style</string>
|
||||
<string name="lockscreen_clock_dialog_title">Select clock style</string>
|
||||
@@ -102,7 +102,7 @@
|
||||
<string name="lockscreen_clock_sammy_bold">Sammy (bold)</string>
|
||||
<string name="lockscreen_clock_sammy_accent_hour">Sammy (accent hour)</string>
|
||||
<string name="lockscreen_clock_sammy_accent_min">Sammy (accent minute)</string>
|
||||
|
||||
|
||||
<!-- Lockscreen Date styles -->
|
||||
<string name="lockscreen_date_title">Date style</string>
|
||||
<string name="lockscreen_date_selection_title">Date style</string>
|
||||
@@ -116,12 +116,12 @@
|
||||
<string name="lockscreen_date_selection_str_gradient">Gradient</string>
|
||||
<string name="lockscreen_date_selection_str_border_accent">Dark with accented borders</string>
|
||||
<string name="lockscreen_date_selection_str_border_gradient">Dark with gradient borders</string>
|
||||
|
||||
|
||||
<!-- Status bar - icons -->
|
||||
<string name="status_bar_icons_title">Status bar icons</string>
|
||||
<string name="status_bar_system_icons_title">System icons</string>
|
||||
<string name="status_bar_system_icons_summary">Control which status bar icons are shown</string>
|
||||
|
||||
|
||||
<!-- Statusbar Clock -->
|
||||
<string name="statusbar_items_title">Statusbar items</string>
|
||||
<string name="clock_category_title">Clock</string>
|
||||
@@ -180,7 +180,7 @@
|
||||
<string name="status_bar_battery_style_q">Icon portrait (default)</string>
|
||||
<string name="status_bar_battery_style_dotted_circle">Circle (Dotted)</string>
|
||||
<string name="status_bar_battery_style_circle">Circle</string>
|
||||
<string name="status_bar_battery_style_text">Text</string>
|
||||
<string name="status_bar_battery_style_text">Text</string>
|
||||
<string name="status_bar_battery_style_hidden">Hidden</string>
|
||||
<string name="status_bar_battery_style_big_circle">Big circle</string>
|
||||
<string name="status_bar_battery_style_filled_circle">Circle (Filled)</string>
|
||||
@@ -199,7 +199,7 @@
|
||||
<string name="battery_percentage_next">Enabled</string>
|
||||
<string name="battery_percentage_inside">Enabled (inside icon)</string>
|
||||
<string name="battery_percentage_estimate">Enabled (estimate)</string>
|
||||
|
||||
|
||||
<!-- Network traffic -->
|
||||
<string name="traffic_title">Traffic indicators</string>
|
||||
<string name="traffic_title_summary">Customize network traffic indicators</string>
|
||||
@@ -212,16 +212,16 @@
|
||||
<string name="network_traffic_autohide_threshold_title">Net activity autohide threshold (KB/s)</string>
|
||||
<string name="network_traffic_hidearrow">Hide arrows</string>
|
||||
<string name="network_traffic_hidearrow_summary">Hide the network traffic indicator arrows</string>
|
||||
|
||||
|
||||
<!-- 4G icon -->
|
||||
<string name="statusbar_items_category">Icons</string>
|
||||
<string name="show_fourg_icon_title">4G icon</string>
|
||||
<string name="show_fourg_icon_summary">Display 4G icon in signal icon instead LTE</string>
|
||||
|
||||
|
||||
<!-- Show VoLTE icon on statusbar -->
|
||||
<string name="volte_icon_title">VoLTE icon</string>
|
||||
<string name="volte_icon_summary">Display VoLTE icon (Needs a SystemUI restart to take effect)</string>
|
||||
|
||||
|
||||
<!-- VoLTE icon styles -->
|
||||
<string name="volte_icon_style_title">Select VoLTE Icon</string>
|
||||
<string name="volte_icon_vo">Default Icon</string>
|
||||
@@ -230,7 +230,7 @@
|
||||
<string name="volte_icon_hd">HD Icon</string>
|
||||
<string name="volte_icon_miui">VoLTE Miui Icon</string>
|
||||
<string name="volte_icon_asus">VoLTE Asus Icon</string>
|
||||
|
||||
|
||||
<!-- Lock screen visualizer -->
|
||||
<string name="visualizer_title">Display music visualizer</string>
|
||||
<string name="lockscreen_visualizer_title">Music visualizer</string>
|
||||
@@ -253,11 +253,11 @@
|
||||
<string name="battery_light_medium_color">Medium battery</string>
|
||||
<string name="battery_light_full_color">Almost full battery</string>
|
||||
<string name="battery_light_reallyfull_color">Full (100) battery</string>
|
||||
|
||||
|
||||
<!-- Old MobileType Toggle -->
|
||||
<string name="use_old_mobiletype_title">Use old mobile type style</string>
|
||||
<string name="use_old_mobiletype_summary">Merge signal and type icons</string>
|
||||
|
||||
|
||||
<!-- Themes -->
|
||||
<string name="theme_type_title">System theme</string>
|
||||
<string name="theme_type_summary">Select theme</string>
|
||||
@@ -269,7 +269,7 @@
|
||||
<string name="theme_type_du_pitchblack">Pitch black</string>
|
||||
<string name="theme_type_dark_grey">Dark Grey</string>
|
||||
<string name="theme_type_material_ocean">Material Ocean</string>
|
||||
|
||||
|
||||
<!-- RGB Accenter -->
|
||||
<string name="theme_rgb_title">RGB Accent | Gradient Theming</string>
|
||||
<string name="themes_hub_title">Themes</string>
|
||||
@@ -278,7 +278,7 @@
|
||||
<string name="accent_summary">Gradient Maker</string>
|
||||
<string name="gradient_color">Gradient picker</string>
|
||||
<string name="gradient_summary">Gradient effect maker</string>
|
||||
|
||||
|
||||
<!-- Power menu and dialogs opacity -->
|
||||
<string name="lockscreen_secure_power_title">Secure power menu</string>
|
||||
<string name="lockscreen_secure_power_menu_title">Secure power menu</string>
|
||||
@@ -287,7 +287,7 @@
|
||||
<string name="panel_porn_title">Power Menu Transparency</string>
|
||||
<string name="power_menu_transparency">Power/reboot menu opacity</string>
|
||||
<string name="power_menu_dialog_dim">Power/reboot dialog dim background amount</string>
|
||||
|
||||
|
||||
<!-- Rounded corners -->
|
||||
<string name="corners_category_title">Rounded corners</string>
|
||||
<string name="corners_category_summary">Adjust rounded corners and padding</string>
|
||||
@@ -309,7 +309,7 @@
|
||||
<string name="adaptive_playback_timeout_2_min">2 minutes</string>
|
||||
<string name="adaptive_playback_timeout_5_min">5 minutes</string>
|
||||
<string name="adaptive_playback_timeout_10_min">10 minutes</string>
|
||||
|
||||
|
||||
<!-- Custom carrier label and position -->
|
||||
<string name="label_title">Label</string>
|
||||
<string name="carrier_label_settings_title">Carrier label</string>
|
||||
@@ -332,4 +332,69 @@
|
||||
<string name="fod_recognizing_animation_title">Recognizing animation</string>
|
||||
<string name="fod_recognizing_animation_summary">Show an animation while reading your fingerprint</string>
|
||||
|
||||
<!-- Slim recents -->
|
||||
<string name="ok">OK</string>
|
||||
<string name="alternative_recents_category">Alternative recents</string>
|
||||
<string name="alternative_recents_swipe_up_enabled_warning_summary">When using swipe up home navigation to open recents, only stock recents are supported</string>
|
||||
<string name="slim_recents_title">Slim Recents</string>
|
||||
<string name="slim_recents_summary">Enable to use an alternative recents screen</string>
|
||||
<string name="slim_recents_fragment_title">Slim recents settings</string>
|
||||
<string name="slim_recents_fragment_summary">Customize the additional settings for slim recents</string>
|
||||
<string name="recents_max_apps_title">Max allowed apps</string>
|
||||
<string name="recent_panel_scale_title">Size</string>
|
||||
<string name="recent_panel_expanded_mode_title">Expanded mode</string>
|
||||
<string name="recent_panel_expanded_mode_summary">Recent tasks expanded preview mode</string>
|
||||
<string name="recent_panel_expanded_mode_auto">Auto (Default)</string>
|
||||
<string name="recent_panel_expanded_mode_always">Always</string>
|
||||
<string name="recent_panel_expanded_mode_never">Never</string>
|
||||
<string name="recent_panel_expanded_mode_disabled">Disabled</string>
|
||||
<string name="recent_panel_bg_color_title">Panel background color</string>
|
||||
<string name="recent_card_bg_color_title">Card background color</string>
|
||||
<string name="slim_recents_mem_display_long_click_clear_title">Memory bar longpress gesture</string>
|
||||
<string name="slim_recents_mem_display_long_click_clear_summary">Clear recents by long-pressing the memory bar</string>
|
||||
<string name="slim_icon_pack_title">Icon Pack</string>
|
||||
<string name="slim_icon_pack_summary">Apply a custom icon pack for apps in the panel</string>
|
||||
<string name="no_iconpacks_summary">No icon packs installed</string>
|
||||
<string name="dialog_pick_iconpack_title">Pick icon pack</string>
|
||||
<string name="default_iconpack_title">Default icons</string>
|
||||
<string name="slim_recents_corner_radius_title">Card corner radius</string>
|
||||
<!-- ATTENTION: RTL languages need to replace left with right -->
|
||||
<string name="recent_panel_lefty_mode_title">Show on the left edge</string>
|
||||
<string name="recent_panel_lefty_mode_summary">Show recent apps panel on the left edge of the screen</string>
|
||||
<string name="slim_blacklist_apps_cat_title">Blacklist</string>
|
||||
<string name="slim_blacklist_apps_title">Apps blacklist</string>
|
||||
<string name="slim_blacklist_apps_summary">Apps to not show in the panel</string>
|
||||
<string name="slim_blacklist_add_apps_title">Add app</string>
|
||||
<string name="slim_blacklist_add_apps_summary">Tap here to add, tap on added app to remove it</string>
|
||||
|
||||
<!-- Slim Recent App Sidebar -->
|
||||
<string name="recent_app_sidebar_cat_title">App Sidebar</string>
|
||||
<string name="recent_app_sidebar_title">Recents app sidebar</string>
|
||||
<string name="recent_app_sidebar_summary">Show app shortcuts on the other edge</string>
|
||||
<string name="recent_app_sidebar_picker_title">Sidebar shortcuts</string>
|
||||
<string name="recent_app_sidebar_picker_summary">Choose apps to show in the sidebar</string>
|
||||
<string name="recent_app_sidebar_style_title">Sidebar style</string>
|
||||
<string name="recent_app_sidebar_style_summary">Change the look of the sidebar</string>
|
||||
<string name="recent_app_sidebar_hide_labels_title">Hide icon labels</string>
|
||||
<string name="recent_app_sidebar_label_color_title">Label color</string>
|
||||
<string name="recent_app_sidebar_bg_color_title">Background color</string>
|
||||
<string name="recent_app_sidebar_scale_title">Size</string>
|
||||
<string name="recent_app_sidebar_open_simultaneously_title">Open simultaneously with recents</string>
|
||||
<string name="recent_app_sidebar_open_simultaneously_summary">Reduce recents opening lag by disabling this</string>
|
||||
<string name="default_auto_string">Default (App based)</string>
|
||||
|
||||
<!-- Slim recents membar -->
|
||||
<string name="default_string">Default</string>
|
||||
<string name="profile_choose_app">Choose app</string>
|
||||
<string name="dialog_delete_title">Delete</string>
|
||||
<string name="dialog_delete_message">Remove selected item?</string>
|
||||
<string name="slim_recents_mem_display_category_title">Memory Bar</string>
|
||||
<string name="slim_recents_mem_display_title">Memory bar</string>
|
||||
<string name="slim_recents_mem_display_summary">Show a progress bar displaying RAM</string>
|
||||
<string name="slim_recents_mem_display_color">Memory bar color</string>
|
||||
<string name="slim_recents_mem_display_text_color">Memory bar text color</string>
|
||||
<string name="slim_recents_enter_exit_animation_title">Animation</string>
|
||||
<string name="slim_recents_enter_exit_animation_translate">Translate</string>
|
||||
<string name="slim_recents_enter_exit_animation_fade">Fade</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -18,4 +18,21 @@
|
||||
android:title="@string/recents_title"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="alternative_recents_category"
|
||||
android:title="@string/alternative_recents_category">
|
||||
|
||||
<Preference
|
||||
android:key="swipe_up_enabled_warning"
|
||||
android:selectable="false"
|
||||
android:summary="@string/alternative_recents_swipe_up_enabled_warning_summary" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingMasterSwitchPreference
|
||||
android:key="use_slim_recents"
|
||||
android:fragment="com.cherish.settings.fragments.SlimRecents"
|
||||
android:title="@string/slim_recents_fragment_title"
|
||||
android:summary="@string/slim_recents_fragment_summary"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
23
res/xml/slim_recent_app_sidebar.xml
Normal file
23
res/xml/slim_recent_app_sidebar.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright (C) 2017 AICP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/recent_app_sidebar_picker_title">
|
||||
|
||||
</PreferenceScreen>
|
||||
58
res/xml/slim_recent_app_sidebar_style.xml
Normal file
58
res/xml/slim_recent_app_sidebar_style.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright (C) 2017 AICP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:title="@string/recent_app_sidebar_style_title">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="recent_app_sidebar_scale_factor"
|
||||
android:title="@string/recent_app_sidebar_scale_title"
|
||||
android:defaultValue="100"
|
||||
android:max="160"
|
||||
settings:min="60"
|
||||
settings:interval="5"
|
||||
settings:units="%" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="recent_app_sidebar_disable_labels"
|
||||
android:title="@string/recent_app_sidebar_hide_labels_title"
|
||||
android:disableDependentsState="true"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="recent_app_sidebar_text_color"
|
||||
android:title="@string/recent_app_sidebar_label_color_title"
|
||||
settings:defaultColorValue="0xffffffff"
|
||||
alphaSlider="false"
|
||||
android:dependency="recent_app_sidebar_disable_labels" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="recent_app_sidebar_bg_color"
|
||||
android:title="@string/recent_app_sidebar_bg_color_title"
|
||||
settings:defaultColorValue="0x00ffffff"
|
||||
alphaSlider="true" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="recent_app_sidebar_open_simultaneously"
|
||||
android:title="@string/recent_app_sidebar_open_simultaneously_title"
|
||||
android:summary="@string/recent_app_sidebar_open_simultaneously_summary"
|
||||
android:defaultValue="true" />
|
||||
|
||||
</PreferenceScreen>
|
||||
150
res/xml/slim_recents.xml
Normal file
150
res/xml/slim_recents.xml
Normal file
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright (C) 2017 AICP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
android:title="@string/slim_recents_title">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="recent_panel_scale_factor"
|
||||
android:title="@string/recent_panel_scale_title"
|
||||
settings:min="60"
|
||||
settings:interval="5"
|
||||
android:max="160"
|
||||
android:defaultValue="100"
|
||||
settings:units="%" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="recent_panel_bg_color"
|
||||
android:title="@string/recent_panel_bg_color_title"
|
||||
settings:defaultColorValue="0x00ffffff"
|
||||
alphaSlider="true" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="recent_card_bg_color"
|
||||
android:title="@string/recent_card_bg_color_title"
|
||||
settings:defaultColorValue="0x00ffffff"
|
||||
alphaSlider="true" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="recents_max_apps"
|
||||
android:title="@string/recents_max_apps_title"
|
||||
android:defaultValue="15"
|
||||
settings:min="5"
|
||||
android:max="105" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="recent_panel_lefty_mode"
|
||||
android:title="@string/recent_panel_lefty_mode_title"
|
||||
android:summary="@string/recent_panel_lefty_mode_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="slim_recent_enter_exit_animation"
|
||||
android:title="@string/slim_recents_enter_exit_animation_title"
|
||||
android:entries="@array/slim_recents_enter_exit_animation_entries"
|
||||
android:entryValues="@array/slim_recents_enter_exit_animation_values"
|
||||
android:defaultValue="0" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="slim_recents_corner_radius"
|
||||
android:title="@string/slim_recents_corner_radius_title"
|
||||
settings:min="0"
|
||||
android:max="20"
|
||||
android:defaultValue="8"
|
||||
settings:units="dp" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="recent_panel_expanded_mode"
|
||||
android:entries="@array/recent_panel_expanded_mode_entries"
|
||||
android:entryValues="@array/recent_panel_expanded_mode_values"
|
||||
android:title="@string/recent_panel_expanded_mode_title"
|
||||
android:summary="@string/recent_panel_expanded_mode_summary"
|
||||
android:defaultValue="0" />
|
||||
|
||||
<Preference
|
||||
android:key="slim_icon_pack"
|
||||
android:title="@string/slim_icon_pack_title"
|
||||
android:summary="@string/slim_icon_pack_summary" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="blacklist_fragment"
|
||||
android:fragment="com.cherish.settings.fragments.SlimRecentsBlacklist"
|
||||
android:title="@string/slim_blacklist_apps_title"
|
||||
android:summary="@string/slim_blacklist_apps_summary" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/recent_app_sidebar_cat_title">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="use_recent_app_sidebar"
|
||||
android:title="@string/recent_app_sidebar_title"
|
||||
android:summary="@string/recent_app_sidebar_summary"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="recent_app_sidebar"
|
||||
android:title="@string/recent_app_sidebar_picker_title"
|
||||
android:summary="@string/recent_app_sidebar_picker_summary"
|
||||
android:fragment="com.cherish.settings.preferences.dslv.ActionListViewSettings"
|
||||
android:dependency="use_recent_app_sidebar" >
|
||||
<extra android:name="actionMode" android:value="7" />
|
||||
<extra android:name="maxAllowedActions" android:value="-1" />
|
||||
<extra android:name="useAppPickerOnly" android:value="true" />
|
||||
<extra android:name="fragment" android:value="com.cherish.settings.fragments.SlimRecentAppSidebar" />
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="recent_app_sidebar_fragment"
|
||||
android:fragment="com.cherish.settings.fragments.SlimRecentAppSidebarStyle"
|
||||
android:title="@string/recent_app_sidebar_style_title"
|
||||
android:summary="@string/recent_app_sidebar_style_summary"
|
||||
android:dependency="use_recent_app_sidebar" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/slim_recents_mem_display_category_title">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="slim_recents_mem_display"
|
||||
android:title="@string/slim_recents_mem_display_title"
|
||||
android:summary="@string/slim_recents_mem_display_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="slim_recents_mem_display_long_click_clear"
|
||||
android:title="@string/slim_recents_mem_display_long_click_clear_title"
|
||||
android:summary="@string/slim_recents_mem_display_long_click_clear_summary"
|
||||
android:defaultValue="false"
|
||||
android:dependency="slim_recents_mem_display" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="slim_mem_bar_color"
|
||||
android:title="@string/slim_recents_mem_display_color"
|
||||
settings:defaultColorValue="0xffffffff"
|
||||
android:dependency="slim_recents_mem_display"/>
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="slim_mem_text_color"
|
||||
android:title="@string/slim_recents_mem_display_text_color"
|
||||
settings:defaultColorValue="0xffffffff"
|
||||
android:dependency="slim_recents_mem_display"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
27
res/xml/slim_recents_blacklist.xml
Normal file
27
res/xml/slim_recents_blacklist.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 The ABC rom
|
||||
Copyright (C) 2017 AICP
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/slim_blacklist_apps_title">
|
||||
|
||||
<Preference
|
||||
android:key="add_blacklist_packages"
|
||||
android:title="@string/slim_blacklist_add_apps_title"
|
||||
android:summary="@string/slim_blacklist_add_apps_summary" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -11,6 +11,7 @@ import android.os.UserHandle;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import android.provider.Settings;
|
||||
@@ -19,11 +20,20 @@ import com.android.settings.R;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
public class RecentsSettings extends SettingsPreferenceFragment implements
|
||||
OnPreferenceChangeListener {
|
||||
|
||||
private static final String PREF_STOCK_RECENTS_CATEGORY = "stock_recents_category";
|
||||
private static final String PREF_ALTERNATIVE_RECENTS_CATEGORY = "alternative_recents_category";
|
||||
private static final String PREF_SWIPE_UP_ENABLED = "swipe_up_enabled_warning";
|
||||
|
||||
private PreferenceCategory mStockRecentsCategory;
|
||||
private PreferenceCategory mAlternativeRecentsCategory;
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -32,6 +42,75 @@ public class RecentsSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
mStockRecentsCategory = (PreferenceCategory) findPreference(PREF_STOCK_RECENTS_CATEGORY);
|
||||
mAlternativeRecentsCategory =
|
||||
(PreferenceCategory) findPreference(PREF_ALTERNATIVE_RECENTS_CATEGORY);
|
||||
|
||||
// Alternative recents en-/disabling
|
||||
Preference.OnPreferenceChangeListener alternativeRecentsChangeListener =
|
||||
new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
updateDependencies(preference, (Boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < mAlternativeRecentsCategory.getPreferenceCount(); i++) {
|
||||
Preference preference = mAlternativeRecentsCategory.getPreference(i);
|
||||
if (preference instanceof SystemSettingMasterSwitchPreference) {
|
||||
preference.setOnPreferenceChangeListener(alternativeRecentsChangeListener);
|
||||
}
|
||||
}
|
||||
|
||||
updateDependencies();
|
||||
|
||||
// Warning for alternative recents when gesture navigation is enabled,
|
||||
// which directly controls quickstep (launcher) recents.
|
||||
final int navigationMode = getActivity().getResources()
|
||||
.getInteger(com.android.internal.R.integer.config_navBarInteractionMode);
|
||||
// config_navBarInteractionMode:
|
||||
// 0: 3 button mode (supports slim recents)
|
||||
// 1: 2 button mode (currently does not support alternative recents)
|
||||
// 2: gesture only (currently does not support alternative recents)
|
||||
if (navigationMode != 0) {
|
||||
for (int i = 0; i < mAlternativeRecentsCategory.getPreferenceCount(); i++) {
|
||||
Preference preference = mAlternativeRecentsCategory.getPreference(i);
|
||||
if (PREF_SWIPE_UP_ENABLED.equals(preference.getKey())) {
|
||||
// We want to have that one enabled
|
||||
continue;
|
||||
}
|
||||
preference.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
mAlternativeRecentsCategory.removePreference(findPreference(PREF_SWIPE_UP_ENABLED));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDependencies() {
|
||||
updateDependencies(null, null);
|
||||
}
|
||||
|
||||
private void updateDependencies(Preference updatedPreference, Boolean newValue) {
|
||||
// Disable stock recents category if alternative enabled
|
||||
boolean alternativeRecentsEnabled = newValue != null && newValue;
|
||||
if (!alternativeRecentsEnabled) {
|
||||
for (int i = 0; i < mAlternativeRecentsCategory.getPreferenceCount(); i++) {
|
||||
Preference preference = mAlternativeRecentsCategory.getPreference(i);
|
||||
if (preference == updatedPreference) {
|
||||
// Already used newValue
|
||||
continue;
|
||||
}
|
||||
if (preference instanceof SystemSettingMasterSwitchPreference
|
||||
&& ((SystemSettingMasterSwitchPreference) preference).isChecked()) {
|
||||
alternativeRecentsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mStockRecentsCategory != null) {
|
||||
mStockRecentsCategory.setEnabled(!alternativeRecentsEnabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
38
src/com/cherish/settings/fragments/SlimRecentAppSidebar.java
Normal file
38
src/com/cherish/settings/fragments/SlimRecentAppSidebar.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Havoc-OS
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.cherish.settings.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
public class SlimRecentAppSidebar extends SettingsPreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.slim_recent_app_sidebar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Havoc-OS
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.cherish.settings.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
|
||||
public class SlimRecentAppSidebarStyle extends SettingsPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String RECENT_APP_SIDEBAR_TEXT_COLOR = "recent_app_sidebar_text_color";
|
||||
private static final String RECENT_APP_SIDEBAR_BG_COLOR = "recent_app_sidebar_bg_color";
|
||||
|
||||
private ColorPickerPreference mRecentSidebarTextColor;
|
||||
private ColorPickerPreference mRecentSidebarBgColor;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.slim_recent_app_sidebar_style);
|
||||
|
||||
mRecentSidebarTextColor = (ColorPickerPreference) findPreference(RECENT_APP_SIDEBAR_TEXT_COLOR);
|
||||
mRecentSidebarTextColor.setOnPreferenceChangeListener(this);
|
||||
final int intColor = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_APP_SIDEBAR_TEXT_COLOR, 0xffffffff);
|
||||
String hexColor = String.format("#%08x", (0xffffffff & intColor));
|
||||
if (hexColor.equals("#ffffffff")) {
|
||||
mRecentSidebarTextColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mRecentSidebarTextColor.setSummary(hexColor);
|
||||
}
|
||||
mRecentSidebarTextColor.setNewPreviewColor(intColor);
|
||||
|
||||
mRecentSidebarBgColor = (ColorPickerPreference) findPreference(RECENT_APP_SIDEBAR_BG_COLOR);
|
||||
mRecentSidebarBgColor.setOnPreferenceChangeListener(this);
|
||||
final int intColorCard = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_APP_SIDEBAR_BG_COLOR, 0x00ffffff);
|
||||
String hexColorCard = String.format("#%08x", (0x00ffffff & intColorCard));
|
||||
if (hexColorCard.equals("#00ffffff")) {
|
||||
mRecentSidebarBgColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mRecentSidebarBgColor.setSummary(hexColorCard);
|
||||
}
|
||||
mRecentSidebarBgColor.setNewPreviewColor(intColorCard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mRecentSidebarTextColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#ffffffff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_APP_SIDEBAR_TEXT_COLOR,
|
||||
intHex, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mRecentSidebarBgColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#00ffffff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_APP_SIDEBAR_BG_COLOR,
|
||||
intHex, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
}
|
||||
392
src/com/cherish/settings/fragments/SlimRecents.java
Normal file
392
src/com/cherish/settings/fragments/SlimRecents.java
Normal file
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* Copyright (C) 2017 AICP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package com.cherish.settings.fragments;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.R;
|
||||
|
||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SlimRecents extends SettingsPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener, DialogInterface.OnDismissListener {
|
||||
|
||||
private static final String RECENT_PANEL_LEFTY_MODE = "recent_panel_lefty_mode";
|
||||
private static final String RECENT_ICON_PACK = "slim_icon_pack";
|
||||
private static final String RECENT_PANEL_BG_COLOR = "recent_panel_bg_color";
|
||||
private static final String RECENT_CARD_BG_COLOR = "recent_card_bg_color";
|
||||
private static final String SLIM_MEM_BAR_COLOR = "slim_mem_bar_color";
|
||||
private static final String SLIM_MEM_TEXT_COLOR = "slim_mem_text_color";
|
||||
|
||||
private SwitchPreference mRecentPanelLeftyMode;
|
||||
private Preference mIconPack;
|
||||
private ColorPickerPreference mRecentPanelBgColor;
|
||||
private ColorPickerPreference mRecentCardBgColor;
|
||||
private ColorPickerPreference mMemBarColor;
|
||||
private ColorPickerPreference mMemTextColor;
|
||||
|
||||
// Icon pack
|
||||
private final static String[] sSupportedActions = new String[] {
|
||||
"org.adw.launcher.THEMES",
|
||||
"com.gau.go.launcherex.theme"
|
||||
};
|
||||
private static final String[] sSupportedCategories = new String[] {
|
||||
"com.fede.launcher.THEME_ICONPACK",
|
||||
"com.anddoes.launcher.THEME",
|
||||
"com.teslacoilsw.launcher.THEME"
|
||||
};
|
||||
private AlertDialog mDialog;
|
||||
private ListView mListView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.slim_recents);
|
||||
|
||||
mRecentPanelLeftyMode = (SwitchPreference) findPreference(RECENT_PANEL_LEFTY_MODE);
|
||||
mRecentPanelLeftyMode.setOnPreferenceChangeListener(this);
|
||||
mIconPack = findPreference(RECENT_ICON_PACK);
|
||||
|
||||
// Recent panel background color
|
||||
mRecentPanelBgColor = (ColorPickerPreference) findPreference(RECENT_PANEL_BG_COLOR);
|
||||
mRecentPanelBgColor.setOnPreferenceChangeListener(this);
|
||||
final int intColor = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_PANEL_BG_COLOR, 0x00ffffff);
|
||||
String hexColor = String.format("#%08x", (0x00ffffff & intColor));
|
||||
if (hexColor.equals("#00ffffff")) {
|
||||
mRecentPanelBgColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mRecentPanelBgColor.setSummary(hexColor);
|
||||
}
|
||||
mRecentPanelBgColor.setNewPreviewColor(intColor);
|
||||
|
||||
// Recent card background color
|
||||
mRecentCardBgColor = (ColorPickerPreference) findPreference(RECENT_CARD_BG_COLOR);
|
||||
mRecentCardBgColor.setOnPreferenceChangeListener(this);
|
||||
final int intColorCard = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_CARD_BG_COLOR, 0x00ffffff);
|
||||
String hexColorCard = String.format("#%08x", (0x00ffffff & intColorCard));
|
||||
if (hexColorCard.equals("#00ffffff")) {
|
||||
mRecentCardBgColor.setSummary(R.string.default_auto_string);
|
||||
} else {
|
||||
mRecentCardBgColor.setSummary(hexColorCard);
|
||||
}
|
||||
mRecentCardBgColor.setNewPreviewColor(intColorCard);
|
||||
|
||||
mMemBarColor = (ColorPickerPreference) findPreference(SLIM_MEM_BAR_COLOR);
|
||||
mMemBarColor.setOnPreferenceChangeListener(this);
|
||||
final int intMemColor = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.SLIM_MEM_BAR_COLOR, 0xffffffff);
|
||||
String hexMemColor = String.format("#%08x", (0xffffffff & intMemColor));
|
||||
if (hexMemColor.equals("#ffffffff")) {
|
||||
mMemBarColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mMemBarColor.setSummary(hexMemColor);
|
||||
}
|
||||
mMemBarColor.setNewPreviewColor(intMemColor);
|
||||
|
||||
mMemTextColor = (ColorPickerPreference) findPreference(SLIM_MEM_TEXT_COLOR);
|
||||
mMemTextColor.setOnPreferenceChangeListener(this);
|
||||
final int intTextColor = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.SLIM_MEM_TEXT_COLOR, 0xffffffff);
|
||||
String hexTextColor = String.format("#%08x", (0xffffffff & intTextColor));
|
||||
if (hexTextColor.equals("#ffffffff")) {
|
||||
mMemTextColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mMemTextColor.setSummary(hexTextColor);
|
||||
}
|
||||
mMemTextColor.setNewPreviewColor(intTextColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
boolean recentLeftyMode = Settings.System.getInt(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_PANEL_GRAVITY, Gravity.END) == Gravity.START;
|
||||
mRecentPanelLeftyMode.setChecked(recentLeftyMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mRecentPanelLeftyMode) {
|
||||
Settings.System.putInt(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_PANEL_GRAVITY,
|
||||
((Boolean) newValue) ? Gravity.START : Gravity.END);
|
||||
return true;
|
||||
} else if (preference == mRecentPanelBgColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#00ffffff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_PANEL_BG_COLOR,
|
||||
intHex, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mRecentCardBgColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#00ffffff")) {
|
||||
preference.setSummary(R.string.default_auto_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.RECENT_CARD_BG_COLOR,
|
||||
intHex, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mMemBarColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#ffffffff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.SLIM_MEM_BAR_COLOR,
|
||||
intHex, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mMemTextColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#ffffffff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putIntForUser(getContext().getContentResolver(),
|
||||
Settings.System.SLIM_MEM_TEXT_COLOR,
|
||||
intHex, UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (preference == mIconPack) {
|
||||
pickIconPack(getContext());
|
||||
return true;
|
||||
} else {
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
}
|
||||
|
||||
/** Slim Recents Icon Pack Dialog **/
|
||||
private void pickIconPack(final Context context) {
|
||||
if (mDialog != null) {
|
||||
return;
|
||||
}
|
||||
Map<String, IconPackInfo> supportedPackages = getSupportedPackages(context);
|
||||
if (supportedPackages.isEmpty()) {
|
||||
Toast.makeText(context, R.string.no_iconpacks_summary, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.dialog_pick_iconpack_title)
|
||||
.setOnDismissListener(this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setView(createDialogView(context, supportedPackages));
|
||||
mDialog = builder.show();
|
||||
}
|
||||
|
||||
private View createDialogView(final Context context, Map<String, IconPackInfo> supportedPackages) {
|
||||
final LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
final View view = inflater.inflate(R.layout.dialog_iconpack, null);
|
||||
final IconAdapter adapter = new IconAdapter(context, supportedPackages);
|
||||
|
||||
mListView = (ListView) view.findViewById(R.id.iconpack_list);
|
||||
mListView.setAdapter(adapter);
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
if (adapter.isCurrentIconPack(position)) {
|
||||
return;
|
||||
}
|
||||
String selectedPackage = adapter.getItem(position);
|
||||
Settings.System.putString(getContext().getContentResolver(),
|
||||
Settings.System.SLIM_RECENTS_ICON_PACK, selectedPackage);
|
||||
mDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (mDialog != null) {
|
||||
mDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class IconAdapter extends BaseAdapter {
|
||||
ArrayList<IconPackInfo> mSupportedPackages;
|
||||
LayoutInflater mLayoutInflater;
|
||||
String mCurrentIconPack;
|
||||
int mCurrentIconPackPosition = -1;
|
||||
|
||||
IconAdapter(Context ctx, Map<String, IconPackInfo> supportedPackages) {
|
||||
mLayoutInflater = LayoutInflater.from(ctx);
|
||||
mSupportedPackages = new ArrayList<IconPackInfo>(supportedPackages.values());
|
||||
Collections.sort(mSupportedPackages, new Comparator<IconPackInfo>() {
|
||||
@Override
|
||||
public int compare(IconPackInfo lhs, IconPackInfo rhs) {
|
||||
return lhs.label.toString().compareToIgnoreCase(rhs.label.toString());
|
||||
}
|
||||
});
|
||||
|
||||
Resources res = ctx.getResources();
|
||||
String defaultLabel = res.getString(R.string.default_iconpack_title);
|
||||
Drawable icon = res.getDrawable(android.R.drawable.sym_def_app_icon);
|
||||
mSupportedPackages.add(0, new IconPackInfo(defaultLabel, icon, ""));
|
||||
mCurrentIconPack = Settings.System.getString(ctx.getContentResolver(),
|
||||
Settings.System.SLIM_RECENTS_ICON_PACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mSupportedPackages.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItem(int position) {
|
||||
return (String) mSupportedPackages.get(position).packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isCurrentIconPack(int position) {
|
||||
return mCurrentIconPackPosition == position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = mLayoutInflater.inflate(R.layout.iconpack_view_radio, null);
|
||||
}
|
||||
IconPackInfo info = mSupportedPackages.get(position);
|
||||
TextView txtView = (TextView) convertView.findViewById(R.id.title);
|
||||
txtView.setText(info.label);
|
||||
ImageView imgView = (ImageView) convertView.findViewById(R.id.icon);
|
||||
imgView.setImageDrawable(info.icon);
|
||||
RadioButton radioButton = (RadioButton) convertView.findViewById(R.id.radio);
|
||||
boolean isCurrentIconPack = info.packageName.equals(mCurrentIconPack);
|
||||
radioButton.setChecked(isCurrentIconPack);
|
||||
if (isCurrentIconPack) {
|
||||
mCurrentIconPackPosition = position;
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, IconPackInfo> getSupportedPackages(Context context) {
|
||||
Intent i = new Intent();
|
||||
Map<String, IconPackInfo> packages = new HashMap<String, IconPackInfo>();
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
for (String action : sSupportedActions) {
|
||||
i.setAction(action);
|
||||
for (ResolveInfo r : packageManager.queryIntentActivities(i, 0)) {
|
||||
IconPackInfo info = new IconPackInfo(r, packageManager);
|
||||
packages.put(r.activityInfo.packageName, info);
|
||||
}
|
||||
}
|
||||
i = new Intent(Intent.ACTION_MAIN);
|
||||
for (String category : sSupportedCategories) {
|
||||
i.addCategory(category);
|
||||
for (ResolveInfo r : packageManager.queryIntentActivities(i, 0)) {
|
||||
IconPackInfo info = new IconPackInfo(r, packageManager);
|
||||
packages.put(r.activityInfo.packageName, info);
|
||||
}
|
||||
i.removeCategory(category);
|
||||
}
|
||||
return packages;
|
||||
}
|
||||
|
||||
private static class IconPackInfo {
|
||||
String packageName;
|
||||
CharSequence label;
|
||||
Drawable icon;
|
||||
|
||||
IconPackInfo(ResolveInfo r, PackageManager packageManager) {
|
||||
packageName = r.activityInfo.packageName;
|
||||
icon = r.loadIcon(packageManager);
|
||||
label = r.loadLabel(packageManager);
|
||||
}
|
||||
|
||||
IconPackInfo(){
|
||||
}
|
||||
|
||||
public IconPackInfo(String label, Drawable icon, String packageName) {
|
||||
this.label = label;
|
||||
this.icon = icon;
|
||||
this.packageName = packageName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
}
|
||||
294
src/com/cherish/settings/fragments/SlimRecentsBlacklist.java
Normal file
294
src/com/cherish/settings/fragments/SlimRecentsBlacklist.java
Normal file
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The ABC rom
|
||||
* Copyright (C) 2017 AICP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cherish.settings.fragments;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.R;
|
||||
import com.cherish.settings.preferences.PackageListAdapter;
|
||||
import com.cherish.settings.preferences.PackageListAdapter.PackageItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
public class SlimRecentsBlacklist extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String TAG = "SlimRecentsBlacklist";
|
||||
|
||||
private static final int DIALOG_BLACKLIST_APPS = 1;
|
||||
|
||||
private PackageListAdapter mPackageAdapter;
|
||||
private PackageManager mPackageManager;
|
||||
private PreferenceGroup mBlacklistPrefList;
|
||||
private Preference mAddBlacklistPref;
|
||||
private String mBlacklistPackageList;
|
||||
private Map<String, Package> mBlacklistPackages;
|
||||
|
||||
private AlertDialog mDialog;
|
||||
private ListView mListView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.slim_recents_blacklist);
|
||||
|
||||
initializeAllPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int dialogId) {
|
||||
switch (dialogId) {
|
||||
case DIALOG_BLACKLIST_APPS: {
|
||||
Dialog dialog;
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
|
||||
final ListView list = new ListView(getActivity());
|
||||
list.setAdapter(mPackageAdapter);
|
||||
alertDialog.setTitle(R.string.profile_choose_app);
|
||||
alertDialog.setView(list);
|
||||
dialog = alertDialog.create();
|
||||
list.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Add empty application definition, the user will be able to edit it later
|
||||
PackageItem info = (PackageItem) parent.getItemAtPosition(position);
|
||||
addCustomApplicationPref(info.packageName, mBlacklistPackages);
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
return super.onCreateDialog(dialogId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDialogMetricsCategory(int dialogId) {
|
||||
switch (dialogId) {
|
||||
case DIALOG_BLACKLIST_APPS:
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
refreshCustomApplicationPrefs();
|
||||
}
|
||||
|
||||
private void initializeAllPreferences() {
|
||||
mPackageManager = getActivity().getPackageManager();
|
||||
mPackageAdapter = new PackageListAdapter(getActivity());
|
||||
//mBlacklistPrefList = (PreferenceGroup) findPreference("blacklist_applications");
|
||||
mBlacklistPrefList = getPreferenceScreen();
|
||||
mBlacklistPrefList.setOrderingAsAdded(false);
|
||||
mBlacklistPackages = new HashMap<String, Package>();
|
||||
mAddBlacklistPref = findPreference("add_blacklist_packages");
|
||||
mAddBlacklistPref.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference == mAddBlacklistPref) {
|
||||
showDialog(DIALOG_BLACKLIST_APPS);
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.dialog_delete_title)
|
||||
.setMessage(R.string.dialog_delete_message)
|
||||
//.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
removeApplicationPref(preference.getKey(), mBlacklistPackages);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
|
||||
builder.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Application class
|
||||
*/
|
||||
private static class Package {
|
||||
public String name;
|
||||
/**
|
||||
* Stores all the application values in one call
|
||||
* @param name
|
||||
*/
|
||||
public Package(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(name);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static Package fromString(String value) {
|
||||
if (TextUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Package item = new Package(value);
|
||||
return item;
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private void refreshCustomApplicationPrefs() {
|
||||
if (!parsePackageList()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the Application Preferences
|
||||
if (mBlacklistPrefList != null) {
|
||||
mBlacklistPrefList.removeAll();
|
||||
|
||||
for (Package pkg : mBlacklistPackages.values()) {
|
||||
try {
|
||||
Preference pref = createPreferenceFromInfo(pkg);
|
||||
mBlacklistPrefList.addPreference(pref);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keep these at the top
|
||||
mAddBlacklistPref.setOrder(0);
|
||||
// Add 'add' options
|
||||
mBlacklistPrefList.addPreference(mAddBlacklistPref);
|
||||
}
|
||||
|
||||
private void addCustomApplicationPref(String packageName, Map<String,Package> map) {
|
||||
Package pkg = map.get(packageName);
|
||||
if (pkg == null) {
|
||||
pkg = new Package(packageName);
|
||||
map.put(packageName, pkg);
|
||||
savePackageList(false, map);
|
||||
refreshCustomApplicationPrefs();
|
||||
}
|
||||
}
|
||||
|
||||
private Preference createPreferenceFromInfo(Package pkg)
|
||||
throws PackageManager.NameNotFoundException {
|
||||
PackageInfo info = mPackageManager.getPackageInfo(pkg.name,
|
||||
PackageManager.GET_META_DATA);
|
||||
Preference pref =
|
||||
new Preference(getActivity());
|
||||
|
||||
pref.setKey(pkg.name);
|
||||
pref.setTitle(info.applicationInfo.loadLabel(mPackageManager));
|
||||
pref.setIcon(info.applicationInfo.loadIcon(mPackageManager));
|
||||
pref.setPersistent(false);
|
||||
pref.setOnPreferenceClickListener(this);
|
||||
return pref;
|
||||
}
|
||||
|
||||
private void removeApplicationPref(String packageName, Map<String,Package> map) {
|
||||
if (map.remove(packageName) != null) {
|
||||
savePackageList(false, map);
|
||||
refreshCustomApplicationPrefs();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean parsePackageList() {
|
||||
boolean parsed = false;
|
||||
final String blacklistString = Settings.System.getString(getActivity().getContentResolver(),
|
||||
Settings.System.SLIM_RECENTS_BLACKLIST_VALUES);
|
||||
|
||||
if (!TextUtils.equals(mBlacklistPackageList, blacklistString)) {
|
||||
mBlacklistPackageList = blacklistString;
|
||||
mBlacklistPackages.clear();
|
||||
parseAndAddToMap(blacklistString, mBlacklistPackages);
|
||||
parsed = true;
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
private void parseAndAddToMap(String baseString, Map<String,Package> map) {
|
||||
if (baseString == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] array = TextUtils.split(baseString, "\\|");
|
||||
for (String item : array) {
|
||||
if (TextUtils.isEmpty(item)) {
|
||||
continue;
|
||||
}
|
||||
Package pkg = Package.fromString(item);
|
||||
map.put(pkg.name, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
private void savePackageList(boolean preferencesUpdated, Map<String,Package> map) {
|
||||
String setting = Settings.System.SLIM_RECENTS_BLACKLIST_VALUES;
|
||||
|
||||
List<String> settings = new ArrayList<String>();
|
||||
for (Package app : map.values()) {
|
||||
settings.add(app.toString());
|
||||
}
|
||||
final String value = TextUtils.join("|", settings);
|
||||
if (preferencesUpdated) {
|
||||
mBlacklistPackageList = value;
|
||||
}
|
||||
Settings.System.putString(getActivity().getContentResolver(),
|
||||
setting, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user