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

Commit 26c4909

Browse files
committed
Set up basic user login.
1 parent f175bf6 commit 26c4909

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

asset-browser-ui/app/src/main/java/com/adobe/assetbrowserui/MainActivity.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,31 @@
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+
private AdobeUXAuthManager mUXAuthManager = AdobeUXAuthManager.getSharedAuthManager();
21+
private AdobeAuthSessionHelper mAuthSessionHelper;
22+
1423
@Override
1524
protected void onCreate(Bundle savedInstanceState) {
1625
super.onCreate(savedInstanceState);
1726
setContentView(R.layout.activity_main);
1827
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
1928
setSupportActionBar(toolbar);
2029

30+
mAuthSessionHelper = new AdobeAuthSessionHelper(mStatusCallback);
31+
mAuthSessionHelper.onCreate(savedInstanceState);
32+
2133
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
2234
fab.setOnClickListener(new View.OnClickListener() {
2335
@Override
@@ -28,6 +40,37 @@ public void onClick(View view) {
2840
});
2941
}
3042

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

0 commit comments

Comments
 (0)