mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:57:39 +00:00
Merge conflict
This commit is contained in:
commit
3e97d29bcf
@ -9,6 +9,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
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 com.topjohnwu.magisk.module.Module;
|
import com.topjohnwu.magisk.module.Module;
|
||||||
import com.topjohnwu.magisk.rv.ItemClickListener;
|
import com.topjohnwu.magisk.rv.ItemClickListener;
|
||||||
@ -22,6 +23,7 @@ import butterknife.ButterKnife;
|
|||||||
public abstract class BaseModuleFragment extends Fragment {
|
public abstract class BaseModuleFragment extends Fragment {
|
||||||
|
|
||||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||||
|
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -29,6 +31,13 @@ public abstract class BaseModuleFragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.single_module_fragment, container, false);
|
View view = inflater.inflate(R.layout.single_module_fragment, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
|
||||||
|
if (listModules().size() == 0) {
|
||||||
|
emptyTv.setVisibility(View.VISIBLE);
|
||||||
|
recyclerView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
recyclerView.setAdapter(new ModulesAdapter(listModules(), new ItemClickListener() {
|
recyclerView.setAdapter(new ModulesAdapter(listModules(), new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view, int position) {
|
public void onItemClick(View view, int position) {
|
||||||
|
@ -188,4 +188,8 @@ public class MagiskFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onRootGranted() {
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ 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.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
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;
|
||||||
@ -51,14 +54,32 @@ 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);
|
||||||
|
|
||||||
viewPager.setAdapter(new TabsAdapter(getChildFragmentManager()));
|
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
|
||||||
|
|
||||||
new CheckFolders().execute();
|
new CheckFolders().execute();
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
return view;
|
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 {
|
public static class NormalModuleFragment extends BaseModuleFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,6 +117,9 @@ public class ModulesFragment extends Fragment {
|
|||||||
super.onPostExecute(v);
|
super.onPostExecute(v);
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
viewPager.setAdapter(new TabsAdapter(getChildFragmentManager()));
|
||||||
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -45,8 +46,9 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_welcome);
|
setContentView(R.layout.activity_welcome);
|
||||||
view = findViewById(R.id.toolbar);
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
view = toolbar;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
}
|
}
|
||||||
@ -123,17 +125,21 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
private void navigate(final int itemId) {
|
private void navigate(final int itemId) {
|
||||||
Fragment navFragment = null;
|
Fragment navFragment = null;
|
||||||
|
String tag = "";
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case R.id.magisk:
|
case R.id.magisk:
|
||||||
setTitle(R.string.magisk);
|
setTitle(R.string.magisk);
|
||||||
|
tag = "magisk";
|
||||||
navFragment = new MagiskFragment();
|
navFragment = new MagiskFragment();
|
||||||
break;
|
break;
|
||||||
case R.id.modules:
|
case R.id.modules:
|
||||||
setTitle(R.string.modules);
|
setTitle(R.string.modules);
|
||||||
|
tag = "modules";
|
||||||
navFragment = new ModulesFragment();
|
navFragment = new ModulesFragment();
|
||||||
break;
|
break;
|
||||||
case R.id.log:
|
case R.id.log:
|
||||||
setTitle(R.string.log);
|
setTitle(R.string.log);
|
||||||
|
tag = "log";
|
||||||
navFragment = new LogFragment();
|
navFragment = new LogFragment();
|
||||||
break;
|
break;
|
||||||
case R.id.app_about:
|
case R.id.app_about:
|
||||||
@ -147,7 +153,7 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
try {
|
try {
|
||||||
toolbar.setElevation(navFragment instanceof ModulesFragment ? 0 : 10);
|
toolbar.setElevation(navFragment instanceof ModulesFragment ? 0 : 10);
|
||||||
|
|
||||||
transaction.replace(R.id.content_frame, navFragment).commit();
|
transaction.replace(R.id.content_frame, navFragment, tag).commit();
|
||||||
} catch (IllegalStateException ignored) {
|
} catch (IllegalStateException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,6 +161,20 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
public static class Init extends AsyncTask<Void, Integer, Void> {
|
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
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
return null;
|
return null;
|
||||||
@ -164,9 +184,15 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
super.onPostExecute(v);
|
super.onPostExecute(v);
|
||||||
|
|
||||||
|
progress.dismiss();
|
||||||
|
|
||||||
if (!Shell.rootAccess()) {
|
if (!Shell.rootAccess()) {
|
||||||
Snackbar.make(view, R.string.no_root_access, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(view, R.string.no_root_access, Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MagiskFragment fragment = (MagiskFragment) activity.getSupportFragmentManager().findFragmentByTag("magisk");
|
||||||
|
fragment.onRootGranted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,16 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_rv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/no_modules_found"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
11
app/src/main/res/menu/menu_modules.xml
Normal file
11
app/src/main/res/menu/menu_modules.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?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>
|
@ -46,5 +46,8 @@
|
|||||||
<string name="app_source_code">Source code</string>
|
<string name="app_source_code">Source code</string>
|
||||||
<string name="app_translators">App\'s translators</string>
|
<string name="app_translators">App\'s translators</string>
|
||||||
<string name="support_thread">Support thread</string>
|
<string name="support_thread">Support thread</string>
|
||||||
|
<string name="force_reload">Refresh</string>
|
||||||
|
<string name="no_modules_found">No modules found</string>
|
||||||
|
<string name="loading">Loading…</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user