diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherBackupAgentHelper.java | 30 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherSettings.java | 3 |
4 files changed, 45 insertions, 8 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index c6da5844a..61c4b1a22 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -103,6 +103,8 @@ public class DeviceProfile { // QSB private int searchBarWidgetInternalPaddingTop, searchBarWidgetInternalPaddingBottom; private int searchBarTopPaddingPx; + private int tallSearchBarNegativeTopPaddingPx, normalSearchBarTopExtraPaddingPx; + private int searchBarTopExtraPaddingPx; // One of the above. private int normalSearchBarBottomPaddingPx, tallSearchBarBottomPaddingPx; private int searchBarBottomPaddingPx; // One of the above. private int normalSearchBarSpaceHeightPx, tallSearchBarSpaceHeightPx; @@ -216,6 +218,10 @@ public class DeviceProfile { R.dimen.qsb_internal_padding_top); searchBarWidgetInternalPaddingBottom = res.getDimensionPixelSize( R.dimen.qsb_internal_padding_bottom); + normalSearchBarTopExtraPaddingPx = res.getDimensionPixelSize( + R.dimen.dynamic_grid_search_bar_extra_top_padding); + tallSearchBarNegativeTopPaddingPx = res.getDimensionPixelSize( + R.dimen.dynamic_grid_search_bar_negative_top_padding_short); if (isTablet && !isVerticalBarLayout()) { searchBarTopPaddingPx = searchBarWidgetInternalPaddingTop; normalSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom + @@ -225,8 +231,9 @@ public class DeviceProfile { searchBarTopPaddingPx = searchBarWidgetInternalPaddingTop; normalSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom + res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_bottom_padding); - tallSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom + - res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_bottom_padding_short); + tallSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom + + res.getDimensionPixelSize( + R.dimen.dynamic_grid_search_bar_bottom_negative_padding_short); } // Calculate the actual text height @@ -272,7 +279,7 @@ public class DeviceProfile { /** Returns the amount of extra space to allocate to the search bar for vertical padding. */ private int getSearchBarTotalVerticalPadding() { - return searchBarTopPaddingPx + searchBarBottomPaddingPx; + return searchBarTopPaddingPx + searchBarTopExtraPaddingPx + searchBarBottomPaddingPx; } /** Returns the width and height of the search bar, ignoring any padding. */ @@ -427,10 +434,13 @@ public class DeviceProfile { hotseatBarHeightPx = shortHotseatBarHeightPx; searchBarSpaceHeightPx = tallSearchBarSpaceHeightPx; searchBarBottomPaddingPx = tallSearchBarBottomPaddingPx; + searchBarTopExtraPaddingPx = isPhone ? tallSearchBarNegativeTopPaddingPx + : normalSearchBarTopExtraPaddingPx; } else { hotseatBarHeightPx = normalHotseatBarHeightPx; searchBarSpaceHeightPx = normalSearchBarSpaceHeightPx; searchBarBottomPaddingPx = normalSearchBarBottomPaddingPx; + searchBarTopExtraPaddingPx = normalSearchBarTopExtraPaddingPx; } } @@ -445,6 +455,7 @@ public class DeviceProfile { lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); lp.width = searchBarBounds.width(); lp.height = searchBarBounds.height(); + lp.topMargin = searchBarTopExtraPaddingPx; if (hasVerticalBarLayout) { // Vertical search bar space -- The search bar is fixed in the layout to be on the left // of the screen regardless of RTL diff --git a/src/com/android/launcher3/LauncherBackupAgentHelper.java b/src/com/android/launcher3/LauncherBackupAgentHelper.java index 6619aafdb..2177f527e 100644 --- a/src/com/android/launcher3/LauncherBackupAgentHelper.java +++ b/src/com/android/launcher3/LauncherBackupAgentHelper.java @@ -20,6 +20,7 @@ import android.app.backup.BackupAgentHelper; import android.app.backup.BackupDataInput; import android.app.backup.BackupManager; import android.content.Context; +import android.content.SharedPreferences; import android.database.Cursor; import android.os.ParcelFileDescriptor; import android.util.Log; @@ -32,13 +33,13 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper { private static final String TAG = "LauncherBAHelper"; + private static final String KEY_LAST_NOTIFIED_TIME = "backup_manager_last_notified"; + private static final String LAUNCHER_DATA_PREFIX = "L"; static final boolean VERBOSE = false; static final boolean DEBUG = false; - private static BackupManager sBackupManager; - /** * Notify the backup manager that out database is dirty. * @@ -47,10 +48,29 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper { * @param context application context */ public static void dataChanged(Context context) { - if (sBackupManager == null) { - sBackupManager = new BackupManager(context); + dataChanged(context, 0); + } + + /** + * Notify the backup manager that out database is dirty. + * + * <P>This does not force an immediate backup. + * + * @param context application context + * @param throttleMs duration in ms for which two consecutive calls to backup manager should + * not be made. + */ + public static void dataChanged(Context context, long throttleMs) { + SharedPreferences prefs = Utilities.getPrefs(context); + long now = System.currentTimeMillis(); + long lastTime = prefs.getLong(KEY_LAST_NOTIFIED_TIME, 0); + + // User can manually change the system time, which could lead to now < lastTime. + // Re-backup in that case, as the backup will have a wrong lastModifiedTime. + if (now < lastTime || now >= (lastTime + throttleMs)) { + BackupManager.dataChanged(context.getPackageName()); + prefs.edit().putLong(KEY_LAST_NOTIFIED_TIME, now).apply(); } - sBackupManager.dataChanged(); } private LauncherBackupHelper mHelper; diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index 7674d2acf..476093032 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -270,6 +270,9 @@ public class LauncherProvider extends ContentProvider { if (mListener != null) { mListener.onSettingsChanged(arg, value); } + if (extras.getBoolean(LauncherSettings.Settings.NOTIFY_BACKUP)) { + LauncherBackupAgentHelper.dataChanged(getContext()); + } Bundle result = new Bundle(); result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE, value); return result; diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java index 8a5804f34..01d670d7b 100644 --- a/src/com/android/launcher3/LauncherSettings.java +++ b/src/com/android/launcher3/LauncherSettings.java @@ -324,5 +324,8 @@ public class LauncherSettings { public static final String EXTRA_VALUE = "value"; public static final String EXTRA_DEFAULT_VALUE = "default_value"; + + // Extra for set_boolean method to also notify the backup manager of the change. + public static final String NOTIFY_BACKUP = "notify_backup"; } } |