enable cancelling editing nickname with simple UI

This commit is contained in:
Ryan ZHAO 2021-04-22 15:52:01 +10:00
parent b94597a1f6
commit 162b597d4d
2 changed files with 28 additions and 0 deletions

View File

@ -274,6 +274,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private ImageView muteIndicatorImageView; private ImageView muteIndicatorImageView;
private TextView subtitleTextView; private TextView subtitleTextView;
private View homeButtonContainer; private View homeButtonContainer;
private View cancelButtonContainer;
private AttachmentTypeSelector attachmentTypeSelector; private AttachmentTypeSelector attachmentTypeSelector;
private AttachmentManager attachmentManager; private AttachmentManager attachmentManager;
@ -398,10 +399,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
textView.setText(getRecipient().getName()); textView.setText(getRecipient().getName());
} }
imm.hideSoftInputFromWindow(v.getWindowToken(),0); imm.hideSoftInputFromWindow(v.getWindowToken(),0);
cancelButtonContainer.setVisibility(View.GONE);
} else { } else {
String nickname = DatabaseFactory.getStorage(this).getDisplayName(getRecipient().getAddress().serialize()); String nickname = DatabaseFactory.getStorage(this).getDisplayName(getRecipient().getAddress().serialize());
titleTextView.setText(nickname); titleTextView.setText(nickname);
imm.showSoftInput(v, 0); imm.showSoftInput(v, 0);
cancelButtonContainer.setVisibility(View.VISIBLE);
} }
}); });
} }
@ -1293,6 +1296,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
muteIndicatorImageView = ViewUtil.findById(this, R.id.muteIndicatorImageView); muteIndicatorImageView = ViewUtil.findById(this, R.id.muteIndicatorImageView);
subtitleTextView = ViewUtil.findById(this, R.id.subtitleTextView); subtitleTextView = ViewUtil.findById(this, R.id.subtitleTextView);
homeButtonContainer = ViewUtil.findById(this, R.id.homeButtonContainer); homeButtonContainer = ViewUtil.findById(this, R.id.homeButtonContainer);
cancelButtonContainer = ViewUtil.findById(this, R.id.cancelButtonContainer);
ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle); ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);
ImageButton inlineAttachmentButton = ViewUtil.findById(this, R.id.inline_attachment_button); ImageButton inlineAttachmentButton = ViewUtil.findById(this, R.id.inline_attachment_button);
@ -1338,6 +1342,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
inlineAttachmentButton.setOnClickListener(v -> handleAddAttachment()); inlineAttachmentButton.setOnClickListener(v -> handleAddAttachment());
homeButtonContainer.setOnClickListener(v -> onSupportNavigateUp()); homeButtonContainer.setOnClickListener(v -> onSupportNavigateUp());
cancelButtonContainer.setOnClickListener(v -> {
titleTextView.clearFocus();
});
} }
protected void initializeActionBar() { protected void initializeActionBar() {

View File

@ -99,6 +99,26 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" /> android:layout_weight="1" />
<LinearLayout
android:id="@+id/cancelButtonContainer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:clickable="true"
android:focusable="true"
android:visibility="gone">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_clear_24"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>