diff options
-rw-r--r-- | res/xml/security_settings_biometric_weak.xml | 2 | ||||
-rw-r--r-- | res/xml/security_settings_chooser.xml | 2 | ||||
-rw-r--r-- | res/xml/security_settings_encrypted.xml | 8 | ||||
-rw-r--r-- | res/xml/security_settings_lockscreen.xml | 2 | ||||
-rw-r--r-- | res/xml/security_settings_misc.xml | 20 | ||||
-rw-r--r-- | res/xml/security_settings_nfc_unlock.xml | 33 | ||||
-rw-r--r-- | res/xml/security_settings_password.xml | 2 | ||||
-rw-r--r-- | res/xml/security_settings_pin.xml | 2 | ||||
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 27 | ||||
-rw-r--r-- | src/com/android/settings/HighlightingFragment.java | 121 | ||||
-rw-r--r-- | src/com/android/settings/SettingsPreferenceFragment.java | 150 | ||||
-rw-r--r-- | src/com/android/settings/search/IndexDatabaseHelper.java | 2 |
12 files changed, 287 insertions, 84 deletions
diff --git a/res/xml/security_settings_biometric_weak.xml b/res/xml/security_settings_biometric_weak.xml index e0422f7..7226c6c 100644 --- a/res/xml/security_settings_biometric_weak.xml +++ b/res/xml/security_settings_biometric_weak.xml @@ -52,8 +52,8 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:fragment="com.android.settings.OwnerInfoSettings" android:key="owner_info_settings" + android:fragment="com.android.settings.OwnerInfoSettings" android:title="@string/owner_info_settings_title" android:summary="@string/owner_info_settings_summary"/> diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml index 57fed09..f6e2e89 100644 --- a/res/xml/security_settings_chooser.xml +++ b/res/xml/security_settings_chooser.xml @@ -27,8 +27,8 @@ android:persistent="false"/> <PreferenceScreen - android:fragment="com.android.settings.OwnerInfoSettings" android:key="owner_info_settings" + android:fragment="com.android.settings.OwnerInfoSettings" android:title="@string/owner_info_settings_title" android:summary="@string/owner_info_settings_summary"/> diff --git a/res/xml/security_settings_encrypted.xml b/res/xml/security_settings_encrypted.xml index e82dc56..37452f6 100644 --- a/res/xml/security_settings_encrypted.xml +++ b/res/xml/security_settings_encrypted.xml @@ -18,13 +18,13 @@ <PreferenceCategory android:key="security_category" - android:title="@string/crypt_keeper_settings_title" - > + android:title="@string/crypt_keeper_settings_title"> + <Preference style="?android:preferenceInformationStyle" + android:key="crypt_keeper_encrypt_title" android:title="@string/crypt_keeper_encrypt_title" - android:summary="@string/crypt_keeper_encrypted_summary" - /> + android:summary="@string/crypt_keeper_encrypted_summary"/> </PreferenceCategory> diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml index bb95463..abf06e3 100644 --- a/res/xml/security_settings_lockscreen.xml +++ b/res/xml/security_settings_lockscreen.xml @@ -27,8 +27,8 @@ android:persistent="false"/> <PreferenceScreen - android:fragment="com.android.settings.OwnerInfoSettings" android:key="owner_info_settings" + android:fragment="com.android.settings.OwnerInfoSettings" android:title="@string/owner_info_settings_title" android:summary="@string/owner_info_settings_summary"/> </PreferenceCategory> diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml index 58f92d8..84ce96c 100644 --- a/res/xml/security_settings_misc.xml +++ b/res/xml/security_settings_misc.xml @@ -20,7 +20,8 @@ android:title="@string/sim_lock_settings_title" android:persistent="false"> - <Preference android:title="@string/sim_lock_settings_category" + <Preference android:key="sim_lock_settings" + android:title="@string/sim_lock_settings_category" android:persistent="false"> <intent android:action="android.intent.action.MAIN" android:targetPackage="com.android.settings" @@ -40,25 +41,25 @@ android:title="@string/device_admin_title" android:persistent="false"> - <Preference android:title="@string/manage_device_admin" + <Preference android:key="manage_device_admin" + android:title="@string/manage_device_admin" android:summary="@string/manage_device_admin_summary" android:persistent="false" android:fragment="com.android.settings.DeviceAdminSettings"/> - <Preference android:title="@string/manage_trust_agents" + <Preference android:key="manage_trust_agents" + android:title="@string/manage_trust_agents" android:summary="@string/manage_trust_agents_summary" android:persistent="false" android:fragment="com.android.settings.TrustAgentSettings"/> - <CheckBoxPreference - android:key="toggle_install_applications" + <CheckBoxPreference android:key="toggle_install_applications" android:title="@string/install_applications" android:summaryOff="@string/install_unknown_applications" android:summaryOn="@string/install_unknown_applications" android:persistent="false" /> - <CheckBoxPreference - android:key="toggle_verify_applications" + <CheckBoxPreference android:key="toggle_verify_applications" android:title="@string/verify_applications" android:summaryOff="@string/verify_applications_summary" android:summaryOn="@string/verify_applications_summary" @@ -74,7 +75,8 @@ style="?android:attr/preferenceInformationStyle" android:persistent="false" /> - <Preference android:title="@string/trusted_credentials" + <Preference android:key="trusted_credentials" + android:title="@string/trusted_credentials" android:summary="@string/trusted_credentials_summary" android:persistent="false" android:fragment="com.android.settings.TrustedCredentialsSettings"/> @@ -88,7 +90,7 @@ android:targetClass="com.android.certinstaller.CertInstallerMain"/> </Preference> - <Preference android:key="reset_credentials" + <Preference android:key="credentials_reset" android:title="@string/credentials_reset" android:summary="@string/credentials_reset_summary" android:persistent="false"> diff --git a/res/xml/security_settings_nfc_unlock.xml b/res/xml/security_settings_nfc_unlock.xml index c3442c6..63e5a74 100644 --- a/res/xml/security_settings_nfc_unlock.xml +++ b/res/xml/security_settings_nfc_unlock.xml @@ -16,27 +16,28 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <PreferenceCategory - android:key="security_category" - android:title="@string/lock_settings_nfc_title"> + <PreferenceCategory + android:key="security_category" + android:title="@string/lock_settings_nfc_title"> + <CheckBoxPreference - android:key="nfc_unlock_enabled" - android:title="@string/nfc_unlock_enabled" - android:persistent="false" /> + android:key="nfc_unlock_enabled" + android:title="@string/nfc_unlock_enabled" + android:persistent="false" /> <Preference - android:title="@string/start_nfc_pairing" - android:key="nfc_pairing" - android:persistent="false" - android:dependency="nfc_unlock_enabled" > - <intent android:action="android.settings.PAIR_NFC_DEVICE"/> + android:key="nfc_pairing" + android:title="@string/start_nfc_pairing" + android:persistent="false" + android:dependency="nfc_unlock_enabled" > + <intent android:action="android.settings.PAIR_NFC_DEVICE"/> </Preference> - </PreferenceCategory> - <PreferenceCategory - android:key="nfc_unlock_tags_category" - android:title="@string/nfc_unlock_paired_tags_title"> + </PreferenceCategory> - </PreferenceCategory> + <PreferenceCategory + android:key="nfc_unlock_tags_category" + android:title="@string/nfc_unlock_paired_tags_title"> + </PreferenceCategory> </PreferenceScreen> diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml index c23f057..0380716 100644 --- a/res/xml/security_settings_password.xml +++ b/res/xml/security_settings_password.xml @@ -39,8 +39,8 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:fragment="com.android.settings.OwnerInfoSettings" android:key="owner_info_settings" + android:fragment="com.android.settings.OwnerInfoSettings" android:title="@string/owner_info_settings_title" android:summary="@string/owner_info_settings_summary"/> diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml index 65c7b0c..c114631 100644 --- a/res/xml/security_settings_pin.xml +++ b/res/xml/security_settings_pin.xml @@ -39,8 +39,8 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:fragment="com.android.settings.OwnerInfoSettings" android:key="owner_info_settings" + android:fragment="com.android.settings.OwnerInfoSettings" android:title="@string/owner_info_settings_title" android:summary="@string/owner_info_settings_summary"/> diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index 563a343..b5299ee 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -152,7 +152,7 @@ import java.util.Locale; * Panel showing data usage history across various networks, including options * to inspect based on usage cycle and control through {@link NetworkPolicy}. */ -public class DataUsageSummary extends Fragment implements Indexable { +public class DataUsageSummary extends HighlightingFragment implements Indexable { private static final String TAG = "DataUsage"; private static final boolean LOGD = false; @@ -351,6 +351,7 @@ public class DataUsageSummary extends Fragment implements Indexable { mDataEnabled = new Switch(inflater.getContext()); mDataEnabledView = inflatePreference(inflater, mNetworkSwitches, mDataEnabled); + mDataEnabledView.setTag("data_usage_enable_mobile"); mDataEnabled.setOnCheckedChangeListener(mDataEnabledListener); mNetworkSwitches.addView(mDataEnabledView); @@ -358,6 +359,7 @@ public class DataUsageSummary extends Fragment implements Indexable { mDisableAtLimit.setClickable(false); mDisableAtLimit.setFocusable(false); mDisableAtLimitView = inflatePreference(inflater, mNetworkSwitches, mDisableAtLimit); + mDisableAtLimitView.setTag("data_usage_disable_mobile_limit"); mDisableAtLimitView.setClickable(true); mDisableAtLimitView.setFocusable(true); mDisableAtLimitView.setOnClickListener(mDisableAtLimitListener); @@ -366,6 +368,7 @@ public class DataUsageSummary extends Fragment implements Indexable { // bind cycle dropdown mCycleView = mHeader.findViewById(R.id.cycles); + mCycleView.setTag("data_usage_cycle"); mCycleSpinner = (Spinner) mCycleView.findViewById(R.id.cycles_spinner); mCycleAdapter = new CycleAdapter(context); mCycleSpinner.setAdapter(mCycleAdapter); @@ -409,8 +412,8 @@ public class DataUsageSummary extends Fragment implements Indexable { } @Override - public void onResume() { - super.onResume(); + public void onViewStateRestored(Bundle savedInstanceState) { + super.onViewStateRestored(savedInstanceState); // pick default tab based on incoming intent final Intent intent = getActivity().getIntent(); @@ -419,6 +422,18 @@ public class DataUsageSummary extends Fragment implements Indexable { // this kicks off chain reaction which creates tabs, binds the body to // selected network, and binds chart, cycles and detail list. updateTabs(); + } + + @Override + public void onResume() { + super.onResume(); + + getView().post(new Runnable() { + @Override + public void run() { + highlightViewIfNeeded(); + } + }); // kick off background task to update stats new AsyncTask<Void, Void, Void>() { @@ -1729,6 +1744,7 @@ public class DataUsageSummary extends Fragment implements Indexable { final View view = dialogInflater.inflate(R.layout.data_usage_cycle_editor, null, false); final NumberPicker cycleDayPicker = (NumberPicker) view.findViewById(R.id.cycle_day); + cycleDayPicker.setTag("data_usage_cycle"); final NetworkTemplate template = getArguments().getParcelable(EXTRA_TEMPLATE); final int cycleDay = editor.getPolicyCycleDay(template); @@ -2403,18 +2419,21 @@ public class DataUsageSummary extends Fragment implements Indexable { // Mobile data data = new SearchIndexableRaw(context); + data.key = "data_usage_enable_mobile"; data.title = res.getString(R.string.data_usage_enable_mobile); data.screenTitle = res.getString(R.string.data_usage_summary_title); result.add(data); // Set mobile data limit data = new SearchIndexableRaw(context); + data.key = "data_usage_disable_mobile_limit"; data.title = res.getString(R.string.data_usage_disable_mobile_limit); data.screenTitle = res.getString(R.string.data_usage_summary_title); result.add(data); - // Data usage cycke + // Data usage cycle data = new SearchIndexableRaw(context); + data.key = "data_usage_cycle"; data.title = res.getString(R.string.data_usage_cycle); data.screenTitle = res.getString(R.string.data_usage_summary_title); result.add(data); diff --git a/src/com/android/settings/HighlightingFragment.java b/src/com/android/settings/HighlightingFragment.java new file mode 100644 index 0000000..7842044 --- /dev/null +++ b/src/com/android/settings/HighlightingFragment.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * 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; + +import android.app.Fragment; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import android.view.ViewGroup; + +public class HighlightingFragment extends Fragment { + + private static final String TAG = "HighlightSettingsFragment"; + + private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 300; + private static final String SAVE_HIGHLIGHTED_KEY = "android:view_highlighted"; + + private String mViewKey; + private boolean mViewHighlighted = false; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + if (icicle != null) { + mViewHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY); + } + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + + outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mViewHighlighted); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + final Bundle args = getArguments(); + if (args != null) { + mViewKey = args.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY); + highlightViewIfNeeded(); + } + } + + public void highlightViewIfNeeded() { + if (!mViewHighlighted &&!TextUtils.isEmpty(mViewKey)) { + highlightView(mViewKey); + } + } + + private Drawable getHighlightDrawable() { + return getResources().getDrawable(R.drawable.preference_highlight); + } + + private void highlightView(String key) { + final Drawable highlight = getHighlightDrawable(); + + // Try locating the View thru its Tag / Key + final View view = findViewForKey(getView(), key); + if (view != null ) { + view.setBackground(highlight); + + getView().postDelayed(new Runnable() { + @Override + public void run() { + final int centerX = view.getWidth() / 2; + final int centerY = view.getHeight() / 2; + highlight.setHotspot(0, centerX, centerY); + highlight.clearHotspots(); + } + }, DELAY_HIGHLIGHT_DURATION_MILLIS); + + mViewHighlighted = true; + } + } + + private View findViewForKey(View root, String key) { + if (checkTag(root, key)) { + return root; + } + if (root instanceof ViewGroup) { + final ViewGroup group = (ViewGroup) root; + final int count = group.getChildCount(); + for (int n = 0; n < count; n++) { + final View child = group.getChildAt(n); + final View view = findViewForKey(child, key); + if (view != null) { + return view; + } + } + } + return null; + } + + private boolean checkTag(View view, String key) { + final Object tag = view.getTag(); + if (tag == null || !(tag instanceof String)) { + return false; + } + final String viewKey = (String) tag; + return (!TextUtils.isEmpty(viewKey) && viewKey.equals(key)); + } +} diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index e27c9ed..5e0c06d 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -33,6 +33,8 @@ import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; import android.widget.Button; import android.widget.ListAdapter; import android.widget.ListView; @@ -45,7 +47,7 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di private static final String TAG = "SettingsPreferenceFragment"; private static final int MENU_HELP = Menu.FIRST + 100; - private static final int HIGHLIGHT_DURATION_MILLIS = 300; + private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 300; private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted"; @@ -56,6 +58,7 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di // Cache the content resolver for async callbacks private ContentResolver mContentResolver; + private String mPreferenceKey; private boolean mPreferenceHighlighted = false; @Override @@ -89,69 +92,126 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di final Bundle args = getArguments(); if (args != null) { - final String key = args.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY); - if (hasListView() && !TextUtils.isEmpty(key)) { - highlightPreference(key); - } + mPreferenceKey = args.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY); + highlightPreferenceIfNeeded(); + } + } + + @Override + protected void onBindPreferences() { + highlightPreferenceIfNeeded(); + } + + public void highlightPreferenceIfNeeded() { + if (!mPreferenceHighlighted &&!TextUtils.isEmpty(mPreferenceKey)) { + highlightPreference(mPreferenceKey); } } + private Drawable getHighlightDrawable() { + return getResources().getDrawable(R.drawable.preference_highlight); + } + + /** + * Return a valid ListView position or -1 if none is found + */ + private int canUseListViewForHighLighting(String key) { + if (!hasListView()) { + return -1; + } + + ListView listView = getListView(); + ListAdapter adapter = listView.getAdapter(); + + if (adapter != null && adapter instanceof PreferenceGroupAdapter) { + return findListPositionFromKey(adapter, key); + } + + return -1; + } + private void highlightPreference(String key) { - final int position = findPositionFromKey(key); + final Drawable highlight = getHighlightDrawable(); + + final int position = canUseListViewForHighLighting(key); if (position >= 0) { final ListView listView = getListView(); final ListAdapter adapter = listView.getAdapter(); - if (adapter instanceof PreferenceGroupAdapter) { - final Drawable drawable = getHighlightDrawable(); - ((PreferenceGroupAdapter) adapter).setHighlightedDrawable(drawable); - ((PreferenceGroupAdapter) adapter).setHighlighted(position); - - listView.post(new Runnable() { - @Override - public void run() { - listView.setSelection(position); - if (!mPreferenceHighlighted) { - listView.postDelayed(new Runnable() { - @Override - public void run() { - final int centerX = listView.getWidth() / 2; - final int centerY = listView.getChildAt(0).getHeight() / 2; - drawable.setHotspot(0, centerX, centerY); - drawable.clearHotspots(); - ((PreferenceGroupAdapter) adapter).setHighlighted(-1); - } - }, HIGHLIGHT_DURATION_MILLIS); - - mPreferenceHighlighted = true; + ((PreferenceGroupAdapter) adapter).setHighlightedDrawable(highlight); + ((PreferenceGroupAdapter) adapter).setHighlighted(position); + + listView.post(new Runnable() { + @Override + public void run() { + listView.setSelection(position); + listView.postDelayed(new Runnable() { + @Override + public void run() { + final int centerX = listView.getWidth() / 2; + final int centerY = listView.getChildAt(0).getHeight() / 2; + highlight.setHotspot(0, centerX, centerY); + highlight.clearHotspots(); + ((PreferenceGroupAdapter) adapter).setHighlighted(-1); } - } - }); + }, DELAY_HIGHLIGHT_DURATION_MILLIS); + + mPreferenceHighlighted = true; + } + }); + } else { + // Try locating the Preference View thru its tag + View preferenceView = findPreferenceViewForKey(getView(), key); + if (preferenceView != null ) { + preferenceView.setBackground(highlight); + final int centerX = preferenceView.getWidth() / 2; + final int centerY = preferenceView.getHeight() / 2; + highlight.setHotspot(0, centerX, centerY); + highlight.clearHotspots(); } } - } - private Drawable getHighlightDrawable() { - return getResources().getDrawable(R.drawable.preference_highlight); + private int findListPositionFromKey(ListAdapter adapter, String key) { + final int count = adapter.getCount(); + for (int n = 0; n < count; n++) { + final Object item = adapter.getItem(n); + if (item instanceof Preference) { + Preference preference = (Preference) item; + final String preferenceKey = preference.getKey(); + if (preferenceKey != null && preferenceKey.equals(key)) { + return n; + } + } + } + return -1; } - private int findPositionFromKey(String key) { - final ListAdapter adapter = getListView().getAdapter(); - if (adapter != null) { - final int count = adapter.getCount(); + private View findPreferenceViewForKey(View root, String key) { + if (checkTag(root, key)) { + return root; + } + if (root instanceof ViewGroup) { + final ViewGroup group = (ViewGroup) root; + final int count = group.getChildCount(); for (int n = 0; n < count; n++) { - Object item = adapter.getItem(n); - if (item instanceof Preference) { - Preference preference = (Preference) item; - final String preferenceKey = preference.getKey(); - if (preferenceKey != null && preferenceKey.equals(key)) { - return n; - } + final View child = group.getChildAt(n); + final View view = findPreferenceViewForKey(child, key); + if (view != null) { + return view; } } } - return -1; + return null; + } + + private boolean checkTag(View view, String key) { + final Object tag = view.getTag(); + if (tag == null || !(tag instanceof String)) { + return false; + } + final String prefKey = (String) tag; + return (!TextUtils.isEmpty(prefKey) && prefKey.equals(key)); } protected void removePreference(String key) { diff --git a/src/com/android/settings/search/IndexDatabaseHelper.java b/src/com/android/settings/search/IndexDatabaseHelper.java index 4e94cb1..19c4e20 100644 --- a/src/com/android/settings/search/IndexDatabaseHelper.java +++ b/src/com/android/settings/search/IndexDatabaseHelper.java @@ -28,7 +28,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper { private static final String TAG = "IndexDatabaseHelper"; private static final String DATABASE_NAME = "search_index.db"; - private static final int DATABASE_VERSION = 109; + private static final int DATABASE_VERSION = 110; public interface Tables { public static final String TABLE_PREFS_INDEX = "prefs_index"; |