diff --git a/README.md b/README.md index c6099da3..e987f953 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,20 @@ # Tusky -This is an android client for [Mastodon, a GNU Social-compatible microblogging server](https://mastodon.social). Presently, it is in active development and its current state does not represent the features or design of the final program. +![](https://lh3.googleusercontent.com/6Ctl3PXaQi19qMaipWwzHAoKS9M9zy328cuulNZNAmRbjsPkSXs2xJ2OcyQNpOy23hI=w100) -It is currently available for alpha testing on the Tusky [Google Play store page](https://play.google.com/store/apps/details?id=com.keylesspalace.tusky). You can also find it on F-Droid or at its [F-Droid page](https://f-droid.org/repository/browse/?fdid=com.keylesspalace.tusky). +Tusky is a beautiful Android client for [Mastodon](https://github.com/tootsuite/mastodon). Mastodon is a GNU social-compatible federated social network. That means not one entity controls the whole network, rather, like e-mail, volunteers and organisations operate their own independent servers, users from which can all interact with each other seamlessly. -Also, [my mastodon account is Vavassor@mastodon.social](https://mastodon.social/users/Vavassor). +It is currently available for alpha testing on [Google Play](https://play.google.com/store/apps/details?id=com.keylesspalace.tusky). You can also find it on F-Droid or at its [F-Droid page](https://f-droid.org/repository/browse/?fdid=com.keylesspalace.tusky). + +## Features + +- Material Design +- Most Mastodon APIs implemented +- Push notifications + +#### Head of development + +My Mastodon account is [Vavassor@mastodon.social](https://mastodon.social/users/Vavassor). ## Building diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 84193826..f6bbf47f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,9 @@ - + diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index cb0f0dec..0fcd6ffd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -22,7 +22,6 @@ import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.text.Spanned; @@ -68,7 +67,7 @@ public class BaseActivity extends AppCompatActivity { @Override protected void onDestroy() { - mastodonApiDispatcher.cancelAll(); + if(mastodonApiDispatcher != null) mastodonApiDispatcher.cancelAll(); super.onDestroy(); } diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index 0dbfdf13..88a453c3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -56,6 +56,11 @@ public class LoginActivity extends AppCompatActivity { @BindView(R.id.button_login) Button button; @BindView(R.id.no_account) TextView noAccount; + @Override + protected void createMastodonAPI() { + // Don't do this in this activity, since we don't know a domain yet + } + /** * Chain together the key-value pairs into a query string, for either appending to a URL or * as the content of an HTTP request. @@ -77,7 +82,7 @@ public class LoginActivity extends AppCompatActivity { private String validateDomain(String s) { s = s.replaceFirst("http://", ""); s = s.replaceFirst("https://", ""); - return s; + return s.trim(); } private String getOauthRedirectUri() { @@ -242,6 +247,17 @@ public class LoginActivity extends AppCompatActivity { Uri uri = getIntent().getData(); String redirectUri = getOauthRedirectUri(); + preferences = getSharedPreferences( + getString(R.string.preferences_file_key), Context.MODE_PRIVATE); + + if (preferences.getString("accessToken", null) != null && preferences.getString("domain", null) != null) { + // We are already logged in, go to MainActivity + Intent intent = new Intent(this, MainActivity.class); + startActivity(intent); + finish(); + return; + } + if (uri != null && uri.toString().startsWith(redirectUri)) { // This should either have returned an authorization code or an error. String code = uri.getQueryParameter("code"); @@ -251,8 +267,6 @@ public class LoginActivity extends AppCompatActivity { /* During the redirect roundtrip this Activity usually dies, which wipes out the * instance variables, so they have to be recovered from where they were saved in * SharedPreferences. */ - preferences = getSharedPreferences( - getString(R.string.preferences_file_key), Context.MODE_PRIVATE); domain = preferences.getString("domain", null); clientId = preferences.getString("clientId", null); clientSecret = preferences.getString("clientSecret", null); diff --git a/app/src/main/res/drawable/elephant_friend.png b/app/src/main/res/drawable/elephant_friend.png index 93e8ec1a..3c5145ba 100644 Binary files a/app/src/main/res/drawable/elephant_friend.png and b/app/src/main/res/drawable/elephant_friend.png differ diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 6a3a901f..27d85549 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,63 +1,55 @@ - - + android:padding="16dp" + android:gravity="center" + android:layout_height="wrap_content"> - + android:layout_marginBottom="50dp" + android:src="@drawable/elephant_friend"/> - + + android:inputType="textUri" + android:hint="@string/hint_domain" + android:ems="10" + android:id="@+id/edit_text_domain" /> + - - - +