|
|
|
|
@ -24,17 +24,10 @@ import java.util.Locale; |
|
|
|
|
public class Updater implements Download.Callback { |
|
|
|
|
|
|
|
|
|
private DialogUpdateBinding binding; |
|
|
|
|
private final Download download; |
|
|
|
|
private AlertDialog dialog; |
|
|
|
|
private boolean dev; |
|
|
|
|
|
|
|
|
|
private static class Loader { |
|
|
|
|
static volatile Updater INSTANCE = new Updater(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Updater get() { |
|
|
|
|
return Loader.INSTANCE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private File getFile() { |
|
|
|
|
return Path.cache("update.apk"); |
|
|
|
|
} |
|
|
|
|
@ -47,6 +40,14 @@ public class Updater implements Download.Callback { |
|
|
|
|
return Github.getApk(dev, BuildConfig.FLAVOR_mode + "-" + BuildConfig.FLAVOR_api + "-" + BuildConfig.FLAVOR_abi); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Updater create() { |
|
|
|
|
return new Updater(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Updater() { |
|
|
|
|
this.download = Download.create(getApk(), getFile(), this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Updater force() { |
|
|
|
|
Notify.show(R.string.update_check); |
|
|
|
|
Setting.putUpdate(true); |
|
|
|
|
@ -103,12 +104,13 @@ public class Updater implements Download.Callback { |
|
|
|
|
|
|
|
|
|
private void cancel(View view) { |
|
|
|
|
Setting.putUpdate(false); |
|
|
|
|
download.cancel(); |
|
|
|
|
dismiss(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void confirm(View view) { |
|
|
|
|
binding.confirm.setEnabled(false); |
|
|
|
|
Download.create(getApk(), getFile(), this).start(); |
|
|
|
|
download.start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void dismiss() { |
|
|
|
|
|