Make user details bottom sheet look better

This commit is contained in:
Niels Andriesse 2021-05-24 11:08:08 +10:00
parent e7ae08fe7a
commit 04b62df83c
4 changed files with 46 additions and 36 deletions

View File

@ -38,21 +38,21 @@ class UserDetailsBottomSheet : BottomSheetDialogFragment() {
nameTextViewContainer.visibility = View.VISIBLE
nameTextViewContainer.setOnClickListener {
nameTextViewContainer.visibility = View.INVISIBLE
nameEditContainer.visibility = View.VISIBLE
nameEditText.text = null
nameEditText.requestFocus()
nameEditTextContainer.visibility = View.VISIBLE
nicknameEditText.text = null
nicknameEditText.requestFocus()
showSoftKeyboard()
}
btnCancelNickNameEdit.setOnClickListener {
nameEditText.clearFocus()
cancelNicknameEditingButton.setOnClickListener {
nicknameEditText.clearFocus()
hideSoftKeyboard()
nameTextViewContainer.visibility = View.VISIBLE
nameEditContainer.visibility = View.INVISIBLE
nameEditTextContainer.visibility = View.INVISIBLE
}
btnSaveNickNameEdit.setOnClickListener {
saveNicknameButton.setOnClickListener {
saveNickName(recipient)
}
nameEditText.setOnEditorActionListener { _, actionId, _ ->
nicknameEditText.setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_DONE -> {
saveNickName(recipient)
@ -72,13 +72,13 @@ class UserDetailsBottomSheet : BottomSheetDialogFragment() {
}
fun saveNickName(recipient: Recipient) {
nameEditText.clearFocus()
nicknameEditText.clearFocus()
hideSoftKeyboard()
nameTextViewContainer.visibility = View.VISIBLE
nameEditContainer.visibility = View.INVISIBLE
nameEditTextContainer.visibility = View.INVISIBLE
var newNickName: String? = null
if (nameEditText.text.isNotEmpty()) {
newNickName = nameEditText.text.toString()
if (nicknameEditText.text.isNotEmpty()) {
newNickName = nicknameEditText.text.toString()
}
val publicKey = recipient.address.serialize()
val contactDB = DatabaseFactory.getSessionContactDatabase(context)
@ -91,11 +91,11 @@ class UserDetailsBottomSheet : BottomSheetDialogFragment() {
@SuppressLint("ServiceCast")
fun showSoftKeyboard() {
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.showSoftInput(nameEditText, 0)
imm?.showSoftInput(nicknameEditText, 0)
}
fun hideSoftKeyboard() {
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.hideSoftInputFromWindow(nameEditText.windowToken, 0)
imm?.hideSoftInputFromWindow(nicknameEditText.windowToken, 0)
}
}

View File

@ -29,27 +29,37 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_centerInParent="true"
android:visibility="visible">
<View
android:layout_width="24dp"
android:layout_height="24dp" />
<TextView
android:id="@+id/nameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="@dimen/massive_font_size"
android:layout_marginStart="@dimen/small_spacing"
android:layout_marginEnd="@dimen/small_spacing"
android:textSize="@dimen/large_font_size"
android:textStyle="bold"
android:textColor="@color/text"
android:textAlignment="center"
android:text="Spiderman"
android:paddingStart="24dp"
android:paddingEnd="0dp"
android:drawableEnd="@drawable/ic_baseline_edit_24"
android:drawablePadding="@dimen/small_spacing" />
android:text="Spiderman" />
<ImageView
android:layout_width="20dp"
android:layout_height="22dp"
android:paddingTop="2dp"
android:src="@drawable/ic_baseline_edit_24" />
</LinearLayout>
<LinearLayout
android:id="@+id/nameEditContainer"
android:id="@+id/nameEditTextContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
@ -57,34 +67,32 @@
android:visibility="invisible">
<ImageView
android:id="@+id/btnCancelNickNameEdit"
android:id="@+id/cancelNicknameEditingButton"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_baseline_clear_24"/>
android:src="@drawable/ic_baseline_clear_24" />
<EditText
android:id="@+id/nameEditText"
style="@style/SessionEditText"
android:id="@+id/nicknameEditText"
style="@style/SmallSessionEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="@dimen/small_spacing"
android:layout_marginEnd="@dimen/small_spacing"
android:textAlignment="center"
android:textSize="@dimen/very_large_font_size"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:inputType="text"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="Enter a name"/>
android:hint="@string/fragment_user_details_bottom_sheet_edit_text_hint" />
<ImageView
android:id="@+id/btnSaveNickNameEdit"
android:id="@+id/saveNicknameButton"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_done_24"/>
android:src="@drawable/ic_baseline_done_24" />
</LinearLayout>
@ -95,8 +103,8 @@
android:id="@+id/publicKeyTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/large_font_size"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginTop="@dimen/medium_spacing"
android:textSize="@dimen/medium_font_size"
android:textIsSelectable="true"
android:text="05987d601943c267879be41830888066c6a024cbdc9a548d06813924bf3372ea78" />

View File

@ -813,8 +813,10 @@
<string name="activity_backup_restore_select_file">Select a file</string>
<string name="activity_backup_restore_explanation_1">Select a backup file and enter the passphrase it was created with.</string>
<string name="activity_backup_restore_passphrase">30-digit passphrase</string>
<!-- LinkDeviceActivity -->
<string name="activity_link_device_skip_prompt">This is taking a while, would you like to skip?</string>
<string name="activity_join_public_chat_join_rooms">Or join one of these…</string>
<string name="fragment_user_details_bottom_sheet_edit_text_hint">Enter a nickname</string>
</resources>

View File

@ -137,7 +137,7 @@
<style name="SessionIDTextView">
<item name="android:background">@drawable/session_id_text_view_background</item>
<item name="android:padding">@dimen/medium_spacing</item>
<item name="android:textSize">@dimen/large_font_size</item>
<item name="android:textSize">20sp</item>
<item name="android:textColor">@color/text</item>
<item name="android:fontFamily">@font/space_mono_regular</item>
<item name="android:textAlignment">viewStart</item>