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:textColor="@color/text"
|
||||||
android:text="@string/activity_create_closed_group_empty_state_message" />
|
android:text="@string/activity_create_closed_group_empty_state_message" />
|
||||||
|
|
||||||
<Button
|
<!-- <Button-->
|
||||||
style="@style/MediumProminentOutlineButton"
|
<!-- style="@style/MediumProminentOutlineButton"-->
|
||||||
android:id="@+id/btnCreateNewPrivateChat"
|
<!-- android:id="@+id/btnCreateNewPrivateChat"-->
|
||||||
android:layout_width="196dp"
|
<!-- android:layout_width="196dp"-->
|
||||||
android:layout_height="@dimen/medium_button_height"
|
<!-- android:layout_height="@dimen/medium_button_height"-->
|
||||||
android:layout_marginTop="@dimen/medium_spacing"
|
<!-- android:layout_marginTop="@dimen/medium_spacing"-->
|
||||||
android:text="@string/activity_create_closed_group_empty_state_button_title" />
|
<!-- android:text="@string/activity_create_closed_group_empty_state_button_title" />-->
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -151,9 +151,9 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
REQ_CODE_ADD_USERS -> {
|
REQ_CODE_ADD_USERS -> {
|
||||||
if (resultCode != RESULT_OK) return
|
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
|
val changedMembers = members + selectedContacts
|
||||||
updateMembers(changedMembers)
|
updateMembers(changedMembers)
|
||||||
}
|
}
|
||||||
|
@ -15,33 +15,27 @@ import network.loki.messenger.R
|
|||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp
|
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>> {
|
class SelectContactsActivity : PassphraseRequiredActionBarActivity(), LoaderManager.LoaderCallbacks<List<String>> {
|
||||||
private var members = listOf<String>()
|
private var members = listOf<String>()
|
||||||
set(value) { field = value; selectContactsAdapter.members = value }
|
set(value) { field = value; selectContactsAdapter.members = value }
|
||||||
|
|
||||||
private val selectContactsAdapter by lazy {
|
private lateinit var selectContactsAdapter: SelectContactsAdapter
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Lifecycle
|
// region Lifecycle
|
||||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||||
super.onCreate(savedInstanceState, isReady)
|
super.onCreate(savedInstanceState, isReady)
|
||||||
setContentView(R.layout.activity_select_contacts)
|
setContentView(R.layout.activity_select_contacts)
|
||||||
supportActionBar!!.title = resources.getString(R.string.activity_select_contacts_title)
|
supportActionBar!!.title = resources.getString(R.string.activity_select_contacts_title)
|
||||||
|
|
||||||
|
this.selectContactsAdapter = SelectContactsAdapter(this, GlideApp.with(this))
|
||||||
recyclerView.adapter = selectContactsAdapter
|
recyclerView.adapter = selectContactsAdapter
|
||||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
btnCreateNewPrivateChat.setOnClickListener { createNewPrivateChat() }
|
|
||||||
|
// btnCreateNewPrivateChat.setOnClickListener { closeAndCreatePrivateChat() }
|
||||||
|
|
||||||
LoaderManager.getInstance(this).initLoader(0, null, this)
|
LoaderManager.getInstance(this).initLoader(0, null, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,25 +68,24 @@ class SelectContactsActivity : PassphraseRequiredActionBarActivity(), LoaderMana
|
|||||||
|
|
||||||
// region Interaction
|
// region Interaction
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val id = item.itemId
|
when(item.itemId) {
|
||||||
when(id) {
|
R.id.doneButton -> closeAndReturnSelected()
|
||||||
R.id.doneButton -> returnContacts()
|
|
||||||
else -> { /* Do nothing */ }
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createNewPrivateChat() {
|
// private fun closeAndCreatePrivateChat() {
|
||||||
setResult(createNewPrivateChatResultCode)
|
// setResult(RESULT_CREATE_PRIVATE_CHAT)
|
||||||
finish()
|
// finish()
|
||||||
}
|
// }
|
||||||
|
|
||||||
private fun returnContacts() {
|
private fun closeAndReturnSelected() {
|
||||||
val selectedMembers = this.selectedMembers
|
val selectedMembers = this.selectContactsAdapter.selectedMembers
|
||||||
val selectedContacts = selectedMembers.toTypedArray()
|
val selectedContacts = selectedMembers.toTypedArray()
|
||||||
val data = Intent()
|
val intent = Intent()
|
||||||
data.putExtra(EXTRA_SELECTED_CONTACTS, selectedContacts)
|
intent.putExtra(EXTRA_RESULT_SELECTED_CONTACTS, selectedContacts)
|
||||||
setResult(Activity.RESULT_OK, data)
|
setResult(Activity.RESULT_OK, intent)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
// endregion
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user