Commit dab5dea1 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Add Uninstall button to dragged icon after drag drop done

parent 6984f861
Pipeline #143144 passed with stage
in 1 minute and 53 seconds
...@@ -80,7 +80,6 @@ import foundation.e.blisslauncher.features.test.dragndrop.SpringLoadedDragContro ...@@ -80,7 +80,6 @@ import foundation.e.blisslauncher.features.test.dragndrop.SpringLoadedDragContro
import foundation.e.blisslauncher.features.test.graphics.DragPreviewProvider; import foundation.e.blisslauncher.features.test.graphics.DragPreviewProvider;
import foundation.e.blisslauncher.features.test.uninstall.UninstallHelper; import foundation.e.blisslauncher.features.test.uninstall.UninstallHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
...@@ -1012,6 +1011,24 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V ...@@ -1012,6 +1011,24 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
child.startAnimation(AnimationUtils child.startAnimation(AnimationUtils
.loadAnimation(getContext(), R.anim.wobble_reverse)); .loadAnimation(getContext(), R.anim.wobble_reverse));
} }
LauncherItem info = (LauncherItem) child.getTag();
if (child instanceof IconTextView && (info instanceof ApplicationItem || info instanceof ShortcutItem) && !UninstallHelper.INSTANCE
.isUninstallDisabled(info.user.getRealHandle(), getContext())) {
// Return early if this app is system app
if (info instanceof ApplicationItem) {
ApplicationItem applicationItem = (ApplicationItem) info;
if (applicationItem.isSystemApp != ApplicationItem.FLAG_SYSTEM_UNKNOWN) {
if ((applicationItem.isSystemApp & ApplicationItem.FLAG_SYSTEM_NO) != 0) {
((IconTextView) child).applyUninstallIconState(true);
}
} else {
((IconTextView) child).applyUninstallIconState(true);
}
} else if (info instanceof ShortcutItem) {
((IconTextView) child).applyUninstallIconState(true);
}
}
} }
}); });
} }
...@@ -1867,6 +1884,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V ...@@ -1867,6 +1884,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
folderView.startAnimation(AnimationUtils folderView.startAnimation(AnimationUtils
.loadAnimation(getContext(), R.anim.wobble_reverse)); .loadAnimation(getContext(), R.anim.wobble_reverse));
} }
folderView.applyUninstallIconState(false);
}); });
return true; return true;
} }
...@@ -2796,12 +2814,13 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V ...@@ -2796,12 +2814,13 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
lastFolderItem.screenId = folder.screenId; lastFolderItem.screenId = folder.screenId;
bindItems(Collections.singletonList(lastFolderItem), true); bindItems(Collections.singletonList(lastFolderItem), true);
} else { } else {
folder.icon = new GraphicsUtil(getContext()).generateFolderIcon(getContext(), folder); folder.icon = new GraphicsUtil(getContext())
.generateFolderIcon(getContext(), folder);
layout.removeViewInLayout(parent); layout.removeViewInLayout(parent);
if (parent instanceof DropTarget) { if (parent instanceof DropTarget) {
mDragController.removeDropTarget((DropTarget) parent); mDragController.removeDropTarget((DropTarget) parent);
} }
bindItems(Arrays.asList(folder), true); bindItems(Collections.singletonList(folder), true);
} }
} }
} }
......
...@@ -22,12 +22,15 @@ import android.widget.GridLayout ...@@ -22,12 +22,15 @@ import android.widget.GridLayout
import androidx.annotation.IntDef import androidx.annotation.IntDef
import foundation.e.blisslauncher.R import foundation.e.blisslauncher.R
import foundation.e.blisslauncher.core.Utilities import foundation.e.blisslauncher.core.Utilities
import foundation.e.blisslauncher.core.database.model.ApplicationItem
import foundation.e.blisslauncher.core.database.model.LauncherItem import foundation.e.blisslauncher.core.database.model.LauncherItem
import foundation.e.blisslauncher.core.database.model.ShortcutItem
import foundation.e.blisslauncher.core.utils.Constants import foundation.e.blisslauncher.core.utils.Constants
import foundation.e.blisslauncher.features.launcher.Hotseat import foundation.e.blisslauncher.features.launcher.Hotseat
import foundation.e.blisslauncher.features.test.anim.Interpolators import foundation.e.blisslauncher.features.test.anim.Interpolators
import foundation.e.blisslauncher.features.test.dragndrop.DropTarget import foundation.e.blisslauncher.features.test.dragndrop.DropTarget
import foundation.e.blisslauncher.features.test.graphics.DragPreviewProvider import foundation.e.blisslauncher.features.test.graphics.DragPreviewProvider
import foundation.e.blisslauncher.features.test.uninstall.UninstallHelper.isUninstallDisabled
import java.lang.Double.MAX_VALUE import java.lang.Double.MAX_VALUE
import java.util.ArrayList import java.util.ArrayList
import java.util.Arrays import java.util.Arrays
...@@ -867,6 +870,26 @@ open class CellLayout @JvmOverloads constructor( ...@@ -867,6 +870,26 @@ open class CellLayout @JvmOverloads constructor(
) )
) )
} }
val info: LauncherItem = dragView.getTag() as LauncherItem
if ((info is ApplicationItem || info is ShortcutItem) && !isUninstallDisabled(
info.user.realHandle,
context
)
) {
// Return early if this app is system app
if (info is ApplicationItem) {
if (info.isSystemApp != ApplicationItem.FLAG_SYSTEM_UNKNOWN) {
if (info.isSystemApp and ApplicationItem.FLAG_SYSTEM_NO != 0) {
dragView.applyUninstallIconState(true)
}
} else {
dragView.applyUninstallIconState(true)
}
} else if (info is ShortcutItem) {
dragView.applyUninstallIconState(true)
}
}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment