mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-29 04:55:15 +00:00
Merge remote-tracking branch 'upstream/dev' into libsession-integration
# Conflicts: # app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
This commit is contained in:
commit
9a7d3a45d7
@ -42,6 +42,7 @@ class ClearAllDataDialog : BaseDialog() {
|
|||||||
var selectedOption = device
|
var selectedOption = device
|
||||||
val optionAdapter = RadioOptionAdapter { selectedOption = it }
|
val optionAdapter = RadioOptionAdapter { selectedOption = it }
|
||||||
binding.recyclerView.apply {
|
binding.recyclerView.apply {
|
||||||
|
itemAnimator = null
|
||||||
adapter = optionAdapter
|
adapter = optionAdapter
|
||||||
addItemDecoration(DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL))
|
addItemDecoration(DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL))
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
|
@ -1,42 +1,41 @@
|
|||||||
package org.thoughtcrime.securesms.preferences
|
package org.thoughtcrime.securesms.preferences
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration
|
|
||||||
import network.loki.messenger.databinding.DialogListPreferenceBinding
|
import network.loki.messenger.databinding.DialogListPreferenceBinding
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
|
||||||
|
|
||||||
class ListPreferenceDialog(
|
fun listPreferenceDialog(
|
||||||
private val listPreference: ListPreference,
|
context: Context,
|
||||||
private val dialogListener: () -> Unit
|
listPreference: ListPreference,
|
||||||
) : BaseDialog() {
|
dialogListener: () -> Unit
|
||||||
private lateinit var binding: DialogListPreferenceBinding
|
) : AlertDialog {
|
||||||
|
|
||||||
override fun setContentView(builder: AlertDialog.Builder) {
|
val builder = AlertDialog.Builder(context)
|
||||||
binding = DialogListPreferenceBinding.inflate(LayoutInflater.from(requireContext()))
|
|
||||||
binding.titleTextView.text = listPreference.dialogTitle
|
val binding = DialogListPreferenceBinding.inflate(LayoutInflater.from(context))
|
||||||
binding.messageTextView.text = listPreference.dialogMessage
|
binding.titleTextView.text = listPreference.dialogTitle
|
||||||
binding.closeButton.setOnClickListener {
|
binding.messageTextView.text = listPreference.dialogMessage
|
||||||
dismiss()
|
|
||||||
}
|
builder.setView(binding.root)
|
||||||
val options = listPreference.entryValues.zip(listPreference.entries) { value, title ->
|
|
||||||
RadioOption(value.toString(), title.toString())
|
val dialog = builder.show()
|
||||||
}
|
|
||||||
val valueIndex = listPreference.findIndexOfValue(listPreference.value)
|
val valueIndex = listPreference.findIndexOfValue(listPreference.value)
|
||||||
val optionAdapter = RadioOptionAdapter(valueIndex) {
|
RadioOptionAdapter(valueIndex) {
|
||||||
listPreference.value = it.value
|
listPreference.value = it.value
|
||||||
dismiss()
|
dialog.dismiss()
|
||||||
dialogListener.invoke()
|
dialogListener()
|
||||||
}
|
|
||||||
binding.recyclerView.apply {
|
|
||||||
adapter = optionAdapter
|
|
||||||
addItemDecoration(DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL))
|
|
||||||
setHasFixedSize(true)
|
|
||||||
}
|
|
||||||
optionAdapter.submitList(options)
|
|
||||||
builder.setView(binding.root)
|
|
||||||
builder.setCancelable(false)
|
|
||||||
}
|
}
|
||||||
|
.apply {
|
||||||
|
listPreference.entryValues.zip(listPreference.entries) { value, title ->
|
||||||
|
RadioOption(value.toString(), title.toString())
|
||||||
|
}.let(this::submitList)
|
||||||
|
}
|
||||||
|
.let { binding.recyclerView.adapter = it }
|
||||||
|
|
||||||
}
|
binding.closeButton.setOnClickListener { dialog.dismiss() }
|
||||||
|
|
||||||
|
return dialog
|
||||||
|
}
|
||||||
|
@ -2,6 +2,8 @@ package org.thoughtcrime.securesms.preferences;
|
|||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
|
||||||
|
import static org.thoughtcrime.securesms.preferences.ListPreferenceDialogKt.listPreferenceDialog;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -77,10 +79,10 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
|||||||
.setOnPreferenceClickListener(preference -> {
|
.setOnPreferenceClickListener(preference -> {
|
||||||
ListPreference listPreference = (ListPreference) preference;
|
ListPreference listPreference = (ListPreference) preference;
|
||||||
listPreference.setDialogMessage(R.string.preferences_notifications__content_message);
|
listPreference.setDialogMessage(R.string.preferences_notifications__content_message);
|
||||||
new ListPreferenceDialog(listPreference, () -> {
|
listPreferenceDialog(getContext(), listPreference, () -> {
|
||||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
|
initializeListSummary(findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
|
||||||
return null;
|
return null;
|
||||||
}).show(getChildFragmentManager(), "ListPreferenceDialog");
|
});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ class RadioOptionAdapter(
|
|||||||
) : ListAdapter<RadioOption, RadioOptionAdapter.ViewHolder>(RadioOptionDiffer()) {
|
) : ListAdapter<RadioOption, RadioOptionAdapter.ViewHolder>(RadioOptionDiffer()) {
|
||||||
|
|
||||||
class RadioOptionDiffer: DiffUtil.ItemCallback<RadioOption>() {
|
class RadioOptionDiffer: DiffUtil.ItemCallback<RadioOption>() {
|
||||||
override fun areItemsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem === newItem
|
override fun areItemsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem.title == newItem.title
|
||||||
override fun areContentsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem == newItem
|
override fun areContentsTheSame(oldItem: RadioOption, newItem: RadioOption) = oldItem.value == newItem.value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
@ -31,7 +31,7 @@ class RadioOptionAdapter(
|
|||||||
holder.bind(option, isSelected) {
|
holder.bind(option, isSelected) {
|
||||||
onClickListener(it)
|
onClickListener(it)
|
||||||
selectedOptionPosition = position
|
selectedOptionPosition = position
|
||||||
notifyDataSetChanged()
|
notifyItemRangeChanged(0, itemCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,8 @@ import nl.komponents.kovenant.ui.alwaysUi
|
|||||||
import nl.komponents.kovenant.ui.successUi
|
import nl.komponents.kovenant.ui.successUi
|
||||||
import org.session.libsession.avatars.AvatarHelper
|
import org.session.libsession.avatars.AvatarHelper
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.*
|
||||||
import org.session.libsession.utilities.ProfileKeyUtil
|
|
||||||
import org.session.libsession.utilities.ProfilePictureUtilities
|
|
||||||
import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol
|
import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.avatar.AvatarSelection
|
import org.thoughtcrime.securesms.avatar.AvatarSelection
|
||||||
import org.thoughtcrime.securesms.components.ProfilePictureView
|
import org.thoughtcrime.securesms.components.ProfilePictureView
|
||||||
@ -85,7 +82,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
super.onCreate(savedInstanceState, isReady)
|
super.onCreate(savedInstanceState, isReady)
|
||||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
val displayName = TextSecurePreferences.getProfileName(this) ?: hexEncodedPublicKey
|
val displayName = getDisplayName()
|
||||||
glide = GlideApp.with(this)
|
glide = GlideApp.with(this)
|
||||||
with(binding) {
|
with(binding) {
|
||||||
setupProfilePictureView(profilePictureView.root)
|
setupProfilePictureView(profilePictureView.root)
|
||||||
@ -112,10 +109,13 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDisplayName(): String =
|
||||||
|
TextSecurePreferences.getProfileName(this) ?: truncateIdForDisplay(hexEncodedPublicKey)
|
||||||
|
|
||||||
private fun setupProfilePictureView(view: ProfilePictureView) {
|
private fun setupProfilePictureView(view: ProfilePictureView) {
|
||||||
view.glide = glide
|
view.glide = glide
|
||||||
view.publicKey = hexEncodedPublicKey
|
view.publicKey = hexEncodedPublicKey
|
||||||
view.displayName = TextSecurePreferences.getProfileName(this) ?: hexEncodedPublicKey
|
view.displayName = getDisplayName()
|
||||||
view.isLarge = true
|
view.isLarge = true
|
||||||
view.update()
|
view.update()
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
style="@style/Widget.Session.TabLayout"
|
|
||||||
android:id="@+id/tabLayout"
|
android:id="@+id/tabLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/tab_bar_height" />
|
android:layout_height="@dimen/tab_bar_height" />
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
style="@style/Widget.Session.TabLayout"
|
|
||||||
android:id="@+id/tabLayout"
|
android:id="@+id/tabLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/tab_bar_height" />
|
android:layout_height="@dimen/tab_bar_height" />
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
style="@style/Widget.Session.TabLayout"
|
|
||||||
android:id="@+id/tabLayout"
|
android:id="@+id/tabLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/tab_bar_height" />
|
android:layout_height="@dimen/tab_bar_height" />
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:text="@string/cancel" />
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/unblockButton"
|
android:id="@+id/unblockButton"
|
||||||
android:contentDescription="@string/AccessibilityId_block_confirm"
|
android:contentDescription="@string/AccessibilityId_block_confirm"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
android:text="@string/cancel" />
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/downloadButton"
|
android:id="@+id/downloadButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:text="@string/cancel" />
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/joinButton"
|
android:id="@+id/joinButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
android:contentDescription="@string/AccessibilityId_cancel_link_preview_button"/>
|
android:contentDescription="@string/AccessibilityId_cancel_link_preview_button"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/enableLinkPreviewsButton"
|
android:id="@+id/enableLinkPreviewsButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="?dialog_background_color">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/titleTextView"
|
android:id="@+id/titleTextView"
|
||||||
@ -21,11 +20,10 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/closeButton"
|
android:id="@+id/closeButton"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/medium_spacing"
|
android:layout_marginEnd="@dimen/medium_spacing"
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/ic_baseline_close_24"
|
android:src="@drawable/ic_baseline_close_24"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/titleTextView"
|
app:layout_constraintBottom_toBottomOf="@id/titleTextView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -36,7 +34,6 @@
|
|||||||
android:id="@+id/messageTextView"
|
android:id="@+id/messageTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?dialog_background_color"
|
|
||||||
android:drawablePadding="@dimen/large_spacing"
|
android:drawablePadding="@dimen/large_spacing"
|
||||||
android:gravity="center_horizontal|center_vertical"
|
android:gravity="center_horizontal|center_vertical"
|
||||||
android:paddingHorizontal="@dimen/large_spacing"
|
android:paddingHorizontal="@dimen/large_spacing"
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:text="@string/cancel" />
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/openURLButton"
|
android:id="@+id/openURLButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:text="@string/cancel" />
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Destructive"
|
style="@style/Widget.Session.Button.Dialog.DestructiveText"
|
||||||
android:id="@+id/sendSeedButton"
|
android:id="@+id/sendSeedButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
@ -41,7 +41,7 @@
|
|||||||
android:text="@string/cancel" />
|
android:text="@string/cancel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Dialog.Unimportant"
|
style="@style/Widget.Session.Button.Dialog.UnimportantText"
|
||||||
android:id="@+id/shareButton"
|
android:id="@+id/shareButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/small_button_height"
|
android:layout_height="@dimen/small_button_height"
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tabLayout"
|
android:id="@+id/tabLayout"
|
||||||
style="@style/Widget.Session.TabLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/tab_bar_height"
|
android:layout_height="@dimen/tab_bar_height"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tabLayout"
|
android:id="@+id/tabLayout"
|
||||||
style="@style/Widget.Session.TabLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/tab_bar_height"
|
android:layout_height="@dimen/tab_bar_height"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
android:text="@string/fragment_view_my_qr_code_explanation" />
|
android:text="@string/fragment_view_my_qr_code_explanation" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Session.Button.Common.UnimportantOutline"
|
style="@style/Widget.Session.Button.Common.ProminentOutline"
|
||||||
android:id="@+id/shareButton"
|
android:id="@+id/shareButton"
|
||||||
android:layout_width="196dp"
|
android:layout_width="196dp"
|
||||||
android:layout_height="@dimen/medium_button_height"
|
android:layout_height="@dimen/medium_button_height"
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
android:id="@+id/tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/Widget.Session.TabLayout"
|
|
||||||
app:tabRippleColor="@color/cell_selected"
|
app:tabRippleColor="@color/cell_selected"
|
||||||
app:tabIndicatorColor="?colorAccent"
|
app:tabIndicatorColor="?colorAccent"
|
||||||
android:scrollbars="horizontal"/>
|
android:scrollbars="horizontal"/>
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
<org.thoughtcrime.securesms.components.ControllableTabLayout
|
<org.thoughtcrime.securesms.components.ControllableTabLayout
|
||||||
android:id="@+id/tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
style="@style/Widget.Session.TabLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"/>
|
android:layout_gravity="top"/>
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
<item name="elevation">1dp</item>
|
<item name="elevation">1dp</item>
|
||||||
<item name="tabIndicatorColor">@color/transparent</item>
|
<item name="tabIndicatorColor">@color/transparent</item>
|
||||||
<item name="tabIndicatorHeight">@dimen/accent_line_thickness</item>
|
<item name="tabIndicatorHeight">@dimen/accent_line_thickness</item>
|
||||||
<item name="tabRippleColor">@color/cell_selected</item>
|
|
||||||
<item name="tabTextAppearance">@style/TextAppearance.Session.Tab</item>
|
<item name="tabTextAppearance">@style/TextAppearance.Session.Tab</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -123,19 +122,10 @@
|
|||||||
<item name="android:textColor">?android:textColorPrimary</item>
|
<item name="android:textColor">?android:textColorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.Session.Button.Dialog.Unimportant">
|
|
||||||
<item name="android:background">@drawable/unimportant_dialog_button_background</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Widget.Session.Button.Dialog.UnimportantText">
|
<style name="Widget.Session.Button.Dialog.UnimportantText">
|
||||||
<item name="android:background">@drawable/unimportant_dialog_text_button_background</item>
|
<item name="android:background">@drawable/unimportant_dialog_text_button_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.Session.Button.Dialog.Destructive">
|
|
||||||
<item name="android:background">@drawable/destructive_dialog_button_background</item>
|
|
||||||
<item name="android:textColor">@color/black</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Widget.Session.Button.Dialog.DestructiveText">
|
<style name="Widget.Session.Button.Dialog.DestructiveText">
|
||||||
<item name="android:background">@drawable/destructive_dialog_text_button_background</item>
|
<item name="android:background">@drawable/destructive_dialog_text_button_background</item>
|
||||||
<item name="android:textColor">@color/destructive</item>
|
<item name="android:textColor">@color/destructive</item>
|
||||||
|
@ -303,6 +303,8 @@
|
|||||||
<item name="dividerHorizontal">?dividerVertical</item>
|
<item name="dividerHorizontal">?dividerVertical</item>
|
||||||
<item name="message_received_background_color">#F2F2F2</item>
|
<item name="message_received_background_color">#F2F2F2</item>
|
||||||
<item name="colorAccent">@color/classic_accent</item>
|
<item name="colorAccent">@color/classic_accent</item>
|
||||||
|
<item name="colorControlHighlight">?android:colorControlHighlight</item>
|
||||||
|
<item name="tabStyle">@style/Widget.Session.TabLayout</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Ocean">
|
<style name="Ocean">
|
||||||
@ -310,6 +312,8 @@
|
|||||||
<item name="dividerHorizontal">?dividerVertical</item>
|
<item name="dividerHorizontal">?dividerVertical</item>
|
||||||
<item name="message_received_background_color">#F2F2F2</item>
|
<item name="message_received_background_color">#F2F2F2</item>
|
||||||
<item name="colorAccent">@color/ocean_accent</item>
|
<item name="colorAccent">@color/ocean_accent</item>
|
||||||
|
<item name="colorControlHighlight">?android:colorControlHighlight</item>
|
||||||
|
<item name="tabStyle">@style/Widget.Session.TabLayout</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Classic.Dark">
|
<style name="Classic.Dark">
|
||||||
|
@ -7,16 +7,17 @@ import org.session.libsession.messaging.calls.CallMessageType
|
|||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
||||||
import org.session.libsession.utilities.ExpirationUtil
|
import org.session.libsession.utilities.ExpirationUtil
|
||||||
|
import org.session.libsession.utilities.truncateIdForDisplay
|
||||||
|
|
||||||
object UpdateMessageBuilder {
|
object UpdateMessageBuilder {
|
||||||
|
|
||||||
fun buildGroupUpdateMessage(context: Context, updateMessageData: UpdateMessageData, sender: String? = null, isOutgoing: Boolean = false): String {
|
fun buildGroupUpdateMessage(context: Context, updateMessageData: UpdateMessageData, senderId: String? = null, isOutgoing: Boolean = false): String {
|
||||||
var message = ""
|
var message = ""
|
||||||
val updateData = updateMessageData.kind ?: return message
|
val updateData = updateMessageData.kind ?: return message
|
||||||
if (!isOutgoing && sender == null) return message
|
if (!isOutgoing && senderId == null) return message
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val senderName: String = if (!isOutgoing) {
|
val senderName: String = if (!isOutgoing) {
|
||||||
storage.getContactWithSessionID(sender!!)?.displayName(Contact.ContactContext.REGULAR) ?: sender
|
storage.getContactWithSessionID(senderId!!)?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId)
|
||||||
} else { context.getString(R.string.MessageRecord_you) }
|
} else { context.getString(R.string.MessageRecord_you) }
|
||||||
|
|
||||||
when (updateData) {
|
when (updateData) {
|
||||||
@ -78,11 +79,11 @@ object UpdateMessageBuilder {
|
|||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
fun buildExpirationTimerMessage(context: Context, duration: Long, sender: String? = null, isOutgoing: Boolean = false): String {
|
fun buildExpirationTimerMessage(context: Context, duration: Long, senderId: String? = null, isOutgoing: Boolean = false): String {
|
||||||
if (!isOutgoing && sender == null) return ""
|
if (!isOutgoing && senderId == null) return ""
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val senderName: String? = if (!isOutgoing) {
|
val senderName: String? = if (!isOutgoing) {
|
||||||
storage.getContactWithSessionID(sender!!)?.displayName(Contact.ContactContext.REGULAR) ?: sender
|
storage.getContactWithSessionID(senderId!!)?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId)
|
||||||
} else { context.getString(R.string.MessageRecord_you) }
|
} else { context.getString(R.string.MessageRecord_you) }
|
||||||
return if (duration <= 0) {
|
return if (duration <= 0) {
|
||||||
if (isOutgoing) context.getString(R.string.MessageRecord_you_disabled_disappearing_messages)
|
if (isOutgoing) context.getString(R.string.MessageRecord_you_disabled_disappearing_messages)
|
||||||
@ -94,9 +95,9 @@ object UpdateMessageBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun buildDataExtractionMessage(context: Context, kind: DataExtractionNotificationInfoMessage.Kind, sender: String? = null): String {
|
fun buildDataExtractionMessage(context: Context, kind: DataExtractionNotificationInfoMessage.Kind, senderId: String? = null): String {
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val senderName = storage.getContactWithSessionID(sender!!)?.displayName(Contact.ContactContext.REGULAR) ?: sender!!
|
val senderName = storage.getContactWithSessionID(senderId!!)?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId)
|
||||||
return when (kind) {
|
return when (kind) {
|
||||||
DataExtractionNotificationInfoMessage.Kind.SCREENSHOT ->
|
DataExtractionNotificationInfoMessage.Kind.SCREENSHOT ->
|
||||||
context.getString(R.string.MessageRecord_s_took_a_screenshot, senderName)
|
context.getString(R.string.MessageRecord_s_took_a_screenshot, senderName)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package org.session.libsession.utilities
|
||||||
|
|
||||||
|
fun truncateIdForDisplay(id: String): String =
|
||||||
|
id.takeIf { it.length > 8 }?.apply{ "${take(4)}…${takeLast(4)}" } ?: id
|
@ -17,7 +17,4 @@ fun Context.getColorFromAttr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val RecyclerView.isScrolledToBottom: Boolean
|
val RecyclerView.isScrolledToBottom: Boolean
|
||||||
get() {
|
get() = computeVerticalScrollOffset() + computeVerticalScrollExtent() >= computeVerticalScrollRange()
|
||||||
val contentHeight = height - (paddingTop + paddingBottom)
|
|
||||||
return computeVerticalScrollRange() == computeVerticalScrollOffset() + contentHeight
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user