Skip to content

Commit b88112c

Browse files
ADFA-5337 chore(ui): hide the analytics opt-in UI when analytics is compiled out
Follow-up to the conditional Firebase build: when built without google-services.json (BuildConfig.ANALYTICS_ENABLED = false) there is nothing to share, so the opt-in UI should not appear. - SettingsSubFragment: the "Share usage statistics" toggle is not added. - AboutFragment (+ fragment_about.xml): the "Share anonymous data" row + description are GONE (ids added to hide them). - WizardActivity / SetupSectionFragment: the first-run analytics enrollment prompt is skipped and the flow proceeds. No change when analytics is enabled (file present): the UI shows exactly as before.
1 parent 6d48d1a commit b88112c

5 files changed

Lines changed: 35 additions & 13 deletions

File tree

‎controller/app/src/main/java/org/iiab/controller/SetupSectionFragment.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ private void persistSelectedLanguage() {
206206
* the consent and proceeds. Shown at most once (guarded by a flag).
207207
*/
208208
private void maybeShowAnalyticsEnrollment() {
209+
// ADFA-5337: no analytics compiled in (no google-services.json) → nothing to consent to; skip.
210+
if (!BuildConfig.ANALYTICS_ENABLED) {
211+
completeSetup();
212+
return;
213+
}
209214
SharedPreferences delivery = requireContext().getSharedPreferences(
210215
DELIVERY_PREFS, Context.MODE_PRIVATE);
211216
if (delivery.getBoolean(KEY_ENROLLMENT_SHOWN, false)) {

‎controller/app/src/main/java/org/iiab/controller/redesign/SettingsSubFragment.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,14 @@ private void buildAbout(Context ctx, LinearLayout list) {
190190
}
191191
});
192192
SettingsUi.row(ctx, list, getString(R.string.k2go_settings_permissions), null, null, v -> openAppSettings(ctx));
193-
SettingsUi.toggle(ctx, list, getString(R.string.k2go_settings_usage_stats), AnalyticsConsent.isEnabled(ctx), checked -> {
194-
AnalyticsConsent.setEnabled(ctx, checked);
195-
org.iiab.controller.analytics.AnalyticsClient.with(ctx).applyConsent();
196-
});
193+
// ADFA-5337: hide the usage-statistics toggle when analytics is compiled out (no
194+
// google-services.json), since there's nothing to share and the switch would do nothing.
195+
if (org.iiab.controller.BuildConfig.ANALYTICS_ENABLED) {
196+
SettingsUi.toggle(ctx, list, getString(R.string.k2go_settings_usage_stats), AnalyticsConsent.isEnabled(ctx), checked -> {
197+
AnalyticsConsent.setEnabled(ctx, checked);
198+
org.iiab.controller.analytics.AnalyticsClient.with(ctx).applyConsent();
199+
});
200+
}
197201
SettingsUi.preview(ctx, list, getString(R.string.k2go_settings_licenses), null);
198202
SettingsUi.preview(ctx, list, getString(R.string.k2go_settings_privacy), null);
199203
}

‎controller/app/src/main/java/org/iiab/controller/redesign/WizardActivity.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ private void onPrimary() {
198198
/** One-time usage-stats consent prompt; runs {@code onDone} after the choice (or immediately
199199
* if already asked here or in the legacy flow). Reuses the analytics_enroll_* strings. */
200200
private void maybeAskAnalytics(Runnable onDone) {
201+
// ADFA-5337: no analytics compiled in (no google-services.json) → nothing to consent to; skip.
202+
if (!org.iiab.controller.BuildConfig.ANALYTICS_ENABLED) { onDone.run(); return; }
201203
if (AnalyticsConsent.wasAsked(this)) { onDone.run(); return; }
202204
new MaterialAlertDialogBuilder(this)
203205
.setTitle(R.string.analytics_enroll_title)

‎controller/app/src/main/java/org/iiab/controller/settings/AboutFragment.java‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,22 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
3333
TextView versionView = view.findViewById(R.id.about_version);
3434
versionView.setText(getString(R.string.about_version, appVersionName()));
3535

36-
SwitchCompat analytics = view.findViewById(R.id.switch_analytics_consent);
37-
analytics.setChecked(AnalyticsConsent.isEnabled(requireContext()));
38-
analytics.setOnCheckedChangeListener(
39-
(btn, checked) -> {
40-
AnalyticsConsent.setEnabled(requireContext(), checked);
41-
org.iiab.controller.analytics.AnalyticsClient.with(requireContext()).applyConsent();
42-
});
36+
// ADFA-5337: no analytics compiled in (no google-services.json) → hide the whole opt-in block,
37+
// since there's nothing to share and the switch would do nothing.
38+
if (!org.iiab.controller.BuildConfig.ANALYTICS_ENABLED) {
39+
View row = view.findViewById(R.id.analytics_consent_row);
40+
View desc = view.findViewById(R.id.analytics_consent_desc);
41+
if (row != null) row.setVisibility(View.GONE);
42+
if (desc != null) desc.setVisibility(View.GONE);
43+
} else {
44+
SwitchCompat analytics = view.findViewById(R.id.switch_analytics_consent);
45+
analytics.setChecked(AnalyticsConsent.isEnabled(requireContext()));
46+
analytics.setOnCheckedChangeListener(
47+
(btn, checked) -> {
48+
AnalyticsConsent.setEnabled(requireContext(), checked);
49+
org.iiab.controller.analytics.AnalyticsClient.with(requireContext()).applyConsent();
50+
});
51+
}
4352
}
4453

4554
private String appVersionName() {

‎controller/app/src/main/res/layout/fragment_about.xml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
<View android:layout_width="match_parent" android:layout_height="1dp"
2222
android:layout_marginTop="24dp" android:background="@color/chrome_ripple"/>
2323

24-
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
24+
<LinearLayout android:id="@+id/analytics_consent_row"
25+
android:layout_width="match_parent" android:layout_height="wrap_content"
2526
android:orientation="horizontal" android:gravity="center_vertical"
2627
android:layout_marginTop="20dp">
2728
<TextView android:layout_width="0dp" android:layout_height="wrap_content"
@@ -32,7 +33,8 @@
3233
android:id="@+id/switch_analytics_consent"
3334
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
3435
</LinearLayout>
35-
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
36+
<TextView android:id="@+id/analytics_consent_desc"
37+
android:layout_width="match_parent" android:layout_height="wrap_content"
3638
android:layout_marginTop="6dp"
3739
android:text="@string/settings_analytics_desc"
3840
android:textSize="13sp"/>

0 commit comments

Comments
 (0)