From 1db90db6429b977b064a8b191c2671c14dbc37a4 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 7 Mar 2017 22:23:17 +0100 Subject: [PATCH 1/2] Spark animations for boost/favourite buttons --- app/build.gradle | 1 + .../keylesspalace/tusky/StatusViewHolder.java | 43 ++++++++----------- .../main/res/drawable/favourite_active.xml | 9 ++++ .../main/res/drawable/favourite_inactive.xml | 9 ++++ app/src/main/res/drawable/reblog_active.xml | 9 ++++ app/src/main/res/drawable/reblog_disabled.xml | 9 ++++ app/src/main/res/drawable/reblog_inactive.xml | 9 ++++ app/src/main/res/layout/item_status.xml | 22 +++++++--- app/src/main/res/values/colors.xml | 4 +- build.gradle | 1 + 10 files changed, 83 insertions(+), 33 deletions(-) create mode 100644 app/src/main/res/drawable/favourite_active.xml create mode 100644 app/src/main/res/drawable/favourite_inactive.xml create mode 100644 app/src/main/res/drawable/reblog_active.xml create mode 100644 app/src/main/res/drawable/reblog_disabled.xml create mode 100644 app/src/main/res/drawable/reblog_inactive.xml diff --git a/app/build.gradle b/app/build.gradle index 159cfb30..d09fbb60 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,5 +32,6 @@ dependencies { compile 'com.android.support:design:25.1.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.pkmmte.view:circularimageview:1.1' + compile 'com.github.peter9870:sparkbutton:master' testCompile 'junit:junit:4.12' } diff --git a/app/src/main/java/com/keylesspalace/tusky/StatusViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/StatusViewHolder.java index 3f30299b..12eee0ab 100644 --- a/app/src/main/java/com/keylesspalace/tusky/StatusViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/StatusViewHolder.java @@ -34,6 +34,9 @@ import android.widget.ToggleButton; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.NetworkImageView; import com.squareup.picasso.Picasso; +import com.varunest.sparkbutton.SparkButton; +import com.varunest.sparkbutton.SparkButtonBuilder; +import com.varunest.sparkbutton.SparkEventListener; import java.util.Date; @@ -47,8 +50,8 @@ class StatusViewHolder extends RecyclerView.ViewHolder { private View rebloggedBar; private TextView rebloggedByDisplayName; private ImageButton replyButton; - private ImageButton reblogButton; - private ImageButton favouriteButton; + private SparkButton reblogButton; + private SparkButton favouriteButton; private ImageButton moreButton; private boolean favourited; private boolean reblogged; @@ -72,8 +75,8 @@ class StatusViewHolder extends RecyclerView.ViewHolder { rebloggedBar = itemView.findViewById(R.id.status_reblogged_bar); rebloggedByDisplayName = (TextView) itemView.findViewById(R.id.status_reblogged); replyButton = (ImageButton) itemView.findViewById(R.id.status_reply); - reblogButton = (ImageButton) itemView.findViewById(R.id.status_reblog); - favouriteButton = (ImageButton) itemView.findViewById(R.id.status_favourite); + reblogButton = (SparkButton) itemView.findViewById(R.id.status_reblog); + favouriteButton = (SparkButton) itemView.findViewById(R.id.status_favourite); moreButton = (ImageButton) itemView.findViewById(R.id.status_more); reblogged = false; favourited = false; @@ -187,35 +190,25 @@ class StatusViewHolder extends RecyclerView.ViewHolder { private void setReblogged(boolean reblogged) { this.reblogged = reblogged; - int attribute; - if (reblogged) { - attribute = R.attr.status_reblog_button_marked_tint; - } else { - attribute = R.attr.status_reblog_button_tint; - } - ThemeUtils.setImageViewTint(reblogButton, attribute); + reblogButton.setChecked(reblogged); } /** This should only be called after setReblogged, in order to override the tint correctly. */ private void setRebloggingEnabled(boolean enabled) { reblogButton.setEnabled(enabled); + if (enabled) { - reblogButton.setImageResource(R.drawable.ic_repeat_24dp); + reblogButton.setInactiveImage(R.drawable.reblog_inactive); + reblogButton.setActiveImage(R.drawable.reblog_active); } else { - ThemeUtils.setImageViewTint(reblogButton, R.attr.status_reblog_button_disabled_tint); - reblogButton.setImageResource(R.drawable.ic_lock_24dp); + reblogButton.setInactiveImage(R.drawable.reblog_disabled); + reblogButton.setActiveImage(R.drawable.reblog_disabled); } } private void setFavourited(boolean favourited) { this.favourited = favourited; - int attribute; - if (favourited) { - attribute = R.attr.status_favourite_button_marked_tint; - } else { - attribute = R.attr.status_favourite_button_tint; - } - ThemeUtils.setImageViewTint(favouriteButton, attribute); + favouriteButton.setChecked(favourited); } private void setMediaPreviews(final Status.MediaAttachment[] attachments, @@ -313,15 +306,15 @@ class StatusViewHolder extends RecyclerView.ViewHolder { listener.onReply(getAdapterPosition()); } }); - reblogButton.setOnClickListener(new View.OnClickListener() { + reblogButton.setEventListener(new SparkEventListener() { @Override - public void onClick(View v) { + public void onEvent(ImageView button, boolean buttonState) { listener.onReblog(!reblogged, getAdapterPosition()); } }); - favouriteButton.setOnClickListener(new View.OnClickListener() { + favouriteButton.setEventListener(new SparkEventListener() { @Override - public void onClick(View v) { + public void onEvent(ImageView button, boolean buttonState) { listener.onFavourite(!favourited, getAdapterPosition()); } }); diff --git a/app/src/main/res/drawable/favourite_active.xml b/app/src/main/res/drawable/favourite_active.xml new file mode 100644 index 00000000..2d53859f --- /dev/null +++ b/app/src/main/res/drawable/favourite_active.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/favourite_inactive.xml b/app/src/main/res/drawable/favourite_inactive.xml new file mode 100644 index 00000000..24b69ac3 --- /dev/null +++ b/app/src/main/res/drawable/favourite_inactive.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/reblog_active.xml b/app/src/main/res/drawable/reblog_active.xml new file mode 100644 index 00000000..c23ed9a9 --- /dev/null +++ b/app/src/main/res/drawable/reblog_active.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/reblog_disabled.xml b/app/src/main/res/drawable/reblog_disabled.xml new file mode 100644 index 00000000..59db1759 --- /dev/null +++ b/app/src/main/res/drawable/reblog_disabled.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/reblog_inactive.xml b/app/src/main/res/drawable/reblog_inactive.xml new file mode 100644 index 00000000..74d6b8fe --- /dev/null +++ b/app/src/main/res/drawable/reblog_inactive.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/item_status.xml b/app/src/main/res/layout/item_status.xml index be611581..53b6b93f 100644 --- a/app/src/main/res/layout/item_status.xml +++ b/app/src/main/res/layout/item_status.xml @@ -227,6 +227,8 @@ android:layout_height="wrap_content" android:layout_below="@id/status_media_preview_container" android:layout_toRightOf="@+id/status_avatar" + android:clipChildren="false" + android:clipToPadding="false" android:paddingBottom="8dp" android:paddingTop="6dp"> @@ -242,10 +244,14 @@ android:layout_height="match_parent" android:layout_weight="1" /> - @@ -254,11 +260,15 @@ android:layout_height="match_parent" android:layout_weight="1" /> - #000000 #2F2F2F #4F4F4F - #009F6F + #56a7e1 #BFBFBF #4F4F4F - #ffec21 + #fab207 #B0B0B0 #CFCFCF #34444C diff --git a/build.gradle b/build.gradle index 1ea4bd05..83a6ca5a 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ buildscript { allprojects { repositories { jcenter() + maven { url "https://jitpack.io" } } } From 34c4951241e23deb059143dcca52e0f4b825abb3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 7 Mar 2017 23:10:41 +0100 Subject: [PATCH 2/2] Animated splash screen (mind: preview for the circular loader seems broken in Android Studio, but works in app) --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 2 +- .../keylesspalace/tusky/SplashActivity.java | 22 ++++++++++++--- .../main/res/drawable/splash_background.xml | 9 ------- app/src/main/res/layout/activity_splash.xml | 27 +++++++++++++++++++ app/src/main/res/values/styles.xml | 4 --- 6 files changed, 47 insertions(+), 18 deletions(-) delete mode 100644 app/src/main/res/drawable/splash_background.xml create mode 100644 app/src/main/res/layout/activity_splash.xml diff --git a/app/build.gradle b/app/build.gradle index 73233f09..c9c6c400 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,4 +34,5 @@ dependencies { compile 'com.pkmmte.view:circularimageview:1.1' compile 'com.github.peter9870:sparkbutton:master' testCompile 'junit:junit:4.12' + compile 'com.mikhaellopez:circularfillableloaders:1.2.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2601bee2..4bdc081e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,7 +14,7 @@ android:theme="@style/AppTheme"> + android:theme="@android:style/Theme.Black.NoTitleBar"> diff --git a/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java b/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java index 1297196c..c3e38c03 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java @@ -15,29 +15,43 @@ package com.keylesspalace.tusky; +import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; -public class SplashActivity extends AppCompatActivity { +public class SplashActivity extends Activity { + private static int SPLASH_TIME_OUT = 2000; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_splash); /* Determine whether the user is currently logged in, and if so go ahead and load the * timeline. Otherwise, start the activity_login screen. */ SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_file_key), Context.MODE_PRIVATE); String domain = preferences.getString("domain", null); String accessToken = preferences.getString("accessToken", null); - Intent intent; + + + final Intent intent; + if (domain != null && accessToken != null) { intent = new Intent(this, MainActivity.class); } else { intent = new Intent(this, LoginActivity.class); } - startActivity(intent); - finish(); + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + startActivity(intent); + finish(); + } + }, SPLASH_TIME_OUT); } } diff --git a/app/src/main/res/drawable/splash_background.xml b/app/src/main/res/drawable/splash_background.xml deleted file mode 100644 index fb783fdf..00000000 --- a/app/src/main/res/drawable/splash_background.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml new file mode 100644 index 00000000..11c059c1 --- /dev/null +++ b/app/src/main/res/layout/activity_splash.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 1574f158..a62b68a7 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,9 +1,5 @@ - -