diff options
author | cretin45 <cretin45@gmail.com> | 2016-01-05 12:00:09 -0800 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2016-01-05 12:15:33 -0800 |
commit | 72f2ccb08f297836d18b61d5d80de9fcd7a69042 (patch) | |
tree | 4a500db5fa5bf3c87167fe2252e0e4db9dcb95e9 | |
parent | a20b046db71039ee581bb80274cf1fc450b3fd99 (diff) | |
download | packages_apps_Trebuchet-72f2ccb08f297836d18b61d5d80de9fcd7a69042.tar.gz packages_apps_Trebuchet-72f2ccb08f297836d18b61d5d80de9fcd7a69042.tar.bz2 packages_apps_Trebuchet-72f2ccb08f297836d18b61d5d80de9fcd7a69042.zip |
Trebuchet: Move allow rotation pref to overlay panel
Change-Id: I83feccbf5aac5de53ca578c4d62a25561d72b3ee
-rw-r--r-- | AndroidManifest.xml | 7 | ||||
-rw-r--r-- | res/values/config.xml | 1 | ||||
-rw-r--r-- | res/values/preferences_defaults.xml | 1 | ||||
-rw-r--r-- | res/xml/launcher_preferences.xml | 26 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/OverviewSettingsPanel.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/SettingsActivity.java | 76 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 21 | ||||
-rw-r--r-- | src/com/android/launcher3/settings/SettingsProvider.java | 1 |
10 files changed, 33 insertions, 121 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b6f02bed4..fb86691e9 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -161,13 +161,6 @@ </intent-filter> </activity> - <activity - android:name="com.android.launcher3.SettingsActivity" - android:label="@string/settings_button_text" - android:autoRemoveFromRecents="true" - android:process=":settings_process"> - </activity> - <!-- Debugging tools --> <activity android:name="com.android.launcher3.MemoryDumpActivity" diff --git a/res/values/config.xml b/res/values/config.xml index 93c6d14f4..4d3f01111 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -7,7 +7,6 @@ <bool name="config_largeHeap">false</bool> <bool name="is_tablet">false</bool> <bool name="is_large_tablet">false</bool> - <bool name="allow_rotation">false</bool> <!-- Max number of page indicators to show --> <integer name="config_maxNumberOfPageIndicatorsToShow">21</integer> diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml index 4413e7ba7..5917c20aa 100644 --- a/res/values/preferences_defaults.xml +++ b/res/values/preferences_defaults.xml @@ -10,4 +10,5 @@ <bool name="preferences_interface_use_scroller_default">true</bool> <bool name="preferences_interface_use_horizontal_scrubber_default">true</bool> <bool name="preferences_interface_drawer_search_default">true</bool> + <bool name="preferences_interface_allow_rotation">false</bool> </resources> diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml deleted file mode 100644 index 624d9eb2c..000000000 --- a/res/xml/launcher_preferences.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2015 Google Inc. - - 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"> - - <SwitchPreference - android:key="pref_allowRotation" - android:title="@string/allow_rotation_title" - android:defaultValue="@bool/allow_rotation" - android:persistent="true" - /> - -</PreferenceScreen> diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index f2bb46254..323b58256 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -601,7 +601,7 @@ public class Launcher extends Activity @Override public void onSettingsChanged(String settings, boolean value) { - if (Utilities.ALLOW_ROTATION_PREFERENCE_KEY.equals(settings)) { + if (SettingsProvider.SETTINGS_UI_ALLOW_ROTATION.equals(settings)) { mRotationEnabled = value; if (!waitUntilResume(mUpdateOrientationRunnable, true)) { mUpdateOrientationRunnable.run(); @@ -3157,7 +3157,7 @@ public class Launcher extends Activity if (mLauncherCallbacks != null) { mLauncherCallbacks.onClickSettingsButton(v); } else { - startActivity(new Intent(this, SettingsActivity.class)); + startSettings(); } } diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index d912eeffa..229b01991 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -51,7 +51,8 @@ public class OverviewSettingsPanel { String[] valuesApp = new String[] { res.getString(R.string.larger_icons_text), - res.getString(R.string.protected_app_settings)}; + res.getString(R.string.protected_app_settings), + res.getString(R.string.allow_rotation_title)}; mSettingsAdapter = new SettingsPinnedHeaderAdapter(mLauncher); mSettingsAdapter.setHeaders(headers); diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java deleted file mode 100644 index dab71c862..000000000 --- a/src/com/android/launcher3/SettingsActivity.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2015 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.launcher3; - -import android.app.Activity; -import android.os.Bundle; -import android.preference.Preference; -import android.preference.Preference.OnPreferenceChangeListener; -import android.preference.PreferenceFragment; -import android.preference.SwitchPreference; - -/** - * Settings activity for Launcher. Currently implements the following setting: Allow rotation - */ -public class SettingsActivity extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Display the fragment as the main content. - getFragmentManager().beginTransaction() - .replace(android.R.id.content, new LauncherSettingsFragment()) - .commit(); - } - - /** - * This fragment shows the launcher preferences. - */ - public static class LauncherSettingsFragment extends PreferenceFragment - implements OnPreferenceChangeListener { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.launcher_preferences); - - SwitchPreference pref = (SwitchPreference) findPreference( - Utilities.ALLOW_ROTATION_PREFERENCE_KEY); - pref.setPersistent(false); - - Bundle extras = new Bundle(); - extras.putBoolean(LauncherSettings.Settings.EXTRA_DEFAULT_VALUE, false); - Bundle value = getActivity().getContentResolver().call( - LauncherSettings.Settings.CONTENT_URI, - LauncherSettings.Settings.METHOD_GET_BOOLEAN, - Utilities.ALLOW_ROTATION_PREFERENCE_KEY, extras); - pref.setChecked(value.getBoolean(LauncherSettings.Settings.EXTRA_VALUE)); - - pref.setOnPreferenceChangeListener(this); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - Bundle extras = new Bundle(); - extras.putBoolean(LauncherSettings.Settings.EXTRA_VALUE, (Boolean) newValue); - getActivity().getContentResolver().call( - LauncherSettings.Settings.CONTENT_URI, - LauncherSettings.Settings.METHOD_SET_BOOLEAN, - preference.getKey(), extras); - return true; - } - } -} diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index d2c182c67..b51ef168a 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -25,7 +25,6 @@ import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -56,6 +55,8 @@ import android.util.TypedValue; import android.view.View; import android.widget.Toast; +import com.android.launcher3.settings.SettingsProvider; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -110,22 +111,19 @@ public final class Utilities { private static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher_force_rotate"; private static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY); - public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation"; - public static boolean isPropertyEnabled(String propertyName) { return Log.isLoggable(propertyName, Log.VERBOSE); } public static boolean isAllowRotationPrefEnabled(Context context, boolean multiProcess) { - SharedPreferences sharedPrefs = context.getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE | (multiProcess ? - Context.MODE_MULTI_PROCESS : 0)); - boolean allowRotationPref = sharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false); + boolean allowRotationPref = SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_ALLOW_ROTATION, + R.bool.preferences_interface_allow_rotation); return sForceEnableRotation || allowRotationPref; } public static boolean isRotationAllowedForDevice(Context context) { - return sForceEnableRotation || context.getResources().getBoolean(R.bool.allow_rotation); + return sForceEnableRotation || context.getResources().getBoolean(R.bool.preferences_interface_allow_rotation); } public static Bitmap createIconBitmap(Cursor c, int iconIndex, Context context) { diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index 2d140fcbb..31214e3d0 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -6,6 +6,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Typeface; +import android.os.Bundle; import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; @@ -17,6 +18,7 @@ import android.widget.TextView; import android.widget.Toast; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherSettings; import com.android.launcher3.OverviewSettingsPanel; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -183,6 +185,12 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { R.bool.preferences_interface_general_icons_large_default); setSettingSwitch(stateView, settingSwitch, current); break; + case 2: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_ALLOW_ROTATION, + R.bool.preferences_interface_allow_rotation); + setSettingSwitch(stateView, settingSwitch, current); + break; default: hideStates(stateView, settingSwitch); } @@ -320,6 +328,11 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { OverviewSettingsPanel.ANDROID_PROTECTED_APPS); mLauncher.startActivity(intent); break; + case 2: + onSettingsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_ALLOW_ROTATION, + R.bool.preferences_interface_allow_rotation); + break; } } @@ -358,6 +371,14 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { SettingsProvider.putBoolean(mContext, SettingsProvider.SETTINGS_CHANGED, true); ((Switch)v.findViewById(R.id.setting_switch)).setChecked(!current); + + Bundle extras = new Bundle(); + extras.putBoolean(LauncherSettings.Settings.EXTRA_VALUE, !current); + + mContext.getContentResolver().call( + LauncherSettings.Settings.CONTENT_URI, + LauncherSettings.Settings.METHOD_SET_BOOLEAN, + key, extras); } private void onIconLabelsBooleanChanged(View v, String key, int res) { diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java index d67619cbd..4357a451c 100644 --- a/src/com/android/launcher3/settings/SettingsProvider.java +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -37,6 +37,7 @@ public final class SettingsProvider { public static final String SETTINGS_UI_USE_HORIZONTAL_SCRUBBER = "ui_horizontal_scrubber"; public static final String SETTINGS_UI_DRAWER_SEARCH = "ui_drawer_search"; public static final String SETTINGS_UI_GENERAL_ICONS_LARGE = "ui_general_icons_large"; + public static final String SETTINGS_UI_ALLOW_ROTATION = "ui_allow_rotation"; public static SharedPreferences get(Context context) { return context.getSharedPreferences(SETTINGS_KEY, Context.MODE_PRIVATE); |