Skip to content

Commit

Permalink
Application version is now retrieved from application build data, no …
Browse files Browse the repository at this point in the history
…need to store it in multiple files anymore
  • Loading branch information
nicorac committed Sep 15, 2023
1 parent 3c45cca commit 1516d20
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
4 changes: 2 additions & 2 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">BCR Gui</string>
<string name="title_activity_main">BCR Gui</string>
<string name="app_name">BCR-GUI</string>
<string name="title_activity_main">BCR-GUI</string>
<string name="package_name">com.github.nicorac.bcrgui</string>
<string name="custom_url_scheme">com.github.nicorac.bcrgui</string>
</resources>
6 changes: 3 additions & 3 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export enum AppRoutesEnum {

const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: AppRoutesEnum.Main },
{ path: AppRoutesEnum.Main, title: version.appName, component: MainPage },
{ path: AppRoutesEnum.Settings, title: 'Settings', component: SettingsPage },
{ path: AppRoutesEnum.About, title: 'About', component: AboutPage },
{ path: AppRoutesEnum.Main, title: '' /* set by page itself */, component: MainPage },
{ path: AppRoutesEnum.Settings, title: 'Settings', component: SettingsPage },
{ path: AppRoutesEnum.About, title: 'About', component: AboutPage },
];

@NgModule({
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RecordingsSortPipe } from './pipes/recordings-sort.pipe';
import { ToHmsPipe } from './pipes/to-hms.pipe';
import { RecordingsService } from './services/recordings.service';
import { SettingsService } from './services/settings.service';
import version from './version';

@NgModule({
declarations: [
Expand Down Expand Up @@ -62,7 +63,8 @@ function appInitializer(recordingsService: RecordingsService, settings: Settings
// wait for Ionic initialization
await platform.ready();

// initialize settings
// initialize version & settings
await version.initialize();
await settings.initialize();

// initialize recordings service
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/about/about.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div>
<div class="title">{{ version.appName }}</div>
<div>
BCR-GUI is a companion app for
{{ version.appName }} is a companion app for
<a href="https://github.com/chenxiaolong/BCR">BCR</a> (Basic Call Recorder)
to ease management of its recordings database
</div>
Expand All @@ -27,14 +27,14 @@ <h2>Version</h2>
<div class="item">
<ion-label class="ion-text-wrap">
<h2>Copyright</h2>
<p>{{ version.copyright }} (<a href="{{ version.website }}">{{ version.website }}</a>)</p>
<p>{{ version.copyright }} (<a href="{{ version.websiteUri }}">{{ version.websiteUri }}</a>)</p>
</ion-label>
</div>

<div class="item">
<ion-label class="ion-text-wrap">
<h2>Source code</h2>
<p>GitHub (<a href="{{ version.sources }}">{{ version.sources }}</a>)</p>
<p>GitHub (<a href="{{ version.sourcesUri }}">{{ version.sourcesUri }}</a>)</p>
</ion-label>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/main/main.page.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-header />
<app-header [title]="version.appName" />

<ion-content id="main-content" class="ion-padding" [class.disabled]="recordingsService.refreshProgress | async">

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/main/main.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { MessageBoxService } from 'src/app/services/message-box.service';
import { RecordingsService } from 'src/app/services/recordings.service';
import { SettingsService } from 'src/app/services/settings.service';
import { bringIntoView } from 'src/app/utils/scroll';
import version from '../../version';
import { AndroidSAF } from 'src/plugins/capacitorandroidsaf';
import { DatePipe } from '@angular/common';
import { Component } from '@angular/core';
import { Directory, Filesystem } from '@capacitor/filesystem';
import { Share } from '@capacitor/share';
import version from '../../version';

@Component({
selector: 'app-main',
Expand Down
1 change: 1 addition & 0 deletions src/app/services/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { SortMode } from '../pipes/recordings-sort.pipe';
import { FromJSON, Serialized, ToJSON } from '../utils/json-serializer';
import version from '../version';

export type Appearance = 'system' | 'light' | 'dark';
export type Theme = 'light' | 'dark';
Expand Down
37 changes: 28 additions & 9 deletions src/app/version.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
export default {
// NOTE: remember to change version number in Android apk too:
// android\app\build.gradle --> versionName + versionCode
"appName": "BCR-GUI",
"version": "0.0.10",
"copyright": "Claudio Nicora (nicorac) 2023",
"website": "https://coolsoft.altervista.org",
"sources": "https://github.com/nicorac/bcr-gui"
}
import { App } from '@capacitor/app';

class versionClass {

// dynamic values
// these fields are injected at runtime by SettingsService.initialize()
// set their values in file `android/app/build.gradle`
private _appName = '';
get appName(): string { return this._appName };
private _version = '';
get version(): string { return this._version };

// static values
readonly copyright = "Claudio Nicora (nicorac) 2023";
readonly websiteUri = "https://coolsoft.altervista.org";
readonly sourcesUri = "https://github.com/nicorac/bcr-gui";

// read version
async initialize() {
const ver = await App.getInfo();
this._appName = ver.name;
this._version = ver.version;
}

}

let version = new versionClass();
export default version;

0 comments on commit 1516d20

Please sign in to comment.