diff --git a/app/src/main/java/net/typeblog/shelter/ui/AppListFragment.java b/app/src/main/java/net/typeblog/shelter/ui/AppListFragment.java index 90afbe4..515f5ef 100644 --- a/app/src/main/java/net/typeblog/shelter/ui/AppListFragment.java +++ b/app/src/main/java/net/typeblog/shelter/ui/AppListFragment.java @@ -17,6 +17,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.ContextMenu; @@ -218,7 +219,15 @@ public class AppListFragment extends Fragment { switch (item.getItemId()) { case MENU_ITEM_CLONE: - installOrUninstall(mSelectedApp, true); + if (Utility.isMIUI() && !mSelectedApp.isSystem()) { + // Cannot clone non-system apps on MIUI + new AlertDialog.Builder(getContext()) + .setMessage(R.string.miui_cannot_clone) + .setPositiveButton(android.R.string.ok, null) + .show(); + } else { + installOrUninstall(mSelectedApp, true); + } return true; case MENU_ITEM_UNINSTALL: installOrUninstall(mSelectedApp, false); diff --git a/app/src/main/java/net/typeblog/shelter/util/Utility.java b/app/src/main/java/net/typeblog/shelter/util/Utility.java index 570aba8..48c8b12 100644 --- a/app/src/main/java/net/typeblog/shelter/util/Utility.java +++ b/app/src/main/java/net/typeblog/shelter/util/Utility.java @@ -127,10 +127,9 @@ public class Utility { manager.clearUserRestriction(adminComponent, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES); manager.clearUserRestriction(adminComponent, UserManager.DISALLOW_UNINSTALL_APPS); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || isMIUI()) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // Polyfill for UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES // Don't use this on Android Oreo and later, it will crash - // TODO: WIP: Maybe this is needed on MIUI manager.setSecureSetting(adminComponent, Settings.Secure.INSTALL_NON_MARKET_APPS, "1"); } @@ -145,8 +144,6 @@ public class Utility { Process proc = Runtime.getRuntime().exec("getprop ro.miui.ui.version.name"); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line = reader.readLine().trim(); - // TODO: Remove this after trying on MIUI - android.util.Log.d("Utility", "ro.miui.ui.version.name = " + line); return !line.isEmpty(); } catch (Exception e) { return false; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 627d7a7..7b655aa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,4 +59,7 @@ Operations for %s All apps in \"Auto Freeze\" list have been frozen successfully. Shortcut created on your launcher. + + + Cloning non-system apps to another profile is currently not possible on MIUI. Please clone your system\'s app store (e.g. Play Store) into the other profile and then install apps from there.