Merge "Convert LauncherPluginLib to soong" into ub-launcher3-master
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
index ec1d55b..d08d851 100644
--- a/protos/launcher_log.proto
+++ b/protos/launcher_log.proto
@@ -151,6 +151,10 @@
DISMISS_PREDICTION = 21;
HYBRID_HOTSEAT_ACCEPTED = 22;
HYBRID_HOTSEAT_CANCELED = 23;
+ OVERVIEW_ACTIONS_SHARE_BUTTON = 24;
+ OVERVIEW_ACTIONS_SCREENSHOT_BUTTON = 25;
+ OVERVIEW_ACTIONS_SELECT_BUTTON = 26;
+ SELECT_MODE_CLOSE_BUTTON = 27;
}
enum TipType {
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index c72509e..ddb88dc 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -33,6 +33,7 @@
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
+import static java.util.Optional.ofNullable;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -95,6 +96,7 @@
import com.android.launcher3.userevent.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.LauncherLogProto.Target;
import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.util.Executors;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.ClipPathView;
import com.android.launcher3.widget.PendingAddShortcutInfo;
@@ -322,12 +324,11 @@
post(() -> {
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
if (isEmpty(mFolderName.getText())) {
- FolderNameInfo[] nameInfos =
- (FolderNameInfo[]) mInfo.suggestedFolderNames.getParcelableArrayExtra(
- FolderInfo.EXTRA_FOLDER_SUGGESTIONS);
- if (nameInfos != null) {
- showLabelSuggestion(nameInfos, false);
- }
+ ofNullable(mInfo)
+ .map(info -> info.suggestedFolderNames)
+ .map(folderNames -> (FolderNameInfo[]) folderNames
+ .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
+ .ifPresent(nameInfos -> showLabelSuggestion(nameInfos, false));
}
}
mFolderName.setHint("");
@@ -426,7 +427,7 @@
mInfo = info;
ArrayList<WorkspaceItemInfo> children = info.contents;
Collections.sort(children, ITEM_POS_COMPARATOR);
- updateItemLocationsInDatabaseBatch();
+ updateItemLocationsInDatabaseBatch(true);
DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
if (lp == null) {
@@ -444,11 +445,7 @@
mFolderName.setHint(null);
} else {
mFolderName.setText("");
- if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
- mFolderName.setHint("");
- } else {
- mFolderName.setHint(R.string.folder_hint_text);
- }
+ mFolderName.setHint(R.string.folder_hint_text);
}
// In case any children didn't come across during loading, clean up the folder accordingly
mFolderIcon.post(() -> {
@@ -464,8 +461,6 @@
*/
public void showSuggestedTitle(FolderNameInfo[] nameInfos) {
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
- mInfo.suggestedFolderNames = new Intent().putExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS,
- nameInfos);
if (isEmpty(mFolderName.getText().toString())
&& !mInfo.hasOption(FLAG_MANUAL_FOLDER_NAME)) {
showLabelSuggestion(nameInfos, true);
@@ -985,7 +980,7 @@
// Reordering may have occured, and we need to save the new item locations. We do this once
// at the end to prevent unnecessary database operations.
- updateItemLocationsInDatabaseBatch();
+ updateItemLocationsInDatabaseBatch(false);
// Use the item count to check for multi-page as the folder UI may not have
// been refreshed yet.
if (getItemCount() <= mContent.itemsPerPage()) {
@@ -995,7 +990,7 @@
}
}
- private void updateItemLocationsInDatabaseBatch() {
+ private void updateItemLocationsInDatabaseBatch(boolean isBind) {
FolderGridOrganizer verifier = new FolderGridOrganizer(
mLauncher.getDeviceProfile().inv).setFolderInfo(mInfo);
@@ -1011,6 +1006,18 @@
if (!items.isEmpty()) {
mLauncher.getModelWriter().moveItemsInDatabase(items, mInfo.id, 0);
}
+ if (FeatureFlags.FOLDER_NAME_SUGGEST.get() && !isBind) {
+ Executors.MODEL_EXECUTOR.post(() -> {
+ FolderNameInfo[] nameInfos =
+ new FolderNameInfo[FolderNameProvider.SUGGEST_MAX];
+ FolderNameProvider fnp = FolderNameProvider.newInstance(getContext());
+ fnp.getSuggestedFolderName(
+ getContext(), mInfo.contents, nameInfos);
+ mInfo.suggestedFolderNames = new Intent().putExtra(
+ FolderInfo.EXTRA_FOLDER_SUGGESTIONS,
+ nameInfos);
+ });
+ }
}
public void notifyDrop() {
@@ -1315,7 +1322,7 @@
// We only need to update the locations if it doesn't get handled in
// #onDropCompleted.
if (d.dragSource != this) {
- updateItemLocationsInDatabaseBatch();
+ updateItemLocationsInDatabaseBatch(false);
}
}
@@ -1356,7 +1363,7 @@
verifier.updateRankAndPos(item, rank);
mLauncher.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX,
item.cellY);
- updateItemLocationsInDatabaseBatch();
+ updateItemLocationsInDatabaseBatch(false);
if (mContent.areViewsBound()) {
mContent.createAndAddViewForRank(item, rank);
@@ -1647,26 +1654,8 @@
checkNotNull(mFolderName.getText().toString(),
"Expected valid folder label, but found null");
- Optional<String[]> suggestedLabels = Optional.ofNullable(
- (FolderNameInfo[]) mInfo.suggestedFolderNames
- .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
- .map(folderNameInfoArray ->
- stream(folderNameInfoArray)
- .filter(Objects::nonNull)
- .map(FolderNameInfo::getLabel)
- .map(CharSequence::toString)
- .toArray(String[]::new));
-
-
- int accepted_suggestion_index = suggestedLabels
- .map(folderNameInfoArray ->
- IntStream.range(0, folderNameInfoArray.length)
- .filter(index -> newLabel.equalsIgnoreCase(
- folderNameInfoArray[index]))
- .findFirst()
- .orElse(-1)
- ).orElse(-1);
-
+ Optional<String[]> suggestedLabels = getSuggestedLabels();
+ int accepted_suggestion_index = getAcceptedSuggestionIndex();
boolean hasValidPrimary = suggestedLabels
.map(labels -> labels.length > 0 && !isEmpty(labels[0]))
.orElse(false);
@@ -1695,6 +1684,39 @@
: Target.ToFolderLabelState.valueOf("TO_CUSTOM" + suggestionsSuffix);
}
+ private Optional<String[]> getSuggestedLabels() {
+ return ofNullable(mInfo)
+ .map(info -> info.suggestedFolderNames)
+ .map(
+ folderNames ->
+ (FolderNameInfo[])
+ folderNames.getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
+ .map(
+ folderNameInfoArray ->
+ stream(folderNameInfoArray)
+ .filter(Objects::nonNull)
+ .map(FolderNameInfo::getLabel)
+ .filter(Objects::nonNull)
+ .map(CharSequence::toString)
+ .toArray(String[]::new));
+ }
+
+ private int getAcceptedSuggestionIndex() {
+ String newLabel =
+ checkNotNull(mFolderName.getText().toString(),
+ "Expected valid folder label, but found null");
+
+ return getSuggestedLabels()
+ .map(suggestionsArray ->
+ IntStream.range(0, suggestionsArray.length)
+ .filter(index -> newLabel.equalsIgnoreCase(
+ suggestionsArray[index]))
+ .findFirst()
+ .orElse(-1)
+ ).orElse(-1);
+
+ }
+
private Target.Builder newEditTextTargetBuilder() {
return Target.newBuilder().setType(Target.Type.ITEM).setItemType(ItemType.EDITTEXT);
diff --git a/src/com/android/launcher3/folder/FolderNameInfo.java b/src/com/android/launcher3/folder/FolderNameInfo.java
index ecbe46c..1287219 100644
--- a/src/com/android/launcher3/folder/FolderNameInfo.java
+++ b/src/com/android/launcher3/folder/FolderNameInfo.java
@@ -84,6 +84,6 @@
@Override
@NonNull
public String toString() {
- return mLabel.toString() + ":" + mScore;
+ return String.format("%s:%.2f", mLabel, mScore);
}
}
diff --git a/src/com/android/launcher3/logging/FileLog.java b/src/com/android/launcher3/logging/FileLog.java
index 67f07b1..a3fdf8d 100644
--- a/src/com/android/launcher3/logging/FileLog.java
+++ b/src/com/android/launcher3/logging/FileLog.java
@@ -10,6 +10,7 @@
import androidx.annotation.VisibleForTesting;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.IOUtils;
import java.io.BufferedReader;
@@ -42,7 +43,7 @@
private static Handler sHandler = null;
private static File sLogsDirectory = null;
- public static final int LOG_DAYS = 4;
+ public static final int LOG_DAYS = FeatureFlags.ENABLE_HYBRID_HOTSEAT.get() ? 10 : 4;
public static void setDir(File logsDir) {
if (ENABLED) {