Skip to content

Commit

Permalink
feat(all): issue161 - Add version details to sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
isuPatches committed Dec 26, 2022
1 parent 831c378 commit 86c410f
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 19 deletions.
19 changes: 17 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import com.isupatches.android.wisefy.build.Dependencies
import com.isupatches.android.wisefy.build.Versions
import com.isupatches.android.wisefy.build.compose
import com.isupatches.android.wisefy.build.dagger
import com.isupatches.android.wisefy.build.gitCommitHash
import com.isupatches.android.wisefy.build.navigation

plugins {
Expand All @@ -25,10 +26,24 @@ android {
minSdk = BuildVersions.MIN_SDK
targetSdk = BuildVersions.TARGET_SDK

versionCode = BuildVersions.MODULE_VERSION_CODE
versionName = BuildVersions.MODULE_VERSION_NAME
versionCode = BuildVersions.Sample.VERSION_CODE
versionName = BuildVersions.Sample.VERSION_NAME

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("String", "GIT_HASH", "\"${gitCommitHash()}\"")

buildConfigField("String", "WISEFY_CORE_VERSION","\"${BuildVersions.WISEFY_CORE_VERSION}\"")
buildConfigField("String", "WISEFY_ACCESS_POINTS_VERSION","\"${BuildVersions.WISEFY_ACCESS_POINTS_VERSION}\"")
buildConfigField("String", "WISEFY_ADD_NETWORK_VERSION","\"${BuildVersions.WISEFY_ADD_NETWORK_VERSION}\"")
buildConfigField("String", "WISEFY_NETWORK_CONNECTION_VERSION","\"${BuildVersions.WISEFY_NETWORK_CONNECTION_VERSION}\"")
buildConfigField("String", "WISEFY_NETWORK_INFO_VERSION","\"${BuildVersions.WISEFY_NETWORK_INFO_VERSION}\"")
buildConfigField("String", "WISEFY_REMOVE_NETWORK_VERSION","\"${BuildVersions.WISEFY_REMOVE_NETWORK_VERSION}\"")
buildConfigField("String", "WISEFY_SAVED_NETWORKS_VERSION","\"${BuildVersions.WISEFY_SAVED_NETWORKS_VERSION}\"")
buildConfigField("String", "WISEFY_SIGNAL_VERSION","\"${BuildVersions.WISEFY_SIGNAL_VERSION}\"")
buildConfigField("String", "WISEFY_WIFI_VERSION","\"${BuildVersions.WISEFY_WIFI_VERSION}\"")
buildConfigField("String", "WISEFY_VERSION", "\"${BuildVersions.WISEFY_VERSION}\"")
buildConfigField("String", "WISEFY_KTX_VERSION", "\"${BuildVersions.WISEFY_KTX_VERSION}\"")
}

signingConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand All @@ -33,10 +36,12 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import com.isupatches.android.wisefy.sample.BuildConfig
import com.isupatches.android.wisefy.sample.R
import com.isupatches.android.wisefy.sample.ui.primitives.WisefySampleSizes
import com.isupatches.android.wisefy.sample.ui.theme.WisefySampleTheme


@Composable
internal fun HomeScreen() {
WisefySampleTheme {
Expand All @@ -46,7 +51,6 @@ internal fun HomeScreen() {
.verticalScroll(rememberScrollState())
.padding(
top = WisefySampleSizes.WisefySampleTopMargin,
bottom = WisefySampleSizes.WisefySampleBottomMargin,
start = WisefySampleSizes.WisefySampleHorizontalMargins,
end = WisefySampleSizes.WisefySampleHorizontalMargins
)
Expand Down Expand Up @@ -80,6 +84,209 @@ internal fun HomeScreen() {
)
}
}
Row(
modifier =
Modifier.padding(
top = WisefySampleSizes.XLarge,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.core_version_args, BuildConfig.WISEFY_CORE_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.accesspoints_version_args, BuildConfig.WISEFY_ACCESS_POINTS_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.addnetwork_version_args, BuildConfig.WISEFY_ADD_NETWORK_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(
R.string.networkconnection_version_args,
BuildConfig.WISEFY_NETWORK_CONNECTION_VERSION
),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.networkinfo_version_args, BuildConfig.WISEFY_NETWORK_INFO_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(
R.string.removenetwork_version_args,
BuildConfig.WISEFY_REMOVE_NETWORK_VERSION
),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(
R.string.savednetworks_version_args,
BuildConfig.WISEFY_SAVED_NETWORKS_VERSION
),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.signal_version_args, BuildConfig.WISEFY_SIGNAL_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.wifi_version_args, BuildConfig.WISEFY_WIFI_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
Modifier
.padding(
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.wisefy_version_args, BuildConfig.WISEFY_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(
modifier = Modifier
.padding(
bottom = WisefySampleSizes.XLarge,
top = WisefySampleSizes.Small,
start = WisefySampleSizes.Large,
end = WisefySampleSizes.Large
)
) {
Text(
text = stringResource(R.string.wisefy_ktx_version_args, BuildConfig.WISEFY_KTX_VERSION),
style = MaterialTheme.typography.body2,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
Row(Modifier.weight(1f)) {
Spacer(modifier = Modifier.fillMaxSize())
}
Row {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(
top = WisefySampleSizes.Large,
start = WisefySampleSizes.Medium,
bottom = WisefySampleSizes.Large,
end = WisefySampleSizes.Medium
),
contentAlignment = Alignment.BottomCenter
) {
Text(
text = stringResource(
R.string.author_and_version_args,
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE,
BuildConfig.GIT_HASH
),
style = MaterialTheme.typography.caption,
textAlign = TextAlign.Center,
color = MaterialTheme.colors.onBackground
)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ internal fun WisefySampleBottomNavigation(navController: NavController) {
},
label = {
Text(
text = stringResource(item.stringResId),
text = "",
style = WisefySampleTypography.caption
)
},
selectedContentColor = MaterialTheme.colors.onPrimary,
unselectedContentColor = MaterialTheme.colors.onPrimary.copy(UNSELECTED_NAVIGATION_ITEM_ALPHA),
alwaysShowLabel = true,
alwaysShowLabel = false,
selected = currentRoute == item.route,
onClick = {
navController.navigate(item.route) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,18 @@
<string name="show_password">Show password</string>

<string name="rssi_input_invalid">Invalid RSSI input</string>

<string name="author_and_version_args">Patches Barrett - v%1$s build %2$s-%3$s</string>

<string name="core_version_args">wisefy:core:%s</string>
<string name="accesspoints_version_args">wisefy:accesspoints:%s</string>
<string name="addnetwork_version_args">wisefy:addnetwork:%s</string>
<string name="networkconnection_version_args">wisefy:networkconnection:%s</string>
<string name="networkinfo_version_args">wisefy:networkinfo:%s</string>
<string name="removenetwork_version_args">wisefy:removenetwork:%s</string>
<string name="savednetworks_version_args">wisefy:savednetworks:%s</string>
<string name="signal_version_args">wisefy:signal:%s</string>
<string name="wifi_version_args">wisefy:wifi:%s</string>
<string name="wisefy_version_args">wisefy:%s</string>
<string name="wisefy_ktx_version_args">wisefy:ktx:%s</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ object BuildVersions {
const val TARGET_SDK: Int = 33
const val MIN_SDK: Int = 23

const val MODULE_VERSION_CODE: Int = 18
const val MODULE_VERSION_NAME: String = "5.0.0"
object Sample {
const val VERSION_CODE: Int = 18
const val VERSION_NAME: String = "5.0.0"
}

const val WISEFY_CORE_VERSION: String = "5.0.0"
const val WISEFY_ACCESS_POINTS_VERSION: String = "5.0.0"
const val WISEFY_ADD_NETWORK_VERSION: String = "5.0.0"
const val WISEFY_NETWORK_CONNECTION_VERSION: String = "5.0.0"
const val WISEFY_NETWORK_INFO_VERSION: String = "5.0.0"
const val WISEFY_REMOVE_NETWORK_VERSION: String = "5.0.0"
const val WISEFY_SAVED_NETWORKS_VERSION: String = "5.0.0"
const val WISEFY_SIGNAL_VERSION: String = "5.0.0"
const val WISEFY_WIFI_VERSION: String = "5.0.0"
const val WISEFY_VERSION: String = "5.0.0"
const val WISEFY_KTX_VERSION: String = "5.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2022 Patches Barrett
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.isupatches.android.wisefy.build

import java.io.ByteArrayOutputStream
import java.io.OutputStream
import org.gradle.api.Project

/*
* https://stackoverflow.com/questions/28498688/gradle-script-to-autoversion-and-include-the-commit-hash-in-android
*/
fun Project.gitCommitHash(): String {
val stdout: OutputStream = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}
2 changes: 1 addition & 1 deletion wisefy/accesspoints/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = PublishingConstants.GROUP_ID
version = BuildVersions.MODULE_VERSION_NAME
version = BuildVersions.WISEFY_ACCESS_POINTS_VERSION

android {
namespace = "com.isupatches.android.wisefy.accesspoints"
Expand Down
2 changes: 1 addition & 1 deletion wisefy/addnetwork/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = PublishingConstants.GROUP_ID
version = BuildVersions.MODULE_VERSION_NAME
version = BuildVersions.WISEFY_ADD_NETWORK_VERSION

android {
namespace = "com.isupatches.android.wisefy.addnetwork"
Expand Down
2 changes: 1 addition & 1 deletion wisefy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = GROUP_ID
version = BuildVersions.MODULE_VERSION_NAME
version = BuildVersions.WISEFY_VERSION

android {
namespace = "com.isupatches.android.wisefy"
Expand Down
Loading

0 comments on commit 86c410f

Please sign in to comment.