diff --git a/app/src/main/java/com/topjohnwu/magisk/model/Module.java b/app/src/main/java/com/topjohnwu/magisk/model/Module.java index 0d2c89d2c..c358abbc4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/Module.java +++ b/app/src/main/java/com/topjohnwu/magisk/model/Module.java @@ -45,12 +45,28 @@ public class Module { return mDescription; } - public void createRemoveFile() { - Utils.executeCommand("echo \"\" > " + mRemoveFile.getPath()); + public void createDisableFile() { + Utils.executeCommand("touch " + mDisableFile.getPath()); } - public void createDisableFile() { - Utils.executeCommand("echo \"\" > " + mDisableFile.getPath()); + public boolean removeDisableFile() { + return mDisableFile.delete(); + } + + public boolean isEnabled() { + return mDisableFile.exists(); + } + + public void createRemoveFile() { + Utils.executeCommand("touch " + mRemoveFile.getPath()); + } + + public boolean deleteRemoveFile() { + return mRemoveFile.delete(); + } + + public boolean willBeRemoved() { + return mRemoveFile.exists(); } public void parse() throws Exception { diff --git a/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java b/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java index 7245c5c54..78da35655 100644 --- a/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java @@ -4,6 +4,8 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.TextView; @@ -18,11 +20,13 @@ import butterknife.ButterKnife; public class ModulesAdapter extends RecyclerView.Adapter { private final List mList; - private final ItemClickListener mListener; + private final ItemClickListener chboxListener; + private final ItemClickListener deleteBtnListener; - public ModulesAdapter(List list, ItemClickListener listener) { + public ModulesAdapter(List list, ItemClickListener chboxListener, ItemClickListener deleteBtnListener) { this.mList = list; - this.mListener = listener; + this.chboxListener = chboxListener; + this.deleteBtnListener = deleteBtnListener; } @Override @@ -34,18 +38,38 @@ public class ModulesAdapter extends RecyclerView.Adapter classPopupHelper = Class.forName(menuPopupHelper.getClass().getName()); - Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); - setForceIcons.invoke(menuPopupHelper, true); - break; - } - } - } catch (Exception ignored) { - } - - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.remove: - listModules().get(position).createRemoveFile(); - Snackbar.make(view, R.string.remove_file_created, Snackbar.LENGTH_SHORT).show(); - break; - case R.id.disable: - listModules().get(position).createDisableFile(); - Snackbar.make(view, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show(); - break; - } - - return false; - } - }); - popup.inflate(R.menu.module_popup); - popup.show(); - } - }; - @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.single_module_fragment, container, false); ButterKnife.bind(this, view); - recyclerView.setAdapter(new ModulesAdapter(listModules(), moduleActions)); + recyclerView.setAdapter(new ModulesAdapter(listModules(), new ItemClickListener() { + @Override + public void onItemClick(View view, int position) { + CheckBox chbox = (CheckBox) view; + + if (!chbox.isChecked()) { + listModules().get(position).createDisableFile(); + Snackbar.make(view, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show(); + } else { + listModules().get(position).removeDisableFile(); + Snackbar.make(view, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show(); + } + } + }, new ItemClickListener() { + @Override + public void onItemClick(View view, int position) { + listModules().get(position).createRemoveFile(); + Snackbar.make(view, R.string.remove_file_created, Snackbar.LENGTH_SHORT).show(); + } + })); return view; } diff --git a/app/src/main/res/drawable/ic_block.xml b/app/src/main/res/drawable/ic_block.xml deleted file mode 100644 index ea9660ac2..000000000 --- a/app/src/main/res/drawable/ic_block.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/list_item_module.xml b/app/src/main/res/layout/list_item_module.xml index 284bf2044..cc8e8f6b9 100644 --- a/app/src/main/res/layout/list_item_module.xml +++ b/app/src/main/res/layout/list_item_module.xml @@ -64,10 +64,20 @@ android:textAppearance="?android:attr/textAppearanceSmall" android:textIsSelectable="false"/> + + - + + \ No newline at end of file diff --git a/app/src/main/res/menu/module_popup.xml b/app/src/main/res/menu/module_popup.xml deleted file mode 100644 index 2cf1d7804..000000000 --- a/app/src/main/res/menu/module_popup.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 63eda8419..6656f4156 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -9,5 +9,6 @@ #757575 #FFFFFF #BDBDBD + #F44336 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4c066fc5a..43951331e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,5 +40,6 @@ Log is empty Could not write log to SD card: This feature will not work without permission to write external storage. + Module will be enabled at next reboot diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/RootAccessDeniedException.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/RootAccessDeniedException.java deleted file mode 100644 index 35f353d1b..000000000 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/RootAccessDeniedException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2012 Dominik Schürmann - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sufficientlysecure.rootcommands.util; - -import java.io.IOException; - -public class RootAccessDeniedException extends IOException { - private static final long serialVersionUID = 9088998884166225540L; - - public RootAccessDeniedException() { - super(); - } - - public RootAccessDeniedException(String detailMessage) { - super(detailMessage); - } - -} diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/UnsupportedArchitectureException.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/UnsupportedArchitectureException.java deleted file mode 100644 index 96ad0309e..000000000 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/UnsupportedArchitectureException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2012 Dominik Schürmann - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sufficientlysecure.rootcommands.util; - -public class UnsupportedArchitectureException extends Exception { - private static final long serialVersionUID = 7826528799780001655L; - - public UnsupportedArchitectureException() { - super(); - } - - public UnsupportedArchitectureException(String detailMessage) { - super(detailMessage); - } - -}