parent
a4ed235f73
commit
584d8b126a
@ -0,0 +1,45 @@
|
||||
package com.fox2code.mmm.manager;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.fox2code.mmm.utils.FastException;
|
||||
import com.fox2code.mmm.utils.Http;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class LocalModuleInfo extends ModuleInfo {
|
||||
public String updateVersion;
|
||||
public long updateVersionCode = Long.MIN_VALUE;
|
||||
public String updateZipUrl;
|
||||
public String updateChangeLog;
|
||||
|
||||
public LocalModuleInfo(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public void checkModuleUpdate() {
|
||||
if (this.updateJson != null) {
|
||||
try {
|
||||
JSONObject jsonUpdate = new JSONObject(new String(Http.doHttpGet(
|
||||
this.updateJson, false), StandardCharsets.UTF_8));
|
||||
this.updateVersion = jsonUpdate.optString("version");
|
||||
this.updateVersionCode = jsonUpdate.getLong("versionCode");
|
||||
this.updateZipUrl = jsonUpdate.getString("zipUrl");
|
||||
this.updateChangeLog = jsonUpdate.optString("changelog");
|
||||
if (this.updateZipUrl.isEmpty()) throw FastException.INSTANCE;
|
||||
if (this.updateVersion == null || this.updateVersion.trim().isEmpty()) {
|
||||
this.updateVersion = "v" + this.updateVersionCode;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.updateVersion = null;
|
||||
this.updateVersionCode = Long.MIN_VALUE;
|
||||
this.updateZipUrl = null;
|
||||
this.updateChangeLog = null;
|
||||
Log.w("LocalModuleInfo",
|
||||
"Failed update checking for module: " + this.id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.fox2code.mmm.utils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public final class FastException extends RuntimeException {
|
||||
public static final FastException INSTANCE = new FastException();
|
||||
|
||||
private FastException() {}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/>
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M14.94,4.66h-4.72l2.36,-2.36zM10.25,19.37h4.66l-2.33,2.33zM6.1,6.27L1.6,17.73h1.84l0.92,-2.45h5.11l0.92,2.45h1.84L7.74,6.27L6.1,6.27zM4.97,13.64l1.94,-5.18 1.94,5.18L4.97,13.64zM15.73,16.14h6.12v1.59h-8.53v-1.29l5.92,-8.56h-5.88v-1.6h8.3v1.26l-5.93,8.6z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue