Finish repo download and flash
This commit is contained in:
parent
160c6e6554
commit
cb5187fd8d
@ -137,13 +137,14 @@ public class MagiskFragment extends Fragment {
|
|||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
new DownloadReceiver(getString(R.string.magisk)) {
|
new DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(Uri uri) {
|
public void task(Uri uri) {
|
||||||
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Utils.magiskLink, "latest_magisk.zip"))
|
Utils.magiskLink,
|
||||||
|
"Magisk-v" + String.valueOf(Utils.remoteMagiskVersion) + ".zip"))
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show());
|
.show());
|
||||||
} else {
|
} else {
|
||||||
@ -153,14 +154,14 @@ public class MagiskFragment extends Fragment {
|
|||||||
magiskCheckUpdatesStatus.setTextColor(colorOK);
|
magiskCheckUpdatesStatus.setTextColor(colorOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.remoteAppVersion > BuildConfig.VERSION_CODE) {
|
if (Utils.remoteAppVersionCode > BuildConfig.VERSION_CODE) {
|
||||||
appCheckUpdatesContainer.setBackgroundColor(colorNeutral);
|
appCheckUpdatesContainer.setBackgroundColor(colorNeutral);
|
||||||
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||||
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, String.valueOf(Utils.remoteAppVersion)));
|
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, Utils.remoteAppVersion));
|
||||||
appCheckUpdatesStatus.setTextColor(colorNeutral);
|
appCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||||
appUpdateView.setOnClickListener(view -> builder
|
appUpdateView.setOnClickListener(view -> builder
|
||||||
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
||||||
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), String.valueOf(Utils.remoteAppVersion), Utils.appChangelog))
|
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), Utils.remoteAppVersion, Utils.appChangelog))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(getActivity(),
|
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(getActivity(),
|
||||||
new DownloadReceiver() {
|
new DownloadReceiver() {
|
||||||
@ -168,11 +169,13 @@ public class MagiskFragment extends Fragment {
|
|||||||
public void task(Uri uri) {
|
public void task(Uri uri) {
|
||||||
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
install.setData(uri);
|
Uri content = FileProvider.getUriForFile(getActivity(), "com.topjohnwu.magisk.provider", new File(uri.getPath()));
|
||||||
|
install.setData(content);
|
||||||
mContext.startActivity(install);
|
mContext.startActivity(install);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Utils.appLink, "latest_manager.apk"))
|
Utils.appLink,
|
||||||
|
"MagiskManager-v" + Utils.remoteAppVersion + ".apk"))
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show()
|
.show()
|
||||||
);
|
);
|
||||||
|
@ -4,14 +4,11 @@ import android.animation.Animator;
|
|||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -20,11 +17,12 @@ import android.view.WindowManager;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.WebWindow;
|
import com.topjohnwu.magisk.utils.WebWindow;
|
||||||
|
|
||||||
@ -38,150 +36,107 @@ import butterknife.ButterKnife;
|
|||||||
public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder> {
|
public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder> {
|
||||||
|
|
||||||
private final List<Repo> mList;
|
private final List<Repo> mList;
|
||||||
List<Boolean> mExpandedList;
|
private List<Boolean> mExpandedList;
|
||||||
private View viewMain;
|
private View mView;
|
||||||
private Context context;
|
private Context context;
|
||||||
private boolean mCanUpdate;
|
|
||||||
private boolean alertUpdate;
|
|
||||||
private boolean ignoreAlertUpdate;
|
|
||||||
private Repo repo;
|
|
||||||
private ViewHolder mHolder;
|
|
||||||
private String mDonateUrl, mSupportUrl, mLogUrl,alertPackage;
|
|
||||||
private SharedPreferences prefs;
|
|
||||||
|
|
||||||
|
|
||||||
public ReposAdapter(List<Repo> list) {
|
public ReposAdapter(List<Repo> list) {
|
||||||
alertPackage = "";
|
mList = list;
|
||||||
alertUpdate = false;
|
|
||||||
this.mList = list;
|
|
||||||
Log.d("Magisk", "ReposAdapter: I am alive. I have a list " + list.size());
|
|
||||||
mExpandedList = new ArrayList<>(mList.size());
|
mExpandedList = new ArrayList<>(mList.size());
|
||||||
for (int i = 0; i < mList.size(); i++) {
|
for (int i = 0; i < mList.size(); i++) {
|
||||||
mExpandedList.add(false);
|
mExpandedList.add(false);
|
||||||
if (mList.get(i).canUpdate()) {
|
|
||||||
alertUpdate = true;
|
|
||||||
if (alertPackage.equals("")) {
|
|
||||||
alertPackage = mList.get(i).getName();
|
|
||||||
} else {
|
|
||||||
alertPackage += mList.get(i).getName() + ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
viewMain = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_repo, parent, false);
|
mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_repo, parent, false);
|
||||||
ButterKnife.bind(this, viewMain);
|
ButterKnife.bind(this, mView);
|
||||||
context = parent.getContext();
|
context = parent.getContext();
|
||||||
return new ViewHolder(viewMain);
|
return new ViewHolder(mView);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
// switch (item.getItemId()) {
|
|
||||||
// case R.id.force_reload:
|
|
||||||
// listModulesDownload.clear();
|
|
||||||
// new Utils.LoadModules(getActivity(), true).execute();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return super.onOptionsItemSelected(item);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
final Repo repo = mList.get(position);
|
||||||
repo = mList.get(position);
|
|
||||||
mHolder = holder;
|
|
||||||
mDonateUrl = repo.getDonateUrl();
|
|
||||||
mSupportUrl = repo.getSupportUrl();
|
|
||||||
mLogUrl = repo.getLogUrl();
|
|
||||||
mExpandedList = new ArrayList<>(mList.size());
|
mExpandedList = new ArrayList<>(mList.size());
|
||||||
for (int i = 0; i < mList.size(); i++) {
|
for (int i = 0; i < mList.size(); i++) {
|
||||||
mExpandedList.add(false);
|
mExpandedList.add(false);
|
||||||
}
|
}
|
||||||
SetupViewElements(repo);
|
if (repo.isCache()) {
|
||||||
|
holder.title.setText("[Cache] " + repo.getName());
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupViewElements(Repo repo) {
|
|
||||||
int mPosition = mHolder.getAdapterPosition();
|
|
||||||
String titleString;
|
|
||||||
if (repo.getId() != null) {
|
|
||||||
if (repo.isCacheModule()) {
|
|
||||||
titleString = "[Cache] " + repo.getName();
|
|
||||||
} else {
|
} else {
|
||||||
titleString = repo.getName();
|
holder.title.setText(repo.getName());
|
||||||
}
|
}
|
||||||
|
String author = repo.getAuthor();
|
||||||
mHolder.title.setText(titleString);
|
String versionName = repo.getVersion();
|
||||||
mHolder.versionName.setText(repo.getVersion());
|
String description = repo.getDescription();
|
||||||
mHolder.description.setText(repo.getDescription());
|
if (versionName != null) {
|
||||||
String authorString = this.context.getResources().getString(R.string.author) + " " + repo.getAuthor();
|
holder.versionName.setText(versionName);
|
||||||
mHolder.author.setText(authorString);
|
|
||||||
if (prefs.contains("ignoreUpdateAlerts")) {
|
|
||||||
ignoreAlertUpdate = prefs.getBoolean("ignoreUpdateAlerts",false);
|
|
||||||
}
|
}
|
||||||
mHolder.installedStatus.setText(repo.isInstalled() ? this.context.getResources().getString(R.string.module_installed) : this.context.getResources().getString(R.string.module_not_installed));
|
if (author != null) {
|
||||||
if (mExpandedList.get(mPosition)) {
|
holder.author.setText(context.getString(R.string.author, author));
|
||||||
mHolder.expandLayout.setVisibility(View.VISIBLE);
|
}
|
||||||
} else {
|
if (description != null) {
|
||||||
mHolder.expandLayout.setVisibility(View.GONE);
|
holder.description.setText(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repo.isInstalled()) {
|
if (repo.isInstalled()) {
|
||||||
mHolder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
holder.installedStatus.setText(context.getString(R.string.module_installed));
|
||||||
mHolder.updateStatus.setText(repo.canUpdate() ? this.context.getResources().getString(R.string.module_update_available) : this.context.getResources().getString(R.string.module_up_to_date));
|
holder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
||||||
|
holder.updateStatus.setText(repo.canUpdate() ? context.getString(R.string.module_update_available) : context.getString(R.string.module_up_to_date));
|
||||||
|
} else {
|
||||||
|
holder.installedStatus.setText(context.getString(R.string.module_not_installed));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("Magisk", "ReposAdapter: Setting up info " + repo.getId() + " and " + repo.getDescription() + " and " + repo.getVersion());
|
View.OnClickListener listener = view -> {
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
if (view.getId() == holder.updateImage.getId()) {
|
||||||
mCanUpdate = prefs.getBoolean("repo-canUpdate_" + repo.getId(), false);
|
Utils.downloadAndReceive(
|
||||||
|
context,
|
||||||
|
new DownloadReceiver(repo.getName() + "-" + repo.getVersion()) {
|
||||||
View.OnClickListener oCl = view -> {
|
|
||||||
Log.d("Magisk", "Onlick captured, view is " + view.getId());
|
|
||||||
|
|
||||||
if (view.getId() == mHolder.updateImage.getId()) {
|
|
||||||
if (!repo.isInstalled() | repo.canUpdate()) {
|
|
||||||
|
|
||||||
DownloadReceiver receiver = new DownloadReceiver() {
|
|
||||||
@Override
|
@Override
|
||||||
public void task(Uri uri) {
|
public void task(Uri uri) {
|
||||||
new Async.FlashZIP(context, uri, repo.getName() + "-v" + repo.getVersion());
|
new Async.FlashZIP(context, uri, mName) {
|
||||||
|
@Override
|
||||||
|
protected void preProcessing() throws Throwable {
|
||||||
|
super.preProcessing();
|
||||||
|
new File(mUri.getPath()).delete();
|
||||||
|
Shell.su(
|
||||||
|
"cd " + mFile.getParent(),
|
||||||
|
"mkdir git",
|
||||||
|
"unzip -o install.zip -d git",
|
||||||
|
"mv git/* install",
|
||||||
|
"cd install",
|
||||||
|
"rm -rf system/placeholder",
|
||||||
|
"chmod 644 $(find . -type f)",
|
||||||
|
"chmod 755 $(find . -type d)",
|
||||||
|
"rm -rf ../install.zip ../git",
|
||||||
|
"zip -r ../install.zip *",
|
||||||
|
"rm -rf ../install"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
repo.getZipUrl(),
|
||||||
|
repo.getId().replace(" ", "") + ".zip");
|
||||||
|
}
|
||||||
|
if ((view.getId() == holder.changeLog.getId()) && (!repo.getLogUrl().equals(""))) {
|
||||||
|
new WebWindow("Changelog", repo.getLogUrl(), context);
|
||||||
|
}
|
||||||
|
if ((view.getId() == holder.authorLink.getId()) && (!repo.getSupportUrl().equals(""))) {
|
||||||
|
new WebWindow("Donate", repo.getDonateUrl(), context);
|
||||||
|
}
|
||||||
|
if ((view.getId() == holder.supportLink.getId()) && (!repo.getSupportUrl().equals(""))) {
|
||||||
|
new WebWindow("Support", repo.getSupportUrl(), context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String filename = repo.getId().replace(" ", "") + ".zip";
|
|
||||||
Utils.downloadAndReceive(context, receiver, repo.getZipUrl(), filename);
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((view.getId() == mHolder.changeLog.getId()) && (!repo.getLogUrl().equals(""))) {
|
|
||||||
new WebWindow("Changelog", repo.getLogUrl(),context);
|
|
||||||
}
|
|
||||||
if ((view.getId() == mHolder.authorLink.getId()) && (!repo.getSupportUrl().equals(""))) {
|
|
||||||
new WebWindow("Donate", repo.getDonateUrl(),context);
|
|
||||||
}
|
|
||||||
if ((view.getId() == mHolder.supportLink.getId()) && (!repo.getSupportUrl().equals(""))) {
|
|
||||||
new WebWindow("Support", repo.getSupportUrl(),context);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mHolder.changeLog.setOnClickListener(oCl);
|
|
||||||
mHolder.updateImage.setOnClickListener(oCl);
|
|
||||||
mHolder.authorLink.setOnClickListener(oCl);
|
|
||||||
mHolder.supportLink.setOnClickListener(oCl);
|
|
||||||
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
|
|
||||||
boolean mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
|
||||||
|
|
||||||
|
holder.changeLog.setOnClickListener(listener);
|
||||||
|
holder.updateImage.setOnClickListener(listener);
|
||||||
|
holder.authorLink.setOnClickListener(listener);
|
||||||
|
holder.supportLink.setOnClickListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mList.size();
|
return mList.size();
|
||||||
@ -189,30 +144,19 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
|
|
||||||
class ViewHolder extends RecyclerView.ViewHolder {
|
class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@BindView(R.id.title)
|
@BindView(R.id.title) TextView title;
|
||||||
TextView title;
|
@BindView(R.id.version_name) TextView versionName;
|
||||||
@BindView(R.id.version_name)
|
@BindView(R.id.description) TextView description;
|
||||||
TextView versionName;
|
@BindView(R.id.author) TextView author;
|
||||||
@BindView(R.id.description)
|
@BindView(R.id.installedStatus) TextView installedStatus;
|
||||||
TextView description;
|
@BindView(R.id.updateStatus) TextView updateStatus;
|
||||||
@BindView(R.id.author)
|
@BindView(R.id.expand_layout) LinearLayout expandLayout;
|
||||||
TextView author;
|
@BindView(R.id.update) ImageView updateImage;
|
||||||
@BindView(R.id.installedStatus)
|
@BindView(R.id.installed) ImageView installedImage;
|
||||||
TextView installedStatus;
|
@BindView(R.id.changeLog) ImageView changeLog;
|
||||||
@BindView(R.id.updateStatus)
|
@BindView(R.id.authorLink) ImageView authorLink;
|
||||||
TextView updateStatus;
|
@BindView(R.id.supportLink) ImageView supportLink;
|
||||||
@BindView(R.id.expand_layout)
|
|
||||||
LinearLayout expandLayout;
|
|
||||||
@BindView(R.id.update)
|
|
||||||
ImageView updateImage;
|
|
||||||
@BindView(R.id.installed)
|
|
||||||
ImageView installedImage;
|
|
||||||
@BindView(R.id.changeLog)
|
|
||||||
ImageView changeLog;
|
|
||||||
@BindView(R.id.authorLink)
|
|
||||||
ImageView authorLink;
|
|
||||||
@BindView(R.id.supportLink)
|
|
||||||
ImageView supportLink;
|
|
||||||
private ValueAnimator mAnimator;
|
private ValueAnimator mAnimator;
|
||||||
private ObjectAnimator animY2;
|
private ObjectAnimator animY2;
|
||||||
private ViewHolder holder;
|
private ViewHolder holder;
|
||||||
@ -243,7 +187,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
viewMain.setOnClickListener(view -> {
|
mView.setOnClickListener(view -> {
|
||||||
int position = getAdapterPosition();
|
int position = getAdapterPosition();
|
||||||
if (mExpandedList.get(position)) {
|
if (mExpandedList.get(position)) {
|
||||||
collapse(holder.expandLayout);
|
collapse(holder.expandLayout);
|
||||||
@ -251,7 +195,6 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
expand(holder.expandLayout);
|
expand(holder.expandLayout);
|
||||||
}
|
}
|
||||||
mExpandedList.set(position, !mExpandedList.get(position));
|
mExpandedList.set(position, !mExpandedList.get(position));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -267,23 +210,19 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
int finalHeight = view.getHeight();
|
int finalHeight = view.getHeight();
|
||||||
ValueAnimator mAnimator = slideAnimator(finalHeight, 0);
|
ValueAnimator mAnimator = slideAnimator(finalHeight, 0);
|
||||||
mAnimator.addListener(new Animator.AnimatorListener() {
|
mAnimator.addListener(new Animator.AnimatorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animator) {
|
public void onAnimationEnd(Animator animator) {
|
||||||
view.setVisibility(View.GONE);
|
view.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animator animator) {
|
public void onAnimationStart(Animator animator) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationCancel(Animator animator) {
|
public void onAnimationCancel(Animator animator) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationRepeat(Animator animator) {
|
public void onAnimationRepeat(Animator animator) {}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
mAnimator.start();
|
mAnimator.start();
|
||||||
animY2.reverse();
|
animY2.reverse();
|
||||||
|
@ -72,7 +72,7 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
new Async.CheckUpdates(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.CheckUpdates(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
new Async.LoadModules(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new Async.LoadModules(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
new Async.BusyboxEnv(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new Async.constructEnv(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
// Start main activity
|
// Start main activity
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
@ -17,8 +17,7 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
|
|||||||
long downloadID;
|
long downloadID;
|
||||||
public String mName;
|
public String mName;
|
||||||
|
|
||||||
public DownloadReceiver() {
|
public DownloadReceiver() {}
|
||||||
}
|
|
||||||
|
|
||||||
public DownloadReceiver(String name) {
|
public DownloadReceiver(String name) {
|
||||||
mName = name;
|
mName = name;
|
||||||
|
@ -10,6 +10,7 @@ import android.os.Environment;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -33,11 +35,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Async {
|
public class Async {
|
||||||
|
|
||||||
public static class BusyboxEnv extends AsyncTask<Void, Void, Void> {
|
public static class constructEnv extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
public BusyboxEnv(Context context) {
|
public constructEnv(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,16 +47,22 @@ public class Async {
|
|||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
String toolPath = mContext.getApplicationInfo().dataDir + "/busybox";
|
String toolPath = mContext.getApplicationInfo().dataDir + "/busybox";
|
||||||
String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so";
|
String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so";
|
||||||
if (Shell.rootAccess() && !Utils.commandExists("unzip") && !Utils.itemExist(toolPath)) {
|
String zip = mContext.getApplicationInfo().dataDir + "/lib/libzip.so";
|
||||||
Shell.su(true,
|
if (Shell.rootAccess()) {
|
||||||
|
if (!Utils.commandExists("unzip") || !Utils.commandExists("zip") || !Utils.itemExist(toolPath)) {
|
||||||
|
Shell.sh(
|
||||||
|
"rm -rf " + toolPath,
|
||||||
"mkdir " + toolPath,
|
"mkdir " + toolPath,
|
||||||
"chmod 755 " + toolPath,
|
"chmod 755 " + toolPath,
|
||||||
"ln -s " + busybox + " " + toolPath + "/busybox",
|
"ln -s " + busybox + " " + toolPath + "/busybox",
|
||||||
"for tool in $(" + toolPath + "/busybox --list); do",
|
"for tool in $(" + toolPath + "/busybox --list); do",
|
||||||
"ln -s " + busybox + " " + toolPath + "/$tool",
|
"ln -s " + busybox + " " + toolPath + "/$tool",
|
||||||
"done"
|
"done",
|
||||||
|
!Utils.commandExists("zip") ? "ln -s " + zip + " " + toolPath + "/zip" : ""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,25 +83,24 @@ public class Async {
|
|||||||
|
|
||||||
JSONObject magisk = json.getJSONObject("magisk");
|
JSONObject magisk = json.getJSONObject("magisk");
|
||||||
JSONObject app = json.getJSONObject("app");
|
JSONObject app = json.getJSONObject("app");
|
||||||
JSONObject root = json.getJSONObject("root");
|
|
||||||
|
|
||||||
Utils.remoteMagiskVersion = magisk.getInt("versionCode");
|
Utils.remoteMagiskVersion = magisk.getInt("versionCode");
|
||||||
Utils.magiskLink = magisk.getString("link");
|
Utils.magiskLink = magisk.getString("link");
|
||||||
Utils.magiskChangelog = magisk.getString("changelog");
|
Utils.magiskChangelog = magisk.getString("changelog");
|
||||||
|
|
||||||
Utils.remoteAppVersion = app.getInt("versionCode");
|
Utils.remoteAppVersion = app.getString("version");
|
||||||
|
Utils.remoteAppVersionCode = app.getInt("versionCode");
|
||||||
Utils.appLink = app.getString("link");
|
Utils.appLink = app.getString("link");
|
||||||
Utils.appChangelog = app.getString("changelog");
|
Utils.appChangelog = app.getString("changelog");
|
||||||
|
|
||||||
Utils.phhLink = root.getString("phh");
|
} catch (JSONException ignored) {
|
||||||
Utils.supersuLink = root.getString("supersu");
|
Logger.dev("JSON error!");
|
||||||
} catch (JSONException ignored) {}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void v) {
|
||||||
super.onPostExecute(aVoid);
|
|
||||||
if (Shell.rootAccess() && Utils.magiskVersion == -1) {
|
if (Shell.rootAccess() && Utils.magiskVersion == -1) {
|
||||||
new AlertDialog.Builder(mContext)
|
new AlertDialog.Builder(mContext)
|
||||||
.setTitle(R.string.no_magisk_title)
|
.setTitle(R.string.no_magisk_title)
|
||||||
@ -101,14 +108,14 @@ public class Async {
|
|||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
||||||
mContext,
|
mContext,
|
||||||
new DownloadReceiver(mContext.getString(R.string.magisk)) {
|
new DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(Uri uri) {
|
public void task(Uri uri) {
|
||||||
new FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Utils.magiskLink,
|
Utils.magiskLink,
|
||||||
"latest_magisk.zip"))
|
"Magisk-v" + String.valueOf(Utils.remoteMagiskVersion) + ".zip"))
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
@ -181,14 +188,13 @@ public class Async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FlashZIP extends AsyncTask<Void, Void, Boolean> {
|
public static class FlashZIP extends AsyncTask<Void, Void, Integer> {
|
||||||
|
|
||||||
private String mName;
|
private String mName;
|
||||||
private Uri mUri;
|
protected Uri mUri;
|
||||||
private ProgressDialog progress;
|
private ProgressDialog progress;
|
||||||
private File mFile, sdFile;
|
protected File mFile, sdFile;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private List<String> ret;
|
|
||||||
private boolean copyToSD;
|
private boolean copyToSD;
|
||||||
|
|
||||||
public FlashZIP(Context context, Uri uri, String name) {
|
public FlashZIP(Context context, Uri uri, String name) {
|
||||||
@ -204,17 +210,22 @@ public class Async {
|
|||||||
Cursor c = mContext.getContentResolver().query(uri, null, null, null, null);
|
Cursor c = mContext.getContentResolver().query(uri, null, null, null, null);
|
||||||
int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
|
if (nameIndex != -1) {
|
||||||
mName = c.getString(nameIndex);
|
mName = c.getString(nameIndex);
|
||||||
|
} else {
|
||||||
|
int idx = uri.getPath().lastIndexOf('/');
|
||||||
|
mName = uri.getPath().substring(idx + 1);
|
||||||
|
}
|
||||||
c.close();
|
c.close();
|
||||||
copyToSD = false;
|
copyToSD = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createFileFromInputStream(InputStream inputStream, File f) throws IOException {
|
private void createFileFromInputStream(InputStream inputStream, File file) throws IOException {
|
||||||
if (f.exists() && !f.delete()) {
|
if (file.exists() && !file.delete()) {
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
f.setWritable(true, false);
|
file.setWritable(true, false);
|
||||||
OutputStream outputStream = new FileOutputStream(f);
|
OutputStream outputStream = new FileOutputStream(file);
|
||||||
byte buffer[] = new byte[1024];
|
byte buffer[] = new byte[1024];
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
@ -223,24 +234,15 @@ public class Async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
Logger.dev("FlashZip: File created successfully - " + f.getPath());
|
Logger.dev("FlashZip: File created successfully - " + file.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void preProcessing() throws Throwable {
|
||||||
protected void onPreExecute() {
|
|
||||||
super.onPreExecute();
|
|
||||||
progress = ProgressDialog.show(mContext, mContext.getString(R.string.zip_install_progress_title), mContext.getString(R.string.zip_install_progress_msg, mName));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Boolean doInBackground(Void... voids) {
|
|
||||||
Logger.dev("FlashZip Running... " + mName);
|
|
||||||
InputStream in;
|
|
||||||
try {
|
try {
|
||||||
try {
|
InputStream in = mContext.getContentResolver().openInputStream(mUri);
|
||||||
in = mContext.getContentResolver().openInputStream(mUri);
|
mFile = new File(mContext.getCacheDir().getAbsolutePath() + "/install.zip");
|
||||||
mFile = new File(mContext.getFilesDir().getAbsolutePath() + "/install.zip");
|
|
||||||
createFileFromInputStream(in, mFile);
|
createFileFromInputStream(in, mFile);
|
||||||
|
in.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.e("Magisk", "FlashZip: Invalid Uri");
|
Log.e("Magisk", "FlashZip: Invalid Uri");
|
||||||
throw e;
|
throw e;
|
||||||
@ -248,17 +250,37 @@ public class Async {
|
|||||||
Log.e("Magisk", "FlashZip: Error in creating file");
|
Log.e("Magisk", "FlashZip: Error in creating file");
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
progress = ProgressDialog.show(mContext, mContext.getString(R.string.zip_install_progress_title), mContext.getString(R.string.zip_install_progress_msg, mName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Integer doInBackground(Void... voids) {
|
||||||
|
Logger.dev("FlashZip Running... " + mName);
|
||||||
|
List<String> ret = null;
|
||||||
|
if (Shell.rootAccess()) {
|
||||||
|
try {
|
||||||
|
preProcessing();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
this.cancel(true);
|
this.cancel(true);
|
||||||
progress.cancel();
|
progress.cancel();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
if (Shell.rootAccess()) {
|
|
||||||
ret = Shell.su(
|
ret = Shell.su(
|
||||||
"unzip -o " + mFile.getPath() + " META-INF/com/google/android/* -d " + mFile.getParent(),
|
"unzip -o " + mFile.getPath() + " META-INF/com/google/android/* -d " + mFile.getParent(),
|
||||||
|
"if [ \"$(cat " + mFile.getParent() + "/META-INF/com/google/android/updater-script)\" = \"#MAGISK\" ]; then echo true; else echo false; fi"
|
||||||
|
);
|
||||||
|
if (! Boolean.parseBoolean(ret.get(ret.size() - 1))) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ret = Shell.su(
|
||||||
"BOOTMODE=true sh " + mFile.getParent() + "/META-INF/com/google/android/update-binary dummy 1 "+ mFile.getPath(),
|
"BOOTMODE=true sh " + mFile.getParent() + "/META-INF/com/google/android/update-binary dummy 1 "+ mFile.getPath(),
|
||||||
"if [ $? -eq 0 ]; then echo true; else echo false; fi"
|
"if [ $? -eq 0 ]; then echo true; else echo false; fi",
|
||||||
|
"rm -rf " + mFile.getParent() + "/META-INF"
|
||||||
);
|
);
|
||||||
Logger.dev("FlashZip: Console log:");
|
Logger.dev("FlashZip: Console log:");
|
||||||
for (String line : ret) {
|
for (String line : ret) {
|
||||||
@ -266,36 +288,53 @@ public class Async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Copy the file to sdcard
|
// Copy the file to sdcard
|
||||||
if (copyToSD) {
|
if (copyToSD && mFile != null) {
|
||||||
try {
|
sdFile = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + (mName.contains(".zip") ? mName : mName + ".zip").replace(" ", "_"));
|
||||||
sdFile = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + (mName.contains(".zip") ? mName : mName + ".zip"));
|
|
||||||
if ((!sdFile.getParentFile().exists() && !sdFile.getParentFile().mkdirs()) || (sdFile.exists() && !sdFile.delete())) {
|
if ((!sdFile.getParentFile().exists() && !sdFile.getParentFile().mkdirs()) || (sdFile.exists() && !sdFile.delete())) {
|
||||||
throw new IOException();
|
sdFile = null;
|
||||||
}
|
} else {
|
||||||
|
try {
|
||||||
|
FileInputStream in = new FileInputStream(mFile);
|
||||||
createFileFromInputStream(in, sdFile);
|
createFileFromInputStream(in, sdFile);
|
||||||
assert in != null;
|
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e("Magisk", "FlashZip: Unable to copy to sdcard");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mFile.delete();
|
mFile.delete();
|
||||||
return ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1));
|
} catch (IOException e) {
|
||||||
|
// Use the badass way :)
|
||||||
|
Shell.su("cp -af " + mFile.getPath() + " " + sdFile.getPath());
|
||||||
|
if (!sdFile.exists()) {
|
||||||
|
sdFile = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mFile.exists() && !mFile.delete()) {
|
||||||
|
Shell.su("rm -f " + mFile.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -1 = error; 0 = invalid zip; 1 = success
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Integer result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
if (!result) {
|
switch (result) {
|
||||||
|
case -1:
|
||||||
if (sdFile == null) {
|
if (sdFile == null) {
|
||||||
Toast.makeText(mContext, mContext.getString(R.string.install_error), Toast.LENGTH_LONG).show();
|
Toast.makeText(mContext, mContext.getString(R.string.install_error), Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(mContext, mContext.getString(R.string.manual_install, mFile.getAbsolutePath()), Toast.LENGTH_LONG).show();
|
Toast.makeText(mContext, mContext.getString(R.string.manual_install, mFile.getAbsolutePath()), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
case 0:
|
||||||
|
Toast.makeText(mContext, mContext.getString(R.string.invalid_zip), Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
done();
|
done();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ import javax.crypto.spec.DESKeySpec;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static int magiskVersion, remoteMagiskVersion = -1, remoteAppVersion = -1;
|
public static int magiskVersion, remoteMagiskVersion = -1, remoteAppVersionCode = -1;
|
||||||
public static String magiskLink, magiskChangelog, appChangelog, appLink, phhLink, supersuLink;
|
public static String magiskLink, magiskChangelog, appLink, appChangelog, remoteAppVersion;
|
||||||
private static final String TAG = "Magisk";
|
private static final String TAG = "Magisk";
|
||||||
|
|
||||||
public static final String MAGISK_PATH = "/magisk";
|
public static final String MAGISK_PATH = "/magisk";
|
||||||
@ -99,27 +99,12 @@ public class Utils {
|
|||||||
|
|
||||||
public static boolean createFile(String path) {
|
public static boolean createFile(String path) {
|
||||||
String command = "touch " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo true; else echo false; fi";
|
String command = "touch " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo true; else echo false; fi";
|
||||||
if (!Shell.rootAccess()) {
|
return Shell.rootAccess() && Boolean.parseBoolean(Shell.su(command).get(0));
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return Boolean.parseBoolean(Shell.su(command).get(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeFile(String path) {
|
public static boolean removeFile(String path) {
|
||||||
boolean check;
|
|
||||||
String command = "rm -f " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo false; else echo true; fi";
|
String command = "rm -f " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo false; else echo true; fi";
|
||||||
if (!Shell.rootAccess()) {
|
return Shell.rootAccess() && Boolean.parseBoolean(Shell.su(command).get(0));
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
check = Boolean.parseBoolean(Shell.su(command).get(0));
|
|
||||||
return check;
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
Log.d("Magisk:", "SU error executing removeFile " + e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleRoot(Boolean b, Context context) {
|
public static void toggleRoot(Boolean b, Context context) {
|
||||||
@ -132,7 +117,7 @@ public class Utils {
|
|||||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
|
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
|
||||||
SetupQuickSettingsTile(context);
|
SetupQuickSettingsTile(context);
|
||||||
}
|
}
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root",b).apply();
|
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", b).apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,29 +168,20 @@ public class Utils {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void downloadAndReceive(Context context, DownloadReceiver receiver, String link, String file) {
|
public static void downloadAndReceive(Context context, DownloadReceiver receiver, String link, String filename) {
|
||||||
|
File file = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + filename);
|
||||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File downloadFile, dir = new File(Environment.getExternalStorageDirectory() + "/MagiskManager");
|
|
||||||
downloadFile = new File(dir + "/" + file);
|
if ((!file.getParentFile().exists() && !file.getParentFile().mkdirs()) || (file.exists() && !file.delete())) {
|
||||||
if (!dir.exists()) {
|
|
||||||
if (!dir.mkdirs()) {
|
|
||||||
Toast.makeText(context, R.string.toast_error_makedir, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.toast_error_makedir, Toast.LENGTH_LONG).show();
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (downloadFile.exists()) {
|
|
||||||
if (!downloadFile.delete()) {
|
|
||||||
Toast.makeText(context, R.string.toast_error_removing_files, Toast.LENGTH_LONG).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
|
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
|
||||||
request.setDestinationUri(Uri.fromFile(downloadFile));
|
request.setDestinationUri(Uri.fromFile(file));
|
||||||
|
|
||||||
receiver.setDownloadID(downloadManager.enqueue(request));
|
receiver.setDownloadID(downloadManager.enqueue(request));
|
||||||
context.registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
context.registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
||||||
|
BIN
app/src/main/jniLibs/armeabi/libzip.so
Normal file
BIN
app/src/main/jniLibs/armeabi/libzip.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/x86/libzip.so
Normal file
BIN
app/src/main/jniLibs/x86/libzip.so
Normal file
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v7.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
style="?attr/cardStyle"
|
style="?attr/cardStyle"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v7.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -14,7 +15,6 @@
|
|||||||
card_view:cardCornerRadius="@dimen/card_corner_radius"
|
card_view:cardCornerRadius="@dimen/card_corner_radius"
|
||||||
card_view:cardElevation="@dimen/card_elevation">
|
card_view:cardElevation="@dimen/card_elevation">
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -24,8 +24,7 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical">
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
@ -40,15 +39,38 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/version_name"
|
android:id="@+id/version_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/card_textview_width"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_below="@id/title"
|
android:layout_below="@id/title"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:text="@string/no_info_provided"
|
||||||
android:textColor="@android:color/tertiary_text_dark"
|
android:textColor="@android:color/tertiary_text_dark"
|
||||||
android:textIsSelectable="false"
|
android:textIsSelectable="false"
|
||||||
android:textStyle="bold|italic"
|
android:textStyle="bold|italic" />
|
||||||
/>
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/author"
|
||||||
|
android:layout_width="@dimen/card_textview_width"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_below="@id/version_name"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:text="@string/no_info_provided"
|
||||||
|
android:textColor="@android:color/tertiary_text_dark"
|
||||||
|
android:textIsSelectable="false"
|
||||||
|
android:textStyle="bold|italic"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_below="@id/author"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:text="@string/no_info_provided"
|
||||||
|
android:textIsSelectable="false" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/update"
|
android:id="@+id/update"
|
||||||
@ -60,19 +82,7 @@
|
|||||||
android:background="@drawable/ic_file_download_black"
|
android:background="@drawable/ic_file_download_black"
|
||||||
android:backgroundTint="@color/icon_grey"
|
android:backgroundTint="@color/icon_grey"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:gravity="end"
|
android:gravity="end" />
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/description"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_below="@id/update"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textIsSelectable="false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -82,18 +92,7 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_below="@id/description"
|
android:layout_below="@id/description"
|
||||||
android:minHeight="100dp"
|
android:minHeight="100dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
|
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/author"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="@android:color/tertiary_text_dark"
|
|
||||||
android:textIsSelectable="false"
|
|
||||||
android:textStyle="bold|italic"/>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -146,7 +145,6 @@
|
|||||||
android:background="@drawable/ic_support"
|
android:background="@drawable/ic_support"
|
||||||
android:backgroundTint="@color/icon_grey"/>
|
android:backgroundTint="@color/icon_grey"/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -162,8 +160,7 @@
|
|||||||
android:layout_marginStart="@dimen/card_imageview_margin"
|
android:layout_marginStart="@dimen/card_imageview_margin"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:visibility="gone"
|
android:visibility="gone" />
|
||||||
/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
<string name="download_file_error">Error downloading file</string>
|
<string name="download_file_error">Error downloading file</string>
|
||||||
<string name="install_error">Installation error!</string>
|
<string name="install_error">Installation error!</string>
|
||||||
<string name="manual_install">Error in flashing file, zip file placed in %1$s\nFlash it in recovery manually</string>
|
<string name="manual_install">Error in flashing file, zip file placed in %1$s\nFlash it in recovery manually</string>
|
||||||
|
<string name="invalid_zip">The zip is not a Magisk Module!!</string>
|
||||||
<string name="reboot_title">Installation succeeded!</string>
|
<string name="reboot_title">Installation succeeded!</string>
|
||||||
<string name="reboot_msg">Do you want to reboot now?</string>
|
<string name="reboot_msg">Do you want to reboot now?</string>
|
||||||
<string name="reboot">Reboot</string>
|
<string name="reboot">Reboot</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user