Add reboot menu
This commit is contained in:
parent
bb80ab4026
commit
b2873dd44b
@ -8,6 +8,9 @@ import android.support.annotation.Nullable;
|
|||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
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.TextView;
|
import android.widget.TextView;
|
||||||
@ -17,6 +20,7 @@ import com.topjohnwu.magisk.asyncs.LoadModules;
|
|||||||
import com.topjohnwu.magisk.components.Fragment;
|
import com.topjohnwu.magisk.components.Fragment;
|
||||||
import com.topjohnwu.magisk.container.Module;
|
import com.topjohnwu.magisk.container.Module;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
@ -50,6 +54,7 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
|
|||||||
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.fragment_modules, container, false);
|
View view = inflater.inflate(R.layout.fragment_modules, container, false);
|
||||||
unbinder = ButterKnife.bind(this, view);
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
recyclerView.setVisibility(View.GONE);
|
recyclerView.setVisibility(View.GONE);
|
||||||
@ -99,6 +104,31 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
|
|||||||
unbinder.unbind();
|
unbinder.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.menu_reboot, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.reboot:
|
||||||
|
Shell.su_raw("/system/bin/reboot");
|
||||||
|
return true;
|
||||||
|
case R.id.reboot_recovery:
|
||||||
|
Shell.su_raw("/system/bin/reboot recovery");
|
||||||
|
return true;
|
||||||
|
case R.id.reboot_bootloader:
|
||||||
|
Shell.su_raw("/system/bin/reboot bootloader");
|
||||||
|
return true;
|
||||||
|
case R.id.reboot_download:
|
||||||
|
Shell.su_raw("/system/bin/reboot download");
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
listModules.clear();
|
listModules.clear();
|
||||||
listModules.addAll(getApplication().moduleMap.values());
|
listModules.addAll(getApplication().moduleMap.values());
|
||||||
|
25
app/src/main/res/menu/menu_reboot.xml
Normal file
25
app/src/main/res/menu/menu_reboot.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?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/reboot"
|
||||||
|
android:title="@string/reboot"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/reboot_recovery"
|
||||||
|
android:title="@string/reboot_recovery"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/reboot_bootloader"
|
||||||
|
android:title="@string/reboot_bootloader"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/reboot_download"
|
||||||
|
android:title="@string/reboot_download"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
</menu>
|
@ -207,5 +207,8 @@
|
|||||||
<string name="settings_update_custom">自訂</string>
|
<string name="settings_update_custom">自訂</string>
|
||||||
<string name="settings_update_custom_msg">請輸入自訂網址</string>
|
<string name="settings_update_custom_msg">請輸入自訂網址</string>
|
||||||
<string name="su_db_corrupt">SU 資料庫已毀損,將會重新建置</string>
|
<string name="su_db_corrupt">SU 資料庫已毀損,將會重新建置</string>
|
||||||
|
<string name="reboot_recovery">重啟到 Recovery</string>
|
||||||
|
<string name="reboot_bootloader">重啟到 Bootloader</string>
|
||||||
|
<string name="reboot_download">重啟到 Download</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<string name="disable_file_created">Module will be disabled at next reboot</string>
|
<string name="disable_file_created">Module will be disabled at next reboot</string>
|
||||||
<string name="disable_file_removed">Module will be enabled at next reboot</string>
|
<string name="disable_file_removed">Module will be enabled at next reboot</string>
|
||||||
<string name="author">Created by %1$s</string>
|
<string name="author">Created by %1$s</string>
|
||||||
|
<string name="reboot_recovery">Reboot to Recovery</string>
|
||||||
|
<string name="reboot_bootloader">Reboot to Bootloader</string>
|
||||||
|
<string name="reboot_download">Reboot to Download</string>
|
||||||
|
|
||||||
<!--Repo Fragment-->
|
<!--Repo Fragment-->
|
||||||
<string name="update_available">Update Available</string>
|
<string name="update_available">Update Available</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user