feat: SHA-256 verification, download progress, native installer, i18n
- SHA-256 hash check on downloaded APK (Web Crypto API, no new deps)
- Download progress bar in a locked sheet (stream-based tracking)
- Native Android InstallPlugin (FileProvider + ACTION_VIEW intent)
- REQUEST_INSTALL_PACKAGES permission in AndroidManifest
- applicationIdSuffix .debug for debug builds
- Update row only shown when an update is available
- Label changed to 'openGym v{0} available', icon to 'info'
- All 7 new UI strings translated in 12 locales
- pt-BR snapshot count updated (291 → 298)
This commit is contained in:
1 parent
106a3abee0
commit
7958d0fcd4
22 files changed
+344
-96
No files matched your search
@@ -17,6 +17,9 @@ android {
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<!-- Permissions -->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<!-- Workout-day reminder: lets the local-notifications plugin fire at the exact minute
|
||||
on Android 12+. Where it isn't granted, scheduling silently falls back to inexact
|
||||
alarms — the reminder still arrives, just not to the minute. -->
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package ch.duartesantos.opengym;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import androidx.core.content.FileProvider;
|
||||
import com.getcapacitor.Plugin;
|
||||
import com.getcapacitor.PluginCall;
|
||||
import com.getcapacitor.PluginMethod;
|
||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Minimal local Capacitor plugin that opens the Android package installer
|
||||
* for an APK file stored in the app's cache directory.
|
||||
*
|
||||
* Usage from JS:
|
||||
* import { registerPlugin } from '@capacitor/core';
|
||||
* const Install = registerPlugin('Install');
|
||||
* await Install.installApk({ fileName: 'opengym-update.apk' });
|
||||
*/
|
||||
@CapacitorPlugin(name = "Install")
|
||||
public class InstallPlugin extends Plugin {
|
||||
|
||||
@PluginMethod
|
||||
public void installApk(PluginCall call) {
|
||||
String fileName = call.getString("fileName");
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
call.reject("fileName is required");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(getContext().getCacheDir(), fileName);
|
||||
if (!file.exists()) {
|
||||
call.reject("APK file not found: " + fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
Uri uri = FileProvider.getUriForFile(
|
||||
getContext(),
|
||||
getContext().getPackageName() + ".fileprovider",
|
||||
file
|
||||
);
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(uri, "application/vnd.android.package-archive");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
getContext().startActivity(intent);
|
||||
call.resolve();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
package ch.duartesantos.opengym;
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {}
|
||||
public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
registerPlugin(InstallPlugin.class);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user