11package com .d4rk .androidtutorials .java .ui .screens .startup ;
22
3- import android .Manifest ;
43import android .content .Intent ;
54import android .net .Uri ;
6- import android .os .Build ;
75import android .os .Bundle ;
86
97import androidx .appcompat .app .AppCompatActivity ;
10- import androidx .lifecycle .ViewModelProvider ;
118
12- import com .d4rk .androidtutorials .java .R ;
139import com .d4rk .androidtutorials .java .databinding .ActivityStartupBinding ;
1410import com .d4rk .androidtutorials .java .ui .screens .main .MainActivity ;
15- import com .d4rk .androidtutorials .java .ui .screens .startup .dialogs .ConsentDialogFragment ;
16- import com .google .android .ump .ConsentInformation ;
17- import com .google .android .ump .ConsentRequestParameters ;
18- import com .google .android .ump .UserMessagingPlatform ;
19- import com .d4rk .androidtutorials .java .utils .ConsentUtils ;
20-
21-
22- import me .zhanghai .android .fastscroll .FastScrollerBuilder ;
2311
2412import dagger .hilt .android .AndroidEntryPoint ;
13+ import me .zhanghai .android .fastscroll .FastScrollerBuilder ;
2514
2615@ AndroidEntryPoint
2716public class StartupActivity extends AppCompatActivity {
2817
29- private StartupViewModel startupViewModel ;
30- private ConsentInformation consentInformation ;
31-
3218 @ Override
3319 protected void onCreate (Bundle savedInstanceState ) {
3420 super .onCreate (savedInstanceState );
35- com . d4rk . androidtutorials . java . databinding . ActivityStartupBinding binding = ActivityStartupBinding .inflate (getLayoutInflater ());
21+ ActivityStartupBinding binding = ActivityStartupBinding .inflate (getLayoutInflater ());
3622 setContentView (binding .getRoot ());
3723
38- ConsentUtils .applyStoredConsent (this );
39-
40- startupViewModel = new ViewModelProvider (this ).get (StartupViewModel .class );
41-
42- consentInformation = UserMessagingPlatform .getConsentInformation (this );
43- ConsentRequestParameters params = new ConsentRequestParameters .Builder ()
44- .setTagForUnderAgeOfConsent (false )
45- .build ();
46-
47- startupViewModel .requestConsentInfoUpdate (
48- this ,
49- params ,
50- () -> {
51- if (consentInformation .isConsentFormAvailable ()) {
52- startupViewModel .loadConsentForm (
53- this ,
54- formError -> ConsentUtils .updateFirebaseConsent (this ,
55- false , false , false , false )
56- );
57- } else if (consentInformation .getConsentStatus () == ConsentInformation .ConsentStatus .OBTAINED ) {
58- ConsentUtils .applyStoredConsent (this );
59- }
60- },
61- formError -> {}
62- );
63-
6424 new FastScrollerBuilder (binding .scrollView )
6525 .useMd2Style ()
6626 .build ();
@@ -71,23 +31,8 @@ protected void onCreate(Bundle savedInstanceState) {
7131 );
7232
7333 binding .floatingButtonAgree .setOnClickListener (v -> {
74- ConsentDialogFragment dialog = new ConsentDialogFragment ();
75- dialog .setConsentListener ((analytics , adStorage , adUserData , adPersonalization ) -> {
76- ConsentUtils .updateFirebaseConsent (this ,
77- analytics , adStorage , adUserData , adPersonalization );
78- proceedToMainActivity ();
79- });
80- dialog .show (getSupportFragmentManager (), "consent_dialog" );
34+ startActivity (new Intent (this , MainActivity .class ));
35+ finish ();
8136 });
82-
83- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
84- requestPermissions (new String []{Manifest .permission .POST_NOTIFICATIONS }, 1 );
85- }
8637 }
87-
88- private void proceedToMainActivity () {
89- startActivity (new Intent (this , MainActivity .class ));
90- finish ();
91- }
92-
9338}
0 commit comments