Merge "Preserving the open folder state across rotation" into ub-launcher3-master
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index a3b92dc..ce7e392 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -113,7 +113,7 @@
if (display == DISPLAY_WORKSPACE) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
} else if (display == DISPLAY_ALL_APPS) {
- setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.allAppsIconTextSizeSp);
defaultIconSize = grid.allAppsIconSizePx;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 5032dcf..8538a1f 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -98,7 +98,7 @@
public int allAppsNumPredictiveCols;
public int allAppsButtonVisualSize;
public final int allAppsIconSizePx;
- public final int allAppsIconTextSizePx;
+ public final float allAppsIconTextSizeSp;
// QSB
private int searchBarWidgetInternalPaddingTop, searchBarWidgetInternalPaddingBottom;
@@ -150,7 +150,7 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
// AllApps uses the original non-scaled icon text size
- allAppsIconTextSizePx = Utilities.pxFromDp(inv.iconTextSize, dm);
+ allAppsIconTextSizeSp = inv.iconTextSize;
// AllApps uses the original non-scaled icon size
allAppsIconSizePx = Utilities.pxFromDp(inv.iconSize, dm);
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 0a26109..ad959ef 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -27,6 +27,7 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.util.ConfigMonitor;
import com.android.launcher3.util.TestingUtils;
import com.android.launcher3.util.Thunk;
@@ -108,7 +109,6 @@
sContext.registerReceiver(mModel, filter);
UserManagerCompat.getInstance(sContext).enableAndResetCache();
-
if (!Utilities.ATLEAST_KITKAT) {
sContext.registerReceiver(new BroadcastReceiver() {
@@ -118,6 +118,7 @@
}
}, new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
}
+ new ConfigMonitor(sContext).register();
}
/**
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 261292d..494ea2f 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -43,7 +43,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
-import android.os.StrictMode;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
@@ -57,7 +56,6 @@
import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.Thunk;
-import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
@@ -322,7 +320,8 @@
return null;
}
case LauncherSettings.Settings.METHOD_DELETE_DB: {
- deleteDatabase();
+ // Are you sure? (y/n)
+ mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
return null;
}
}
@@ -482,17 +481,6 @@
mOpenHelper, getContext().getResources(), defaultLayout);
}
- private void deleteDatabase() {
- // Are you sure? (y/n)
- final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- final File dbFile = new File(db.getPath());
- mOpenHelper.close();
- if (dbFile.exists()) {
- SQLiteDatabase.deleteDatabase(dbFile);
- }
- mOpenHelper = new DatabaseHelper(getContext(), this);
- }
-
/**
* Send notification that we've deleted the {@link AppWidgetHost},
* probably as part of the initial database creation. The receiver may
diff --git a/src/com/android/launcher3/util/ConfigMonitor.java b/src/com/android/launcher3/util/ConfigMonitor.java
new file mode 100644
index 0000000..c61fa88
--- /dev/null
+++ b/src/com/android/launcher3/util/ConfigMonitor.java
@@ -0,0 +1,55 @@
+package com.android.launcher3.util;
+
+/**
+ * Copyright (C) 2015 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.
+ */
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Configuration;
+import android.util.Log;
+
+/**
+ * {@link BroadcastReceiver} which watches configuration changes and
+ * restarts the process in case changes which affect the device profile.
+ */
+public class ConfigMonitor extends BroadcastReceiver {
+
+ private final Context mContext;
+ private final float mFontScale;
+
+ public ConfigMonitor(Context context) {
+ mContext = context;
+
+ Configuration config = context.getResources().getConfiguration();
+ mFontScale = config.fontScale;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Configuration config = context.getResources().getConfiguration();
+ if (mFontScale != config.fontScale) {
+ Log.d("ConfigMonitor", "Configuration changed, restarting launcher");
+ mContext.unregisterReceiver(this);
+ android.os.Process.killProcess(android.os.Process.myPid());
+ }
+ }
+
+ public void register() {
+ mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
+ }
+}