Cleanup; added update checker
This commit is contained in:
parent
3e97d29bcf
commit
c97197b61a
@ -25,6 +25,7 @@ dependencies {
|
||||
compile 'com.android.support:recyclerview-v7:24.2.0'
|
||||
compile 'com.android.support:cardview-v7:24.2.0'
|
||||
compile 'com.android.support:design:24.2.0'
|
||||
compile 'com.github.javiersantos:AppUpdater:2.3'
|
||||
|
||||
compile 'com.jakewharton:butterknife:8.2.1'
|
||||
apt 'com.jakewharton:butterknife-compiler:8.2.1'
|
||||
|
11
app/magisk_update.xml
Normal file
11
app/magisk_update.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<AppUpdater>
|
||||
<update>
|
||||
<latestVersion>2.0</latestVersion>
|
||||
<url>
|
||||
http://forum.xda-developers.com/android/software/mod-magisk-v1-universal-systemless-t3432382
|
||||
</url>
|
||||
<releaseNotes>
|
||||
- Version 4.0!
|
||||
</releaseNotes>
|
||||
</update>
|
||||
</AppUpdater>
|
@ -4,6 +4,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -9,9 +9,6 @@ import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
@ -19,9 +16,6 @@ import android.widget.ProgressBar;
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@ -30,24 +24,10 @@ import butterknife.ButterKnife;
|
||||
|
||||
public class ModulesFragment extends Fragment {
|
||||
|
||||
private static final String MAGISK_PATH = "/magisk";
|
||||
private static final String MAGISK_CACHE_PATH = "/cache/magisk";
|
||||
|
||||
// protected static List<Module> listModules = new ArrayList<>();
|
||||
// protected static List<Module> listModulesCache = new ArrayList<>();
|
||||
|
||||
@BindView(R.id.progressBar) ProgressBar progressBar;
|
||||
@BindView(R.id.pager) ViewPager viewPager;
|
||||
@BindView(R.id.tab_layout) TabLayout tabLayout;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// listModules.clear();
|
||||
// listModulesCache.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@ -60,26 +40,6 @@ public class ModulesFragment extends Fragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.menu_modules, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.force_reload:
|
||||
listModules.clear();
|
||||
listModulesCache.clear();
|
||||
|
||||
new CheckFolders().execute();
|
||||
break;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public static class NormalModuleFragment extends BaseModuleFragment {
|
||||
|
||||
@Override
|
||||
@ -100,6 +60,13 @@ public class ModulesFragment extends Fragment {
|
||||
|
||||
private class CheckFolders extends AsyncTask<Void, Integer, Void> {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
// Ensure initialize is done
|
||||
|
@ -1,15 +1,12 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
@ -17,24 +14,22 @@ import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.github.javiersantos.appupdater.AppUpdater;
|
||||
import com.github.javiersantos.appupdater.enums.UpdateFrom;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class WelcomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||
public static View view;
|
||||
private static final String XML_UPDATE_CHECK = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/master/app/magisk_update.xml";
|
||||
private final Handler mDrawerHandler = new Handler();
|
||||
|
||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||
@BindView(R.id.drawer_layout) DrawerLayout drawer;
|
||||
@BindView(R.id.nav_view) NavigationView navigationView;
|
||||
@ -47,7 +42,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_welcome);
|
||||
ButterKnife.bind(this);
|
||||
view = toolbar;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
@ -90,6 +84,8 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
}
|
||||
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
new AppUpdater(this).setUpdateFrom(UpdateFrom.XML).setUpdateXML(XML_UPDATE_CHECK).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,40 +155,4 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
||||
}
|
||||
}
|
||||
|
||||
public static class Init extends AsyncTask<Void, Integer, Void> {
|
||||
|
||||
private final AppCompatActivity activity;
|
||||
private ProgressDialog progress;
|
||||
|
||||
public Init(AppCompatActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
||||
progress = ProgressDialog.show(activity, null, activity.getString(R.string.loading), true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
super.onPostExecute(v);
|
||||
|
||||
progress.dismiss();
|
||||
|
||||
if (!Shell.rootAccess()) {
|
||||
Snackbar.make(view, R.string.no_root_access, Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
MagiskFragment fragment = (MagiskFragment) activity.getSupportFragmentManager().findFragmentByTag("magisk");
|
||||
fragment.onRootGranted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/force_reload"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
android:title="@string/force_reload"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
</menu>
|
@ -17,6 +17,7 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user