diff --git a/app/build.gradle b/app/build.gradle index 435fc68e8..72a8c8ad2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/magisk_update.xml b/app/magisk_update.xml new file mode 100644 index 000000000..1f5881a12 --- /dev/null +++ b/app/magisk_update.xml @@ -0,0 +1,11 @@ + + + 2.0 + + http://forum.xda-developers.com/android/software/mod-magisk-v1-universal-systemless-t3432382 + + + - Version 4.0! + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fec72de9..47fb5507e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,8 @@ xmlns:tools="http://schemas.android.com/tools"> + + listModules = new ArrayList<>(); -// protected static List 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 { + @Override + protected void onPreExecute() { + super.onPreExecute(); + + progressBar.setVisibility(View.VISIBLE); + } + @Override protected Void doInBackground(Void... voids) { // Ensure initialize is done diff --git a/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java b/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java index cf73a4a1f..c0fa9e0d9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java @@ -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 { - - 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(); - } - } } diff --git a/app/src/main/res/menu/menu_modules.xml b/app/src/main/res/menu/menu_modules.xml deleted file mode 100644 index e441c9bd5..000000000 --- a/app/src/main/res/menu/menu_modules.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4ec4cf5f1..5e76393d7 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ buildscript { allprojects { repositories { jcenter() + maven { url "https://jitpack.io" } } }