summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2013-11-08 17:58:44 -0800
committerAdnan Begovic <adnan@cyngn.com>2015-10-29 17:36:27 -0700
commite116de1c0318e50200c7d82f3a31e08eaa3a189a (patch)
treeeb3b095d005550b00c9f7d348de4f5210c418903 /src
parent2ea9a80502df3cd28c4255b7250cd257755e9e2f (diff)
downloadpackages_apps_Settings-e116de1c0318e50200c7d82f3a31e08eaa3a189a.tar.gz
packages_apps_Settings-e116de1c0318e50200c7d82f3a31e08eaa3a189a.tar.bz2
packages_apps_Settings-e116de1c0318e50200c7d82f3a31e08eaa3a189a.zip
Settings : Add hooks for device specific features
Add support for : Devices with bluetooth input peripherals Devices with screen gesture support Devices with a back touchpad Change-Id: Ia4835c69a8ba8fb76597e0ab0540f8ef1ed6e322
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/ButtonSettings.java4
-rw-r--r--src/com/android/settings/SettingsActivity.java3
-rw-r--r--src/com/android/settings/Utils.java92
-rw-r--r--src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java2
4 files changed, 100 insertions, 1 deletions
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java
index 5ddfab15c..6cb6895c6 100644
--- a/src/com/android/settings/ButtonSettings.java
+++ b/src/com/android/settings/ButtonSettings.java
@@ -65,6 +65,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
private static final String KEY_NAVIGATION_BAR_LEFT = "navigation_bar_left";
private static final String KEY_POWER_END_CALL = "power_end_call";
private static final String KEY_HOME_ANSWER_CALL = "home_answer_call";
+ private static final String KEY_BLUETOOTH_INPUT_SETTINGS = "bluetooth_input_settings";
private static final String CATEGORY_POWER = "power_key";
private static final String CATEGORY_HOME = "home_key";
@@ -362,6 +363,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
if (!backlight.isButtonSupported() && !backlight.isKeyboardSupported()) {
prefScreen.removePreference(backlight);
}
+
+ Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(),
+ getPreferenceScreen(), KEY_BLUETOOTH_INPUT_SETTINGS);
}
@Override
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 09d97a6fd..d9ff0c386 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -1245,7 +1245,8 @@ public class SettingsActivity extends Activity
DashboardTile tile = category.getTile(n);
boolean removeTile = false;
id = (int) tile.id;
- if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
+ if (id == R.id.operator_settings || id == R.id.manufacturer_settings
+ || id == R.id.device_specific_gesture_settings) {
if (!Utils.updateTileToSpecificActivityFromMetaDataOrRemove(this, tile)) {
removeTile = true;
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 075194a6e..b1170c846 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -223,6 +223,98 @@ public final class Utils {
return false;
}
+ /**
+ * Finds a matching activity for a preference's intent. If a matching
+ * activity is not found, it will remove the preference. The icon, title and
+ * summary of the preference will also be updated with the values retrieved
+ * from the activity's meta-data elements. If no meta-data elements are
+ * specified then the preference title will be set to match the label of the
+ * activity, an icon and summary text will not be displayed.
+ *
+ * @param context The context.
+ * @param parentPreferenceGroup The preference group that contains the
+ * preference whose intent is being resolved.
+ * @param preferenceKey The key of the preference whose intent is being
+ * resolved.
+ *
+ * @return Whether an activity was found. If false, the preference was
+ * removed.
+ *
+ * @see {@link #META_DATA_PREFERENCE_ICON}
+ * {@link #META_DATA_PREFERENCE_TITLE}
+ * {@link #META_DATA_PREFERENCE_SUMMARY}
+ */
+ public static boolean updatePreferenceToSpecificActivityFromMetaDataOrRemove(Context context,
+ PreferenceGroup parentPreferenceGroup, String preferenceKey) {
+
+ Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
+ if (preference == null) {
+ return false;
+ }
+
+ Intent intent = preference.getIntent();
+ if (intent != null) {
+ // Find the activity that is in the system image
+ PackageManager pm = context.getPackageManager();
+ List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
+ int listSize = list.size();
+ for (int i = 0; i < listSize; i++) {
+ ResolveInfo resolveInfo = list.get(i);
+ if ((resolveInfo.activityInfo.applicationInfo.flags
+ & ApplicationInfo.FLAG_SYSTEM) != 0) {
+ Drawable icon = null;
+ String title = null;
+ String summary = null;
+
+ // Get the activity's meta-data
+ try {
+ Resources res = pm
+ .getResourcesForApplication(resolveInfo.activityInfo.packageName);
+ Bundle metaData = resolveInfo.activityInfo.metaData;
+
+ if (res != null && metaData != null) {
+ if (preference instanceof IconPreferenceScreen) {
+ icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
+ }
+ title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
+ summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
+ }
+ } catch (NameNotFoundException e) {
+ // Ignore
+ } catch (NotFoundException e) {
+ // Ignore
+ }
+
+ // Set the preference title to the activity's label if no
+ // meta-data is found
+ if (TextUtils.isEmpty(title)) {
+ title = resolveInfo.loadLabel(pm).toString();
+ }
+
+ // Set icon, title and summary for the preference
+ preference.setTitle(title);
+ preference.setSummary(summary);
+ if (preference instanceof IconPreferenceScreen) {
+ IconPreferenceScreen iconPreference = (IconPreferenceScreen) preference;
+ iconPreference.setIcon(icon);
+ }
+
+ // Replace the intent with this specific activity
+ preference.setIntent(new Intent().setClassName(
+ resolveInfo.activityInfo.packageName,
+ resolveInfo.activityInfo.name));
+
+ return true;
+ }
+ }
+ }
+
+ // Did not find a matching activity, so remove the preference
+ parentPreferenceGroup.removePreference(preference);
+
+ return false;
+ }
+
public static boolean updateTileToSpecificActivityFromMetaDataOrRemove(Context context,
DashboardTile tile) {
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index e8ef5ef34..7d39fa174 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -84,6 +84,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
private static final String KEY_INPUT_METHOD_SELECTOR = "input_method_selector";
private static final String KEY_USER_DICTIONARY_SETTINGS = "key_user_dictionary_settings";
private static final String KEY_PREVIOUSLY_ENABLED_SUBTYPES = "previously_enabled_subtypes";
+ private static final String KEY_TRACKPAD_SETTINGS = "gesture_pad_settings";
+
// false: on ICS or later
private static final boolean SHOW_INPUT_METHOD_SWITCHER_SETTINGS = false;