parent
46efdf7830
commit
ffb6c9a7a7
3 changed files with 54 additions and 1 deletions
|
@ -54,6 +54,7 @@ import android.view.ViewGroup;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -212,6 +213,8 @@ public final class ComposeActivity
|
|||
private ImageButton contentWarningButton;
|
||||
private ImageButton emojiButton;
|
||||
private ImageButton hideMediaToggle;
|
||||
private Button atButton;
|
||||
private Button hashButton;
|
||||
|
||||
private ComposeOptionsView composeOptionsView;
|
||||
private BottomSheetBehavior composeOptionsBehavior;
|
||||
|
@ -267,6 +270,8 @@ public final class ComposeActivity
|
|||
hideMediaToggle = findViewById(R.id.composeHideMediaButton);
|
||||
emojiView = findViewById(R.id.emojiView);
|
||||
emojiList = Collections.emptyList();
|
||||
atButton = findViewById(R.id.atButton);
|
||||
hashButton = findViewById(R.id.hashButton);
|
||||
|
||||
saveTootHelper = new SaveTootHelper(database.tootDao(), this);
|
||||
|
||||
|
@ -371,6 +376,8 @@ public final class ComposeActivity
|
|||
contentWarningButton.setOnClickListener(v -> onContentWarningChanged());
|
||||
emojiButton.setOnClickListener(v -> showEmojis());
|
||||
hideMediaToggle.setOnClickListener(v -> toggleHideMedia());
|
||||
atButton.setOnClickListener(v -> atButtonClicked());
|
||||
hashButton.setOnClickListener(v -> hashButtonClicked());
|
||||
|
||||
TextView actionPhotoTake = findViewById(R.id.action_photo_take);
|
||||
TextView actionPhotoPick = findViewById(R.id.action_photo_pick);
|
||||
|
@ -693,6 +700,24 @@ public final class ComposeActivity
|
|||
textEditor.requestFocus();
|
||||
}
|
||||
|
||||
private void replaceTextAtCaret(CharSequence text) {
|
||||
// If you select "backward" in an editable, you get SelectionStart > SelectionEnd
|
||||
int start = Math.min(textEditor.getSelectionStart(), textEditor.getSelectionEnd());
|
||||
int end = Math.max(textEditor.getSelectionStart(), textEditor.getSelectionEnd());
|
||||
textEditor.getText().replace(start, end, text);
|
||||
|
||||
// Set the cursor after the inserted text
|
||||
textEditor.setSelection(start + text.length());
|
||||
}
|
||||
|
||||
private void atButtonClicked() {
|
||||
replaceTextAtCaret("@");
|
||||
}
|
||||
|
||||
private void hashButtonClicked() {
|
||||
replaceTextAtCaret("#");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
ArrayList<SavedQueuedMedia> savedMediaQueued = new ArrayList<>();
|
||||
|
@ -1785,7 +1810,7 @@ public final class ComposeActivity
|
|||
|
||||
@Override
|
||||
public void onEmojiSelected(@NotNull String shortcode) {
|
||||
textEditor.getText().insert(textEditor.getSelectionStart(), ":" + shortcode + ": ");
|
||||
replaceTextAtCaret(":" + shortcode + ": ");
|
||||
}
|
||||
|
||||
private void loadCachedInstanceMetadata(@NotNull AccountEntity activeAccount) {
|
||||
|
|
|
@ -21,6 +21,32 @@
|
|||
android:padding="8dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
<!--content description will be set in code -->
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/atButton"
|
||||
style="?attr/image_button_style"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:padding="8dp"
|
||||
android:text="@string/at_symbol"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:textColorTertiary"
|
||||
android:textSize="?attr/status_text_large"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/hashButton"
|
||||
style="?attr/image_button_style"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:padding="8dp"
|
||||
android:text="@string/hash_symbol"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:textColorTertiary"
|
||||
android:textSize="?attr/status_text_large"
|
||||
/>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<string name="preferences_file_key" translatable="false">com.keylesspalace.tusky.PREFERENCES</string>
|
||||
|
||||
<string name="status_sensitive_media_template" translatable="false"><b>%1$s</b><br>%2$s</string>
|
||||
<string name="at_symbol" translatable="false">\@</string>
|
||||
<string name="hash_symbol" translatable="false">#</string>
|
||||
|
||||
<string-array name="post_privacy_values">
|
||||
<item>public</item>
|
||||
|
|
Loading…
Reference in a new issue