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
3e35de9b
Commit
3e35de9b
authored
Mar 13, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small UI improvements
parent
1e24c72c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
55 deletions
+49
-55
ApplicationAdapter.java
...ava/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
+44
-50
SectionedAdapter.java
.../java/com/topjohnwu/magisk/adapters/SectionedAdapter.java
+1
-1
list_item_hide_process.xml
app/src/main/res/layout/list_item_hide_process.xml
+4
-4
No files found.
app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
View file @
3e35de9b
...
...
@@ -58,6 +58,8 @@ public class ApplicationAdapter extends SectionedAdapter
private
static
final
String
SAFETYNET_PROCESS
=
"com.google.android.gms.unstable"
;
private
static
final
String
GMS_PACKAGE
=
"com.google.android.gms"
;
private
static
int
BOTTOM_MARGIN
=
-
1
;
private
List
<
HideAppInfo
>
fullList
,
showList
;
private
List
<
HideTarget
>
hideList
;
private
PackageManager
pm
;
...
...
@@ -71,6 +73,10 @@ public class ApplicationAdapter extends SectionedAdapter
AsyncTask
.
SERIAL_EXECUTOR
.
execute
(
this
::
loadApps
);
}
private
static
ViewGroup
.
MarginLayoutParams
getMargins
(
RecyclerView
.
ViewHolder
vh
)
{
return
(
ViewGroup
.
MarginLayoutParams
)
vh
.
itemView
.
getLayoutParams
();
}
@Override
public
int
getSectionCount
()
{
return
showList
.
size
();
...
...
@@ -78,13 +84,17 @@ public class ApplicationAdapter extends SectionedAdapter
@Override
public
int
getItemCount
(
int
section
)
{
return
showList
.
get
(
section
).
expanded
?
showList
.
get
(
section
).
processes
.
size
()
:
0
;
HideAppInfo
app
=
showList
.
get
(
section
);
return
app
.
expanded
?
app
.
processList
.
size
()
:
0
;
}
@Override
public
AppViewHolder
onCreateSectionViewHolder
(
ViewGroup
parent
)
{
View
v
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
list_item_hide_app
,
parent
,
false
);
return
new
AppViewHolder
(
v
);
AppViewHolder
vh
=
new
AppViewHolder
(
v
);
if
(
BOTTOM_MARGIN
<
0
)
BOTTOM_MARGIN
=
getMargins
(
vh
).
bottomMargin
;
return
vh
;
}
@Override
...
...
@@ -96,45 +106,34 @@ public class ApplicationAdapter extends SectionedAdapter
@Override
public
void
onBindSectionViewHolder
(
AppViewHolder
holder
,
int
section
)
{
HideAppInfo
app
=
showList
.
get
(
section
);
IndeterminateCheckBox
.
OnStateChangedListener
listener
=
(
IndeterminateCheckBox
indeterminateCheckBox
,
@Nullable
Boolean
stat
)
->
{
if
(
stat
!=
null
)
{
for
(
HideProcessInfo
p
:
app
.
processes
)
{
String
cmd
=
Utils
.
fmt
(
"magiskhide --%s %s %s"
,
stat
?
"add"
:
"rm"
,
app
.
info
.
packageName
,
p
.
name
);
Shell
.
su
(
cmd
).
submit
();
p
.
hidden
=
stat
;
}
}
};
holder
.
app_name
.
setText
(
app
.
name
);
holder
.
app_icon
.
setImageDrawable
(
app
.
info
.
loadIcon
(
pm
));
holder
.
package_name
.
setText
(
app
.
info
.
packageName
);
holder
.
checkBox
.
setOnStateChangedListener
(
null
);
holder
.
checkBox
.
setOnStateChangedListener
(
listener
);
holder
.
checkBox
.
setOnStateChangedListener
(
app
.
listener
);
holder
.
checkBox
.
setState
(
app
.
getState
());
if
(
app
.
expanded
)
{
holder
.
checkBox
.
setVisibility
(
View
.
GONE
);
setBottomMargin
(
holder
.
itemView
,
0
)
;
getMargins
(
holder
).
bottomMargin
=
0
;
}
else
{
holder
.
checkBox
.
setVisibility
(
View
.
VISIBLE
);
setBottomMargin
(
holder
.
itemView
,
2
)
;
getMargins
(
holder
).
bottomMargin
=
BOTTOM_MARGIN
;
}
holder
.
itemView
.
setOnClickListener
((
v
)
->
{
int
index
=
getItemPosition
(
section
,
0
);
if
(
app
.
expanded
)
{
app
.
expanded
=
false
;
notifyItemRangeRemoved
(
index
,
app
.
process
es
.
size
());
setBottomMargin
(
holder
.
itemView
,
2
)
;
notifyItemRangeRemoved
(
index
,
app
.
process
List
.
size
());
getMargins
(
holder
).
bottomMargin
=
BOTTOM_MARGIN
;
holder
.
checkBox
.
setOnStateChangedListener
(
null
);
holder
.
checkBox
.
setVisibility
(
View
.
VISIBLE
);
holder
.
checkBox
.
setState
(
app
.
getState
());
holder
.
checkBox
.
setOnStateChangedListener
(
listener
);
holder
.
checkBox
.
setOnStateChangedListener
(
app
.
listener
);
}
else
{
holder
.
checkBox
.
setVisibility
(
View
.
GONE
);
setBottomMargin
(
holder
.
itemView
,
0
)
;
getMargins
(
holder
).
bottomMargin
=
0
;
app
.
expanded
=
true
;
notifyItemRangeInserted
(
index
,
app
.
process
es
.
size
());
notifyItemRangeInserted
(
index
,
app
.
process
List
.
size
());
}
});
}
...
...
@@ -142,21 +141,17 @@ public class ApplicationAdapter extends SectionedAdapter
@Override
public
void
onBindItemViewHolder
(
ProcessViewHolder
holder
,
int
section
,
int
position
)
{
HideAppInfo
hideApp
=
showList
.
get
(
section
);
HideProcessInfo
target
=
hideApp
.
process
es
.
get
(
position
);
HideProcessInfo
target
=
hideApp
.
process
List
.
get
(
position
);
holder
.
process
.
setText
(
target
.
name
);
holder
.
checkbox
.
setOnCheckedChangeListener
(
null
);
holder
.
checkbox
.
setChecked
(
target
.
hidden
);
holder
.
checkbox
.
setOnCheckedChangeListener
((
v
,
isChecked
)
->
{
String
pair
=
Utils
.
fmt
(
"%s %s"
,
hideApp
.
info
.
packageName
,
target
.
name
);
if
(
isChecked
)
{
Shell
.
su
(
"magiskhide --add "
+
pair
).
submit
();
target
.
hidden
=
true
;
}
else
{
Shell
.
su
(
"magiskhide --rm "
+
pair
).
submit
();
target
.
hidden
=
false
;
}
holder
.
checkbox
.
setOnCheckedChangeListener
((
v
,
checked
)
->
{
Shell
.
su
(
Utils
.
fmt
(
"magiskhide --%s %s %s"
,
checked
?
"add"
:
"rm"
,
hideApp
.
info
.
packageName
,
target
.
name
)).
submit
();
target
.
hidden
=
checked
;
});
getMargins
(
holder
).
bottomMargin
=
position
==
hideApp
.
processList
.
size
()
-
1
?
BOTTOM_MARGIN
:
0
;
}
public
void
filter
(
String
constraint
)
{
...
...
@@ -179,18 +174,6 @@ public class ApplicationAdapter extends SectionedAdapter
AsyncTask
.
SERIAL_EXECUTOR
.
execute
(
this
::
loadApps
);
}
private
void
setBottomMargin
(
View
view
,
int
dp
)
{
ViewGroup
.
LayoutParams
params
=
view
.
getLayoutParams
();
ViewGroup
.
MarginLayoutParams
marginParams
;
if
(
params
instanceof
ViewGroup
.
MarginLayoutParams
)
{
marginParams
=
(
ViewGroup
.
MarginLayoutParams
)
params
;
}
else
{
marginParams
=
new
ViewGroup
.
MarginLayoutParams
(
params
);
}
marginParams
.
bottomMargin
=
Utils
.
dpInPx
(
dp
);
view
.
setLayoutParams
(
marginParams
);
}
private
void
addProcesses
(
Set
<
String
>
set
,
ComponentInfo
[]
infos
)
{
if
(
infos
!=
null
)
for
(
ComponentInfo
info
:
infos
)
...
...
@@ -258,7 +241,7 @@ public class ApplicationAdapter extends SectionedAdapter
filter
=
filter
.
toLowerCase
();
if
(
contains
(
target
.
name
,
filter
))
return
true
;
for
(
HideProcessInfo
p
:
target
.
process
es
)
{
for
(
HideProcessInfo
p
:
target
.
process
List
)
{
if
(
contains
(
p
.
name
,
filter
))
return
true
;
}
...
...
@@ -268,16 +251,27 @@ public class ApplicationAdapter extends SectionedAdapter
class
HideAppInfo
implements
Comparable
<
HideAppInfo
>
{
String
name
;
ApplicationInfo
info
;
List
<
HideProcessInfo
>
process
es
;
List
<
HideProcessInfo
>
process
List
;
boolean
expanded
;
IndeterminateCheckBox
.
OnStateChangedListener
listener
;
HideAppInfo
(
ApplicationInfo
appInfo
,
Set
<
String
>
set
)
{
info
=
appInfo
;
name
=
Utils
.
getAppLabel
(
info
,
pm
);
expanded
=
false
;
process
es
=
StreamSupport
.
stream
(
set
)
process
List
=
StreamSupport
.
stream
(
set
)
.
map
(
process
->
new
HideProcessInfo
(
info
.
packageName
,
process
))
.
sorted
().
collect
(
Collectors
.
toList
());
listener
=
(
IndeterminateCheckBox
box
,
@Nullable
Boolean
status
)
->
{
if
(
status
!=
null
)
{
for
(
HideProcessInfo
p
:
processList
)
{
String
cmd
=
Utils
.
fmt
(
"magiskhide --%s %s %s"
,
status
?
"add"
:
"rm"
,
info
.
packageName
,
p
.
name
);
Shell
.
su
(
cmd
).
submit
();
p
.
hidden
=
status
;
}
}
};
}
@Override
...
...
@@ -293,7 +287,7 @@ public class ApplicationAdapter extends SectionedAdapter
Boolean
getState
()
{
boolean
all
=
true
;
boolean
hidden
=
false
;
for
(
HideProcessInfo
p
:
process
es
)
{
for
(
HideProcessInfo
p
:
process
List
)
{
if
(!
p
.
hidden
)
all
=
false
;
else
...
...
@@ -357,7 +351,7 @@ public class ApplicationAdapter extends SectionedAdapter
@BindView
(
R
.
id
.
package_name
)
TextView
package_name
;
@BindView
(
R
.
id
.
checkbox
)
IndeterminateCheckBox
checkBox
;
public
AppViewHolder
(
@NonNull
View
itemView
)
{
AppViewHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
new
ApplicationAdapter$AppViewHolder_ViewBinding
(
this
,
itemView
);
}
...
...
@@ -368,7 +362,7 @@ public class ApplicationAdapter extends SectionedAdapter
@BindView
(
R
.
id
.
process
)
TextView
process
;
@BindView
(
R
.
id
.
checkbox
)
CheckBox
checkbox
;
public
ProcessViewHolder
(
@NonNull
View
itemView
)
{
ProcessViewHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
new
ApplicationAdapter$ProcessViewHolder_ViewBinding
(
this
,
itemView
);
}
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/SectionedAdapter.java
View file @
3e35de9b
...
...
@@ -44,7 +44,7 @@ public abstract class SectionedAdapter<S extends RecyclerView.ViewHolder, C exte
if
(
info
.
position
==
-
1
)
return
SECTION_TYPE
;
else
return
getItemViewType
(
info
.
section
,
info
.
position
);
return
getItemViewType
(
info
.
section
,
info
.
position
);
}
public
int
getItemViewType
(
int
section
,
int
position
)
{
...
...
app/src/main/res/layout/list_item_hide_process.xml
View file @
3e35de9b
...
...
@@ -7,16 +7,16 @@
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_marginStart=
"@dimen/card_horizontal_margin"
android:layout_marginTop=
"0dp"
android:layout_marginEnd=
"@dimen/card_horizontal_margin"
android:layout_marginBottom=
"0dp"
app:cardCornerRadius=
"@dimen/card_corner_radius"
app:cardCornerRadius=
"0dp"
app:cardElevation=
"@dimen/card_elevation"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/info_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:paddingTop=
"2dp"
android:paddingBottom=
"2dp"
>
<TextView
android:id=
"@+id/process"
...
...
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