mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
Settings activity toolbar and display name editing refactoring.
This commit is contained in:
parent
37a3ae9c32
commit
6aaa2dbabd
@ -119,7 +119,7 @@
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.SettingsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Session.DarkTheme.NoActionBar" />
|
||||
android:label="@string/activity_settings_title"/>
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.PathActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
@ -2,14 +2,15 @@
|
||||
android:width="25dp"
|
||||
android:height="25dp"
|
||||
android:viewportWidth="25"
|
||||
android:viewportHeight="25">
|
||||
android:viewportHeight="25"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<group>
|
||||
<clip-path android:pathData="M7.81,7.81H1.56V1.56h6.25V7.81zM9.38,0H0v9.38h9.38V0z M 0,0"/>
|
||||
<group>
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M-5,-5h19.38v19.38h-19.38z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -18,7 +19,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M-1.88,-1.88h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -27,7 +28,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M-5,10.62h19.38v19.38h-19.38z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -36,7 +37,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M-1.88,13.75h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -45,7 +46,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M10.62,-5h19.38v19.38h-19.38z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -54,7 +55,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M13.75,-1.88h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -63,7 +64,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M-5,5.94h14.69v13.12h-14.69z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -72,7 +73,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M5.94,9.06h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -81,7 +82,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M-0.31,5.94h13.12v11.56h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -90,7 +91,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M5.94,13.75h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -99,7 +100,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M2.81,5.94h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -108,7 +109,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M7.5,1.25h11.56v13.12h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -117,7 +118,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M7.5,5.94h14.69v13.12h-14.69z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -126,7 +127,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M5.94,4.38h11.56v11.56h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -135,7 +136,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M9.06,16.88h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -144,7 +145,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M5.94,16.88h11.56v13.12h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -153,7 +154,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M9.06,12.19h11.56v11.56h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -162,7 +163,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M5.94,-5h13.12v16.25h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -171,7 +172,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M13.75,16.88h11.56v13.12h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -180,7 +181,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M13.75,13.75h13.12v11.56h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -189,7 +190,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M12.19,15.31h11.56v11.56h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -198,7 +199,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M10.62,13.75h11.56v11.56h-11.56z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -207,7 +208,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M16.88,10.62h13.12v13.12h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -216,7 +217,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M16.88,15.31h13.12v14.69h-13.12z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -225,7 +226,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M10.62,9.06h14.69v13.12h-14.69z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@ -234,7 +235,7 @@
|
||||
<clip-path android:pathData="M-335,-28h375v908h-375z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M13.75,5.94h16.25v13.12h-16.25z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:fillColor="@android:color/white"/>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
|
@ -1,9 +1,15 @@
|
||||
<vector android:height="24dp" android:viewportHeight="512"
|
||||
android:viewportWidth="448" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="448"
|
||||
android:viewportHeight="512">
|
||||
<group
|
||||
android:scaleX="0.88"
|
||||
android:scaleY="0.88"
|
||||
android:translateX="64">
|
||||
<path android:fillColor="?attr/pref_icon_tint" android:pathData="M0,224h192L192,32L0,32v192zM64,96h64v64L64,160L64,96zM256,32v192h192L448,32L256,32zM384,160h-64L320,96h64v64zM0,480h192L192,288L0,288v192zM64,352h64v64L64,416v-64zM416,288h32v128h-96v-32h-32v96h-64L256,288h96v32h64v-32zM416,448h32v32h-32v-32zM352,448h32v32h-32v-32z"/>
|
||||
<path
|
||||
android:fillColor="?attr/pref_icon_tint"
|
||||
android:pathData="M0,224h192L192,32L0,32v192zM64,96h64v64L64,160L64,96zM256,32v192h192L448,32L256,32zM384,160h-64L320,96h64v64zM0,480h192L192,288L0,288v192zM64,352h64v64L64,416v-64zM416,288h32v128h-96v-32h-32v96h-64L256,288h96v32h64v-32zM416,448h32v32h-32v-32zM352,448h32v32h-32v-32z"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
@ -20,59 +20,6 @@
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:contentInsetLeft="20dp"
|
||||
app:contentInsetRight="20dp"
|
||||
android:theme="?attr/actionBarStyle">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cancelButton"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_close_white_24dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_settings_title"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="@dimen/very_large_font_size"
|
||||
android:fontFamily="sans-serif-medium" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/saveButton"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_check_white_24dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/showQRCodeButton"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_qr_code" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/large_profile_picture_size"
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
|
12
res/menu/settings_general.xml
Normal file
12
res/menu/settings_general.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_qr_code"
|
||||
android:title=""
|
||||
android:icon="@drawable/ic_qr_code"
|
||||
app:showAsAction="always" />
|
||||
|
||||
</menu>
|
@ -11,9 +11,11 @@ import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.ActionMode
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
@ -34,7 +36,6 @@ import org.thoughtcrime.securesms.loki.dialogs.SeedDialog
|
||||
import org.thoughtcrime.securesms.loki.utilities.fadeIn
|
||||
import org.thoughtcrime.securesms.loki.utilities.fadeOut
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper
|
||||
@ -51,9 +52,11 @@ import java.security.SecureRandom
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
private var displayNameEditActionMode: ActionMode? = null
|
||||
set(value) { field = value; handleDisplayNameEditActionModeChanged() }
|
||||
|
||||
private lateinit var glide: GlideRequests
|
||||
private var isEditingDisplayName = false
|
||||
set(value) { field = value; handleIsEditingDisplayNameChanged() }
|
||||
private var displayNameToBeUploaded: String? = null
|
||||
private var profilePictureToBeUploaded: ByteArray? = null
|
||||
private var tempFile: File? = null
|
||||
@ -68,23 +71,16 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
// region Lifecycle
|
||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||
super.onCreate(savedInstanceState, isReady)
|
||||
// setTheme(if (isDarkTheme())
|
||||
// R.style.Session_DarkTheme_NoActionBar
|
||||
// else
|
||||
// R.style.Session_LightTheme_NoActionBar)
|
||||
|
||||
setContentView(R.layout.activity_settings)
|
||||
setSupportActionBar(toolbar)
|
||||
cancelButton.setOnClickListener { cancelEditingDisplayName() }
|
||||
saveButton.setOnClickListener { saveDisplayName() }
|
||||
showQRCodeButton.setOnClickListener { showQRCode() }
|
||||
|
||||
glide = GlideApp.with(this)
|
||||
profilePictureView.glide = glide
|
||||
profilePictureView.publicKey = hexEncodedPublicKey
|
||||
profilePictureView.isLarge = true
|
||||
profilePictureView.update()
|
||||
profilePictureView.setOnClickListener { showEditProfilePictureUI() }
|
||||
ctnGroupNameSection.setOnClickListener { showEditDisplayNameUI() }
|
||||
ctnGroupNameSection.setOnClickListener { startActionMode(DisplayNameEditActionModeCallback()) }
|
||||
btnGroupNameDisplay.text = DatabaseFactory.getLokiUserDatabase(this).getDisplayName(hexEncodedPublicKey)
|
||||
publicKeyTextView.text = hexEncodedPublicKey
|
||||
copyButton.setOnClickListener { copyPublicKey() }
|
||||
@ -110,18 +106,22 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDarkTheme(): Boolean {
|
||||
val themeFlag = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||
return themeFlag == Configuration.UI_MODE_NIGHT_YES;
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.settings_general, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
//TODO Remove it.
|
||||
private fun setDarkTheme(darkTheme: Boolean) {
|
||||
// AppCompatDelegate.setDefaultNightMode(if (darkTheme) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO )
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_qr_code -> {
|
||||
showQRCode()
|
||||
return true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
AvatarSelection.REQUEST_CODE_AVATAR -> {
|
||||
@ -151,17 +151,16 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
// endregion
|
||||
|
||||
// region Updating
|
||||
private fun handleIsEditingDisplayNameChanged() {
|
||||
cancelButton.visibility = if (isEditingDisplayName) View.VISIBLE else View.GONE
|
||||
showQRCodeButton.visibility = if (isEditingDisplayName) View.GONE else View.VISIBLE
|
||||
saveButton.visibility = if (isEditingDisplayName) View.VISIBLE else View.GONE
|
||||
private fun handleDisplayNameEditActionModeChanged() {
|
||||
val isEditingDisplayName = this.displayNameEditActionMode !== null
|
||||
|
||||
btnGroupNameDisplay.visibility = if (isEditingDisplayName) View.INVISIBLE else View.VISIBLE
|
||||
displayNameEditText.visibility = if (isEditingDisplayName) View.VISIBLE else View.INVISIBLE
|
||||
val titleTextViewLayoutParams = titleTextView.layoutParams as LinearLayout.LayoutParams
|
||||
titleTextViewLayoutParams.leftMargin = if (isEditingDisplayName) toPx(16, resources) else 0
|
||||
titleTextView.layoutParams = titleTextViewLayoutParams
|
||||
|
||||
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
if (isEditingDisplayName) {
|
||||
displayNameEditText.setText(btnGroupNameDisplay.text)
|
||||
displayNameEditText.selectAll()
|
||||
displayNameEditText.requestFocus()
|
||||
inputMethodManager.showSoftInput(displayNameEditText, 0)
|
||||
} else {
|
||||
@ -216,21 +215,24 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
// endregion
|
||||
|
||||
// region Interaction
|
||||
private fun cancelEditingDisplayName() {
|
||||
isEditingDisplayName = false
|
||||
}
|
||||
|
||||
private fun saveDisplayName() {
|
||||
/**
|
||||
* @return true if the update was successful.
|
||||
*/
|
||||
private fun saveDisplayName(): Boolean {
|
||||
val displayName = displayNameEditText.text.toString().trim()
|
||||
if (displayName.isEmpty()) {
|
||||
return Toast.makeText(this, R.string.activity_settings_display_name_missing_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, R.string.activity_settings_display_name_missing_error, Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
if (displayName.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
|
||||
return Toast.makeText(this, R.string.activity_settings_display_name_too_long_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, R.string.activity_settings_display_name_too_long_error, Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
isEditingDisplayName = false
|
||||
// isEditingDisplayName = false
|
||||
displayNameToBeUploaded = displayName
|
||||
updateProfile(false)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun showQRCode() {
|
||||
@ -242,10 +244,6 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
tempFile = AvatarSelection.startAvatarSelection(this, false, true)
|
||||
}
|
||||
|
||||
private fun showEditDisplayNameUI() {
|
||||
isEditingDisplayName = true
|
||||
}
|
||||
|
||||
private fun copyPublicKey() {
|
||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("Session ID", hexEncodedPublicKey)
|
||||
@ -289,4 +287,46 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
ClearAllDataDialog().show(supportFragmentManager, "Clear All Data Dialog")
|
||||
}
|
||||
// endregion
|
||||
|
||||
//TODO Remove it.
|
||||
private fun isDarkTheme(): Boolean {
|
||||
val themeFlag = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||
return themeFlag == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
//TODO Remove it.
|
||||
private fun setDarkTheme(darkTheme: Boolean) {
|
||||
// AppCompatDelegate.setDefaultNightMode(if (darkTheme) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO )
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
|
||||
private inner class DisplayNameEditActionModeCallback: ActionMode.Callback {
|
||||
|
||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||
mode.title = getString(R.string.activity_settings_display_name_edit_text_hint)
|
||||
mode.menuInflater.inflate(R.menu.menu_apply, menu)
|
||||
this@SettingsActivity.displayNameEditActionMode = mode
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onDestroyActionMode(mode: ActionMode) {
|
||||
this@SettingsActivity.displayNameEditActionMode = null
|
||||
}
|
||||
|
||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.applyButton -> {
|
||||
if (this@SettingsActivity.saveDisplayName()) {
|
||||
mode.finish()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user