mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-17 07:22:50 +00:00
Add git commit hash and branch information to AboutActivity for debug builds
This will help us differentiate between custom/debug builds and release builds of Aegis.
This commit is contained in:
parent
1d513441c6
commit
cbe3697d68
2 changed files with 22 additions and 13 deletions
|
@ -1,5 +1,17 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
def getCmdOutput = { cmd ->
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine cmd
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout.toString().trim()
|
||||
}
|
||||
|
||||
def getGitHash = { -> return getCmdOutput(["git", "rev-parse", "--short", "HEAD"]) }
|
||||
def getGitBranch = { -> return getCmdOutput(["git", "rev-parse", "--abbrev-ref", "HEAD"]) }
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
|
||||
|
@ -9,6 +21,8 @@ android {
|
|||
targetSdkVersion 28
|
||||
versionCode 21
|
||||
versionName "1.0.2"
|
||||
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
|
||||
buildConfigField "String", "GIT_BRANCH", "\"${getGitBranch()}\""
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
|
@ -80,5 +94,4 @@ dependencies {
|
|||
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
|
||||
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
package com.beemdevelopment.aegis.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.beemdevelopment.aegis.Preferences;
|
||||
import com.beemdevelopment.aegis.BuildConfig;
|
||||
import com.beemdevelopment.aegis.R;
|
||||
import com.beemdevelopment.aegis.Theme;
|
||||
import com.beemdevelopment.aegis.helpers.ThemeHelper;
|
||||
|
@ -22,7 +20,6 @@ import androidx.core.view.LayoutInflaterCompat;
|
|||
|
||||
import de.psdev.licensesdialog.LicenseResolver;
|
||||
import de.psdev.licensesdialog.LicensesDialog;
|
||||
import de.psdev.licensesdialog.licenses.License;
|
||||
|
||||
public class AboutActivity extends AegisActivity {
|
||||
|
||||
|
@ -48,7 +45,7 @@ public class AboutActivity extends AegisActivity {
|
|||
btnLicenses.setOnClickListener(v -> showLicenseDialog());
|
||||
|
||||
TextView appVersion = findViewById(R.id.app_version);
|
||||
appVersion.setText(getCurrentVersion());
|
||||
appVersion.setText(getCurrentAppVersion());
|
||||
|
||||
View btnGithub = findViewById(R.id.btn_github);
|
||||
btnGithub.setOnClickListener(v -> openUrl(GITHUB));
|
||||
|
@ -74,13 +71,12 @@ public class AboutActivity extends AegisActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private String getCurrentVersion() {
|
||||
try {
|
||||
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
private static String getCurrentAppVersion() {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return String.format("%s-%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.GIT_HASH, BuildConfig.GIT_BRANCH);
|
||||
}
|
||||
return "Unknown version";
|
||||
|
||||
return BuildConfig.VERSION_NAME;
|
||||
}
|
||||
|
||||
private void openUrl(String url) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue