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.

This commit is contained in:
Vavassor 2017-06-20 14:16:03 -04:00
parent 53e6769d55
commit b9b5e58b50
6 changed files with 38 additions and 31 deletions

View file

@ -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);
}
}

View file

@ -0,0 +1,7 @@
<vector android:height="24dp" android:viewportHeight="35.43307"
android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#ffffff"
android:pathData="M4.99,5.56L2.99,7.56L7.55,12.13A17.72,17.72 0,0 0,2.4 17.71A17.72,17.72 0,0 0,17.72 26.57A17.72,17.72 0,0 0,21.56 26.13L26.79,31.37L28.79,29.36L4.99,5.56zM17.72,8.86A17.72,17.72 0,0 0,12.95 9.53L15.26,11.84A6.38,6.38 0,0 1,17.72 11.34A6.38,6.38 0,0 1,24.09 17.72A6.38,6.38 0,0 1,23.6 20.18L27.21,23.78A17.72,17.72 0,0 0,33.04 17.72A17.72,17.72 0,0 0,17.72 8.86zM17.72,14.17A3.54,3.54 0,0 0,17.6 14.18L21.26,17.83A3.54,3.54 0,0 0,21.26 17.72A3.54,3.54 0,0 0,17.72 14.17zM11.55,16.13L14.41,18.99A3.54,3.54 0,0 0,16.45 21.03L19.31,23.88A6.38,6.38 0,0 1,17.72 24.09A6.38,6.38 0,0 1,11.34 17.72A6.38,6.38 0,0 1,11.55 16.13z"
android:strokeAlpha="1" android:strokeColor="#00000000"
android:strokeLineCap="square" android:strokeLineJoin="miter" android:strokeWidth="2.65748024"/>
</vector>

View file

@ -127,17 +127,16 @@
app:srcCompat="@drawable/ic_public_24dp"
android:contentDescription="@string/action_compose_options" />
<Button
android:id="@+id/action_toggle_nsfw"
<ImageButton
android:id="@+id/action_hide_media"
style="?attr/image_button_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:visibility="gone"
android:textColor="?attr/compose_nsfw_button_color"
android:text="@string/toggle_nsfw" />
app:srcCompat="@drawable/ic_hide_media_24dp"
android:contentDescription="@string/action_hide_media"
android:visibility="gone" />
<android.support.v4.widget.Space
android:layout_width="0dp"

View file

@ -35,8 +35,8 @@
<attr name="compose_media_button_disabled_tint" format="reference|color" />
<attr name="compose_mention_color" format="reference|color" />
<attr name="compose_content_warning_bar_background" format="reference" />
<attr name="compose_nsfw_button_color" format="reference|color" />
<attr name="compose_nsfw_button_selected_color" format="reference|color" />
<attr name="compose_hide_media_button_color" format="reference|color" />
<attr name="compose_hide_media_button_selected_color" format="reference|color" />
<attr name="compose_image_button_tint" format="reference|color" />
<attr name="report_status_background_color" format="reference|color" />
<attr name="report_status_divider_drawable" format="reference" />

View file

@ -91,7 +91,7 @@
<string name="action_mute">Mute</string>
<string name="action_unmute">Unmute</string>
<string name="action_mention">Mention</string>
<string name="toggle_nsfw">NSFW</string>
<string name="action_hide_media">Hide media</string>
<string name="action_compose_options">Options</string>
<string name="action_open_drawer">Open drawer</string>
<string name="action_clear">Clear</string>

View file

@ -65,8 +65,8 @@
<item name="compose_media_button_disabled_tint">@color/compose_media_button_disabled_dark</item>
<item name="compose_mention_color">@color/color_accent_dark</item>
<item name="compose_content_warning_bar_background">@drawable/border_background_dark</item>
<item name="compose_nsfw_button_color">@color/image_button_dark</item>
<item name="compose_nsfw_button_selected_color">@color/color_accent_dark</item>
<item name="compose_hide_media_button_color">@color/image_button_dark</item>
<item name="compose_hide_media_button_selected_color">@color/color_accent_dark</item>
<item name="compose_image_button_tint">@color/image_button_dark</item>
<item name="report_status_background_color">@color/color_background_dark</item>
<item name="report_status_divider_drawable">@drawable/status_divider_dark</item>
@ -142,8 +142,8 @@
<item name="compose_media_button_disabled_tint">@color/compose_media_button_disabled_light</item>
<item name="compose_mention_color">@color/compose_mention_light</item>
<item name="compose_content_warning_bar_background">@drawable/border_background_light</item>
<item name="compose_nsfw_button_color">@color/image_button_light</item>
<item name="compose_nsfw_button_selected_color">@color/color_accent_light</item>
<item name="compose_hide_media_button_color">@color/image_button_light</item>
<item name="compose_hide_media_button_selected_color">@color/color_accent_light</item>
<item name="compose_image_button_tint">@color/image_button_light</item>
<item name="report_status_background_color">@color/report_status_background_light</item>
<item name="report_status_divider_drawable">@drawable/report_status_divider_light</item>