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
a747fdd2
Commit
a747fdd2
authored
Jul 28, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Organize dialog code
parent
27851bde
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
403 additions
and
334 deletions
+403
-334
MagiskFragment.java
app/src/full/java/com/topjohnwu/magisk/MagiskFragment.java
+18
-12
PolicyAdapter.java
...ull/java/com/topjohnwu/magisk/adapters/PolicyAdapter.java
+2
-2
ReposAdapter.java
...full/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
+2
-2
CheckUpdates.java
...c/full/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java
+3
-3
CustomAlertDialog.java
...va/com/topjohnwu/magisk/components/CustomAlertDialog.java
+8
-15
EnvFixDialog.java
...ll/java/com/topjohnwu/magisk/components/EnvFixDialog.java
+33
-0
FlavorActivity.java
.../java/com/topjohnwu/magisk/components/FlavorActivity.java
+19
-1
InstallMethodDialog.java
.../com/topjohnwu/magisk/components/InstallMethodDialog.java
+101
-0
MagiskInstallDialog.java
.../com/topjohnwu/magisk/components/MagiskInstallDialog.java
+53
-0
ManagerInstallDialog.java
...com/topjohnwu/magisk/components/ManagerInstallDialog.java
+38
-0
UninstallDialog.java
...java/com/topjohnwu/magisk/components/UninstallDialog.java
+40
-0
OnBootService.java
...ull/java/com/topjohnwu/magisk/services/OnBootService.java
+2
-2
NotificationMgr.java
...full/java/com/topjohnwu/magisk/utils/NotificationMgr.java
+84
-0
ShowUI.java
app/src/full/java/com/topjohnwu/magisk/utils/ShowUI.java
+0
-278
Activity.java
...c/main/java/com/topjohnwu/magisk/components/Activity.java
+0
-19
No files found.
app/src/full/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
a747fdd2
...
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk;
import
android.app.NotificationManager
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.StringRes
;
import
android.support.v4.widget.SwipeRefreshLayout
;
...
...
@@ -20,12 +21,16 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.asyncs.CheckSafetyNet
;
import
com.topjohnwu.magisk.asyncs.CheckUpdates
;
import
com.topjohnwu.magisk.components.AlertDialogBuilder
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.CustomAlertDialog
;
import
com.topjohnwu.magisk.components.EnvFixDialog
;
import
com.topjohnwu.magisk.components.ExpandableView
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.MagiskInstallDialog
;
import
com.topjohnwu.magisk.components.ManagerInstallDialog
;
import
com.topjohnwu.magisk.components.UninstallDialog
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.ISafetyNetHelper
;
import
com.topjohnwu.magisk.utils.ShowUI
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
...
...
@@ -84,11 +89,11 @@ public class MagiskFragment extends Fragment
safetyNetProgress
.
setVisibility
(
View
.
VISIBLE
);
safetyNetRefreshIcon
.
setVisibility
(
View
.
GONE
);
safetyNetStatusText
.
setText
(
R
.
string
.
checking_safetyNet_status
);
new
CheckSafetyNet
(
get
Activity
()).
exec
();
new
CheckSafetyNet
(
require
Activity
()).
exec
();
collapse
();
};
if
(!
TextUtils
.
equals
(
mm
.
getPackageName
(),
Const
.
ORIG_PKG_NAME
))
{
new
AlertDialogBuilder
(
get
Activity
())
new
CustomAlertDialog
(
require
Activity
())
.
setTitle
(
R
.
string
.
cannot_check_sn_title
)
.
setMessage
(
R
.
string
.
cannot_check_sn_notice
)
.
setCancelable
(
true
)
...
...
@@ -96,7 +101,7 @@ public class MagiskFragment extends Fragment
.
show
();
}
else
if
(!
CheckSafetyNet
.
dexPath
.
exists
())
{
// Show dialog
new
AlertDialogBuilder
(
get
Activity
())
new
CustomAlertDialog
(
require
Activity
())
.
setTitle
(
R
.
string
.
proprietary_title
)
.
setMessage
(
R
.
string
.
proprietary_notice
)
.
setCancelable
(
true
)
...
...
@@ -115,25 +120,26 @@ public class MagiskFragment extends Fragment
// Show Manager update first
if
(
mm
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
ShowUI
.
managerInstallDialog
(
getActivity
()
);
new
ManagerInstallDialog
((
Activity
)
requireActivity
()).
show
(
);
return
;
}
((
NotificationManager
)
mm
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)).
cancelAll
();
ShowUI
.
magiskInstallDialog
(
getActivity
()
);
new
MagiskInstallDialog
((
Activity
)
getActivity
()).
show
(
);
}
@OnClick
(
R
.
id
.
uninstall_button
)
void
uninstall
()
{
ShowUI
.
uninstallDialog
(
getActivity
()
);
new
UninstallDialog
(
requireActivity
()).
show
(
);
}
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_magisk
,
container
,
false
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
get
Activity
().
setTitle
(
R
.
string
.
magisk
);
require
Activity
().
setTitle
(
R
.
string
.
magisk
);
mm
=
getApplication
();
...
...
@@ -204,7 +210,7 @@ public class MagiskFragment extends Fragment
}
private
void
updateUI
()
{
((
MainActivity
)
get
Activity
()).
checkHideSection
();
((
MainActivity
)
require
Activity
()).
checkHideSection
();
boolean
hasNetwork
=
Utils
.
checkNetworkStatus
();
boolean
hasRoot
=
Shell
.
rootAccess
();
...
...
@@ -266,7 +272,7 @@ public class MagiskFragment extends Fragment
install
();
}
else
if
(
mm
.
remoteMagiskVersionCode
>=
Const
.
MAGISK_VER
.
FIX_ENV
&&
!
ShellUtils
.
fastCmdResult
(
"env_check"
))
{
ShowUI
.
envFixDialog
(
getActivity
()
);
new
EnvFixDialog
(
requireActivity
()).
show
(
);
}
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/adapters/PolicyAdapter.java
View file @
a747fdd2
...
...
@@ -12,7 +12,7 @@ import android.widget.Switch;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.components.
AlertDialogBuilder
;
import
com.topjohnwu.magisk.components.
CustomAlertDialog
;
import
com.topjohnwu.magisk.components.ExpandableView
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.container.Policy
;
...
...
@@ -93,7 +93,7 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
dbHelper
.
updatePolicy
(
policy
);
}
});
holder
.
delete
.
setOnClickListener
(
v
->
new
AlertDialogBuilder
((
Activity
)
v
.
getContext
())
holder
.
delete
.
setOnClickListener
(
v
->
new
CustomAlertDialog
((
Activity
)
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
)
->
{
...
...
app/src/full/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
View file @
a747fdd2
...
...
@@ -16,7 +16,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.MarkDownWindow
;
import
com.topjohnwu.magisk.asyncs.ProcessRepoZip
;
import
com.topjohnwu.magisk.components.
AlertDialogBuilder
;
import
com.topjohnwu.magisk.components.
CustomAlertDialog
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
...
...
@@ -102,7 +102,7 @@ public class ReposAdapter extends SectionedAdapter<ReposAdapter.SectionHolder, R
holder
.
downloadImage
.
setOnClickListener
(
v
->
{
String
filename
=
repo
.
getName
()
+
"-"
+
repo
.
getVersion
()
+
".zip"
;
new
AlertDialogBuilder
((
Activity
)
context
)
new
CustomAlertDialog
((
Activity
)
context
)
.
setTitle
(
context
.
getString
(
R
.
string
.
repo_install_title
,
repo
.
getName
()))
.
setMessage
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
filename
))
.
setCancelable
(
true
)
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java
View file @
a747fdd2
...
...
@@ -3,7 +3,7 @@ package com.topjohnwu.magisk.asyncs;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.
ShowUI
;
import
com.topjohnwu.magisk.utils.
NotificationMgr
;
import
com.topjohnwu.magisk.utils.WebService
;
import
org.json.JSONException
;
...
...
@@ -59,9 +59,9 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
MagiskManager
mm
=
MagiskManager
.
get
();
if
(
showNotification
)
{
if
(
BuildConfig
.
VERSION_CODE
<
mm
.
remoteManagerVersionCode
)
{
ShowUI
.
managerUpdateNotification
();
NotificationMgr
.
managerUpdate
();
}
else
if
(
mm
.
magiskVersionCode
<
mm
.
remoteMagiskVersionCode
)
{
ShowUI
.
magiskUpdateNotification
();
NotificationMgr
.
magiskUpdate
();
}
}
mm
.
updateCheckDone
.
publish
();
...
...
app/src/full/java/com/topjohnwu/magisk/components/
AlertDialogBuilder
.java
→
app/src/full/java/com/topjohnwu/magisk/components/
CustomAlertDialog
.java
View file @
a747fdd2
...
...
@@ -18,7 +18,7 @@ import com.topjohnwu.magisk.R;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
public
class
AlertDialogBuilder
extends
AlertDialog
.
Builder
{
public
class
CustomAlertDialog
extends
AlertDialog
.
Builder
{
@BindView
(
R
.
id
.
button_panel
)
LinearLayout
buttons
;
@BindView
(
R
.
id
.
message_panel
)
LinearLayout
messagePanel
;
...
...
@@ -34,17 +34,7 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
private
AlertDialog
dialog
;
public
AlertDialogBuilder
(
@NonNull
Activity
context
)
{
super
(
context
);
setup
();
}
public
AlertDialogBuilder
(
@NonNull
Activity
context
,
@StyleRes
int
themeResId
)
{
super
(
context
,
themeResId
);
setup
();
}
private
void
setup
()
{
{
View
v
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
alert_dialog
,
null
);
ButterKnife
.
bind
(
this
,
v
);
super
.
setView
(
v
);
...
...
@@ -55,9 +45,12 @@ public class AlertDialogBuilder extends AlertDialog.Builder {
messagePanel
.
setVisibility
(
View
.
GONE
);
}
@Override
public
AlertDialog
.
Builder
setTitle
(
int
titleId
)
{
return
super
.
setTitle
(
titleId
);
public
CustomAlertDialog
(
@NonNull
Activity
context
)
{
super
(
context
);
}
public
CustomAlertDialog
(
@NonNull
Activity
context
,
@StyleRes
int
themeResId
)
{
super
(
context
,
themeResId
);
}
@Override
...
...
app/src/full/java/com/topjohnwu/magisk/components/EnvFixDialog.java
0 → 100644
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.support.annotation.NonNull
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
EnvFixDialog
extends
CustomAlertDialog
{
public
EnvFixDialog
(
@NonNull
Activity
activity
)
{
super
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
mm
.
remoteMagiskVersionString
,
mm
.
remoteMagiskVersionCode
);
setTitle
(
R
.
string
.
env_fix_title
);
setMessage
(
R
.
string
.
env_fix_msg
);
setCancelable
(
true
);
setPositiveButton
(
R
.
string
.
yes
,
(
d
,
i
)
->
Utils
.
dlAndReceive
(
activity
,
new
DownloadReceiver
()
{
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
new
InstallMagisk
(
activity
,
uri
).
exec
();
}
},
mm
.
magiskLink
,
filename
));
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
}
}
app/src/full/java/com/topjohnwu/magisk/components/FlavorActivity.java
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.StyleRes
;
...
...
@@ -12,6 +13,8 @@ import com.topjohnwu.magisk.utils.Topic;
public
abstract
class
FlavorActivity
extends
AppCompatActivity
{
private
ActivityResultListener
activityResultListener
;
@StyleRes
public
int
getDarkTheme
()
{
return
-
1
;
...
...
@@ -27,7 +30,6 @@ public abstract class FlavorActivity extends AppCompatActivity {
if
(
this
instanceof
Topic
.
Subscriber
)
{
((
Topic
.
Subscriber
)
this
).
subscribeTopics
();
}
if
(
getMagiskManager
().
isDarkTheme
&&
getDarkTheme
()
!=
-
1
)
{
setTheme
(
getDarkTheme
());
}
...
...
@@ -54,4 +56,20 @@ public abstract class FlavorActivity extends AppCompatActivity {
setFinishOnTouchOutside
(
true
);
}
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
activityResultListener
!=
null
)
activityResultListener
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
activityResultListener
=
null
;
}
public
void
startActivityForResult
(
Intent
intent
,
int
requestCode
,
ActivityResultListener
listener
)
{
activityResultListener
=
listener
;
super
.
startActivityForResult
(
intent
,
requestCode
);
}
public
interface
ActivityResultListener
{
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
);
}
}
app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java
0 → 100644
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.app.AlertDialog
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.List
;
class
InstallMethodDialog
extends
AlertDialog
.
Builder
{
InstallMethodDialog
(
Activity
activity
,
List
<
String
>
options
,
String
filename
)
{
super
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
setTitle
(
R
.
string
.
select_method
);
setItems
(
options
.
toArray
(
new
String
[
0
]),
(
dialog
,
idx
)
->
{
DownloadReceiver
receiver
=
null
;
switch
(
idx
)
{
case
1
:
if
(
mm
.
remoteMagiskVersionCode
<
1400
)
{
SnackbarMaker
.
make
(
activity
,
R
.
string
.
no_boot_file_patch_support
,
Snackbar
.
LENGTH_LONG
).
show
();
return
;
}
MagiskManager
.
toast
(
R
.
string
.
boot_file_patch_msg
,
Toast
.
LENGTH_LONG
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
intent
.
setType
(
"*/*"
);
activity
.
startActivityForResult
(
intent
,
Const
.
ID
.
SELECT_BOOT
,
(
requestCode
,
resultCode
,
data
)
->
{
if
(
requestCode
==
Const
.
ID
.
SELECT_BOOT
&&
resultCode
==
Activity
.
RESULT_OK
&&
data
!=
null
)
{
Utils
.
dlAndReceive
(
activity
,
new
SelectBoot
(
data
),
mm
.
magiskLink
,
filename
);
}
});
return
;
case
0
:
receiver
=
new
DownloadReceiver
()
{
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
SnackbarMaker
.
showUri
(
activity
,
uri
);
}
};
break
;
case
2
:
receiver
=
new
DownloadReceiver
()
{
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_MAGISK
);
context
.
startActivity
(
intent
);
}
};
break
;
case
3
:
receiver
=
new
DownloadReceiver
()
{
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_SECOND_SLOT
);
context
.
startActivity
(
intent
);
}
};
default
:
}
Utils
.
dlAndReceive
(
activity
,
receiver
,
mm
.
magiskLink
,
filename
);
});
}
private
class
SelectBoot
extends
DownloadReceiver
{
private
Intent
data
;
public
SelectBoot
(
Intent
data
)
{
this
.
data
=
data
;
}
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
);
intent
.
setData
(
uri
)
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
putExtra
(
Const
.
Key
.
FLASH_SET_BOOT
,
data
.
getData
())
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
PATCH_BOOT
);
context
.
startActivity
(
intent
);
}
}
}
app/src/full/java/com/topjohnwu/magisk/components/MagiskInstallDialog.java
0 → 100644
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.MarkDownWindow
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
MagiskInstallDialog
extends
CustomAlertDialog
{
public
MagiskInstallDialog
(
Activity
activity
)
{
super
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
mm
.
remoteMagiskVersionString
,
mm
.
remoteMagiskVersionCode
);
setTitle
(
mm
.
getString
(
R
.
string
.
repo_install_title
,
mm
.
getString
(
R
.
string
.
magisk
)));
setMessage
(
mm
.
getString
(
R
.
string
.
repo_install_msg
,
filename
));
setCancelable
(
true
);
setPositiveButton
(
R
.
string
.
install
,
(
d
,
i
)
->
{
List
<
String
>
options
=
new
ArrayList
<>();
options
.
add
(
mm
.
getString
(
R
.
string
.
download_zip_only
));
options
.
add
(
mm
.
getString
(
R
.
string
.
patch_boot_file
));
if
(
Shell
.
rootAccess
())
{
options
.
add
(
mm
.
getString
(
R
.
string
.
direct_install
));
}
String
s
=
ShellUtils
.
fastCmd
(
"grep_prop ro.build.ab_update"
);
if
(!
s
.
isEmpty
()
&&
Boolean
.
parseBoolean
(
s
))
{
options
.
add
(
mm
.
getString
(
R
.
string
.
install_second_slot
));
}
new
InstallMethodDialog
(
activity
,
options
,
filename
).
show
();
});
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
if
(!
TextUtils
.
isEmpty
(
mm
.
magiskNoteLink
))
{
setNeutralButton
(
R
.
string
.
release_notes
,
(
d
,
i
)
->
{
if
(
mm
.
magiskNoteLink
.
contains
(
"forum.xda-developers"
))
{
// Open forum links in browser
Intent
openLink
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
mm
.
magiskNoteLink
));
openLink
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mm
.
startActivity
(
openLink
);
}
else
{
new
MarkDownWindow
(
activity
,
null
,
mm
.
magiskNoteLink
).
exec
();
}
});
}
}
}
app/src/full/java/com/topjohnwu/magisk/components/ManagerInstallDialog.java
0 → 100644
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.Manifest
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.MarkDownWindow
;
import
com.topjohnwu.magisk.receivers.ManagerUpdate
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
ManagerInstallDialog
extends
CustomAlertDialog
{
public
ManagerInstallDialog
(
@NonNull
Activity
activity
)
{
super
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
String
filename
=
Utils
.
fmt
(
"MagiskManager-v%s(%d).apk"
,
mm
.
remoteManagerVersionString
,
mm
.
remoteManagerVersionCode
);
setTitle
(
mm
.
getString
(
R
.
string
.
repo_install_title
,
mm
.
getString
(
R
.
string
.
app_name
)));
setMessage
(
mm
.
getString
(
R
.
string
.
repo_install_msg
,
filename
));
setCancelable
(
true
);
setPositiveButton
(
R
.
string
.
install
,
(
d
,
i
)
->
activity
.
runWithPermission
(
new
String
[]
{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
},
()
->
{
Intent
intent
=
new
Intent
(
mm
,
ManagerUpdate
.
class
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_LINK
,
mm
.
managerLink
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_FILENAME
,
filename
);
mm
.
sendBroadcast
(
intent
);
}))
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
if
(!
TextUtils
.
isEmpty
(
mm
.
managerNoteLink
))
{
setNeutralButton
(
R
.
string
.
app_changelog
,
(
d
,
i
)
->
new
MarkDownWindow
(
activity
,
null
,
mm
.
managerNoteLink
).
exec
());
}
}
}
app/src/full/java/com/topjohnwu/magisk/components/UninstallDialog.java
0 → 100644
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.RestoreImages
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
UninstallDialog
extends
CustomAlertDialog
{
public
UninstallDialog
(
@NonNull
Activity
activity
)
{
super
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
setTitle
(
R
.
string
.
uninstall_magisk_title
);
setMessage
(
R
.
string
.
uninstall_magisk_msg
);
setNeutralButton
(
R
.
string
.
restore_img
,
(
d
,
i
)
->
new
RestoreImages
(
activity
).
exec
());
if
(!
TextUtils
.
isEmpty
(
mm
.
uninstallerLink
))
{
setPositiveButton
(
R
.
string
.
complete_uninstall
,
(
d
,
i
)
->
Utils
.
dlAndReceive
(
activity
,
new
DownloadReceiver
()
{
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
)
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
setData
(
uri
)
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
UNINSTALL
);
context
.
startActivity
(
intent
);
}
},
mm
.
uninstallerLink
,
"magisk-uninstaller.zip"
));
}
}
}
app/src/full/java/com/topjohnwu/magisk/services/OnBootService.java
View file @
a747fdd2
...
...
@@ -6,7 +6,7 @@ import android.support.annotation.NonNull;
import
android.support.v4.app.JobIntentService
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.
ShowUI
;
import
com.topjohnwu.magisk.utils.
NotificationMgr
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
...
...
@@ -28,6 +28,6 @@ public class OnBootService extends JobIntentService {
Shell
shell
=
Shell
.
newInstance
();
if
(
shell
.
getStatus
()
>=
Shell
.
ROOT_SHELL
&&
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
shell
,
"mm_patch_dtbo"
)))
ShowUI
.
dtboPatchedNotification
();
NotificationMgr
.
dtboPatched
();
}
}
app/src/full/java/com/topjohnwu/magisk/utils/NotificationMgr.java
0 → 100644
View file @
a747fdd2
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.TaskStackBuilder
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.SplashActivity
;
import
com.topjohnwu.magisk.receivers.ManagerUpdate
;
import
com.topjohnwu.magisk.receivers.RebootReceiver
;
public
class
NotificationMgr
{
public
static
void
magiskUpdate
()
{
MagiskManager
mm
=
MagiskManager
.
get
();
Intent
intent
=
new
Intent
(
mm
,
SplashActivity
.
class
);
intent
.
putExtra
(
Const
.
Key
.
OPEN_SECTION
,
"magisk"
);
TaskStackBuilder
stackBuilder
=
TaskStackBuilder
.
create
(
mm
);
stackBuilder
.
addParentStack
(
SplashActivity
.
class
);
stackBuilder
.
addNextIntent
(
intent
);
PendingIntent
pendingIntent
=
stackBuilder
.
getPendingIntent
(
Const
.
ID
.
MAGISK_UPDATE_NOTIFICATION_ID
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
mm
,
Const
.
ID
.
NOTIFICATION_CHANNEL
);
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk_outline
)
.
setContentTitle
(
mm
.
getString
(
R
.
string
.
magisk_update_title
))
.
setContentText
(
mm
.
getString
(
R
.
string
.
magisk_update_available
,
mm
.
remoteMagiskVersionString
))
.
setVibrate
(
new
long
[]{
0
,
100
,
100
,
100
})
.
setAutoCancel
(
true
)
.
setContentIntent
(
pendingIntent
);
NotificationManager
notificationManager
=
(
NotificationManager
)
mm
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
Const
.
ID
.
MAGISK_UPDATE_NOTIFICATION_ID
,
builder
.
build
());
}
public
static
void
managerUpdate
()
{
MagiskManager
mm
=
MagiskManager
.
get
();
String
filename
=
Utils
.
fmt
(
"MagiskManager-v%s(%d).apk"
,
mm
.
remoteManagerVersionString
,
mm
.
remoteManagerVersionCode
);
Intent
intent
=
new
Intent
(
mm
,
ManagerUpdate
.
class
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_LINK
,
mm
.
managerLink
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_FILENAME
,
filename
);
PendingIntent
pendingIntent
=
PendingIntent
.
getBroadcast
(
mm
,
Const
.
ID
.
APK_UPDATE_NOTIFICATION_ID
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
mm
,
Const
.
ID
.
NOTIFICATION_CHANNEL
);
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk_outline
)
.
setContentTitle
(
mm
.
getString
(
R
.
string
.
manager_update_title
))
.
setContentText
(
mm
.
getString
(
R
.
string
.
manager_download_install
))
.
setVibrate
(
new
long
[]{
0
,
100
,
100
,
100
})
.
setAutoCancel
(
true
)
.
setContentIntent
(
pendingIntent
);
NotificationManager
notificationManager
=
(
NotificationManager
)
mm
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
Const
.
ID
.
APK_UPDATE_NOTIFICATION_ID
,
builder
.
build
());
}
public
static
void
dtboPatched
()
{
MagiskManager
mm
=
MagiskManager
.
get
();
Intent
intent
=
new
Intent
(
mm
,
RebootReceiver
.
class
);
PendingIntent
pendingIntent
=
PendingIntent
.
getBroadcast
(
mm
,
Const
.
ID
.
DTBO_NOTIFICATION_ID
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
mm
,
Const
.
ID
.
NOTIFICATION_CHANNEL
);
builder
.
setSmallIcon
(
R
.
drawable
.
ic_magisk_outline
)
.
setContentTitle
(
mm
.
getString
(
R
.
string
.
dtbo_patched_title
))
.
setContentText
(
mm
.
getString
(
R
.
string
.
dtbo_patched_reboot
))
.
setVibrate
(
new
long
[]{
0
,
100
,
100
,
100
})
.
addAction
(
R
.
drawable
.
ic_refresh
,
mm
.
getString
(
R
.
string
.
reboot
),
pendingIntent
);
NotificationManager
notificationManager
=
(
NotificationManager
)
mm
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
notify
(
Const
.
ID
.
DTBO_NOTIFICATION_ID
,
builder
.
build
());
}
}
app/src/full/java/com/topjohnwu/magisk/utils/ShowUI.java
deleted
100644 → 0
View file @
27851bde
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/components/Activity.java
View file @
a747fdd2
...
...
@@ -17,8 +17,6 @@ public abstract class Activity extends FlavorActivity {
protected
static
Runnable
permissionGrantCallback
;
private
ActivityResultListener
activityResultListener
;
public
Activity
()
{
super
();
Configuration
configuration
=
new
Configuration
();
...
...
@@ -74,21 +72,4 @@ public abstract class Activity extends FlavorActivity {
}
permissionGrantCallback
=
null
;
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
activityResultListener
!=
null
)
activityResultListener
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
activityResultListener
=
null
;
}
public
void
startActivityForResult
(
Intent
intent
,
int
requestCode
,
ActivityResultListener
listener
)
{
activityResultListener
=
listener
;
super
.
startActivityForResult
(
intent
,
requestCode
);
}
public
interface
ActivityResultListener
{
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
);
}
}
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