mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Update the suggestFolderName when items are added and deleted from folders
Bug: 149935239 Bug: 149967272 Bug: 148900990 Change-Id: I0ed27236ad22579a1f3dcfd35a32252c5b1f6691
This commit is contained in:
@@ -95,6 +95,7 @@ import com.android.launcher3.userevent.LauncherLogProto.ItemType;
|
||||
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;
|
||||
@@ -426,7 +427,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
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 class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
*/
|
||||
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
|
||||
// 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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
}
|
||||
}
|
||||
|
||||
private void updateItemLocationsInDatabaseBatch() {
|
||||
private void updateItemLocationsInDatabaseBatch(boolean isBind) {
|
||||
FolderGridOrganizer verifier = new FolderGridOrganizer(
|
||||
mLauncher.getDeviceProfile().inv).setFolderInfo(mInfo);
|
||||
|
||||
@@ -1011,6 +1006,18 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
// 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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
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);
|
||||
|
||||
@@ -84,6 +84,6 @@ public final class FolderNameInfo implements Parcelable {
|
||||
@Override
|
||||
@NonNull
|
||||
public String toString() {
|
||||
return mLabel.toString() + ":" + mScore;
|
||||
return String.format("%s:%.2f", mLabel, mScore);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user