Clean up create private chat screen

This commit is contained in:
nielsandriesse 2021-06-02 11:34:30 +10:00
parent 9888f23789
commit 43fbc3de55
5 changed files with 167 additions and 152 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="network.loki.messenger"> package="network.loki.messenger">
@ -7,7 +8,7 @@
<permission <permission
android:name="network.loki.messenger.ACCESS_SESSION_SECRETS" android:name="network.loki.messenger.ACCESS_SESSION_SECRETS"
android:label="Access to TextSecure Secrets" android:label="Access to Session secrets"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
<uses-feature <uses-feature
@ -36,32 +37,26 @@
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<!-- For conversation 'shortcuts' on the desktop -->
<uses-permission android:name="android.permission.INSTALL_SHORTCUT" /> <uses-permission android:name="android.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" /> <uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!-- Unused permissions that need to be removed -->
<uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove"/> <uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" tools:node="remove"/> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" tools:node="remove"/>
<!-- The allowBackup="false" below is important to guard against potential malicious backups --> <!-- The allowBackup="false" below is important to guard against potential malicious backups -->
<application <application
android:name="org.thoughtcrime.securesms.ApplicationContext" android:name="org.thoughtcrime.securesms.ApplicationContext"
android:allowBackup="false" android:allowBackup="false"
@ -73,7 +68,8 @@
android:theme="@style/Theme.Session.DayNight" android:theme="@style/Theme.Session.DayNight"
tools:replace="android:allowBackup"> tools:replace="android:allowBackup">
<!-- Disable analytics --> <!-- Disable all analytics -->
<meta-data <meta-data
android:name="firebase_analytics_collection_deactivated" android:name="firebase_analytics_collection_deactivated"
android:value="true" /> android:value="true" />
@ -90,22 +86,16 @@
android:name="firebase_messaging_auto_init_enabled" android:name="firebase_messaging_auto_init_enabled"
android:value="false" /> android:value="false" />
<!-- Session -->
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.LandingActivity" android:name="org.thoughtcrime.securesms.loki.activities.LandingActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.FlatActionBar"/> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.RegisterActivity" android:name="org.thoughtcrime.securesms.loki.activities.RegisterActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.FlatActionBar"/>
<activity
android:name="org.thoughtcrime.securesms.loki.activities.RecoveryPhraseRestoreActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Session.DayNight.FlatActionBar" /> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.BackupRestoreActivity" android:name="org.thoughtcrime.securesms.loki.activities.RecoveryPhraseRestoreActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Session.DayNight.FlatActionBar" /> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
@ -113,16 +103,16 @@
android:name="org.thoughtcrime.securesms.loki.activities.LinkDeviceActivity" android:name="org.thoughtcrime.securesms.loki.activities.LinkDeviceActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Session.DayNight.FlatActionBar" /> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.DisplayNameActivity" android:name="org.thoughtcrime.securesms.loki.activities.DisplayNameActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Session.DayNight.FlatActionBar"/> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.PNModeActivity" android:name="org.thoughtcrime.securesms.loki.activities.PNModeActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.FlatActionBar" /> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.HomeActivity" android:name="org.thoughtcrime.securesms.loki.activities.HomeActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
@ -131,18 +121,19 @@
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.SettingsActivity" android:name="org.thoughtcrime.securesms.loki.activities.SettingsActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:label="@string/activity_settings_title"/> android:label="@string/activity_settings_title" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.PathActivity" android:name="org.thoughtcrime.securesms.loki.activities.PathActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.QRCodeActivity" android:name="org.thoughtcrime.securesms.loki.activities.QRCodeActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.FlatActionBar"/> android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.CreatePrivateChatActivity" android:name="org.thoughtcrime.securesms.loki.activities.CreatePrivateChatActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.FlatActionBar"/> android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Session.DayNight.FlatActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.CreateClosedGroupActivity" android:name="org.thoughtcrime.securesms.loki.activities.CreateClosedGroupActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
@ -164,14 +155,14 @@
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.PrivacySettingsActivity" android:name="org.thoughtcrime.securesms.loki.activities.PrivacySettingsActivity"
android:label="@string/activity_privacy_settings_title" android:label="@string/activity_privacy_settings_title"
android:screenOrientation="portrait"/> android:screenOrientation="portrait" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.NotificationSettingsActivity" android:name="org.thoughtcrime.securesms.loki.activities.NotificationSettingsActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.ChatSettingsActivity" android:name="org.thoughtcrime.securesms.loki.activities.ChatSettingsActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<!-- Session -->
<activity <activity
android:name="org.thoughtcrime.securesms.ShareActivity" android:name="org.thoughtcrime.securesms.ShareActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
@ -184,9 +175,7 @@
android:windowSoftInputMode="stateHidden"> android:windowSoftInputMode="stateHidden">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" /> <data android:mimeType="audio/*" />
<data android:mimeType="image/*" /> <data android:mimeType="image/*" />
<data android:mimeType="text/plain" /> <data android:mimeType="text/plain" />
@ -195,7 +184,6 @@
<data android:mimeType="text/*" /> <data android:mimeType="text/*" />
<data android:mimeType="*/*" /> <data android:mimeType="*/*" />
</intent-filter> </intent-filter>
<meta-data <meta-data
android:name="android.service.chooser.chooser_target_service" android:name="android.service.chooser.chooser_target_service"
android:value=".service.DirectShareService" /> android:value=".service.DirectShareService" />
@ -207,11 +195,9 @@
android:targetActivity="org.thoughtcrime.securesms.loki.activities.HomeActivity"> android:targetActivity="org.thoughtcrime.securesms.loki.activities.HomeActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" /> <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter> </intent-filter>
<meta-data <meta-data
android:name="com.sec.minimode.icon.portrait.normal" android:name="com.sec.minimode.icon.portrait.normal"
android:resource="@mipmap/ic_launcher" /> android:resource="@mipmap/ic_launcher" />
@ -235,16 +221,15 @@
<activity <activity
android:name="org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2" android:name="org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.TextSecure.DayNight.NoActionBar"> android:theme="@style/Theme.TextSecure.DayNight.NoActionBar" />
</activity>
<activity <activity
android:name="org.thoughtcrime.securesms.loki.activities.OpenGroupGuidelinesActivity" android:name="org.thoughtcrime.securesms.loki.activities.OpenGroupGuidelinesActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.TextSecure.DayNight"/> android:theme="@style/Theme.TextSecure.DayNight" />
<activity <activity
android:name="org.thoughtcrime.securesms.longmessage.LongMessageActivity" android:name="org.thoughtcrime.securesms.longmessage.LongMessageActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/Theme.TextSecure.DayNight"/> android:theme="@style/Theme.TextSecure.DayNight" />
<activity <activity
android:name="org.thoughtcrime.securesms.conversation.ConversationPopupActivity" android:name="org.thoughtcrime.securesms.conversation.ConversationPopupActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
@ -269,7 +254,7 @@
android:name="org.thoughtcrime.securesms.PassphrasePromptActivity" android:name="org.thoughtcrime.securesms.PassphrasePromptActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:launchMode="singleTask" android:launchMode="singleTask"
android:theme="@style/Theme.Session.DayNight.NoActionBar"/> android:theme="@style/Theme.Session.DayNight.NoActionBar" />
<activity <activity
android:name="org.thoughtcrime.securesms.giph.ui.GiphyActivity" android:name="org.thoughtcrime.securesms.giph.ui.GiphyActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
@ -311,7 +296,7 @@
<activity <activity
android:name="org.thoughtcrime.securesms.scribbles.StickerSelectActivity" android:name="org.thoughtcrime.securesms.scribbles.StickerSelectActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:theme="@style/Theme.Session.ForceDark"/> android:theme="@style/Theme.Session.ForceDark" />
<activity <activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity" android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
@ -441,7 +426,6 @@
<action android:name="info.guardianproject.panic.action.TRIGGER" /> <action android:name="info.guardianproject.panic.action.TRIGGER" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- Session -->
<receiver <receiver
android:name="org.thoughtcrime.securesms.loki.api.BackgroundPollWorker$BootBroadcastReceiver" android:name="org.thoughtcrime.securesms.loki.api.BackgroundPollWorker$BootBroadcastReceiver"
android:enabled="true"> android:enabled="true">
@ -449,7 +433,6 @@
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- Session -->
<service <service
android:name="org.thoughtcrime.securesms.jobmanager.JobSchedulerScheduler$SystemService" android:name="org.thoughtcrime.securesms.jobmanager.JobSchedulerScheduler$SystemService"
android:enabled="@bool/enable_job_service" android:enabled="@bool/enable_job_service"
@ -461,11 +444,9 @@
<receiver <receiver
android:name="org.thoughtcrime.securesms.jobmanager.AlarmManagerScheduler$RetryReceiver" android:name="org.thoughtcrime.securesms.jobmanager.AlarmManagerScheduler$RetryReceiver"
android:enabled="@bool/enable_alarm_manager" /> <!-- Probably don't need this one --> android:enabled="@bool/enable_alarm_manager" /> <!-- Probably don't need this one -->
<uses-library <uses-library
android:name="com.sec.android.app.multiwindow" android:name="com.sec.android.app.multiwindow"
android:required="false" /> android:required="false" />
<meta-data <meta-data
android:name="com.sec.android.support.multiwindow" android:name="com.sec.android.support.multiwindow"
android:value="true" /> android:value="true" />

View file

@ -7,35 +7,43 @@ import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
import android.text.InputType import android.text.InputType
import android.util.Log
import android.util.TypedValue
import android.view.* import android.view.*
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.Toast import android.widget.Toast
import kotlinx.android.synthetic.main.activity_create_private_chat.loader import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.activity_create_private_chat.tabLayout import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.activity_create_private_chat.viewPager import androidx.fragment.app.FragmentPagerAdapter
import kotlinx.android.synthetic.main.activity_create_private_chat.*
import kotlinx.android.synthetic.main.fragment_enter_public_key.* import kotlinx.android.synthetic.main.fragment_enter_public_key.*
import network.loki.messenger.R import network.loki.messenger.R
import nl.komponents.kovenant.ui.failUi import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi import nl.komponents.kovenant.ui.successUi
import org.session.libsession.snode.SnodeAPI import org.session.libsession.snode.SnodeAPI
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.conversation.ConversationActivity
import org.session.libsession.utilities.Address import org.session.libsession.utilities.Address
import org.session.libsession.utilities.DistributionTypes import org.session.libsession.utilities.DistributionTypes
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsignal.utilities.PublicKeyValidation
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.conversation.ConversationActivity
import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.utilities.PublicKeyValidation
class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRCodeWrapperFragmentDelegate { class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRCodeWrapperFragmentDelegate {
private val adapter = CreatePrivateChatActivityAdapter(this) private val adapter = CreatePrivateChatActivityAdapter(this)
private var isKeyboardShowing = false
set(value) {
val hasChanged = (field != value)
field = value
if (hasChanged) {
adapter.isKeyboardShowing = value
}
}
// region Lifecycle // region Lifecycle
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) { override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
@ -47,11 +55,15 @@ class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRC
// Set up view pager // Set up view pager
viewPager.adapter = adapter viewPager.adapter = adapter
tabLayout.setupWithViewPager(viewPager) tabLayout.setupWithViewPager(viewPager)
} rootLayout.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onCreateOptionsMenu(menu: Menu?): Boolean { override fun onGlobalLayout() {
menuInflater.inflate(R.menu.menu_done, menu) val diff = rootLayout.rootView.height - rootLayout.height
return true val displayMetrics = this@CreatePrivateChatActivity.resources.displayMetrics
val estimatedKeyboardHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200.0f, displayMetrics)
this@CreatePrivateChatActivity.isKeyboardShowing = (diff > estimatedKeyboardHeight)
}
})
} }
// endregion // endregion
@ -73,13 +85,6 @@ class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRC
// endregion // endregion
// region Interaction // region Interaction
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when(item.itemId) {
R.id.doneButton -> adapter.enterPublicKeyFragment.createPrivateChatIfPossible()
}
return super.onOptionsItemSelected(item)
}
override fun handleQRCodeScanned(hexEncodedPublicKey: String) { override fun handleQRCodeScanned(hexEncodedPublicKey: String) {
createPrivateChatIfPossible(hexEncodedPublicKey) createPrivateChatIfPossible(hexEncodedPublicKey)
} }
@ -122,6 +127,8 @@ class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRC
// region Adapter // region Adapter
private class CreatePrivateChatActivityAdapter(val activity: CreatePrivateChatActivity) : FragmentPagerAdapter(activity.supportFragmentManager) { private class CreatePrivateChatActivityAdapter(val activity: CreatePrivateChatActivity) : FragmentPagerAdapter(activity.supportFragmentManager) {
val enterPublicKeyFragment = EnterPublicKeyFragment() val enterPublicKeyFragment = EnterPublicKeyFragment()
var isKeyboardShowing = false
set(value) { field = value; enterPublicKeyFragment.isKeyboardShowing = isKeyboardShowing }
override fun getCount(): Int { override fun getCount(): Int {
return 2 return 2
@ -152,6 +159,8 @@ private class CreatePrivateChatActivityAdapter(val activity: CreatePrivateChatAc
// region Enter Public Key Fragment // region Enter Public Key Fragment
class EnterPublicKeyFragment : Fragment() { class EnterPublicKeyFragment : Fragment() {
var isKeyboardShowing = false
set(value) { field = value; handleIsKeyboardShowingChanged() }
private val hexEncodedPublicKey: String private val hexEncodedPublicKey: String
get() { get() {
@ -182,6 +191,10 @@ class EnterPublicKeyFragment : Fragment() {
createPrivateChatButton.setOnClickListener { createPrivateChatIfPossible() } createPrivateChatButton.setOnClickListener { createPrivateChatIfPossible() }
} }
private fun handleIsKeyboardShowingChanged() {
optionalContentContainer.isVisible = !isKeyboardShowing
}
private fun copyPublicKey() { private fun copyPublicKey() {
val clipboard = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clipboard = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("Session ID", hexEncodedPublicKey) val clip = ClipData.newPlainText("Session ID", hexEncodedPublicKey)
@ -197,9 +210,10 @@ class EnterPublicKeyFragment : Fragment() {
startActivity(intent) startActivity(intent)
} }
fun createPrivateChatIfPossible() { private fun createPrivateChatIfPossible() {
val hexEncodedPublicKey = publicKeyEditText.text?.trim().toString() ?: "" val hexEncodedPublicKey = publicKeyEditText.text?.trim().toString()
(requireActivity() as CreatePrivateChatActivity).createPrivateChatIfPossible(hexEncodedPublicKey) val activity = requireActivity() as CreatePrivateChatActivity
activity.createPrivateChatIfPossible(hexEncodedPublicKey)
} }
} }
// endregion // endregion

View file

@ -15,10 +15,10 @@
android:elevation="1dp" /> android:elevation="1dp" />
<EditText <EditText
style="@style/SessionEditText" style="@style/SmallSessionEditText"
android:id="@+id/publicKeyEditText" android:id="@+id/publicKeyEditText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="64dp"
android:layout_marginLeft="@dimen/large_spacing" android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing" android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing" android:layout_marginRight="@dimen/large_spacing"
@ -26,7 +26,7 @@
android:paddingBottom="0dp" android:paddingBottom="0dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:maxLines="2" android:maxLines="3"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:hint="@string/fragment_enter_public_key_edit_text_hint" /> android:hint="@string/fragment_enter_public_key_edit_text_hint" />
@ -41,56 +41,65 @@
android:alpha="0.6" android:alpha="0.6"
android:textAlignment="center" android:textAlignment="center"
android:text="@string/fragment_enter_public_key_explanation" /> android:text="@string/fragment_enter_public_key_explanation" />
<org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
android:id="@+id/separatorView"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing" />
<TextView
android:id="@+id/publicKeyTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:textSize="@dimen/medium_font_size"
android:textColor="@color/text"
android:fontFamily="@font/space_mono_regular"
android:textAlignment="center"
tools:text="05987d601943c267879be41830888066c6a024cbdc9a548d06813924bf3372ea78" />
<LinearLayout <LinearLayout
android:id="@+id/optionalContentContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing" android:orientation="vertical">
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:orientation="horizontal">
<Button <org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
style="@style/Widget.Session.Button.Common.UnimportantFilled" android:id="@+id/separatorView"
android:id="@+id/copyButton" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="32dp"
android:layout_height="@dimen/medium_button_height" android:layout_marginLeft="@dimen/large_spacing"
android:layout_weight="1" android:layout_marginTop="@dimen/large_spacing"
android:text="@string/copy" /> android:layout_marginRight="@dimen/large_spacing" />
<Button <TextView
style="@style/Widget.Session.Button.Common.UnimportantFilled" android:id="@+id/publicKeyTextView"
android:id="@+id/shareButton" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="@dimen/medium_button_height" android:layout_marginLeft="@dimen/large_spacing"
android:layout_weight="1" android:layout_marginTop="@dimen/large_spacing"
android:layout_marginStart="@dimen/medium_spacing" android:layout_marginRight="@dimen/large_spacing"
android:text="@string/share" /> android:textSize="@dimen/medium_font_size"
android:textColor="@color/text"
android:fontFamily="@font/space_mono_regular"
android:textAlignment="center"
tools:text="05987d601943c267879be41830888066c6a024cbdc9a548d06813924bf3372ea78" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:orientation="horizontal">
<Button
style="@style/Widget.Session.Button.Common.UnimportantFilled"
android:id="@+id/copyButton"
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:text="@string/copy" />
<Button
style="@style/Widget.Session.Button.Common.UnimportantFilled"
android:id="@+id/shareButton"
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/medium_spacing"
android:text="@string/share" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/spacer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1" />

View file

@ -2,6 +2,7 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contentView" android:id="@+id/contentView"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -17,7 +18,7 @@
style="@style/SmallSessionEditText" style="@style/SmallSessionEditText"
android:id="@+id/publicKeyEditText" android:id="@+id/publicKeyEditText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="54dp" android:layout_height="64dp"
android:layout_marginLeft="@dimen/large_spacing" android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing" android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing" android:layout_marginRight="@dimen/large_spacing"
@ -25,7 +26,7 @@
android:paddingBottom="0dp" android:paddingBottom="0dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:maxLines="2" android:maxLines="3"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:hint="@string/fragment_enter_public_key_edit_text_hint" /> android:hint="@string/fragment_enter_public_key_edit_text_hint" />
@ -40,56 +41,65 @@
android:alpha="0.6" android:alpha="0.6"
android:textAlignment="center" android:textAlignment="center"
android:text="@string/fragment_enter_public_key_explanation" /> android:text="@string/fragment_enter_public_key_explanation" />
<org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
android:id="@+id/separatorView"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing" />
<TextView
android:id="@+id/publicKeyTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:textSize="@dimen/medium_font_size"
android:textColor="@color/text"
android:fontFamily="@font/space_mono_regular"
android:textAlignment="center"
tools:text="05987d601943c267879be41830888066c6a024cbdc9a548d06813924bf3372ea78" />
<LinearLayout <LinearLayout
android:id="@+id/optionalContentContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing" android:orientation="vertical">
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:orientation="horizontal">
<Button <org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
style="@style/Widget.Session.Button.Common.UnimportantFilled" android:id="@+id/separatorView"
android:id="@+id/copyButton" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="32dp"
android:layout_height="@dimen/medium_button_height" android:layout_marginLeft="@dimen/large_spacing"
android:layout_weight="1" android:layout_marginTop="@dimen/large_spacing"
android:text="@string/copy" /> android:layout_marginRight="@dimen/large_spacing" />
<Button <TextView
style="@style/Widget.Session.Button.Common.UnimportantFilled" android:id="@+id/publicKeyTextView"
android:id="@+id/shareButton" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="@dimen/medium_button_height" android:layout_marginLeft="@dimen/large_spacing"
android:layout_weight="1" android:layout_marginTop="@dimen/large_spacing"
android:layout_marginStart="@dimen/medium_spacing" android:layout_marginRight="@dimen/large_spacing"
android:text="@string/share" /> android:textSize="@dimen/medium_font_size"
android:textColor="@color/text"
android:fontFamily="@font/space_mono_regular"
android:textAlignment="center"
tools:text="05987d601943c267879be41830888066c6a024cbdc9a548d06813924bf3372ea78" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:orientation="horizontal">
<Button
style="@style/Widget.Session.Button.Common.UnimportantFilled"
android:id="@+id/copyButton"
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:text="@string/copy" />
<Button
style="@style/Widget.Session.Button.Common.UnimportantFilled"
android:id="@+id/shareButton"
android:layout_width="0dp"
android:layout_height="@dimen/medium_button_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/medium_spacing"
android:text="@string/share" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/spacer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1" />