Move to different versioning scheme and show version in About dialog

This commit is contained in:
Torsten Grote 2020-10-23 10:25:44 -03:00 committed by Chirayu Desai
parent 81cd67217b
commit 7694eb3cf9
8 changed files with 55 additions and 8 deletions

View file

@ -6,6 +6,15 @@ plugins {
id "org.jlleitschuh.gradle.ktlint" version "9.4.0"
}
def gitDescribe = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always', '--tags', '--dirty=-dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
android {
compileSdkVersion 30
@ -14,6 +23,7 @@ android {
defaultConfig {
minSdkVersion 29 // leave at 29 for robolectric tests
targetSdkVersion 30
versionNameSuffix "-$gitDescribe"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
}

View file

@ -2,8 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.stevesoltys.seedvault"
android:versionCode="7"
android:versionName="1.0.0">
android:versionCode="30000001"
android:versionName="11-1.0">
<!--
The version code is the targeted SDK_VERSION plus 6 digits for our own version code.
The version name is the targeted Android version followed by - and our own version name.
-->
<uses-permission
android:name="android.permission.BACKUP"

View file

@ -8,9 +8,14 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.transport.backup.PackageService
import org.koin.android.ext.android.inject
class AboutDialogFragment : DialogFragment() {
private val packageService: PackageService by inject()
private lateinit var versionView: TextView
private lateinit var licenseView: TextView
private lateinit var authorView: TextView
private lateinit var designView: TextView
@ -27,11 +32,15 @@ class AboutDialogFragment : DialogFragment() {
): View? {
val v: View = inflater.inflate(R.layout.fragment_about, container, false)
versionView = v.findViewById(R.id.versionView)
licenseView = v.findViewById(R.id.licenseView)
authorView = v.findViewById(R.id.authorView)
designView = v.findViewById(R.id.designView)
sponsorView = v.findViewById(R.id.sponsorView)
val versionName = packageService.getVersionName(requireContext().packageName) ?: "???"
versionView.text = getString(R.string.about_version, versionName)
return v
}

View file

@ -113,6 +113,12 @@ internal class PackageService(
return ExpectedAppTotals(appsTotal, appsOptOut)
}
fun getVersionName(packageName: String): String? = try {
packageManager.getPackageInfo(packageName, 0).versionName
} catch (e: PackageManager.NameNotFoundException) {
null
}
private fun logPackages(packages: List<String>) {
packages.chunked(LOG_MAX_PACKAGES).forEach {
Log.i(TAG, it.toString())

View file

@ -62,6 +62,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appNameView" />
<TextView
android:id="@+id/versionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/about_version"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/summaryView" />
<TextView
android:id="@+id/licenseView"
android:layout_width="wrap_content"
@ -73,7 +86,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/summaryView" />
app:layout_constraintTop_toBottomOf="@+id/versionView" />
<TextView
android:id="@+id/authorView"

View file

@ -136,6 +136,7 @@
<!-- About -->
<string name="about_title">About</string>
<string name="about_summary">A backup application using Android\'s internal backup API.</string>
<string name="about_version">Version: %s</string>
<string name="about_license">License: <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache2</a></string>
<string name="about_author">Written by: <a href="https://github.com/stevesoltys">Steve Soltys</a> and <a href="https://blog.grobox.de">Torsten Grote</a></string>
<string name="about_design">Design by: <a href="https://www.glennsorrentino.com/">Glenn Sorrentino</a></string>

View file

@ -9,8 +9,6 @@ android {
applicationId "org.calyxos.backup.contacts"
minSdkVersion 30
targetSdkVersion 30
versionCode 30
versionName "0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -54,8 +52,8 @@ dependencies {
//noinspection GradleDependency
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testImplementation 'junit:junit:4.13'
def mockk_version = "1.10.0"
testImplementation 'junit:junit:4.13.1'
def mockk_version = "1.10.2"
testImplementation "io.mockk:mockk:$mockk_version"
//noinspection GradleDependency

View file

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.calyxos.backup.contacts">
package="org.calyxos.backup.contacts"
android:versionCode="30000001"
android:versionName="11-0.1">
<!--
The version code is the targeted SDK_VERSION plus 6 digits for our own version code.
The version name is the targeted Android version followed by - and our own version name.
-->
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />