Skip to content

Commit 90321af

Browse files
Update build info displayed for sample app
1 parent b92a8c1 commit 90321af

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

samples/java_layout/src/main/java/io/customer/android/sample/java_layout/utils/ViewUtils.java

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
import com.google.android.material.textfield.TextInputEditText;
1616
import com.google.android.material.textfield.TextInputLayout;
1717

18+
import java.text.DateFormat;
19+
import java.util.Date;
1820
import java.util.Locale;
1921

2022
import io.customer.android.sample.java_layout.BuildConfig;
2123
import io.customer.android.sample.java_layout.R;
22-
import io.customer.sdk.core.di.AndroidSDKComponent;
23-
import io.customer.sdk.core.di.SDKComponent;
2424

2525
public class ViewUtils {
2626
public static void prepareForAutomatedTests(@NonNull View view, @StringRes int contentDescResId) {
@@ -55,16 +55,40 @@ public static void setError(@NonNull TextInputLayout textInputLayout, @Nullable
5555
}
5656

5757
public static void setBuildInfo(@NonNull TextView textView) {
58-
AndroidSDKComponent androidSDKComponent = SDKComponent.INSTANCE.android();
59-
String sdkVersion = androidSDKComponent.getClient().getSdkVersion();
60-
String buildInfo = String.format(Locale.ENGLISH,
61-
"Customer.io Android SDK %s Java Layout %s (%s)",
62-
sdkVersion,
63-
BuildConfig.VERSION_NAME,
64-
BuildConfig.VERSION_CODE);
58+
String buildInfo = String.format(
59+
Locale.ENGLISH,
60+
"SDK version: %s\n" +
61+
"Build date: %s\n" +
62+
"Branch: %s\n" +
63+
"Default workspace: Native iOS & Android\n" +
64+
"App version: %s",
65+
getSdkVersion(),
66+
getBuildTime(),
67+
getBranchName(),
68+
BuildConfig.VERSION_CODE
69+
);
6570
textView.setText(buildInfo);
6671
}
6772

73+
private static String getBuildTime() {
74+
return DateFormat.getDateTimeInstance().format(new Date(BuildConfig.BUILD_TIMESTAMP));
75+
}
76+
77+
private static String getSdkVersion() {
78+
if (isEmptyOrUnset(BuildConfig.SDK_VERSION)) return "as source code(" + getBranchName() + ")";
79+
return BuildConfig.SDK_VERSION;
80+
}
81+
82+
private static String getBranchName() {
83+
if (isEmptyOrUnset(BuildConfig.BRANCH)) return "local development";
84+
return BuildConfig.BRANCH;
85+
}
86+
87+
private static boolean isEmptyOrUnset(String text) {
88+
// When local properties are not set, they have a string value of "null"
89+
return TextUtils.isEmpty(text) || "null".equalsIgnoreCase(text);
90+
}
91+
6892
@NonNull
6993
public static MaterialAlertDialogBuilder createAlertDialog(@NonNull Activity activity) {
7094
return new MaterialAlertDialogBuilder(activity)

samples/java_layout/src/main/res/layout/activity_dashboard.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@
177177
android:layout_width="0dp"
178178
android:layout_height="wrap_content"
179179
android:layout_marginBottom="@dimen/margin_default"
180-
android:gravity="center"
181180
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
182181
app:layout_constraintBottom_toBottomOf="parent"
183182
app:layout_constraintEnd_toEndOf="parent"

samples/java_layout/src/main/res/layout/activity_login.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
android:layout_width="0dp"
128128
android:layout_height="wrap_content"
129129
android:layout_marginBottom="@dimen/margin_default"
130-
android:gravity="center"
131130
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
132131
app:layout_constraintBottom_toBottomOf="parent"
133132
app:layout_constraintEnd_toEndOf="parent"

0 commit comments

Comments
 (0)