Prevent flash screen close when tapping outside
This commit is contained in:
parent
773c24b7fc
commit
c1a0f520f9
@ -16,9 +16,9 @@ import android.widget.TextView;
|
|||||||
import com.topjohnwu.magisk.asyncs.FlashZip;
|
import com.topjohnwu.magisk.asyncs.FlashZip;
|
||||||
import com.topjohnwu.magisk.asyncs.InstallMagisk;
|
import com.topjohnwu.magisk.asyncs.InstallMagisk;
|
||||||
import com.topjohnwu.magisk.components.Activity;
|
import com.topjohnwu.magisk.components.Activity;
|
||||||
import com.topjohnwu.magisk.utils.AdaptiveList;
|
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -63,6 +63,7 @@ public class FlashActivity extends Activity {
|
|||||||
ab.setTitle(R.string.flashing);
|
ab.setTitle(R.string.flashing);
|
||||||
}
|
}
|
||||||
setFloating();
|
setFloating();
|
||||||
|
setFinishOnTouchOutside(false);
|
||||||
if (!Shell.rootAccess())
|
if (!Shell.rootAccess())
|
||||||
reboot.setVisibility(View.GONE);
|
reboot.setVisibility(View.GONE);
|
||||||
|
|
||||||
@ -148,4 +149,35 @@ public class FlashActivity extends Activity {
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class AdaptiveList<E> extends ArrayList<E> {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import android.app.Activity;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.FlashActivity;
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.utils.AdaptiveList;
|
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||||
|
|
||||||
@ -24,9 +24,9 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
|
|||||||
|
|
||||||
private Uri mUri;
|
private Uri mUri;
|
||||||
private File mCachedFile;
|
private File mCachedFile;
|
||||||
private AdaptiveList<String> mList;
|
private FlashActivity.AdaptiveList<String> mList;
|
||||||
|
|
||||||
public FlashZip(Activity context, Uri uri, AdaptiveList<String> list) {
|
public FlashZip(Activity context, Uri uri, FlashActivity.AdaptiveList<String> list) {
|
||||||
super(context);
|
super(context);
|
||||||
mUri = uri;
|
mUri = uri;
|
||||||
mList = list;
|
mList = list;
|
||||||
|
@ -6,8 +6,8 @@ import android.os.Build;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.FlashActivity;
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.utils.AdaptiveList;
|
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.TarEntry;
|
import com.topjohnwu.magisk.utils.TarEntry;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -34,12 +34,12 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
private static final int DIRECT_MODE = 1;
|
private static final int DIRECT_MODE = 1;
|
||||||
|
|
||||||
private Uri mBootImg, mZip;
|
private Uri mBootImg, mZip;
|
||||||
private AdaptiveList<String> mList;
|
private FlashActivity.AdaptiveList<String> mList;
|
||||||
private String mBootLocation;
|
private String mBootLocation;
|
||||||
private boolean mKeepEnc, mKeepVerity;
|
private boolean mKeepEnc, mKeepVerity;
|
||||||
private int mode;
|
private int mode;
|
||||||
|
|
||||||
private InstallMagisk(Activity context, AdaptiveList<String> list, Uri zip, boolean enc, boolean verity) {
|
private InstallMagisk(Activity context, FlashActivity.AdaptiveList<String> list, Uri zip, boolean enc, boolean verity) {
|
||||||
super(context);
|
super(context);
|
||||||
mList = list;
|
mList = list;
|
||||||
mZip = zip;
|
mZip = zip;
|
||||||
@ -47,13 +47,13 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
mKeepVerity = verity;
|
mKeepVerity = verity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstallMagisk(Activity context, AdaptiveList<String> list, Uri zip, boolean enc, boolean verity, Uri boot) {
|
public InstallMagisk(Activity context, FlashActivity.AdaptiveList<String> list, Uri zip, boolean enc, boolean verity, Uri boot) {
|
||||||
this(context, list, zip, enc, verity);
|
this(context, list, zip, enc, verity);
|
||||||
mBootImg = boot;
|
mBootImg = boot;
|
||||||
mode = PATCH_MODE;
|
mode = PATCH_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstallMagisk(Activity context, AdaptiveList<String> list, Uri zip, boolean enc, boolean verity, String boot) {
|
public InstallMagisk(Activity context, FlashActivity.AdaptiveList<String> list, Uri zip, boolean enc, boolean verity, String boot) {
|
||||||
this(context, list, zip, enc, verity);
|
this(context, list, zip, enc, verity);
|
||||||
mBootLocation = boot;
|
mBootLocation = boot;
|
||||||
mode = DIRECT_MODE;
|
mode = DIRECT_MODE;
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class AdaptiveList<E> extends ArrayList<E> {
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user