Compose close dialog + focus fix (#539)
This commit is contained in:
parent
49e61bab83
commit
e82c9dcd2a
|
@ -476,6 +476,7 @@ public final class ComposeActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textEditor.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1239,22 +1240,9 @@ public final class ComposeActivity extends BaseActivity
|
||||||
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
||||||
input.setText(item.description);
|
input.setText(item.description);
|
||||||
|
|
||||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
DialogInterface.OnClickListener okListener = (dialog, which) -> {
|
||||||
.setView(dialogLayout)
|
mastodonApi.updateMedia(item.id, input.getText().toString())
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.enqueue(new Callback<Attachment>() {
|
||||||
.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>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<Attachment> call, @NonNull Response<Attachment> response) {
|
public void onResponse(@NonNull Call<Attachment> call, @NonNull Response<Attachment> response) {
|
||||||
Attachment attachment = response.body();
|
Attachment attachment = response.body();
|
||||||
|
@ -1270,8 +1258,22 @@ public final class ComposeActivity extends BaseActivity
|
||||||
public void onFailure(@NonNull Call<Attachment> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<Attachment> call, @NonNull Throwable t) {
|
||||||
showFailedCaptionMessage();
|
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();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1547,15 +1549,34 @@ public final class ComposeActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home: {
|
case android.R.id.home:
|
||||||
onBackPressed();
|
handleCloseButton();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
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
|
@Override
|
||||||
public List<Account> searchAccounts(String mention) {
|
public List<Account> searchAccounts(String mention) {
|
||||||
ArrayList<Account> resultList = new ArrayList<>();
|
ArrayList<Account> resultList = new ArrayList<>();
|
||||||
|
|
|
@ -17,31 +17,31 @@
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:background="@android:color/transparent">
|
android:background="@android:color/transparent">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/composeAvatar"
|
android:id="@+id/composeAvatar"
|
||||||
android:padding="8dp"
|
|
||||||
android:layout_gravity="right|end"
|
|
||||||
android:layout_width="?attr/actionBarSize"
|
android:layout_width="?attr/actionBarSize"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:layout_gravity="right|end"
|
||||||
|
android:padding="8dp"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
<!--content description will be set in code -->
|
<!--content description will be set in code -->
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textSize="?attr/status_text_small"
|
|
||||||
android:id="@+id/reply_tv"
|
android:id="@+id/reply_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="6dp"
|
android:layout_marginBottom="6dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
|
android:textSize="?attr/status_text_small"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:text="Reply to @username"
|
tools:text="Reply to @username"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textSize="?attr/status_text_small"
|
|
||||||
android:id="@+id/reply_content_tv"
|
android:id="@+id/reply_content_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -51,6 +51,7 @@
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
|
android:textSize="?attr/status_text_small"
|
||||||
android:visibility="gone"
|
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: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" />
|
tools:visibility="visible" />
|
||||||
|
@ -63,7 +64,6 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:textSize="?attr/status_text_medium"
|
|
||||||
android:id="@+id/field_content_warning"
|
android:id="@+id/field_content_warning"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -73,7 +73,8 @@
|
||||||
android:inputType="text|textCapSentences"
|
android:inputType="text|textCapSentences"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp" />
|
android:paddingRight="16dp"
|
||||||
|
android:textSize="?attr/status_text_medium" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -204,19 +205,19 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/characters_left"
|
android:id="@+id/characters_left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:textSize="?attr/status_text_medium"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:textColorPrimary" />
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="?attr/status_text_medium" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/floating_btn"
|
android:id="@+id/floating_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:textSize="?attr/status_text_medium"
|
|
||||||
android:background="@drawable/compose_button_colors"
|
android:background="@drawable/compose_button_colors"
|
||||||
android:text="@string/action_send"
|
android:text="@string/action_send"
|
||||||
android:textColor="@android:color/white" />
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="?attr/status_text_medium" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue