summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornebkat <nebkat@gmail.com>2011-11-30 16:28:21 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-08-06 17:42:49 +0100
commit25ffed506cfaff098462e73f5d4f6c19693f5147 (patch)
treefccb63abc2a90c489480854ddb6f71083bdef174 /src
parent12675a79c0dbc46a4b4edbe50b99c9b43c71d40b (diff)
downloadandroid_packages_apps_Trebuchet-25ffed506cfaff098462e73f5d4f6c19693f5147.tar.gz
android_packages_apps_Trebuchet-25ffed506cfaff098462e73f5d4f6c19693f5147.tar.bz2
android_packages_apps_Trebuchet-25ffed506cfaff098462e73f5d4f6c19693f5147.zip
Preferences: Hide search bar preference + others
- Restart Launcher on preferences changed - Implement "getCurrentOrientation()" Change-Id: I0728824ab994984c1dc798b61efa26b727ca3ea2
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java35
-rw-r--r--src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java49
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java22
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/Preferences.java10
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java9
5 files changed, 100 insertions, 25 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index b9de8fd6c..c44754096 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -95,7 +95,7 @@ import android.widget.Toast;
import com.android.common.Search;
import com.cyanogenmod.trebuchet.R;
import com.cyanogenmod.trebuchet.DropTarget.DragObject;
-import com.cyanogenmod.trebuchet.preference.Preferences;
+import com.cyanogenmod.trebuchet.preference.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -290,6 +290,9 @@ public final class Launcher extends Activity
private BubbleTextView mWaitingForResume;
+ // Preferences
+ private boolean mShowSearchBar;
+
private Runnable mBuildLayersRunnable = new Runnable() {
public void run() {
if (mWorkspace != null) {
@@ -340,6 +343,9 @@ public final class Launcher extends Activity
mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
mAppWidgetHost.startListening();
+ // Preferences
+ mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(this);
+
if (PROFILE_STARTUP) {
android.os.Debug.startMethodTracing(
Environment.getExternalStorageDirectory() + "/launcher");
@@ -677,6 +683,10 @@ public final class Launcher extends Activity
InstallShortcutReceiver.flushInstallQueue(this);
mPaused = false;
+ // Restart launcher when preferences are changed
+ if (preferencesChanged()) {
+ android.os.Process.killProcess(android.os.Process.myPid());
+ }
if (mRestoring || mOnResumeNeedsLoad) {
mWorkspaceLoading = true;
mModel.startLoader(true);
@@ -898,6 +908,11 @@ public final class Launcher extends Activity
// Get the search/delete bar
mSearchDropTargetBar = (SearchDropTargetBar) mDragLayer.findViewById(R.id.qsb_bar);
+ // Hide the search divider if we are hiding search bar
+ if (!mShowSearchBar && getCurrentOrientation() == Configuration.ORIENTATION_LANDSCAPE) {
+ ((View) findViewById(R.id.qsb_divider)).setVisibility(View.GONE);
+ }
+
// Setup AppsCustomize
mAppsCustomizeTabHost = (AppsCustomizeTabHost)
findViewById(R.id.apps_customize_pane);
@@ -2837,10 +2852,14 @@ public final class Launcher extends Activity
}
}
+ public int getCurrentOrientation() {
+ return getResources().getConfiguration().orientation;
+ }
+
/** Maps the current orientation to an index for referencing orientation correct global icons */
private int getCurrentOrientationIndexForGlobalIcons() {
// default - 0, landscape - 1
- switch (getResources().getConfiguration().orientation) {
+ switch (getCurrentOrientation()) {
case Configuration.ORIENTATION_LANDSCAPE:
return 1;
default:
@@ -3680,6 +3699,18 @@ public final class Launcher extends Activity
dismissCling(cling, Cling.FOLDER_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
}
+ public boolean preferencesChanged() {
+ SharedPreferences prefs =
+ getSharedPreferences(PreferencesProvider.PREFERENCES_KEY, Context.MODE_PRIVATE);
+ boolean preferencesChanged = prefs.getBoolean(PreferencesProvider.PREFERENCES_CHANGED, false);
+ if (preferencesChanged) {
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(PreferencesProvider.PREFERENCES_CHANGED, false);
+ editor.commit();
+ }
+ return preferencesChanged;
+ }
+
/**
* Prints out out state for debugging.
*/
diff --git a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
index c58178849..78112556e 100644
--- a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
+++ b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
@@ -28,6 +28,7 @@ import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
/*
* Ths bar will manage the transition between the QSB search bar and the delete drop
@@ -43,6 +44,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
private static final AccelerateInterpolator sAccelerateInterpolator =
new AccelerateInterpolator();
+ private boolean mShowQSBSearchBar;
+
private boolean mIsSearchBarHidden;
private View mQSBSearchBar;
private View mDropTargetBar;
@@ -60,6 +63,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
public SearchDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+
+ mShowQSBSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
}
public void setup(Launcher launcher, DragController dragController) {
@@ -108,6 +113,10 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
mEnableDropDownDropTargets =
getResources().getBoolean(R.bool.config_useDropTargetDownTransition);
+ if (!mShowQSBSearchBar) {
+ mQSBSearchBar.setVisibility(View.GONE);
+ }
+
// Create the various fade animations
if (mEnableDropDownDropTargets) {
mDropTargetBar.setTranslationY(-mBarHeight);
@@ -136,30 +145,34 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
*/
public void showSearchBar(boolean animated) {
if (!mIsSearchBarHidden) return;
- if (animated) {
- prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarAnim.reverse();
- } else {
- mQSBSearchBarAnim.cancel();
- if (mEnableDropDownDropTargets) {
- mQSBSearchBar.setTranslationY(0);
+ if (mShowQSBSearchBar) {
+ if (animated) {
+ prepareStartAnimation(mQSBSearchBar);
+ mQSBSearchBarAnim.reverse();
} else {
- mQSBSearchBar.setAlpha(1f);
+ mQSBSearchBarAnim.cancel();
+ if (mEnableDropDownDropTargets) {
+ mQSBSearchBar.setTranslationY(0);
+ } else {
+ mQSBSearchBar.setAlpha(1f);
+ }
}
}
mIsSearchBarHidden = false;
}
public void hideSearchBar(boolean animated) {
if (mIsSearchBarHidden) return;
- if (animated) {
- prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarAnim.start();
- } else {
- mQSBSearchBarAnim.cancel();
- if (mEnableDropDownDropTargets) {
- mQSBSearchBar.setTranslationY(-mBarHeight);
+ if (mShowQSBSearchBar) {
+ if (animated) {
+ prepareStartAnimation(mQSBSearchBar);
+ mQSBSearchBarAnim.start();
} else {
- mQSBSearchBar.setAlpha(0f);
+ mQSBSearchBarAnim.cancel();
+ if (mEnableDropDownDropTargets) {
+ mQSBSearchBar.setTranslationY(-mBarHeight);
+ } else {
+ mQSBSearchBar.setAlpha(0f);
+ }
}
}
mIsSearchBarHidden = true;
@@ -183,7 +196,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
// Animate out the QSB search bar, and animate in the drop target bar
prepareStartAnimation(mDropTargetBar);
mDropTargetBarAnim.start();
- if (!mIsSearchBarHidden) {
+ if (!mIsSearchBarHidden && mShowQSBSearchBar) {
prepareStartAnimation(mQSBSearchBar);
mQSBSearchBarAnim.start();
}
@@ -199,7 +212,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
// Restore the QSB search bar, and animate out the drop target bar
prepareStartAnimation(mDropTargetBar);
mDropTargetBarAnim.reverse();
- if (!mIsSearchBarHidden) {
+ if (!mIsSearchBarHidden && mShowQSBSearchBar) {
prepareStartAnimation(mQSBSearchBar);
mQSBSearchBarAnim.reverse();
}
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 38f4abbd4..b0ebfc6e8 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -30,6 +30,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;
@@ -58,6 +59,7 @@ import android.widget.TextView;
import com.cyanogenmod.trebuchet.R;
import com.cyanogenmod.trebuchet.FolderIcon.FolderRingAnimator;
import com.cyanogenmod.trebuchet.LauncherSettings.Favorites;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -256,6 +258,9 @@ public class Workspace extends SmoothPagedView
private float[] mNewRotationYs;
private float mTransitionProgress;
+ // Preferences
+ private boolean mShowSearchBar;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -334,6 +339,9 @@ public class Workspace extends SmoothPagedView
LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY);
setHapticFeedbackEnabled(false);
+ // Preferences
+ mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
+
mLauncher = (Launcher) context;
initWorkspace();
@@ -423,6 +431,14 @@ public class Workspace extends SmoothPagedView
// In this case, we will skip drawing background protection
}
+ if (!mShowSearchBar) {
+ int paddingTop = 0;
+ if (mLauncher.getCurrentOrientation() == Configuration.ORIENTATION_PORTRAIT) {
+ paddingTop = (int)res.getDimension(R.dimen.qsb_bar_hidden_inset);
+ }
+ setPadding(0, paddingTop, getPaddingRight(), getPaddingBottom());
+ }
+
mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
display.getSize(mDisplaySize);
@@ -3774,8 +3790,10 @@ public class Workspace extends SmoothPagedView
final View scrollIndicator = getScrollingIndicator();
cancelScrollingIndicatorAnimations();
- if (qsbDivider != null) qsbDivider.setAlpha(reducedFade);
- if (dockDivider != null) dockDivider.setAlpha(reducedFade);
+ if (mShowSearchBar) {
+ if (qsbDivider != null) qsbDivider.setAlpha(reducedFade);
+ if (dockDivider != null) dockDivider.setAlpha(reducedFade);
+ }
scrollIndicator.setAlpha(1 - fade);
}
}
diff --git a/src/com/cyanogenmod/trebuchet/preference/Preferences.java b/src/com/cyanogenmod/trebuchet/preference/Preferences.java
index c277bc397..d9e889970 100644
--- a/src/com/cyanogenmod/trebuchet/preference/Preferences.java
+++ b/src/com/cyanogenmod/trebuchet/preference/Preferences.java
@@ -16,9 +16,11 @@
package com.cyanogenmod.trebuchet.preference;
+import android.content.Context;
+import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.Preference;
import android.preference.PreferenceActivity;
+
import com.cyanogenmod.trebuchet.R;
public class Preferences extends PreferenceActivity {
@@ -29,5 +31,11 @@ public class Preferences extends PreferenceActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
+
+ SharedPreferences prefs =
+ getSharedPreferences(PreferencesProvider.PREFERENCES_KEY, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(PreferencesProvider.PREFERENCES_CHANGED, true);
+ editor.commit();
}
}
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 2a124021e..f6cc9d5d8 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -4,10 +4,15 @@ import android.content.Context;
import android.content.SharedPreferences;
public final class PreferencesProvider {
- private static final String PREFERENCES_FILE = "com.cyanogenmod.trebuchet_preferences";
+ public static final String PREFERENCES_KEY = "com.cyanogenmod.trebuchet_preferences";
+
+ public static final String PREFERENCES_CHANGED = "preferences_changed";
public static class Interface {
public static class Homescreen {
-
+ public static boolean getShowSearchBar(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_general_search", true);
+ }
}
public static class Drawer {