Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f178054

Browse files
Merge pull request #154 from MihaiCristianCondrea/codex/implement-consent-fallback-behavior
Add consent UMP fallback checks in onboarding and main
2 parents bf687ad + 4e0ae66 commit f178054

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/main/MainActivity.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.d4rk.androidtutorials.java.databinding.ActivityMainBinding;
3636
import com.d4rk.androidtutorials.java.ui.components.navigation.BottomSheetMenuFragment;
3737
import com.d4rk.androidtutorials.java.ui.screens.startup.StartupActivity;
38+
import com.d4rk.androidtutorials.java.ui.screens.startup.StartupViewModel;
3839
import com.d4rk.androidtutorials.java.ui.screens.support.SupportActivity;
3940
import com.d4rk.androidtutorials.java.utils.ConsentUtils;
4041
import com.d4rk.androidtutorials.java.utils.EdgeToEdgeDelegate;
@@ -49,6 +50,9 @@
4950
import com.google.android.play.core.install.model.AppUpdateType;
5051
import com.google.android.play.core.install.model.InstallStatus;
5152
import com.google.android.play.core.install.model.UpdateAvailability;
53+
import com.google.android.ump.ConsentInformation;
54+
import com.google.android.ump.ConsentRequestParameters;
55+
import com.google.android.ump.UserMessagingPlatform;
5256

5357
import dagger.hilt.android.AndroidEntryPoint;
5458

@@ -108,6 +112,15 @@ protected void onCreate(Bundle savedInstanceState) {
108112

109113
mainViewModel = new ViewModelProvider(this).get(MainViewModel.class);
110114

115+
// Fallback: show the consent form again if required.
116+
ConsentInformation consentInformation = UserMessagingPlatform.getConsentInformation(this);
117+
if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
118+
StartupViewModel consentViewModel = new ViewModelProvider(this).get(StartupViewModel.class);
119+
ConsentRequestParameters params = new ConsentRequestParameters.Builder().build();
120+
consentViewModel.requestConsentInfoUpdate(this, params,
121+
() -> consentViewModel.loadConsentForm(this, null), null);
122+
}
123+
111124
setupActionBar();
112125
observeViewModel();
113126

‎app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/onboarding/OnboardingActivity.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
import com.d4rk.androidtutorials.java.R;
1616
import com.d4rk.androidtutorials.java.databinding.ActivityOnboardingBinding;
1717
import com.d4rk.androidtutorials.java.ui.screens.main.MainActivity;
18+
import com.d4rk.androidtutorials.java.ui.screens.startup.StartupViewModel;
1819
import com.google.android.material.tabs.TabLayout;
1920
import com.google.android.material.tabs.TabLayoutMediator;
21+
import com.google.android.ump.ConsentInformation;
22+
import com.google.android.ump.ConsentRequestParameters;
23+
import com.google.android.ump.UserMessagingPlatform;
2024

2125
import dagger.hilt.android.AndroidEntryPoint;
2226

@@ -36,6 +40,15 @@ protected void onCreate(Bundle savedInstanceState) {
3640

3741
viewModel = new ViewModelProvider(this).get(OnboardingViewModel.class);
3842

43+
// Fallback: show the consent form again if required.
44+
ConsentInformation consentInformation = UserMessagingPlatform.getConsentInformation(this);
45+
if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
46+
StartupViewModel consentViewModel = new ViewModelProvider(this).get(StartupViewModel.class);
47+
ConsentRequestParameters params = new ConsentRequestParameters.Builder().build();
48+
consentViewModel.requestConsentInfoUpdate(this, params,
49+
() -> consentViewModel.loadConsentForm(this, null), null);
50+
}
51+
3952
adapter = new OnboardingPagerAdapter(this);
4053
binding.viewPager.setAdapter(adapter);
4154
int startPage = viewModel.getCurrentPage();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /