feat: show android version on settings page

This commit is contained in:
Johannes Millan 2024-11-13 19:22:03 +01:00
parent 2e74f9c45d
commit d6d1bb359c
8 changed files with 36 additions and 6 deletions

View file

@ -4,6 +4,14 @@
<selectionStates>
<SelectionState runConfigName="SP">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-11-13T18:07:26.343977020Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/home/johannes/.android/avd/A11_Pixel_6_API_30.avd" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
</selectionStates>
</component>

View file

@ -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 = [

View file

@ -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

View file

@ -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) {

View file

@ -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}`;
};

View file

@ -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;

View file

@ -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();

View file

@ -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;
};