mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Add su revoke
This commit is contained in:
parent
67c9e2ead6
commit
15ca18848e
@ -61,8 +61,8 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
int title = isChecked ? R.string.disable_file_removed : R.string.disable_file_created;
|
int snack = isChecked ? R.string.disable_file_removed : R.string.disable_file_created;
|
||||||
Snackbar.make(holder.title, title, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(holder.itemView, snack, Snackbar.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}.exec());
|
}.exec());
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
int title = removed ? R.string.remove_file_deleted : R.string.remove_file_created;
|
int snack = removed ? R.string.remove_file_deleted : R.string.remove_file_created;
|
||||||
Snackbar.make(holder.title, title, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(holder.itemView, snack, Snackbar.LENGTH_SHORT).show();
|
||||||
updateDeleteButton(holder, module);
|
updateDeleteButton(holder, module);
|
||||||
}
|
}
|
||||||
}.exec());
|
}.exec());
|
||||||
|
@ -3,6 +3,7 @@ package com.topjohnwu.magisk.adapters;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -16,6 +17,7 @@ import android.widget.TextView;
|
|||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.superuser.Policy;
|
import com.topjohnwu.magisk.superuser.Policy;
|
||||||
import com.topjohnwu.magisk.superuser.SuDatabaseHelper;
|
import com.topjohnwu.magisk.superuser.SuDatabaseHelper;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,9 +46,8 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
|
Policy policy = policyList.get(position);
|
||||||
try {
|
try {
|
||||||
Policy policy = policyList.get(position);
|
|
||||||
|
|
||||||
holder.setExpanded(expandList.contains(policy));
|
holder.setExpanded(expandList.contains(policy));
|
||||||
|
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
@ -63,38 +64,56 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
|
|||||||
holder.packageName.setText(policy.packageName);
|
holder.packageName.setText(policy.packageName);
|
||||||
holder.appIcon.setImageDrawable(pm.getPackageInfo(policy.packageName, 0).applicationInfo.loadIcon(pm));
|
holder.appIcon.setImageDrawable(pm.getPackageInfo(policy.packageName, 0).applicationInfo.loadIcon(pm));
|
||||||
holder.masterSwitch.setOnCheckedChangeListener((v, isChecked) -> {
|
holder.masterSwitch.setOnCheckedChangeListener((v, isChecked) -> {
|
||||||
if (isChecked && policy.policy == Policy.DENY) {
|
if ((isChecked && policy.policy == Policy.DENY) ||
|
||||||
policy.policy = Policy.ALLOW;
|
(!isChecked && policy.policy == Policy.ALLOW)) {
|
||||||
dbHelper.addPolicy(policy);
|
policy.policy = isChecked ? Policy.ALLOW : Policy.DENY;
|
||||||
} else if (!isChecked && policy.policy == Policy.ALLOW) {
|
String message = v.getContext().getString(
|
||||||
policy.policy = Policy.DENY;
|
isChecked ? R.string.su_snack_grant : R.string.su_snack_deny, policy.appName);
|
||||||
|
Snackbar.make(holder.itemView, message, Snackbar.LENGTH_SHORT).show();
|
||||||
dbHelper.addPolicy(policy);
|
dbHelper.addPolicy(policy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.notificationSwitch.setOnCheckedChangeListener((v, isChecked) -> {
|
holder.notificationSwitch.setOnCheckedChangeListener((v, isChecked) -> {
|
||||||
if (isChecked && !policy.notification) {
|
if ((isChecked && !policy.notification) ||
|
||||||
policy.notification = true;
|
(!isChecked && policy.notification)) {
|
||||||
dbHelper.addPolicy(policy);
|
policy.notification = isChecked;
|
||||||
} else if (!isChecked && policy.notification) {
|
String message = v.getContext().getString(
|
||||||
policy.notification = false;
|
isChecked ? R.string.su_snack_notif_on : R.string.su_snack_notif_off, policy.appName);
|
||||||
|
Snackbar.make(holder.itemView, message, Snackbar.LENGTH_SHORT).show();
|
||||||
dbHelper.addPolicy(policy);
|
dbHelper.addPolicy(policy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.loggingSwitch.setOnCheckedChangeListener((v, isChecked) -> {
|
holder.loggingSwitch.setOnCheckedChangeListener((v, isChecked) -> {
|
||||||
if (isChecked && !policy.logging) {
|
if ((isChecked && !policy.logging) ||
|
||||||
policy.logging = true;
|
(!isChecked && policy.logging)) {
|
||||||
dbHelper.addPolicy(policy);
|
policy.logging = isChecked;
|
||||||
} else if (!isChecked && policy.logging) {
|
String message = v.getContext().getString(
|
||||||
policy.logging = false;
|
isChecked ? R.string.su_snack_log_on : R.string.su_snack_log_off, policy.appName);
|
||||||
|
Snackbar.make(holder.itemView, message, Snackbar.LENGTH_SHORT).show();
|
||||||
dbHelper.addPolicy(policy);
|
dbHelper.addPolicy(policy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
holder.delete.setOnClickListener(v -> Utils.getAlertDialogBuilder(v.getContext())
|
||||||
|
.setTitle(R.string.su_revoke_title)
|
||||||
|
.setMessage(v.getContext().getString(R.string.su_revoke_msg, policy.appName))
|
||||||
|
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||||
|
policyList.remove(position);
|
||||||
|
notifyItemRemoved(position);
|
||||||
|
notifyItemRangeChanged(position, policyList.size());
|
||||||
|
Snackbar.make(holder.itemView, v.getContext().getString(R.string.su_snack_revoke, policy.appName),
|
||||||
|
Snackbar.LENGTH_SHORT).show();
|
||||||
|
dbHelper.deletePolicy(policy.uid);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
|
.setCancelable(true)
|
||||||
|
.show());
|
||||||
holder.masterSwitch.setChecked(policy.policy == Policy.ALLOW);
|
holder.masterSwitch.setChecked(policy.policy == Policy.ALLOW);
|
||||||
holder.notificationSwitch.setChecked(policy.notification);
|
holder.notificationSwitch.setChecked(policy.notification);
|
||||||
holder.loggingSwitch.setChecked(policy.logging);
|
holder.loggingSwitch.setChecked(policy.logging);
|
||||||
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
policyList.remove(position);
|
policyList.remove(position);
|
||||||
|
dbHelper.deletePolicy(policy.uid);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, policyList.size());
|
notifyItemRangeChanged(position, policyList.size());
|
||||||
onBindViewHolder(holder, position);
|
onBindViewHolder(holder, position);
|
||||||
@ -116,6 +135,7 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
|
|||||||
@BindView(R.id.notification_switch) Switch notificationSwitch;
|
@BindView(R.id.notification_switch) Switch notificationSwitch;
|
||||||
@BindView(R.id.logging_switch) Switch loggingSwitch;
|
@BindView(R.id.logging_switch) Switch loggingSwitch;
|
||||||
|
|
||||||
|
@BindView(R.id.delete) ImageView delete;
|
||||||
@BindView(R.id.more_info) ImageView moreInfo;
|
@BindView(R.id.more_info) ImageView moreInfo;
|
||||||
|
|
||||||
private ValueAnimator mAnimator;
|
private ValueAnimator mAnimator;
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
android:viewportHeight="24.0"
|
android:viewportHeight="24.0"
|
||||||
android:viewportWidth="24.0">
|
android:viewportWidth="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#757575"
|
android:fillColor="#000"
|
||||||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportHeight="24.0"
|
|
||||||
android:viewportWidth="24.0">
|
|
||||||
<path
|
|
||||||
android:fillColor="#000"
|
|
||||||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
|
||||||
</vector>
|
|
@ -106,6 +106,7 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="@dimen/checkbox_padding"
|
android:padding="@dimen/checkbox_padding"
|
||||||
android:src="@drawable/ic_delete"
|
android:src="@drawable/ic_delete"
|
||||||
|
android:tint="@color/icon_grey"
|
||||||
tools:ignore="ContentDescription"/>
|
tools:ignore="ContentDescription"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -142,6 +142,16 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:src="@drawable/ic_delete"
|
||||||
|
android:tint="@color/icon_grey"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/more_info"
|
android:id="@+id/more_info"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_clear"
|
android:id="@+id/menu_clear"
|
||||||
android:icon="@drawable/ic_delete_black"
|
android:icon="@drawable/ic_delete"
|
||||||
android:title="@string/menuClearLog"
|
android:title="@string/menuClearLog"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
<!--Toasts, Dialogs-->
|
<!--Toasts, Dialogs-->
|
||||||
<string name="permissionNotGranted">This feature will not work without permission to write external storage.</string>
|
<string name="permissionNotGranted">This feature will not work without permission to write external storage.</string>
|
||||||
<string name="no_thanks">No thanks</string>
|
<string name="no_thanks">No thanks</string>
|
||||||
|
<string name="yes">Yes</string>
|
||||||
<string name="repo_install_title">Install %1$s</string>
|
<string name="repo_install_title">Install %1$s</string>
|
||||||
<string name="repo_install_msg">Do you want to install %1$s ?</string>
|
<string name="repo_install_msg">Do you want to install %1$s ?</string>
|
||||||
<string name="download_install">Download & install</string>
|
<string name="download_install">Download & install</string>
|
||||||
@ -155,9 +156,17 @@
|
|||||||
<string name="twentymin">20 min</string>
|
<string name="twentymin">20 min</string>
|
||||||
<string name="thirtymin">30 min</string>
|
<string name="thirtymin">30 min</string>
|
||||||
<string name="sixtymin">60 min</string>
|
<string name="sixtymin">60 min</string>
|
||||||
<string name="su_allow_toast">%1$s is granted Superuser permissions</string>
|
<string name="su_allow_toast">%1$s is granted Superuser rights</string>
|
||||||
<string name="su_deny_toast">%1$s is denied Superuser permissions</string>
|
<string name="su_deny_toast">%1$s is denied Superuser rights</string>
|
||||||
<string name="no_apps_found">No apps found</string>
|
<string name="no_apps_found">No apps found</string>
|
||||||
|
<string name="su_snack_grant">Superuser rights of %1$s is granted</string>
|
||||||
|
<string name="su_snack_deny">Superuser rights of %1$s is denied</string>
|
||||||
|
<string name="su_snack_notif_on">Notifications of %1$s is enabled</string>
|
||||||
|
<string name="su_snack_notif_off">Notifications of %1$s is disabled</string>
|
||||||
|
<string name="su_snack_log_on">Logging of %1$s is enabled</string>
|
||||||
|
<string name="su_snack_log_off">Logging of %1$s is disabled</string>
|
||||||
|
<string name="su_snack_revoke">%1$s rights are revoked</string>
|
||||||
|
<string name="su_revoke_title">Revoke?</string>
|
||||||
|
<string name="su_revoke_msg">Confirm to revoke %1$s rights?</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user