Move to different versioning scheme and show version in About dialog
This commit is contained in:
parent
81cd67217b
commit
7694eb3cf9
8 changed files with 55 additions and 8 deletions
|
@ -6,6 +6,15 @@ plugins {
|
||||||
id "org.jlleitschuh.gradle.ktlint" version "9.4.0"
|
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 {
|
android {
|
||||||
|
|
||||||
compileSdkVersion 30
|
compileSdkVersion 30
|
||||||
|
@ -14,6 +23,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 29 // leave at 29 for robolectric tests
|
minSdkVersion 29 // leave at 29 for robolectric tests
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
|
versionNameSuffix "-$gitDescribe"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
testInstrumentationRunnerArguments disableAnalytics: 'true'
|
testInstrumentationRunnerArguments disableAnalytics: 'true'
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.stevesoltys.seedvault"
|
package="com.stevesoltys.seedvault"
|
||||||
android:versionCode="7"
|
android:versionCode="30000001"
|
||||||
android:versionName="1.0.0">
|
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
|
<uses-permission
|
||||||
android:name="android.permission.BACKUP"
|
android:name="android.permission.BACKUP"
|
||||||
|
|
|
@ -8,9 +8,14 @@ import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.stevesoltys.seedvault.R
|
import com.stevesoltys.seedvault.R
|
||||||
|
import com.stevesoltys.seedvault.transport.backup.PackageService
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
|
||||||
class AboutDialogFragment : DialogFragment() {
|
class AboutDialogFragment : DialogFragment() {
|
||||||
|
|
||||||
|
private val packageService: PackageService by inject()
|
||||||
|
|
||||||
|
private lateinit var versionView: TextView
|
||||||
private lateinit var licenseView: TextView
|
private lateinit var licenseView: TextView
|
||||||
private lateinit var authorView: TextView
|
private lateinit var authorView: TextView
|
||||||
private lateinit var designView: TextView
|
private lateinit var designView: TextView
|
||||||
|
@ -27,11 +32,15 @@ class AboutDialogFragment : DialogFragment() {
|
||||||
): View? {
|
): View? {
|
||||||
val v: View = inflater.inflate(R.layout.fragment_about, container, false)
|
val v: View = inflater.inflate(R.layout.fragment_about, container, false)
|
||||||
|
|
||||||
|
versionView = v.findViewById(R.id.versionView)
|
||||||
licenseView = v.findViewById(R.id.licenseView)
|
licenseView = v.findViewById(R.id.licenseView)
|
||||||
authorView = v.findViewById(R.id.authorView)
|
authorView = v.findViewById(R.id.authorView)
|
||||||
designView = v.findViewById(R.id.designView)
|
designView = v.findViewById(R.id.designView)
|
||||||
sponsorView = v.findViewById(R.id.sponsorView)
|
sponsorView = v.findViewById(R.id.sponsorView)
|
||||||
|
|
||||||
|
val versionName = packageService.getVersionName(requireContext().packageName) ?: "???"
|
||||||
|
versionView.text = getString(R.string.about_version, versionName)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,12 @@ internal class PackageService(
|
||||||
return ExpectedAppTotals(appsTotal, appsOptOut)
|
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>) {
|
private fun logPackages(packages: List<String>) {
|
||||||
packages.chunked(LOG_MAX_PACKAGES).forEach {
|
packages.chunked(LOG_MAX_PACKAGES).forEach {
|
||||||
Log.i(TAG, it.toString())
|
Log.i(TAG, it.toString())
|
||||||
|
|
|
@ -62,6 +62,19 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/appNameView" />
|
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
|
<TextView
|
||||||
android:id="@+id/licenseView"
|
android:id="@+id/licenseView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -73,7 +86,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/summaryView" />
|
app:layout_constraintTop_toBottomOf="@+id/versionView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/authorView"
|
android:id="@+id/authorView"
|
||||||
|
|
|
@ -136,6 +136,7 @@
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about_title">About</string>
|
<string name="about_title">About</string>
|
||||||
<string name="about_summary">A backup application using Android\'s internal backup API.</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_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_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>
|
<string name="about_design">Design by: <a href="https://www.glennsorrentino.com/">Glenn Sorrentino</a></string>
|
||||||
|
|
|
@ -9,8 +9,6 @@ android {
|
||||||
applicationId "org.calyxos.backup.contacts"
|
applicationId "org.calyxos.backup.contacts"
|
||||||
minSdkVersion 30
|
minSdkVersion 30
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 30
|
|
||||||
versionName "0.1"
|
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -54,8 +52,8 @@ dependencies {
|
||||||
|
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependency
|
||||||
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
testImplementation 'junit:junit:4.13'
|
testImplementation 'junit:junit:4.13.1'
|
||||||
def mockk_version = "1.10.0"
|
def mockk_version = "1.10.2"
|
||||||
testImplementation "io.mockk:mockk:$mockk_version"
|
testImplementation "io.mockk:mockk:$mockk_version"
|
||||||
|
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependency
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
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.READ_CONTACTS" />
|
||||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||||
|
|
Loading…
Reference in a new issue