More cleanup, add native filepicker
Code cleanup, add filepicker lib to avoid issues with stock file apps.
This commit is contained in:
parent
c2a188f7fe
commit
041531e96d
@ -14,6 +14,7 @@ android {
|
|||||||
enabled true
|
enabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
@ -24,13 +25,18 @@ android {
|
|||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url "http://dl.bintray.com/lukaville/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
compile 'com.android.support:recyclerview-v7:24.2.0'
|
compile 'com.android.support:recyclerview-v7:24.2.0'
|
||||||
compile 'com.android.support:cardview-v7:24.2.0'
|
compile 'com.android.support:cardview-v7:24.2.0'
|
||||||
compile 'com.android.support:design:24.2.0'
|
compile 'com.android.support:design:24.2.0'
|
||||||
|
compile 'com.nbsp:library:1.1'
|
||||||
compile 'com.jakewharton:butterknife:8.4.0'
|
compile 'com.jakewharton:butterknife:8.4.0'
|
||||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
|
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.magisk.utils.WebWindow;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -76,6 +77,9 @@ public abstract class BaseRepoFragment extends Fragment {
|
|||||||
private View viewMain;
|
private View viewMain;
|
||||||
private Context context;
|
private Context context;
|
||||||
private boolean mIsInstalled, mCanUpdate;
|
private boolean mIsInstalled, mCanUpdate;
|
||||||
|
private Repo repo;
|
||||||
|
private ViewHolder mHolder;
|
||||||
|
private int mPosition;
|
||||||
|
|
||||||
public ReposAdapter(List<Repo> list) {
|
public ReposAdapter(List<Repo> list) {
|
||||||
this.mList = list;
|
this.mList = list;
|
||||||
@ -96,42 +100,47 @@ public abstract class BaseRepoFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||||
final Repo repo = mList.get(position);
|
repo = mList.get(position);
|
||||||
|
mHolder = holder;
|
||||||
|
SetupViewElements();
|
||||||
|
|
||||||
Log.d("Magisk", "ReposAdapter: Trying set up bindview from list pos " + position + " out of a total of " + mList.size() + " and " + repo.getId());
|
}
|
||||||
|
|
||||||
|
private void SetupViewElements() {
|
||||||
|
mPosition = mHolder.getAdapterPosition();
|
||||||
if (repo.getId() != null) {
|
if (repo.getId() != null) {
|
||||||
TextView authorView = holder.author;
|
TextView authorView = mHolder.author;
|
||||||
holder.title.setText(repo.getName());
|
mHolder.title.setText(repo.getName());
|
||||||
holder.versionName.setText(repo.getmVersion());
|
mHolder.versionName.setText(repo.getmVersion());
|
||||||
holder.description.setText(repo.getDescription());
|
mHolder.description.setText(repo.getDescription());
|
||||||
String authorString = getResources().getString(R.string.author) + " " + repo.getmAuthor();
|
String authorString = getResources().getString(R.string.author) + " " + repo.getmAuthor();
|
||||||
holder.author.setText(authorString);
|
mHolder.author.setText(authorString);
|
||||||
if ((repo.getmLogUrl() != null) && (repo.getmLogUrl().equals(""))) {
|
if ((repo.getmLogUrl() != null) && (repo.getmLogUrl().equals(""))) {
|
||||||
holder.log.setText(repo.getmLogUrl());
|
mHolder.log.setText(repo.getmLogUrl());
|
||||||
Linkify.addLinks(holder.log, Linkify.WEB_URLS);
|
Linkify.addLinks(mHolder.log, Linkify.WEB_URLS);
|
||||||
} else {
|
} else {
|
||||||
holder.log.setVisibility(View.GONE);
|
mHolder.log.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
holder.installedStatus.setText(repo.isInstalled() ? getResources().getString(R.string.module_installed) : getResources().getString(R.string.module_not_installed));
|
mHolder.installedStatus.setText(repo.isInstalled() ? getResources().getString(R.string.module_installed) : getResources().getString(R.string.module_not_installed));
|
||||||
if (mExpandedList.get(position)) {
|
if (mExpandedList.get(mPosition)) {
|
||||||
holder.expandLayout.setVisibility(View.VISIBLE);
|
mHolder.expandLayout.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.expandLayout.setVisibility(View.GONE);
|
mHolder.expandLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if (repo.isInstalled()) {
|
if (repo.isInstalled()) {
|
||||||
holder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
mHolder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
||||||
holder.updateStatus.setText(repo.canUpdate() ? getResources().getString(R.string.module_update_available) : getResources().getString(R.string.module_up_to_date));
|
mHolder.updateStatus.setText(repo.canUpdate() ? getResources().getString(R.string.module_update_available) : 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);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
updateImage.setImageResource(R.drawable.ic_system_update_alt_black);
|
updateImage.setImageResource(R.drawable.ic_system_update_alt_black);
|
||||||
mCanUpdate = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
mCanUpdate = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
||||||
updateImage.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
View.OnClickListener oCl = view -> {
|
||||||
public void onClick(View view) {
|
if (view == updateImage) {
|
||||||
if (!mIsInstalled | mCanUpdate) {
|
if (!mIsInstalled | mCanUpdate) {
|
||||||
|
|
||||||
Utils.DownloadReceiver reciever = new Utils.DownloadReceiver() {
|
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(File file) {
|
public void task(File file) {
|
||||||
Log.d("Magisk", "Task firing");
|
Log.d("Magisk", "Task firing");
|
||||||
@ -139,12 +148,17 @@ public abstract class BaseRepoFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
String filename = repo.getId().replace(" ", "") + ".zip";
|
String filename = repo.getId().replace(" ", "") + ".zip";
|
||||||
Utils.downloadAndReceive(context, reciever, repo.getmZipUrl(), filename);
|
Utils.downloadAndReceive(context, receiver, repo.getmZipUrl(), filename);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
} else if (view == mHolder.log) {
|
||||||
|
new WebWindow("Changelog",repo.getmLogUrl(),getActivity());
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
updateImage.setOnClickListener(oCl);
|
||||||
|
mHolder.log.setOnClickListener(oCl);
|
||||||
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
|
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
|
||||||
mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
||||||
// if (mIsInstalled) {
|
// if (mIsInstalled) {
|
||||||
@ -155,11 +169,8 @@ public abstract class BaseRepoFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mList.size();
|
return mList.size();
|
||||||
|
@ -25,17 +25,13 @@ import android.widget.ScrollView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
@ -14,7 +14,6 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -23,14 +22,17 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.nbsp.materialfilepicker.MaterialFilePicker;
|
||||||
|
import com.nbsp.materialfilepicker.ui.FilePickerActivity;
|
||||||
import com.topjohnwu.magisk.module.Module;
|
import com.topjohnwu.magisk.module.Module;
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -42,11 +44,16 @@ public class ModulesFragment extends Fragment {
|
|||||||
public static List<Repo> listModulesDownload = new ArrayList<>();
|
public static List<Repo> listModulesDownload = new ArrayList<>();
|
||||||
private static final int FILE_SELECT_CODE = 0;
|
private static final int FILE_SELECT_CODE = 0;
|
||||||
private int viewPagePosition;
|
private int viewPagePosition;
|
||||||
|
private static final int RESULT_OK = 1;
|
||||||
|
|
||||||
@BindView(R.id.progressBar) ProgressBar progressBar;
|
@BindView(R.id.progressBar)
|
||||||
@BindView(R.id.fab) FloatingActionButton fabio;
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.pager) ViewPager viewPager;
|
@BindView(R.id.fab)
|
||||||
@BindView(R.id.tab_layout) TabLayout tabLayout;
|
FloatingActionButton fabio;
|
||||||
|
@BindView(R.id.pager)
|
||||||
|
ViewPager viewPager;
|
||||||
|
@BindView(R.id.tab_layout)
|
||||||
|
TabLayout tabLayout;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -54,46 +61,56 @@ public class ModulesFragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.modules_fragment, container, false);
|
View view = inflater.inflate(R.layout.modules_fragment, container, false);
|
||||||
|
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
new Utils.LoadModules(getActivity(),false).execute();
|
new Utils.LoadModules(getActivity(), false).execute();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
inflater.inflate(R.menu.menu_module, menu);
|
inflater.inflate(R.menu.menu_module, menu);
|
||||||
fabio.setOnClickListener(new View.OnClickListener() {
|
fabio.setOnClickListener(view -> {
|
||||||
@Override
|
openFilePicker();
|
||||||
public void onClick(View view) {
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setType("*/zip");
|
|
||||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
|
||||||
startActivityForResult(intent,FILE_SELECT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
private void openFilePicker() {
|
||||||
switch (requestCode) {
|
new MaterialFilePicker()
|
||||||
case FILE_SELECT_CODE:
|
.withSupportFragment(this)
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
.withFilter(Pattern.compile(".*\\.zip$"))
|
||||||
// Get the Uri of the selected file
|
.withRequestCode(FILE_SELECT_CODE)
|
||||||
Uri uri = data.getData();
|
.withHiddenFiles(true)
|
||||||
String path = uri.getPath();
|
.start();
|
||||||
String fileName = uri.getLastPathSegment();
|
}
|
||||||
new Utils.FlashZIP(getActivity(), fileName, path).execute();
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
Log.d("Magisk","WelcomeActivity: Got an OK result" + resultCode);
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
String path = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
|
||||||
|
Log.d("Magisk","ModuleFragment: Got an OK result " + path);
|
||||||
|
if (path != null) {
|
||||||
|
Log.d("Path: ", path);
|
||||||
|
Toast.makeText(getActivity(), "Picked file: " + path, Toast.LENGTH_LONG).show();
|
||||||
|
// Get the Uri of the selected file
|
||||||
|
String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
|
||||||
|
|
||||||
|
Uri uri = Uri.parse(filePath);
|
||||||
|
|
||||||
|
path = uri.getPath();
|
||||||
|
Log.d("Magisk","ModuleFragment: Got an OK result " + filePath + " and " + uri.toString() + " and " + path);
|
||||||
|
|
||||||
|
String fileName = uri.getLastPathSegment();
|
||||||
|
new Utils.FlashZIP(getActivity(), fileName, path).execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
@ -107,7 +124,7 @@ public class ModulesFragment extends Fragment {
|
|||||||
viewPager.setAdapter(new TabsAdapter(getChildFragmentManager()));
|
viewPager.setAdapter(new TabsAdapter(getChildFragmentManager()));
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
viewPager.setCurrentItem(viewPagePosition);
|
viewPager.setCurrentItem(viewPagePosition);
|
||||||
new Utils.LoadModules(getActivity(),true).execute();
|
new Utils.LoadModules(getActivity(), true).execute();
|
||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -115,8 +132,8 @@ public class ModulesFragment extends Fragment {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectPage(int pageIndex){
|
void selectPage(int pageIndex) {
|
||||||
tabLayout.setScrollPosition(pageIndex,0f,true);
|
tabLayout.setScrollPosition(pageIndex, 0f, true);
|
||||||
viewPager.setCurrentItem(pageIndex);
|
viewPager.setCurrentItem(pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +154,7 @@ public class ModulesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DownloadModuleFragment extends BaseRepoFragment {
|
public static class DownloadModuleFragment extends BaseRepoFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -146,7 +164,6 @@ public class ModulesFragment extends Fragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class updateUI extends AsyncTask<Void, Void, Void> {
|
private class updateUI extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -169,7 +186,7 @@ public class ModulesFragment extends Fragment {
|
|||||||
private class TabsAdapter extends FragmentPagerAdapter {
|
private class TabsAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
String[] tabTitles = new String[]{
|
String[] tabTitles = new String[]{
|
||||||
getString(R.string.modules), getString(R.string.cache_modules) ,"Download"
|
getString(R.string.modules), getString(R.string.cache_modules), "Download"
|
||||||
};
|
};
|
||||||
|
|
||||||
public TabsAdapter(FragmentManager fm) {
|
public TabsAdapter(FragmentManager fm) {
|
||||||
@ -192,7 +209,7 @@ public class ModulesFragment extends Fragment {
|
|||||||
return new NormalModuleFragment();
|
return new NormalModuleFragment();
|
||||||
} else if (position == 1) {
|
} else if (position == 1) {
|
||||||
return new CacheModuleFragment();
|
return new CacheModuleFragment();
|
||||||
} else {
|
} else {
|
||||||
return new DownloadModuleFragment();
|
return new DownloadModuleFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -7,8 +7,6 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Module {
|
public class Module {
|
||||||
|
|
||||||
private String mRemoveFile;
|
private String mRemoveFile;
|
||||||
@ -203,6 +201,6 @@ public class Module {
|
|||||||
|
|
||||||
public boolean isOnline() {return mIsOnline; }
|
public boolean isOnline() {return mIsOnline; }
|
||||||
|
|
||||||
public boolean isUpdateAvailable() { return mUpdateAvailable; };
|
public boolean isUpdateAvailable() { return mUpdateAvailable; }
|
||||||
|
|
||||||
}
|
}
|
@ -102,7 +102,7 @@ public class Repo {
|
|||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putString("repo_" + mId, manifestString);
|
editor.putString("repo_" + mId, manifestString);
|
||||||
editor.putBoolean("hasCachedRepos", true);
|
editor.putBoolean("hasCachedRepos", true);
|
||||||
editor.putString("updated_" + mId, this.lastUpdate.toString());
|
editor.putString("updated_" + mId, this.lastUpdate);
|
||||||
Log.d("Magisk", "Storing Preferences: " + manifestString);
|
Log.d("Magisk", "Storing Preferences: " + manifestString);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -8,14 +8,11 @@ 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.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
@ -30,7 +27,6 @@ import com.topjohnwu.magisk.module.Module;
|
|||||||
import com.topjohnwu.magisk.module.RepoHelper;
|
import com.topjohnwu.magisk.module.RepoHelper;
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
33
app/src/main/java/com/topjohnwu/magisk/utils/WebWindow.java
Normal file
33
app/src/main/java/com/topjohnwu/magisk/utils/WebWindow.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
|
||||||
|
public class WebWindow {
|
||||||
|
|
||||||
|
public WebWindow(String title, String url, Context context) {
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(context);
|
||||||
|
alert.setTitle(title);
|
||||||
|
|
||||||
|
WebView wv = new WebView(context);
|
||||||
|
wv.loadUrl(url);
|
||||||
|
wv.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||||
|
view.loadUrl(url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alert.setView(wv);
|
||||||
|
alert.setNegativeButton("Close", (dialog, id) -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user