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
0addbaa9
Commit
0addbaa9
authored
Sep 21, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor repo class and SharedPref
parent
baae3592
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
375 additions
and
444 deletions
+375
-444
ModulesAdapter.java
app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java
+4
-4
ReposAdapter.java
app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java
+13
-16
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+2
-9
WelcomeActivity.java
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
+1
-4
BaseModule.java
...src/main/java/com/topjohnwu/magisk/module/BaseModule.java
+5
-8
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+3
-2
Repo.java
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
+280
-232
RepoHelper.java
...src/main/java/com/topjohnwu/magisk/module/RepoHelper.java
+49
-156
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+8
-13
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+8
-0
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java
View file @
0addbaa9
...
...
@@ -85,8 +85,8 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
holder
.
description
.
setText
(
module
.
getDescription
());
holder
.
author
.
setText
(
module
.
getAuthor
());
String
logUrl
=
module
.
getmLogUrl
();
String
supportUrl
=
module
.
get
m
SupportUrl
();
String
donateUrl
=
module
.
get
m
DonateUrl
();
String
supportUrl
=
module
.
getSupportUrl
();
String
donateUrl
=
module
.
getDonateUrl
();
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
if
(
prefs
.
contains
(
"ignoreUpdateAlerts"
))
{
ignoreAlertUpdate
=
prefs
.
getBoolean
(
"ignoreUpdateAlerts"
,
false
);
...
...
@@ -140,10 +140,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
new
WebWindow
(
"Changelog"
,
module
.
getmLogUrl
(),
context
);
}
if
(
view
.
getId
()
==
holder
.
authorLink
.
getId
())
{
new
WebWindow
(
"Donate"
,
module
.
get
m
DonateUrl
(),
context
);
new
WebWindow
(
"Donate"
,
module
.
getDonateUrl
(),
context
);
}
if
(
view
.
getId
()
==
holder
.
supportLink
.
getId
())
{
new
WebWindow
(
"Support"
,
module
.
get
m
SupportUrl
(),
context
);
new
WebWindow
(
"Support"
,
module
.
getSupportUrl
(),
context
);
}
};
...
...
app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java
View file @
0addbaa9
...
...
@@ -92,9 +92,9 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
repo
=
mList
.
get
(
position
);
mHolder
=
holder
;
mDonateUrl
=
repo
.
get
m
DonateUrl
();
mSupportUrl
=
repo
.
get
m
SupportUrl
();
mLogUrl
=
repo
.
get
m
LogUrl
();
mDonateUrl
=
repo
.
getDonateUrl
();
mSupportUrl
=
repo
.
getSupportUrl
();
mLogUrl
=
repo
.
getLogUrl
();
mExpandedList
=
new
ArrayList
<>(
mList
.
size
());
for
(
int
i
=
0
;
i
<
mList
.
size
();
i
++)
{
mExpandedList
.
add
(
false
);
...
...
@@ -114,13 +114,10 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
}
mHolder
.
title
.
setText
(
titleString
);
mHolder
.
versionName
.
setText
(
repo
.
get
m
Version
());
mHolder
.
versionName
.
setText
(
repo
.
getVersion
());
mHolder
.
description
.
setText
(
repo
.
getDescription
());
String
authorString
=
this
.
context
.
getResources
().
getString
(
R
.
string
.
author
)
+
" "
+
repo
.
get
m
Author
();
String
authorString
=
this
.
context
.
getResources
().
getString
(
R
.
string
.
author
)
+
" "
+
repo
.
getAuthor
();
mHolder
.
author
.
setText
(
authorString
);
String
logUrl
=
repo
.
getmLogUrl
();
String
supportUrl
=
repo
.
getmSupportUrl
();
String
donateUrl
=
repo
.
getmDonateUrl
();
if
(
prefs
.
contains
(
"ignoreUpdateAlerts"
))
{
ignoreAlertUpdate
=
prefs
.
getBoolean
(
"ignoreUpdateAlerts"
,
false
);
}
...
...
@@ -136,7 +133,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
mHolder
.
updateStatus
.
setText
(
repo
.
canUpdate
()
?
this
.
context
.
getResources
().
getString
(
R
.
string
.
module_update_available
)
:
this
.
context
.
getResources
().
getString
(
R
.
string
.
module_up_to_date
));
}
Log
.
d
(
"Magisk"
,
"ReposAdapter: Setting up info "
+
repo
.
getId
()
+
" and "
+
repo
.
getDescription
()
+
" and "
+
repo
.
get
m
Version
());
Log
.
d
(
"Magisk"
,
"ReposAdapter: Setting up info "
+
repo
.
getId
()
+
" and "
+
repo
.
getDescription
()
+
" and "
+
repo
.
getVersion
());
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
mCanUpdate
=
prefs
.
getBoolean
(
"repo-canUpdate_"
+
repo
.
getId
(),
false
);
...
...
@@ -155,19 +152,19 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
}
};
String
filename
=
repo
.
getId
().
replace
(
" "
,
""
)
+
".zip"
;
Utils
.
downloadAndReceive
(
context
,
receiver
,
repo
.
get
m
ZipUrl
(),
filename
);
Utils
.
downloadAndReceive
(
context
,
receiver
,
repo
.
getZipUrl
(),
filename
);
}
else
{
Toast
.
makeText
(
context
,
repo
.
getId
()
+
" is already installed."
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
if
((
view
.
getId
()
==
mHolder
.
changeLog
.
getId
())
&&
(!
repo
.
get
m
LogUrl
().
equals
(
""
)))
{
new
WebWindow
(
"Changelog"
,
repo
.
get
m
LogUrl
(),
context
);
if
((
view
.
getId
()
==
mHolder
.
changeLog
.
getId
())
&&
(!
repo
.
getLogUrl
().
equals
(
""
)))
{
new
WebWindow
(
"Changelog"
,
repo
.
getLogUrl
(),
context
);
}
if
((
view
.
getId
()
==
mHolder
.
authorLink
.
getId
())
&&
(!
repo
.
get
m
SupportUrl
().
equals
(
""
)))
{
new
WebWindow
(
"Donate"
,
repo
.
get
m
DonateUrl
(),
context
);
if
((
view
.
getId
()
==
mHolder
.
authorLink
.
getId
())
&&
(!
repo
.
getSupportUrl
().
equals
(
""
)))
{
new
WebWindow
(
"Donate"
,
repo
.
getDonateUrl
(),
context
);
}
if
((
view
.
getId
()
==
mHolder
.
supportLink
.
getId
())
&&
(!
repo
.
get
m
SupportUrl
().
equals
(
""
)))
{
new
WebWindow
(
"Support"
,
repo
.
get
m
SupportUrl
(),
context
);
if
((
view
.
getId
()
==
mHolder
.
supportLink
.
getId
())
&&
(!
repo
.
getSupportUrl
().
equals
(
""
)))
{
new
WebWindow
(
"Support"
,
repo
.
getSupportUrl
(),
context
);
}
};
mHolder
.
changeLog
.
setOnClickListener
(
oCl
);
...
...
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
0addbaa9
...
...
@@ -112,14 +112,7 @@ public class ReposFragment extends Fragment {
};
Log
.
d
(
"Magisk"
,
"ReposFragment, LoadRepo called"
);
mListRepos
.
clear
();
List
<
Repo
>
magiskRepos
=
RepoHelper
.
listRepos
(
getActivity
(),
doReload
,
taskDelegate
);
for
(
Repo
repo
:
magiskRepos
)
{
Log
.
d
(
"Magisk"
,
"ReposFragment: Adding repo from string "
+
repo
.
getId
());
mListRepos
.
add
(
repo
);
}
new
Async
.
LoadRepos
(
getActivity
());
}
private
void
NotifyOfAlerts
()
{
...
...
@@ -138,7 +131,7 @@ public class ReposFragment extends Fragment {
}
};
String
filename
=
repo
.
getId
().
replace
(
" "
,
""
)
+
".zip"
;
Utils
.
downloadAndReceive
(
getActivity
(),
receiver
,
repo
.
get
m
ZipUrl
(),
filename
);
Utils
.
downloadAndReceive
(
getActivity
(),
receiver
,
repo
.
getZipUrl
(),
filename
);
break
;
...
...
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
View file @
0addbaa9
...
...
@@ -79,10 +79,7 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
//Do a thing here when we get a result we want
};
new
Async
.
LoadModules
(
this
).
execute
();
new
Async
.
LoadRepos
(
this
,
true
,
delegate
).
execute
();
new
Async
.
LoadRepos
(
this
,
!
prefs
.
contains
(
"hasCachedRepos"
),
delegate
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
new
Async
.
LoadModules
(
getApplication
()).
execute
();
new
Async
.
LoadRepos
(
this
,
false
,
delegate
).
execute
();
new
Async
.
LoadRepos
(
this
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
setSupportActionBar
(
toolbar
);
...
...
app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java
View file @
0addbaa9
...
...
@@ -7,16 +7,13 @@ import java.util.List;
public
abstract
class
BaseModule
{
protected
String
mId
,
mName
,
mVersion
,
m
Description
,
mSupportUrl
,
mDonateUrl
,
mAuthor
;
protected
String
mId
,
mName
,
mVersion
,
m
Author
,
mDescription
,
mSupportUrl
,
mDonateUrl
;
protected
boolean
mIsCacheModule
=
false
;
protected
int
mVersionCode
=
0
;
public
BaseModule
(
List
<
String
>
props
)
{
this
(
props
.
toArray
(
new
String
[
props
.
size
()]));
}
protected
void
parseProps
(
List
<
String
>
props
)
{
parseProps
(
props
.
toArray
(
new
String
[
props
.
size
()]));
}
p
ublic
BaseModule
(
String
[]
props
)
{
p
rotected
void
parseProps
(
String
[]
props
)
{
for
(
String
line
:
props
)
{
String
[]
prop
=
line
.
split
(
"="
,
2
);
if
(
prop
.
length
!=
2
)
{
...
...
@@ -93,11 +90,11 @@ public abstract class BaseModule {
return
mVersionCode
;
}
public
String
get
m
DonateUrl
()
{
public
String
getDonateUrl
()
{
return
mDonateUrl
;
}
public
String
get
m
SupportUrl
()
{
public
String
getSupportUrl
()
{
return
mSupportUrl
;
}
}
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
0addbaa9
...
...
@@ -16,9 +16,10 @@ public class Module extends BaseModule {
private
String
mZipUrl
,
mLogUrl
;
private
boolean
mEnable
,
mRemove
,
mUpdateAvailable
=
false
,
mIsInstalled
;
public
Module
(
String
path
,
Context
context
)
{
public
Module
(
Context
context
,
String
path
)
{
super
(
Utils
.
readFile
(
path
+
"/module.prop"
));
super
();
parseProps
(
Utils
.
readFile
(
path
+
"/module.prop"
));
mRemoveFile
=
path
+
"/remove"
;
mDisableFile
=
path
+
"/disable"
;
...
...
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
View file @
0addbaa9
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/module/RepoHelper.java
View file @
0addbaa9
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
0addbaa9
...
...
@@ -14,7 +14,6 @@ import com.topjohnwu.magisk.ModulesFragment;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
org.json.JSONException
;
...
...
@@ -30,6 +29,7 @@ import java.io.InputStreamReader;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Collections
;
import
java.util.List
;
public
class
Async
{
...
...
@@ -195,17 +195,19 @@ public class Async {
for
(
String
mod
:
magisk
)
{
Log
.
d
(
"Magisk"
,
"Utils: Adding module from string "
+
mod
);
ModulesFragment
.
listModules
.
add
(
new
Module
(
m
od
,
mContext
));
ModulesFragment
.
listModules
.
add
(
new
Module
(
m
Context
,
mod
));
}
for
(
String
mod
:
magiskCache
)
{
Log
.
d
(
"Magisk"
,
"Utils: Adding cache module from string "
+
mod
);
Module
cacheMod
=
new
Module
(
m
od
,
mContext
);
Module
cacheMod
=
new
Module
(
m
Context
,
mod
);
// Prevent people forgot to change module.prop
cacheMod
.
setCache
();
ModulesFragment
.
listModules
.
add
(
cacheMod
);
}
Collections
.
sort
(
ModulesFragment
.
listModules
,
new
Utils
.
ModuleComparator
());
return
null
;
}
...
...
@@ -217,22 +219,15 @@ public class Async {
private
boolean
doReload
;
private
RepoHelper
.
TaskDelegate
mTaskDelegate
;
public
LoadRepos
(
Context
context
,
boolean
reload
,
RepoHelper
.
TaskDelegate
delegate
)
{
public
LoadRepos
(
Context
context
)
{
mContext
=
context
;
doReload
=
reload
;
mTaskDelegate
=
delegate
;
}
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
ReposFragment
.
mListRepos
.
clear
();
List
<
Repo
>
magiskRepos
=
RepoHelper
.
listRepos
(
mContext
,
doReload
,
mTaskDelegate
);
for
(
Repo
repo
:
magiskRepos
)
{
Log
.
d
(
"Magisk"
,
"Utils: Adding repo from string "
+
repo
.
getId
());
ReposFragment
.
mListRepos
.
add
(
repo
);
}
RepoHelper
.
createRepoMap
(
mContext
);
ReposFragment
.
mListRepos
=
RepoHelper
.
getSortedList
();
return
null
;
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
0addbaa9
...
...
@@ -31,6 +31,7 @@ import com.topjohnwu.magisk.ModulesFragment;
import
com.topjohnwu.magisk.MonitorService
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.module.BaseModule
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.RepoHelper
;
...
...
@@ -52,6 +53,7 @@ import java.net.URL;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.spec.InvalidKeySpecException
;
import
java.util.Comparator
;
import
java.util.List
;
import
javax.crypto.BadPaddingException
;
...
...
@@ -304,4 +306,10 @@ public class Utils {
}
public
static
class
ModuleComparator
implements
Comparator
<
BaseModule
>
{
@Override
public
int
compare
(
BaseModule
o1
,
BaseModule
o2
)
{
return
o1
.
getName
().
compareTo
(
o2
.
getName
());
}
}
}
app/src/main/res/values/strings.xml
View file @
0addbaa9
...
...
@@ -105,4 +105,6 @@
<string
name=
"some_string"
>
GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus
</string>
<string
name=
"downloads"
>
Downloads
</string>
<string
name=
"url_main"
>
https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=
</string>
<string
name=
"file_url"
>
https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s
</string>
<string
name=
"zip_url"
>
https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip
</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