Compose close dialog + focus fix (#539)
This commit is contained in:
parent
49e61bab83
commit
e82c9dcd2a
2 changed files with 59 additions and 37 deletions
|
@ -476,6 +476,7 @@ public final class ComposeActivity extends BaseActivity
|
|||
}
|
||||
}
|
||||
|
||||
textEditor.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1239,22 +1240,9 @@ public final class ComposeActivity extends BaseActivity
|
|||
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
||||
input.setText(item.description);
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setView(dialogLayout)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
//noinspection ConstantConditions
|
||||
window.setSoftInputMode(
|
||||
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
}
|
||||
|
||||
dialog.setOnShowListener(dialogInterface -> {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(view -> mastodonApi.updateMedia(item.id,
|
||||
input.getText().toString()).enqueue(new Callback<Attachment>() {
|
||||
DialogInterface.OnClickListener okListener = (dialog, which) -> {
|
||||
mastodonApi.updateMedia(item.id, input.getText().toString())
|
||||
.enqueue(new Callback<Attachment>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Attachment> call, @NonNull Response<Attachment> response) {
|
||||
Attachment attachment = response.body();
|
||||
|
@ -1270,8 +1258,22 @@ public final class ComposeActivity extends BaseActivity
|
|||
public void onFailure(@NonNull Call<Attachment> call, @NonNull Throwable t) {
|
||||
showFailedCaptionMessage();
|
||||
}
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setView(dialogLayout)
|
||||
.setPositiveButton(android.R.string.ok, okListener)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
//noinspection ConstantConditions
|
||||
window.setSoftInputMode(
|
||||
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
}
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
@ -1547,15 +1549,34 @@ public final class ComposeActivity extends BaseActivity
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home: {
|
||||
onBackPressed();
|
||||
case android.R.id.home:
|
||||
handleCloseButton();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// Acting like a teen: deliberately ignoring parent.
|
||||
handleCloseButton();
|
||||
}
|
||||
|
||||
private void handleCloseButton() {
|
||||
if (!TextUtils.isEmpty(textEditor.getText())
|
||||
|| !TextUtils.isEmpty(contentWarningEditor.getText())
|
||||
|| !mediaQueued.isEmpty()) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Close the toot without saving?")
|
||||
.setPositiveButton(android.R.string.yes, (d, w) -> finish())
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Account> searchAccounts(String mention) {
|
||||
ArrayList<Account> resultList = new ArrayList<>();
|
||||
|
|
|
@ -17,31 +17,31 @@
|
|||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composeAvatar"
|
||||
android:padding="8dp"
|
||||
android:layout_gravity="right|end"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="right|end"
|
||||
android:padding="8dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
<!--content description will be set in code -->
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<TextView
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:id="@+id/reply_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:text="Reply to @username"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:id="@+id/reply_content_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -51,6 +51,7 @@
|
|||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="4dp"
|
||||
android:textSize="?attr/status_text_small"
|
||||
android:visibility="gone"
|
||||
tools:text="Post content which may be preeettyy long, so please, make sure there's enough room for everything, okay? Not kidding. I wish Eugen answered me more often, sigh."
|
||||
tools:visibility="visible" />
|
||||
|
@ -63,7 +64,6 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:textSize="?attr/status_text_medium"
|
||||
android:id="@+id/field_content_warning"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -73,7 +73,8 @@
|
|||
android:inputType="text|textCapSentences"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
android:paddingRight="16dp"
|
||||
android:textSize="?attr/status_text_medium" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
|
@ -204,19 +205,19 @@
|
|||
<TextView
|
||||
android:id="@+id/characters_left"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="?attr/status_text_medium"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary" />
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="?attr/status_text_medium" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/floating_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:textSize="?attr/status_text_medium"
|
||||
android:background="@drawable/compose_button_colors"
|
||||
android:text="@string/action_send"
|
||||
android:textColor="@android:color/white" />
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="?attr/status_text_medium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue