mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:37:49 +00:00
More refinements...
This commit is contained in:
parent
145d4e4bd5
commit
46abbfe224
@ -3,13 +3,16 @@ package com.topjohnwu.magisk;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
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.util.Log;
|
||||||
@ -29,17 +32,22 @@ 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;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public abstract class BaseModuleFragment extends Fragment {
|
public abstract class BaseModuleFragment extends Fragment {
|
||||||
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
@BindView(R.id.swipeRefreshLayout)
|
||||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
@BindView(R.id.empty_rv) TextView emptyTv;
|
@BindView(R.id.recyclerView)
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
@BindView(R.id.empty_rv)
|
||||||
|
TextView emptyTv;
|
||||||
|
|
||||||
private RepoHelper.TaskDelegate mDelegate;
|
private RepoHelper.TaskDelegate mDelegate;
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
@ -55,13 +63,16 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
ButterKnife.bind(this, viewMain);
|
ButterKnife.bind(this, viewMain);
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
|
||||||
Log.d("Magisk","ModulesFragment: SWIPE");
|
|
||||||
mDelegate.taskCompletionResult("OK");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
|
|
||||||
|
mDelegate.taskCompletionResult("OK");
|
||||||
|
prefs.edit().putBoolean("ignoreUpdateAlerts", false).apply();
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
prefs.registerOnSharedPreferenceChangeListener((sharedPreferences, s) -> {
|
prefs.registerOnSharedPreferenceChangeListener((sharedPreferences, s) -> {
|
||||||
if (s.contains("updated")) {
|
if (s.contains("updated")) {
|
||||||
viewMain.invalidate();
|
viewMain.invalidate();
|
||||||
@ -98,6 +109,8 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
listModules().get(position).deleteRemoveFile();
|
listModules().get(position).deleteRemoveFile();
|
||||||
Snackbar.make(undeleteBtn, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(undeleteBtn, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
return viewMain;
|
return viewMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,20 +120,27 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHolder> {
|
public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHolder> {
|
||||||
|
|
||||||
private final List<Module> mList;
|
private final List<Module> mList;
|
||||||
|
private final List<Module> mListToUpdate = new ArrayList<>();
|
||||||
List<Boolean> mExpandedList;
|
List<Boolean> mExpandedList;
|
||||||
@BindView(R.id.expand_layout)
|
@BindView(R.id.expand_layout)
|
||||||
LinearLayout expandedLayout;
|
LinearLayout expandedLayout;
|
||||||
private View viewMain;
|
private View viewMain;
|
||||||
private Context context;
|
private Context context;
|
||||||
private final Utils.ItemClickListener chboxListener;
|
private final Utils.ItemClickListener chboxListener;
|
||||||
private final Utils.ItemClickListener deleteBtnListener;
|
private final Utils.ItemClickListener deleteBtnListener;
|
||||||
private final Utils.ItemClickListener unDeleteBtnListener;
|
private final Utils.ItemClickListener unDeleteBtnListener;
|
||||||
|
private boolean alertUpdate, ignoreAlertUpdate;
|
||||||
|
|
||||||
public ModulesAdapter(List<Module> list, Utils.ItemClickListener chboxListener, Utils.ItemClickListener deleteBtnListener, Utils.ItemClickListener undeleteBtnListener) {
|
public ModulesAdapter(List<Module> list, Utils.ItemClickListener chboxListener, Utils.ItemClickListener deleteBtnListener, Utils.ItemClickListener undeleteBtnListener) {
|
||||||
|
alertUpdate = false;
|
||||||
this.mList = list;
|
this.mList = list;
|
||||||
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 (listModules().get(i).isUpdateAvailable()) {
|
||||||
|
alertUpdate = true;
|
||||||
|
mListToUpdate.add(listModules().get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.chboxListener = chboxListener;
|
this.chboxListener = chboxListener;
|
||||||
this.deleteBtnListener = deleteBtnListener;
|
this.deleteBtnListener = deleteBtnListener;
|
||||||
@ -130,43 +150,84 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
@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_module, parent, false);
|
viewMain = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_module, parent, false);
|
||||||
context = parent.getContext();
|
context = parent.getContext();
|
||||||
ButterKnife.bind(this, viewMain);
|
ButterKnife.bind(this, viewMain);
|
||||||
return new ViewHolder(viewMain);
|
return new ViewHolder(viewMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||||
final Module module = mList.get(position);
|
final Module module = mList.get(position);
|
||||||
Log.d("Magisk","ModulesAdapter: Trying set up bindview from list pos " + position + " and " + module.getName() );
|
Log.d("Magisk", "ModulesAdapter: Trying set up bindview from list pos " + position + " and " + module.getName());
|
||||||
|
Log.d("Magisk", "BaseModuleFragment: Log ID is " + module.getmLogUrl());
|
||||||
holder.title.setText(module.getName());
|
holder.title.setText(module.getName());
|
||||||
holder.versionName.setText(module.getVersion());
|
holder.versionName.setText(module.getVersion());
|
||||||
holder.description.setText(module.getDescription());
|
holder.description.setText(module.getDescription());
|
||||||
holder.author.setText(module.getAuthor());
|
holder.author.setText(module.getAuthor());
|
||||||
|
String logUrl = module.getmLogUrl();
|
||||||
|
String supportUrl = module.getmSupportUrl();
|
||||||
|
String donateUrl = module.getmDonateUrl();
|
||||||
|
if (supportUrl != null && !supportUrl.isEmpty()) holder.supportLink.setBackgroundColor(Color.GRAY);
|
||||||
|
if (logUrl != null && !logUrl.isEmpty()) holder.changeLog.setBackgroundColor(Color.GRAY);
|
||||||
|
if (donateUrl != null && !donateUrl.isEmpty()) holder.authorLink.setBackgroundColor(Color.GRAY);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if (prefs.contains("ignoreUpdateAlerts")) {
|
||||||
|
ignoreAlertUpdate = prefs.getBoolean("ignoreUpdateAlerts", false);
|
||||||
|
}
|
||||||
if (prefs.contains("repo-canUpdate_" + module.getId())) {
|
if (prefs.contains("repo-canUpdate_" + module.getId())) {
|
||||||
if (prefs.getBoolean("repo-canUpdate_" + module.getId(),false)) {
|
if (prefs.getBoolean("repo-canUpdate_" + module.getId(), false)) {
|
||||||
holder.updateStatus.setText(R.string.module_update_available);
|
holder.updateStatus.setText(R.string.module_update_available);
|
||||||
holder.updateStatus.setVisibility(View.VISIBLE);
|
holder.updateStatus.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.updateStatus.setVisibility(View.GONE);
|
holder.updateStatus.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alertUpdate && !ignoreAlertUpdate) {
|
||||||
|
Iterator<Module> iterRepo = mListToUpdate.iterator();
|
||||||
|
while (iterRepo.hasNext()) {
|
||||||
|
Module mModule = iterRepo.next();
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
||||||
|
@Override
|
||||||
|
public void task(File file) {
|
||||||
|
Log.d("Magisk", "Task firing");
|
||||||
|
new Utils.FlashZIP(context, mModule.getId(), file.toString()).execute();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
String filename = mModule.getId().replace(" ", "") + ".zip";
|
||||||
|
Utils.downloadAndReceive(context, receiver, mModule.getmZipUrl(), filename);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
ignoreAlertUpdate = true;
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
editor.putBoolean("ignoreUpdateAlerts", ignoreAlertUpdate);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setMessage("An update is available for " + mModule.getName() + ". Would you like to install it?").setPositiveButton("Yes", dialogClickListener)
|
||||||
|
.setNegativeButton("No", dialogClickListener).show();
|
||||||
|
mListToUpdate.remove(mModule);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
View.OnClickListener oCl = new View.OnClickListener() {
|
View.OnClickListener oCl = view -> {
|
||||||
@Override
|
if (view.getId() == holder.changeLog.getId()) {
|
||||||
public void onClick(View view) {
|
|
||||||
if (view.getId() == holder.changeLog.getId()) {
|
new WebWindow("Changelog", module.getmLogUrl(), context);
|
||||||
new WebWindow("Changelog",module.getChangeLog(),context);
|
}
|
||||||
}
|
if (view.getId() == holder.authorLink.getId()) {
|
||||||
if (view.getId() == holder.authorLink.getId()) {
|
new WebWindow("Donate", module.getmDonateUrl(), context);
|
||||||
new WebWindow("Donate",module.getmDonateUrl(),context);
|
}
|
||||||
}
|
if (view.getId() == holder.supportLink.getId()) {
|
||||||
if (view.getId() == holder.supportLink.getId()) {
|
new WebWindow("Support", module.getmSupportUrl(), context);
|
||||||
new WebWindow("Support",module.getmSupportUrl(),context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -206,19 +267,31 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
|
|
||||||
class ViewHolder extends RecyclerView.ViewHolder {
|
class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@BindView(R.id.title) TextView title;
|
@BindView(R.id.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.warning) TextView warning;
|
@BindView(R.id.description)
|
||||||
@BindView(R.id.checkbox) CheckBox checkBox;
|
TextView description;
|
||||||
@BindView(R.id.author) TextView author;
|
@BindView(R.id.warning)
|
||||||
@BindView(R.id.updateStatus) TextView updateStatus;
|
TextView warning;
|
||||||
@BindView(R.id.delete) ImageView delete;
|
@BindView(R.id.checkbox)
|
||||||
@BindView(R.id.changeLog) ImageView changeLog;
|
CheckBox checkBox;
|
||||||
@BindView(R.id.authorLink) ImageView authorLink;
|
@BindView(R.id.author)
|
||||||
@BindView(R.id.supportLink) ImageView supportLink;
|
TextView author;
|
||||||
@BindView(R.id.expand_layout) LinearLayout expandLayout;
|
@BindView(R.id.updateStatus)
|
||||||
|
TextView updateStatus;
|
||||||
|
@BindView(R.id.delete)
|
||||||
|
ImageView delete;
|
||||||
|
@BindView(R.id.changeLog)
|
||||||
|
ImageView changeLog;
|
||||||
|
@BindView(R.id.authorLink)
|
||||||
|
ImageView authorLink;
|
||||||
|
@BindView(R.id.supportLink)
|
||||||
|
ImageView supportLink;
|
||||||
|
@BindView(R.id.expand_layout)
|
||||||
|
LinearLayout expandLayout;
|
||||||
private ValueAnimator mAnimator;
|
private ValueAnimator mAnimator;
|
||||||
private int mMeasuredHeight;
|
private int mMeasuredHeight;
|
||||||
|
|
||||||
@ -226,19 +299,19 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
super(itemView);
|
super(itemView);
|
||||||
WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
DisplayMetrics dimension = new DisplayMetrics();
|
DisplayMetrics dimension = new DisplayMetrics();
|
||||||
windowmanager.getDefaultDisplay().getMetrics(dimension);
|
windowmanager.getDefaultDisplay().getMetrics(dimension);
|
||||||
final int mHeight = dimension.heightPixels;
|
|
||||||
|
|
||||||
expandLayout.getViewTreeObserver().addOnPreDrawListener(
|
expandLayout.getViewTreeObserver().addOnPreDrawListener(
|
||||||
new ViewTreeObserver.OnPreDrawListener() {
|
new ViewTreeObserver.OnPreDrawListener() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreDraw() {
|
public boolean onPreDraw() {
|
||||||
expandLayout.getViewTreeObserver().removeOnPreDrawListener(this);
|
expandLayout.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
expandLayout.setVisibility(View.GONE);
|
expandLayout.setVisibility(View.GONE);
|
||||||
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||||
final int heightSpec = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
|
final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||||
expandLayout.measure(widthSpec, heightSpec);
|
expandLayout.measure(widthSpec, heightSpec);
|
||||||
mAnimator = slideAnimator(0, expandLayout.getMeasuredHeight());
|
mAnimator = slideAnimator(0, expandLayout.getMeasuredHeight());
|
||||||
return true;
|
return true;
|
||||||
@ -262,58 +335,59 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
delete.setEnabled(false);
|
delete.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void expand(View view) {
|
|
||||||
|
|
||||||
// set Visible
|
private void expand(View view) {
|
||||||
|
|
||||||
|
// set Visible
|
||||||
|
|
||||||
|
|
||||||
Log.d("Magisk", "ReposFragment: Expand anim called " + mMeasuredHeight + " and " + view.getId());
|
Log.d("Magisk", "ReposFragment: Expand anim called " + mMeasuredHeight + " and " + view.getId());
|
||||||
view.setVisibility(View.VISIBLE);
|
view.setVisibility(View.VISIBLE);
|
||||||
mAnimator.start();
|
mAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collapse(View view) {
|
private void collapse(View view) {
|
||||||
int finalHeight = view.getHeight();
|
int finalHeight = view.getHeight();
|
||||||
ValueAnimator mAnimator = slideAnimator(finalHeight, 0);
|
ValueAnimator mAnimator = slideAnimator(finalHeight, 0);
|
||||||
Log.d("Magisk", "ReposFragment: Collapse anim called " + finalHeight + " and " + view.getId());
|
Log.d("Magisk", "ReposFragment: Collapse anim called " + finalHeight + " and " + view.getId());
|
||||||
|
|
||||||
mAnimator.addListener(new Animator.AnimatorListener() {
|
mAnimator.addListener(new Animator.AnimatorListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animator) {
|
public void onAnimationEnd(Animator animator) {
|
||||||
// Height=0, but it set visibility to GONE
|
// Height=0, but it set visibility to GONE
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueAnimator slideAnimator(int start, int end) {
|
private ValueAnimator slideAnimator(int start, int end) {
|
||||||
|
|
||||||
ValueAnimator animator = ValueAnimator.ofInt(start, end);
|
ValueAnimator animator = ValueAnimator.ofInt(start, end);
|
||||||
|
|
||||||
animator.addUpdateListener(valueAnimator -> {
|
animator.addUpdateListener(valueAnimator -> {
|
||||||
// Update Height
|
// Update Height
|
||||||
int value = (Integer) valueAnimator.getAnimatedValue();
|
int value = (Integer) valueAnimator.getAnimatedValue();
|
||||||
|
|
||||||
ViewGroup.LayoutParams layoutParams = expandLayout
|
ViewGroup.LayoutParams layoutParams = expandLayout
|
||||||
.getLayoutParams();
|
.getLayoutParams();
|
||||||
layoutParams.height = value;
|
layoutParams.height = value;
|
||||||
expandLayout.setLayoutParams(layoutParams);
|
expandLayout.setLayoutParams(layoutParams);
|
||||||
});
|
});
|
||||||
return animator;
|
return animator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,24 +33,37 @@ import butterknife.ButterKnife;
|
|||||||
|
|
||||||
public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder> {
|
public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder> {
|
||||||
|
|
||||||
private ReposFragment reposFragment;
|
|
||||||
private final List<Repo> mList;
|
private final List<Repo> mList;
|
||||||
List<Boolean> mExpandedList;
|
List<Boolean> mExpandedList;
|
||||||
private View viewMain;
|
private View viewMain;
|
||||||
private Context context;
|
private Context context;
|
||||||
private boolean mIsInstalled, mCanUpdate;
|
private boolean mCanUpdate;
|
||||||
|
private boolean alertUpdate;
|
||||||
|
private boolean ignoreAlertUpdate;
|
||||||
private Repo repo;
|
private Repo repo;
|
||||||
private ViewHolder mHolder;
|
private ViewHolder mHolder;
|
||||||
|
private String mDonateUrl, mSupportUrl, mLogUrl,alertPackage;
|
||||||
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
|
|
||||||
public ReposAdapter(ReposFragment reposFragment, List<Repo> list) {
|
public ReposAdapter(ReposFragment reposFragment, List<Repo> list) {
|
||||||
this.reposFragment = reposFragment;
|
ReposFragment reposFragment1 = reposFragment;
|
||||||
|
alertPackage = "";
|
||||||
|
alertUpdate = false;
|
||||||
this.mList = list;
|
this.mList = list;
|
||||||
Log.d("Magisk", "ReposAdapter: I am alive. I have a list " + list.size());
|
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
|
||||||
@ -75,17 +88,21 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||||
|
prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
repo = mList.get(position);
|
repo = mList.get(position);
|
||||||
mHolder = holder;
|
mHolder = holder;
|
||||||
|
mDonateUrl = repo.getmDonateUrl();
|
||||||
|
mSupportUrl = repo.getmSupportUrl();
|
||||||
|
mLogUrl = repo.getmLogUrl();
|
||||||
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();
|
SetupViewElements(repo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupViewElements() {
|
private void SetupViewElements(Repo repo) {
|
||||||
int mPosition = mHolder.getAdapterPosition();
|
int mPosition = mHolder.getAdapterPosition();
|
||||||
String titleString;
|
String titleString;
|
||||||
if (repo.getId() != null) {
|
if (repo.getId() != null) {
|
||||||
@ -100,26 +117,37 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
mHolder.description.setText(repo.getDescription());
|
mHolder.description.setText(repo.getDescription());
|
||||||
String authorString = this.context.getResources().getString(R.string.author) + " " + repo.getmAuthor();
|
String authorString = this.context.getResources().getString(R.string.author) + " " + repo.getmAuthor();
|
||||||
mHolder.author.setText(authorString);
|
mHolder.author.setText(authorString);
|
||||||
|
String logUrl = repo.getmLogUrl();
|
||||||
|
String supportUrl = repo.getmSupportUrl();
|
||||||
|
String donateUrl = repo.getmDonateUrl();
|
||||||
|
if (supportUrl.equals("")) mHolder.supportLink.setBackgroundColor(Color.GRAY);
|
||||||
|
if (logUrl.equals("")) mHolder.changeLog.setBackgroundColor(Color.GRAY);
|
||||||
|
if (donateUrl.equals("")) mHolder.authorLink.setBackgroundColor(Color.GRAY);
|
||||||
|
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));
|
mHolder.installedStatus.setText(repo.isInstalled() ? this.context.getResources().getString(R.string.module_installed) : this.context.getResources().getString(R.string.module_not_installed));
|
||||||
if (mExpandedList.get(mPosition)) {
|
if (mExpandedList.get(mPosition)) {
|
||||||
mHolder.expandLayout.setVisibility(View.VISIBLE);
|
mHolder.expandLayout.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mHolder.expandLayout.setVisibility(View.GONE);
|
mHolder.expandLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repo.isInstalled()) {
|
if (repo.isInstalled()) {
|
||||||
mHolder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
mHolder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
||||||
mHolder.updateStatus.setText(repo.canUpdate() ? this.context.getResources().getString(R.string.module_update_available) : this.context.getResources().getString(R.string.module_up_to_date));
|
mHolder.updateStatus.setText(repo.canUpdate() ? this.context.getResources().getString(R.string.module_update_available) : this.context.getResources().getString(R.string.module_up_to_date));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("Magisk", "ReposAdapter: Setting up info " + repo.getId() + " and " + repo.getDescription() + " and " + repo.getmVersion());
|
Log.d("Magisk", "ReposAdapter: Setting up info " + repo.getId() + " and " + repo.getDescription() + " and " + repo.getmVersion());
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
mCanUpdate = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
mCanUpdate = prefs.getBoolean("repo-canUpdate_" + repo.getId(), false);
|
||||||
|
|
||||||
|
|
||||||
View.OnClickListener oCl = view -> {
|
View.OnClickListener oCl = view -> {
|
||||||
Log.d("Magisk", "Onlick captured, view is " + view.getId());
|
Log.d("Magisk", "Onlick captured, view is " + view.getId());
|
||||||
|
|
||||||
if (view.getId() == mHolder.updateImage.getId()) {
|
if (view.getId() == mHolder.updateImage.getId()) {
|
||||||
if (!mIsInstalled | mCanUpdate) {
|
if (!repo.isInstalled() | repo.canUpdate()) {
|
||||||
|
|
||||||
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@ -134,14 +162,14 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (view.getId() == mHolder.changeLog.getId()) {
|
if ((view.getId() == mHolder.changeLog.getId()) && (!repo.getmLogUrl().equals(""))) {
|
||||||
new WebWindow("Changelog", repo.getmLogText(), this.context);
|
new WebWindow("Changelog", repo.getmLogUrl(),context);
|
||||||
}
|
}
|
||||||
if (view.getId() == mHolder.authorLink.getId()) {
|
if ((view.getId() == mHolder.authorLink.getId()) && (!repo.getmSupportUrl().equals(""))) {
|
||||||
new WebWindow("Donate", repo.getmDonateUrl(), this.context);
|
new WebWindow("Donate", repo.getmDonateUrl(),context);
|
||||||
}
|
}
|
||||||
if (view.getId() == mHolder.supportLink.getId()) {
|
if ((view.getId() == mHolder.supportLink.getId()) && (!repo.getmSupportUrl().equals(""))) {
|
||||||
new WebWindow("Support", repo.getmSupportUrl(), this.context);
|
new WebWindow("Support", repo.getmSupportUrl(),context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mHolder.changeLog.setOnClickListener(oCl);
|
mHolder.changeLog.setOnClickListener(oCl);
|
||||||
@ -149,13 +177,15 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
mHolder.authorLink.setOnClickListener(oCl);
|
mHolder.authorLink.setOnClickListener(oCl);
|
||||||
mHolder.supportLink.setOnClickListener(oCl);
|
mHolder.supportLink.setOnClickListener(oCl);
|
||||||
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
|
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
|
||||||
mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
boolean mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mList.size();
|
return mList.size();
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -15,8 +19,11 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
import com.topjohnwu.magisk.module.RepoHelper;
|
import com.topjohnwu.magisk.module.RepoHelper;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -25,41 +32,83 @@ import butterknife.ButterKnife;
|
|||||||
public class ReposFragment extends Fragment {
|
public class ReposFragment extends Fragment {
|
||||||
|
|
||||||
public static List<Repo> mListRepos = new ArrayList<>();
|
public static List<Repo> mListRepos = new ArrayList<>();
|
||||||
|
public static List<Repo> mListReposToUpdate = new ArrayList<>();
|
||||||
@BindView(R.id.recyclerView)
|
@BindView(R.id.recyclerView)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
@BindView(R.id.empty_rv)
|
@BindView(R.id.empty_rv)
|
||||||
TextView emptyTv;
|
TextView emptyTv;
|
||||||
@BindView(R.id.swipeRefreshLayout)
|
@BindView(R.id.swipeRefreshLayout)
|
||||||
SwipeRefreshLayout swipeRefreshLayout;
|
SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
private View mView;
|
||||||
|
private boolean mCanUpdate;
|
||||||
|
private boolean alertUpdate;
|
||||||
|
private boolean ignoreAlertUpdate;
|
||||||
|
private String alertPackage;
|
||||||
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
@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 view = inflater.inflate(R.layout.single_repo_fragment, container, false);
|
View view = inflater.inflate(R.layout.single_repo_fragment, container, false);
|
||||||
|
mView = view;
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
if (prefs.contains("ignoreUpdateAlerts")) {
|
||||||
|
ignoreAlertUpdate = prefs.getBoolean("ignoreUpdateAlerts", false);
|
||||||
|
}
|
||||||
swipeRefreshLayout.setOnRefreshListener(() -> {
|
swipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
Log.d("Magisk","ReposFragment: WTF IM CALLED");
|
|
||||||
this.LoadRepo(true);
|
this.LoadRepo(true);
|
||||||
|
ignoreAlertUpdate = false;
|
||||||
|
prefs.edit().putBoolean("ignoreUpdateAlerts",false).apply();
|
||||||
|
|
||||||
});
|
});
|
||||||
LoadRepo(false);
|
LoadRepo(false);
|
||||||
setHasOptionsMenu(false);
|
setHasOptionsMenu(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();
|
||||||
Log.d("Magisk", "ReposFragment: ListRepos size is " + listRepos().size());
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
NotifyOfAlerts();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckForUpdates() {
|
||||||
|
for (int i = 0; i < mListRepos.size(); i++) {
|
||||||
|
if (mListRepos.get(i).canUpdate()) {
|
||||||
|
alertUpdate = true;
|
||||||
|
mListReposToUpdate.add(mListRepos.get(i));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachFragment(Fragment 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) {
|
||||||
|
mView.invalidate();
|
||||||
|
mView.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -75,6 +124,43 @@ public class ReposFragment extends Fragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NotifyOfAlerts() {
|
||||||
|
if (alertUpdate && !ignoreAlertUpdate) {
|
||||||
|
Iterator<Repo> iterRepo = mListReposToUpdate.iterator();
|
||||||
|
while (iterRepo.hasNext()) {
|
||||||
|
Repo repo = iterRepo.next();
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
||||||
|
@Override
|
||||||
|
public void task(File file) {
|
||||||
|
Log.d("Magisk", "Task firing");
|
||||||
|
new Utils.FlashZIP(getActivity(), repo.getId(), file.toString()).execute();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
String filename = repo.getId().replace(" ", "") + ".zip";
|
||||||
|
Utils.downloadAndReceive(getActivity(), receiver, repo.getmZipUrl(), filename);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
ignoreAlertUpdate = true;
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
editor.putBoolean("ignoreUpdateAlerts", ignoreAlertUpdate);
|
||||||
|
editor.apply();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder 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
|
||||||
@ -102,6 +188,8 @@ public class ReposFragment extends Fragment {
|
|||||||
recyclerView.setAdapter(new ReposAdapter(this, listRepos()));
|
recyclerView.setAdapter(new ReposAdapter(this, listRepos()));
|
||||||
if (swipeRefreshLayout.isRefreshing()) {
|
if (swipeRefreshLayout.isRefreshing()) {
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
CheckForUpdates();
|
||||||
|
NotifyOfAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class Module {
|
|||||||
private String mVersion = "(No version provided)";
|
private String mVersion = "(No version provided)";
|
||||||
private String mDescription = "(No description provided)";
|
private String mDescription = "(No description provided)";
|
||||||
private String mUrl,mSupportUrl,mDonateUrl,mZipUrl,mBaseUrl,mManifestUrl,mAuthor,mLogUrl;
|
private String mUrl,mSupportUrl,mDonateUrl,mZipUrl,mBaseUrl,mManifestUrl,mAuthor,mLogUrl;
|
||||||
private boolean mEnable, mRemove,mUpdateAvailable,mIsOnline,mIsCacheModule;
|
private boolean mEnable, mRemove,mUpdateAvailable, mIsInstalled,mIsCacheModule;
|
||||||
|
|
||||||
|
|
||||||
private String mId;
|
private String mId;
|
||||||
@ -81,12 +81,13 @@ public class Module {
|
|||||||
this.mLogUrl = props[1];
|
this.mLogUrl = props[1];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.d("Magisk", "Manifest string not recognized: " + props[0]);
|
Log.d("Magisk", "Module: Manifest string not recognized: " + props[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Log.d("Magisk","Module: Loaded module with ID of " + this.mId + " or " + mId);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
@ -97,7 +98,6 @@ public class Module {
|
|||||||
if (!preferenceKey.equals("nope")) {
|
if (!preferenceKey.equals("nope")) {
|
||||||
Log.d("Magisk", "Module: repo_" + mId + " found.");
|
Log.d("Magisk", "Module: repo_" + mId + " found.");
|
||||||
String entryString = prefs.getString("repo_" + mId, "");
|
String entryString = prefs.getString("repo_" + mId, "");
|
||||||
|
|
||||||
String[] subStrings = entryString.split("\n");
|
String[] subStrings = entryString.split("\n");
|
||||||
for (String subKeys : subStrings) {
|
for (String subKeys : subStrings) {
|
||||||
String[] idEntry = subKeys.split("=", 2);
|
String[] idEntry = subKeys.split("=", 2);
|
||||||
@ -107,9 +107,9 @@ public class Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idEntry[1].equals(mId)) {
|
if (idEntry[1].equals(mId)) {
|
||||||
Log.d("Magisk", "Module: Hey, I know I'm online...");
|
Log.d("Magisk", "Module: Hey, I know " + mId + " is online...");
|
||||||
mIsOnline = true;
|
mIsInstalled = true;
|
||||||
} else mIsOnline = false;
|
} else mIsInstalled = false;
|
||||||
}
|
}
|
||||||
if (idEntry[0].equals("logUrl")) {
|
if (idEntry[0].equals("logUrl")) {
|
||||||
mLogUrl = idEntry[1];
|
mLogUrl = idEntry[1];
|
||||||
@ -140,9 +140,8 @@ public class Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
if (mIsOnline) {
|
if (mIsInstalled) {
|
||||||
editor.putBoolean("repo-isInstalled_" + mId, true);
|
editor.putBoolean("repo-isInstalled_" + mId, true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
editor.putBoolean("repo-isInstalled_" + mId, false);
|
editor.putBoolean("repo-isInstalled_" + mId, false);
|
||||||
}
|
}
|
||||||
@ -195,7 +194,7 @@ public class Module {
|
|||||||
|
|
||||||
public String getId() {return mId; }
|
public String getId() {return mId; }
|
||||||
|
|
||||||
public String getChangeLog() {return mLogUrl; }
|
public String getmLogUrl() {return mLogUrl; }
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return mDescription;
|
return mDescription;
|
||||||
@ -229,6 +228,8 @@ public class Module {
|
|||||||
return mDonateUrl;
|
return mDonateUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getmZipUrl() { return mZipUrl; }
|
||||||
|
|
||||||
public String getmManifestUrl() {
|
public String getmManifestUrl() {
|
||||||
return mManifestUrl;
|
return mManifestUrl;
|
||||||
}
|
}
|
||||||
@ -237,7 +238,7 @@ public class Module {
|
|||||||
return mSupportUrl;
|
return mSupportUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnline() {return mIsOnline; }
|
public boolean isInstalled() {return mIsInstalled; }
|
||||||
|
|
||||||
public boolean isUpdateAvailable() { return mUpdateAvailable; }
|
public boolean isUpdateAvailable() { return mUpdateAvailable; }
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import java.util.Date;
|
|||||||
public class Repo {
|
public class Repo {
|
||||||
private String mBaseUrl;
|
private String mBaseUrl;
|
||||||
private String mZipUrl;
|
private String mZipUrl;
|
||||||
private String mLogText;
|
private String mLogUrl;
|
||||||
private String mManifestUrl;
|
private String mManifestUrl;
|
||||||
private String mVersion;
|
private String mVersion;
|
||||||
private String mName;
|
private String mName;
|
||||||
@ -72,14 +72,17 @@ public class Repo {
|
|||||||
for (int f = 0; f < repoArray.length(); f++) {
|
for (int f = 0; f < repoArray.length(); f++) {
|
||||||
JSONObject jsonobject = repoArray.getJSONObject(f);
|
JSONObject jsonobject = repoArray.getJSONObject(f);
|
||||||
String name = jsonobject.getString("name");
|
String name = jsonobject.getString("name");
|
||||||
|
String url = jsonobject.getString("download_url").trim();
|
||||||
|
Log.d("Magisk","Repo - checking object named " + name + " with value of " + url);
|
||||||
if (name.contains(".zip")) {
|
if (name.contains(".zip")) {
|
||||||
this.mZipUrl = jsonobject.getString("download_url");
|
this.mZipUrl = url;
|
||||||
} else if (name.equals("module.prop")) {
|
}
|
||||||
this.mManifestUrl = jsonobject.getString("download_url");
|
if (name.equals("module.prop")) {
|
||||||
} else if (name.equals("changelog.txt")) {
|
this.mManifestUrl = url;
|
||||||
String logUrl = jsonobject.getString("download_url");;
|
}
|
||||||
String logText = webreq.makeWebServiceCall(logUrl,WebRequest.GET);
|
if (name.contains("log.txt")) {
|
||||||
this.mLogText = logText;
|
Log.d("Magisk","Repo: Setting log URL for " + name + " of " + url);
|
||||||
|
this.mLogUrl = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -96,10 +99,9 @@ public class Repo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void PutProps(String manifestString) {
|
private void PutProps(String manifestString) {
|
||||||
manifestString = manifestString + "zipUrl=" + mZipUrl + "\nbaseUrl=" + mBaseUrl + "\nmanifestUrl=" + mManifestUrl;
|
manifestString = manifestString + "zipUrl=" + mZipUrl + "\nbaseUrl=" + mBaseUrl + "\nlogUrl=" + mLogUrl + "\nmanifestUrl=" + mManifestUrl;
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putString("log_" + mId, mLogText);
|
|
||||||
editor.putString("repo_" + mId, manifestString);
|
editor.putString("repo_" + mId, manifestString);
|
||||||
editor.putBoolean("hasCachedRepos", true);
|
editor.putBoolean("hasCachedRepos", true);
|
||||||
editor.putString("updated_" + mId, this.lastUpdate);
|
editor.putString("updated_" + mId, this.lastUpdate);
|
||||||
@ -142,6 +144,9 @@ public class Repo {
|
|||||||
case "support":
|
case "support":
|
||||||
this.mSupportUrl = props[1];
|
this.mSupportUrl = props[1];
|
||||||
break;
|
break;
|
||||||
|
case "logUrl":
|
||||||
|
this.mLogUrl = props[1];
|
||||||
|
break;
|
||||||
case "donateUrl":
|
case "donateUrl":
|
||||||
this.mDonateUrl = props[1];
|
this.mDonateUrl = props[1];
|
||||||
break;
|
break;
|
||||||
@ -171,9 +176,7 @@ public class Repo {
|
|||||||
if (prefs.contains("updated_" + this.mId)) {
|
if (prefs.contains("updated_" + this.mId)) {
|
||||||
lastUpdate = prefs.getString("updated_" + this.mId,"");
|
lastUpdate = prefs.getString("updated_" + this.mId,"");
|
||||||
}
|
}
|
||||||
if (prefs.contains("log_" + this.mId)) {
|
|
||||||
mLogText = prefs.getString("log_" + this.mId,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return this.mId != null;
|
return this.mId != null;
|
||||||
@ -239,8 +242,8 @@ public class Repo {
|
|||||||
return mBaseUrl;
|
return mBaseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getmLogText() {
|
public String getmLogUrl() {
|
||||||
return mLogText;
|
return mLogUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ public class RepoHelper {
|
|||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(String... values) {
|
protected void onProgressUpdate(String... values) {
|
||||||
super.onProgressUpdate(values);
|
super.onProgressUpdate(values);
|
||||||
|
prefs.edit().putBoolean("ignoreUpdateAlerts", false).apply();
|
||||||
Toast.makeText(activityContext, "Refreshing online modules", Toast.LENGTH_SHORT).show();
|
Toast.makeText(activityContext, "Refreshing online modules", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user