Added new coursework, cleaned up structure
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.corwinperren.httpoauth">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="com.example.corwinperren.httpoauth" android:host="oauth"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ShowPostsActivity"></activity>
|
||||
<activity android:name=".SubmitPostActivity"></activity>
|
||||
<activity android:name=".GoogleAuthCompleteActivity"></activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.example.corwinperren.httpoauth;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
|
||||
import net.openid.appauth.AuthState;
|
||||
import net.openid.appauth.AuthorizationException;
|
||||
import net.openid.appauth.AuthorizationResponse;
|
||||
import net.openid.appauth.AuthorizationService;
|
||||
import net.openid.appauth.TokenResponse;
|
||||
|
||||
|
||||
public class GoogleAuthCompleteActivity extends AppCompatActivity {
|
||||
private AuthorizationService mAuthorizationService;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mAuthorizationService = new AuthorizationService(this);
|
||||
|
||||
AuthorizationResponse resp = AuthorizationResponse.fromIntent(getIntent());
|
||||
AuthorizationException ex = AuthorizationException.fromIntent(getIntent());
|
||||
|
||||
if(resp != null){
|
||||
final AuthState authState = new AuthState(resp, ex);
|
||||
mAuthorizationService.performTokenRequest(resp.createTokenExchangeRequest(),
|
||||
new AuthorizationService.TokenResponseCallback() {
|
||||
@Override
|
||||
public void onTokenRequestCompleted(@Nullable TokenResponse tokenResponse, @Nullable AuthorizationException e) {
|
||||
authState.update(tokenResponse,e);
|
||||
SharedPreferences authPreferences = getSharedPreferences("auth", MODE_PRIVATE);
|
||||
authPreferences.edit().putString("stateJson", authState.jsonSerializeString()).apply();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.example.corwinperren.httpoauth;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import net.openid.appauth.AuthState;
|
||||
import net.openid.appauth.AuthorizationRequest;
|
||||
import net.openid.appauth.AuthorizationService;
|
||||
import net.openid.appauth.AuthorizationServiceConfiguration;
|
||||
import net.openid.appauth.ResponseTypeValues;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
private String mClientIDString = "106019908752-hkcvokpsq34vg0795mbhm42mbitqocub.apps.googleusercontent.com";
|
||||
|
||||
public AuthorizationService mAuthorizationService;
|
||||
|
||||
Button gplus_login_button;
|
||||
Button show_posts_button;
|
||||
Button submit_new_post_button;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mAuthorizationService = new AuthorizationService(this);
|
||||
|
||||
gplus_login_button = (Button) findViewById(R.id.gplus_login_button);
|
||||
show_posts_button = (Button) findViewById(R.id.show_posts_button);
|
||||
submit_new_post_button = (Button) findViewById(R.id.submit_new_post_button);
|
||||
|
||||
setupButtonHandlers();
|
||||
}
|
||||
|
||||
private void setupButtonHandlers(){
|
||||
gplus_login_button.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
getOrCreateAuthState();
|
||||
}
|
||||
});
|
||||
|
||||
show_posts_button.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
Intent intent = new Intent(MainActivity.this, ShowPostsActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
submit_new_post_button.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
Intent intent = new Intent(MainActivity.this, SubmitPostActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void request_authorization(){
|
||||
Uri authEndpoint = new Uri.Builder().scheme("https").authority("accounts.google.com").path("/o/oauth2/v2/auth").build();
|
||||
Uri tokenEndpoint = new Uri.Builder().scheme("https").authority("www.googleapis.com").path("/oauth2/v4/token").build();
|
||||
Uri redirect = new Uri.Builder().scheme("com.example.corwinperren.httpoauth").path("oauth").build();
|
||||
|
||||
AuthorizationServiceConfiguration config = new AuthorizationServiceConfiguration(authEndpoint, tokenEndpoint, null);
|
||||
AuthorizationRequest req = new AuthorizationRequest.Builder(config, mClientIDString, ResponseTypeValues.CODE, redirect)
|
||||
.setScopes("https://www.googleapis.com/auth/plus.me", "https://www.googleapis.com/auth/plus.stream.write", "https://www.googleapis.com/auth/plus.stream.read")
|
||||
.build();
|
||||
|
||||
Intent authComplete = new Intent(this, GoogleAuthCompleteActivity.class);
|
||||
mAuthorizationService.performAuthorizationRequest(req, PendingIntent.getActivity(this, req.hashCode(), authComplete, 0));
|
||||
}
|
||||
|
||||
AuthState getOrCreateAuthState() {
|
||||
AuthState auth = null;
|
||||
SharedPreferences authPreference = getSharedPreferences("auth", MODE_PRIVATE);
|
||||
String stateJson = authPreference.getString("stateJson", null);
|
||||
if (stateJson != null) {
|
||||
try {
|
||||
auth = AuthState.jsonDeserialize(stateJson);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (auth != null && auth.getAccessToken() != null) {
|
||||
return auth;
|
||||
} else {
|
||||
request_authorization();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package com.example.corwinperren.httpoauth;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.openid.appauth.AuthState;
|
||||
import net.openid.appauth.AuthorizationException;
|
||||
import net.openid.appauth.AuthorizationService;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ShowPostsActivity extends AppCompatActivity {
|
||||
|
||||
TextView first_published_text_view;
|
||||
TextView first_content_text_view;
|
||||
|
||||
TextView second_published_header_text_view;
|
||||
TextView second_published_text_view;
|
||||
TextView second_content_text_view;
|
||||
|
||||
TextView third_published_header_text_view;
|
||||
TextView third_published_text_view;
|
||||
TextView third_content_text_view;
|
||||
|
||||
private AuthorizationService mAuthorizationService;
|
||||
private AuthState mAuthState;
|
||||
private OkHttpClient mOkHttpClient;
|
||||
|
||||
SharedPreferences authPreference;
|
||||
String stateJson;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.show_posts_activity);
|
||||
|
||||
first_published_text_view = (TextView) findViewById(R.id.first_published_text_view);
|
||||
first_content_text_view = (TextView) findViewById(R.id.first_content_text_view);
|
||||
|
||||
second_published_header_text_view = (TextView) findViewById(R.id.second_published_header_text_view);
|
||||
second_published_text_view = (TextView) findViewById(R.id.second_published_text_view);
|
||||
second_content_text_view = (TextView) findViewById(R.id.second_content_text_view);
|
||||
|
||||
third_published_header_text_view = (TextView) findViewById(R.id.third_published_header_text_view);
|
||||
third_published_text_view = (TextView) findViewById(R.id.third_published_text_view);
|
||||
third_content_text_view = (TextView) findViewById(R.id.third_content_text_view);
|
||||
|
||||
first_published_text_view.setText("Loading...");
|
||||
first_content_text_view.setText("Loading...");
|
||||
second_published_text_view.setText("Loading...");
|
||||
second_content_text_view.setText("Loading...");
|
||||
third_published_text_view.setText("Loading...");
|
||||
third_content_text_view.setText("Loading...");
|
||||
|
||||
second_published_header_text_view.setVisibility(View.INVISIBLE);
|
||||
second_published_text_view.setVisibility(View.INVISIBLE);
|
||||
second_content_text_view.setVisibility(View.INVISIBLE);
|
||||
|
||||
third_published_header_text_view.setVisibility(View.INVISIBLE);
|
||||
third_published_text_view.setVisibility(View.INVISIBLE);
|
||||
third_content_text_view.setVisibility(View.INVISIBLE);
|
||||
|
||||
|
||||
mAuthorizationService = new AuthorizationService(this);
|
||||
|
||||
authPreference = getSharedPreferences("auth", MODE_PRIVATE);
|
||||
stateJson = authPreference.getString("stateJson", null);
|
||||
|
||||
update_list();
|
||||
}
|
||||
|
||||
private void update_list(){
|
||||
authPreference = getSharedPreferences("auth", MODE_PRIVATE);
|
||||
stateJson = authPreference.getString("stateJson", null);
|
||||
|
||||
if(stateJson != null){
|
||||
|
||||
try{
|
||||
mAuthState = AuthState.jsonDeserialize(stateJson);
|
||||
mAuthState.performActionWithFreshTokens(mAuthorizationService, auth_state_action);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
first_published_text_view.setText("Not Logged In!");
|
||||
first_content_text_view.setText("Not Logged In!");
|
||||
}
|
||||
}
|
||||
|
||||
public AuthState.AuthStateAction auth_state_action = new AuthState.AuthStateAction() {
|
||||
@Override
|
||||
public void execute(@Nullable String accessToken, @Nullable String idToken, @Nullable AuthorizationException e) {
|
||||
if(e == null){
|
||||
mOkHttpClient = new OkHttpClient();
|
||||
HttpUrl reqUrl = HttpUrl.parse("https://www.googleapis.com/plusDomains/v1/people/me/activities/user");
|
||||
Request request = new Request.Builder()
|
||||
.url(reqUrl)
|
||||
.addHeader("Authorization", "Bearer " + accessToken)
|
||||
.build();
|
||||
mOkHttpClient.newCall(request).enqueue(http_response_callback);
|
||||
}else{
|
||||
Log.d(MainActivity.TAG, "Authstate execution failed");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public Callback http_response_callback = new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String r = response.body().string();
|
||||
try {
|
||||
JSONObject j = new JSONObject(r);
|
||||
final JSONArray items = j.getJSONArray("items");
|
||||
|
||||
final Integer num_posts = items.length();
|
||||
|
||||
if (num_posts > 0){
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
first_published_text_view.setText(items.getJSONObject(0).getString("published"));
|
||||
first_content_text_view.setText(items.getJSONObject(0).getString("title"));
|
||||
|
||||
if(num_posts > 1){
|
||||
second_published_text_view.setText(items.getJSONObject(1).getString("published"));
|
||||
second_content_text_view.setText(items.getJSONObject(1).getString("title"));
|
||||
|
||||
second_published_header_text_view.setVisibility(View.VISIBLE);
|
||||
second_published_text_view.setVisibility(View.VISIBLE);
|
||||
second_content_text_view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if(num_posts > 2){
|
||||
third_published_text_view.setText(items.getJSONObject(2).getString("published"));
|
||||
third_content_text_view.setText(items.getJSONObject(2).getString("title"));
|
||||
|
||||
third_published_header_text_view.setVisibility(View.VISIBLE);
|
||||
third_published_text_view.setVisibility(View.VISIBLE);
|
||||
third_content_text_view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}catch (JSONException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
first_published_text_view.setText("No posts to display.");
|
||||
first_content_text_view.setText("No posts to display.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
} catch (JSONException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.example.corwinperren.httpoauth;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import net.openid.appauth.AuthState;
|
||||
import net.openid.appauth.AuthorizationException;
|
||||
import net.openid.appauth.AuthorizationService;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
||||
public class SubmitPostActivity extends AppCompatActivity {
|
||||
|
||||
EditText submit_edit_text;
|
||||
Button submit_button;
|
||||
|
||||
private AuthorizationService mAuthorizationService;
|
||||
private AuthState mAuthState;
|
||||
private OkHttpClient mOkHttpClient;
|
||||
|
||||
SharedPreferences authPreference;
|
||||
String stateJson;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.submit_post_activity);
|
||||
|
||||
submit_edit_text = (EditText) findViewById(R.id.submit_edit_text);
|
||||
submit_button = (Button) findViewById(R.id.submit_submit_button);
|
||||
|
||||
mAuthorizationService = new AuthorizationService(this);
|
||||
|
||||
authPreference = getSharedPreferences("auth", MODE_PRIVATE);
|
||||
stateJson = authPreference.getString("stateJson", null);
|
||||
|
||||
setupButtonHandlers();
|
||||
}
|
||||
|
||||
private void setupButtonHandlers(){
|
||||
if(stateJson != null){
|
||||
submit_button.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
post_to_gplus();
|
||||
}
|
||||
});
|
||||
submit_button.setEnabled(true);
|
||||
|
||||
}else{
|
||||
submit_button.setEnabled(false);
|
||||
submit_edit_text.setHint("Not Logged In!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void post_to_gplus(){
|
||||
|
||||
try{
|
||||
mAuthState = AuthState.jsonDeserialize(stateJson);
|
||||
mAuthState.performActionWithFreshTokens(mAuthorizationService, auth_state_action);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public AuthState.AuthStateAction auth_state_action = new AuthState.AuthStateAction() {
|
||||
@Override
|
||||
public void execute(@Nullable String accessToken, @Nullable String idToken, @Nullable AuthorizationException e) {
|
||||
if(e == null){
|
||||
String text_to_post = submit_edit_text.getText().toString();
|
||||
|
||||
mOkHttpClient = new OkHttpClient();
|
||||
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
JSONObject json_google_object = new JSONObject();
|
||||
JSONObject json_google_access = new JSONObject();
|
||||
JSONObject jsonBody = new JSONObject();
|
||||
|
||||
try {
|
||||
json_google_object.put("originalContent", text_to_post);
|
||||
json_google_access.put("domainRestricted", true);
|
||||
jsonBody.put("object", json_google_object);
|
||||
jsonBody.put("access", json_google_access);
|
||||
} catch(Exception e1){
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
RequestBody body = RequestBody.create(JSON, jsonBody.toString());
|
||||
|
||||
HttpUrl reqUrl = HttpUrl.parse("https://www.googleapis.com/plusDomains/v1/people/me/activities");
|
||||
Request request = new Request.Builder()
|
||||
.url(reqUrl)
|
||||
.post(body)
|
||||
.addHeader("Authorization", "Bearer " + accessToken)
|
||||
.build();
|
||||
mOkHttpClient.newCall(request).enqueue(http_response_callback);
|
||||
}else{
|
||||
Log.d(MainActivity.TAG, "Authstate execution failed");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public Callback http_response_callback = new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
// String r = response.body().string();
|
||||
// Log.d(MainActivity.TAG, r);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
submit_edit_text.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
Intent intent = new Intent(SubmitPostActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.example.corwinperren.httpoauth.MainActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/gplus_login_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="G+ Login"
|
||||
app:layout_constraintBottom_toTopOf="@+id/show_posts_button"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/show_posts_button"
|
||||
app:layout_constraintRight_toRightOf="@+id/show_posts_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_posts_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Show Posts"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.501" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/submit_new_post_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Submit New Post"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/show_posts_button"
|
||||
app:layout_constraintRight_toRightOf="@+id/show_posts_button"
|
||||
app:layout_constraintTop_toBottomOf="@+id/show_posts_button" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/third_published_header_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="#3 Published"
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintTop_toBottomOf="@+id/second_content_text_view"
|
||||
android:layout_marginLeft="8dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/third_published_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="Loading..."
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintLeft_toRightOf="@+id/third_published_header_text_view"
|
||||
app:layout_constraintTop_toTopOf="@+id/third_published_header_text_view" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/third_content_text_view"
|
||||
android:layout_width="368dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Loading..."
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/third_published_header_text_view" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Most Recent Posts"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintHorizontal_bias="0.502"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="#1 Published"
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/first_published_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="Loading..."
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintLeft_toRightOf="@+id/textView3"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/first_content_text_view"
|
||||
android:layout_width="368dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Loading..."
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/second_content_text_view"
|
||||
android:layout_width="368dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Loading..."
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/second_published_header_text_view" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/second_published_header_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="#2 Published"
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/first_content_text_view" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/second_published_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="Loading..."
|
||||
android:textColor="@android:color/black"
|
||||
app:layout_constraintLeft_toRightOf="@+id/second_published_header_text_view"
|
||||
app:layout_constraintTop_toTopOf="@+id/second_published_header_text_view" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Submit Post"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintHorizontal_bias="0.505"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/submit_edit_text"
|
||||
android:layout_width="368dp"
|
||||
android:layout_height="137dp"
|
||||
android:ems="10"
|
||||
android:inputType="textMultiLine"
|
||||
android:hint="Enter text here.\nMulti-line allowed."
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2"
|
||||
android:layout_marginLeft="8dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:layout_marginRight="8dp"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/submit_submit_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:text="Submit"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/submit_edit_text" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">CS496 HTTP OAuth</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||