Merge "Use PreferenceActivity and FragmentBreadCrumbs as they offer the same capabilities now."
This commit is contained in:
committed by
Android (Google) Code Review
commit
653abb13d8
@@ -1,168 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2008 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:title="@string/settings_label"
|
|
||||||
android:key="parent">
|
|
||||||
|
|
||||||
<!-- Operator hook -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:key="operator_settings">
|
|
||||||
<intent android:action="com.android.settings.OPERATOR_APPLICATION_SETTING" />
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Manufacturer hook -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:key="manufacturer_settings">
|
|
||||||
<intent android:action="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Wireless controls -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:title="@string/radio_controls_title"
|
|
||||||
android:fragment="com.android.settings.WirelessSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_wireless">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Call settings - this is in the phone process -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:key="call_settings"
|
|
||||||
settings:icon="@drawable/ic_settings_call"
|
|
||||||
android:title="@string/call_settings_title">
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.MAIN"
|
|
||||||
android:targetPackage="com.android.phone"
|
|
||||||
android:targetClass="com.android.phone.CallFeaturesSetting" />
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Sound -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
settings:icon="@drawable/ic_settings_sound"
|
|
||||||
android:fragment="com.android.settings.SoundSettings"
|
|
||||||
android:title="@string/sound_settings_title">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Display -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
settings:icon="@drawable/ic_settings_display"
|
|
||||||
android:fragment="com.android.settings.DisplaySettings"
|
|
||||||
android:title="@string/display_settings_title">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Security & Location -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.SecuritySettings"
|
|
||||||
settings:icon="@drawable/ic_settings_security"
|
|
||||||
android:title="@string/security_settings_title"
|
|
||||||
android:key="security_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Application Settings -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.ApplicationSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_applications"
|
|
||||||
android:title="@string/applications_settings"
|
|
||||||
android:key="applications_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Data Sync. The settings activity will ensure this is resolved to an
|
|
||||||
activity on the system image, otherwise it will remove this
|
|
||||||
preference. -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.ManageAccountsSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_sync"
|
|
||||||
android:title="@string/sync_settings"
|
|
||||||
android:key="sync_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Privacy -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.PrivacySettings"
|
|
||||||
settings:icon="@drawable/ic_settings_privacy"
|
|
||||||
android:title="@string/privacy_settings"
|
|
||||||
android:key="privacy_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Storage -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.deviceinfo.Memory"
|
|
||||||
settings:icon="@drawable/ic_settings_storage"
|
|
||||||
android:title="@string/storage_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Language -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.LanguageSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_language"
|
|
||||||
android:title="@string/language_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Voice input & output -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.VoiceInputOutputSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_speech"
|
|
||||||
android:title="@string/voice_input_output_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Accessibility feedback -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.AccessibilitySettings"
|
|
||||||
settings:icon="@drawable/ic_settings_accessibility"
|
|
||||||
android:title="@string/accessibility_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Dock -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:key="dock_settings"
|
|
||||||
android:fragment="com.android.settings.DockSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_dock"
|
|
||||||
android:title="@string/dock_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- Date & Time -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.DateTimeSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_date_time"
|
|
||||||
android:title="@string/date_and_time_settings_title">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
<!-- About Device -->
|
|
||||||
|
|
||||||
<com.android.settings.IconPreferenceScreen
|
|
||||||
android:fragment="com.android.settings.DeviceInfoSettings"
|
|
||||||
settings:icon="@drawable/ic_settings_about"
|
|
||||||
android:title="@string/about_settings">
|
|
||||||
</com.android.settings.IconPreferenceScreen>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
166
res/xml/settings_headers.xml
Normal file
166
res/xml/settings_headers.xml
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<preference-headers
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- Operator hook -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.WirelessSettings"
|
||||||
|
android:id="@+id/operator_settings">
|
||||||
|
<intent android:action="com.android.settings.OPERATOR_APPLICATION_SETTING" />
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Manufacturer hook -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.WirelessSettings"
|
||||||
|
android:id="@+id/manufacturer_settings">
|
||||||
|
<intent android:action="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Wireless controls -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:title="@string/radio_controls_title"
|
||||||
|
android:fragment="com.android.settings.WirelessSettings"
|
||||||
|
android:icon="@drawable/ic_settings_wireless">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Call settings - this is in the phone process -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:id="@+id/call_settings"
|
||||||
|
android:icon="@drawable/ic_settings_call"
|
||||||
|
android:title="@string/call_settings_title">
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.MAIN"
|
||||||
|
android:targetPackage="com.android.phone"
|
||||||
|
android:targetClass="com.android.phone.CallFeaturesSetting" />
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Sound -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:icon="@drawable/ic_settings_sound"
|
||||||
|
android:fragment="com.android.settings.SoundSettings"
|
||||||
|
android:title="@string/sound_settings_title">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Display -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:icon="@drawable/ic_settings_display"
|
||||||
|
android:fragment="com.android.settings.DisplaySettings"
|
||||||
|
android:title="@string/display_settings_title">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Security & Location -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.SecuritySettings"
|
||||||
|
android:icon="@drawable/ic_settings_security"
|
||||||
|
android:title="@string/security_settings_title"
|
||||||
|
android:id="@+id/security_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Application Settings -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.ApplicationSettings"
|
||||||
|
android:icon="@drawable/ic_settings_applications"
|
||||||
|
android:title="@string/applications_settings"
|
||||||
|
android:id="@+id/applications_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Data Sync. The settings activity will ensure this is resolved to an
|
||||||
|
activity on the system image, otherwise it will remove this
|
||||||
|
preference. -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.ManageAccountsSettings"
|
||||||
|
android:icon="@drawable/ic_settings_sync"
|
||||||
|
android:title="@string/sync_settings"
|
||||||
|
android:id="@+id/sync_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Privacy -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.PrivacySettings"
|
||||||
|
android:icon="@drawable/ic_settings_privacy"
|
||||||
|
android:title="@string/privacy_settings"
|
||||||
|
android:id="@+id/privacy_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Storage -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.deviceinfo.Memory"
|
||||||
|
android:icon="@drawable/ic_settings_storage"
|
||||||
|
android:title="@string/storage_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Language -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.LanguageSettings"
|
||||||
|
android:icon="@drawable/ic_settings_language"
|
||||||
|
android:title="@string/language_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Voice input & output -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.VoiceInputOutputSettings"
|
||||||
|
android:icon="@drawable/ic_settings_speech"
|
||||||
|
android:title="@string/voice_input_output_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Accessibility feedback -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.AccessibilitySettings"
|
||||||
|
android:icon="@drawable/ic_settings_accessibility"
|
||||||
|
android:title="@string/accessibility_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Dock -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:id="@+id/dock_settings"
|
||||||
|
android:fragment="com.android.settings.DockSettings"
|
||||||
|
android:icon="@drawable/ic_settings_dock"
|
||||||
|
android:title="@string/dock_settings">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Date & Time -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.DateTimeSettings"
|
||||||
|
android:icon="@drawable/ic_settings_date_time"
|
||||||
|
android:title="@string/date_and_time_settings_title">
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- About Device -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.android.settings.DeviceInfoSettings"
|
||||||
|
android:icon="@drawable/ic_settings_about"
|
||||||
|
android:title="@string/about_settings">
|
||||||
|
</header>
|
||||||
|
</preference-headers>
|
@@ -106,6 +106,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private ListPreference mLockAfter;
|
private ListPreference mLockAfter;
|
||||||
|
|
||||||
|
private SettingsObserver mSettingsObserver;
|
||||||
|
|
||||||
private final class SettingsObserver implements Observer {
|
private final class SettingsObserver implements Observer {
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
updateToggles();
|
updateToggles();
|
||||||
@@ -125,14 +127,24 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
createPreferenceHierarchy();
|
createPreferenceHierarchy();
|
||||||
|
|
||||||
updateToggles();
|
updateToggles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
// listen for Location Manager settings changes
|
// listen for Location Manager settings changes
|
||||||
Cursor settingsCursor = getContentResolver().query(Settings.Secure.CONTENT_URI, null,
|
Cursor settingsCursor = getContentResolver().query(Settings.Secure.CONTENT_URI, null,
|
||||||
"(" + Settings.System.NAME + "=?)",
|
"(" + Settings.System.NAME + "=?)",
|
||||||
new String[]{Settings.Secure.LOCATION_PROVIDERS_ALLOWED},
|
new String[]{Settings.Secure.LOCATION_PROVIDERS_ALLOWED},
|
||||||
null);
|
null);
|
||||||
mContentQueryMap = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, null);
|
mContentQueryMap = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, null);
|
||||||
mContentQueryMap.addObserver(new SettingsObserver());
|
mContentQueryMap.addObserver(mSettingsObserver = new SettingsObserver());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mContentQueryMap.deleteObserver(mSettingsObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PreferenceScreen createPreferenceHierarchy() {
|
private PreferenceScreen createPreferenceHierarchy() {
|
||||||
|
@@ -16,354 +16,61 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceFragment;
|
|
||||||
import android.preference.PreferenceGroup;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top-level settings activity to handle single pane and double pane UI layout.
|
* Top-level settings activity to handle single pane and double pane UI layout.
|
||||||
*/
|
*/
|
||||||
public class Settings extends Activity
|
public class Settings extends PreferenceActivity implements
|
||||||
implements PreferenceFragment.OnPreferenceStartFragmentCallback,
|
|
||||||
SettingsPreferenceFragment.OnStateListener,
|
|
||||||
SettingsPreferenceFragment.FragmentStarter {
|
SettingsPreferenceFragment.FragmentStarter {
|
||||||
|
|
||||||
private static final boolean DBG = false;
|
// TODO: Update Call Settings based on airplane mode state.
|
||||||
|
|
||||||
private static final String TAG = "Settings";
|
|
||||||
|
|
||||||
private static final String KEY_PARENT = "parent";
|
|
||||||
private static final String KEY_CALL_SETTINGS = "call_settings";
|
|
||||||
private static final String KEY_SYNC_SETTINGS = "sync_settings";
|
|
||||||
private static final String KEY_SEARCH_SETTINGS = "search_settings";
|
|
||||||
private static final String KEY_DOCK_SETTINGS = "dock_settings";
|
|
||||||
|
|
||||||
private static final String KEY_OPERATOR_SETTINGS = "operator_settings";
|
|
||||||
private static final String KEY_MANUFACTURER_SETTINGS = "manufacturer_settings";
|
|
||||||
|
|
||||||
public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment";
|
|
||||||
|
|
||||||
public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
|
|
||||||
|
|
||||||
private static final String BACK_STACK_PREFS = ":settings:prefs";
|
|
||||||
|
|
||||||
private View mPrefsPane;
|
|
||||||
private View mMainPane;
|
|
||||||
private boolean mSinglePane;
|
|
||||||
|
|
||||||
private BreadCrumbs mBreadCrumbs;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the activity with the top-level headers.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onBuildHeaders(List<Header> target) {
|
||||||
super.onCreate(savedInstanceState);
|
loadHeadersFromResource(R.xml.settings_headers, target);
|
||||||
setContentView(R.layout.settings_top_level);
|
|
||||||
mPrefsPane = findViewById(R.id.prefs);
|
|
||||||
mMainPane = findViewById(R.id.top_level);
|
|
||||||
mSinglePane = mMainPane == null;
|
|
||||||
if (mSinglePane) mMainPane = mPrefsPane;
|
|
||||||
|
|
||||||
final Intent intent = getIntent();
|
updateHeaderList(target);
|
||||||
String initialFragment = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
|
}
|
||||||
Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
|
||||||
|
|
||||||
createActionBar();
|
private void updateHeaderList(List<Header> target) {
|
||||||
|
int i = 0;
|
||||||
if (mSinglePane) {
|
while (i < target.size()) {
|
||||||
if (initialFragment != null) {
|
Header header = target.get(i);
|
||||||
showFragment(initialFragment, initialArguments);
|
long id = header.id;
|
||||||
} else {
|
if (id == R.id.dock_settings) {
|
||||||
// Intent#getCompontent() lets us get Fragment name, even when the Intent is
|
if (!needsDockSettings())
|
||||||
// given via <activity-alias>.
|
target.remove(header);
|
||||||
//
|
} else if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
|
||||||
// e.g. When we reach here via "ChildSetting" activity-alias,
|
Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header);
|
||||||
// we should get the name here instead of targetActivity ("Settings").
|
} else if (id == R.id.call_settings) {
|
||||||
if (intent.getComponent().getClassName().equals(this.getClass().getName())) {
|
if (!Utils.isVoiceCapable(this))
|
||||||
showFragment(TopLevelSettings.class.getName(), null);
|
target.remove(header);
|
||||||
} else {
|
|
||||||
showFragment(intent.getComponent().getClassName(), intent.getExtras());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!intent.getComponent().getClassName().equals(this.getClass().getName())) {
|
|
||||||
if (showFragment(intent.getComponent().getClassName(), intent.getExtras())) {
|
|
||||||
mMainPane.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Fragment topLevel = getFragmentManager().findFragmentById(R.id.top_level);
|
|
||||||
if (topLevel != null) {
|
|
||||||
((TopLevelSettings) topLevel).selectFirst();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (target.get(i) == header)
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createActionBar() {
|
private boolean needsDockSettings() {
|
||||||
LayoutInflater inflater = (LayoutInflater)
|
return getResources().getBoolean(R.bool.has_dock_settings);
|
||||||
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
View customNavBar = inflater.inflate(R.layout.settings_actionbar, null, false);
|
|
||||||
getActionBar().setCustomNavigationMode(customNavBar);
|
|
||||||
mBreadCrumbs = (BreadCrumbs) customNavBar.findViewById(R.id.bread_crumbs);
|
|
||||||
mBreadCrumbs.setActivity(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean showFragment(Preference preference) {
|
public boolean startFragment(Fragment caller, String fragmentClass, int requestCode,
|
||||||
if (mSinglePane) {
|
Bundle extras) {
|
||||||
startWithFragment(preference.getFragment(), preference.getExtras());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
mBreadCrumbs.clear();
|
|
||||||
return showFragment(preference.getFragment(), preference.getExtras());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startWithFragment(String fragmentName, Bundle args) {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
|
||||||
intent.setClass(this, getClass());
|
|
||||||
intent.putExtra(EXTRA_SHOW_FRAGMENT, fragmentName);
|
|
||||||
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean showFragment(String fragmentClass, Bundle extras) {
|
|
||||||
if (DBG) Log.d(TAG, "showFragment");
|
|
||||||
Fragment f = Fragment.instantiate(this, fragmentClass, extras);
|
|
||||||
if (f instanceof SettingsPreferenceFragment) {
|
|
||||||
SettingsPreferenceFragment spf = (SettingsPreferenceFragment) f;
|
|
||||||
spf.setOnStateListener(this);
|
|
||||||
spf.setFragmentStarter(this);
|
|
||||||
}
|
|
||||||
mBreadCrumbs.clear();
|
|
||||||
getFragmentManager().popBackStack(BACK_STACK_PREFS, POP_BACK_STACK_INCLUSIVE);
|
|
||||||
getFragmentManager().openTransaction().replace(R.id.prefs, f).commit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addToBreadCrumbs(Fragment fragment) {
|
|
||||||
final CharSequence title = ((PreferenceFragment) fragment)
|
|
||||||
.getPreferenceScreen().getTitle();
|
|
||||||
if (mSinglePane) {
|
|
||||||
mBreadCrumbs.clear();
|
|
||||||
}
|
|
||||||
mBreadCrumbs.push(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeFromBreadCrumbs(Fragment fragment) {
|
|
||||||
mBreadCrumbs.pop(((PreferenceFragment) fragment).getPreferenceScreen().getTitle());
|
|
||||||
mBreadCrumbs.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCreated(SettingsPreferenceFragment fragment) {
|
|
||||||
if (DBG) Log.d(TAG, "Fragment created " + fragment);
|
|
||||||
addToBreadCrumbs(fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDestroyed(SettingsPreferenceFragment fragment) {
|
|
||||||
Log.d(TAG, "Fragment destroyed " + fragment + " (name: " + fragment.getClass() + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
|
|
||||||
if (DBG) Log.d(TAG, "onPreferenceStartFragment");
|
|
||||||
return startFragment(caller, pref.getFragment(), -1, pref.getExtras());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean startFragment(
|
|
||||||
Fragment caller, String fragmentClass, int requestCode, Bundle extras) {
|
|
||||||
Fragment f = Fragment.instantiate(this, fragmentClass, extras);
|
Fragment f = Fragment.instantiate(this, fragmentClass, extras);
|
||||||
caller.setTargetFragment(f, requestCode);
|
caller.setTargetFragment(f, requestCode);
|
||||||
if (f instanceof SettingsPreferenceFragment) {
|
if (f instanceof SettingsPreferenceFragment) {
|
||||||
SettingsPreferenceFragment spf = (SettingsPreferenceFragment) f;
|
SettingsPreferenceFragment spf = (SettingsPreferenceFragment) f;
|
||||||
spf.setOnStateListener(this);
|
|
||||||
spf.setFragmentStarter(this);
|
spf.setFragmentStarter(this);
|
||||||
}
|
}
|
||||||
getFragmentManager().openTransaction().replace(R.id.prefs, f)
|
|
||||||
.addToBackStack(BACK_STACK_PREFS).commit();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
mBreadCrumbs.pop();
|
|
||||||
mBreadCrumbs.update();
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TopLevelSettings extends PreferenceFragment {
|
|
||||||
|
|
||||||
private IconPreferenceScreen mHighlightedPreference;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
// Load the preferences from an XML resource
|
|
||||||
addPreferencesFromResource(R.xml.settings);
|
|
||||||
|
|
||||||
updatePreferenceList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
updateCallSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCallSettings() {
|
|
||||||
Preference callSettings = findPreference(KEY_CALL_SETTINGS);
|
|
||||||
// Might have been removed in non-voice-capable devices
|
|
||||||
if (callSettings != null) {
|
|
||||||
callSettings.setEnabled(!AirplaneModeEnabler.isAirplaneModeOn(getActivity()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePreferenceList() {
|
|
||||||
final Activity activity = getActivity();
|
|
||||||
PreferenceGroup parent = (PreferenceGroup) findPreference(KEY_PARENT);
|
|
||||||
Preference dockSettings = parent.findPreference(KEY_DOCK_SETTINGS);
|
|
||||||
if (activity.getResources().getBoolean(R.bool.has_dock_settings) == false
|
|
||||||
&& dockSettings != null) {
|
|
||||||
parent.removePreference(dockSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(activity, parent,
|
|
||||||
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
|
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
|
||||||
// If it is a fragment preference, replace the prefs pane in the 2 pane UI.
|
|
||||||
final String fragmentClass = preference.getFragment();
|
|
||||||
if (fragmentClass != null) {
|
|
||||||
boolean showed = ((Settings) getActivity()).showFragment(preference);
|
|
||||||
if (showed) {
|
|
||||||
highlight(preference);
|
|
||||||
}
|
|
||||||
return showed;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void highlight(Preference preference) {
|
|
||||||
if (mHighlightedPreference != null) {
|
|
||||||
mHighlightedPreference.setHighlighted(false);
|
|
||||||
}
|
|
||||||
mHighlightedPreference = (IconPreferenceScreen) preference;
|
|
||||||
mHighlightedPreference.setHighlighted(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void selectFirst() {
|
|
||||||
Preference first = getPreferenceScreen().getPreference(0);
|
|
||||||
onPreferenceTreeClick(getPreferenceScreen(), first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class BreadCrumbs extends LinearLayout implements OnClickListener {
|
|
||||||
|
|
||||||
private ArrayList<CharSequence> mTitles = new ArrayList<CharSequence>();
|
|
||||||
private TextView mLevelUpTitle;
|
|
||||||
private TextView mCurrentLevelTitle;
|
|
||||||
private View mDivider;
|
|
||||||
private Activity mActivity;
|
|
||||||
|
|
||||||
public BreadCrumbs(Context context) {
|
|
||||||
this(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BreadCrumbs(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void push(CharSequence title) {
|
|
||||||
if (mTitles.size() == 0
|
|
||||||
|| !TextUtils.equals(title, mTitles.get(mTitles.size() - 1))) {
|
|
||||||
mTitles.add(title);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pop() {
|
|
||||||
if (mTitles.size() > 0) {
|
|
||||||
mTitles.remove(mTitles.size() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pop(CharSequence title) {
|
|
||||||
if (mTitles.size() > 1) {
|
|
||||||
mTitles.remove(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
mTitles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initNavViews() {
|
|
||||||
if (mLevelUpTitle == null) {
|
|
||||||
mLevelUpTitle = (TextView) findViewById(R.id.level_up_title);
|
|
||||||
mCurrentLevelTitle = (TextView) findViewById(R.id.level_current_title);
|
|
||||||
mDivider = findViewById(R.id.level_divider);
|
|
||||||
if (mLevelUpTitle != null) {
|
|
||||||
mLevelUpTitle.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
if (mCurrentLevelTitle != null) {
|
|
||||||
mCurrentLevelTitle.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
initNavViews();
|
|
||||||
if (mLevelUpTitle == null) return;
|
|
||||||
|
|
||||||
final int titleCount = mTitles.size();
|
|
||||||
if (titleCount > 1) {
|
|
||||||
mLevelUpTitle.setText(mTitles.get(titleCount - 2));
|
|
||||||
mLevelUpTitle.setVisibility(VISIBLE);
|
|
||||||
mDivider.setVisibility(VISIBLE);
|
|
||||||
} else {
|
|
||||||
mLevelUpTitle.setVisibility(GONE);
|
|
||||||
mDivider.setVisibility(GONE);
|
|
||||||
}
|
|
||||||
if (titleCount > 0) {
|
|
||||||
mCurrentLevelTitle.setText(mTitles.get(titleCount - 1));
|
|
||||||
} else {
|
|
||||||
mCurrentLevelTitle.setText("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActivity(Activity activity) {
|
|
||||||
mActivity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (mActivity == null)
|
|
||||||
return;
|
|
||||||
if (v == mLevelUpTitle) {
|
|
||||||
mActivity.onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,6 @@ import android.os.Environment;
|
|||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.util.Log;
|
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -220,8 +219,8 @@ public class TetherSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onStart() {
|
||||||
super.onResume();
|
super.onStart();
|
||||||
|
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
|
|
||||||
@@ -244,8 +243,8 @@ public class TetherSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onStop() {
|
||||||
super.onPause();
|
super.onStop();
|
||||||
getActivity().unregisterReceiver(mTetherChangeReceiver);
|
getActivity().unregisterReceiver(mTetherChangeReceiver);
|
||||||
mTetherChangeReceiver = null;
|
mTetherChangeReceiver = null;
|
||||||
mWifiApEnabler.pause();
|
mWifiApEnabler.pause();
|
||||||
|
@@ -37,9 +37,9 @@ import android.os.Bundle;
|
|||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.SettingNotFoundException;
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
import android.speech.tts.TextToSpeech;
|
import android.speech.tts.TextToSpeech;
|
||||||
@@ -126,6 +126,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
mDefaultLocVariant = currentLocale.getVariant();
|
mDefaultLocVariant = currentLocale.getVariant();
|
||||||
|
|
||||||
mTts = new TextToSpeech(activity, this);
|
mTts = new TextToSpeech(activity, this);
|
||||||
|
initClickers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +137,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
// whenever we return to this screen, we don't know the state of the
|
// whenever we return to this screen, we don't know the state of the
|
||||||
// system, so we have to recheck that we can play the demo, or it must be disabled.
|
// system, so we have to recheck that we can play the demo, or it must be disabled.
|
||||||
// TODO make the TTS service listen to "changes in the system", i.e. sd card un/mount
|
// TODO make the TTS service listen to "changes in the system", i.e. sd card un/mount
|
||||||
initClickers();
|
|
||||||
updateWidgetState();
|
updateWidgetState();
|
||||||
checkVoiceData();
|
checkVoiceData();
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
mTts.setLanguage(new Locale(mDefaultLanguage, mDefaultCountry, mDefaultLocVariant));
|
mTts.setLanguage(new Locale(mDefaultLanguage, mDefaultCountry, mDefaultLocVariant));
|
||||||
mTts.setSpeechRate(mDefaultRate/100.0f);
|
mTts.setSpeechRate(mDefaultRate/100.0f);
|
||||||
initDefaultSettings();
|
initDefaultSettings();
|
||||||
initClickers();
|
|
||||||
updateWidgetState();
|
updateWidgetState();
|
||||||
checkVoiceData();
|
checkVoiceData();
|
||||||
mTtsStarted = true;
|
mTtsStarted = true;
|
||||||
|
@@ -31,7 +31,6 @@ import android.provider.UserDictionary;
|
|||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@@ -39,7 +38,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.widget.AlphabetIndexer;
|
import android.widget.AlphabetIndexer;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
@@ -47,6 +46,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
import android.widget.SimpleCursorAdapter;
|
import android.widget.SimpleCursorAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -198,8 +198,10 @@ public class UserDictionarySettings extends ListFragment implements DialogCreata
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
MenuItem actionItem =
|
||||||
menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
|
menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
|
||||||
.setIcon(R.drawable.ic_menu_add);
|
.setIcon(R.drawable.ic_menu_add);
|
||||||
|
actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -20,8 +20,8 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.Resources.NotFoundException;
|
import android.content.res.Resources.NotFoundException;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -29,9 +29,9 @@ import android.os.Bundle;
|
|||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
|
import android.preference.PreferenceActivity.Header;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -203,6 +203,66 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean updateHeaderToSpecificActivityFromMetaDataOrRemove(Context context,
|
||||||
|
List<Header> target, Header header) {
|
||||||
|
|
||||||
|
Intent intent = header.intent;
|
||||||
|
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) {
|
||||||
|
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
|
||||||
|
// TODO:
|
||||||
|
//header.icon = icon;
|
||||||
|
header.title = title;
|
||||||
|
header.summary = summary;
|
||||||
|
// Replace the intent with this specific activity
|
||||||
|
header.intent = new Intent().setClassName(resolveInfo.activityInfo.packageName,
|
||||||
|
resolveInfo.activityInfo.name);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Did not find a matching activity, so remove the preference
|
||||||
|
if (target.remove(header)) System.err.println("Removed " + header.id);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if Monkey is running.
|
* Returns true if Monkey is running.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user