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
ad16a6fc
Commit
ad16a6fc
authored
Jan 24, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project restructure
parent
478b7eeb
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
200 additions
and
180 deletions
+200
-180
proguard-rules.pro
app/proguard-rules.pro
+1
-1
AboutActivity.java
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
+3
-2
Global.java
app/src/main/java/com/topjohnwu/magisk/Global.java
+37
-0
InstallFragment.java
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
+13
-18
MagiskHideFragment.java
...rc/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
+8
-11
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+12
-14
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+4
-6
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+4
-6
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+4
-4
StatusFragment.java
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
+24
-31
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+1
-1
ModuleHelper.java
...c/main/java/com/topjohnwu/magisk/module/ModuleHelper.java
+24
-61
MagiskDlReceiver.java
...java/com/topjohnwu/magisk/receivers/MagiskDlReceiver.java
+2
-2
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+1
-2
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+17
-19
FABBehavior.java
...src/main/java/com/topjohnwu/magisk/utils/FABBehavior.java
+1
-1
ValueSortedMap.java
.../main/java/com/topjohnwu/magisk/utils/ValueSortedMap.java
+43
-0
modules_fragment.xml
app/src/main/res/layout/modules_fragment.xml
+1
-1
No files found.
app/proguard-rules.pro
View file @
ad16a6fc
...
...
@@ -29,7 +29,7 @@
# Application classes that will be serialized/deserialized over Gson
-
keep
class
com
.
topjohnwu
.
magisk
.
module
.
**
{
*
;
}
-
keep
class
com
.
topjohnwu
.
magisk
.
utils
.
ModuleHelper
$
ValueSortedMap
{
*
;
}
-
keep
class
com
.
topjohnwu
.
magisk
.
module
.
ModuleHelper
$
ValueSortedMap
{
*
;
}
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
...
...
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
View file @
ad16a6fc
...
...
@@ -28,9 +28,10 @@ import butterknife.ButterKnife;
public
class
AboutActivity
extends
AppCompatActivity
{
private
static
final
String
SOURCE_CODE_URL
=
"https://github.com/topjohnwu/MagiskManager"
;
private
static
final
String
XDA_THREAD
=
"http://forum.xda-developers.com/showthread.php?t=3432382"
;
private
static
final
String
DONATION_URL
=
"http://topjohnwu.github.io/donate"
;
private
static
final
String
XDA_THREAD
=
"http://forum.xda-developers.com/showthread.php?t=3432382"
;
private
static
final
String
SOURCE_CODE_URL
=
"https://github.com/topjohnwu/MagiskManager"
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
app_version_info
)
AboutCardRow
appVersionInfo
;
@BindView
(
R
.
id
.
app_changelog
)
AboutCardRow
appChangelog
;
...
...
app/src/main/java/com/topjohnwu/magisk/Global.java
0 → 100644
View file @
ad16a6fc
package
com
.
topjohnwu
.
magisk
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
import
java.util.List
;
public
class
Global
{
public
static
class
Constant
{
// No global constants now
}
public
static
class
Info
{
public
static
double
magiskVersion
;
public
static
double
remoteMagiskVersion
=
-
1
;
public
static
String
magiskVersionString
=
"(none)"
;
public
static
String
magiskLink
;
public
static
String
releaseNoteLink
;
public
static
int
SNCheckResult
=
-
1
;
public
static
String
bootBlock
=
null
;
}
public
static
class
Data
{
public
static
ValueSortedMap
<
String
,
Repo
>
repoMap
=
new
ValueSortedMap
<>();
public
static
ValueSortedMap
<
String
,
com
.
topjohnwu
.
magisk
.
module
.
Module
>
moduleMap
=
new
ValueSortedMap
<>();
public
static
List
<
String
>
blockList
;
}
public
static
class
Events
{
public
static
final
CallbackHandler
.
Event
blockDetectionDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
packageLoadDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
reloadMainActivity
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
moduleLoadDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
repoLoadDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
updateCheckDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
safetyNetDone
=
new
CallbackHandler
.
Event
();
}
}
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
View file @
ad16a6fc
...
...
@@ -28,11 +28,6 @@ import butterknife.Unbinder;
public
class
InstallFragment
extends
Fragment
implements
CallbackHandler
.
EventListener
{
public
static
final
CallbackHandler
.
Event
blockDetectionDone
=
new
CallbackHandler
.
Event
();
public
static
List
<
String
>
blockList
;
public
static
String
bootBlock
=
null
;
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
current_version_title
)
TextView
currentVersionTitle
;
@BindView
(
R
.
id
.
install_title
)
TextView
installTitle
;
...
...
@@ -48,14 +43,14 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
View
v
=
inflater
.
inflate
(
R
.
layout
.
install_fragment
,
container
,
false
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
detectButton
.
setOnClickListener
(
v1
->
toAutoDetect
());
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
StatusFragment
.
magiskVersionString
));
installTitle
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
StatusFragment
.
remoteMagiskVersion
));
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
Global
.
Info
.
magiskVersionString
));
installTitle
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
Global
.
Info
.
remoteMagiskVersion
));
flashButton
.
setOnClickListener
(
v1
->
{
String
bootImage
=
bootBlock
;
String
bootImage
=
Global
.
Info
.
bootBlock
;
if
(
bootImage
==
null
)
{
bootImage
=
blockList
.
get
(
spinner
.
getSelectedItemPosition
()
-
1
);
bootImage
=
Global
.
Data
.
blockList
.
get
(
spinner
.
getSelectedItemPosition
()
-
1
);
}
String
filename
=
"Magisk-v"
+
StatusFragment
.
remoteMagiskVersion
+
".zip"
;
String
filename
=
"Magisk-v"
+
Global
.
Info
.
remoteMagiskVersion
+
".zip"
;
String
finalBootImage
=
bootImage
;
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
getString
(
R
.
string
.
repo_install_title
,
getString
(
R
.
string
.
magisk
)))
...
...
@@ -64,15 +59,15 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
.
setPositiveButton
(
R
.
string
.
download_install
,
(
dialogInterface
,
i
)
->
Utils
.
dlAndReceive
(
getActivity
(),
new
MagiskDlReceiver
(
finalBootImage
,
keepEncChkbox
.
isChecked
(),
keepVerityChkbox
.
isChecked
()),
StatusFragment
.
magiskLink
,
Global
.
Info
.
magiskLink
,
Utils
.
getLegalFilename
(
filename
)))
.
setNeutralButton
(
R
.
string
.
check_release_notes
,
(
dialog
,
which
)
->
{
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
StatusFragment
.
releaseNoteLink
)));
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Global
.
Info
.
releaseNoteLink
)));
})
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
();
});
if
(
blockDetectionDone
.
isTriggered
)
{
if
(
Global
.
Events
.
blockDetectionDone
.
isTriggered
)
{
updateUI
();
}
return
v
;
...
...
@@ -84,8 +79,8 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
}
private
void
updateUI
()
{
List
<
String
>
items
=
new
ArrayList
<>(
blockList
);
items
.
add
(
0
,
getString
(
R
.
string
.
auto_detect
,
bootBlock
));
List
<
String
>
items
=
new
ArrayList
<>(
Global
.
Data
.
blockList
);
items
.
add
(
0
,
getString
(
R
.
string
.
auto_detect
,
Global
.
Info
.
bootBlock
));
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
getActivity
(),
android
.
R
.
layout
.
simple_spinner_item
,
items
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
...
...
@@ -94,7 +89,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
}
private
void
toAutoDetect
()
{
if
(
bootBlock
!=
null
)
{
if
(
Global
.
Info
.
bootBlock
!=
null
)
{
spinner
.
setSelection
(
0
);
}
}
...
...
@@ -103,12 +98,12 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
public
void
onStart
()
{
super
.
onStart
();
getActivity
().
setTitle
(
R
.
string
.
install
);
CallbackHandler
.
register
(
blockDetectionDone
,
this
);
CallbackHandler
.
register
(
Global
.
Events
.
blockDetectionDone
,
this
);
}
@Override
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
blockDetectionDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
blockDetectionDone
,
this
);
super
.
onStop
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
View file @
ad16a6fc
...
...
@@ -29,19 +29,16 @@ import butterknife.Unbinder;
public
class
MagiskHideFragment
extends
Fragment
implements
CallbackHandler
.
EventListener
{
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
// Don't show in list...
public
static
final
List
<
String
>
BLACKLIST
=
Arrays
.
asList
(
public
static
final
List
<
String
>
HIDEBLACKLIST
=
Arrays
.
asList
(
"android"
,
"com.topjohnwu.magisk"
,
"com.google.android.gms"
,
"com.google.android.apps.walletnfcrel"
,
"com.nianticlabs.pokemongo"
);
public
static
final
CallbackHandler
.
Event
packageLoadDone
=
new
CallbackHandler
.
Event
();
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
private
ApplicationAdapter
appAdapter
;
...
...
@@ -98,15 +95,15 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
public
void
onStart
()
{
super
.
onStart
();
getActivity
().
setTitle
(
R
.
string
.
magiskhide
);
CallbackHandler
.
register
(
packageLoadDone
,
this
);
if
(
packageLoadDone
.
isTriggered
)
{
onTrigger
(
packageLoadDone
);
CallbackHandler
.
register
(
Global
.
Events
.
packageLoadDone
,
this
);
if
(
Global
.
Events
.
packageLoadDone
.
isTriggered
)
{
onTrigger
(
Global
.
Events
.
packageLoadDone
);
}
}
@Override
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
packageLoadDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
packageLoadDone
,
this
);
super
.
onStop
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
ad16a6fc
...
...
@@ -34,8 +34,6 @@ public class MainActivity extends AppCompatActivity
private
static
final
String
SELECTED_ITEM_ID
=
"SELECTED_ITEM_ID"
;
public
static
final
CallbackHandler
.
Event
recreate
=
new
CallbackHandler
.
Event
();
private
final
Handler
mDrawerHandler
=
new
Handler
();
private
SharedPreferences
prefs
;
...
...
@@ -88,28 +86,28 @@ public class MainActivity extends AppCompatActivity
}
navigationView
.
setNavigationItemSelectedListener
(
this
);
CallbackHandler
.
register
(
recreate
,
this
);
CallbackHandler
.
register
(
Global
.
Events
.
reloadMainActivity
,
this
);
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
CallbackHandler
.
register
(
StatusFragment
.
updateCheckDone
,
this
);
if
(
StatusFragment
.
updateCheckDone
.
isTriggered
)
{
onTrigger
(
StatusFragment
.
updateCheckDone
);
CallbackHandler
.
register
(
Global
.
Events
.
updateCheckDone
,
this
);
if
(
Global
.
Events
.
updateCheckDone
.
isTriggered
)
{
onTrigger
(
Global
.
Events
.
updateCheckDone
);
}
checkHideSection
();
}
@Override
protected
void
onPause
()
{
CallbackHandler
.
unRegister
(
StatusFragment
.
updateCheckDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
updateCheckDone
,
this
);
super
.
onPause
();
}
@Override
protected
void
onDestroy
()
{
CallbackHandler
.
unRegister
(
recreate
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
reloadMainActivity
,
this
);
super
.
onDestroy
();
}
...
...
@@ -139,22 +137,22 @@ public class MainActivity extends AppCompatActivity
@Override
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
if
(
event
==
StatusFragment
.
updateCheckDone
)
{
if
(
event
==
Global
.
Events
.
updateCheckDone
)
{
Menu
menu
=
navigationView
.
getMenu
();
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
StatusFragment
.
remoteMagiskVersion
>
0
&&
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
Global
.
Info
.
remoteMagiskVersion
>
0
&&
Shell
.
rootAccess
());
}
else
if
(
event
==
recreate
)
{
}
else
if
(
event
==
Global
.
Events
.
reloadMainActivity
)
{
recreate
();
}
}
private
void
checkHideSection
()
{
Menu
menu
=
navigationView
.
getMenu
();
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
StatusFragment
.
magiskVersion
>=
8
&&
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
Global
.
Info
.
magiskVersion
>=
8
&&
prefs
.
getBoolean
(
"magiskhide"
,
false
)
&&
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
StatusFragment
.
magiskVersion
>=
4
&&
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
Global
.
Info
.
magiskVersion
>=
4
&&
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
StatusFragment
.
magiskVersion
>=
4
&&
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Global
.
Info
.
magiskVersion
>=
4
&&
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
Shell
.
rootAccess
());
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
ad16a6fc
...
...
@@ -19,7 +19,7 @@ import com.topjohnwu.magisk.module.Module;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.
utils
.ModuleHelper
;
import
com.topjohnwu.magisk.
module
.ModuleHelper
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -30,8 +30,6 @@ import butterknife.Unbinder;
public
class
ModulesFragment
extends
Fragment
implements
CallbackHandler
.
EventListener
{
public
static
final
CallbackHandler
.
Event
moduleLoadDone
=
new
CallbackHandler
.
Event
();
private
static
final
int
FETCH_ZIP_CODE
=
2
;
private
Unbinder
unbinder
;
...
...
@@ -71,7 +69,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
}
});
if
(
moduleLoadDone
.
isTriggered
)
{
if
(
Global
.
Events
.
moduleLoadDone
.
isTriggered
)
{
updateUI
();
}
...
...
@@ -97,13 +95,13 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
@Override
public
void
onStart
()
{
super
.
onStart
();
CallbackHandler
.
register
(
moduleLoadDone
,
this
);
CallbackHandler
.
register
(
Global
.
Events
.
moduleLoadDone
,
this
);
getActivity
().
setTitle
(
R
.
string
.
modules
);
}
@Override
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
moduleLoadDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
moduleLoadDone
,
this
);
super
.
onStop
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
ad16a6fc
...
...
@@ -20,7 +20,7 @@ import com.topjohnwu.magisk.module.Repo;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.
utils
.ModuleHelper
;
import
com.topjohnwu.magisk.
module
.ModuleHelper
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -31,8 +31,6 @@ import butterknife.Unbinder;
public
class
ReposFragment
extends
Fragment
implements
CallbackHandler
.
EventListener
{
public
static
final
CallbackHandler
.
Event
repoLoadDone
=
new
CallbackHandler
.
Event
();
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
@BindView
(
R
.
id
.
empty_rv
)
TextView
emptyTv
;
...
...
@@ -74,7 +72,7 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
new
Async
.
LoadRepos
(
getActivity
()).
exec
();
});
if
(
repoLoadDone
.
isTriggered
)
{
if
(
Global
.
Events
.
repoLoadDone
.
isTriggered
)
{
reloadRepos
();
updateUI
();
}
...
...
@@ -112,13 +110,13 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
@Override
public
void
onStart
()
{
super
.
onStart
();
CallbackHandler
.
register
(
repoLoadDone
,
this
);
CallbackHandler
.
register
(
Global
.
Events
.
repoLoadDone
,
this
);
getActivity
().
setTitle
(
R
.
string
.
downloads
);
}
@Override
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
repoLoadDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
repoLoadDone
,
this
);
super
.
onStop
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
ad16a6fc
...
...
@@ -14,9 +14,9 @@ import android.support.v7.widget.Toolbar;
import
android.view.WindowManager
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.module.ModuleHelper
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.ModuleHelper
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
...
...
@@ -107,10 +107,10 @@ public class SettingsActivity extends AppCompatActivity {
themePreference
.
setSummary
(
R
.
string
.
theme_default
);
}
if
(
StatusFragment
.
magiskVersion
<
9
)
{
if
(
Global
.
Info
.
magiskVersion
<
9
)
{
hostsPreference
.
setEnabled
(
false
);
busyboxPreference
.
setEnabled
(
false
);
}
else
if
(
StatusFragment
.
magiskVersion
<
8
)
{
}
else
if
(
Global
.
Info
.
magiskVersion
<
8
)
{
magiskhidePreference
.
setEnabled
(
false
);
}
else
if
(!
Shell
.
rootAccess
())
{
busyboxPreference
.
setEnabled
(
false
);
...
...
@@ -146,7 +146,7 @@ public class SettingsActivity extends AppCompatActivity {
if
(
Utils
.
isDarkTheme
!=
theme
.
equalsIgnoreCase
(
getString
(
R
.
string
.
theme_dark_value
)))
{
Utils
.
isDarkTheme
=
!
Utils
.
isDarkTheme
;
getActivity
().
recreate
();
MainActivity
.
recreate
.
trigger
();
Global
.
Events
.
reloadMainActivity
.
trigger
();
}
break
;
case
"magiskhide"
:
...
...
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
View file @
ad16a6fc
...
...
@@ -30,15 +30,8 @@ import butterknife.Unbinder;
public
class
StatusFragment
extends
Fragment
implements
CallbackHandler
.
EventListener
{
public
static
double
magiskVersion
,
remoteMagiskVersion
=
-
1
;
public
static
String
magiskVersionString
=
"(none)"
,
magiskLink
,
releaseNoteLink
;
public
static
int
SNCheckResult
=
-
1
;
private
static
boolean
noDialog
=
false
;
public
static
final
CallbackHandler
.
Event
updateCheckDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
safetyNetDone
=
new
CallbackHandler
.
Event
();
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
...
...
@@ -93,7 +86,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
safetyNetStatusText
.
setTextColor
(
defaultColor
);
safetyNetDone
.
isTriggered
=
false
;
Global
.
Events
.
safetyNetDone
.
isTriggered
=
false
;
noDialog
=
false
;
updateUI
();
...
...
@@ -108,7 +101,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
Async
.
checkSafetyNet
(
getActivity
());
});
if
(
magiskVersion
<
0
&&
Shell
.
rootAccess
()
&&
!
noDialog
)
{
if
(
Global
.
Info
.
magiskVersion
<
0
&&
Shell
.
rootAccess
()
&&
!
noDialog
)
{
noDialog
=
true
;
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
R
.
string
.
no_magisk_title
)
...
...
@@ -133,10 +126,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
if
(
event
==
updateCheckDone
)
{
if
(
event
==
Global
.
Events
.
updateCheckDone
)
{
Logger
.
dev
(
"StatusFragment: Update Check UI refresh triggered"
);
updateCheckUI
();
}
else
if
(
event
==
safetyNetDone
)
{
}
else
if
(
event
==
Global
.
Events
.
safetyNetDone
)
{
Logger
.
dev
(
"StatusFragment: SafetyNet UI refresh triggered"
);
updateSafetyNetUI
();
}
...
...
@@ -145,12 +138,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
public
void
onStart
()
{
super
.
onStart
();
CallbackHandler
.
register
(
updateCheckDone
,
this
);
CallbackHandler
.
register
(
safetyNetDone
,
this
);
if
(
updateCheckDone
.
isTriggered
)
{
CallbackHandler
.
register
(
Global
.
Events
.
updateCheckDone
,
this
);
CallbackHandler
.
register
(
Global
.
Events
.
safetyNetDone
,
this
);
if
(
Global
.
Events
.
updateCheckDone
.
isTriggered
)
{
updateCheckUI
();
}
if
(
safetyNetDone
.
isTriggered
)
{
if
(
Global
.
Events
.
safetyNetDone
.
isTriggered
)
{
updateSafetyNetUI
();
}
getActivity
().
setTitle
(
R
.
string
.
status
);
...
...
@@ -158,8 +151,8 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
updateCheckDone
,
this
);
CallbackHandler
.
unRegister
(
safetyNetDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
updateCheckDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
safetyNetDone
,
this
);
super
.
onStop
();
}
...
...
@@ -172,14 +165,14 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
private
static
void
checkMagiskInfo
()
{
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
if
(
ret
.
get
(
0
).
length
()
==
0
)
{
magiskVersion
=
-
1
;
Global
.
Info
.
magiskVersion
=
-
1
;
}
else
{
try
{
magiskVersionString
=
ret
.
get
(
0
);
magiskVersion
=
Double
.
parseDouble
(
ret
.
get
(
0
));
Global
.
Info
.
magiskVersionString
=
ret
.
get
(
0
);
Global
.
Info
.
magiskVersion
=
Double
.
parseDouble
(
ret
.
get
(
0
));
}
catch
(
NumberFormatException
e
)
{
// Custom version don't need to receive updates
magiskVersion
=
Double
.
POSITIVE_INFINITY
;
Global
.
Info
.
magiskVersion
=
Double
.
POSITIVE_INFINITY
;
}
}
}
...
...
@@ -189,10 +182,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
checkMagiskInfo
();
if
(
magiskVersion
<
0
)
{
if
(
Global
.
Info
.
magiskVersion
<
0
)
{
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
}
else
{
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
magiskVersionString
));
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
Global
.
Info
.
magiskVersionString
));
}
if
(
Shell
.
rootStatus
==
1
)
{
...
...
@@ -222,21 +215,21 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
private
void
updateCheckUI
()
{
int
image
,
color
;
if
(
remoteMagiskVersion
<
0
)
{
if
(
Global
.
Info
.
remoteMagiskVersion
<
0
)
{
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_help
;
magiskUpdateText
.
setText
(
R
.
string
.
cannot_check_updates
);
}
else
if
(
remoteMagiskVersion
>
magiskVersion
)
{
}
else
if
(
Global
.
Info
.
remoteMagiskVersion
>
Global
.
Info
.
magiskVersion
)
{
color
=
colorInfo
;
image
=
R
.
drawable
.
ic_update
;
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
magisk_update_available
,
remoteMagiskVersion
));
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
magisk_update_available
,
Global
.
Info
.
remoteMagiskVersion
));
}
else
{
color
=
colorOK
;
image
=
R
.
drawable
.
ic_check_circle
;
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
up_to_date
,
getString
(
R
.
string
.
magisk
)));
}
if
(
magiskVersion
<
0
)
{
if
(
Global
.
Info
.
magiskVersion
<
0
)
{
color
=
colorBad
;
image
=
R
.
drawable
.
ic_cancel
;
}
...
...
@@ -250,7 +243,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
updateMagisk
=
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
R
.
string
.
magisk_update_title
)
.
setMessage
(
getString
(
R
.
string
.
magisk_update_message
,
remoteMagiskVersion
))
.
setMessage
(
getString
(
R
.
string
.
magisk_update_message
,
Global
.
Info
.
remoteMagiskVersion
))
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
goto_install
,
(
dialogInterface
,
i
)
->
{
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
...
...
@@ -261,12 +254,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
}
catch
(
IllegalStateException
ignored
)
{}
})
.
setNeutralButton
(
R
.
string
.
check_release_notes
,
(
dialog
,
which
)
->
{
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
releaseNoteLink
)));
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Global
.
Info
.
releaseNoteLink
)));
})
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
create
();
if
(
magiskVersion
<
remoteMagiskVersion
&&
Shell
.
rootAccess
())
{
if
(
Global
.
Info
.
magiskVersion
<
Global
.
Info
.
remoteMagiskVersion
&&
Shell
.
rootAccess
())
{
magiskStatusContainer
.
setOnClickListener
(
view
->
updateMagisk
.
show
());
if
(!
noDialog
)
{
noDialog
=
true
;
...
...
@@ -278,7 +271,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
private
void
updateSafetyNetUI
()
{
int
image
,
color
;
safetyNetProgress
.
setVisibility
(
View
.
GONE
);
switch
(
SNCheckResult
)
{
switch
(
Global
.
Info
.
SNCheckResult
)
{
case
-
3
:
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_help
;
...
...
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
ad16a6fc
...
...
@@ -24,7 +24,7 @@ public class Module extends BaseModule {
if
(
mName
==
null
)
mName
=
mId
;
Logger
.
dev
(
"Creating
Module
, id: "
+
mId
);
Logger
.
dev
(
"Creating
Data
, id: "
+
mId
);
mEnable
=
!
Utils
.
itemExist
(
mDisableFile
);
mRemove
=
Utils
.
itemExist
(
mRemoveFile
);
...
...
app/src/main/java/com/topjohnwu/magisk/
utils
/ModuleHelper.java
→
app/src/main/java/com/topjohnwu/magisk/
module
/ModuleHelper.java
View file @
ad16a6fc
package
com
.
topjohnwu
.
magisk
.
utils
;
package
com
.
topjohnwu
.
magisk
.
module
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.support.annotation.NonNull
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.module.BaseModule
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.Global
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
import
com.topjohnwu.magisk.utils.WebService
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
...
...
@@ -17,42 +18,36 @@ import org.json.JSONObject;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
public
class
ModuleHelper
{
private
static
final
String
MAGISK_PATH
=
"/magisk"
;
public
static
final
String
FILE_KEY
=
"RepoMap"
;
private
static
final
String
REPO_KEY
=
"repomap"
;
public
static
final
String
VERSION_KEY
=
"version"
;
public
static
final
String
ETAG_KEY
=
"ETag"
;
private
static
final
int
DATABASE_VER
=
1
;
private
static
ValueSortedMap
<
String
,
Repo
>
repoMap
=
new
ValueSortedMap
<>();
private
static
ValueSortedMap
<
String
,
Module
>
moduleMap
=
new
ValueSortedMap
<>();
private
static
final
String
MAGISK_PATH
=
"/magisk"
;
private
static
final
int
GSON_DB_VER
=
1
;
private
static
final
String
ETAG_KEY
=
"ETag"
;
private
static
final
String
VERSION_KEY
=
"version"
;
private
static
final
String
REPO_KEY
=
"repomap"
;
private
static
final
String
FILE_KEY
=
"RepoMap"
;
public
static
void
createModuleMap
()
{
Logger
.
dev
(
"ModuleHelper: Loading modules"
);
moduleMap
.
clear
();
Global
.
Data
.
moduleMap
.
clear
();
for
(
String
path
:
Utils
.
getModList
(
MAGISK_PATH
))
{
Logger
.
dev
(
"ModuleHelper: Adding modules from "
+
path
);
Module
module
;
try
{
module
=
new
Module
(
path
);
moduleMap
.
put
(
module
.
getId
(),
module
);
Global
.
Data
.
moduleMap
.
put
(
module
.
getId
(),
module
);
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
Logger
.
dev
(
"ModuleHelper:
Module
load done"
);
Logger
.
dev
(
"ModuleHelper:
Data
load done"
);
}
public
static
void
createRepoMap
(
Context
context
)
{
...
...
@@ -60,13 +55,13 @@ public class ModuleHelper {
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
FILE_KEY
,
Context
.
MODE_PRIVATE
);
repoMap
.
clear
();
Global
.
Data
.
repoMap
.
clear
();
Gson
gson
=
new
Gson
();
String
jsonString
;
int
cachedVersion
=
prefs
.
getInt
(
VERSION_KEY
,
0
);
if
(
cachedVersion
!=
DATABASE
_VER
)
{
if
(
cachedVersion
!=
GSON_DB
_VER
)
{
// Ignore incompatible cached database
jsonString
=
null
;
}
else
{
...
...
@@ -123,7 +118,7 @@ public class ModuleHelper {
repo
.
update
(
updatedDate
);
}
if
(
repo
.
getId
()
!=
null
)
{
repoMap
.
put
(
id
,
repo
);
Global
.
Data
.
repoMap
.
put
(
id
,
repo
);
}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
...
...
@@ -133,12 +128,12 @@ public class ModuleHelper {
}
else
{
// Use cached if no internet or no updates
Logger
.
dev
(
"ModuleHelper: No updates, use cached"
);
repoMap
.
putAll
(
cached
);
Global
.
Data
.
repoMap
.
putAll
(
cached
);
}
prefs
.
edit
()
.
putInt
(
VERSION_KEY
,
DATABASE
_VER
)
.
putString
(
REPO_KEY
,
gson
.
toJson
(
repoMap
))
.
putInt
(
VERSION_KEY
,
GSON_DB
_VER
)
.
putString
(
REPO_KEY
,
gson
.
toJson
(
Global
.
Data
.
repoMap
))
.
putString
(
ETAG_KEY
,
etag
)
.
apply
();
...
...
@@ -147,15 +142,15 @@ public class ModuleHelper {
public
static
void
getModuleList
(
List
<
Module
>
moduleList
)
{
moduleList
.
clear
();
moduleList
.
addAll
(
moduleMap
.
values
());
moduleList
.
addAll
(
Global
.
Data
.
moduleMap
.
values
());
}
public
static
void
getRepoLists
(
List
<
Repo
>
update
,
List
<
Repo
>
installed
,
List
<
Repo
>
others
)
{
update
.
clear
();
installed
.
clear
();
others
.
clear
();
for
(
Repo
repo
:
repoMap
.
values
())
{
Module
module
=
moduleMap
.
get
(
repo
.
getId
());
for
(
Repo
repo
:
Global
.
Data
.
repoMap
.
values
())
{
Module
module
=
Global
.
Data
.
moduleMap
.
get
(
repo
.
getId
());
if
(
module
!=
null
)
{
if
(
repo
.
getVersionCode
()
>
module
.
getVersionCode
())
{
update
.
add
(
repo
);
...
...
@@ -168,36 +163,4 @@ public class ModuleHelper {
}
}
private
static
class
ValueSortedMap
<
K
,
V
extends
Comparable
<?
super
V
>>
extends
HashMap
<
K
,
V
>
{
private
List
<
V
>
sorted
=
new
ArrayList
<>();
@NonNull
@Override
public
Collection
<
V
>
values
()
{
if
(
sorted
.
isEmpty
())
{
sorted
.
addAll
(
super
.
values
());
Collections
.
sort
(
sorted
);
}
return
sorted
;
}
@Override
public
V
put
(
K
key
,
V
value
)
{
sorted
.
clear
();
return
super
.
put
(
key
,
value
);
}
@Override
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
m
)
{
sorted
.
clear
();
super
.
putAll
(
m
);
}
@Override
public
V
remove
(
Object
key
)
{
sorted
.
clear
();
return
super
.
remove
(
key
);
}
}
}
app/src/main/java/com/topjohnwu/magisk/receivers/MagiskDlReceiver.java
View file @
ad16a6fc
...
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.receivers;
import
android.net.Uri
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.
StatusFragment
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
...
...
@@ -56,7 +56,7 @@ public class MagiskDlReceiver extends DownloadReceiver {
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
StatusFragment
.
remoteMagiskVersion
));
+
String
.
valueOf
(
Global
.
Info
.
remoteMagiskVersion
));
return
null
;
}
}.
exec
();
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
ad16a6fc
...
...
@@ -28,6 +28,7 @@ import butterknife.ButterKnife;
public
class
SuRequestActivity
extends
AppCompatActivity
{
private
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
private
final
static
int
SU_PROTOCOL_PARAM_MAX
=
20
;
private
final
static
int
SU_PROTOCOL_NAME_MAX
=
20
;
private
final
static
int
SU_PROTOCOL_VALUE_MAX
=
256
;
...
...
@@ -49,8 +50,6 @@ public class SuRequestActivity extends AppCompatActivity {
private
String
appName
,
packageName
;
private
CountDownTimer
timer
;
private
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
ad16a6fc
...
...
@@ -11,12 +11,10 @@ import android.provider.OpenableColumns;
import
android.util.Log
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.
InstallFragment
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.MagiskHideFragment
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.StatusFragment
;
import
com.topjohnwu.magisk.module.ModuleHelper
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -60,16 +58,16 @@ public class Async {
try
{
JSONObject
json
=
new
JSONObject
(
jsonStr
);
JSONObject
magisk
=
json
.
getJSONObject
(
"magisk"
);
StatusFragment
.
remoteMagiskVersion
=
magisk
.
getDouble
(
"versionCode"
);
StatusFragment
.
magiskLink
=
magisk
.
getString
(
"link"
);
StatusFragment
.
releaseNoteLink
=
magisk
.
getString
(
"note"
);
Global
.
Info
.
remoteMagiskVersion
=
magisk
.
getDouble
(
"versionCode"
);
Global
.
Info
.
magiskLink
=
magisk
.
getString
(
"link"
);
Global
.
Info
.
releaseNoteLink
=
magisk
.
getString
(
"note"
);
}
catch
(
JSONException
ignored
)
{}
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
StatusFragment
.
updateCheckDone
.
trigger
();
Global
.
Events
.
updateCheckDone
.
trigger
();
}
}
...
...
@@ -77,8 +75,8 @@ public class Async {
new
SafetyNetHelper
(
context
)
{
@Override
public
void
handleResults
(
int
i
)
{
StatusFragment
.
SNCheckResult
=
i
;
StatusFragment
.
safetyNetDone
.
trigger
();
Global
.
Info
.
SNCheckResult
=
i
;
Global
.
Events
.
safetyNetDone
.
trigger
();
}
}.
requestTest
();
}
...
...
@@ -93,7 +91,7 @@ public class Async {
@Override
protected
void
onPostExecute
(
Void
v
)
{
ModulesFragment
.
moduleLoadDone
.
trigger
();
Global
.
Events
.
moduleLoadDone
.
trigger
();
}
}
...
...
@@ -113,7 +111,7 @@ public class Async {
@Override
protected
void
onPostExecute
(
Void
v
)
{
ReposFragment
.
repoLoadDone
.
trigger
();
Global
.
Events
.
repoLoadDone
.
trigger
();
}
}
...
...
@@ -130,7 +128,7 @@ public class Async {
List
<
ApplicationInfo
>
listApps
=
pm
.
getInstalledApplications
(
PackageManager
.
GET_META_DATA
);
for
(
Iterator
<
ApplicationInfo
>
i
=
listApps
.
iterator
();
i
.
hasNext
();
)
{
ApplicationInfo
info
=
i
.
next
();
if
(
MagiskHideFragment
.
BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
if
(
MagiskHideFragment
.
HIDE
BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
i
.
remove
();
}
Collections
.
sort
(
listApps
,
(
a
,
b
)
->
a
.
loadLabel
(
pm
).
toString
().
toLowerCase
()
...
...
@@ -141,7 +139,7 @@ public class Async {
@Override
protected
void
onPostExecute
(
Result
result
)
{
MagiskHideFragment
.
packageLoadDone
.
trigger
(
result
);
Global
.
Events
.
packageLoadDone
.
trigger
(
result
);
}
public
static
class
Result
{
...
...
@@ -289,7 +287,7 @@ public class Async {
}
protected
void
onSuccess
()
{
StatusFragment
.
updateCheckDone
.
trigger
();
Global
.
Events
.
updateCheckDone
.
trigger
();
new
LoadModules
().
exec
();
Utils
.
getAlertDialogBuilder
(
mContext
)
...
...
@@ -324,9 +322,9 @@ public class Async {
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
if
(
Shell
.
rootAccess
())
{
InstallFragment
.
blockList
=
Shell
.
su
(
"ls /dev/block | grep mmc"
);
if
(
InstallFragment
.
bootBlock
==
null
)
{
InstallFragment
.
bootBlock
=
Utils
.
detectBootImage
();
Global
.
Data
.
blockList
=
Shell
.
su
(
"ls /dev/block | grep mmc"
);
if
(
Global
.
Info
.
bootBlock
==
null
)
{
Global
.
Info
.
bootBlock
=
Utils
.
detectBootImage
();
}
}
return
null
;
...
...
@@ -334,7 +332,7 @@ public class Async {
@Override
protected
void
onPostExecute
(
Void
aVoid
)
{
InstallFragment
.
blockDetectionDone
.
trigger
();
Global
.
Events
.
blockDetectionDone
.
trigger
();
}
}
}
app/src/main/java/com/topjohnwu/magisk/FABBehavior.java
→
app/src/main/java/com/topjohnwu/magisk/
utils/
FABBehavior.java
View file @
ad16a6fc
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.content.Context
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ValueSortedMap.java
0 → 100644
View file @
ad16a6fc
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.support.annotation.NonNull
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ValueSortedMap
<
K
,
V
extends
Comparable
<?
super
V
>>
extends
HashMap
<
K
,
V
>
{
private
List
<
V
>
sorted
=
new
ArrayList
<>();
@NonNull
@Override
public
Collection
<
V
>
values
()
{
if
(
sorted
.
isEmpty
())
{
sorted
.
addAll
(
super
.
values
());
Collections
.
sort
(
sorted
);
}
return
sorted
;
}
@Override
public
V
put
(
K
key
,
V
value
)
{
sorted
.
clear
();
return
super
.
put
(
key
,
value
);
}
@Override
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
m
)
{
sorted
.
clear
();
super
.
putAll
(
m
);
}
@Override
public
V
remove
(
Object
key
)
{
sorted
.
clear
();
return
super
.
remove
(
key
);
}
}
app/src/main/res/layout/modules_fragment.xml
View file @
ad16a6fc
...
...
@@ -47,7 +47,7 @@
android:layout_gravity=
"bottom|center_horizontal"
android:layout_marginEnd=
"113dp"
android:layout_marginBottom=
"10dp"
app:layout_behavior=
".FABBehavior"
app:layout_behavior=
".
utils.
FABBehavior"
fab:menu_fab_size=
"normal"
fab:menu_showShadow=
"true"
fab:menu_shadowColor=
"#66000000"
...
...
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