diff --git a/.github/workflows/reusable_build_sample_apps.yml b/.github/workflows/reusable_build_sample_apps.yml index 58da882d..d6365daf 100644 --- a/.github/workflows/reusable_build_sample_apps.yml +++ b/.github/workflows/reusable_build_sample_apps.yml @@ -58,10 +58,15 @@ jobs: bundler-cache: true # cache tools to make builds faster in future - name: Setup local.properties file for sample app + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + COMMIT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} run: | touch "samples/local.properties" echo "cdpApiKey=${{ secrets[matrix.cio-cdpapikey-secret-key] }}" >> "samples/local.properties" echo "siteId=${{ secrets[matrix.cio-siteid-secret-key] }}" >> "samples/local.properties" + echo "branch=$BRANCH_NAME" >> "samples/local.properties" + echo "commit=${COMMIT_HASH:0:7}" >> "samples/local.properties" if [ "${{ inputs.use_latest_sdk_version == true }}" ]; then echo "sdkVersion=${{ steps.latest-sdk-version-step.outputs.LATEST_TAG }}" >> "samples/local.properties" fi diff --git a/samples/fastlane/Fastfile b/samples/fastlane/Fastfile index 43179cc8..c7eb36d0 100644 --- a/samples/fastlane/Fastfile +++ b/samples/fastlane/Fastfile @@ -64,7 +64,7 @@ platform :android do path_to_root_directory_sample_app = File.expand_path('../', Dir.pwd) # We are currently in `samples/N/fastlane/` and we need the directory name `samples/N`` name_of_sample_app_module = File.basename(path_to_root_directory_sample_app) # just get the name of the directory I am in now. `samples/N` - new_app_version = get_new_app_version() + new_app_version = get_new_app_version().gsub("/", ".") test_groups = get_build_test_groups() app_package_name = CredentialsManager::AppfileConfig.try_fetch_value(:package_name) # get package_name from Appfile diff --git a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java index 35b76c73..f53da4f0 100644 --- a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java +++ b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java @@ -43,7 +43,7 @@ public static CustomerIOSDKConfig getDefaultConfigurations() { CioLogLevel.DEBUG, Region.US.INSTANCE, true, - true, + false, true); } diff --git a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/utils/ViewUtils.java b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/utils/ViewUtils.java index b5363d5d..c98fc1be 100644 --- a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/utils/ViewUtils.java +++ b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/utils/ViewUtils.java @@ -15,12 +15,12 @@ import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; +import java.text.DateFormat; +import java.util.Date; import java.util.Locale; import io.customer.android.sample.java_layout.BuildConfig; import io.customer.android.sample.java_layout.R; -import io.customer.sdk.core.di.AndroidSDKComponent; -import io.customer.sdk.core.di.SDKComponent; public class ViewUtils { public static void prepareForAutomatedTests(@NonNull View view, @StringRes int contentDescResId) { @@ -55,16 +55,40 @@ public static void setError(@NonNull TextInputLayout textInputLayout, @Nullable } public static void setBuildInfo(@NonNull TextView textView) { - AndroidSDKComponent androidSDKComponent = SDKComponent.INSTANCE.android(); - String sdkVersion = androidSDKComponent.getClient().getSdkVersion(); - String buildInfo = String.format(Locale.ENGLISH, - "Customer.io Android SDK %s Java Layout %s (%s)", - sdkVersion, - BuildConfig.VERSION_NAME, - BuildConfig.VERSION_CODE); + String buildInfo = String.format( + Locale.ENGLISH, + "SDK version: %s\n" + + "Build date: %s\n" + + "Branch: %s\n" + + "Default workspace: Native iOS & Android\n" + + "App version: %s", + getSdkVersion(), + getBuildTime(), + getBranchName(), + BuildConfig.VERSION_CODE + ); textView.setText(buildInfo); } + private static String getBuildTime() { + return DateFormat.getDateTimeInstance().format(new Date(BuildConfig.BUILD_TIMESTAMP)); + } + + private static String getSdkVersion() { + if (isEmptyOrUnset(BuildConfig.SDK_VERSION)) return "as source code"; + return BuildConfig.SDK_VERSION; + } + + private static String getBranchName() { + if (isEmptyOrUnset(BuildConfig.BRANCH)) return "local development"; + return BuildConfig.BRANCH + "." + BuildConfig.COMMIT; + } + + private static boolean isEmptyOrUnset(String text) { + // When local properties are not set, they have a string value of "null" + return TextUtils.isEmpty(text) || "null".equalsIgnoreCase(text); + } + @NonNull public static MaterialAlertDialogBuilder createAlertDialog(@NonNull Activity activity) { return new MaterialAlertDialogBuilder(activity) diff --git a/samples/java_layout/src/main/res/layout/activity_dashboard.xml b/samples/java_layout/src/main/res/layout/activity_dashboard.xml index 25f7328f..35052e86 100644 --- a/samples/java_layout/src/main/res/layout/activity_dashboard.xml +++ b/samples/java_layout/src/main/res/layout/activity_dashboard.xml @@ -177,7 +177,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/margin_default" - android:gravity="center" android:textAppearance="@style/TextAppearance.Material3.BodySmall" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/samples/java_layout/src/main/res/layout/activity_login.xml b/samples/java_layout/src/main/res/layout/activity_login.xml index bb5c57e2..ef7d4c97 100644 --- a/samples/java_layout/src/main/res/layout/activity_login.xml +++ b/samples/java_layout/src/main/res/layout/activity_login.xml @@ -127,7 +127,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/margin_default" - android:gravity="center" android:textAppearance="@style/TextAppearance.Material3.BodySmall" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/samples/sample-app.gradle b/samples/sample-app.gradle index 7f245045..b424a3c5 100644 --- a/samples/sample-app.gradle +++ b/samples/sample-app.gradle @@ -20,10 +20,17 @@ android { // cdpApiKey=KEY can be used as a fallback for all sample apps String cdpApiKey = getConfigWithPrefix("cdpApiKey") String siteId = getConfigWithPrefix("siteId") + String sdkVersion = localProperties["sdkVersion"] + String branch = localProperties["branch"] + String commit = localProperties["commit"] // Set build config fields for API keys buildConfigField "String", "CDP_API_KEY", "\"${cdpApiKey}\"" buildConfigField "String", "SITE_ID", "\"${siteId}\"" + buildConfigField "String", "SDK_VERSION", "\"${sdkVersion}\"" + buildConfigField "String", "BRANCH", "\"${branch}\"" + buildConfigField "String", "COMMIT", "\"${commit}\"" + buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L" } // Avoid redefining signing configs in sample apps to avoid breaking release // builds (specially on CI servers)