From 3f861084bf5b312eef01675914ea49129b1665df Mon Sep 17 00:00:00 2001 From: Vavassor Date: Tue, 20 Jun 2017 14:16:03 -0400 Subject: [PATCH] Changes the NSFW button to a "hide media" icon in the composer. This is inspired in part by the upstream change tootsuite/mastodon#2696. But also NSFW was never a good description of this function. --- .../keylesspalace/tusky/ComposeActivity.java | 33 ++++++++++--------- .../main/res/drawable/ic_hide_media_24dp.xml | 7 ++++ app/src/main/res/layout/activity_compose.xml | 15 ++++----- app/src/main/res/values/attrs.xml | 4 +-- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/values/styles.xml | 8 ++--- 6 files changed, 38 insertions(+), 31 deletions(-) create mode 100644 app/src/main/res/drawable/ic_hide_media_24dp.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index e464c068..1e34124e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -145,8 +145,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm ImageButton pickBtn; @BindView(R.id.compose_photo_take) ImageButton takeBtn; - @BindView(R.id.action_toggle_nsfw) - Button nsfwBtn; + @BindView(R.id.action_hide_media) + ImageButton hideMediaToggle; @BindView(R.id.postProgress) ProgressBar postProgress; @BindView(R.id.action_toggle_visibility) @@ -209,10 +209,10 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm initiateCameraApp(); } }); - nsfwBtn.setOnClickListener(new View.OnClickListener() { + hideMediaToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - toggleNsfw(); + toggleHideMedia(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @@ -293,7 +293,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); postProgress.setVisibility(View.INVISIBLE); - updateNsfwButtonColor(); + updateHideMediaToggleColor(); final ParserUtils parser = new ParserUtils(this); @@ -456,25 +456,25 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm Snackbar.make(findViewById(R.id.activity_compose), stringId, Snackbar.LENGTH_LONG).show(); } - private void toggleNsfw() { + private void toggleHideMedia() { statusMarkSensitive = !statusMarkSensitive; - updateNsfwButtonColor(); + updateHideMediaToggleColor(); } - private void updateNsfwButtonColor() { + private void updateHideMediaToggleColor() { @AttrRes int attribute; if (statusMarkSensitive) { - attribute = R.attr.compose_nsfw_button_selected_color; + attribute = R.attr.compose_hide_media_button_selected_color; } else { - attribute = R.attr.compose_nsfw_button_color; + attribute = R.attr.compose_hide_media_button_color; } - nsfwBtn.setTextColor(ThemeUtils.getColor(this, attribute)); + ThemeUtils.setDrawableTint(this, hideMediaToggle.getDrawable(), attribute); } private void disableButtons() { pickBtn.setClickable(false); takeBtn.setClickable(false); - nsfwBtn.setClickable(false); + hideMediaToggle.setClickable(false); visibilityBtn.setClickable(false); floatingBtn.setEnabled(false); } @@ -482,7 +482,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm private void enableButtons() { pickBtn.setClickable(true); takeBtn.setClickable(true); - nsfwBtn.setClickable(true); + hideMediaToggle.setClickable(true); visibilityBtn.setClickable(true); floatingBtn.setEnabled(true); } @@ -1168,13 +1168,14 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm if (!showMarkSensitive) { statusMarkSensitive = false; - nsfwBtn.setTextColor(ThemeUtils.getColor(this, R.attr.compose_nsfw_button_color)); + ThemeUtils.setDrawableTint(this, hideMediaToggle.getDrawable(), + R.attr.compose_hide_media_button_color); } if (show) { - nsfwBtn.setVisibility(View.VISIBLE); + hideMediaToggle.setVisibility(View.VISIBLE); } else { - nsfwBtn.setVisibility(View.GONE); + hideMediaToggle.setVisibility(View.GONE); } } diff --git a/app/src/main/res/drawable/ic_hide_media_24dp.xml b/app/src/main/res/drawable/ic_hide_media_24dp.xml new file mode 100644 index 00000000..8b64ae1a --- /dev/null +++ b/app/src/main/res/drawable/ic_hide_media_24dp.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index 0737da5a..1e837d2c 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -127,17 +127,16 @@ app:srcCompat="@drawable/ic_public_24dp" android:contentDescription="@string/action_compose_options" /> -