mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Select contacts activity cleanup.
This commit is contained in:
parent
d9599b984a
commit
f5ff045b5d
@ -33,13 +33,13 @@
|
||||
android:textColor="@color/text"
|
||||
android:text="@string/activity_create_closed_group_empty_state_message" />
|
||||
|
||||
<Button
|
||||
style="@style/MediumProminentOutlineButton"
|
||||
android:id="@+id/btnCreateNewPrivateChat"
|
||||
android:layout_width="196dp"
|
||||
android:layout_height="@dimen/medium_button_height"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="@string/activity_create_closed_group_empty_state_button_title" />
|
||||
<!-- <Button-->
|
||||
<!-- style="@style/MediumProminentOutlineButton"-->
|
||||
<!-- android:id="@+id/btnCreateNewPrivateChat"-->
|
||||
<!-- android:layout_width="196dp"-->
|
||||
<!-- android:layout_height="@dimen/medium_button_height"-->
|
||||
<!-- android:layout_marginTop="@dimen/medium_spacing"-->
|
||||
<!-- android:text="@string/activity_create_closed_group_empty_state_button_title" />-->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -151,9 +151,9 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
||||
when (requestCode) {
|
||||
REQ_CODE_ADD_USERS -> {
|
||||
if (resultCode != RESULT_OK) return
|
||||
if (data == null || data.extras == null || !data.hasExtra(EXTRA_SELECTED_CONTACTS)) return
|
||||
if (data == null || data.extras == null || !data.hasExtra(EXTRA_RESULT_SELECTED_CONTACTS)) return
|
||||
|
||||
val selectedContacts = data.extras!!.getStringArray(EXTRA_SELECTED_CONTACTS)!!.toSet()
|
||||
val selectedContacts = data.extras!!.getStringArray(EXTRA_RESULT_SELECTED_CONTACTS)!!.toSet()
|
||||
val changedMembers = members + selectedContacts
|
||||
updateMembers(changedMembers)
|
||||
}
|
||||
|
@ -15,33 +15,27 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
|
||||
const val EXTRA_SELECTED_CONTACTS = "SELECTED_CONTACTS_RESULT"
|
||||
const val EXTRA_RESULT_SELECTED_CONTACTS = "RESULT_SELECTED_CONTACTS"
|
||||
//const val RESULT_CREATE_PRIVATE_CHAT = 100;
|
||||
|
||||
class SelectContactsActivity : PassphraseRequiredActionBarActivity(), LoaderManager.LoaderCallbacks<List<String>> {
|
||||
private var members = listOf<String>()
|
||||
set(value) { field = value; selectContactsAdapter.members = value }
|
||||
|
||||
private val selectContactsAdapter by lazy {
|
||||
val glide = GlideApp.with(this)
|
||||
val result = SelectContactsAdapter(this, glide)
|
||||
result
|
||||
}
|
||||
|
||||
private val selectedMembers: Set<String>
|
||||
get() { return selectContactsAdapter.selectedMembers }
|
||||
|
||||
companion object {
|
||||
public val createNewPrivateChatResultCode = 100
|
||||
}
|
||||
private lateinit var selectContactsAdapter: SelectContactsAdapter
|
||||
|
||||
// region Lifecycle
|
||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||
super.onCreate(savedInstanceState, isReady)
|
||||
setContentView(R.layout.activity_select_contacts)
|
||||
supportActionBar!!.title = resources.getString(R.string.activity_select_contacts_title)
|
||||
|
||||
this.selectContactsAdapter = SelectContactsAdapter(this, GlideApp.with(this))
|
||||
recyclerView.adapter = selectContactsAdapter
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
btnCreateNewPrivateChat.setOnClickListener { createNewPrivateChat() }
|
||||
|
||||
// btnCreateNewPrivateChat.setOnClickListener { closeAndCreatePrivateChat() }
|
||||
|
||||
LoaderManager.getInstance(this).initLoader(0, null, this)
|
||||
}
|
||||
|
||||
@ -74,25 +68,24 @@ class SelectContactsActivity : PassphraseRequiredActionBarActivity(), LoaderMana
|
||||
|
||||
// region Interaction
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val id = item.itemId
|
||||
when(id) {
|
||||
R.id.doneButton -> returnContacts()
|
||||
else -> { /* Do nothing */ }
|
||||
when(item.itemId) {
|
||||
R.id.doneButton -> closeAndReturnSelected()
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun createNewPrivateChat() {
|
||||
setResult(createNewPrivateChatResultCode)
|
||||
finish()
|
||||
}
|
||||
// private fun closeAndCreatePrivateChat() {
|
||||
// setResult(RESULT_CREATE_PRIVATE_CHAT)
|
||||
// finish()
|
||||
// }
|
||||
|
||||
private fun returnContacts() {
|
||||
val selectedMembers = this.selectedMembers
|
||||
private fun closeAndReturnSelected() {
|
||||
val selectedMembers = this.selectContactsAdapter.selectedMembers
|
||||
val selectedContacts = selectedMembers.toTypedArray()
|
||||
val data = Intent()
|
||||
data.putExtra(EXTRA_SELECTED_CONTACTS, selectedContacts)
|
||||
setResult(Activity.RESULT_OK, data)
|
||||
val intent = Intent()
|
||||
intent.putExtra(EXTRA_RESULT_SELECTED_CONTACTS, selectedContacts)
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
finish()
|
||||
}
|
||||
// endregion
|
||||
}
|
Loading…
Reference in New Issue
Block a user