kopia lustrzana https://github.com/ryukoposting/Signal-Android
Update new story button.
rodzic
f533219bad
commit
43caec69e3
|
@ -96,7 +96,7 @@ object Stories {
|
|||
|
||||
fun getHeaderAction(onClick: () -> Unit): HeaderAction {
|
||||
return HeaderAction(
|
||||
R.string.ContactsCursorLoader_new_story,
|
||||
R.string.ContactsCursorLoader_add_to,
|
||||
R.drawable.ic_plus_12,
|
||||
onClick
|
||||
)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.thoughtcrime.securesms.stories.settings.story
|
||||
|
||||
import org.thoughtcrime.securesms.databinding.NewStoryItemBinding
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.BindingFactory
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.BindingViewHolder
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel
|
||||
|
||||
/**
|
||||
* Entry point for new story creation.
|
||||
*/
|
||||
object NewStoryItem {
|
||||
fun register(mappingAdapter: MappingAdapter) {
|
||||
mappingAdapter.registerFactory(Model::class.java, BindingFactory(::ViewHolder, NewStoryItemBinding::inflate))
|
||||
}
|
||||
|
||||
class Model(val onClick: () -> Unit) : MappingModel<Model> {
|
||||
override fun areItemsTheSame(newItem: Model) = true
|
||||
override fun areContentsTheSame(newItem: Model) = true
|
||||
}
|
||||
|
||||
private class ViewHolder(binding: NewStoryItemBinding) : BindingViewHolder<Model, NewStoryItemBinding>(binding) {
|
||||
override fun bind(model: Model) {
|
||||
binding.root.setOnClickListener {
|
||||
model.onClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,7 +69,8 @@ class StoriesPrivacySettingsFragment :
|
|||
}
|
||||
}
|
||||
)
|
||||
ContactSearchItems.registerHeaders(middle)
|
||||
|
||||
NewStoryItem.register(top as MappingAdapter)
|
||||
|
||||
middle.setPagingController(viewModel.pagingController)
|
||||
|
||||
|
@ -82,10 +83,6 @@ class StoriesPrivacySettingsFragment :
|
|||
viewModel.pagingController.onDataInvalidated()
|
||||
}
|
||||
|
||||
lifecycleDisposable += viewModel.headerActionRequests.subscribe {
|
||||
ChooseStoryTypeBottomSheet().show(childFragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
|
||||
}
|
||||
|
||||
lifecycleDisposable += viewModel.state.subscribe { state ->
|
||||
if (state.isUpdatingEnabledState) {
|
||||
progressDisplayManager.show(viewLifecycleOwner, childFragmentManager)
|
||||
|
@ -93,7 +90,7 @@ class StoriesPrivacySettingsFragment :
|
|||
progressDisplayManager.hide()
|
||||
}
|
||||
|
||||
(top as MappingAdapter).submitList(getTopConfiguration(state).toMappingModelList())
|
||||
top.submitList(getTopConfiguration(state).toMappingModelList())
|
||||
middle.submitList(getMiddleConfiguration(state).toMappingModelList())
|
||||
(bottom as MappingAdapter).submitList(getBottomConfiguration(state).toMappingModelList())
|
||||
}
|
||||
|
@ -113,6 +110,14 @@ class StoriesPrivacySettingsFragment :
|
|||
)
|
||||
|
||||
space(20.dp)
|
||||
|
||||
sectionHeaderPref(R.string.StoriesPrivacySettingsFragment__stories)
|
||||
|
||||
customPref(
|
||||
NewStoryItem.Model {
|
||||
ChooseStoryTypeBottomSheet().show(childFragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.StoriesPrivacySettingsFragment__turn_on_stories),
|
||||
|
|
|
@ -4,10 +4,8 @@ import androidx.lifecycle.ViewModel
|
|||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||
import org.signal.paging.PagedData
|
||||
import org.signal.paging.PagingConfig
|
||||
import org.signal.paging.ProxyPagingController
|
||||
|
@ -17,7 +15,6 @@ import org.thoughtcrime.securesms.contacts.paged.ContactSearchPagedDataSource
|
|||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class StoriesPrivacySettingsViewModel : ViewModel() {
|
||||
|
||||
|
@ -36,21 +33,16 @@ class StoriesPrivacySettingsViewModel : ViewModel() {
|
|||
.build()
|
||||
|
||||
private val disposables = CompositeDisposable()
|
||||
private val headerActionRequestSubject = PublishSubject.create<Unit>()
|
||||
|
||||
val state: Flowable<StoriesPrivacySettingsState> = store.stateFlowable.observeOn(AndroidSchedulers.mainThread())
|
||||
val userHasActiveStories: Boolean get() = store.state.userHasStories
|
||||
val pagingController = ProxyPagingController<ContactSearchKey>()
|
||||
val headerActionRequests: Observable<Unit> = headerActionRequestSubject.debounce(100, TimeUnit.MILLISECONDS)
|
||||
|
||||
init {
|
||||
val configuration = ContactSearchConfiguration.build {
|
||||
addSection(
|
||||
ContactSearchConfiguration.Section.Stories(
|
||||
includeHeader = true,
|
||||
headerAction = Stories.getHeaderAction {
|
||||
headerActionRequestSubject.onNext(Unit)
|
||||
}
|
||||
includeHeader = false,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:minHeight="64dp"
|
||||
android:paddingHorizontal="@dimen/dsl_settings_gutter">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@color/signal_colorSurfaceVariant"
|
||||
android:scaleType="centerInside"
|
||||
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Signal.Circle"
|
||||
app:srcCompat="@drawable/ic_plus_20"
|
||||
app:tint="@color/signal_colorOnSurfaceVariant" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/NewStoryItem__new_story"
|
||||
android:textAppearance="@style/Signal.Text.BodyLarge" />
|
||||
|
||||
</LinearLayout>
|
|
@ -220,7 +220,7 @@
|
|||
<!-- Label for my stories when selecting who to send media to -->
|
||||
<string name="ContactsCursorLoader_my_stories">My Stories</string>
|
||||
<!-- Action for creating a new story -->
|
||||
<string name="ContactsCursorLoader_new_story">New story</string>
|
||||
<string name="ContactsCursorLoader_add_to">Add to…</string>
|
||||
|
||||
<!-- ContactsDatabase -->
|
||||
<string name="ContactsDatabase_message_s">Message %s</string>
|
||||
|
@ -5269,6 +5269,11 @@
|
|||
<string name="StoriesPrivacySettingsFragment__you_will_no_longer_be_able_to_share">You will no longer be able to share or view stories. Story updates you have recently shared will also be deleted.</string>
|
||||
<!-- Page title when launched from stories landing screen -->
|
||||
<string name="StoriesPrivacySettingsFragment__story_privacy">Story privacy</string>
|
||||
<!-- Header for section that lists out stories -->
|
||||
<string name="StoriesPrivacySettingsFragment__stories">Stories</string>
|
||||
|
||||
<!-- NewStoryItem -->
|
||||
<string name="NewStoryItem__new_story">New story</string>
|
||||
|
||||
<!-- GroupStorySettingsFragment -->
|
||||
<!-- Section header for who can view a group story -->
|
||||
|
|
Ładowanie…
Reference in New Issue