summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--proguard.flags2
-rw-r--r--res/values/cm_strings.xml2
-rw-r--r--res/values/preferences_defaults.xml4
-rw-r--r--res/xml/preferences_headers.xml3
-rw-r--r--res/xml/preferences_homescreen.xml25
-rw-r--r--src/com/android/launcher3/DynamicGrid.java13
-rw-r--r--src/com/android/launcher3/Launcher.java8
-rw-r--r--src/com/android/launcher3/Workspace.java24
-rw-r--r--src/com/android/launcher3/settings/SettingsActivity.java14
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java20
10 files changed, 97 insertions, 18 deletions
diff --git a/proguard.flags b/proguard.flags
index 9b59b217e..ff2a51ec6 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -49,3 +49,5 @@
-keep class com.android.launcher3.MemoryDumpActivity {
*;
}
+
+-keep class com.android.launcher3.preference.Preferences$*Fragment
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 4da459fd2..320567826 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -16,6 +16,8 @@
<!-- Homescreen -->
<string name="preferences_interface_homescreen_title">Homescreen</string>
<string name="preferences_interface_homescreen_summary">Screens and wallpaper</string>
+ <string name="preferences_interface_homescreen_search_title">Search bar</string>
+ <string name="preferences_interface_homescreen_search_summary">Show persistent search bar at top of screen</string>
<!-- Drawer -->
<string name="preferences_interface_drawer_title">Drawer</string>
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml
new file mode 100644
index 000000000..99fe92405
--- /dev/null
+++ b/res/values/preferences_defaults.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <bool name="preferences_interface_homescreen_search_default">true</bool>
+</resources> \ No newline at end of file
diff --git a/res/xml/preferences_headers.xml b/res/xml/preferences_headers.xml
index c1975cabc..b90ec1eb4 100644
--- a/res/xml/preferences_headers.xml
+++ b/res/xml/preferences_headers.xml
@@ -17,6 +17,7 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
<header android:id="@+id/preferences_homescreen_section"
+ android:fragment="com.android.launcher3.settings.SettingsActivity$HomescreenFragment"
android:title="@string/preferences_interface_homescreen_title"
android:summary="@string/preferences_interface_homescreen_summary" />
@@ -35,4 +36,4 @@
<header android:id="@+id/preferences_application_version"
android:summary="@string/application_copyright" />
-</preference-headers> \ No newline at end of file
+</preference-headers>
diff --git a/res/xml/preferences_homescreen.xml b/res/xml/preferences_homescreen.xml
new file mode 100644
index 000000000..8b2652b9a
--- /dev/null
+++ b/res/xml/preferences_homescreen.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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:launcher="http://schemas.android.com/apk/res/com.android.launcher3"
+ android:key="ui_homescreen"
+ android:title="@string/preferences_interface_homescreen_title">
+ <CheckBoxPreference android:key="ui_homescreen_search"
+ android:title="@string/preferences_interface_homescreen_search_title"
+ android:summary="@string/preferences_interface_homescreen_search_summary"
+ android:defaultValue="@bool/preferences_interface_homescreen_search_default" />
+</PreferenceScreen>
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 4776c8668..57ddb3939 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -31,6 +31,7 @@ import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
+import com.android.launcher3.settings.SettingsProvider;
import java.util.ArrayList;
import java.util.Collections;
@@ -90,6 +91,7 @@ class DeviceProfile {
int hotseatAllAppsRank;
int allAppsNumRows;
int allAppsNumCols;
+ boolean searchBarVisible;
int searchBarSpaceWidthPx;
int searchBarSpaceMaxWidthPx;
int searchBarSpaceHeightPx;
@@ -182,10 +184,12 @@ class DeviceProfile {
updateFromConfiguration(resources, wPx, hPx, awPx, ahPx);
// Search Bar
+ searchBarVisible = SettingsProvider.getBoolean(SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
+ resources.getBoolean(R.bool.preferences_interface_homescreen_search_default));
searchBarSpaceMaxWidthPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width);
searchBarHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height);
searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx);
- searchBarSpaceHeightPx = searchBarHeightPx + 2 * edgeMarginPx;
+ searchBarSpaceHeightPx = searchBarHeightPx + (searchBarVisible ? 2 * edgeMarginPx : 0);
// Calculate the actual text height
Paint textPaint = new Paint();
@@ -303,7 +307,7 @@ class DeviceProfile {
if (orientation == CellLayout.LANDSCAPE &&
transposeLayoutWithOrientation) {
// Pad the left and right of the workspace with search/hotseat bar sizes
- padding.set(searchBarSpaceHeightPx, edgeMarginPx,
+ padding.set(searchBarVisible ? searchBarSpaceHeightPx : edgeMarginPx, edgeMarginPx,
hotseatBarHeightPx, edgeMarginPx);
} else {
if (isTablet()) {
@@ -317,13 +321,13 @@ class DeviceProfile {
int gap = (int) ((width - 2 * edgeMarginPx -
(numColumns * cellWidthPx)) / (2 * (numColumns + 1)));
padding.set(edgeMarginPx + gap,
- searchBarSpaceHeightPx,
+ searchBarVisible ? searchBarSpaceHeightPx : edgeMarginPx,
edgeMarginPx + gap,
hotseatBarHeightPx + pageIndicatorHeightPx);
} else {
// Pad the top and bottom of the workspace with search/hotseat bar sizes
padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
- searchBarSpaceHeightPx,
+ searchBarVisible ? searchBarSpaceHeightPx : edgeMarginPx,
desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.right,
hotseatBarHeightPx + pageIndicatorHeightPx);
}
@@ -393,6 +397,7 @@ class DeviceProfile {
// Layout the search bar
View qsbBar = launcher.getQsbBar();
+ qsbBar.setVisibility(searchBarVisible ? View.VISIBLE : View.GONE);
LayoutParams vglp = qsbBar.getLayoutParams();
vglp.width = LayoutParams.MATCH_PARENT;
vglp.height = LayoutParams.MATCH_PARENT;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index fb9e1da80..1df137d1d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -380,6 +380,9 @@ public class Launcher extends Activity
super.onCreate(savedInstanceState);
+ // Load all settings
+ SettingsProvider.load(this);
+
LauncherAppState.setApplicationContext(getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();
@@ -408,9 +411,6 @@ public class Launcher extends Activity
mDragController = new DragController(this);
mInflater = getLayoutInflater();
- // Load all settings
- SettingsProvider.load(this);
-
mStats = new Stats(this);
mAppWidgetManager = AppWidgetManager.getInstance(this);
@@ -839,7 +839,7 @@ public class Launcher extends Activity
super.onResume();
if (settingsChanged()) {
- finish();
+ android.os.Process.killProcess(android.os.Process.myPid());
}
// Restore the previous launcher state
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index f6416c84b..bea8c3057 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -32,6 +32,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -65,6 +66,7 @@ import android.widget.TextView;
import com.android.launcher3.FolderIcon.FolderRingAnimator;
import com.android.launcher3.Launcher.CustomContentCallbacks;
import com.android.launcher3.LauncherSettings.Favorites;
+import com.android.launcher3.settings.SettingsProvider;
import java.util.ArrayList;
import java.util.HashMap;
@@ -275,6 +277,8 @@ public class Workspace extends SmoothPagedView
}
};
+ private boolean mShowSearchBar;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -302,6 +306,9 @@ public class Workspace extends SmoothPagedView
// With workspace, data is available straight from the get-go
setDataIsReady();
+ mShowSearchBar = SettingsProvider.getBoolean(SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, context,
+ R.bool.preferences_interface_homescreen_search_default);
+
mLauncher = (Launcher) context;
final Resources res = getResources();
mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
@@ -2090,14 +2097,17 @@ public class Workspace extends SmoothPagedView
}
ObjectAnimator hotseatAlpha = ObjectAnimator.ofFloat(hotseat, "alpha",
finalHotseatAndPageIndicatorAlpha);
- ObjectAnimator searchBarAlpha = ObjectAnimator.ofFloat(searchBar,
- "alpha", finalSearchBarAlpha);
+ ObjectAnimator searchBarAlpha = null;
+ if (mShowSearchBar) {
+ searchBarAlpha = ObjectAnimator.ofFloat(searchBar,
+ "alpha", finalSearchBarAlpha);
+ }
ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel,
"alpha", finalOverviewPanelAlpha);
overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel));
hotseatAlpha.addListener(new AlphaUpdateListener(hotseat));
- searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));
+ if (mShowSearchBar) searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));
if (workspaceToOverview) {
hotseatAlpha.setInterpolator(new DecelerateInterpolator(2));
@@ -2111,7 +2121,7 @@ public class Workspace extends SmoothPagedView
anim.play(overviewPanelAlpha);
anim.play(hotseatAlpha);
- anim.play(searchBarAlpha);
+ if (mShowSearchBar) anim.play(searchBarAlpha);
anim.play(pageIndicatorAlpha);
anim.setStartDelay(delay);
} else {
@@ -2123,8 +2133,10 @@ public class Workspace extends SmoothPagedView
getPageIndicator().setAlpha(finalHotseatAndPageIndicatorAlpha);
AlphaUpdateListener.updateVisibility(getPageIndicator());
}
- searchBar.setAlpha(finalSearchBarAlpha);
- AlphaUpdateListener.updateVisibility(searchBar);
+ if (mShowSearchBar) {
+ searchBar.setAlpha(finalSearchBarAlpha);
+ AlphaUpdateListener.updateVisibility(searchBar);
+ }
updateCustomContentVisibility();
setScaleX(mNewScale);
setScaleY(mNewScale);
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index e9cf6fe1a..bad49b1a5 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -62,6 +62,11 @@ public class SettingsActivity extends PreferenceActivity
}
@Override
+ public boolean isValidFragment(String fragmentName) {
+ return true;
+ }
+
+ @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
@@ -113,6 +118,15 @@ public class SettingsActivity extends PreferenceActivity
editor.commit();
}
+ public static class HomescreenFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preferences_homescreen);
+ }
+ }
+
private static class HeaderAdapter extends ArrayAdapter<Header> {
private static final int HEADER_TYPE_NORMAL = 0;
private static final int HEADER_TYPE_CATEGORY = 1;
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java
index 30a7732b9..fdf2757df 100644
--- a/src/com/android/launcher3/settings/SettingsProvider.java
+++ b/src/com/android/launcher3/settings/SettingsProvider.java
@@ -26,6 +26,8 @@ public final class SettingsProvider {
public static final String SETTINGS_CHANGED = "settings_changed";
+ public static final String SETTINGS_UI_HOMESCREEN_SEARCH = "ui_homescreen_search";
+
private static Map<String, ?> sKeyValues;
public static void load(Context context) {
@@ -33,18 +35,30 @@ public final class SettingsProvider {
sKeyValues = preferences.getAll();
}
- private static int getInt(String key, int def) {
+ public static int getInt(String key, int def) {
return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Integer ?
(Integer) sKeyValues.get(key) : def;
}
- private static boolean getBoolean(String key, boolean def) {
+ public static int getInt(String key, Context context, int resource) {
+ return getInt(key, context.getResources().getInteger(resource));
+ }
+
+ public static boolean getBoolean(String key, boolean def) {
return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof Boolean ?
(Boolean) sKeyValues.get(key) : def;
}
- private static String getString(String key, String def) {
+ public static boolean getBoolean(String key, Context context, int resource) {
+ return getBoolean(key, context.getResources().getBoolean(resource));
+ }
+
+ public static String getString(String key, String def) {
return sKeyValues.containsKey(key) && sKeyValues.get(key) instanceof String ?
(String) sKeyValues.get(key) : def;
}
+
+ public static String getString(String key, Context context, int resource) {
+ return getString(key, context.getResources().getString(resource));
+ }
}