diff --git a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java index 9a761ed9c..542f7b3f2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java @@ -8,6 +8,9 @@ import android.support.annotation.Nullable; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.RecyclerView; 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.TextView; @@ -17,6 +20,7 @@ import com.topjohnwu.magisk.asyncs.LoadModules; import com.topjohnwu.magisk.components.Fragment; import com.topjohnwu.magisk.container.Module; import com.topjohnwu.magisk.utils.Const; +import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Topic; 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) { View view = inflater.inflate(R.layout.fragment_modules, container, false); unbinder = ButterKnife.bind(this, view); + setHasOptionsMenu(true); mSwipeRefreshLayout.setOnRefreshListener(() -> { recyclerView.setVisibility(View.GONE); @@ -99,6 +104,31 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber { 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() { listModules.clear(); listModules.addAll(getApplication().moduleMap.values()); diff --git a/app/src/main/res/menu/menu_reboot.xml b/app/src/main/res/menu/menu_reboot.xml new file mode 100644 index 000000000..5bf662aba --- /dev/null +++ b/app/src/main/res/menu/menu_reboot.xml @@ -0,0 +1,25 @@ + +
\ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index a9ca0299f..abfe8d896 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -207,5 +207,8 @@