More refinements...

This commit is contained in:
d8ahazard
2016-09-13 15:44:07 -05:00
parent 145d4e4bd5
commit 46abbfe224
6 changed files with 324 additions and 127 deletions
@@ -16,7 +16,7 @@ public class Module {
private String mVersion = "(No version provided)";
private String mDescription = "(No description provided)";
private String mUrl,mSupportUrl,mDonateUrl,mZipUrl,mBaseUrl,mManifestUrl,mAuthor,mLogUrl;
private boolean mEnable, mRemove,mUpdateAvailable,mIsOnline,mIsCacheModule;
private boolean mEnable, mRemove,mUpdateAvailable, mIsInstalled,mIsCacheModule;
private String mId;
@@ -81,12 +81,13 @@ public class Module {
this.mLogUrl = props[1];
break;
default:
Log.d("Magisk", "Manifest string not recognized: " + props[0]);
Log.d("Magisk", "Module: Manifest string not recognized: " + props[0]);
break;
}
}
Log.d("Magisk","Module: Loaded module with ID of " + this.mId + " or " + mId);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -97,7 +98,6 @@ public class Module {
if (!preferenceKey.equals("nope")) {
Log.d("Magisk", "Module: repo_" + mId + " found.");
String entryString = prefs.getString("repo_" + mId, "");
String[] subStrings = entryString.split("\n");
for (String subKeys : subStrings) {
String[] idEntry = subKeys.split("=", 2);
@@ -107,9 +107,9 @@ public class Module {
}
if (idEntry[1].equals(mId)) {
Log.d("Magisk", "Module: Hey, I know I'm online...");
mIsOnline = true;
} else mIsOnline = false;
Log.d("Magisk", "Module: Hey, I know " + mId + " is online...");
mIsInstalled = true;
} else mIsInstalled = false;
}
if (idEntry[0].equals("logUrl")) {
mLogUrl = idEntry[1];
@@ -140,9 +140,8 @@ public class Module {
}
SharedPreferences.Editor editor = prefs.edit();
if (mIsOnline) {
if (mIsInstalled) {
editor.putBoolean("repo-isInstalled_" + mId, true);
} else {
editor.putBoolean("repo-isInstalled_" + mId, false);
}
@@ -195,7 +194,7 @@ public class Module {
public String getId() {return mId; }
public String getChangeLog() {return mLogUrl; }
public String getmLogUrl() {return mLogUrl; }
public String getDescription() {
return mDescription;
@@ -229,6 +228,8 @@ public class Module {
return mDonateUrl;
}
public String getmZipUrl() { return mZipUrl; }
public String getmManifestUrl() {
return mManifestUrl;
}
@@ -237,7 +238,7 @@ public class Module {
return mSupportUrl;
}
public boolean isOnline() {return mIsOnline; }
public boolean isInstalled() {return mIsInstalled; }
public boolean isUpdateAvailable() { return mUpdateAvailable; }
@@ -18,7 +18,7 @@ import java.util.Date;
public class Repo {
private String mBaseUrl;
private String mZipUrl;
private String mLogText;
private String mLogUrl;
private String mManifestUrl;
private String mVersion;
private String mName;
@@ -72,14 +72,17 @@ public class Repo {
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 = jsonobject.getString("download_url");
} else if (name.equals("module.prop")) {
this.mManifestUrl = jsonobject.getString("download_url");
} else if (name.equals("changelog.txt")) {
String logUrl = jsonobject.getString("download_url");;
String logText = webreq.makeWebServiceCall(logUrl,WebRequest.GET);
this.mLogText = logText;
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) {
@@ -96,10 +99,9 @@ public class Repo {
}
private void PutProps(String manifestString) {
manifestString = manifestString + "zipUrl=" + mZipUrl + "\nbaseUrl=" + mBaseUrl + "\nmanifestUrl=" + mManifestUrl;
manifestString = manifestString + "zipUrl=" + mZipUrl + "\nbaseUrl=" + mBaseUrl + "\nlogUrl=" + mLogUrl + "\nmanifestUrl=" + mManifestUrl;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("log_" + mId, mLogText);
editor.putString("repo_" + mId, manifestString);
editor.putBoolean("hasCachedRepos", true);
editor.putString("updated_" + mId, this.lastUpdate);
@@ -142,6 +144,9 @@ public class Repo {
case "support":
this.mSupportUrl = props[1];
break;
case "logUrl":
this.mLogUrl = props[1];
break;
case "donateUrl":
this.mDonateUrl = props[1];
break;
@@ -171,9 +176,7 @@ public class Repo {
if (prefs.contains("updated_" + this.mId)) {
lastUpdate = prefs.getString("updated_" + this.mId,"");
}
if (prefs.contains("log_" + this.mId)) {
mLogText = prefs.getString("log_" + this.mId,"");
}
return this.mId != null;
@@ -239,8 +242,8 @@ public class Repo {
return mBaseUrl;
}
public String getmLogText() {
return mLogText;
public String getmLogUrl() {
return mLogUrl;
}
@@ -80,6 +80,7 @@ public class RepoHelper {
@Override
protected void onProgressUpdate(String... values) {
super.onProgressUpdate(values);
prefs.edit().putBoolean("ignoreUpdateAlerts", false).apply();
Toast.makeText(activityContext, "Refreshing online modules", Toast.LENGTH_SHORT).show();
}