Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0a08760 authored by Pinyao Ting's avatar Pinyao Ting Committed by Automerger Merge Worker
Browse files

Merging from ub-launcher3-rvc-dev @ build 6577335 am: 8020bf2f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/11828234

Change-Id: I8a10d9cda659a374d6e6edc5296416bbb83064cf
parents 158cbbfe 8020bf2f
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ message ItemInfo {
  optional ContainerInfo container_info = 7;

  // Stores the origin of the Item
  optional Origin source = 8;
  optional Attribute attribute = 8;
}

// Represents various launcher surface where items are placed.
@@ -52,6 +52,8 @@ message ContainerInfo {
    PredictionContainer prediction_container = 6;
    SearchResultContainer search_result_container = 7;
    ShortcutsContainer shortcuts_container = 8;
    SettingsContainer settings_container = 9;
    PredictedHotseatContainer predicted_hotseat_container = 10;
  }
}

@@ -75,7 +77,12 @@ message SearchResultContainer {
message ShortcutsContainer {
}

enum Origin {
// Container for generic system shortcuts for launcher specific settings.
// Typically shown up as popup window by longpressing on empty space on workspace.
message SettingsContainer {
}

enum Attribute {
  UNKNOWN = 0;
  DEFAULT_LAYOUT = 1;       // icon automatically placed in workspace, folder, hotseat
  BACKUP_RESTORE = 2;       // icon layout restored from backup
@@ -85,6 +92,8 @@ enum Origin {
  ADD_TO_HOMESCREEN = 6;    // play install + launcher home setting
  ALLAPPS_PREDICTION = 7;   // from prediction bar in all apps container
  HOTSEAT_PREDICTION = 8;   // from prediction bar in hotseat container
  SUGGESTED_LABEL = 9;      // folder icon's label was suggested
  MANUAL_LABEL = 10;        // folder icon's label was manually edited
}

// Main app icons
@@ -143,6 +152,14 @@ message HotseatContainer {
  optional int32 index = 1;
}

// Represents hotseat container with prediction feature enabled.
message PredictedHotseatContainer {
  optional int32 index = 1;

  // No of hotseat positions filled with predicted items.
  optional int32 cardinality = 2;
}

message FolderContainer {
  optional int32 page_index = 1 [default = -1];
  optional int32 grid_x = 2 [default = -1];
+3 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.Build;
import android.util.AttributeSet;
import android.util.IntProperty;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
@@ -241,8 +242,9 @@ public class PredictionRowView extends LinearLayout implements
            while (getChildCount() > mNumPredictedAppsPerRow) {
                removeViewAt(0);
            }
            LayoutInflater inflater = mLauncher.getAppsView().getLayoutInflater();
            while (getChildCount() < mNumPredictedAppsPerRow) {
                BubbleTextView icon = (BubbleTextView) mLauncher.getLayoutInflater().inflate(
                BubbleTextView icon = (BubbleTextView) inflater.inflate(
                        R.layout.all_apps_icon, this, false);
                icon.setOnClickListener(PREDICTION_CLICK_LISTENER);
                icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
+17 −5
Original line number Diff line number Diff line
@@ -144,11 +144,23 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable
        int rightInset = insets.right - mInsets.right;
        int bottomInset = insets.bottom - mInsets.bottom;
        mInsets.set(insets);
        if (mLauncher.getOrientation() == Configuration.ORIENTATION_PORTRAIT) {
            setPadding(leftInset, getPaddingTop(), rightInset, 0);
            mHotseatWrapper.setPadding(mHotseatWrapper.getPaddingLeft(), getPaddingTop(),
                    mHotseatWrapper.getPaddingRight(), bottomInset);
            mHotseatWrapper.getLayoutParams().height =
                    mLauncher.getDeviceProfile().hotseatBarSizePx + insets.bottom;

        } else {
            setPadding(0, getPaddingTop(), 0, 0);
            mHotseatWrapper.setPadding(mHotseatWrapper.getPaddingLeft(), getPaddingTop(),
                    mHotseatWrapper.getPaddingRight(),
                    (int) getResources().getDimension(R.dimen.bottom_sheet_edu_padding));
            ((TextView) findViewById(R.id.hotseat_edu_heading)).setText(
                    R.string.hotseat_edu_title_migrate_landscape);
            ((TextView) findViewById(R.id.hotseat_edu_content)).setText(
                    R.string.hotseat_edu_message_migrate_landscape);
        }
    }

    private void logUserAction(boolean migrated, int pageIndex) {
+1 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ public class HotseatPredictionController implements DragController.DragListener,
    }
    private void setPredictedApps(List<AppTarget> appTargets) {
        mComponentKeyMappers.clear();
        if (appTargets.isEmpty() && mRestoreHelper.shouldRestoreToBackup()) {
        if (appTargets.isEmpty()) {
            mRestoreHelper.restoreBackup();
        }
        StringBuilder predictionLog = new StringBuilder("predictedApps: [\n");
+38 −52
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.launcher3.hybridhotseat;

import static com.android.launcher3.LauncherSettings.Favorites.HYBRID_HOTSEAT_BACKUP_TABLE;
import static com.android.launcher3.provider.LauncherDbUtils.tableExists;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;

import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
@@ -29,17 +30,17 @@ import com.android.launcher3.provider.LauncherDbUtils;
 */
public class HotseatRestoreHelper {
    private final Launcher mLauncher;
    private boolean mBackupExists;
    private boolean mBackupRestored = false;

    HotseatRestoreHelper(Launcher context) {
        mLauncher = context;
        setupBackupTable();
    }

    /**
     * Creates a snapshot backup of Favorite table for future restoration use.
     */
    public synchronized void createBackup() {
    public void createBackup() {
        MODEL_EXECUTOR.execute(() -> {
            try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction)
                    LauncherSettings.Settings.call(
                            mLauncher.getContentResolver(),
@@ -53,21 +54,22 @@ public class HotseatRestoreHelper {
                transaction.commit();
                LauncherSettings.Settings.call(mLauncher.getContentResolver(),
                        LauncherSettings.Settings.METHOD_REFRESH_HOTSEAT_RESTORE_TABLE);
            mBackupExists = true;
            }
        });
    }

    /**
     * Finds and restores a previously saved snapshow of Favorites table
     */
    public void restoreBackup() {
        if (mBackupRestored) return;
        MODEL_EXECUTOR.execute(() -> {
            try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction)
                    LauncherSettings.Settings.call(
                            mLauncher.getContentResolver(),
                            LauncherSettings.Settings.METHOD_NEW_TRANSACTION)
                            .getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
                if (!tableExists(transaction.getDb(), HYBRID_HOTSEAT_BACKUP_TABLE)) {
                mBackupExists = false;
                    return;
                }
                InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
@@ -76,25 +78,9 @@ public class HotseatRestoreHelper {
                        idp.numRows);
                backupTable.restoreFromCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE, true);
                transaction.commit();
            mBackupExists = false;
                mBackupRestored = true;
                mLauncher.getModel().forceReload();
            }
    }

    /**
     * Returns if prediction controller should attempt restoring a backup
     */
    public synchronized boolean shouldRestoreToBackup() {
        return mBackupExists;
    }

    private synchronized void setupBackupTable() {
        try (LauncherDbUtils.SQLiteTransaction transaction = (LauncherDbUtils.SQLiteTransaction)
                LauncherSettings.Settings.call(
                        mLauncher.getContentResolver(),
                        LauncherSettings.Settings.METHOD_NEW_TRANSACTION)
                        .getBinder(LauncherSettings.Settings.EXTRA_VALUE)) {
            mBackupExists = tableExists(transaction.getDb(), HYBRID_HOTSEAT_BACKUP_TABLE);
        }
        });
    }
}
Loading