summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout-land/launcher.xml10
-rw-r--r--res/layout-port/launcher.xml10
-rw-r--r--res/layout-sw600dp/workspace.xml9
-rw-r--r--res/values/attrs.xml2
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/xml/preferences.xml16
-rw-r--r--src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java2
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java10
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java46
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java8
11 files changed, 68 insertions, 53 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 70dcd419f..8a75b8e02 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -29,19 +29,11 @@
android:layout_height="match_parent"
android:paddingLeft="@dimen/qsb_bar_height"
android:paddingRight="@dimen/button_bar_height"
- launcher:defaultScreen="2"
launcher:cellCountX="4"
launcher:cellCountY="4"
launcher:pageSpacing="@dimen/workspace_page_spacing"
launcher:scrollIndicatorPaddingLeft="@dimen/qsb_bar_height"
- launcher:scrollIndicatorPaddingRight="@dimen/button_bar_height">
-
- <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
- </com.cyanogenmod.trebuchet.Workspace>
+ launcher:scrollIndicatorPaddingRight="@dimen/button_bar_height" />
<include
android:id="@+id/qsb_divider"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index d1df03caf..db39f40a0 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -46,19 +46,11 @@
android:layout_height="match_parent"
android:paddingTop="@dimen/qsb_bar_height_inset"
android:paddingBottom="@dimen/button_bar_height"
- launcher:defaultScreen="2"
launcher:cellCountX="4"
launcher:cellCountY="4"
launcher:pageSpacing="@dimen/workspace_page_spacing"
launcher:scrollIndicatorPaddingLeft="@dimen/workspace_divider_padding_left"
- launcher:scrollIndicatorPaddingRight="@dimen/workspace_divider_padding_right">
-
- <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
- </com.cyanogenmod.trebuchet.Workspace>
+ launcher:scrollIndicatorPaddingRight="@dimen/workspace_divider_padding_right" />
<include layout="@layout/hotseat"
android:id="@+id/hotseat"
diff --git a/res/layout-sw600dp/workspace.xml b/res/layout-sw600dp/workspace.xml
index 699797734..699831945 100644
--- a/res/layout-sw600dp/workspace.xml
+++ b/res/layout-sw600dp/workspace.xml
@@ -20,11 +20,4 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.cyanogenmod.trebuchet"
android:paddingTop="@dimen/workspace_content_large_only_top_margin"
- launcher:defaultScreen="2"
- launcher:pageSpacing="@dimen/workspace_page_spacing">
- <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
- <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
-</com.cyanogenmod.trebuchet.Workspace> \ No newline at end of file
+ launcher:pageSpacing="@dimen/workspace_page_spacing" />
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 8eaabfea3..6ee34b184 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -37,8 +37,6 @@
<!-- Workspace specific attributes. These attributes are used to customize
the workspace in XML files. -->
<declare-styleable name="Workspace">
- <!-- The first screen the workspace should display. -->
- <attr name="defaultScreen" format="integer" />
<!-- The number of horizontal cells in the CellLayout -->
<attr name="cellCountX" format="integer" />
<!-- The number of vertical cells in the CellLayout -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 00b6c59f3..021d1d8ca 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -272,6 +272,10 @@ s -->
<!-- Homescreen -->
<string name="preferences_interface_homescreen_title">Homescreen</string>
<string name="preferences_interface_homescreen_general_category">General</string>
+ <string name="preferences_interface_homescreen_general_screens_title">Homescreens</string>
+ <string name="preferences_interface_homescreen_general_screens_summary">Number of screens on the homescreen</string>
+ <string name="preferences_interface_homescreen_general_default_screen_title">Default Screen</string>
+ <string name="preferences_interface_homescreen_general_default_screen_summary">Choose the default homescreen</string>
<string name="preferences_interface_homescreen_general_search_title">Search Bar</string>
<string name="preferences_interface_homescreen_general_search_summary">Enable persistent search bar</string>
<string name="preferences_interface_homescreen_general_resize_any_widget_title">Resize any widget</string>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index dc268303b..c552150dc 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -14,13 +14,27 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.cyanogenmod.trebuchet">
<!-- UI -->
<PreferenceCategory android:title="@string/preferences_interface_title">
<!-- Homescreen -->
<PreferenceScreen android:key="ui_homescreen"
android:title="@string/preferences_interface_homescreen_title">
<PreferenceCategory android:title="@string/preferences_interface_homescreen_general_category">
+ <com.cyanogenmod.trebuchet.preference.NumberPickerPreference android:key="ui_homescreen_screens"
+ android:title="@string/preferences_interface_homescreen_general_screens_title"
+ android:summary="@string/preferences_interface_homescreen_general_screens_summary"
+ android:defaultValue="5"
+ launcher:max="7"
+ launcher:min="1" />
+ <com.cyanogenmod.trebuchet.preference.NumberPickerPreference android:key="ui_homescreen_default_screen"
+ android:title="@string/preferences_interface_homescreen_general_default_screen_title"
+ android:summary="@string/preferences_interface_homescreen_general_default_screen_summary"
+ android:defaultValue="3"
+ launcher:maxExternal="ui_homescreen_screens"
+ launcher:max="7"
+ launcher:min="1" />
<CheckBoxPreference android:key="ui_homescreen_general_search"
android:title="@string/preferences_interface_homescreen_general_search_title"
android:summary="@string/preferences_interface_homescreen_general_search_summary"
diff --git a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
index 9452db838..eab8ff6a0 100644
--- a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
+++ b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
@@ -44,7 +44,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
if (!installShortcut(context, data, screen)) {
// The target screen is full, let's try the other screens
- for (int i = 0; i < Launcher.SCREEN_COUNT; i++) {
+ for (int i = 0; i < Launcher.MAX_SCREEN_COUNT; i++) {
if (i != screen && installShortcut(context, data, i)) break;
}
}
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index c713a6cbc..affc9dc0f 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -135,7 +135,7 @@ public final class Launcher extends Activity
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
- static final int SCREEN_COUNT = 5;
+ static final int MAX_SCREEN_COUNT = 7;
static final int DEFAULT_SCREEN = 2;
static final int DIALOG_CREATE_SHORTCUT = 1;
@@ -2931,7 +2931,7 @@ public final class Launcher extends Activity
if (mWorkspace != null) {
return mWorkspace.getCurrentPage();
} else {
- return SCREEN_COUNT / 2;
+ return DEFAULT_SCREEN;
}
}
diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 7e6b9863a..85c797802 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -926,13 +926,13 @@ public class LauncherModel extends BroadcastReceiver {
// We use the last index to refer to the hotseat and the screen as the rank, so
// test and update the occupied state accordingly
- if (occupied[Launcher.SCREEN_COUNT][item.screen][0] != null) {
+ if (occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0] != null) {
Log.e(TAG, "Error loading shortcut into hotseat " + item
+ " into position (" + item.screen + ":" + item.cellX + "," + item.cellY
- + ") occupied by " + occupied[Launcher.SCREEN_COUNT][item.screen][0]);
+ + ") occupied by " + occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0]);
return false;
} else {
- occupied[Launcher.SCREEN_COUNT][item.screen][0] = item;
+ occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0] = item;
return true;
}
} else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
@@ -986,7 +986,7 @@ public class LauncherModel extends BroadcastReceiver {
// Load workspace in reverse order to ensure that latest items are loaded first (and
// before any earlier duplicates)
final ItemInfo occupied[][][] =
- new ItemInfo[Launcher.SCREEN_COUNT + 1][mCellCountX + 1][mCellCountY + 1];
+ new ItemInfo[Launcher.MAX_SCREEN_COUNT + 1][mCellCountX + 1][mCellCountY + 1];
try {
final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
@@ -1194,7 +1194,7 @@ public class LauncherModel extends BroadcastReceiver {
Log.d(TAG, "workspace layout: ");
for (int y = 0; y < mCellCountY; y++) {
String line = "";
- for (int s = 0; s < Launcher.SCREEN_COUNT; s++) {
+ for (int s = 0; s < Launcher.MAX_SCREEN_COUNT; s++) {
if (s > 0) {
line += " | ";
}
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 7f95f9682..2b6a58e60 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -56,6 +56,7 @@ import android.util.Log;
import android.util.Pair;
import android.view.Display;
import android.view.DragEvent;
+import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -117,8 +118,6 @@ public class Workspace extends SmoothPagedView
private IBinder mWindowToken;
private static final float WALLPAPER_SCREENS_SPAN = 2f;
- private int mDefaultPage;
-
/**
* CellInfo for the cell that is currently being dragged
*/
@@ -240,6 +239,8 @@ public class Workspace extends SmoothPagedView
private float mTransitionProgress;
// Preferences
+ private int mNumberHomescreens;
+ private int mDefaultHomescreen;
private boolean mShowSearchBar;
private boolean mResizeAnyWidget;
private boolean mShowScrollingIndicator;
@@ -310,13 +311,18 @@ public class Workspace extends SmoothPagedView
// if the value is manually specified, use that instead
cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX);
cellCountY = a.getInt(R.styleable.Workspace_cellCountY, cellCountY);
- mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
a.recycle();
LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY);
setHapticFeedbackEnabled(false);
// Preferences
+ mNumberHomescreens = PreferencesProvider.Interface.Homescreen.getNumberHomescreens(context);
+ mDefaultHomescreen = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(context,
+ mNumberHomescreens / 2);
+ if (mDefaultHomescreen >= mNumberHomescreens) {
+ mDefaultHomescreen = mNumberHomescreens / 2;
+ }
mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context);
mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.getShowScrollingIndicator(context);
@@ -393,7 +399,7 @@ public class Workspace extends SmoothPagedView
*/
protected void initWorkspace() {
Context context = getContext();
- mCurrentPage = mDefaultPage;
+ mCurrentPage = mDefaultHomescreen;
Launcher.setScreen(mCurrentPage);
LauncherApplication app = (LauncherApplication)context.getApplicationContext();
mIconCache = app.getIconCache();
@@ -403,6 +409,12 @@ public class Workspace extends SmoothPagedView
final Resources res = getResources();
+ LayoutInflater inflater =
+ (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ for (int i = 0; i < mNumberHomescreens; i++) {
+ inflater.inflate(R.layout.workspace_screen, this);
+ }
+
try {
mBackground = res.getDrawable(R.drawable.apps_customize_bg);
} catch (Resources.NotFoundException e) {
@@ -1226,15 +1238,17 @@ public class Workspace extends SmoothPagedView
if (mOverScrollX < 0 || mOverScrollX > mMaxScrollX) {
int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
CellLayout cl = (CellLayout) getChildAt(index);
- float scrollProgress = getScrollProgress(screenScroll, cl, index);
- cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
- float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
- cl.setCameraDistance(mDensity * CAMERA_DISTANCE);
- cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
- cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
- cl.setRotationY(rotation);
- cl.setOverscrollTransformsDirty(true);
- setFadeForOverScroll(Math.abs(scrollProgress));
+ if (getChildCount() > 1) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, index);
+ cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
+ float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
+ cl.setCameraDistance(mDensity * CAMERA_DISTANCE);
+ cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+ cl.setRotationY(rotation);
+ cl.setOverscrollTransformsDirty(true);
+ setFadeForOverScroll(Math.abs(scrollProgress));
+ }
} else {
if (mOverscrollFade != 0) {
setFadeForOverScroll(0);
@@ -3533,12 +3547,12 @@ public class Workspace extends SmoothPagedView
void moveToDefaultScreen(boolean animate) {
if (!isSmall()) {
if (animate) {
- snapToPage(mDefaultPage);
+ snapToPage(mDefaultHomescreen);
} else {
- setCurrentPage(mDefaultPage);
+ setCurrentPage(mDefaultHomescreen);
}
}
- getChildAt(mDefaultPage).requestFocus();
+ getChildAt(mDefaultHomescreen).requestFocus();
}
@Override
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 9419e6c6d..1144be227 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -10,6 +10,14 @@ public final class PreferencesProvider {
public static class Interface {
public static class Homescreen {
+ public static int getNumberHomescreens(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getInt("ui_homescreen_screens", 5);
+ }
+ public static int getDefaultHomescreen(Context context, int def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getInt("ui_homescreen_default_screen", def + 1) - 1;
+ }
public static boolean getShowSearchBar(Context context) {
final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
return preferences.getBoolean("ui_homescreen_general_search", true);