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