summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-09-11 14:17:31 -0700
committerAmith Yamasani <yamasani@google.com>2010-09-11 14:58:01 -0700
commit60133dd03657354e06fa3aa7e6041862f8ce20a8 (patch)
tree91d3ebe624068a8061ce1055facf21e8a9690335
parentcc0e4db618d9bab9fc759c55ca49913704d2a7f0 (diff)
downloadpackages_apps_Settings-60133dd03657354e06fa3aa7e6041862f8ce20a8.zip
packages_apps_Settings-60133dd03657354e06fa3aa7e6041862f8ce20a8.tar.gz
packages_apps_Settings-60133dd03657354e06fa3aa7e6041862f8ce20a8.tar.bz2
Conditionally remove settings that aren't required on the tablet.
Bug: 2985267 Changes not done : SD card related stuff, as we need some way still to figure out if there is a real SD card in the device. Change-Id: I21c41f18ebe6c050981918481a7f6d69f04b65d0
-rw-r--r--res/xml/settings.xml15
-rw-r--r--res/xml/sound_settings.xml2
-rw-r--r--src/com/android/settings/AccessibilitySettings.java6
-rw-r--r--src/com/android/settings/RingerVolumePreference.java27
-rw-r--r--src/com/android/settings/Settings.java24
-rw-r--r--src/com/android/settings/SoundSettings.java17
-rw-r--r--src/com/android/settings/Utils.java16
7 files changed, 68 insertions, 39 deletions
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 7ec40ec..a91d279 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -116,21 +116,6 @@
android:title="@string/storage_settings">
</com.android.settings.IconPreferenceScreen>
- <!-- Search.
- The settings activity will ensure that this is resolved to an
- activity on the system image, otherwise it will remove this
- preference.
- The intent action is the same as
- android.app.SearchManager.INTENT_ACTION_SEARCH_SETTINGS.
- -->
-
- <com.android.settings.IconPreferenceScreen
- settings:icon="@drawable/ic_settings_search"
- android:title="@string/search_settings"
- android:key="search_settings">
- <intent android:action="android.search.action.SEARCH_SETTINGS" />
- </com.android.settings.IconPreferenceScreen>
-
<!-- Language -->
<com.android.settings.IconPreferenceScreen
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index b800d62..5e87793 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -46,6 +46,7 @@
android:streamType="ring" />
<PreferenceCategory
+ android:key="category_calls"
android:title="@string/sound_category_calls_title"/>
<com.android.settings.DefaultRingtonePreference
@@ -57,6 +58,7 @@
android:ringtoneType="ringtone" />
<PreferenceCategory
+ android:key="category_notification"
android:title="@string/sound_category_notification_title"/>
<!-- Do not nest these, or removals in code will break -->
diff --git a/src/com/android/settings/AccessibilitySettings.java b/src/com/android/settings/AccessibilitySettings.java
index 8892e96..321e956 100644
--- a/src/com/android/settings/AccessibilitySettings.java
+++ b/src/com/android/settings/AccessibilitySettings.java
@@ -136,7 +136,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
displayNoAppsAlert();
}
- if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)) {
+ if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
+ && Utils.isVoiceCapable(getActivity())) {
int incallPowerBehavior = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
@@ -148,7 +149,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
mPowerButtonEndsCallCheckBox.setChecked(powerButtonCheckboxEnabled);
mPowerButtonEndsCallCheckBox.setEnabled(true);
} else {
- // No POWER key on the current device; this entire category is irrelevant.
+ // No POWER key on the current device or no voice capability;
+ // this entire category is irrelevant.
getPreferenceScreen().removePreference(mPowerButtonCategory);
}
}
diff --git a/src/com/android/settings/RingerVolumePreference.java b/src/com/android/settings/RingerVolumePreference.java
index 3ecd819..4479cb0 100644
--- a/src/com/android/settings/RingerVolumePreference.java
+++ b/src/com/android/settings/RingerVolumePreference.java
@@ -45,6 +45,12 @@ public class RingerVolumePreference extends VolumePreference implements
R.id.media_volume_seekbar,
R.id.alarm_volume_seekbar
};
+
+ private static final int[] NEED_VOICE_CAPABILITY_ID = new int[] {
+ com.android.internal.R.id.seekbar, R.id.notification_volume_title,
+ R.id.notification_volume_seekbar
+ };
+
private static final int[] SEEKBAR_TYPE = new int[] {
AudioManager.STREAM_NOTIFICATION,
AudioManager.STREAM_MUSIC,
@@ -83,17 +89,28 @@ public class RingerVolumePreference extends VolumePreference implements
getContext().getContentResolver(),
Settings.System.NOTIFICATIONS_USE_RING_VOLUME, 1) == 1);
setNotificationVolumeVisibility(!mNotificationsUseRingVolumeCheckbox.isChecked());
+ disableSettingsThatNeedVoice(view);
+ }
+
+ private void disableSettingsThatNeedVoice(View parent) {
+ final boolean voiceCapable = getContext().getResources()
+ .getBoolean(com.android.internal.R.bool.config_voice_capable);
+ if (!voiceCapable) {
+ for (int id : NEED_VOICE_CAPABILITY_ID) {
+ parent.findViewById(id).setVisibility(View.GONE);
+ }
+ }
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
-
+
if (!positiveResult) {
for (SeekBarVolumizer vol : mSeekBarVolumizer) {
if (vol != null) vol.revertVolume();
}
- }
+ }
cleanup();
}
@@ -102,13 +119,13 @@ public class RingerVolumePreference extends VolumePreference implements
super.onActivityStop();
cleanup();
}
-
+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setNotificationVolumeVisibility(!isChecked);
-
+
Settings.System.putInt(getContext().getContentResolver(),
Settings.System.NOTIFICATIONS_USE_RING_VOLUME, isChecked ? 1 : 0);
-
+
if (isChecked) {
// The user wants the notification to be same as ring, so do a
// one-time sync right now
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 460ca96..2ce0bcc 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -18,7 +18,6 @@ package com.android.settings;
import android.app.Activity;
import android.app.Fragment;
-import android.app.Fragment.InstantiationException;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
@@ -130,17 +129,12 @@ public class Settings extends Activity
}
private boolean showFragment(String fragmentClass, Bundle extras) {
- try {
- Fragment f = Fragment.instantiate(this, fragmentClass, extras);
- if (f instanceof SettingsPreferenceFragment) {
- ((SettingsPreferenceFragment) f).setOnStateListener(this);
- }
- getFragmentManager().openTransaction().replace(R.id.prefs, f).commit();
- return true;
- } catch (InstantiationException exc) {
- Log.d(TAG, "Couldn't instantiate fragment " + fragmentClass);
- return false;
+ Fragment f = Fragment.instantiate(this, fragmentClass, extras);
+ if (f instanceof SettingsPreferenceFragment) {
+ ((SettingsPreferenceFragment) f).setOnStateListener(this);
}
+ getFragmentManager().openTransaction().replace(R.id.prefs, f).commit();
+ return true;
}
private void addToBreadCrumbs(Fragment fragment) {
@@ -209,9 +203,6 @@ public class Settings extends Activity
PreferenceGroup parent = (PreferenceGroup) findPreference(KEY_PARENT);
Utils.updatePreferenceToSpecificActivityOrRemove(activity, parent,
KEY_SYNC_SETTINGS, 0);
- Utils.updatePreferenceToSpecificActivityOrRemove(activity, parent,
- KEY_SEARCH_SETTINGS, 0);
-
Preference dockSettings = parent.findPreference(KEY_DOCK_SETTINGS);
if (activity.getResources().getBoolean(R.bool.has_dock_settings) == false
&& dockSettings != null) {
@@ -222,6 +213,11 @@ public class Settings extends Activity
KEY_OPERATOR_SETTINGS);
Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(activity, parent,
KEY_MANUFACTURER_SETTINGS);
+
+ Preference callSettings = parent.findPreference(KEY_CALL_SETTINGS);
+ if (!Utils.isVoiceCapable(activity) && callSettings != null) {
+ parent.removePreference(callSettings);
+ }
}
@Override
diff --git a/src/com/android/settings/SoundSettings.java b/src/com/android/settings/SoundSettings.java
index c5dad82..8582f17 100644
--- a/src/com/android/settings/SoundSettings.java
+++ b/src/com/android/settings/SoundSettings.java
@@ -49,12 +49,21 @@ public class SoundSettings extends SettingsPreferenceFragment implements
private static final String KEY_SOUND_SETTINGS = "sound_settings";
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
private static final String KEY_LOCK_SOUNDS = "lock_sounds";
+ private static final String KEY_RINGTONE = "ringtone";
+ private static final String KEY_NOTIFICATION_SOUND = "notification_sound";
+ private static final String KEY_CATEGORY_CALLS = "category_calls";
+ private static final String KEY_CATEGORY_NOTIFICATION = "category_notification";
private static final String VALUE_VIBRATE_NEVER = "never";
private static final String VALUE_VIBRATE_ALWAYS = "always";
private static final String VALUE_VIBRATE_ONLY_SILENT = "silent";
private static final String VALUE_VIBRATE_UNLESS_SILENT = "notsilent";
+ private static final String[] NEED_VOICE_CAPABILITY = {
+ KEY_RINGTONE, KEY_DTMF_TONE, KEY_CATEGORY_CALLS,
+ KEY_EMERGENCY_TONE
+ };
+
private CheckBoxPreference mSilent;
/*
@@ -145,6 +154,14 @@ public class SoundSettings extends SettingsPreferenceFragment implements
}
}
+ if (!Utils.isVoiceCapable(getActivity())) {
+ for (String prefKey : NEED_VOICE_CAPABILITY) {
+ Preference pref = findPreference(prefKey);
+ if (pref != null) {
+ getPreferenceScreen().removePreference(pref);
+ }
+ }
+ }
}
@Override
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index b29ec06..694bc1f 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -16,23 +16,24 @@
package com.android.settings;
+import java.util.List;
+
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.os.SystemProperties;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.SystemProperties;
import android.preference.Preference;
import android.preference.PreferenceGroup;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import java.util.List;
-
public class Utils {
/**
@@ -207,4 +208,13 @@ public class Utils {
public static boolean isMonkeyRunning() {
return SystemProperties.getBoolean("ro.monkey", false);
}
+
+ /**
+ * Returns whether the device is voice-capable (meaning, it is also a phone).
+ */
+ public static boolean isVoiceCapable(Context context) {
+ TelephonyManager telephony =
+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ return telephony != null && telephony.isVoiceCapable();
+ }
}