Adds an indicator of visibility to the send button in the composer. Closes #38
This commit is contained in:
parent
5f2ddcfdc0
commit
81700e7b84
7 changed files with 63 additions and 10 deletions
|
@ -29,6 +29,7 @@ import android.database.Cursor;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
|
@ -114,6 +115,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
private int currentFlags;
|
||||
private ProgressDialog finishingUploadDialog;
|
||||
private EditText contentWarningEditor;
|
||||
private Button floatingBtn;
|
||||
private ImageButton pickBtn;
|
||||
private Button nsfwBtn;
|
||||
|
||||
|
@ -330,7 +332,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||
|
||||
Button floatingBtn = (Button) findViewById(R.id.floating_btn);
|
||||
floatingBtn = (Button) findViewById(R.id.floating_btn);
|
||||
pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick);
|
||||
nsfwBtn = (Button) findViewById(R.id.action_toggle_nsfw);
|
||||
ImageButton visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility);
|
||||
|
@ -360,10 +362,11 @@ public class ComposeActivity extends BaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
String startingVisibility;
|
||||
ArrayList<SavedQueuedMedia> savedMediaQueued = null;
|
||||
if (savedInstanceState != null) {
|
||||
showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive");
|
||||
statusVisibility = savedInstanceState.getString("statusVisibility");
|
||||
startingVisibility = savedInstanceState.getString("statusVisibility");
|
||||
statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive");
|
||||
statusHideText = savedInstanceState.getBoolean("statusHideText");
|
||||
// Keep these until everything needed to put them in the queue is finished initializing.
|
||||
|
@ -377,7 +380,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
}
|
||||
} else {
|
||||
showMarkSensitive = false;
|
||||
statusVisibility = preferences.getString("rememberedVisibility", "public");
|
||||
startingVisibility = preferences.getString("rememberedVisibility", "public");
|
||||
statusMarkSensitive = false;
|
||||
statusHideText = false;
|
||||
}
|
||||
|
@ -395,19 +398,22 @@ public class ComposeActivity extends BaseActivity {
|
|||
inReplyToId = intent.getStringExtra("in_reply_to_id");
|
||||
String replyVisibility = intent.getStringExtra("reply_visibility");
|
||||
|
||||
if (replyVisibility != null) {
|
||||
if (replyVisibility != null && startingVisibility != null) {
|
||||
// Lowest possible visibility setting in response
|
||||
if (statusVisibility.equals("private") || replyVisibility.equals("private")) {
|
||||
statusVisibility = "private";
|
||||
} else if (statusVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) {
|
||||
statusVisibility = "unlisted";
|
||||
if (startingVisibility.equals("private") || replyVisibility.equals("private")) {
|
||||
startingVisibility = "private";
|
||||
} else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) {
|
||||
startingVisibility = "unlisted";
|
||||
} else {
|
||||
statusVisibility = replyVisibility;
|
||||
startingVisibility = replyVisibility;
|
||||
}
|
||||
}
|
||||
|
||||
mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames");
|
||||
}
|
||||
/* Only after the starting visibility is determined and the send button is initialised can
|
||||
* the status visibility be set. */
|
||||
setStatusVisibility(startingVisibility);
|
||||
|
||||
textEditor = createEditText(null); // new String[] { "image/gif", "image/webp" }
|
||||
if (savedInstanceState != null) {
|
||||
|
@ -488,6 +494,30 @@ public class ComposeActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void setStatusVisibility(String visibility) {
|
||||
statusVisibility = visibility;
|
||||
switch (visibility) {
|
||||
case "public": {
|
||||
floatingBtn.setText(R.string.action_send_public);
|
||||
floatingBtn.setCompoundDrawables(null, null, null, null);
|
||||
break;
|
||||
}
|
||||
case "private": {
|
||||
floatingBtn.setText(R.string.action_send);
|
||||
Drawable lock = ThemeUtils.getDrawable(this, R.attr.compose_send_private_drawable,
|
||||
R.drawable.send_private_dark);
|
||||
lock.setBounds(0, 0, lock.getIntrinsicWidth(), lock.getIntrinsicHeight());
|
||||
floatingBtn.setCompoundDrawables(null, null, lock, null);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
floatingBtn.setText(R.string.action_send);
|
||||
floatingBtn.setCompoundDrawables(null, null, null, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showComposeOptions() {
|
||||
ComposeOptionsFragment fragment = ComposeOptionsFragment.newInstance(
|
||||
statusVisibility, statusHideText, inReplyToId != null,
|
||||
|
@ -502,7 +532,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public void onVisibilityChanged(String visibility) {
|
||||
statusVisibility = visibility;
|
||||
setStatusVisibility(visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
9
app/src/main/res/drawable/send_private_dark.xml
Normal file
9
app/src/main/res/drawable/send_private_dark.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/text_color_primary_dark"
|
||||
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/send_private_light.xml
Normal file
9
app/src/main/res/drawable/send_private_light.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/text_color_primary_light"
|
||||
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
|
||||
</vector>
|
|
@ -60,6 +60,7 @@
|
|||
<string name="action_report">Melden</string>
|
||||
<string name="action_delete">Löschen</string>
|
||||
<string name="action_send">TOOT</string>
|
||||
<string name="action_send_public">TOOT!</string>
|
||||
<string name="action_retry">Erneut versuchen</string>
|
||||
<string name="action_mark_sensitive">Markiere Mediendatei als sensibel</string>
|
||||
<string name="action_hide_text">Verstecke Text hinter Warnung</string>
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<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_send_private_drawable" format="reference" />
|
||||
<attr name="report_status_background_color" format="reference|color" />
|
||||
<attr name="report_status_divider_drawable" format="reference" />
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
<string name="action_report">Report</string>
|
||||
<string name="action_delete">Delete</string>
|
||||
<string name="action_send">TOOT</string>
|
||||
<string name="action_send_public">TOOT!</string>
|
||||
<string name="action_retry">Retry</string>
|
||||
<string name="action_mark_sensitive">Mark media sensitive</string>
|
||||
<string name="action_hide_text">Hide text behind warning</string>
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
<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_send_private_drawable">@drawable/send_private_dark</item>
|
||||
<item name="notification_content">@color/notification_content_faded_dark</item>
|
||||
<item name="notification_icon_tint">@color/notification_icon_tint_dark</item>
|
||||
<item name="report_status_background_color">@color/color_background_dark</item>
|
||||
|
@ -138,6 +139,7 @@
|
|||
<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_send_private_drawable">@drawable/send_private_light</item>
|
||||
<item name="notification_content">@color/notification_content_faded_light</item>
|
||||
<item name="notification_icon_tint">@color/notification_icon_tint_light</item>
|
||||
<item name="report_status_background_color">@color/report_status_background_light</item>
|
||||
|
|
Loading…
Reference in a new issue