Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.d4rk.androidtutorials.java.databinding.ActivityMainBinding;
import com.d4rk.androidtutorials.java.ui.components.navigation.BottomSheetMenuFragment;
import com.d4rk.androidtutorials.java.ui.screens.startup.StartupActivity;
import com.d4rk.androidtutorials.java.ui.screens.startup.StartupViewModel;
import com.d4rk.androidtutorials.java.ui.screens.support.SupportActivity;
import com.d4rk.androidtutorials.java.utils.ConsentUtils;
import com.d4rk.androidtutorials.java.utils.EdgeToEdgeDelegate;
Expand All @@ -49,6 +50,9 @@
import com.google.android.play.core.install.model.AppUpdateType;
import com.google.android.play.core.install.model.InstallStatus;
import com.google.android.play.core.install.model.UpdateAvailability;
import com.google.android.ump.ConsentInformation;
import com.google.android.ump.ConsentRequestParameters;
import com.google.android.ump.UserMessagingPlatform;

import dagger.hilt.android.AndroidEntryPoint;

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

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

// Fallback: show the consent form again if required.
ConsentInformation consentInformation = UserMessagingPlatform.getConsentInformation(this);
if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
StartupViewModel consentViewModel = new ViewModelProvider(this).get(StartupViewModel.class);
ConsentRequestParameters params = new ConsentRequestParameters.Builder().build();
consentViewModel.requestConsentInfoUpdate(this, params,
() -> consentViewModel.loadConsentForm(this, null), null);
}

setupActionBar();
observeViewModel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
import com.d4rk.androidtutorials.java.R;
import com.d4rk.androidtutorials.java.databinding.ActivityOnboardingBinding;
import com.d4rk.androidtutorials.java.ui.screens.main.MainActivity;
import com.d4rk.androidtutorials.java.ui.screens.startup.StartupViewModel;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.android.ump.ConsentInformation;
import com.google.android.ump.ConsentRequestParameters;
import com.google.android.ump.UserMessagingPlatform;

import dagger.hilt.android.AndroidEntryPoint;

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

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

// Fallback: show the consent form again if required.
ConsentInformation consentInformation = UserMessagingPlatform.getConsentInformation(this);
if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
StartupViewModel consentViewModel = new ViewModelProvider(this).get(StartupViewModel.class);
ConsentRequestParameters params = new ConsentRequestParameters.Builder().build();
consentViewModel.requestConsentInfoUpdate(this, params,
() -> consentViewModel.loadConsentForm(this, null), null);
}

adapter = new OnboardingPagerAdapter(this);
binding.viewPager.setAdapter(adapter);
int startPage = viewModel.getCurrentPage();
Expand Down
Loading