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
This commit is contained in:
@@ -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
|
||||
|
@@ -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 -->
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user