Merge "Settings: only replace content with new fragment if it has no saved instance state." into ub-launcher3-dorval-polish
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 93662fc..6340619 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -49,7 +49,7 @@
<!-- DO NOT CHANGE THE ID -->
<com.android.launcher3.allapps.AllAppsRecyclerView
android:id="@+id/apps_list_view"
- android:layout_below="@+id/search_container"
+ android:layout_below="@id/search_container_all_apps"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"
@@ -62,7 +62,7 @@
platform bug, which prevents using custom attributes in <include> tag -->
<include
layout="?android:attr/keyboardLayout"
- android:id="@+id/search_container" />
+ android:id="@id/search_container_all_apps" />
<include layout="@layout/all_apps_fast_scroller" />
diff --git a/res/layout/all_apps_search_container.xml b/res/layout/search_container_all_apps.xml
similarity index 98%
rename from res/layout/all_apps_search_container.xml
rename to res/layout/search_container_all_apps.xml
index 2528034..c430521 100644
--- a/res/layout/all_apps_search_container.xml
+++ b/res/layout/search_container_all_apps.xml
@@ -15,7 +15,7 @@
-->
<com.android.launcher3.allapps.search.AppsSearchContainerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/search_container"
+ android:id="@id/search_container_all_apps"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_search_bar_height"
android:layout_gravity="center|top"
diff --git a/res/layout/qsb_container.xml b/res/layout/search_container_workspace.xml
similarity index 95%
rename from res/layout/qsb_container.xml
rename to res/layout/search_container_workspace.xml
index 6fa843d..1c617b1 100644
--- a/res/layout/qsb_container.xml
+++ b/res/layout/search_container_workspace.xml
@@ -19,7 +19,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
- android:id="@+id/qsb_container"
+ android:id="@id/search_container_workspace"
android:padding="0dp" >
<fragment
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index 88b02bb..a6821df 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -77,8 +77,8 @@
<string name="allow_rotation_desc" msgid="8662546029078692509">"En girar el telèfon"</string>
<string name="allow_rotation_blocked_desc" msgid="3212602545192996253">"La configuració actual de la pantalla no permet la rotació"</string>
<string name="icon_badging_title" msgid="874121399231955394">"Punts de notificació"</string>
- <string name="icon_badging_desc_on" msgid="2627952638544674079">"Activada"</string>
- <string name="icon_badging_desc_off" msgid="5503319969924580241">"Desactivada"</string>
+ <string name="icon_badging_desc_on" msgid="2627952638544674079">"Activat"</string>
+ <string name="icon_badging_desc_off" msgid="5503319969924580241">"Desactivat"</string>
<string name="auto_add_shortcuts_label" msgid="8222286205987725611">"Afegeix la icona a la pantalla d\'inici"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Per a les aplicacions noves"</string>
<!-- no translation found for icon_shape_override_label (2977264953998281004) -->
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
index bb0dbc2..72894dc 100644
--- a/res/values-sw720dp/styles.xml
+++ b/res/values-sw720dp/styles.xml
@@ -26,7 +26,7 @@
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
- <item name="android:keyboardLayout">@layout/all_apps_search_container</item>
+ <item name="android:keyboardLayout">@layout/search_container_all_apps</item>
</style>
<!-- Workspace -->
diff --git a/res/values/config.xml b/res/values/config.xml
index 00db4ef..e9c62a7 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -140,4 +140,10 @@
<item type="id" name="action_resize" />
<item type="id" name="action_deep_shortcuts" />
<item type="id" name="action_dismiss_notification" />
+
+<!-- QSB IDs. DO not change -->
+ <item type="id" name="search_container_workspace" />
+ <item type="id" name="search_container_hotseat" />
+ <item type="id" name="search_container_all_apps" />
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 813fe8f..5bdf512 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -25,7 +25,7 @@
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorEdgeEffect">#FF757575</item>
- <item name="android:keyboardLayout">@layout/all_apps_search_container</item>
+ <item name="android:keyboardLayout">@layout/search_container_all_apps</item>
</style>
<style name="BaseLauncherThemeWithCustomAttrs" parent="@style/BaseLauncherTheme">
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 26c5c9d..6ae4068 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -488,7 +488,7 @@
}
@Override
- public View findViewById(int id) {
+ public <T extends View> T findViewById(int id) {
return mLauncherView.findViewById(id);
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index dcc7a9d..185c887 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -926,6 +926,7 @@
@Override
public void onChildViewRemoved(View parent, View child) {
updateFreescrollBounds();
+ mCurrentPage = validateNewPage(mCurrentPage);
invalidate();
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 56a5f9e..28070b7 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -600,12 +600,12 @@
// In transposed layout, we add the QSB in the Grid. As workspace does not touch the
// edges, we do not need a full width QSB.
qsb = LayoutInflater.from(getContext())
- .inflate(R.layout.qsb_container,firstPage, false);
+ .inflate(R.layout.search_container_workspace,firstPage, false);
}
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1);
lp.canReorder = false;
- if (!firstPage.addViewToCellLayout(qsb, 0, R.id.qsb_container, lp, true)) {
+ if (!firstPage.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true)) {
Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
}
}
@@ -623,7 +623,7 @@
}
// Recycle the QSB widget
- View qsb = findViewById(R.id.qsb_container);
+ View qsb = findViewById(R.id.search_container_workspace);
if (qsb != null) {
((ViewGroup) qsb.getParent()).removeView(qsb);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 499eb45..4fb0b86 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -230,7 +230,7 @@
mAppsRecyclerView.addOnScrollListener(new SpringMotionOnScrollListener());
}
- mSearchContainer = findViewById(R.id.search_container);
+ mSearchContainer = findViewById(R.id.search_container_all_apps);
mSearchUiManager = (SearchUiManager) mSearchContainer;
mSearchUiManager.initialize(mApps, mAppsRecyclerView);
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index 022b3b8..09cfc1e 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -222,11 +222,11 @@
int w = mBitmap.getWidth();
int h = mBitmap.getHeight();
AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) dr;
- adaptiveIcon.setBounds(0, 0, w, h);
float blurSizeOutline = mLauncher.getResources()
.getDimension(R.dimen.blur_size_medium_outline);
float normalizationScale = IconNormalizer.getInstance(mLauncher)
.getScale(adaptiveIcon, null, null, null) * ((w - blurSizeOutline) / w);
+ adaptiveIcon.setBounds(0, 0, w, h);
final Path mask = getMaskPath(adaptiveIcon, normalizationScale);
mFgImageView = setupImageView(adaptiveIcon.getForeground(), normalizationScale);
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index 830ca82..739eb04 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -35,6 +35,7 @@
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
+import android.support.annotation.Nullable;
import com.android.launcher3.AppInfo;
import com.android.launcher3.IconCache;
@@ -45,6 +46,7 @@
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
+import com.android.launcher3.util.Provider;
/**
* Helper methods for generating various launcher icons
@@ -315,14 +317,28 @@
public static Bitmap createShortcutIcon(ShortcutInfoCompat shortcutInfo, Context context,
boolean badged) {
+ return createShortcutIcon(shortcutInfo, context, badged, null);
+ }
+
+ public static Bitmap createShortcutIcon(ShortcutInfoCompat shortcutInfo, Context context,
+ boolean badged, @Nullable Provider<Bitmap> fallbackIconProvider) {
LauncherAppState app = LauncherAppState.getInstance(context);
Drawable unbadgedDrawable = DeepShortcutManager.getInstance(context)
.getShortcutIconDrawable(shortcutInfo,
app.getInvariantDeviceProfile().fillResIconDpi);
IconCache cache = app.getIconCache();
- Bitmap unbadgedBitmap = unbadgedDrawable == null
- ? cache.getDefaultIcon(Process.myUserHandle())
- : LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context, 0);
+ Bitmap unbadgedBitmap = null;
+ if (unbadgedDrawable != null) {
+ unbadgedBitmap = LauncherIcons.createScaledBitmapWithoutShadow(
+ unbadgedDrawable, context, 0);
+ } else {
+ if (fallbackIconProvider != null) {
+ unbadgedBitmap = fallbackIconProvider.get();
+ }
+ if (unbadgedBitmap == null) {
+ unbadgedBitmap = cache.getDefaultIcon(Process.myUserHandle());
+ }
+ }
if (!badged) {
return unbadgedBitmap;
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index bb2d0b6..5bad436 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -24,8 +24,8 @@
import android.content.IntentFilter;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageInstaller;
+import android.graphics.Bitmap;
import android.os.Handler;
-import android.os.Looper;
import android.os.Process;
import android.os.SystemClock;
import android.os.Trace;
@@ -66,6 +66,7 @@
import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
+import com.android.launcher3.util.Provider;
import java.util.ArrayList;
import java.util.Collections;
@@ -459,8 +460,18 @@
continue;
}
info = new ShortcutInfo(pinnedShortcut, context);
+ final ShortcutInfo finalInfo = info;
+ Provider<Bitmap> fallbackIconProvider = new Provider<Bitmap>() {
+ @Override
+ public Bitmap get() {
+ // If the pinned deep shortcut is no longer published,
+ // use the last saved icon instead of the default.
+ return c.loadIcon(finalInfo);
+ }
+ };
info.iconBitmap = LauncherIcons
- .createShortcutIcon(pinnedShortcut, context);
+ .createShortcutIcon(pinnedShortcut, context,
+ true /* badged */, fallbackIconProvider);
if (pmHelper.isAppSuspended(
pinnedShortcut.getPackage(), info.user)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
diff --git a/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java b/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
index 29f738b..5858e13 100644
--- a/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
+++ b/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
@@ -47,11 +47,8 @@
}
private int getCount(SQLiteDatabase db, String sql) {
- Cursor c = db.rawQuery(sql, null);
- try {
+ try (Cursor c = db.rawQuery(sql, null)) {
return c.getCount();
- } finally {
- c.getCount();
}
}
@@ -59,7 +56,7 @@
private final long mProfileId;
- public MyDatabaseHelper(long profileId) {
+ MyDatabaseHelper(long profileId) {
super(getContext(), null, null);
mProfileId = profileId;
}