summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2013-10-25 00:44:54 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-10-25 00:44:54 (GMT)
commit6298efc9d9b6cdde873cbfa3e782dbdcf6a2d932 (patch)
treeb1668ddccd60bdd129608b5c60d148808873ff60
parent98d61cd22136fbcf2243f1448373c4b8a73abf7d (diff)
parenta39739b8104131f098c0fc1680b063fd7d12bad7 (diff)
downloadandroid_packages_apps_Trebuchet-6298efc9d9b6cdde873cbfa3e782dbdcf6a2d932.zip
android_packages_apps_Trebuchet-6298efc9d9b6cdde873cbfa3e782dbdcf6a2d932.tar.gz
android_packages_apps_Trebuchet-6298efc9d9b6cdde873cbfa3e782dbdcf6a2d932.tar.bz2
Merge "Revert "Trebuchet : Fix dynamic padding"" into cm-10.2
-rw-r--r--res/values/cm_strings.xml2
-rw-r--r--res/xml/preferences_homescreen.xml4
-rw-r--r--src/com/cyanogenmod/trebuchet/CellLayout.java27
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java11
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java3
5 files changed, 28 insertions, 19 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 4fad354..5ef593b 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -81,6 +81,8 @@
<string name="preferences_interface_homescreen_general_grid_summary">Choose the number of rows/columns on the homescreen</string>
<string name="preferences_interface_homescreen_general_grid_rows_title">Rows</string>
<string name="preferences_interface_homescreen_general_grid_columns_title">Columns</string>
+ <string name="preferences_interface_homescreen_general_stretch_screens_title">Stretch screens</string>
+ <string name="preferences_interface_homescreen_general_stretch_screens_summary">Expand homescreens to fill the size of display</string>
<string name="preferences_interface_homescreen_general_hide_icon_labels_title">Hide icon labels</string>
<string name="preferences_interface_homescreen_general_hide_icon_labels_summary">Hide homescreen icon labels</string>
<string name="preferences_interface_homescreen_scrolling_category">Scrolling</string>
diff --git a/res/xml/preferences_homescreen.xml b/res/xml/preferences_homescreen.xml
index 1834225..ec4ef8d 100644
--- a/res/xml/preferences_homescreen.xml
+++ b/res/xml/preferences_homescreen.xml
@@ -45,6 +45,10 @@
launcher:maxExternal="ui_homescreen_screens"
launcher:max="5"
launcher:min="1" />
+ <CheckBoxPreference android:key="ui_homescreen_stretch_screens"
+ android:title="@string/preferences_interface_homescreen_general_stretch_screens_title"
+ android:summary="@string/preferences_interface_homescreen_general_stretch_screens_summary"
+ android:defaultValue="true" />
<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/CellLayout.java b/src/com/cyanogenmod/trebuchet/CellLayout.java
index 2118a95..eab7d1e 100644
--- a/src/com/cyanogenmod/trebuchet/CellLayout.java
+++ b/src/com/cyanogenmod/trebuchet/CellLayout.java
@@ -74,6 +74,7 @@ public class CellLayout extends ViewGroup {
private int mOriginalHeightGap;
private int mWidthGap;
private int mHeightGap;
+ private int mMaxGap;
private boolean mScrollingTransformsDirty = false;
private final Rect mRect = new Rect();
@@ -190,6 +191,7 @@ public class CellLayout extends ViewGroup {
mCellHeight = mOriginalCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
mWidthGap = mOriginalWidthGap = a.getDimensionPixelSize(R.styleable.CellLayout_widthGap, 0);
mHeightGap = mOriginalHeightGap = a.getDimensionPixelSize(R.styleable.CellLayout_heightGap, 0);
+ mMaxGap = a.getDimensionPixelSize(R.styleable.CellLayout_maxGap, 0);
mCountX = LauncherModel.getWorkspaceCellCountX();
mCountY = LauncherModel.getWorkspaceCellCountY();
mOccupied = new boolean[mCountX][mCountY];
@@ -281,6 +283,11 @@ public class CellLayout extends ViewGroup {
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context);
+ if (!LauncherApplication.isScreenLarge()){
+ mCellWidth = (mCellWidth * res.getInteger(R.integer.default_cell_count_x)) / mCountX;
+ mCellHeight = (mCellHeight * res.getInteger(R.integer.default_cell_count_y)) / mCountY;
+ }
+
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
addView(mShortcutsAndWidgets);
}
@@ -992,26 +999,10 @@ public class CellLayout extends ViewGroup {
if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) {
int hSpace = widthSpecSize - getPaddingLeft() - getPaddingRight();
int vSpace = heightSpecSize - getPaddingTop() - getPaddingBottom();
-
- if (hSpace - (mCountX * mCellWidth) < 0) {
- mCellWidth = hSpace / mCountX;
- }
- if (vSpace - (mCountY * mCellHeight) < 0) {
- mCellHeight = vSpace / mCountY;
- }
-
int hFreeSpace = hSpace - (mCountX * mCellWidth);
int vFreeSpace = vSpace - (mCountY * mCellHeight);
-
- mWidthGap = 0;
- mHeightGap = 0;
-
- if (numWidthGaps > 0) {
- mWidthGap = hFreeSpace / numWidthGaps;
- }
- if (numHeightGaps > 0) {
- mHeightGap = vFreeSpace / numHeightGaps;
- }
+ mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
+ mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
} else {
mWidthGap = mOriginalWidthGap;
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index ac07d6c..0321e2b 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -305,6 +305,7 @@ public class Workspace extends PagedView
// Preferences
private int mNumberHomescreens;
private int mDefaultHomescreen;
+ private boolean mStretchScreens;
private boolean mShowSearchBar;
private boolean mShowHotseat;
private boolean mHideIconLabels;
@@ -392,6 +393,12 @@ public class Workspace extends PagedView
mDefaultHomescreen = mNumberHomescreens / 2;
}
+ mStretchScreens = PreferencesProvider.Interface.Homescreen.getStretchScreens();
+ // Large screen has calculated dimensions always, unless specified by config_workspaceTabletGrid option
+ boolean workspaceTabletGrid = getResources().getBoolean(R.bool.config_workspaceTabletGrid);
+ if (LauncherApplication.isScreenLarge() && workspaceTabletGrid == false) {
+ mStretchScreens = false;
+ }
mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar();
mShowHotseat = PreferencesProvider.Interface.Dock.getShowDock();
mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels();
@@ -524,7 +531,9 @@ public class Workspace extends PagedView
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (int i = 0; i < mNumberHomescreens; i++) {
CellLayout screen = (CellLayout) inflater.inflate(R.layout.workspace_screen, null);
- screen.setCellGaps(-1, -1);
+ if (mStretchScreens) {
+ screen.setCellGaps(-1, -1);
+ }
addView(screen);
}
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 0cf38ae..cd88bb5 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -93,6 +93,9 @@ public final class PreferencesProvider {
return def;
}
}
+ public static boolean getStretchScreens() {
+ return getBoolean("ui_homescreen_stretch_screens", true);
+ }
public static boolean getShowSearchBar() {
return getBoolean("ui_homescreen_general_search", true);
}