5
5
import android .support .design .widget .Snackbar ;
6
6
import android .support .v7 .app .AppCompatActivity ;
7
7
import android .support .v7 .widget .Toolbar ;
8
- import android .view . View ;
8
+ import android .util . Log ;
9
9
import android .view .Menu ;
10
10
import android .view .MenuItem ;
11
+ import android .view .View ;
12
+
13
+ import com .adobe .creativesdk .foundation .auth .AdobeAuthException ;
14
+ import com .adobe .creativesdk .foundation .auth .AdobeAuthSessionHelper ;
15
+ import com .adobe .creativesdk .foundation .auth .AdobeAuthSessionLauncher ;
16
+ import com .adobe .creativesdk .foundation .auth .AdobeUXAuthManager ;
11
17
12
18
public class MainActivity extends AppCompatActivity {
13
19
20
+ private AdobeUXAuthManager mUXAuthManager = AdobeUXAuthManager .getSharedAuthManager ();
21
+ private AdobeAuthSessionHelper mAuthSessionHelper ;
22
+
14
23
@ Override
15
24
protected void onCreate (Bundle savedInstanceState ) {
16
25
super .onCreate (savedInstanceState );
17
26
setContentView (R .layout .activity_main );
18
27
Toolbar toolbar = (Toolbar ) findViewById (R .id .toolbar );
19
28
setSupportActionBar (toolbar );
20
29
30
+ mAuthSessionHelper = new AdobeAuthSessionHelper (mStatusCallback );
31
+ mAuthSessionHelper .onCreate (savedInstanceState );
32
+
21
33
FloatingActionButton fab = (FloatingActionButton ) findViewById (R .id .fab );
22
34
fab .setOnClickListener (new View .OnClickListener () {
23
35
@ Override
@@ -28,6 +40,37 @@ public void onClick(View view) {
28
40
});
29
41
}
30
42
43
+ private AdobeAuthSessionHelper .IAdobeAuthStatusCallback mStatusCallback ;
44
+ {
45
+ mStatusCallback = new AdobeAuthSessionHelper .IAdobeAuthStatusCallback () {
46
+ @ Override
47
+ public void call (AdobeAuthSessionHelper .AdobeAuthStatus adobeAuthStatus , AdobeAuthException e ) {
48
+ if (AdobeAuthSessionHelper .AdobeAuthStatus .AdobeAuthLoggedIn == adobeAuthStatus ) {
49
+ /* 3 */
50
+ showAuthenticatedUI ();
51
+ } else {
52
+ /* 4 */
53
+ showAdobeLoginUI ();
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ private void showAdobeLoginUI () {
60
+ mUXAuthManager .login (new AdobeAuthSessionLauncher .Builder ()
61
+ .withActivity (this )
62
+ .withRequestCode (200 ) // Can be any int
63
+ .build ()
64
+ );
65
+ }
66
+
67
+ private void showAuthenticatedUI () {
68
+
69
+ /* 5 */
70
+ Log .i (MainActivity .class .getSimpleName (), "User is logged in!" );
71
+
72
+ }
73
+
31
74
@ Override
32
75
public boolean onCreateOptionsMenu (Menu menu ) {
33
76
// Inflate the menu; this adds items to the action bar if it is present.
0 commit comments