diff --git a/res/layout/activity_create_closed_group.xml b/res/layout/activity_create_closed_group.xml index a965ae8551..78095701e9 100644 --- a/res/layout/activity_create_closed_group.xml +++ b/res/layout/activity_create_closed_group.xml @@ -5,34 +5,40 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="wrap_content" > - + android:orientation="vertical"> - + - + - + + + + + adapter.enterPublicKeyFragment.createPrivateChatIfPossible() + } + return super.onOptionsItemSelected(item) + } + override fun handleQRCodeScanned(hexEncodedPublicKey: String) { createPrivateChatIfPossible(hexEncodedPublicKey) } @@ -71,6 +81,7 @@ class CreatePrivateChatActivity : PassphraseRequiredActionBarActivity(), ScanQRC // region Adapter private class CreatePrivateChatActivityAdapter(val activity: CreatePrivateChatActivity) : FragmentPagerAdapter(activity.supportFragmentManager) { + val enterPublicKeyFragment = EnterPublicKeyFragment() override fun getCount(): Int { return 2 @@ -78,7 +89,7 @@ private class CreatePrivateChatActivityAdapter(val activity: CreatePrivateChatAc override fun getItem(index: Int): Fragment { return when (index) { - 0 -> EnterPublicKeyFragment() + 0 -> enterPublicKeyFragment 1 -> { val result = ScanQRCodeWrapperFragment() result.delegate = activity @@ -104,8 +115,8 @@ class EnterPublicKeyFragment : Fragment() { private val hexEncodedPublicKey: String get() { - val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context!!) - val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context!!) + val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(requireContext()) + val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(requireContext()) return masterHexEncodedPublicKey ?: userHexEncodedPublicKey } @@ -148,7 +159,7 @@ class EnterPublicKeyFragment : Fragment() { startActivity(intent) } - private fun createPrivateChatIfPossible() { + fun createPrivateChatIfPossible() { val hexEncodedPublicKey = publicKeyEditText.text?.trim().toString() ?: "" (requireActivity() as CreatePrivateChatActivity).createPrivateChatIfPossible(hexEncodedPublicKey) } diff --git a/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt index f21339ab42..1ee9270e6b 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt @@ -184,6 +184,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { private fun onAddMembersClick() { val intent = Intent(this@EditClosedGroupActivity, SelectContactsActivity::class.java) intent.putExtra(SelectContactsActivity.usersToExcludeKey, members.toTypedArray()) + intent.putExtra(SelectContactsActivity.emptyStateTextKey, "No contacts to add") startActivityForResult(intent, addUsersRequestCode) } diff --git a/src/org/thoughtcrime/securesms/loki/activities/SelectContactsActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/SelectContactsActivity.kt index 43a0bd72c6..76bdea6e25 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/SelectContactsActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/SelectContactsActivity.kt @@ -10,7 +10,10 @@ import android.view.Menu import android.view.MenuItem import android.view.View import kotlinx.android.synthetic.main.activity_create_closed_group.* +import kotlinx.android.synthetic.main.activity_create_closed_group.emptyStateContainer +import kotlinx.android.synthetic.main.activity_create_closed_group.mainContentContainer import kotlinx.android.synthetic.main.activity_linked_devices.recyclerView +import kotlinx.android.synthetic.main.activity_select_contacts.* import network.loki.messenger.R import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.mms.GlideApp @@ -26,6 +29,7 @@ class SelectContactsActivity : PassphraseRequiredActionBarActivity(), LoaderMana companion object { val usersToExcludeKey = "usersToExcludeKey" + val emptyStateTextKey = "emptyStateTextKey" val selectedContactsKey = "selectedContactsKey" } @@ -37,6 +41,10 @@ class SelectContactsActivity : PassphraseRequiredActionBarActivity(), LoaderMana supportActionBar!!.title = resources.getString(R.string.activity_select_contacts_title) usersToExclude = intent.getStringArrayExtra(Companion.usersToExcludeKey)?.toSet() ?: setOf() + val emptyStateText = intent.getStringExtra(Companion.emptyStateTextKey) + if (emptyStateText != null) { + emptyStateMessageTextView.text = emptyStateText + } recyclerView.adapter = selectContactsAdapter recyclerView.layoutManager = LinearLayoutManager(this)