Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
15ca1884
Commit
15ca1884
authored
Jan 25, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add su revoke
parent
67c9e2ea
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
35 deletions
+66
-35
ModulesAdapter.java
...in/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java
+4
-4
PolicyAdapter.java
...ain/java/com/topjohnwu/magisk/adapters/PolicyAdapter.java
+37
-17
ic_delete.xml
app/src/main/res/drawable/ic_delete.xml
+1
-1
ic_delete_black.xml
app/src/main/res/drawable/ic_delete_black.xml
+0
-9
list_item_module.xml
app/src/main/res/layout/list_item_module.xml
+1
-0
list_item_policy.xml
app/src/main/res/layout/list_item_policy.xml
+10
-0
menu_log.xml
app/src/main/res/menu/menu_log.xml
+1
-1
strings.xml
app/src/main/res/values/strings.xml
+12
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java
View file @
15ca1884
...
...
@@ -61,8 +61,8 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override
protected
void
onPostExecute
(
Void
v
)
{
int
title
=
isChecked
?
R
.
string
.
disable_file_removed
:
R
.
string
.
disable_file_created
;
Snackbar
.
make
(
holder
.
title
,
title
,
Snackbar
.
LENGTH_SHORT
).
show
();
int
snack
=
isChecked
?
R
.
string
.
disable_file_removed
:
R
.
string
.
disable_file_created
;
Snackbar
.
make
(
holder
.
itemView
,
snack
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
}.
exec
());
...
...
@@ -81,8 +81,8 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override
protected
void
onPostExecute
(
Void
v
)
{
int
title
=
removed
?
R
.
string
.
remove_file_deleted
:
R
.
string
.
remove_file_created
;
Snackbar
.
make
(
holder
.
title
,
title
,
Snackbar
.
LENGTH_SHORT
).
show
();
int
snack
=
removed
?
R
.
string
.
remove_file_deleted
:
R
.
string
.
remove_file_created
;
Snackbar
.
make
(
holder
.
itemView
,
snack
,
Snackbar
.
LENGTH_SHORT
).
show
();
updateDeleteButton
(
holder
,
module
);
}
}.
exec
());
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/PolicyAdapter.java
View file @
15ca1884
...
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.adapters;
import
android.animation.Animator
;
import
android.animation.ValueAnimator
;
import
android.content.pm.PackageManager
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.View
;
...
...
@@ -16,6 +17,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.superuser.Policy
;
import
com.topjohnwu.magisk.superuser.SuDatabaseHelper
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.HashSet
;
import
java.util.List
;
...
...
@@ -44,9 +46,8 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
@Override
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
try
{
Policy
policy
=
policyList
.
get
(
position
);
try
{
holder
.
setExpanded
(
expandList
.
contains
(
policy
));
holder
.
itemView
.
setOnClickListener
(
view
->
{
...
...
@@ -63,38 +64,56 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
holder
.
packageName
.
setText
(
policy
.
packageName
);
holder
.
appIcon
.
setImageDrawable
(
pm
.
getPackageInfo
(
policy
.
packageName
,
0
).
applicationInfo
.
loadIcon
(
pm
));
holder
.
masterSwitch
.
setOnCheckedChangeListener
((
v
,
isChecked
)
->
{
if
(
isChecked
&&
policy
.
policy
==
Policy
.
DENY
)
{
policy
.
policy
=
Policy
.
ALLOW
;
dbHelper
.
addPolicy
(
policy
);
}
else
if
(!
isChecked
&&
policy
.
policy
==
Policy
.
ALLOW
)
{
policy
.
policy
=
Policy
.
DENY
;
if
((
isChecked
&&
policy
.
policy
==
Policy
.
DENY
)
||
(!
isChecked
&&
policy
.
policy
==
Policy
.
ALLOW
))
{
policy
.
policy
=
isChecked
?
Policy
.
ALLOW
:
Policy
.
DENY
;
String
message
=
v
.
getContext
().
getString
(
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
);
}
});
holder
.
notificationSwitch
.
setOnCheckedChangeListener
((
v
,
isChecked
)
->
{
if
(
isChecked
&&
!
policy
.
notification
)
{
policy
.
notification
=
true
;
dbHelper
.
addPolicy
(
policy
);
}
else
if
(!
isChecked
&&
policy
.
notification
)
{
policy
.
notification
=
false
;
if
((
isChecked
&&
!
policy
.
notification
)
||
(!
isChecked
&&
policy
.
notification
))
{
policy
.
notification
=
isChecked
;
String
message
=
v
.
getContext
().
getString
(
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
);
}
});
holder
.
loggingSwitch
.
setOnCheckedChangeListener
((
v
,
isChecked
)
->
{
if
(
isChecked
&&
!
policy
.
logging
)
{
policy
.
logging
=
true
;
dbHelper
.
addPolicy
(
policy
);
}
else
if
(!
isChecked
&&
policy
.
logging
)
{
policy
.
logging
=
false
;
if
((
isChecked
&&
!
policy
.
logging
)
||
(!
isChecked
&&
policy
.
logging
))
{
policy
.
logging
=
isChecked
;
String
message
=
v
.
getContext
().
getString
(
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
);
}
});
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
.
notificationSwitch
.
setChecked
(
policy
.
notification
);
holder
.
loggingSwitch
.
setChecked
(
policy
.
logging
);
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
policyList
.
remove
(
position
);
dbHelper
.
deletePolicy
(
policy
.
uid
);
notifyItemRemoved
(
position
);
notifyItemRangeChanged
(
position
,
policyList
.
size
());
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
.
logging_switch
)
Switch
loggingSwitch
;
@BindView
(
R
.
id
.
delete
)
ImageView
delete
;
@BindView
(
R
.
id
.
more_info
)
ImageView
moreInfo
;
private
ValueAnimator
mAnimator
;
...
...
app/src/main/res/drawable/ic_delete.xml
View file @
15ca1884
...
...
@@ -4,6 +4,6 @@
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
>
<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"
/>
</vector>
app/src/main/res/drawable/ic_delete_black.xml
deleted
100644 → 0
View file @
67c9e2ea
<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>
app/src/main/res/layout/list_item_module.xml
View file @
15ca1884
...
...
@@ -106,6 +106,7 @@
android:gravity=
"center"
android:padding=
"@dimen/checkbox_padding"
android:src=
"@drawable/ic_delete"
android:tint=
"@color/icon_grey"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
...
...
app/src/main/res/layout/list_item_policy.xml
View file @
15ca1884
...
...
@@ -142,6 +142,16 @@
</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
android:id=
"@+id/more_info"
android:layout_width=
"wrap_content"
...
...
app/src/main/res/menu/menu_log.xml
View file @
15ca1884
...
...
@@ -16,7 +16,7 @@
<item
android:id=
"@+id/menu_clear"
android:icon=
"@drawable/ic_delete
_black
"
android:icon=
"@drawable/ic_delete"
android:title=
"@string/menuClearLog"
app:showAsAction=
"ifRoom"
/>
...
...
app/src/main/res/values/strings.xml
View file @
15ca1884
...
...
@@ -87,6 +87,7 @@
<!--Toasts, Dialogs-->
<string
name=
"permissionNotGranted"
>
This feature will not work without permission to write external storage.
</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_msg"
>
Do you want to install %1$s ?
</string>
<string
name=
"download_install"
>
Download
&
install
</string>
...
...
@@ -155,9 +156,17 @@
<string
name=
"twentymin"
>
20 min
</string>
<string
name=
"thirtymin"
>
30 min
</string>
<string
name=
"sixtymin"
>
60 min
</string>
<string
name=
"su_allow_toast"
>
%1$s is granted Superuser
permission
s
</string>
<string
name=
"su_deny_toast"
>
%1$s is denied Superuser
permission
s
</string>
<string
name=
"su_allow_toast"
>
%1$s is granted Superuser
right
s
</string>
<string
name=
"su_deny_toast"
>
%1$s is denied Superuser
right
s
</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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment