|
15 | 15 | import com.google.android.material.textfield.TextInputEditText;
|
16 | 16 | import com.google.android.material.textfield.TextInputLayout;
|
17 | 17 |
|
| 18 | +import java.text.DateFormat; |
| 19 | +import java.util.Date; |
18 | 20 | import java.util.Locale;
|
19 | 21 |
|
20 | 22 | import io.customer.android.sample.java_layout.BuildConfig;
|
21 | 23 | import io.customer.android.sample.java_layout.R;
|
22 |
| -import io.customer.sdk.core.di.AndroidSDKComponent; |
23 |
| -import io.customer.sdk.core.di.SDKComponent; |
24 | 24 |
|
25 | 25 | public class ViewUtils {
|
26 | 26 | public static void prepareForAutomatedTests(@NonNull View view, @StringRes int contentDescResId) {
|
@@ -55,16 +55,40 @@ public static void setError(@NonNull TextInputLayout textInputLayout, @Nullable
|
55 | 55 | }
|
56 | 56 |
|
57 | 57 | 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 | + ); |
65 | 70 | textView.setText(buildInfo);
|
66 | 71 | }
|
67 | 72 |
|
| 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 | + |
68 | 92 | @NonNull
|
69 | 93 | public static MaterialAlertDialogBuilder createAlertDialog(@NonNull Activity activity) {
|
70 | 94 | return new MaterialAlertDialogBuilder(activity)
|
|
0 commit comments