Skip to content

Commit

Permalink
Merge branch 'main' into gist-web-rendering-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 authored Nov 12, 2024
2 parents f00844c + 7bde5d8 commit fb1fa71
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/reusable_build_sample_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static CustomerIOSDKConfig getDefaultConfigurations() {
CioLogLevel.DEBUG,
Region.US.INSTANCE,
true,
true,
false,
true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion samples/java_layout/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions samples/sample-app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fb1fa71

Please sign in to comment.