diff --git a/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java b/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java index 783e69168..edb8fa54f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java @@ -16,9 +16,9 @@ import android.widget.TextView; import com.topjohnwu.magisk.asyncs.FlashZip; import com.topjohnwu.magisk.asyncs.InstallMagisk; import com.topjohnwu.magisk.components.Activity; -import com.topjohnwu.magisk.utils.AdaptiveList; import com.topjohnwu.magisk.utils.Shell; +import java.util.ArrayList; import java.util.List; import butterknife.BindView; @@ -63,6 +63,7 @@ public class FlashActivity extends Activity { ab.setTitle(R.string.flashing); } setFloating(); + setFinishOnTouchOutside(false); if (!Shell.rootAccess()) reboot.setVisibility(View.GONE); @@ -148,4 +149,35 @@ public class FlashActivity extends Activity { ButterKnife.bind(this, itemView); } } + + public static class AdaptiveList extends ArrayList { + + private Runnable callback; + private RecyclerView mView; + + public AdaptiveList(RecyclerView v) { + mView = v; + } + + public void updateView() { + mView.getAdapter().notifyDataSetChanged(); + mView.scrollToPosition(mView.getAdapter().getItemCount() - 1); + } + + public void setCallback(Runnable cb) { + callback = cb; + } + + public boolean add(E e) { + boolean ret = super.add(e); + if (ret) { + if (callback == null) { + updateView(); + } else { + callback.run(); + } + } + return ret; + } + } } diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java index 687a644fc..ce5fc5e69 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java @@ -4,9 +4,9 @@ import android.app.Activity; import android.net.Uri; import android.text.TextUtils; +import com.topjohnwu.magisk.FlashActivity; import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.utils.AdaptiveList; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.ZipUtils; @@ -24,9 +24,9 @@ public class FlashZip extends ParallelTask { private Uri mUri; private File mCachedFile; - private AdaptiveList mList; + private FlashActivity.AdaptiveList mList; - public FlashZip(Activity context, Uri uri, AdaptiveList list) { + public FlashZip(Activity context, Uri uri, FlashActivity.AdaptiveList list) { super(context); mUri = uri; mList = list; diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java index 16143ae1b..9f8b535bf 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java @@ -6,8 +6,8 @@ import android.os.Build; import android.os.Environment; import android.text.TextUtils; +import com.topjohnwu.magisk.FlashActivity; import com.topjohnwu.magisk.MagiskManager; -import com.topjohnwu.magisk.utils.AdaptiveList; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.TarEntry; import com.topjohnwu.magisk.utils.Utils; @@ -34,12 +34,12 @@ public class InstallMagisk extends ParallelTask { private static final int DIRECT_MODE = 1; private Uri mBootImg, mZip; - private AdaptiveList mList; + private FlashActivity.AdaptiveList mList; private String mBootLocation; private boolean mKeepEnc, mKeepVerity; private int mode; - private InstallMagisk(Activity context, AdaptiveList list, Uri zip, boolean enc, boolean verity) { + private InstallMagisk(Activity context, FlashActivity.AdaptiveList list, Uri zip, boolean enc, boolean verity) { super(context); mList = list; mZip = zip; @@ -47,13 +47,13 @@ public class InstallMagisk extends ParallelTask { mKeepVerity = verity; } - public InstallMagisk(Activity context, AdaptiveList list, Uri zip, boolean enc, boolean verity, Uri boot) { + public InstallMagisk(Activity context, FlashActivity.AdaptiveList list, Uri zip, boolean enc, boolean verity, Uri boot) { this(context, list, zip, enc, verity); mBootImg = boot; mode = PATCH_MODE; } - public InstallMagisk(Activity context, AdaptiveList list, Uri zip, boolean enc, boolean verity, String boot) { + public InstallMagisk(Activity context, FlashActivity.AdaptiveList list, Uri zip, boolean enc, boolean verity, String boot) { this(context, list, zip, enc, verity); mBootLocation = boot; mode = DIRECT_MODE; diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/AdaptiveList.java b/app/src/main/java/com/topjohnwu/magisk/utils/AdaptiveList.java deleted file mode 100644 index aa6d59583..000000000 --- a/app/src/main/java/com/topjohnwu/magisk/utils/AdaptiveList.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.topjohnwu.magisk.utils; - -import android.support.v7.widget.RecyclerView; - -import java.util.ArrayList; - -public class AdaptiveList extends ArrayList { - - private Runnable callback; - private RecyclerView mView; - - public AdaptiveList(RecyclerView v) { - mView = v; - } - - public void updateView() { - mView.getAdapter().notifyDataSetChanged(); - mView.scrollToPosition(mView.getAdapter().getItemCount() - 1); - } - - public void setCallback(Runnable cb) { - callback = cb; - } - - public boolean add(E e) { - boolean ret = super.add(e); - if (ret) { - if (callback == null) { - updateView(); - } else { - callback.run(); - } - } - return ret; - } -}