mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-22 12:11:33 +00:00
Fix UI refreshes
This commit is contained in:
parent
6692b618ea
commit
91d3d2ad1f
@ -19,7 +19,6 @@ import android.view.WindowManager;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.RowItem;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -18,6 +18,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ 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 Utils.DownloadReceiver(getString(R.string.magisk)) {
|
new DownloadReceiver(getString(R.string.magisk)) {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
new Async.FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
@ -163,7 +164,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
.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), String.valueOf(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 Utils.DownloadReceiver() {
|
new DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
|
@ -22,6 +22,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.module.Module;
|
import com.topjohnwu.magisk.module.Module;
|
||||||
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -107,7 +108,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
|
|||||||
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
|
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
DownloadReceiver receiver = new DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
Log.d("Magisk", "Task firing");
|
Log.d("Magisk", "Task firing");
|
||||||
|
@ -18,7 +18,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.ipaulpro.afilechooser.FileInfo;
|
import com.ipaulpro.afilechooser.FileInfo;
|
||||||
import com.ipaulpro.afilechooser.utils.FileUtils;
|
import com.ipaulpro.afilechooser.utils.FileUtils;
|
||||||
@ -32,38 +31,36 @@ import butterknife.BindView;
|
|||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class ModulesFragment extends Fragment {
|
public class ModulesFragment extends Fragment {
|
||||||
@BindView(R.id.swipeRefreshLayout)
|
|
||||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
|
||||||
@BindView(R.id.recyclerView)
|
|
||||||
RecyclerView recyclerView;
|
|
||||||
@BindView(R.id.empty_rv)
|
|
||||||
TextView emptyTv;
|
|
||||||
private static final int FETCH_ZIP_CODE = 2;
|
private static final int FETCH_ZIP_CODE = 2;
|
||||||
|
|
||||||
|
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||||
|
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||||
|
@BindView(R.id.fab) FloatingActionButton fabio;
|
||||||
|
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
public static List<Module> listModules = new ArrayList<>();
|
public static List<Module> listModules = new ArrayList<>();
|
||||||
@BindView(R.id.fab)
|
|
||||||
FloatingActionButton fabio;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View viewMain = inflater.inflate(R.layout.modules_fragment, container, false);
|
View viewMain = inflater.inflate(R.layout.modules_fragment, container, false);
|
||||||
|
|
||||||
ButterKnife.bind(this, viewMain);
|
ButterKnife.bind(this, viewMain);
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
fabio.setOnClickListener(v -> {
|
fabio.setOnClickListener(v -> {
|
||||||
Intent getContentIntent = FileUtils.createGetContentIntent(null);
|
Intent getContentIntent = FileUtils.createGetContentIntent(null);
|
||||||
getContentIntent.setType("application/zip");
|
getContentIntent.setType("application/zip");
|
||||||
Intent fileIntent = Intent.createChooser(getContentIntent, "Select a file");
|
Intent fileIntent = Intent.createChooser(getContentIntent, "Select a file");
|
||||||
|
|
||||||
startActivityForResult(fileIntent, FETCH_ZIP_CODE);
|
startActivityForResult(fileIntent, FETCH_ZIP_CODE);
|
||||||
|
|
||||||
});
|
});
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
|
||||||
|
|
||||||
|
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
recyclerView.setVisibility(View.GONE);
|
recyclerView.setVisibility(View.GONE);
|
||||||
new Async.LoadModules(getActivity()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.LoadModules(getActivity()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
new updateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new UpdateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
prefs.edit().putBoolean("ignoreUpdateAlerts", false).apply();
|
prefs.edit().putBoolean("ignoreUpdateAlerts", false).apply();
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -72,12 +69,10 @@ public class ModulesFragment extends Fragment {
|
|||||||
if (s.contains("updated")) {
|
if (s.contains("updated")) {
|
||||||
viewMain.invalidate();
|
viewMain.invalidate();
|
||||||
viewMain.requestLayout();
|
viewMain.requestLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new updateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new UpdateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
|
||||||
return viewMain;
|
return viewMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +99,9 @@ public class ModulesFragment extends Fragment {
|
|||||||
getActivity().setTitle("Modules");
|
getActivity().setTitle("Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class updateUI extends AsyncTask<Void, Void, Void> {
|
private class UpdateUI extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
// Just for blocking
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
return null;
|
return null;
|
||||||
@ -142,8 +138,7 @@ public class ModulesFragment extends Fragment {
|
|||||||
Snackbar.make(undeleteBtn, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(undeleteBtn, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (mSwipeRefreshLayout.isRefreshing())
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
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.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.WebWindow;
|
import com.topjohnwu.magisk.utils.WebWindow;
|
||||||
@ -48,8 +49,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
|
|
||||||
public ReposAdapter(ReposFragment reposFragment, List<Repo> list) {
|
public ReposAdapter(List<Repo> list) {
|
||||||
ReposFragment reposFragment1 = reposFragment;
|
|
||||||
alertPackage = "";
|
alertPackage = "";
|
||||||
alertUpdate = false;
|
alertUpdate = false;
|
||||||
this.mList = list;
|
this.mList = list;
|
||||||
@ -145,7 +145,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
if (view.getId() == mHolder.updateImage.getId()) {
|
if (view.getId() == mHolder.updateImage.getId()) {
|
||||||
if (!repo.isInstalled() | repo.canUpdate()) {
|
if (!repo.isInstalled() | repo.canUpdate()) {
|
||||||
|
|
||||||
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
DownloadReceiver receiver = new DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
Log.d("Magisk", "Task firing");
|
Log.d("Magisk", "Task firing");
|
||||||
|
@ -55,21 +55,21 @@ public class ReposFragment extends Fragment {
|
|||||||
mView = view;
|
mView = view;
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
swipeRefreshLayout.setOnRefreshListener(() -> {
|
swipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
this.LoadRepo(true);
|
new Async.LoadRepos(getActivity()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
new UpdateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
ignoreAlertUpdate = false;
|
ignoreAlertUpdate = false;
|
||||||
|
|
||||||
});
|
});
|
||||||
LoadRepo(false);
|
//LoadRepo(false);
|
||||||
|
new UpdateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
setHasOptionsMenu(false);
|
setHasOptionsMenu(false);
|
||||||
alertUpdate = false;
|
alertUpdate = false;
|
||||||
if (mListRepos.size() == 0) {
|
// if (mListRepos.size() == 0) {
|
||||||
emptyTv.setVisibility(View.VISIBLE);
|
// emptyTv.setVisibility(View.VISIBLE);
|
||||||
recyclerView.setVisibility(View.GONE);
|
// recyclerView.setVisibility(View.GONE);
|
||||||
return view;
|
// return view;
|
||||||
}
|
// }
|
||||||
CheckForUpdates();
|
//CheckForUpdates();
|
||||||
Log.d("Magisk", "ReposFragment: ListRepos size is " + listRepos().size());
|
//recyclerView.setAdapter(new ReposAdapter(this, mListRepos));
|
||||||
recyclerView.setAdapter(new ReposAdapter(this, mListRepos));
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -89,96 +89,117 @@ public class ReposFragment extends Fragment {
|
|||||||
super.onAttachFragment(childFragment);
|
super.onAttachFragment(childFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadRepo(boolean doReload) {
|
// private void LoadRepo(boolean doReload) {
|
||||||
RepoHelper.TaskDelegate taskDelegate = result -> {
|
// RepoHelper.TaskDelegate taskDelegate = result -> {
|
||||||
if (result.equals("Complete")) {
|
// if (result.equals("Complete")) {
|
||||||
Log.d("Magisk", "ReposFragment, got delegate");
|
// Log.d("Magisk", "ReposFragment, got delegate");
|
||||||
UpdateUI();
|
// UpdateUI();
|
||||||
if (mView != null) {
|
// if (mView != null) {
|
||||||
mView.invalidate();
|
// mView.invalidate();
|
||||||
mView.requestLayout();
|
// mView.requestLayout();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// };
|
||||||
|
// Log.d("Magisk", "ReposFragment, LoadRepo called");
|
||||||
|
// new Async.LoadRepos(getActivity());
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
// private void NotifyOfAlerts() {
|
||||||
|
// if (alertUpdate && !ignoreAlertUpdate) {
|
||||||
};
|
// Iterator<Repo> iterRepo = mListReposToUpdate.iterator();
|
||||||
Log.d("Magisk", "ReposFragment, LoadRepo called");
|
// while (iterRepo.hasNext()) {
|
||||||
new Async.LoadRepos(getActivity());
|
// Repo repo = iterRepo.next();
|
||||||
}
|
// DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
|
||||||
|
// switch (which) {
|
||||||
private void NotifyOfAlerts() {
|
// case DialogInterface.BUTTON_POSITIVE:
|
||||||
if (alertUpdate && !ignoreAlertUpdate) {
|
// Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
||||||
Iterator<Repo> iterRepo = mListReposToUpdate.iterator();
|
// @Override
|
||||||
while (iterRepo.hasNext()) {
|
// public void task(File file) {
|
||||||
Repo repo = iterRepo.next();
|
// Log.d("Magisk", "Task firing");
|
||||||
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
|
// new Async.FlashZIP(getActivity(), repo.getId(), file.toString()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
switch (which) {
|
// }
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
// };
|
||||||
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
// String filename = repo.getId().replace(" ", "") + ".zip";
|
||||||
@Override
|
// Utils.downloadAndReceive(getActivity(), receiver, repo.getZipUrl(), filename);
|
||||||
public void task(File file) {
|
//
|
||||||
Log.d("Magisk", "Task firing");
|
// break;
|
||||||
new Async.FlashZIP(getActivity(), repo.getId(), file.toString()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
//
|
||||||
}
|
// case DialogInterface.BUTTON_NEGATIVE:
|
||||||
};
|
//// ignoreAlertUpdate = true;
|
||||||
String filename = repo.getId().replace(" ", "") + ".zip";
|
//// SharedPreferences.Editor editor = prefs.edit();
|
||||||
Utils.downloadAndReceive(getActivity(), receiver, repo.getZipUrl(), filename);
|
//// editor.putBoolean("ignoreUpdateAlerts", ignoreAlertUpdate);
|
||||||
|
//// editor.apply();
|
||||||
break;
|
// break;
|
||||||
|
// }
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
// };
|
||||||
// ignoreAlertUpdate = true;
|
//
|
||||||
// SharedPreferences.Editor editor = prefs.edit();
|
// String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", "");
|
||||||
// editor.putBoolean("ignoreUpdateAlerts", ignoreAlertUpdate);
|
// Logger.dh("ReposFragment: Theme is " + theme);
|
||||||
// editor.apply();
|
// if (theme.equals("Dark")) {
|
||||||
break;
|
// builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh);
|
||||||
}
|
// } else {
|
||||||
};
|
// builder = new AlertDialog.Builder(getActivity());
|
||||||
|
// }
|
||||||
String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", "");
|
// builder.setMessage("An update is available for " + repo.getName() + ". Would you like to install it?").setPositiveButton("Yes", dialogClickListener)
|
||||||
Logger.dh("ReposFragment: Theme is " + theme);
|
// .setNegativeButton("No", dialogClickListener).show();
|
||||||
if (theme.equals("Dark")) {
|
// iterRepo.remove();
|
||||||
builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh);
|
//
|
||||||
} else {
|
// }
|
||||||
builder = new AlertDialog.Builder(getActivity());
|
//
|
||||||
}
|
// }
|
||||||
builder.setMessage("An update is available for " + repo.getName() + ". Would you like to install it?").setPositiveButton("Yes", dialogClickListener)
|
// }
|
||||||
.setNegativeButton("No", dialogClickListener).show();
|
|
||||||
iterRepo.remove();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
LoadRepo(false);
|
//LoadRepo(false);
|
||||||
getActivity().setTitle("Magisk");
|
getActivity().setTitle("Magisk");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Repo> listRepos() {
|
private class UpdateUI extends AsyncTask<Void, Void, Void> {
|
||||||
return mListRepos;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateUI() {
|
@Override
|
||||||
Log.d("Magisk", "ReposFragment: UpdateUI Called, size is " + listRepos().size());
|
protected Void doInBackground(Void... voids) {
|
||||||
|
return null;
|
||||||
if (listRepos().size() == 0) {
|
|
||||||
emptyTv.setVisibility(View.VISIBLE);
|
|
||||||
recyclerView.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
|
||||||
Log.d("Magisk", "ReposFragment: ListRepos size is " + listRepos().size());
|
|
||||||
recyclerView.setAdapter(new ReposAdapter(this, listRepos()));
|
|
||||||
if (swipeRefreshLayout.isRefreshing()) {
|
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
|
||||||
CheckForUpdates();
|
|
||||||
//NotifyOfAlerts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void v) {
|
||||||
|
super.onPostExecute(v);
|
||||||
|
if (mListRepos.size() == 0) {
|
||||||
|
emptyTv.setVisibility(View.VISIBLE);
|
||||||
|
recyclerView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.d("Magisk", "ReposFragment: ListRepos size is " + mListRepos.size());
|
||||||
|
recyclerView.setAdapter(new ReposAdapter(mListRepos));
|
||||||
|
if (swipeRefreshLayout.isRefreshing()) {
|
||||||
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
//CheckForUpdates();
|
||||||
|
//NotifyOfAlerts();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private void UpdateUI() {
|
||||||
|
// Log.d("Magisk", "ReposFragment: UpdateUI Called, size is " + mListRepos.size());
|
||||||
|
//
|
||||||
|
// if (mListRepos.size() == 0) {
|
||||||
|
// emptyTv.setVisibility(View.VISIBLE);
|
||||||
|
// recyclerView.setVisibility(View.GONE);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// Log.d("Magisk", "ReposFragment: ListRepos size is " + mListRepos.size());
|
||||||
|
// recyclerView.setAdapter(new ReposAdapter(this, mListRepos));
|
||||||
|
// if (swipeRefreshLayout.isRefreshing()) {
|
||||||
|
// swipeRefreshLayout.setRefreshing(false);
|
||||||
|
// CheckForUpdates();
|
||||||
|
// //NotifyOfAlerts();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,42 +36,26 @@ import butterknife.ButterKnife;
|
|||||||
public class RootFragment extends Fragment {
|
public class RootFragment extends Fragment {
|
||||||
|
|
||||||
public SharedPreferences prefs;
|
public SharedPreferences prefs;
|
||||||
@BindView(R.id.progressBar)
|
|
||||||
ProgressBar progressBar;
|
@BindView(R.id.progressBar) ProgressBar progressBar;
|
||||||
@BindView(R.id.rootSwitchView)
|
@BindView(R.id.rootSwitchView) View rootToggleView;
|
||||||
View rootToggleView;
|
@BindView(R.id.autoRootSwitchView) View autoRootToggleView;
|
||||||
@BindView(R.id.autoRootSwitchView)
|
@BindView(R.id.selinuxSwitchView) View selinuxToggleView;
|
||||||
View autoRootToggleView;
|
@BindView(R.id.rootStatusView) View rootStatusView;
|
||||||
@BindView(R.id.selinuxSwitchView)
|
@BindView(R.id.safetynetStatusView) View safetynetStatusView;
|
||||||
View selinuxToggleView;
|
@BindView(R.id.selinuxStatusView) View selinuxStatusView;
|
||||||
@BindView(R.id.rootStatusView)
|
@BindView(R.id.root_toggle) Switch rootToggle;
|
||||||
View rootStatusView;
|
@BindView(R.id.auto_root_toggle) Switch autoRootToggle;
|
||||||
@BindView(R.id.safetynetStatusView)
|
@BindView(R.id.selinux_toggle) Switch selinuxToggle;
|
||||||
View safetynetStatusView;
|
@BindView(R.id.root_status_container) View rootStatusContainer;
|
||||||
@BindView(R.id.selinuxStatusView)
|
@BindView(R.id.root_status_icon) ImageView rootStatusIcon;
|
||||||
View selinuxStatusView;
|
@BindView(R.id.root_status) TextView rootStatus;
|
||||||
@BindView(R.id.root_toggle)
|
@BindView(R.id.selinux_status_container) View selinuxStatusContainer;
|
||||||
Switch rootToggle;
|
@BindView(R.id.selinux_status_icon) ImageView selinuxStatusIcon;
|
||||||
@BindView(R.id.auto_root_toggle)
|
@BindView(R.id.selinux_status) TextView selinuxStatus;
|
||||||
Switch autoRootToggle;
|
@BindView(R.id.safety_net_status) TextView safetyNetStatus;
|
||||||
@BindView(R.id.selinux_toggle)
|
@BindView(R.id.safety_net_icon) ImageView safetyNetStatusIcon;
|
||||||
Switch selinuxToggle;
|
|
||||||
@BindView(R.id.root_status_container)
|
|
||||||
View rootStatusContainer;
|
|
||||||
@BindView(R.id.root_status_icon)
|
|
||||||
ImageView rootStatusIcon;
|
|
||||||
@BindView(R.id.root_status)
|
|
||||||
TextView rootStatus;
|
|
||||||
@BindView(R.id.selinux_status_container)
|
|
||||||
View selinuxStatusContainer;
|
|
||||||
@BindView(R.id.selinux_status_icon)
|
|
||||||
ImageView selinuxStatusIcon;
|
|
||||||
@BindView(R.id.selinux_status)
|
|
||||||
TextView selinuxStatus;
|
|
||||||
@BindView(R.id.safety_net_status)
|
|
||||||
TextView safetyNetStatus;
|
|
||||||
@BindView(R.id.safety_net_icon)
|
|
||||||
ImageView safetyNetStatusIcon;
|
|
||||||
int statusOK = R.drawable.ic_check_circle;
|
int statusOK = R.drawable.ic_check_circle;
|
||||||
int statusAuto = R.drawable.ic_autoroot;
|
int statusAuto = R.drawable.ic_autoroot;
|
||||||
int statusError = R.drawable.ic_error;
|
int statusError = R.drawable.ic_error;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.topjohnwu.magisk.receivers;
|
||||||
|
|
||||||
|
import android.app.DownloadManager;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public abstract class DownloadReceiver extends BroadcastReceiver {
|
||||||
|
public Context mContext;
|
||||||
|
long downloadID;
|
||||||
|
public String mName;
|
||||||
|
|
||||||
|
public DownloadReceiver() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadReceiver(String name) {
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
mContext = context;
|
||||||
|
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
|
||||||
|
DownloadManager.Query query = new DownloadManager.Query();
|
||||||
|
query.setFilterById(downloadID);
|
||||||
|
Cursor c = downloadManager.query(query);
|
||||||
|
if (c.moveToFirst()) {
|
||||||
|
int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
|
||||||
|
int status = c.getInt(columnIndex);
|
||||||
|
switch (status) {
|
||||||
|
case DownloadManager.STATUS_SUCCESSFUL:
|
||||||
|
File file = new File(Uri.parse(c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).getPath());
|
||||||
|
task(file);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Toast.makeText(context, R.string.download_file_error, Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
context.unregisterReceiver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownloadID(long id) {
|
||||||
|
downloadID = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void task(File file);
|
||||||
|
}
|
@ -25,11 +25,11 @@ public final class PrivateBroadcastReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
if (ACTION_ENABLEROOT.equals(action)) {
|
if (ACTION_ENABLEROOT.equals(action)) {
|
||||||
Utils.toggleAutoRoot(false, context);
|
Utils.toggleAutoRoot(false, context);
|
||||||
Utils.toggleRoot(true,context);
|
Utils.toggleRoot(true, context);
|
||||||
}
|
}
|
||||||
if (ACTION_DISABLEROOT.equals(action)) {
|
if (ACTION_DISABLEROOT.equals(action)) {
|
||||||
Utils.toggleAutoRoot(false, context);
|
Utils.toggleAutoRoot(false, context);
|
||||||
Utils.toggleRoot(false,context);
|
Utils.toggleRoot(false, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.SetupQuickSettingsTile(context);
|
Utils.SetupQuickSettingsTile(context);
|
||||||
|
@ -17,6 +17,7 @@ import com.topjohnwu.magisk.R;
|
|||||||
import com.topjohnwu.magisk.ReposFragment;
|
import com.topjohnwu.magisk.ReposFragment;
|
||||||
import com.topjohnwu.magisk.module.Module;
|
import com.topjohnwu.magisk.module.Module;
|
||||||
import com.topjohnwu.magisk.module.RepoHelper;
|
import com.topjohnwu.magisk.module.RepoHelper;
|
||||||
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -118,13 +119,13 @@ public class Async {
|
|||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> new AlertDialog.Builder(mContext)
|
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> new AlertDialog.Builder(mContext)
|
||||||
.setTitle(R.string.root_method_title)
|
.setTitle(R.string.root_method_title)
|
||||||
.setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> {
|
.setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> {
|
||||||
Utils.DownloadReceiver rootReceiver;
|
DownloadReceiver rootReceiver;
|
||||||
String link, filename;
|
String link, filename;
|
||||||
switch (root) {
|
switch (root) {
|
||||||
case 0:
|
case 0:
|
||||||
link = Utils.phhLink;
|
link = Utils.phhLink;
|
||||||
filename = "phhsu.zip";
|
filename = "phhsu.zip";
|
||||||
rootReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.phh)) {
|
rootReceiver = new DownloadReceiver(mContext.getString(R.string.phh)) {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
@ -134,7 +135,7 @@ public class Async {
|
|||||||
case 1:
|
case 1:
|
||||||
link = Utils.supersuLink;
|
link = Utils.supersuLink;
|
||||||
filename = "supersu.zip";
|
filename = "supersu.zip";
|
||||||
rootReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.supersu)) {
|
rootReceiver = new DownloadReceiver(mContext.getString(R.string.supersu)) {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
@ -145,7 +146,7 @@ public class Async {
|
|||||||
rootReceiver = null;
|
rootReceiver = null;
|
||||||
link = filename = null;
|
link = filename = null;
|
||||||
}
|
}
|
||||||
Utils.DownloadReceiver magiskReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.magisk)) {
|
DownloadReceiver magiskReceiver = new DownloadReceiver(mContext.getString(R.string.magisk)) {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
Context temp = mContext;
|
Context temp = mContext;
|
||||||
@ -174,7 +175,7 @@ public class Async {
|
|||||||
case 0:
|
case 0:
|
||||||
Utils.downloadAndReceive(
|
Utils.downloadAndReceive(
|
||||||
mContext,
|
mContext,
|
||||||
new Utils.DownloadReceiver(mContext.getString(R.string.phh)) {
|
new DownloadReceiver(mContext.getString(R.string.phh)) {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
@ -185,7 +186,7 @@ public class Async {
|
|||||||
case 1:
|
case 1:
|
||||||
Utils.downloadAndReceive(
|
Utils.downloadAndReceive(
|
||||||
mContext,
|
mContext,
|
||||||
new Utils.DownloadReceiver(mContext.getString(R.string.supersu)) {
|
new DownloadReceiver(mContext.getString(R.string.supersu)) {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new FlashZIP(mContext, mName, file.getPath()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
@ -1,23 +1,18 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.quicksettings.TileService;
|
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
@ -27,8 +22,8 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.RootFragment;
|
|
||||||
import com.topjohnwu.magisk.module.BaseModule;
|
import com.topjohnwu.magisk.module.BaseModule;
|
||||||
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||||
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
||||||
import com.topjohnwu.magisk.services.MonitorService;
|
import com.topjohnwu.magisk.services.MonitorService;
|
||||||
import com.topjohnwu.magisk.services.TileServiceCompat;
|
import com.topjohnwu.magisk.services.TileServiceCompat;
|
||||||
@ -423,51 +418,6 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class DownloadReceiver extends BroadcastReceiver {
|
|
||||||
public Context mContext;
|
|
||||||
long downloadID;
|
|
||||||
public String mName;
|
|
||||||
|
|
||||||
public DownloadReceiver() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public DownloadReceiver(String name) {
|
|
||||||
mName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
mContext = context;
|
|
||||||
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
|
|
||||||
DownloadManager.Query query = new DownloadManager.Query();
|
|
||||||
query.setFilterById(downloadID);
|
|
||||||
Cursor c = downloadManager.query(query);
|
|
||||||
if (c.moveToFirst()) {
|
|
||||||
int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
|
|
||||||
int status = c.getInt(columnIndex);
|
|
||||||
switch (status) {
|
|
||||||
case DownloadManager.STATUS_SUCCESSFUL:
|
|
||||||
File file = new File(Uri.parse(c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).getPath());
|
|
||||||
task(file);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Toast.makeText(context, R.string.download_file_error, Toast.LENGTH_LONG).show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
context.unregisterReceiver(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDownloadID(long id) {
|
|
||||||
downloadID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void task(File file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
|
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
|
||||||
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||||
|
@ -57,35 +57,35 @@
|
|||||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
|
android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.topjohnwu.magisk.utils.RowItem
|
<com.topjohnwu.magisk.RowItem
|
||||||
android:id="@+id/app_version_info"
|
android:id="@+id/app_version_info"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:icon="@drawable/ic_info_outline"
|
app:icon="@drawable/ic_info_outline"
|
||||||
app:text="@string/app_version"/>
|
app:text="@string/app_version"/>
|
||||||
|
|
||||||
<com.topjohnwu.magisk.utils.RowItem
|
<com.topjohnwu.magisk.RowItem
|
||||||
android:id="@+id/app_changelog"
|
android:id="@+id/app_changelog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:icon="@drawable/ic_history"
|
app:icon="@drawable/ic_history"
|
||||||
app:text="@string/app_changelog"/>
|
app:text="@string/app_changelog"/>
|
||||||
|
|
||||||
<com.topjohnwu.magisk.utils.RowItem
|
<com.topjohnwu.magisk.RowItem
|
||||||
android:id="@+id/app_developers"
|
android:id="@+id/app_developers"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:icon="@drawable/ic_person"
|
app:icon="@drawable/ic_person"
|
||||||
app:text="@string/app_developers"/>
|
app:text="@string/app_developers"/>
|
||||||
|
|
||||||
<com.topjohnwu.magisk.utils.RowItem
|
<com.topjohnwu.magisk.RowItem
|
||||||
android:id="@+id/app_translators"
|
android:id="@+id/app_translators"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:icon="@drawable/ic_language"
|
app:icon="@drawable/ic_language"
|
||||||
app:text="@string/app_translators"/>
|
app:text="@string/app_translators"/>
|
||||||
|
|
||||||
<com.topjohnwu.magisk.utils.RowItem
|
<com.topjohnwu.magisk.RowItem
|
||||||
android:id="@+id/app_source_code"
|
android:id="@+id/app_source_code"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -104,7 +104,7 @@
|
|||||||
style="?attr/cardStyle"
|
style="?attr/cardStyle"
|
||||||
app:cardUseCompatPadding="true">
|
app:cardUseCompatPadding="true">
|
||||||
|
|
||||||
<com.topjohnwu.magisk.utils.RowItem
|
<com.topjohnwu.magisk.RowItem
|
||||||
android:id="@+id/support_thread"
|
android:id="@+id/support_thread"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user