This commit is contained in:
Ryan ZHAO 2021-05-13 16:20:55 +10:00
parent 7b8a025947
commit 1d5f7957ab
2 changed files with 24 additions and 43 deletions

View File

@ -172,9 +172,6 @@
<activity
android:name="org.thoughtcrime.securesms.loki.activities.ChatSettingsActivity"
android:screenOrientation="portrait" />
<activity
android:name="org.thoughtcrime.securesms.loki.activities.LinkedDevicesActivity"
android:screenOrientation="portrait" />
<!-- Session -->
<activity
android:name="org.thoughtcrime.securesms.ShareActivity"
@ -224,24 +221,6 @@
android:resource="@mipmap/ic_launcher" />
</activity-alias>
<activity
android:name="org.thoughtcrime.securesms.stickers.StickerPackPreviewActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:launchMode="singleTask"
android:noHistory="true"
android:theme="@style/Theme.TextSecure.DayNight.NoActionBar"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="addstickers"
android:scheme="sgnl" />
</intent-filter>
</activity>
<activity
android:name="org.thoughtcrime.securesms.conversation.ConversationActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
@ -278,23 +257,11 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:launchMode="singleTask"
android:theme="@style/NoAnimation.Theme.AppCompat.Light.DarkActionBar" />
<activity
android:name="org.thoughtcrime.securesms.PassphraseCreateActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="@string/AndroidManifest__create_passphrase"
android:launchMode="singleTask"
android:theme="@style/Theme.Session.DayNight.NoActionBar"
android:windowSoftInputMode="stateUnchanged" />
<activity
android:name="org.thoughtcrime.securesms.PassphrasePromptActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:launchMode="singleTask"
android:theme="@style/Theme.Session.DayNight.NoActionBar"/>
<activity
android:name="org.thoughtcrime.securesms.PushContactSelectionActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="@string/AndroidManifest__select_contacts"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="org.thoughtcrime.securesms.giph.ui.GiphyActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"

View File

@ -9,6 +9,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import kotlinx.android.synthetic.main.fragment_user_details_bottom_sheet.*
@ -36,6 +37,7 @@ public class UserDetailsBottomSheet : BottomSheetDialogFragment() {
nameTextViewContainer.setOnClickListener {
nameTextViewContainer.visibility = View.INVISIBLE
nameEditContainer.visibility = View.VISIBLE
nameEditText.text = null
nameEditText.requestFocus()
showSoftKeyboard()
}
@ -44,19 +46,18 @@ public class UserDetailsBottomSheet : BottomSheetDialogFragment() {
hideSoftKeyboard()
nameTextViewContainer.visibility = View.VISIBLE
nameEditContainer.visibility = View.INVISIBLE
nameEditText.text = null
}
btnSaveNickNameEdit.setOnClickListener {
nameEditText.clearFocus()
hideSoftKeyboard()
nameTextViewContainer.visibility = View.VISIBLE
nameEditContainer.visibility = View.INVISIBLE
var newNickName: String? = null
if (!nameEditText.text.isEmpty()) {
newNickName = nameEditText.text.toString()
saveNickName(recipient)
}
nameEditText.setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_DONE -> {
saveNickName(recipient)
return@setOnEditorActionListener true
}
else -> return@setOnEditorActionListener false
}
SSKEnvironment.shared.profileManager.setDisplayName(requireContext(), recipient, newNickName)
nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous"
}
nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous"
publicKeyTextView.text = publicKey
@ -68,6 +69,19 @@ public class UserDetailsBottomSheet : BottomSheetDialogFragment() {
}
}
fun saveNickName(recipient: Recipient) {
nameEditText.clearFocus()
hideSoftKeyboard()
nameTextViewContainer.visibility = View.VISIBLE
nameEditContainer.visibility = View.INVISIBLE
var newNickName: String? = null
if (!nameEditText.text.isEmpty()) {
newNickName = nameEditText.text.toString()
}
SSKEnvironment.shared.profileManager.setDisplayName(requireContext(), recipient, newNickName)
nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous"
}
@SuppressLint("ServiceCast")
fun showSoftKeyboard() {
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager