From 70acdc87e7932b59418cafb2a9de9c4a7797965f Mon Sep 17 00:00:00 2001 From: Oliver Scott Date: Tue, 27 Aug 2024 10:26:16 -0400 Subject: [PATCH] Settings: Expose clipboard auto clear setting [2/2] [someone5678] * Adapt to current project * Use Settings instead of DeviceConfig as GMS don't likes it * Add switch for clipboard auto clear * Import resources from CalyxOS and crDroid Android and adapt it * Update summary setting logic Ref: https://gitlab.com/CalyxOS/platform_packages_apps_Settings/-/commit/72db57c966dd996cb7a9106e52a6416c589df92d https://github.com/crdroidandroid/android_packages_apps_Settings/commit/48e00e2b812db5ea85253edaced9b1fc48db0efd https://github.com/crdroidandroid/android_packages_apps_crDroidSettings/commit/33c49aa70c9250d64b284af6ee46d5dad618497c https://github.com/crdroidandroid/android_packages_apps_crDroidSettings/commit/bc81eea9cce7d964b2a3f64ae318cd8d0c840adb Issue: calyxos#2208 Change-Id: Ie101177aba90ea085d83c0cb641ffed447cceecd Signed-off-by: someone5678 <59456192+someone5678@users.noreply.github.com> --- res/values/evolution_arrays.xml | 41 +++++++++++++ res/values/evolution_strings.xml | 15 +++++ res/xml/clipboard_auto_clear_settings.xml | 43 ++++++++++++++ res/xml/more_security_privacy_settings.xml | 6 ++ .../privacy/ClipboardAutoClearFragment.java | 58 +++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 res/xml/clipboard_auto_clear_settings.xml create mode 100644 src/com/android/settings/custom/privacy/ClipboardAutoClearFragment.java diff --git a/res/values/evolution_arrays.xml b/res/values/evolution_arrays.xml index 9b3731d455e..a72abeadd32 100644 --- a/res/values/evolution_arrays.xml +++ b/res/values/evolution_arrays.xml @@ -48,4 +48,45 @@ 14400000 28800000 + + + + @string/clipboard_auto_clear_timeout_disable_clipboard + @string/custom_timeout_summary_15secs + @string/custom_timeout_summary_30secs + @string/custom_timeout_summary_1min + @string/custom_timeout_summary_2mins + @string/custom_timeout_summary_5mins + @string/custom_timeout_summary_10mins + @string/custom_timeout_summary_30mins + @string/custom_timeout_summary_1hour_def + @string/custom_timeout_summary_2hours + @string/custom_timeout_summary_4hours + @string/custom_timeout_summary_8hours + @string/custom_timeout_summary_12hours + @string/custom_timeout_summary_24hours + @string/custom_timeout_summary_36hours + @string/custom_timeout_summary_48hours + @string/custom_timeout_summary_72hours + + + + 0 + 15000 + 30000 + 60000 + 120000 + 300000 + 600000 + 1800000 + 3600000 + 7200000 + 14400000 + 28800000 + 43200000 + 86400000 + 129600000 + 172800000 + 259200000 + diff --git a/res/values/evolution_strings.xml b/res/values/evolution_strings.xml index 70a32230875..793d27c2ea5 100644 --- a/res/values/evolution_strings.xml +++ b/res/values/evolution_strings.xml @@ -110,6 +110,14 @@ 2 hours 4 hours 8 hours + 12 hours + 24 hours + 36 hours + 48 hours + 72 hours + + + 1 hour (Default) Less than 1 Minute @@ -166,4 +174,11 @@ Double tap Double tap to check phone Pulse notifications by a double tap + + + Clipboard auto clear timeout + Clipboard auto clear + Automatically clear clipboard at the scheduled time + Use clipboard auto clear + Disable clipboard diff --git a/res/xml/clipboard_auto_clear_settings.xml b/res/xml/clipboard_auto_clear_settings.xml new file mode 100644 index 00000000000..00182b8d3f2 --- /dev/null +++ b/res/xml/clipboard_auto_clear_settings.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + diff --git a/res/xml/more_security_privacy_settings.xml b/res/xml/more_security_privacy_settings.xml index a3725c5b220..014d1e22226 100644 --- a/res/xml/more_security_privacy_settings.xml +++ b/res/xml/more_security_privacy_settings.xml @@ -129,6 +129,12 @@ android:fragment="com.android.settings.network.telephony.CellularSecuritySettingsFragment" settings:controller="com.android.settings.network.CellularSecurityPreferenceController" settings:searchable="false"/> + + diff --git a/src/com/android/settings/custom/privacy/ClipboardAutoClearFragment.java b/src/com/android/settings/custom/privacy/ClipboardAutoClearFragment.java new file mode 100644 index 00000000000..8a7b76762fe --- /dev/null +++ b/src/com/android/settings/custom/privacy/ClipboardAutoClearFragment.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 TheParasiteProject + * + * 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.android.settings.custom.privacy; + +import android.content.Context; +import android.os.Bundle; + +import com.android.internal.logging.nano.MetricsProto; +import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settingslib.search.SearchIndexable; + +import java.util.List; + +@SearchIndexable +public class ClipboardAutoClearFragment extends SettingsPreferenceFragment { + + public static final String TAG = "ClipboardAutoClearFragment"; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.clipboard_auto_clear_settings); + } + + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.EVOLVER; + } + + /** + * For search + */ + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider(R.xml.clipboard_auto_clear_settings) { + + @Override + public List getNonIndexableKeys(Context context) { + List keys = super.getNonIndexableKeys(context); + + return keys; + } + }; +}