diff --git a/go/AndroidManifest.xml b/go/AndroidManifest.xml index 0a9ad7b5ad..0080898624 100644 --- a/go/AndroidManifest.xml +++ b/go/AndroidManifest.xml @@ -36,16 +36,14 @@ android:restoreAnyVersion="true" android:supportsRtl="true" > - + - - - diff --git a/go/res/layout/widget_cell_content.xml b/go/res/layout/widget_cell_content.xml deleted file mode 100644 index 49506d9bec..0000000000 --- a/go/res/layout/widget_cell_content.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/iconloaderlib/build.gradle b/iconloaderlib/build.gradle index d08029386a..a6433ad1a6 100644 --- a/iconloaderlib/build.gradle +++ b/iconloaderlib/build.gradle @@ -37,6 +37,11 @@ android { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } diff --git a/src/com/android/launcher3/graphics/BitmapRenderer.java b/iconloaderlib/src/com/android/launcher3/icons/BitmapRenderer.java similarity index 92% rename from src/com/android/launcher3/graphics/BitmapRenderer.java rename to iconloaderlib/src/com/android/launcher3/icons/BitmapRenderer.java index 2a7f20ea33..a66b929efb 100644 --- a/src/com/android/launcher3/graphics/BitmapRenderer.java +++ b/iconloaderlib/src/com/android/launcher3/icons/BitmapRenderer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.graphics; +package com.android.launcher3.icons; import android.annotation.TargetApi; import android.graphics.Bitmap; @@ -21,14 +21,12 @@ import android.graphics.Canvas; import android.graphics.Picture; import android.os.Build; -import com.android.launcher3.Utilities; - /** * Interface representing a bitmap draw operation. */ public interface BitmapRenderer { - boolean USE_HARDWARE_BITMAP = Utilities.ATLEAST_P; + boolean USE_HARDWARE_BITMAP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; static Bitmap createSoftwareBitmap(int width, int height, BitmapRenderer renderer) { Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); diff --git a/iconloaderlib/src/com/android/launcher3/icons/GraphicsUtils.java b/iconloaderlib/src/com/android/launcher3/icons/GraphicsUtils.java index b096cecb5c..11d5eef52c 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/GraphicsUtils.java +++ b/iconloaderlib/src/com/android/launcher3/icons/GraphicsUtils.java @@ -15,10 +15,18 @@ */ package com.android.launcher3.icons; +import android.graphics.Bitmap; +import android.util.Log; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + import androidx.annotation.ColorInt; public class GraphicsUtils { + private static final String TAG = "GraphicsUtils"; + /** * Set the alpha component of {@code color} to be {@code alpha}. Unlike the support lib version, * it bounds the alpha in valid range instead of throwing an exception to allow for safer @@ -33,4 +41,23 @@ public class GraphicsUtils { } return (color & 0x00ffffff) | (alpha << 24); } + + /** + * Compresses the bitmap to a byte array for serialization. + */ + public static byte[] flattenBitmap(Bitmap bitmap) { + // Try go guesstimate how much space the icon will take when serialized + // to avoid unnecessary allocations/copies during the write (4 bytes per pixel). + int size = bitmap.getWidth() * bitmap.getHeight() * 4; + ByteArrayOutputStream out = new ByteArrayOutputStream(size); + try { + bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); + out.flush(); + out.close(); + return out.toByteArray(); + } catch (IOException e) { + Log.w(TAG, "Could not write bitmap"); + return null; + } + } } diff --git a/src/com/android/launcher3/util/ComponentKey.java b/iconloaderlib/src/com/android/launcher3/util/ComponentKey.java similarity index 93% rename from src/com/android/launcher3/util/ComponentKey.java rename to iconloaderlib/src/com/android/launcher3/util/ComponentKey.java index d478ffa541..34bed94270 100644 --- a/src/com/android/launcher3/util/ComponentKey.java +++ b/iconloaderlib/src/com/android/launcher3/util/ComponentKey.java @@ -29,8 +29,9 @@ public class ComponentKey { private final int mHashCode; public ComponentKey(ComponentName componentName, UserHandle user) { - Preconditions.assertNotNull(componentName); - Preconditions.assertNotNull(user); + if (componentName == null || user == null) { + throw new NullPointerException(); + } this.componentName = componentName; this.user = user; mHashCode = Arrays.hashCode(new Object[] {componentName, user}); diff --git a/src/com/android/launcher3/util/NoLocaleSQLiteHelper.java b/iconloaderlib/src/com/android/launcher3/util/NoLocaleSQLiteHelper.java similarity index 94% rename from src/com/android/launcher3/util/NoLocaleSQLiteHelper.java rename to iconloaderlib/src/com/android/launcher3/util/NoLocaleSQLiteHelper.java index 05a7d27434..fe864a2847 100644 --- a/src/com/android/launcher3/util/NoLocaleSQLiteHelper.java +++ b/iconloaderlib/src/com/android/launcher3/util/NoLocaleSQLiteHelper.java @@ -18,8 +18,6 @@ package com.android.launcher3.util; import static android.database.sqlite.SQLiteDatabase.NO_LOCALIZED_COLLATORS; -import static com.android.launcher3.Utilities.ATLEAST_P; - import android.content.Context; import android.content.ContextWrapper; import android.database.DatabaseErrorHandler; @@ -27,6 +25,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteDatabase.OpenParams; import android.database.sqlite.SQLiteOpenHelper; +import android.os.Build; /** * Extension of {@link SQLiteOpenHelper} which avoids creating default locale table by @@ -34,6 +33,9 @@ import android.database.sqlite.SQLiteOpenHelper; */ public abstract class NoLocaleSQLiteHelper extends SQLiteOpenHelper { + private static final boolean ATLEAST_P = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; + public NoLocaleSQLiteHelper(Context context, String name, int version) { super(ATLEAST_P ? context : new NoLocalContext(context), name, null, version); if (ATLEAST_P) { diff --git a/src/com/android/launcher3/util/Provider.java b/iconloaderlib/src/com/android/launcher3/util/Provider.java similarity index 100% rename from src/com/android/launcher3/util/Provider.java rename to iconloaderlib/src/com/android/launcher3/util/Provider.java diff --git a/src/com/android/launcher3/util/SQLiteCacheHelper.java b/iconloaderlib/src/com/android/launcher3/util/SQLiteCacheHelper.java similarity index 93% rename from src/com/android/launcher3/util/SQLiteCacheHelper.java rename to iconloaderlib/src/com/android/launcher3/util/SQLiteCacheHelper.java index 3faf0709a9..49de4bd1bf 100644 --- a/src/com/android/launcher3/util/SQLiteCacheHelper.java +++ b/iconloaderlib/src/com/android/launcher3/util/SQLiteCacheHelper.java @@ -9,9 +9,6 @@ import android.database.sqlite.SQLiteFullException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; -import com.android.launcher3.Utilities; -import com.android.launcher3.config.FeatureFlags; - /** * An extension of {@link SQLiteOpenHelper} with utility methods for a single table cache DB. * Any exception during write operations are ignored, and any version change causes a DB reset. @@ -19,8 +16,7 @@ import com.android.launcher3.config.FeatureFlags; public abstract class SQLiteCacheHelper { private static final String TAG = "SQLiteCacheHelper"; - private static final boolean NO_ICON_CACHE = FeatureFlags.IS_DOGFOOD_BUILD && - Utilities.isPropertyEnabled(LogConfig.MEMORY_ONLY_ICON_CACHE); + private static final boolean IN_MEMORY_CACHE = false; private final String mTableName; private final MySQLiteOpenHelper mOpenHelper; @@ -28,7 +24,7 @@ public abstract class SQLiteCacheHelper { private boolean mIgnoreWrites; public SQLiteCacheHelper(Context context, String name, int version, String tableName) { - if (NO_ICON_CACHE) { + if (IN_MEMORY_CACHE) { name = null; } mTableName = tableName; diff --git a/proguard.flags b/proguard.flags index bb52a6c9e9..eb27737d4a 100644 --- a/proguard.flags +++ b/proguard.flags @@ -24,7 +24,7 @@ -keep class androidx.recyclerview.widget.RecyclerView { *; } # Preference fragments --keep class ** extends android.preference.PreferenceFragment { +-keep class ** extends android.app.Fragment { public (...); } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 301b08a3f7..79c988d321 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -462,7 +462,7 @@ public class TaskView extends FrameLayout implements PageCallbacks { } if (action == R.string.accessibility_app_usage_settings) { - openAppUsageSettings(); + openAppUsageSettings(this); return true; } @@ -484,14 +484,16 @@ public class TaskView extends FrameLayout implements PageCallbacks { return super.performAccessibilityAction(action, arguments); } - private void openAppUsageSettings() { + private void openAppUsageSettings(View view) { final Intent intent = new Intent(SEE_TIME_IN_APP_TEMPLATE) .putExtra(Intent.EXTRA_PACKAGE_NAME, mTask.getTopComponent().getPackageName()).addFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); try { final Launcher launcher = Launcher.getLauncher(getContext()); - launcher.startActivity(intent); + final ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0, 0, + view.getWidth(), view.getHeight()); + launcher.startActivity(intent, options.toBundle()); launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP, LauncherLogProto.ControlType.APP_USAGE_SETTINGS, this); } catch (ActivityNotFoundException e) { diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml index b1e6f2efd7..33ff46b910 100644 --- a/res/layout/all_apps.xml +++ b/res/layout/all_apps.xml @@ -30,7 +30,50 @@ layout="@layout/all_apps_rv_layout" android:visibility="gone" /> - + + + + + + +