diff --git a/android/.idea/deploymentTargetSelector.xml b/android/.idea/deploymentTargetSelector.xml index 59924d87d1..86aca96ee5 100644 --- a/android/.idea/deploymentTargetSelector.xml +++ b/android/.idea/deploymentTargetSelector.xml @@ -4,6 +4,14 @@ diff --git a/android/app/build.gradle b/android/app/build.gradle index f5a3c4d2ba..2969a40fb5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -20,7 +20,7 @@ android { minSdkVersion 24 targetSdkVersion 34 compileSdk 34 - versionCode 101001 + versionCode 100101 versionName "10.1.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" manifestPlaceholders = [ diff --git a/android/app/src/main/java/com/superproductivity/superproductivity/app/LaunchDecider.kt b/android/app/src/main/java/com/superproductivity/superproductivity/app/LaunchDecider.kt index e09ed4e0c8..17f3e2d974 100644 --- a/android/app/src/main/java/com/superproductivity/superproductivity/app/LaunchDecider.kt +++ b/android/app/src/main/java/com/superproductivity/superproductivity/app/LaunchDecider.kt @@ -29,7 +29,7 @@ class LaunchDecider(private val context: Context) { * If LAUNCH_MODE is set to 1 or 2, it will force the corresponding mode. * The result is saved in SharedPreferences for future launches. */ - private fun getLaunchMode(): Int { + fun getLaunchMode(): Int { val launchMode = BuildConfig.LAUNCH_MODE.toIntOrNull() ?: 0 return when (launchMode) { 1 -> MODE_ONLINE diff --git a/android/app/src/main/java/com/superproductivity/superproductivity/webview/JavaScriptInterface.kt b/android/app/src/main/java/com/superproductivity/superproductivity/webview/JavaScriptInterface.kt index 70a391b078..3a2459e7c1 100644 --- a/android/app/src/main/java/com/superproductivity/superproductivity/webview/JavaScriptInterface.kt +++ b/android/app/src/main/java/com/superproductivity/superproductivity/webview/JavaScriptInterface.kt @@ -21,10 +21,12 @@ import androidx.core.content.ContextCompat import com.anggrayudi.storage.SimpleStorageHelper import com.anggrayudi.storage.file.* import com.superproductivity.superproductivity.App +import com.superproductivity.superproductivity.BuildConfig import com.superproductivity.superproductivity.app.AppLifecycleObserver import com.superproductivity.superproductivity.FullscreenActivity import com.superproductivity.superproductivity.FullscreenActivity.Companion.WINDOW_INTERFACE_PROPERTY import com.superproductivity.superproductivity.R +import com.superproductivity.superproductivity.app.LaunchDecider import org.json.JSONException import org.json.JSONObject import java.io.BufferedOutputStream @@ -59,6 +61,15 @@ class JavaScriptInterface( storageHelper.storage.onActivityResult(requestCode, resultCode, data) } + @Suppress("unused") + @JavascriptInterface + fun getVersion(): String { + val versionName = BuildConfig.VERSION_NAME + val launchDecider = LaunchDecider(activity) + val launchMode = launchDecider.getLaunchMode() + return "${versionName}_L$launchMode" + } + @Suppress("unused") @JavascriptInterface fun showToast(toast: String) { diff --git a/src/app/core/error-handler/global-error-handler.util.ts b/src/app/core/error-handler/global-error-handler.util.ts index d05a3ff18b..6ccf69c619 100644 --- a/src/app/core/error-handler/global-error-handler.util.ts +++ b/src/app/core/error-handler/global-error-handler.util.ts @@ -1,5 +1,4 @@ import { HANDLED_ERROR_PROP_STR, IS_ELECTRON } from '../../app.constants'; -import { environment } from '../../../environments/environment'; import StackTrace from 'stacktrace-js'; import pThrottle from 'p-throttle'; import newGithubIssueUrl from 'new-github-issue-url'; @@ -7,6 +6,7 @@ import { getBeforeLastErrorActionLog } from '../../util/action-logger'; import { download } from '../../util/download'; import { AppDataComplete } from '../../imex/sync/sync.model'; import { privacyExport } from '../../imex/file-imex/privacy-export'; +import { getAppVersionStr } from '../../util/get-app-version-str'; let isWasErrorAlertCreated = false; @@ -159,7 +159,7 @@ export const createErrorAlert = ( export const getSimpleMeta = (): string => { const n = window.navigator; - return `META: SP${environment.version} ${IS_ELECTRON ? 'Electron' : 'Browser'} – ${ + return `META: SP${getAppVersionStr()} __ ${IS_ELECTRON ? 'Electron' : 'Browser'} – ${ n.language } – ${n.platform} – ${n.userAgent}`; }; diff --git a/src/app/features/android/android-interface.ts b/src/app/features/android/android-interface.ts index b11fe5d277..a9acc10a30 100644 --- a/src/app/features/android/android-interface.ts +++ b/src/app/features/android/android-interface.ts @@ -4,6 +4,8 @@ import { BehaviorSubject, merge, Observable, Subject } from 'rxjs'; import { mapTo } from 'rxjs/operators'; export interface AndroidInterface { + getVersion?(): string; + showToast(s: string): void; showNotification(title: string, body: string): void; diff --git a/src/app/pages/config-page/config-page.component.ts b/src/app/pages/config-page/config-page.component.ts index 33fb0dca7c..1b45499698 100644 --- a/src/app/pages/config-page/config-page.component.ts +++ b/src/app/pages/config-page/config-page.component.ts @@ -20,13 +20,13 @@ import { } from '../../features/config/global-config.model'; import { Subscription } from 'rxjs'; import { ProjectCfgFormKey } from '../../features/project/project.model'; -import { environment } from '../../../environments/environment'; import { T } from '../../t.const'; import { versions } from '../../../environments/versions'; import { IS_ELECTRON } from '../../app.constants'; import { IS_ANDROID_WEB_VIEW } from '../../util/is-android-web-view'; import { getAutomaticBackUpFormCfg } from '../../features/config/form-cfgs/automatic-backups-form.const'; import { MatButtonToggleChange } from '@angular/material/button-toggle'; +import { getAppVersionStr } from '../../util/get-app-version-str'; @Component({ selector: 'config-page', @@ -42,7 +42,7 @@ export class ConfigPageComponent implements OnInit, OnDestroy { globalCfg?: GlobalConfigState; - appVersion: string = environment.version; + appVersion: string = getAppVersionStr(); versions?: any = versions; private _subs: Subscription = new Subscription(); diff --git a/src/app/util/get-app-version-str.ts b/src/app/util/get-app-version-str.ts new file mode 100644 index 0000000000..eafbd001cb --- /dev/null +++ b/src/app/util/get-app-version-str.ts @@ -0,0 +1,9 @@ +import { IS_ANDROID_WEB_VIEW } from './is-android-web-view'; +import { androidInterface } from '../features/android/android-interface'; +import { environment } from '../../environments/environment'; + +export const getAppVersionStr = (): string => { + const b = + (IS_ANDROID_WEB_VIEW && androidInterface?.getVersion?.()) || environment.version; + return IS_ANDROID_WEB_VIEW ? `${b}A` : b; +};