From 4060f3f45fa37f562d6e0e92e78b4855cfa51fb8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 7 Mar 2017 15:03:41 +0100 Subject: [PATCH] Nicer login layout --- .../keylesspalace/tusky/LoginActivity.java | 9 +++-- .../drawable/media_preview_unloaded_dark.xml | 4 +- app/src/main/res/layout/activity_login.xml | 38 +++++++++++-------- app/src/main/res/values/strings.xml | 5 ++- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index 88c042b39..c99da8a1b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -22,10 +22,12 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.support.design.widget.Snackbar; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.TextView; import com.android.volley.Request; @@ -48,6 +50,7 @@ public class LoginActivity extends BaseActivity { private String domain; private String clientId; private String clientSecret; + private EditText editText; /** * Chain together the key-value pairs into a query string, for either appending to a URL or @@ -173,7 +176,7 @@ public class LoginActivity extends BaseActivity { preferences = getSharedPreferences( getString(R.string.preferences_file_key), Context.MODE_PRIVATE); Button button = (Button) findViewById(R.id.button_login); - final EditText editText = (EditText) findViewById(R.id.edit_text_domain); + editText = (EditText) findViewById(R.id.edit_text_domain); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -273,7 +276,7 @@ public class LoginActivity extends BaseActivity { try { accessToken = response.getString("access_token"); } catch(JSONException e) { - errorText.setText(e.getMessage()); + editText.setError(e.getMessage()); return; } onLoginSuccess(accessToken); @@ -281,7 +284,7 @@ public class LoginActivity extends BaseActivity { }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { - errorText.setText(error.getMessage()); + editText.setError(error.getMessage()); } }); VolleySingleton.getInstance(this).addToRequestQueue(request); diff --git a/app/src/main/res/drawable/media_preview_unloaded_dark.xml b/app/src/main/res/drawable/media_preview_unloaded_dark.xml index 5585d2881..2d6872b31 100644 --- a/app/src/main/res/drawable/media_preview_unloaded_dark.xml +++ b/app/src/main/res/drawable/media_preview_unloaded_dark.xml @@ -3,12 +3,12 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> - + + android:color="@color/color_primary_dark" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 124130cb8..4aab7117b 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -4,15 +4,9 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:padding="16dp" tools:context="com.keylesspalace.tusky.LoginActivity"> - - @@ -21,30 +15,44 @@ android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerInParent="true"> + android:layout_centerInParent="true" + android:gravity="center"> - + android:src="@drawable/elephant_friend"/> + + + +