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
8a7df954
Commit
8a7df954
authored
Sep 23, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update check module update
parent
8a8aaf32
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
274 deletions
+44
-274
build.gradle
app/build.gradle
+3
-3
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+15
-15
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+10
-0
Repo.java
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
+8
-256
RepoHelper.java
...src/main/java/com/topjohnwu/magisk/module/RepoHelper.java
+7
-0
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+1
-0
No files found.
app/build.gradle
View file @
8a7df954
...
...
@@ -32,9 +32,9 @@ repositories {
dependencies
{
compile
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
compile
'com.android.support:recyclerview-v7:24.2.
0
'
compile
'com.android.support:cardview-v7:24.2.
0
'
compile
'com.android.support:design:24.2.
0
'
compile
'com.android.support:recyclerview-v7:24.2.
1
'
compile
'com.android.support:cardview-v7:24.2.
1
'
compile
'com.android.support:design:24.2.
1
'
compile
'com.github.d8ahazard:BroadcastTileSupportUpdate:master'
compile
'com.jakewharton:butterknife:8.4.0'
compile
'com.github.michalis-vitos:aFileChooser:master'
...
...
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
8a7df954
...
...
@@ -43,7 +43,7 @@ public class ReposFragment extends Fragment {
private
boolean
alertUpdate
;
private
boolean
ignoreAlertUpdate
;
private
String
alertPackage
;
private
SharedPreferences
prefs
;
//
private SharedPreferences prefs;
@Nullable
...
...
@@ -52,16 +52,16 @@ public class ReposFragment extends Fragment {
View
view
=
inflater
.
inflate
(
R
.
layout
.
repos_fragment
,
container
,
false
);
mView
=
view
;
ButterKnife
.
bind
(
this
,
view
);
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getActivity
());
if
(
prefs
.
contains
(
"ignoreUpdateAlerts"
))
{
ignoreAlertUpdate
=
prefs
.
getBoolean
(
"ignoreUpdateAlerts"
,
false
);
}
swipeRefreshLayout
.
setOnRefreshListener
(()
->
{
this
.
LoadRepo
(
true
);
ignoreAlertUpdate
=
false
;
prefs
.
edit
().
putBoolean
(
"ignoreUpdateAlerts"
,
false
).
apply
();
});
//
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
//
if (prefs.contains("ignoreUpdateAlerts")) {
//
ignoreAlertUpdate = prefs.getBoolean("ignoreUpdateAlerts", false);
//
}
//
swipeRefreshLayout.setOnRefreshListener(() -> {
//
this.LoadRepo(true);
//
ignoreAlertUpdate = false;
//
prefs.edit().putBoolean("ignoreUpdateAlerts",false).apply();
//
//
});
LoadRepo
(
false
);
setHasOptionsMenu
(
false
);
alertUpdate
=
false
;
...
...
@@ -136,10 +136,10 @@ public class ReposFragment extends Fragment {
break
;
case
DialogInterface
.
BUTTON_NEGATIVE
:
ignoreAlertUpdate
=
true
;
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putBoolean
(
"ignoreUpdateAlerts"
,
ignoreAlertUpdate
);
editor
.
apply
();
//
ignoreAlertUpdate = true;
//
SharedPreferences.Editor editor = prefs.edit();
//
editor.putBoolean("ignoreUpdateAlerts", ignoreAlertUpdate);
//
editor.apply();
break
;
}
};
...
...
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
8a7df954
...
...
@@ -110,6 +110,16 @@ public class Module extends BaseModule {
}
public
void
checkUpdate
()
{
Repo
repo
=
RepoHelper
.
repoMap
.
get
(
mId
);
if
(
repo
!=
null
)
{
repo
.
setInstalled
();
if
(
repo
.
getVersionCode
()
>
mVersionCode
)
{
repo
.
setUpdate
();
}
}
}
public
String
getmLogUrl
()
{
return
mLogUrl
;
}
public
void
createDisableFile
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
View file @
8a7df954
...
...
@@ -42,6 +42,14 @@ public class Repo extends BaseModule {
}
}
public
void
setUpdate
()
{
mCanUpdate
=
true
;
}
public
void
setInstalled
()
{
mIsInstalled
=
true
;
}
public
String
getZipUrl
()
{
return
mZipUrl
;
}
...
...
@@ -62,259 +70,3 @@ public class Repo extends BaseModule {
public
boolean
canUpdate
()
{
return
mCanUpdate
;
}
public
boolean
isCacheModule
()
{
return
mIsCacheModule
;
}
}
//public class Repo {
// private String mBaseUrl;
// private String mZipUrl;
// private String mLogUrl;
// private String mManifestUrl;
// private String mVersion;
// private String mName;
// private String mDescription;
// private String mAuthor;
// public String mAuthorUrl;
// private String mId;
// private String mVersionCode;
// private String mSupportUrl;
// private String mDonateUrl;
// private String lastUpdate;
// private Context appContext;
// private boolean mIsInstalled,mCanUpdate,mIsCacheModule;
//
//
// public Repo(String manifestString, Context context) {
// appContext = context;
// ParseProps(manifestString);
//
// }
//
//
//
// public Repo(String name, String url, Date updated, Context context) {
// appContext = context;
// this.mName = name;
// this.mBaseUrl = url;
// this.lastUpdate = updated.toString();
//
// this.fetch();
//
// }
//
// public Repo(String moduleName, String moduleDescription, String zipUrl, Date lastUpdated, Context context) {
// appContext = context;
// this.mZipUrl = zipUrl;
// this.mDescription = moduleDescription;
// this.mName = moduleName;
// this.lastUpdate = lastUpdated.toString();
// this.fetch();
//
// }
//
// public void fetch() {
//
// // Construct initial url for contents
// String repoString = WebRequest.makeWebServiceCall(mBaseUrl + "/contents?access_token=" + Utils.procFile(appContext.getString(R.string.some_string), appContext), WebRequest.GET);
// try {
// JSONArray repoArray = new JSONArray(repoString);
// for (int f = 0; f < repoArray.length(); f++) {
// JSONObject jsonobject = repoArray.getJSONObject(f);
// String name = jsonobject.getString("name");
// String url = jsonobject.getString("download_url").trim();
// Log.d("Magisk","Repo - checking object named " + name + " with value of " + url);
// if (name.contains(".zip")) {
// this.mZipUrl = url;
// }
// if (name.equals("module.prop")) {
// this.mManifestUrl = url;
// }
// if (name.contains("log.txt")) {
// Log.d("Magisk","Repo: Setting log URL for " + name + " of " + url);
// this.mLogUrl = url;
// }
// }
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// String manifestString = WebRequest.makeWebServiceCall(mManifestUrl, WebRequest.GET, true);
//
// if (ParseProps(manifestString)) {
// PutProps(manifestString);
// }
//
// }
//
// private void PutProps(String manifestString) {
// manifestString = manifestString + "zipUrl=" + mZipUrl + "\nbaseUrl=" + mBaseUrl + "\nlogUrl=" + mLogUrl + "\nmanifestUrl=" + mManifestUrl;
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
// SharedPreferences.Editor editor = prefs.edit();
// editor.putString("repo_" + mId, manifestString);
// editor.putBoolean("hasCachedRepos", true);
// editor.putString("updated_" + mId, this.lastUpdate);
// editor.apply();
// }
// private boolean ParseProps(String string) {
//
// if ((string.length() <= 1) | (!string.contains("id"))) {
// return false;
// } else {
// String lines[] = string.split("\\n");
// for (String line : lines) {
// if (line != "") {
// String props[] = line.split("=");
// switch (props[0]) {
// case "versionCode":
// this.mVersionCode = props[1];
// break;
// case "name":
// this.mName = props[1];
// break;
// case "author":
// this.mAuthor = props[1];
// break;
// case "id":
// this.mId = props[1];
// break;
// case "version":
// this.mVersion = props[1];
// break;
// case "description":
// this.mDescription = props[1];
// break;
// case "donate":
// this.mDonateUrl = props[1];
// break;
// case "cacheModule":
// this.mIsCacheModule = Boolean.valueOf(props[1]);
// break;
// case "support":
// this.mSupportUrl = props[1];
// break;
// case "logUrl":
// this.mLogUrl = props[1];
// break;
// case "donateUrl":
// this.mDonateUrl = props[1];
// break;
// case "zipUrl":
// this.mZipUrl = props[1];
// break;
// case "baseUrl":
// this.mBaseUrl = props[1];
// break;
// case "manifestUrl":
// this.mManifestUrl = props[1];
// break;
// default:
// Log.d("Magisk", "Manifest string not recognized: " + props[0]);
// break;
// }
// }
//
// }
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
// if (prefs.contains("repo-isInstalled_" + this.mId)) {
// mIsInstalled = prefs.getBoolean("repo-isInstalled_" + this.mId,false);
// }
// if (prefs.contains("repo-canUpdate_" + this.mId)) {
// mCanUpdate = prefs.getBoolean("repo-canUpdate_" + this.mId,false);
// }
// if (prefs.contains("updated_" + this.mId)) {
// lastUpdate = prefs.getString("updated_" + this.mId,"");
// }
//
//
//
// return this.mId != null;
//
// }
// }
//
//
//
//
//
//
//
//
// public String getStringProperty(String mValue) {
// switch (mValue) {
// case "author":
// return mAuthor;
// case "id":
// return mId;
// case "version":
// return mVersion;
// case "description":
// return mDescription;
// case "supportUrl":
// return mSupportUrl;
// case "donateUrl":
// return mDonateUrl;
// case "baseeUrl":
// return mBaseUrl;
// case "zipUrl":
// return mZipUrl;
// default:
// return null;
// }
// }
//
// public String getName() {
// return mName;
// }
//
// public String getmVersion() {
// return mVersion;
// }
//
// public int getmVersionCode() {
// return Integer.valueOf(mVersionCode);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getZipUrl() {
// return mZipUrl;
// }
//
// public String getmBaseUrl() {
// return mBaseUrl;
// }
//
// public String getLogUrl() {
// return mLogUrl;
// }
//
//
// public String getAuthor() {
// return mAuthor;
// }
//
// public String getDonateUrl() {
// return mDonateUrl;
// }
//
// public String getmManifestUrl() {
// return mManifestUrl;
// }
//
// public String getSupportUrl() {
// return mSupportUrl;
// }
//
// public String getLastUpdate() {
// return lastUpdate;
// }
//
// public boolean isInstalled() { return mIsInstalled; }
// public boolean canUpdate() { return mCanUpdate; }
// public boolean isCacheModule() { return mIsCacheModule; }
//}
app/src/main/java/com/topjohnwu/magisk/module/RepoHelper.java
View file @
8a7df954
...
...
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebRequest
;
...
...
@@ -78,6 +79,12 @@ public class RepoHelper {
}
}
public
static
void
checkUpdate
()
{
for
(
Module
module
:
ModulesFragment
.
listModules
)
{
module
.
checkUpdate
();
}
}
public
static
List
<
Repo
>
getSortedList
()
{
ArrayList
<
Repo
>
list
=
new
ArrayList
<>(
repoMap
.
values
());
Collections
.
sort
(
list
,
new
Utils
.
ModuleComparator
());
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
8a7df954
...
...
@@ -227,6 +227,7 @@ public class Async {
protected
Void
doInBackground
(
Void
...
voids
)
{
ReposFragment
.
mListRepos
.
clear
();
RepoHelper
.
createRepoMap
(
mContext
);
RepoHelper
.
checkUpdate
();
ReposFragment
.
mListRepos
=
RepoHelper
.
getSortedList
();
return
null
;
}
...
...
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