summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-01-05 12:00:09 -0800
committercretin45 <cretin45@gmail.com>2016-01-05 12:15:33 -0800
commit72f2ccb08f297836d18b61d5d80de9fcd7a69042 (patch)
tree4a500db5fa5bf3c87167fe2252e0e4db9dcb95e9 /src/com/android
parenta20b046db71039ee581bb80274cf1fc450b3fd99 (diff)
downloadandroid_packages_apps_Trebuchet-72f2ccb08f297836d18b61d5d80de9fcd7a69042.tar.gz
android_packages_apps_Trebuchet-72f2ccb08f297836d18b61d5d80de9fcd7a69042.tar.bz2
android_packages_apps_Trebuchet-72f2ccb08f297836d18b61d5d80de9fcd7a69042.zip
Trebuchet: Move allow rotation pref to overlay panel
Change-Id: I83feccbf5aac5de53ca578c4d62a25561d72b3ee
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/Launcher.java4
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java3
-rw-r--r--src/com/android/launcher3/SettingsActivity.java76
-rw-r--r--src/com/android/launcher3/Utilities.java14
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java21
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java1
6 files changed, 32 insertions, 87 deletions
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);