Skip to content
This repository was archived by the owner on Jul 27, 2019. It is now read-only.

Commit 0a995ca

Browse files
committed
Handling initial login logic.
1 parent d0d682a commit 0a995ca

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

user-auth-ui/app/src/main/java/com/adobe/userauthui/MainActivity.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,33 @@
55
import android.support.design.widget.Snackbar;
66
import android.support.v7.app.AppCompatActivity;
77
import android.support.v7.widget.Toolbar;
8-
import android.view.View;
8+
import android.util.Log;
99
import android.view.Menu;
1010
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;
1117

1218
public class MainActivity extends AppCompatActivity {
1319

20+
/* 1 */
21+
private AdobeUXAuthManager mUXAuthManager = AdobeUXAuthManager.getSharedAuthManager();
22+
private AdobeAuthSessionHelper mAuthSessionHelper;
23+
1424
@Override
1525
protected void onCreate(Bundle savedInstanceState) {
1626
super.onCreate(savedInstanceState);
1727
setContentView(R.layout.activity_main);
1828
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
1929
setSupportActionBar(toolbar);
2030

31+
/* 2 */
32+
mAuthSessionHelper = new AdobeAuthSessionHelper(mStatusCallback);
33+
mAuthSessionHelper.onCreate(savedInstanceState);
34+
2135
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
2236
fab.setOnClickListener(new View.OnClickListener() {
2337
@Override
@@ -28,6 +42,37 @@ public void onClick(View view) {
2842
});
2943
}
3044

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+
3176
@Override
3277
public boolean onCreateOptionsMenu(Menu menu) {
3378
// Inflate the menu; this adds items to the action bar if it is present.

0 commit comments

Comments
 (0)