1
1
package com .d4rk .androidtutorials .java .ui .screens .startup ;
2
2
3
- import android .Manifest ;
4
3
import android .content .Intent ;
5
4
import android .net .Uri ;
6
- import android .os .Build ;
7
5
import android .os .Bundle ;
8
6
9
7
import androidx .appcompat .app .AppCompatActivity ;
10
- import androidx .lifecycle .ViewModelProvider ;
11
8
12
- import com .d4rk .androidtutorials .java .R ;
13
9
import com .d4rk .androidtutorials .java .databinding .ActivityStartupBinding ;
14
10
import 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 ;
23
11
24
12
import dagger .hilt .android .AndroidEntryPoint ;
13
+ import me .zhanghai .android .fastscroll .FastScrollerBuilder ;
25
14
26
15
@ AndroidEntryPoint
27
16
public class StartupActivity extends AppCompatActivity {
28
17
29
- private StartupViewModel startupViewModel ;
30
- private ConsentInformation consentInformation ;
31
-
32
18
@ Override
33
19
protected void onCreate (Bundle savedInstanceState ) {
34
20
super .onCreate (savedInstanceState );
35
- com . d4rk . androidtutorials . java . databinding . ActivityStartupBinding binding = ActivityStartupBinding .inflate (getLayoutInflater ());
21
+ ActivityStartupBinding binding = ActivityStartupBinding .inflate (getLayoutInflater ());
36
22
setContentView (binding .getRoot ());
37
23
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
-
64
24
new FastScrollerBuilder (binding .scrollView )
65
25
.useMd2Style ()
66
26
.build ();
@@ -71,23 +31,8 @@ protected void onCreate(Bundle savedInstanceState) {
71
31
);
72
32
73
33
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 ();
81
36
});
82
-
83
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
84
- requestPermissions (new String []{Manifest .permission .POST_NOTIFICATIONS }, 1 );
85
- }
86
37
}
87
-
88
- private void proceedToMainActivity () {
89
- startActivity (new Intent (this , MainActivity .class ));
90
- finish ();
91
- }
92
-
93
38
}
0 commit comments