Skip to content

Commit

Permalink
fix: some issue in order
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed May 4, 2022
1 parent 2148a0b commit 6233db4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,9 @@ public class CapacitorUpdater {
public String statsUrl = "";
public String appId = "";
public String deviceID = "";
private final String pluginVersion = "3.2.1";


private final FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(final File f, final String name) {
// ignore directories generated by mac os x
return !name.startsWith("__MACOSX") && !name.startsWith(".") && !name.startsWith(".DS_Store");
}
};
private final String pluginVersion = "3.2.1";
private final Context context;

private String versionBuild = "";
private String versionCode = "";
private String versionOs = "";
Expand All @@ -71,6 +62,27 @@ public boolean accept(final File f, final String name) {
static final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static SecureRandom rnd = new SecureRandom();

public CapacitorUpdater (final Context context) throws PackageManager.NameNotFoundException {
this.context = context;

this.prefs = this.context.getSharedPreferences("CapWebViewSettings", Activity.MODE_PRIVATE);
this.editor = this.prefs.edit();
this.versionOs = Build.VERSION.RELEASE;
this.deviceID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);

final PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
this.versionBuild = pInfo.versionName;
this.versionCode = Integer.toString(pInfo.versionCode);
}

private final FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(final File f, final String name) {
// ignore directories generated by mac os x
return !name.startsWith("__MACOSX") && !name.startsWith(".") && !name.startsWith(".DS_Store");
}
};

private int calcTotalPercent(final int percent, final int min, final int max) {
return (percent * (max - min)) / 100 + min;
}
Expand All @@ -86,19 +98,6 @@ private String randomString(final int len){
return sb.toString();
}

public CapacitorUpdater (final Context context) throws PackageManager.NameNotFoundException {
this.context = context;

this.prefs = this.context.getSharedPreferences("CapWebViewSettings", Activity.MODE_PRIVATE);
this.editor = this.prefs.edit();
this.versionOs = Build.VERSION.RELEASE;
this.deviceID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);

final PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
this.versionBuild = pInfo.versionName;
this.versionCode = Integer.toString(pInfo.versionCode);
}

private Boolean unzip(final String source, final String dest) {
final File zipFile = new File(this.context.getFilesDir() + "/" + source);
final File targetDirectory = new File(this.context.getFilesDir() + "/" + dest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.getcapacitor.CapConfig;
import com.getcapacitor.JSArray;
Expand All @@ -29,12 +27,12 @@

@CapacitorPlugin(name = "CapacitorUpdater")
public class CapacitorUpdaterPlugin extends Plugin implements Application.ActivityLifecycleCallbacks {
private static final String autoUpdateUrlDefault = "https://capgo.app/api/auto_update";
private static final String statsUrlDefault = "https://capgo.app/api/stats";
private final String TAG = "Capacitor-updater";
private CapacitorUpdater implementation;
private SharedPreferences prefs;
private SharedPreferences.Editor editor;
private static final String autoUpdateUrlDefault = "https://capgo.app/api/auto_update";
private static final String statsUrlDefault = "https://capgo.app/api/stats";
private String autoUpdateUrl = "";
private Version currentVersionNative;
private Boolean autoUpdate = false;
Expand Down

0 comments on commit 6233db4

Please sign in to comment.