Commit 5896f532 by Baoxy

fix: 禁止桌面摆放多个相同图标/优化激活逻辑

parent 7808bffa
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<activity android:name=".settings.wifi.WifiWhiteListActivity" <activity android:name=".settings.wifi.WifiWhiteListActivity"
android:excludeFromRecents="true"/> android:excludeFromRecents="true"/>
<activity android:name=".function.setting.AdminSettingActivity" <activity android:name=".function.setting.SettingAdminActivity"
android:theme="@style/SettingTheme" android:theme="@style/SettingTheme"
android:excludeFromRecents="true"/> android:excludeFromRecents="true"/>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:orientation="vertical" android:orientation="vertical"
tools:context="com.android.launcher3.function.setting.AdminSettingActivity"> tools:context="com.android.launcher3.function.setting.SettingAdminActivity">
<TextView <TextView
android:id="@+id/tv_setting_title" android:id="@+id/tv_setting_title"
......
...@@ -153,6 +153,7 @@ import com.android.launcher3.widget.WidgetAddFlowHandler; ...@@ -153,6 +153,7 @@ import com.android.launcher3.widget.WidgetAddFlowHandler;
import com.android.launcher3.widget.WidgetHostViewLoader; import com.android.launcher3.widget.WidgetHostViewLoader;
import com.android.launcher3.widget.WidgetsContainerView; import com.android.launcher3.widget.WidgetsContainerView;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.secspace.lib.common.dialog.other.DialogUIUtils;
import com.secspace.lib.common.event.ChangeWallPaperEvent; import com.secspace.lib.common.event.ChangeWallPaperEvent;
import com.secspace.lib.common.event.InitEvent; import com.secspace.lib.common.event.InitEvent;
import com.secspace.lib.common.event.RefreshWorkSpaceEvent; import com.secspace.lib.common.event.RefreshWorkSpaceEvent;
...@@ -1211,12 +1212,6 @@ public class Launcher extends BaseActivity ...@@ -1211,12 +1212,6 @@ public class Launcher extends BaseActivity
} }
private void activationNext() { private void activationNext() {
String pwd = Prefs.getLoginPwd(this);
if (TextUtils.isEmpty(pwd)) {
Intent intent = new Intent(this, PwdPinSetPwdActivity.class);
startActivity(intent);
return;
}
LauncherAppState app = LauncherAppState.getInstanceNoCreate(); LauncherAppState app = LauncherAppState.getInstanceNoCreate();
if (app != null) { if (app != null) {
app.getModel().forceReload(); app.getModel().forceReload();
...@@ -3121,7 +3116,7 @@ public class Launcher extends BaseActivity ...@@ -3121,7 +3116,7 @@ public class Launcher extends BaseActivity
if (TextUtils.equals(((EditText)view).getText().toString(), Prefs.getLoginPwd(mAppContext))) { if (TextUtils.equals(((EditText)view).getText().toString(), Prefs.getLoginPwd(mAppContext))) {
IntentUtil.startExitService(mAppContext); IntentUtil.startExitService(mAppContext);
} else { } else {
ToastUtil.showLong(mAppContext, "密码错误!"); DialogUIUtils.showToastCenter("密码错误");
ErrorTimeHelper.getInstance(mAppContext).addErrorCount(); ErrorTimeHelper.getInstance(mAppContext).addErrorCount();
} }
} }
......
...@@ -9,8 +9,9 @@ import android.text.TextUtils; ...@@ -9,8 +9,9 @@ import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import com.android.launcher3.function.setting.AdminSettingActivity; import com.android.launcher3.function.setting.SettingAdminActivity;
import com.android.launcher3.settings.ErrorTimeHelper; import com.android.launcher3.settings.ErrorTimeHelper;
import com.secspace.lib.common.dialog.other.DialogUIUtils;
import com.secspace.lib.common.function.DialogManager; import com.secspace.lib.common.function.DialogManager;
import com.secspace.lib.common.utils.InputUtil; import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.Prefs; import com.secspace.lib.common.utils.Prefs;
...@@ -37,14 +38,13 @@ public class ManagerAuthActivity extends BaseActivity { ...@@ -37,14 +38,13 @@ public class ManagerAuthActivity extends BaseActivity {
boolean canInputPwd = ErrorTimeHelper.getInstance(mAppContext).canInputPwd(); boolean canInputPwd = ErrorTimeHelper.getInstance(mAppContext).canInputPwd();
if (canInputPwd){ if (canInputPwd){
if (TextUtils.equals(editText.getText().toString(), Prefs.getLoginPwd(mAppContext))) { if (TextUtils.equals(editText.getText().toString(), Prefs.getLoginPwd(mAppContext))) {
ToastUtil.showLong(mAppContext, "密码正确!");
finish(); finish();
ErrorTimeHelper.getInstance(mAppContext).resetLockTimeAndCount(); ErrorTimeHelper.getInstance(mAppContext).resetLockTimeAndCount();
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(mAppContext, AdminSettingActivity.class); intent.setClass(mAppContext, SettingAdminActivity.class);
startActivity(intent); startActivity(intent);
} else { } else {
ToastUtil.showLong(mAppContext, "密码错误!"); DialogUIUtils.showToastCenter("密码错误");
ErrorTimeHelper.getInstance(mAppContext).addErrorCount(); ErrorTimeHelper.getInstance(mAppContext).addErrorCount();
finish(); finish();
} }
......
...@@ -105,12 +105,16 @@ public class Workspace extends PagedView ...@@ -105,12 +105,16 @@ public class Workspace extends PagedView
Insettable, DropTargetSource { Insettable, DropTargetSource {
private static final String TAG = "Launcher.Workspace"; private static final String TAG = "Launcher.Workspace";
/** The value that {@link #mTransitionProgress} must be greater than for /**
* {@link #transitionStateShouldAllowDrop()} to return true. */ * The value that {@link #mTransitionProgress} must be greater than for
* {@link #transitionStateShouldAllowDrop()} to return true.
*/
private static final float ALLOW_DROP_TRANSITION_PROGRESS = 0.25f; private static final float ALLOW_DROP_TRANSITION_PROGRESS = 0.25f;
/** The value that {@link #mTransitionProgress} must be greater than for /**
* {@link #isFinishedSwitchingState()} ()} to return true. */ * The value that {@link #mTransitionProgress} must be greater than for
* {@link #isFinishedSwitchingState()} ()} to return true.
*/
private static final float FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS = 0.5f; private static final float FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS = 0.5f;
private static boolean ENFORCE_DRAG_EVENT_ORDER = false; private static boolean ENFORCE_DRAG_EVENT_ORDER = false;
...@@ -135,15 +139,20 @@ public class Workspace extends PagedView ...@@ -135,15 +139,20 @@ public class Workspace extends PagedView
private long mCustomContentShowTime = -1; private long mCustomContentShowTime = -1;
private LayoutTransition mLayoutTransition; private LayoutTransition mLayoutTransition;
@Thunk final WallpaperManager mWallpaperManager; @Thunk
final WallpaperManager mWallpaperManager;
private ShortcutAndWidgetContainer mDragSourceInternal; private ShortcutAndWidgetContainer mDragSourceInternal;
@Thunk LongArrayMap<CellLayout> mWorkspaceScreens = new LongArrayMap<>(); @Thunk
@Thunk ArrayList<Long> mScreenOrder = new ArrayList<Long>(); LongArrayMap<CellLayout> mWorkspaceScreens = new LongArrayMap<>();
@Thunk
ArrayList<Long> mScreenOrder = new ArrayList<Long>();
@Thunk Runnable mRemoveEmptyScreenRunnable; @Thunk
@Thunk boolean mDeferRemoveExtraEmptyScreen = false; Runnable mRemoveEmptyScreenRunnable;
@Thunk
boolean mDeferRemoveExtraEmptyScreen = false;
/** /**
* CellInfo for the cell that is currently being dragged * CellInfo for the cell that is currently being dragged
...@@ -153,7 +162,8 @@ public class Workspace extends PagedView ...@@ -153,7 +162,8 @@ public class Workspace extends PagedView
/** /**
* Target drop area calculated during last acceptDrop call. * Target drop area calculated during last acceptDrop call.
*/ */
@Thunk int[] mTargetCell = new int[2]; @Thunk
int[] mTargetCell = new int[2];
private int mDragOverX = -1; private int mDragOverX = -1;
private int mDragOverY = -1; private int mDragOverY = -1;
...@@ -165,7 +175,8 @@ public class Workspace extends PagedView ...@@ -165,7 +175,8 @@ public class Workspace extends PagedView
/** /**
* The CellLayout that is currently being dragged over * The CellLayout that is currently being dragged over
*/ */
@Thunk CellLayout mDragTargetLayout = null; @Thunk
CellLayout mDragTargetLayout = null;
/** /**
* The CellLayout that we will show as highlighted * The CellLayout that we will show as highlighted
*/ */
...@@ -176,15 +187,18 @@ public class Workspace extends PagedView ...@@ -176,15 +187,18 @@ public class Workspace extends PagedView
*/ */
private CellLayout mDropToLayout = null; private CellLayout mDropToLayout = null;
@Thunk Launcher mLauncher; @Thunk
@Thunk DragController mDragController; Launcher mLauncher;
@Thunk
DragController mDragController;
// These are temporary variables to prevent having to allocate a new object just to // These are temporary variables to prevent having to allocate a new object just to
// return an (x, y) value from helper functions. Do NOT use them to maintain other state. // return an (x, y) value from helper functions. Do NOT use them to maintain other state.
private static final Rect sTempRect = new Rect(); private static final Rect sTempRect = new Rect();
private final int[] mTempXY = new int[2]; private final int[] mTempXY = new int[2];
@Thunk float[] mDragViewVisualCenter = new float[2]; @Thunk
float[] mDragViewVisualCenter = new float[2];
private float[] mTempTouchCoordinates = new float[2]; private float[] mTempTouchCoordinates = new float[2];
private SpringLoadedDragController mSpringLoadedDragController; private SpringLoadedDragController mSpringLoadedDragController;
...@@ -194,11 +208,11 @@ public class Workspace extends PagedView ...@@ -194,11 +208,11 @@ public class Workspace extends PagedView
// in all apps or customize mode) // in all apps or customize mode)
public enum State { public enum State {
NORMAL (false, false, ContainerType.WORKSPACE), NORMAL(false, false, ContainerType.WORKSPACE),
NORMAL_HIDDEN (false, false, ContainerType.ALLAPPS), NORMAL_HIDDEN(false, false, ContainerType.ALLAPPS),
SPRING_LOADED (false, true, ContainerType.WORKSPACE), SPRING_LOADED(false, true, ContainerType.WORKSPACE),
OVERVIEW (true, true, ContainerType.OVERVIEW), OVERVIEW(true, true, ContainerType.OVERVIEW),
OVERVIEW_HIDDEN (true, false, ContainerType.WIDGETS); OVERVIEW_HIDDEN(true, false, ContainerType.WIDGETS);
public final boolean shouldUpdateWidget; public final boolean shouldUpdateWidget;
public final boolean hasMultipleVisiblePages; public final boolean hasMultipleVisiblePages;
...@@ -213,8 +227,8 @@ public class Workspace extends PagedView ...@@ -213,8 +227,8 @@ public class Workspace extends PagedView
// Direction used for moving the workspace and hotseat UI // Direction used for moving the workspace and hotseat UI
public enum Direction { public enum Direction {
X (TRANSLATION_X), X(TRANSLATION_X),
Y (TRANSLATION_Y); Y(TRANSLATION_Y);
private final Property<View, Float> viewProperty; private final Property<View, Float> viewProperty;
...@@ -228,13 +242,13 @@ public class Workspace extends PagedView ...@@ -228,13 +242,13 @@ public class Workspace extends PagedView
/** /**
* These values correspond to {@link Direction#X} & {@link Direction#Y} * These values correspond to {@link Direction#X} & {@link Direction#Y}
*/ */
private float[] mPageAlpha = new float[] {1, 1}; private float[] mPageAlpha = new float[]{1, 1};
/** /**
* Hotseat alpha can be changed when moving horizontally, vertically, changing states. * Hotseat alpha can be changed when moving horizontally, vertically, changing states.
* The values correspond to {@link Direction#X}, {@link Direction#Y} & * The values correspond to {@link Direction#X}, {@link Direction#Y} &
* {@link #HOTSEAT_STATE_ALPHA_INDEX} respectively. * {@link #HOTSEAT_STATE_ALPHA_INDEX} respectively.
*/ */
private float[] mHotseatAlpha = new float[] {1, 1, 1}; private float[] mHotseatAlpha = new float[]{1, 1, 1};
public static final int QSB_ALPHA_INDEX_STATE_CHANGE = 0; public static final int QSB_ALPHA_INDEX_STATE_CHANGE = 0;
public static final int QSB_ALPHA_INDEX_Y_TRANSLATION = 1; public static final int QSB_ALPHA_INDEX_Y_TRANSLATION = 1;
...@@ -259,7 +273,8 @@ public class Workspace extends PagedView ...@@ -259,7 +273,8 @@ public class Workspace extends PagedView
final WallpaperOffsetInterpolator mWallpaperOffset; final WallpaperOffsetInterpolator mWallpaperOffset;
private boolean mUnlockWallpaperFromDefaultPageOnLayout; private boolean mUnlockWallpaperFromDefaultPageOnLayout;
@Thunk Runnable mDelayedResizeRunnable; @Thunk
Runnable mDelayedResizeRunnable;
private Runnable mDelayedSnapToPageRunnable; private Runnable mDelayedSnapToPageRunnable;
// Variables relating to the creation of user folders by hovering shortcuts over shortcuts // Variables relating to the creation of user folders by hovering shortcuts over shortcuts
...@@ -295,8 +310,10 @@ public class Workspace extends PagedView ...@@ -295,8 +310,10 @@ public class Workspace extends PagedView
private static final int DRAG_MODE_ADD_TO_FOLDER = 2; private static final int DRAG_MODE_ADD_TO_FOLDER = 2;
private static final int DRAG_MODE_REORDER = 3; private static final int DRAG_MODE_REORDER = 3;
private int mDragMode = DRAG_MODE_NONE; private int mDragMode = DRAG_MODE_NONE;
@Thunk int mLastReorderX = -1; @Thunk
@Thunk int mLastReorderY = -1; int mLastReorderX = -1;
@Thunk
int mLastReorderY = -1;
private SparseArray<Parcelable> mSavedStates; private SparseArray<Parcelable> mSavedStates;
private final ArrayList<Integer> mRestoredPages = new ArrayList<Integer>(); private final ArrayList<Integer> mRestoredPages = new ArrayList<Integer>();
...@@ -304,7 +321,8 @@ public class Workspace extends PagedView ...@@ -304,7 +321,8 @@ public class Workspace extends PagedView
private float mCurrentScale; private float mCurrentScale;
private float mTransitionProgress; private float mTransitionProgress;
@Thunk Runnable mDeferredAction; @Thunk
Runnable mDeferredAction;
private boolean mDeferDropAfterUninstall; private boolean mDeferDropAfterUninstall;
private boolean mUninstallSuccessful; private boolean mUninstallSuccessful;
...@@ -559,6 +577,7 @@ public class Workspace extends PagedView ...@@ -559,6 +577,7 @@ public class Workspace extends PagedView
void enableLayoutTransitions() { void enableLayoutTransitions() {
setLayoutTransition(mLayoutTransition); setLayoutTransition(mLayoutTransition);
} }
void disableLayoutTransitions() { void disableLayoutTransitions() {
setLayoutTransition(null); setLayoutTransition(null);
} }
...@@ -586,6 +605,7 @@ public class Workspace extends PagedView ...@@ -586,6 +605,7 @@ public class Workspace extends PagedView
/** /**
* Initializes and binds the first page * Initializes and binds the first page
*
* @param qsb an existing qsb to recycle or null. * @param qsb an existing qsb to recycle or null.
*/ */
public void bindAndInitFirstWorkspaceScreen(View qsb) { public void bindAndInitFirstWorkspaceScreen(View qsb) {
...@@ -780,7 +800,7 @@ public class Workspace extends PagedView ...@@ -780,7 +800,7 @@ public class Workspace extends PagedView
lp.canReorder = false; lp.canReorder = false;
lp.isFullscreen = true; lp.isFullscreen = true;
if (customContent instanceof Insettable) { if (customContent instanceof Insettable) {
((Insettable)customContent).setInsets(mInsets); ((Insettable) customContent).setInsets(mInsets);
} }
// Verify that the child is removed from any existing parent. // Verify that the child is removed from any existing parent.
...@@ -1034,7 +1054,7 @@ public class Workspace extends PagedView ...@@ -1034,7 +1054,7 @@ public class Workspace extends PagedView
int minScreens = 1 + numCustomPages(); int minScreens = 1 + numCustomPages();
int pageShift = 0; int pageShift = 0;
for (Long id: removeScreens) { for (Long id : removeScreens) {
CellLayout cl = mWorkspaceScreens.get(id); CellLayout cl = mWorkspaceScreens.get(id);
mWorkspaceScreens.remove(id); mWorkspaceScreens.remove(id);
mScreenOrder.remove(id); mScreenOrder.remove(id);
...@@ -1192,14 +1212,16 @@ public class Workspace extends PagedView ...@@ -1192,14 +1212,16 @@ public class Workspace extends PagedView
return mIsSwitchingState; return mIsSwitchingState;
} }
/** This differs from isSwitchingState in that we take into account how far the transition /**
* has completed. */ * This differs from isSwitchingState in that we take into account how far the transition
* has completed.
*/
public boolean isFinishedSwitchingState() { public boolean isFinishedSwitchingState() {
return !mIsSwitchingState return !mIsSwitchingState
|| (mTransitionProgress > FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS); || (mTransitionProgress > FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS);
} }
protected void onWindowVisibilityChanged (int visibility) { protected void onWindowVisibilityChanged(int visibility) {
mLauncher.onWindowVisibilityChanged(visibility); mLauncher.onWindowVisibilityChanged(visibility);
} }
...@@ -1500,6 +1522,7 @@ public class Workspace extends PagedView ...@@ -1500,6 +1522,7 @@ public class Workspace extends PagedView
/** /**
* Moves the workspace UI in the Y direction. * Moves the workspace UI in the Y direction.
*
* @param translation the amount of shift. * @param translation the amount of shift.
* @param alpha the alpha for the workspace page * @param alpha the alpha for the workspace page
*/ */
...@@ -1512,6 +1535,7 @@ public class Workspace extends PagedView ...@@ -1512,6 +1535,7 @@ public class Workspace extends PagedView
/** /**
* Moves the workspace UI in the provided direction. * Moves the workspace UI in the provided direction.
*
* @param direction the direction to move the workspace * @param direction the direction to move the workspace
* @param translation the amount of shift. * @param translation the amount of shift.
* @param alpha the alpha for the workspace page * @param alpha the alpha for the workspace page
...@@ -1539,6 +1563,7 @@ public class Workspace extends PagedView ...@@ -1539,6 +1563,7 @@ public class Workspace extends PagedView
/** /**
* Moves the Hotseat UI in the provided direction. * Moves the Hotseat UI in the provided direction.
*
* @param direction the direction to move the workspace * @param direction the direction to move the workspace
* @param translation the amount of shift. * @param translation the amount of shift.
* @param alpha the alpha for the hotseat page * @param alpha the alpha for the hotseat page
...@@ -1843,12 +1868,15 @@ public class Workspace extends PagedView ...@@ -1843,12 +1868,15 @@ public class Workspace extends PagedView
return mState != State.NORMAL; return mState != State.NORMAL;
} }
/** Returns whether a drag should be allowed to be started from the current workspace state. */ /**
* Returns whether a drag should be allowed to be started from the current workspace state.
*/
public boolean workspaceIconsCanBeDragged() { public boolean workspaceIconsCanBeDragged() {
return mState == State.NORMAL || mState == State.SPRING_LOADED; return mState == State.NORMAL || mState == State.SPRING_LOADED;
} }
@Thunk void updateChildrenLayersEnabled(boolean force) { @Thunk
void updateChildrenLayersEnabled(boolean force) {
boolean small = mState == State.OVERVIEW || mIsSwitchingState; boolean small = mState == State.OVERVIEW || mIsSwitchingState;
boolean enableChildrenLayers = force || small || mAnimatingViewIntoPlace || isPageInTransition(); boolean enableChildrenLayers = force || small || mAnimatingViewIntoPlace || isPageInTransition();
...@@ -2208,7 +2236,7 @@ public class Workspace extends PagedView ...@@ -2208,7 +2236,7 @@ public class Workspace extends PagedView
@Override @Override
protected void enableAccessibleDrag(boolean enable) { protected void enableAccessibleDrag(boolean enable) {
super.enableAccessibleDrag(enable); super.enableAccessibleDrag(enable);
setEnableForLayout(mLauncher.getHotseat().getLayout(),enable); setEnableForLayout(mLauncher.getHotseat().getLayout(), enable);
// We need to allow our individual children to become click handlers in this // We need to allow our individual children to become click handlers in this
// case, so temporarily unset the click handlers. // case, so temporarily unset the click handlers.
...@@ -2256,13 +2284,13 @@ public class Workspace extends PagedView ...@@ -2256,13 +2284,13 @@ public class Workspace extends PagedView
dragLayerY += dragRect.top; dragLayerY += dragRect.top;
// Note: The dragRect is used to calculate drag layer offsets, but the // Note: The dragRect is used to calculate drag layer offsets, but the
// dragVisualizeOffset in addition to the dragRect (the size) to position the outline. // dragVisualizeOffset in addition to the dragRect (the size) to position the outline.
dragVisualizeOffset = new Point(- halfPadding, halfPadding); dragVisualizeOffset = new Point(-halfPadding, halfPadding);
} else if (child instanceof FolderIcon) { } else if (child instanceof FolderIcon) {
int previewSize = grid.folderIconSizePx; int previewSize = grid.folderIconSizePx;
dragVisualizeOffset = new Point(- halfPadding, halfPadding - child.getPaddingTop()); dragVisualizeOffset = new Point(-halfPadding, halfPadding - child.getPaddingTop());
dragRect = new Rect(0, child.getPaddingTop(), child.getWidth(), previewSize); dragRect = new Rect(0, child.getPaddingTop(), child.getWidth(), previewSize);
} else if (previewProvider instanceof ShortcutDragPreviewProvider) { } else if (previewProvider instanceof ShortcutDragPreviewProvider) {
dragVisualizeOffset = new Point(- halfPadding, halfPadding); dragVisualizeOffset = new Point(-halfPadding, halfPadding);
} }
// Clear the pressed state if necessary // Clear the pressed state if necessary
...@@ -2297,141 +2325,10 @@ public class Workspace extends PagedView ...@@ -2297,141 +2325,10 @@ public class Workspace extends PagedView
(mState == State.NORMAL || mState == State.SPRING_LOADED)); (mState == State.NORMAL || mState == State.SPRING_LOADED));
} }
// /** // /**
// * {@inheritDoc} // * {@inheritDoc}
// */ // */
// @Override @Override
// public boolean acceptDrop(DragObject d) {
// // If it's an external drop (e.g. from All Apps), check if it should be accepted
// CellLayout dropTargetLayout = mDropToLayout;
// if (d.dragSource != this) {
// // Don't accept the drop if we're not over a screen at time of drop
// if (dropTargetLayout == null) {
// return false;
// }
//
// // Don't accept the drop if intent of drop is empty
// if (d.dragInfo == null || d.dragInfo.getIntent() == null) {
// return false;
// }
//
// // Don't accept the drop if intent exists
// Intent dragIntent = d.dragInfo.getIntent();
// Intent cloneIntent = dragIntent.cloneFilter();
// cloneIntent.putExtras(dragIntent);
//
// String intentUriWithPackage = cloneIntent.toUri(0);
// String intentUriOnlyComponent = null;
// if (dragIntent.getComponent() != null) {
// if (dragIntent.getPackage() == null) {
// intentUriWithPackage = cloneIntent.setPackage(dragIntent.getComponent().getPackageName()).toUri(0);
// }
// intentUriOnlyComponent = new Intent().setComponent(dragIntent.getComponent()).toUri(0);
// }
// String intentUriWithoutPackage = cloneIntent.setPackage(null).toUri(0);
// synchronized (LauncherModel.sBgDataModel) {
// List<ItemInfo> itemInfos = LauncherModel.sBgDataModel.workspaceItems;
// if (itemInfos.size() > 0) {
// for (ItemInfo info : itemInfos) {
// if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
// FolderInfo folderInfo = (FolderInfo) info;
// if (folderInfo.contents != null && folderInfo.contents.size() > 0) {
// for (ShortcutInfo shortcutInfo : folderInfo.contents) {
// if (shortcutInfo.intent != null) {
// Intent shortcutIntent = shortcutInfo.intent.cloneFilter().putExtras(shortcutInfo.intent);
//
// String intentUri = shortcutIntent.toUri(0);
// if (intentUriWithoutPackage.equals(intentUri) || intentUriWithPackage.equals(intentUri) || intentUri.equals(intentUriOnlyComponent)) {
// return false;
// }
// }
// }
// }
// } else {
// if (info.getIntent() != null) {
// Intent shortcutIntent = info.getIntent().cloneFilter().putExtras(info.getIntent());
// String intentUri = shortcutIntent.toUri(0);
// if (intentUriWithoutPackage.equals(intentUri) || intentUriWithPackage.equals(intentUri) || intentUri.equals(intentUriOnlyComponent)) {
// return false;
// }
// }
// }
// }
// }
// }
//
// if (!transitionStateShouldAllowDrop()) return false;
//
// mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
//
// // We want the point to be mapped to the dragTarget.
// if (mLauncher.isHotseatLayout(dropTargetLayout)) {
// mapPointFromSelfToHotseatLayout(mLauncher.getHotseat(), mDragViewVisualCenter);
// } else {
// mapPointFromSelfToChild(dropTargetLayout, mDragViewVisualCenter);
// }
//
// int spanX;
// int spanY;
// if (mDragInfo != null) {
// final CellLayout.CellInfo dragCellInfo = mDragInfo;
// spanX = dragCellInfo.spanX;
// spanY = dragCellInfo.spanY;
// } else {
// spanX = d.dragInfo.spanX;
// spanY = d.dragInfo.spanY;
// }
//
// int minSpanX = spanX;
// int minSpanY = spanY;
// if (d.dragInfo instanceof PendingAddWidgetInfo) {
// minSpanX = ((PendingAddWidgetInfo) d.dragInfo).minSpanX;
// minSpanY = ((PendingAddWidgetInfo) d.dragInfo).minSpanY;
// }
//
// mTargetCell = findNearestArea((int) mDragViewVisualCenter[0],
// (int) mDragViewVisualCenter[1], minSpanX, minSpanY, dropTargetLayout,
// mTargetCell);
// float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
// mDragViewVisualCenter[1], mTargetCell);
// if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
// dropTargetLayout, mTargetCell, distance, true)) {
// // Don't directly create folder on hotseat.
// return !mLauncher.isHotseatLayout(dropTargetLayout);
// }
//
// if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder(d.dragInfo,
// dropTargetLayout, mTargetCell, distance)) {
// return true;
// }
//
// int[] resultSpan = new int[2];
// mTargetCell = dropTargetLayout.performReorder((int) mDragViewVisualCenter[0],
// (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY,
// null, mTargetCell, resultSpan, CellLayout.MODE_ACCEPT_DROP);
// boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0;
//
// // Don't accept the drop if there's no room for the item
// if (!foundCell) {
// // Don't show the message if we are dropping on the AllApps button and the hotseat
// // is full
// boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
// return false;
// }
// }
//
// long screenId = getIdForScreen(dropTargetLayout);
// if (screenId == EXTRA_EMPTY_SCREEN_ID) {
// commitExtraEmptyScreen();
// }
//
// return true;
// }
/**
* {@inheritDoc}
*/
public boolean acceptDrop(DragObject d) { public boolean acceptDrop(DragObject d) {
// If it's an external drop (e.g. from All Apps), check if it should be accepted // If it's an external drop (e.g. from All Apps), check if it should be accepted
CellLayout dropTargetLayout = mDropToLayout; CellLayout dropTargetLayout = mDropToLayout;
...@@ -2440,6 +2337,57 @@ public class Workspace extends PagedView ...@@ -2440,6 +2337,57 @@ public class Workspace extends PagedView
if (dropTargetLayout == null) { if (dropTargetLayout == null) {
return false; return false;
} }
// Don't accept the drop if intent of drop is empty
if (d.dragInfo == null || d.dragInfo.getIntent() == null) {
return false;
}
// Don't accept the drop if intent exists
Intent dragIntent = d.dragInfo.getIntent();
Intent cloneIntent = dragIntent.cloneFilter();
cloneIntent.putExtras(dragIntent);
String intentUriWithPackage = cloneIntent.toUri(0);
String intentUriOnlyComponent = null;
if (dragIntent.getComponent() != null) {
if (dragIntent.getPackage() == null) {
intentUriWithPackage = cloneIntent.setPackage(dragIntent.getComponent().getPackageName()).toUri(0);
}
intentUriOnlyComponent = new Intent().setComponent(dragIntent.getComponent()).toUri(0);
}
String intentUriWithoutPackage = cloneIntent.setPackage(null).toUri(0);
synchronized (LauncherModel.sBgDataModel) {
List<ItemInfo> itemInfos = LauncherModel.sBgDataModel.workspaceItems;
if (itemInfos.size() > 0) {
for (ItemInfo info : itemInfos) {
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
FolderInfo folderInfo = (FolderInfo) info;
if (folderInfo.contents != null && folderInfo.contents.size() > 0) {
for (ShortcutInfo shortcutInfo : folderInfo.contents) {
if (shortcutInfo.intent != null) {
Intent shortcutIntent = shortcutInfo.intent.cloneFilter().putExtras(shortcutInfo.intent);
String intentUri = shortcutIntent.toUri(0);
if (intentUriWithoutPackage.equals(intentUri) || intentUriWithPackage.equals(intentUri) || intentUri.equals(intentUriOnlyComponent)) {
return false;
}
}
}
}
} else {
if (info.getIntent() != null) {
Intent shortcutIntent = info.getIntent().cloneFilter().putExtras(info.getIntent());
String intentUri = shortcutIntent.toUri(0);
if (intentUriWithoutPackage.equals(intentUri) || intentUriWithPackage.equals(intentUri) || intentUri.equals(intentUriOnlyComponent)) {
return false;
}
}
}
}
}
}
if (!transitionStateShouldAllowDrop()) return false; if (!transitionStateShouldAllowDrop()) return false;
mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter); mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
...@@ -2451,8 +2399,8 @@ public class Workspace extends PagedView ...@@ -2451,8 +2399,8 @@ public class Workspace extends PagedView
mapPointFromSelfToChild(dropTargetLayout, mDragViewVisualCenter); mapPointFromSelfToChild(dropTargetLayout, mDragViewVisualCenter);
} }
int spanX = 1; int spanX;
int spanY = 1; int spanY;
if (mDragInfo != null) { if (mDragInfo != null) {
final CellLayout.CellInfo dragCellInfo = mDragInfo; final CellLayout.CellInfo dragCellInfo = mDragInfo;
spanX = dragCellInfo.spanX; spanX = dragCellInfo.spanX;
...@@ -2476,7 +2424,8 @@ public class Workspace extends PagedView ...@@ -2476,7 +2424,8 @@ public class Workspace extends PagedView
mDragViewVisualCenter[1], mTargetCell); mDragViewVisualCenter[1], mTargetCell);
if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo, if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
dropTargetLayout, mTargetCell, distance, true)) { dropTargetLayout, mTargetCell, distance, true)) {
return true; // Don't directly create folder on hotseat.
return !mLauncher.isHotseatLayout(dropTargetLayout);
} }
if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder(d.dragInfo, if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder(d.dragInfo,
...@@ -2492,7 +2441,9 @@ public class Workspace extends PagedView ...@@ -2492,7 +2441,9 @@ public class Workspace extends PagedView
// Don't accept the drop if there's no room for the item // Don't accept the drop if there's no room for the item
if (!foundCell) { if (!foundCell) {
onNoCellFound(dropTargetLayout); // Don't show the message if we are dropping on the AllApps button and the hotseat
// is full
boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
return false; return false;
} }
} }
...@@ -2505,6 +2456,82 @@ public class Workspace extends PagedView ...@@ -2505,6 +2456,82 @@ public class Workspace extends PagedView
return true; return true;
} }
/**
* {@inheritDoc}
*/
// public boolean acceptDrop(DragObject d) {
// // If it's an external drop (e.g. from All Apps), check if it should be accepted
// CellLayout dropTargetLayout = mDropToLayout;
// if (d.dragSource != this) {
// // Don't accept the drop if we're not over a screen at time of drop
// if (dropTargetLayout == null) {
// return false;
// }
// if (!transitionStateShouldAllowDrop()) return false;
//
// mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
//
// // We want the point to be mapped to the dragTarget.
// if (mLauncher.isHotseatLayout(dropTargetLayout)) {
// mapPointFromSelfToHotseatLayout(mLauncher.getHotseat(), mDragViewVisualCenter);
// } else {
// mapPointFromSelfToChild(dropTargetLayout, mDragViewVisualCenter);
// }
//
// int spanX = 1;
// int spanY = 1;
// if (mDragInfo != null) {
// final CellLayout.CellInfo dragCellInfo = mDragInfo;
// spanX = dragCellInfo.spanX;
// spanY = dragCellInfo.spanY;
// } else {
// spanX = d.dragInfo.spanX;
// spanY = d.dragInfo.spanY;
// }
//
// int minSpanX = spanX;
// int minSpanY = spanY;
// if (d.dragInfo instanceof PendingAddWidgetInfo) {
// minSpanX = ((PendingAddWidgetInfo) d.dragInfo).minSpanX;
// minSpanY = ((PendingAddWidgetInfo) d.dragInfo).minSpanY;
// }
//
// mTargetCell = findNearestArea((int) mDragViewVisualCenter[0],
// (int) mDragViewVisualCenter[1], minSpanX, minSpanY, dropTargetLayout,
// mTargetCell);
// float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
// mDragViewVisualCenter[1], mTargetCell);
// if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
// dropTargetLayout, mTargetCell, distance, true)) {
// return true;
// }
//
// if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder(d.dragInfo,
// dropTargetLayout, mTargetCell, distance)) {
// return true;
// }
//
// int[] resultSpan = new int[2];
// mTargetCell = dropTargetLayout.performReorder((int) mDragViewVisualCenter[0],
// (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY,
// null, mTargetCell, resultSpan, CellLayout.MODE_ACCEPT_DROP);
// boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0;
//
// // Don't accept the drop if there's no room for the item
// if (!foundCell) {
// onNoCellFound(dropTargetLayout);
// return false;
// }
// }
//
// long screenId = getIdForScreen(dropTargetLayout);
// if (screenId == EXTRA_EMPTY_SCREEN_ID) {
// commitExtraEmptyScreen();
// }
//
// return true;
// }
boolean willCreateUserFolder(ItemInfo info, CellLayout target, int[] targetCell, boolean willCreateUserFolder(ItemInfo info, CellLayout target, int[] targetCell,
float distance, boolean considerTimeout) { float distance, boolean considerTimeout) {
if (distance > mMaxDistanceForFolderCreation) return false; if (distance > mMaxDistanceForFolderCreation) return false;
...@@ -2545,6 +2572,7 @@ public class Workspace extends PagedView ...@@ -2545,6 +2572,7 @@ public class Workspace extends PagedView
return willAddToExistingUserFolder(dragInfo, dropOverView); return willAddToExistingUserFolder(dragInfo, dropOverView);
} }
boolean willAddToExistingUserFolder(ItemInfo dragInfo, View dropOverView) { boolean willAddToExistingUserFolder(ItemInfo dragInfo, View dropOverView) {
if (dropOverView != null) { if (dropOverView != null) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) dropOverView.getLayoutParams(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) dropOverView.getLayoutParams();
...@@ -2565,7 +2593,7 @@ public class Workspace extends PagedView ...@@ -2565,7 +2593,7 @@ public class Workspace extends PagedView
boolean createUserFolderIfNecessary(View newView, long container, CellLayout target, boolean createUserFolderIfNecessary(View newView, long container, CellLayout target,
int[] targetCell, float distance, boolean external, DragView dragView, int[] targetCell, float distance, boolean external, DragView dragView,
Runnable postAnimationRunnable) { Runnable postAnimationRunnable) {
if (true)return false; if (true) return false;
if (distance > mMaxDistanceForFolderCreation) return false; if (distance > mMaxDistanceForFolderCreation) return false;
View v = target.getChildAt(targetCell[0], targetCell[1]); View v = target.getChildAt(targetCell[0], targetCell[1]);
...@@ -2645,9 +2673,11 @@ public class Workspace extends PagedView ...@@ -2645,9 +2673,11 @@ public class Workspace extends PagedView
} }
@Override @Override
public void prepareAccessibilityDrop() { } public void prepareAccessibilityDrop() {
}
public void onDrop(final DragObject d) { public void onDrop(final DragObject d) {
Log.e("TAG1", "workspace onDrop: ");
mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter); mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
CellLayout dropTargetLayout = mDropToLayout; CellLayout dropTargetLayout = mDropToLayout;
...@@ -2665,8 +2695,8 @@ public class Workspace extends PagedView ...@@ -2665,8 +2695,8 @@ public class Workspace extends PagedView
int snapScreen = -1; int snapScreen = -1;
boolean resizeOnDrop = false; boolean resizeOnDrop = false;
if (d.dragSource != this) { if (d.dragSource != this) {
final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], final int[] touchXY = new int[]{(int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1] }; (int) mDragViewVisualCenter[1]};
onDropExternal(touchXY, dropTargetLayout, d); onDropExternal(touchXY, dropTargetLayout, d);
} else if (mDragInfo != null) { } else if (mDragInfo != null) {
final View cell = mDragInfo.cell; final View cell = mDragInfo.cell;
...@@ -3173,7 +3203,7 @@ public class Workspace extends PagedView ...@@ -3173,7 +3203,7 @@ public class Workspace extends PagedView
/** /**
* Updates {@link #mDragTargetLayout} and {@link #mDragOverlappingLayout} * Updates {@link #mDragTargetLayout} and {@link #mDragOverlappingLayout}
* based on the DragObject's position. * based on the DragObject's position.
* * <p>
* The layout will be: * The layout will be:
* - The Hotseat if the drag object is over it * - The Hotseat if the drag object is over it
* - A side page if we are in spring-loaded mode and the drag object is over it * - A side page if we are in spring-loaded mode and the drag object is over it
...@@ -3366,10 +3396,11 @@ public class Workspace extends PagedView ...@@ -3366,10 +3396,11 @@ public class Workspace extends PagedView
* Drop an item that didn't originate on one of the workspace screens. * Drop an item that didn't originate on one of the workspace screens.
* It may have come from Launcher (e.g. from all apps or customize), or it may have * It may have come from Launcher (e.g. from all apps or customize), or it may have
* come from another app altogether. * come from another app altogether.
* * <p>
* NOTE: This can also be called when we are outside of a drag event, when we want * NOTE: This can also be called when we are outside of a drag event, when we want
* to add an item to one of the workspace screens. * to add an item to one of the workspace screens.
*/ */
private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) { private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) {
final Runnable exitSpringLoadedRunnable = new Runnable() { final Runnable exitSpringLoadedRunnable = new Runnable() {
@Override @Override
...@@ -3387,6 +3418,26 @@ public class Workspace extends PagedView ...@@ -3387,6 +3418,26 @@ public class Workspace extends PagedView
} }
} }
// String className = null;
// ItemInfo current = d.dragInfo;
// if(current != null){
// ComponentName cpm = current.getTargetComponent();
// if(cpm != null){
// className = cpm.getClassName();
// }
// }
//
// final LongArrayMap<ItemInfo> shortcutMapCopy =
// LauncherModel.sBgDataModel.itemsIdMap.clone();
// for (ItemInfo itemInfo : shortcutMapCopy) {
// ComponentName cpm = itemInfo.getTargetComponent();
// if(cpm != null){
// if(TextUtils.equals(className, cpm.getClassName())){
// return;
// }
// }
// }
ItemInfo info = d.dragInfo; ItemInfo info = d.dragInfo;
int spanX = info.spanX; int spanX = info.spanX;
int spanY = info.spanY; int spanY = info.spanY;
...@@ -3673,6 +3724,7 @@ public class Workspace extends PagedView ...@@ -3673,6 +3724,7 @@ public class Workspace extends PagedView
setScaleY(mStateTransitionAnimation.getFinalScale()); setScaleY(mStateTransitionAnimation.getFinalScale());
} }
} }
public void resetTransitionTransform(CellLayout layout) { public void resetTransitionTransform(CellLayout layout) {
if (isSwitchingState()) { if (isSwitchingState()) {
setScaleX(mCurrentScale); setScaleX(mCurrentScale);
...@@ -3688,7 +3740,6 @@ public class Workspace extends PagedView ...@@ -3688,7 +3740,6 @@ public class Workspace extends PagedView
* Return the current CellInfo describing our current drag; this method exists * Return the current CellInfo describing our current drag; this method exists
* so that Launcher can sync this object with the correct info when the activity is created/ * so that Launcher can sync this object with the correct info when the activity is created/
* destroyed * destroyed
*
*/ */
public CellLayout.CellInfo getDragInfo() { public CellLayout.CellInfo getDragInfo() {
return mDragInfo; return mDragInfo;
...@@ -3700,10 +3751,11 @@ public class Workspace extends PagedView ...@@ -3700,10 +3751,11 @@ public class Workspace extends PagedView
/** /**
* Calculate the nearest cell where the given object would be dropped. * Calculate the nearest cell where the given object would be dropped.
* * <p>
* pixelX and pixelY should be in the coordinate system of layout * pixelX and pixelY should be in the coordinate system of layout
*/ */
@Thunk int[] findNearestArea(int pixelX, int pixelY, @Thunk
int[] findNearestArea(int pixelX, int pixelY,
int spanX, int spanY, CellLayout layout, int[] recycle) { int spanX, int spanY, CellLayout layout, int[] recycle) {
return layout.findNearestArea( return layout.findNearestArea(
pixelX, pixelY, spanX, spanY, recycle); pixelX, pixelY, spanX, spanY, recycle);
...@@ -3749,7 +3801,8 @@ public class Workspace extends PagedView ...@@ -3749,7 +3801,8 @@ public class Workspace extends PagedView
} else if (ProviderConfig.IS_DOGFOOD_BUILD) { } else if (ProviderConfig.IS_DOGFOOD_BUILD) {
throw new RuntimeException("Invalid state: cellLayout == null in " throw new RuntimeException("Invalid state: cellLayout == null in "
+ "Workspace#onDropCompleted. Please file a bug. "); + "Workspace#onDropCompleted. Please file a bug. ");
}; }
;
} }
if ((d.cancelled || (beingCalledAfterUninstall && !mUninstallSuccessful)) if ((d.cancelled || (beingCalledAfterUninstall && !mUninstallSuccessful))
&& mDragInfo.cell != null) { && mDragInfo.cell != null) {
...@@ -3995,7 +4048,7 @@ public class Workspace extends PagedView ...@@ -3995,7 +4048,7 @@ public class Workspace extends PagedView
*/ */
public void removeItemsByMatcher(final ItemInfoMatcher matcher) { public void removeItemsByMatcher(final ItemInfoMatcher matcher) {
ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts(); ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
for (final CellLayout layoutParent: cellLayouts) { for (final CellLayout layoutParent : cellLayouts) {
final ViewGroup layout = layoutParent.getShortcutsAndWidgets(); final ViewGroup layout = layoutParent.getShortcutsAndWidgets();
LongArrayMap<View> idToViewMap = new LongArrayMap<>(); LongArrayMap<View> idToViewMap = new LongArrayMap<>();
...@@ -4367,6 +4420,7 @@ public class Workspace extends PagedView ...@@ -4367,6 +4420,7 @@ public class Workspace extends PagedView
/** /**
* Called when the workspace state is changing. * Called when the workspace state is changing.
*
* @param toState final state * @param toState final state
* @param targetAnim animation which will be played during the transition or null. * @param targetAnim animation which will be played during the transition or null.
*/ */
......
...@@ -27,7 +27,7 @@ import kotlinx.coroutines.delay ...@@ -27,7 +27,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
class AdminSettingActivity : BaseActivity() { class SettingAdminActivity : BaseActivity() {
private var mContext: Context? = null private var mContext: Context? = null
private var icon: QMUICommonListItemView? = null private var icon: QMUICommonListItemView? = null
private var reinforce: QMUICommonListItemView? = null private var reinforce: QMUICommonListItemView? = null
......
package com.android.launcher3.function.setting package com.android.launcher3.function.setting
import android.app.Activity
import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View import android.view.View
import android.widget.GridLayout import android.widget.GridLayout
import android.widget.LinearLayout
import android.widget.TextView
import com.android.launcher3.BaseActivity import com.android.launcher3.BaseActivity
import com.android.launcher3.R import com.android.launcher3.R
import com.android.launcher3.mdm.DisableCompat import com.android.launcher3.mdm.DisableCompat
import com.android.launcher3.settings.Contants import com.android.launcher3.settings.Contants
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.dialog.SwitcherDialog
import com.secspace.lib.common.event.ChangeWallPaperEvent
import com.secspace.lib.common.utils.PkgManager import com.secspace.lib.common.utils.PkgManager
import com.secspace.lib.common.utils.Prefs import com.secspace.lib.common.utils.Prefs
import com.secspace.lib.common.utils.ToastUtil import com.secspace.lib.common.utils.ToastUtil
import com.secspace.lib.common.utils.UninstallUtil.removeForbidden
import com.secspace.lib.common.utils.UninstallUtil.uninstallService
import com.secspace.lib.common.utils.dp2px import com.secspace.lib.common.utils.dp2px
import kotlinx.android.synthetic.main.activity_setting.* import kotlinx.android.synthetic.main.activity_setting.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
class SettingPwdActivity : BaseActivity(){ class SettingPwdActivity : BaseActivity(){
private var mContext: Context? = null private var mContext: Context? = null
...@@ -85,60 +70,4 @@ class SettingPwdActivity : BaseActivity(){ ...@@ -85,60 +70,4 @@ class SettingPwdActivity : BaseActivity(){
DisableCompat.disableApplication(mContext, packageName) DisableCompat.disableApplication(mContext, packageName)
} }
} }
private fun uninstall() {
GlobalScope.launch(Dispatchers.Main) {
SwitcherDialog.getInstance(mContext).show(getString(R.string.edu_uninstall), "unInstall")
removeForbidden(mContext)
delay(1000)
uninstallService(mContext)
delay(800)
SwitcherDialog.getInstance(mContext).dismiss("unInstall")
}
}
override fun onActivityResult(
requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_PICK_WALLPAPER) {
if (resultCode == Activity.RESULT_OK) {
Log.e("WWWW", "AAAAA")
val selectedImage = data!!.data
EventBus.getDefault().postSticky(ChangeWallPaperEvent(selectedImage))
ToastUtil.showShort(this, "壁纸修改成功")
}
}
}
private inline fun showTipDialog(crossinline block: () -> Unit, text: String) {
val alertDialog: AlertDialog
val textView = TextView(this)
val view = LayoutInflater.from(this).inflate(R.layout.item_ll, null)
textView.text = text
val ll = view.findViewById<LinearLayout>(R.id.item_ll)
ll.addView(textView)
alertDialog = AlertDialog.Builder(this)
.setTitle(getString(R.string.tip))
.setCancelable(false)
.setView(view)
.setNegativeButton(R.string.work_cancel) { dialog, _ -> dialog.dismiss() }
.setPositiveButton(R.string.work_sure) { dialog, _ ->
run {
dialog.dismiss()
block()
}
}
.create()
if (!alertDialog.isShowing) {
alertDialog.show()
}
}
companion object {
private const val REQUEST_PICK_WALLPAPER = 10
private const val ACTION_CHANGE_WALLPAPER = "action_change_wallpaper"
//允许添加先安装应用
const val ALLOW_NEW_APP = 0
//允许本身自启
const val AUTO_START_SELF = 1
}
} }
\ No newline at end of file
package com.android.launcher3.settings; package com.android.launcher3.settings;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils;
import com.android.launcher3.function.pwd.PwdPinSetPwdActivity;
import com.secspace.lib.common.base.BaseActivity; import com.secspace.lib.common.base.BaseActivity;
import com.secspace.lib.common.function.DialogManager; import com.secspace.lib.common.function.DialogManager;
import com.secspace.lib.common.utils.IntentUtil; import com.secspace.lib.common.utils.IntentUtil;
...@@ -26,6 +28,12 @@ public class BlankActivity extends BaseActivity { ...@@ -26,6 +28,12 @@ public class BlankActivity extends BaseActivity {
DialogManager.INSTANCE.showPrivacyPolicyDialog(this); DialogManager.INSTANCE.showPrivacyPolicyDialog(this);
return; return;
} }
String pwd = Prefs.getLoginPwd(this);
if (TextUtils.isEmpty(pwd)) {
Intent intent = new Intent(this, PwdPinSetPwdActivity.class);
startActivity(intent);
return;
}
IntentUtil.startEduLauncher(this); IntentUtil.startEduLauncher(this);
} }
......
...@@ -96,7 +96,7 @@ object ActivationHelper { ...@@ -96,7 +96,7 @@ object ActivationHelper {
return File(FILE_PATH + context.packageName, PROBATION_FILE_NAME).exists() return File(FILE_PATH + context.packageName, PROBATION_FILE_NAME).exists()
} }
private suspend fun isProbationFromLocal(context: Context): Boolean { suspend fun isProbationFromLocal(context: Context): Boolean {
return withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) {
val file = File(FILE_PATH + context.packageName, PROBATION_FILE_NAME) val file = File(FILE_PATH + context.packageName, PROBATION_FILE_NAME)
if (!file.exists()) { if (!file.exists()) {
......
...@@ -11,10 +11,6 @@ import com.secspace.lib.common.R ...@@ -11,10 +11,6 @@ import com.secspace.lib.common.R
import com.secspace.lib.common.function.ActivationHelper.ActivationListener import com.secspace.lib.common.function.ActivationHelper.ActivationListener
import com.secspace.lib.common.function.ActivationHelper.active import com.secspace.lib.common.function.ActivationHelper.active
import com.secspace.lib.common.utils.IntentUtil import com.secspace.lib.common.utils.IntentUtil
import com.secspace.lib.common.utils.Prefs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
class BuyCodeDialog(activity: Activity) : DialogInterface.OnDismissListener, View.OnClickListener { class BuyCodeDialog(activity: Activity) : DialogInterface.OnDismissListener, View.OnClickListener {
private var mActivity: Activity? private var mActivity: Activity?
...@@ -64,10 +60,7 @@ class BuyCodeDialog(activity: Activity) : DialogInterface.OnDismissListener, Vie ...@@ -64,10 +60,7 @@ class BuyCodeDialog(activity: Activity) : DialogInterface.OnDismissListener, Vie
} }
}, true) }, true)
dismiss() dismiss()
Prefs.setMdmInitializedWhenEnter(mContext, false) WorkManager.removeForbidden(mContext)
GlobalScope.launch(Dispatchers.IO) {
SwitchOutMdm.onInit(mContext)
}
} }
} }
......
...@@ -94,6 +94,18 @@ object DialogManager{ ...@@ -94,6 +94,18 @@ object DialogManager{
}).show() }).show()
} }
fun showActivateLoseDialog(activity: Activity?, title: String?, content: String?, listener: MessageListener) {
DialogUIUtils.showAlert(activity, title, content, "", "", "确定", "输入激活码", false, false, false, object : DialogUIListener() {
override fun onPositive() {
listener.onPositive()
}
override fun onNegative() {
listener.onNegative()
}
}).show()
}
fun showMessageDialogBySure(activity: Activity?, title: String?, content: String?, listener: MessageListener) { fun showMessageDialogBySure(activity: Activity?, title: String?, content: String?, listener: MessageListener) {
DialogUIUtils.showAlert(activity, title, content, "", "", "确定", "", false, false, false, object : DialogUIListener() { DialogUIUtils.showAlert(activity, title, content, "", "", "确定", "", false, false, false, object : DialogUIListener() {
override fun onPositive() { override fun onPositive() {
......
...@@ -176,7 +176,11 @@ public class PrivacyPolicyDialog implements DialogInterface.OnDismissListener, V ...@@ -176,7 +176,11 @@ public class PrivacyPolicyDialog implements DialogInterface.OnDismissListener, V
mActivity.finish(); mActivity.finish();
} else if (v.getId() == R.id.btn_accept) { } else if (v.getId() == R.id.btn_accept) {
Prefs.setPrivacyPolicyState(mActivity, true); Prefs.setPrivacyPolicyState(mActivity, true);
IntentUtil.startEduLauncher(mActivity); try {
mActivity.startActivity(new Intent(mActivity, Class.forName("com.android.launcher3.settings.BlankActivity")));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
dismiss(); dismiss();
mActivity.finish(); mActivity.finish();
} }
......
...@@ -19,7 +19,7 @@ import kotlinx.coroutines.GlobalScope ...@@ -19,7 +19,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
object WorkManager{ object WorkManager {
private val TAG = "SecSpaceWorkManager" private val TAG = "SecSpaceWorkManager"
private lateinit var mContext: Context private lateinit var mContext: Context
private val mHandler: Handler = Handler(Looper.getMainLooper(), Handler.Callback { true }) private val mHandler: Handler = Handler(Looper.getMainLooper(), Handler.Callback { true })
...@@ -50,7 +50,7 @@ object WorkManager{ ...@@ -50,7 +50,7 @@ object WorkManager{
//安装耗时,检查是否都是最新的 //安装耗时,检查是否都是最新的
if (!DpmHelper.getInstance(mContext).isMiddlewareLatest) { if (!DpmHelper.getInstance(mContext).isMiddlewareLatest) {
Log.i(TAG, "will install delay") Log.i(TAG, "will install delay")
mHandler.postDelayed( { enter(launcher) }, 2000) mHandler.postDelayed({ enter(launcher) }, 2000)
return return
} }
LoadingDialog.getInstance(launcher).show("切换中") LoadingDialog.getInstance(launcher).show("切换中")
...@@ -63,7 +63,7 @@ object WorkManager{ ...@@ -63,7 +63,7 @@ object WorkManager{
Prefs.setMdmInitializedWhenEnter(mContext, true) Prefs.setMdmInitializedWhenEnter(mContext, true)
} }
fun exit(context: Context?){ fun exit(context: Context?) {
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
context?.let { SwitchOutMdm.onExit(it) } context?.let { SwitchOutMdm.onExit(it) }
} }
...@@ -140,19 +140,44 @@ object WorkManager{ ...@@ -140,19 +140,44 @@ object WorkManager{
install(path) install(path)
} }
fun removeForbidden(context: Context){
Prefs.setMdmInitializedWhenEnter(context, false)
GlobalScope.launch(Dispatchers.IO) {
SwitchOutMdm.onInit(context)
UninstallUtil.removeForbidden(context)
}
}
internal class EduCheckActiveStatusListener(var activity: Activity) : CheckActiveStatusListener { internal class EduCheckActiveStatusListener(var activity: Activity) : CheckActiveStatusListener {
override fun needActivate() { override fun needActivate() {
Log.i(TAG, "activedFailed: ") Log.i(TAG, "activedFailed: ")
DialogManager.showMessageDialogBySure(activity, activity.getString(R.string.common_remind), activity.getString(R.string.dialog_tip_activate_lose), object: DialogManager.MessageListener{ GlobalScope.launch(Dispatchers.Main) {
val isActivateLocal = ActivationHelper.isProbationFromLocal(activity)
if (isActivateLocal) {
return@launch
}
DialogManager.showActivateLoseDialog(activity, activity.getString(R.string.common_remind), activity.getString(R.string.dialog_tip_activate_lose), object : DialogManager.MessageListener {
override fun onPositive() { override fun onPositive() {
IntentUtil.startExitService(activity) IntentUtil.startExitService(activity)
removeForbidden(activity)
} }
override fun onNegative() { override fun onNegative() {
ActivationHelper.active(activity, object : ActivationHelper.ActivationListener {
override fun activated() {
IntentUtil.startEduLauncher(activity)
}
override fun activationFailed() {
IntentUtil.startExitService(activity)
removeForbidden(activity)
}
}, true)
removeForbidden(activity)
} }
}) })
} }
}
override fun trialCodeWillPastDue() { override fun trialCodeWillPastDue() {
Log.i(TAG, "trialCodeWillPastDue: ") Log.i(TAG, "trialCodeWillPastDue: ")
......
...@@ -92,15 +92,16 @@ ...@@ -92,15 +92,16 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/btn_1" android:id="@+id/btn_2"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/dialogui_selector_left_bottom" android:background="@drawable/dialogui_selector_all_no"
android:gravity="center" android:gravity="center"
android:minHeight="48dp"
android:padding="5dp" android:padding="5dp"
android:text="1" android:text="2"
android:textColor="@color/ios_btntext_blue" android:textColor="@color/ios_btntext_blue"
android:textSize="@dimen/dialogui_btn_txt_size"/> android:textSize="@dimen/dialogui_btn_txt_size"/>
...@@ -111,19 +112,20 @@ ...@@ -111,19 +112,20 @@
android:background="@color/line_dd"/> android:background="@color/line_dd"/>
<Button <Button
android:id="@+id/btn_2" android:id="@+id/btn_1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/dialogui_selector_all_no" android:background="@drawable/dialogui_selector_left_bottom"
android:gravity="center" android:gravity="center"
android:minHeight="48dp"
android:padding="5dp" android:padding="5dp"
android:text="2" android:text="1"
android:textColor="@color/ios_btntext_blue" android:textColor="@color/ios_btntext_blue"
android:textSize="@dimen/dialogui_btn_txt_size"/> android:textSize="@dimen/dialogui_btn_txt_size"/>
<View <View
android:id="@+id/line_btn3" android:id="@+id/line_btn3"
android:layout_width="1px" android:layout_width="1px"
......
Markdown is supported
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