adal change

parent c5ee77ec
......@@ -34,6 +34,7 @@ import com.microsoft.aad.adal.PromptBehavior;
import com.microsoft.aad.adal.Telemetry;
import com.vsoft.vera.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
......@@ -188,14 +189,16 @@ public class ADALActivity extends AppCompatActivity {
} catch (Exception e) {
Log.d(TAG, "Failed to put parameters: " + e.toString());
}
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, MSGRAPH_URL,
final JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, MSGRAPH_URL,
parameters,new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
/* Successfully called graph, process data and send to UI */
Log.d(TAG, "Response: " + response.toString());
updateGraphUI(response);
}
}, new Response.ErrorListener() {
@Override
......@@ -246,19 +249,19 @@ public class ADALActivity extends AppCompatActivity {
private void updateSuccessUI() {
// Called on success from /me endpoint
// Removed call Graph API button and paint Sign out
callGraphButton.setVisibility(View.INVISIBLE);
signOutButton.setVisibility(View.VISIBLE);
findViewById(R.id.welcome).setVisibility(View.VISIBLE);
callGraphButton.setVisibility(View.VISIBLE);
signOutButton.setVisibility(View.GONE);
findViewById(R.id.welcome).setVisibility(View.GONE);
((TextView) findViewById(R.id.welcome)).setText("Welcome, " +
mAuthResult.getUserInfo().getGivenName());
findViewById(R.id.graphData).setVisibility(View.VISIBLE);
findViewById(R.id.graphData).setVisibility(View.GONE);
}
@SuppressLint("SetTextI18n")
private void updateSignedOutUI() {
callGraphButton.setVisibility(View.VISIBLE);
signOutButton.setVisibility(View.INVISIBLE);
signOutButton.setVisibility(View.GONE);
findViewById(R.id.welcome).setVisibility(View.INVISIBLE);
findViewById(R.id.graphData).setVisibility(View.INVISIBLE);
((TextView) findViewById(R.id.graphData)).setText("No Data");
......
......@@ -37,6 +37,7 @@ import com.vsoft.vera.CatalogueApplication;
import com.vsoft.vera.R;
import com.vsoft.vera.db.models.UserApiValues;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
......@@ -113,10 +114,10 @@ public class LoginChooseActivity extends Activity {
loginSSO.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginChooseActivity.this,ADALActivity.class);
startActivity(intent);
// Intent intent = new Intent(LoginChooseActivity.this,ADALActivity.class);
// startActivity(intent);
// onCallGraphClicked();
onCallGraphClicked();
}
});
loginOTP.setOnClickListener(new View.OnClickListener() {
......@@ -196,6 +197,16 @@ public class LoginChooseActivity extends Activity {
Log.d(TAG, "Response: " + response.toString());
updateGraphUI(response);
JSONObject root = null;
try {
root = new JSONObject(response.toString());
String userLoginName = root.getString("givenName");
} catch (JSONException e) {
e.printStackTrace();
}
// updateGraphUI(response);
}
}, new Response.ErrorListener() {
@Override
......@@ -238,26 +249,19 @@ public class LoginChooseActivity extends Activity {
private void updateGraphUI(JSONObject response) {
// Called on success from /me endpoint
// Writes graph data to the UI
TextView graphText = (TextView) findViewById(R.id.graphData);
graphText.setText(response.toString());
// TextView graphText = (TextView) findViewById(R.id.graphData);
// graphText.setText(response.toString());
}
@SuppressLint("SetTextI18n")
private void updateSuccessUI() {
// Called on success from /me endpoint
// Removed call Graph API button and paint Sign out
findViewById(R.id.welcome).setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.welcome)).setText("Welcome, " +
mAuthResult.getUserInfo().getGivenName());
findViewById(R.id.graphData).setVisibility(View.VISIBLE);
}
@SuppressLint("SetTextI18n")
private void updateSignedOutUI() {
findViewById(R.id.welcome).setVisibility(View.INVISIBLE);
findViewById(R.id.graphData).setVisibility(View.INVISIBLE);
((TextView) findViewById(R.id.graphData)).setText("No Data");
}
//
......
......@@ -49,7 +49,7 @@ public class SplashScreen extends Activity {
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, LoginChooseActivity.class);
Intent i = new Intent(SplashScreen.this, ADALActivity.class);
startActivity(i);
// close this activity
......
......@@ -17,17 +17,45 @@
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:id="@+id/welcome"
android:visibility="invisible"/>
android:visibility="gone"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_marginTop="50dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/ic_login_banner" />
<Button
android:id="@+id/callGraph"
android:text="Call Graph"
android:textColor="#FFFFFF"
android:background="#00a1f1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:textAllCaps="false" />
android:layout_marginBottom="@dimen/normal_margin"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:layout_marginTop="30dp"
android:background="@drawable/login_bg"
android:gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="Login with ADAL"
android:textColor="@android:color/white"
android:textSize="@dimen/large_text_size" />
<Button
android:id="@+id/login_with_otp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:layout_marginTop="30dp"
android:background="@drawable/login_bg"
android:gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="Login with otp"
android:textColor="@android:color/white"
android:textSize="@dimen/large_text_size" />
<TextView
android:text="Loading"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment