theme progress bars and remainign alert dialogs

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-10 23:27:03 +02:00
parent b4530a2e85
commit 2332c3568c
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
20 changed files with 137 additions and 62 deletions

View file

@ -96,6 +96,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
updateDownloadState(message)
binding.seekbar.max = message.voiceMessageDuration
viewThemeUtils.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
if (message.isPlayingVoiceMessage) {
showPlayButton()

View file

@ -97,6 +97,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
updateDownloadState(message)
binding.seekbar.max = message.voiceMessageDuration
viewThemeUtils.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
handleIsPlayingVoiceMessageState(message)

View file

@ -231,6 +231,8 @@ class ConversationInfoController(args: Bundle) :
}
binding.addParticipantsAction.visibility = View.GONE
viewThemeUtils.colorCircularProgressBar(binding.progressBar)
}
private fun setupWebinaryView() {

View file

@ -957,13 +957,16 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
})
phoneNumberInputLayout.addView(phoneNumberField)
phoneNumberLayoutWrapper.addView(phoneNumberInputLayout)
val dialog = AlertDialog.Builder((activity)!!)
val dialogBuilder = MaterialAlertDialogBuilder(phoneNumberInputLayout.context)
.setTitle(R.string.nc_settings_phone_book_integration_phone_number_dialog_title)
.setMessage(R.string.nc_settings_phone_book_integration_phone_number_dialog_description)
.setView(phoneNumberLayoutWrapper)
.setPositiveButton(context!!.resources.getString(R.string.nc_common_set), null)
.setNegativeButton(context!!.resources.getString(R.string.nc_common_skip), null)
.create()
viewThemeUtils.colorMaterialAlertDialogBackground(phoneNumberInputLayout.context, dialogBuilder)
val dialog = dialogBuilder.create()
dialog.setOnShowListener(object : OnShowListener {
override fun onShow(dialogInterface: DialogInterface) {
val button = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
@ -974,7 +977,13 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
})
}
})
dialog.show()
viewThemeUtils.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
)
}
private fun setPhoneNumber(textInputLayout: TextInputLayout, dialog: AlertDialog) {

View file

@ -117,6 +117,8 @@ class OperationsMenuController(args: Bundle) : NewBaseController(
sharedApplication!!.componentApplication.inject(this)
currentUser = userManager.currentUser.blockingGet()
viewThemeUtils.colorCircularProgressBar(binding.progressBar)
if (!TextUtils.isEmpty(callUrl) && callUrl.contains("/call")) {
conversationToken = callUrl.substring(callUrl.lastIndexOf("/") + 1)
if (callUrl.contains("/index.php")) {

View file

@ -50,7 +50,7 @@ class PollCreateOptionViewHolder(
}
binding.pollOptionTextEdit.setText(pollCreateOptionItem.pollOption)
viewThemeUtils.colorEditText(binding.pollOptionTextEdit)
viewThemeUtils.colorTextInputLayout(binding.pollOptionTextInputLayout)
if (focus) {
itemsListener.requestFocus(binding.pollOptionTextEdit)

View file

@ -41,6 +41,9 @@ class PollResultHeaderViewHolder(
binding.pollOptionText.text = item.name
binding.pollOptionPercentText.text = "${item.percent}%"
viewThemeUtils.colorDialogSupportingText(binding.pollOptionText)
viewThemeUtils.colorDialogSupportingText(binding.pollOptionPercentText)
if (item.selfVoted) {
binding.pollOptionText.setTypeface(null, Typeface.BOLD)
binding.pollOptionPercentText.setTypeface(null, Typeface.BOLD)

View file

@ -29,12 +29,14 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.PollResultVoterItemBinding
import com.nextcloud.talk.polls.model.PollDetails
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DisplayUtils
class PollResultVoterViewHolder(
private val user: User,
override val binding: PollResultVoterItemBinding
override val binding: PollResultVoterItemBinding,
private val viewThemeUtils: ViewThemeUtils
) : PollResultViewHolder(binding) {
@SuppressLint("SetTextI18n")
@ -45,6 +47,7 @@ class PollResultVoterViewHolder(
binding.pollVoterName.text = item.details.actorDisplayName
binding.pollVoterAvatar.controller = getAvatarDraweeController(item.details)
viewThemeUtils.colorDialogSupportingText(binding.pollVoterName)
}
private fun getAvatarDraweeController(pollDetail: PollDetails): DraweeController? {

View file

@ -52,7 +52,7 @@ class PollResultsAdapter(
LayoutInflater.from(parent.context), parent,
false
)
viewHolder = PollResultVoterViewHolder(user, itemBinding)
viewHolder = PollResultVoterViewHolder(user, itemBinding, viewThemeUtils)
}
PollResultVotersOverviewItem.VIEW_TYPE -> {
val itemBinding = PollResultVotersOverviewItemBinding.inflate(

View file

@ -31,11 +31,11 @@ import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import autodagger.AutoInjector
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.DialogPollCreateBinding
@ -73,9 +73,11 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = DialogPollCreateBinding.inflate(LayoutInflater.from(context))
return AlertDialog.Builder(requireContext())
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context)
.setView(binding.root)
.create()
viewThemeUtils.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
return dialogBuilder.create()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
@ -103,10 +105,9 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
viewThemeUtils.colorPrimaryTextViewElement(binding.pollOptions)
viewThemeUtils.colorPrimaryTextViewElement(binding.pollSettings)
viewThemeUtils.colorEditText(binding.pollCreateQuestionTextEdit)
viewThemeUtils.colorTextInputLayout(binding.pollCreateQuestionTextInputLayout)
viewThemeUtils.colorMaterialButtonText(binding.pollAddOptionsItem)
// TODO button also needs a disabled state handling for colors
viewThemeUtils.colorMaterialButtonText(binding.pollDismiss)
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollCreateButton)

View file

@ -29,12 +29,17 @@ import androidx.fragment.app.Fragment
import autodagger.AutoInjector
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.DialogPollLoadingBinding
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class PollLoadingFragment : Fragment() {
private lateinit var binding: DialogPollLoadingBinding
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
var fragmentHeight = 0
override fun onCreate(savedInstanceState: Bundle?) {
@ -50,6 +55,7 @@ class PollLoadingFragment : Fragment() {
): View {
binding = DialogPollLoadingBinding.inflate(inflater, container, false)
binding.root.layoutParams.height = fragmentHeight
viewThemeUtils.colorCircularProgressBar(binding.pollLoadingProgressbar)
return binding.root
}

View file

@ -26,16 +26,17 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.ViewModelProvider
import autodagger.AutoInjector
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.DialogPollMainBinding
import com.nextcloud.talk.polls.viewmodels.PollMainViewModel
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
@ -44,6 +45,9 @@ class PollMainDialogFragment : DialogFragment() {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var binding: DialogPollMainBinding
private lateinit var viewModel: PollMainViewModel
@ -66,11 +70,15 @@ class PollMainDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = DialogPollMainBinding.inflate(LayoutInflater.from(context))
val dialog = AlertDialog.Builder(requireContext())
.setView(binding.root)
.create()
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root)
viewThemeUtils.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
val dialog = dialogBuilder.create()
binding.messagePollTitle.text = viewModel.pollTitle
viewThemeUtils.colorDialogHeadline(binding.messagePollTitle)
viewThemeUtils.colorDialogIcon(binding.messagePollIcon)
return dialog
}
@ -135,6 +143,7 @@ class PollMainDialogFragment : DialogFragment() {
private fun initVotersAmount(showVotersAmount: Boolean, numVoters: Int, showResultSubtitle: Boolean) {
if (showVotersAmount) {
viewThemeUtils.colorDialogSupportingText(binding.pollVotesAmount)
binding.pollVotesAmount.visibility = View.VISIBLE
binding.pollVotesAmount.text = resources.getQuantityString(
R.plurals.polls_amount_voters,
@ -146,6 +155,7 @@ class PollMainDialogFragment : DialogFragment() {
}
if (showResultSubtitle) {
viewThemeUtils.colorDialogSupportingText(binding.pollResultsSubtitle)
binding.pollResultsSubtitle.visibility = View.VISIBLE
binding.pollResultsSubtitleSeperator.visibility = View.VISIBLE
} else {

View file

@ -31,6 +31,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import autodagger.AutoInjector
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.DialogPollResultsBinding
@ -123,14 +124,25 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
if (showEndPollButton) {
binding.pollResultsEndPollButton.visibility = View.VISIBLE
binding.pollResultsEndPollButton.setOnClickListener {
AlertDialog.Builder(requireContext())
val dialogBuilder = MaterialAlertDialogBuilder(binding.pollResultsEndPollButton.context)
.setTitle(R.string.polls_end_poll)
.setMessage(R.string.polls_end_poll_confirm)
.setPositiveButton(R.string.polls_end_poll) { _, _ ->
parentViewModel.endPoll()
}
.setNegativeButton(R.string.nc_cancel, null)
.show()
viewThemeUtils.colorMaterialAlertDialogBackground(
binding.pollResultsEndPollButton.context,
dialogBuilder
)
val dialog = dialogBuilder.show()
viewThemeUtils.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
)
}
} else {
binding.pollResultsEndPollButton.visibility = View.GONE

View file

@ -37,6 +37,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import autodagger.AutoInjector
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.DialogPollVoteBinding
@ -206,14 +207,25 @@ class PollVoteFragment : Fragment() {
if (showEndPollButton) {
binding.pollVoteEndPollButton.visibility = View.VISIBLE
binding.pollVoteEndPollButton.setOnClickListener {
AlertDialog.Builder(requireContext())
val dialogBuilder = MaterialAlertDialogBuilder(binding.pollVoteEndPollButton.context)
.setTitle(R.string.polls_end_poll)
.setMessage(R.string.polls_end_poll_confirm)
.setPositiveButton(R.string.polls_end_poll) { _, _ ->
parentViewModel.endPoll()
}
.setNegativeButton(R.string.nc_cancel, null)
.show()
viewThemeUtils.colorMaterialAlertDialogBackground(
binding.pollVoteEndPollButton.context,
dialogBuilder
)
val dialog = dialogBuilder.show()
viewThemeUtils.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
)
}
} else {
binding.pollVoteEndPollButton.visibility = View.GONE

View file

@ -36,13 +36,13 @@ import android.widget.AdapterView.OnItemSelectedListener
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.LinearLayoutManager
import autodagger.AutoInjector
import com.bluelinelabs.logansquare.LoganSquare
import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.R
import com.nextcloud.talk.adapters.PredefinedStatusClickListener
import com.nextcloud.talk.adapters.PredefinedStatusListAdapter
@ -166,9 +166,10 @@ class SetStatusDialogFragment :
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = DialogSetStatusBinding.inflate(LayoutInflater.from(context))
return AlertDialog.Builder(requireContext())
.setView(binding.root)
.create()
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root)
viewThemeUtils.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
return dialogBuilder.create()
}
@SuppressLint("DefaultLocale")

View file

@ -498,6 +498,12 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
}
fun colorCircularProgressBarOnSurfaceVariant(progressBar: ProgressBar) {
withScheme(progressBar) { scheme ->
progressBar.indeterminateDrawable.setColorFilter(scheme.onSurfaceVariant, PorterDuff.Mode.SRC_ATOP)
}
}
// TODO split this util into classes depending on framework views vs library views
fun colorPreferenceCategory(category: MaterialPreferenceCategory) {
withScheme(category) { scheme ->
@ -782,6 +788,24 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
}
fun colorDialogHeadline(textView: TextView) {
withScheme(textView) { scheme ->
textView.setTextColor(scheme.onSurface)
}
}
fun colorDialogSupportingText(textView: TextView) {
withScheme(textView) { scheme ->
textView.setTextColor(scheme.onSurfaceVariant)
}
}
fun colorDialogIcon(icon: ImageView) {
withScheme(icon) { scheme ->
icon.setColorFilter(scheme.secondary)
}
}
companion object {
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
R.drawable.ic_mimetype_package_x_generic,

View file

@ -28,22 +28,30 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import androidx.appcompat.app.AlertDialog;
import autodagger.AutoInjector;
import android.widget.TextView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.nextcloud.talk.R;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
import com.yarolegovich.mp.io.StandardUserInputModule;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import autodagger.AutoInjector;
@AutoInjector(NextcloudTalkApplication.class)
public class MagicUserInputModule extends StandardUserInputModule {
@Inject
AppPreferences appPreferences;
@Inject
ViewThemeUtils viewThemeUtils;
private List<String> keysWithIntegerInput = new ArrayList<>();
public MagicUserInputModule(Context context) {
@ -65,6 +73,11 @@ public class MagicUserInputModule extends StandardUserInputModule {
final Listener<String> listener) {
final View view = LayoutInflater.from(context).inflate(R.layout.dialog_edittext, null);
final EditText inputField = view.findViewById(R.id.mp_text_input);
viewThemeUtils.colorEditText(inputField);
int paddingStartEnd = Math.round(view.getResources().getDimension(R.dimen.standard_padding));
int paddingTopBottom = Math.round(view.getResources().getDimension(R.dimen.dialog_padding_top_bottom));
view.setPadding(paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.getIsKeyboardIncognito()) {
inputField.setImeOptions(inputField.getImeOptions() | EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING);
@ -79,11 +92,17 @@ public class MagicUserInputModule extends StandardUserInputModule {
inputField.setInputType(InputType.TYPE_CLASS_NUMBER);
}
final Dialog dialog = new AlertDialog.Builder(context)
.setTitle(title)
.setView(view)
.show();
view.findViewById(R.id.mp_btn_confirm).setOnClickListener(new View.OnClickListener() {
final MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(view.getContext())
.setTitle(title)
.setView(view);
viewThemeUtils.colorMaterialAlertDialogBackground(view.getContext(), dialogBuilder);
final Dialog dialog = dialogBuilder.show();
TextView button = view.findViewById(R.id.mp_btn_confirm);
viewThemeUtils.colorPrimaryTextViewElement(button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onInput(inputField.getText().toString());

View file

@ -115,17 +115,6 @@
app:iconSize="@dimen/avatar_size_app_bar"
tools:visibility="gone" />
<ProgressBar
android:id="@+id/searchProgressBar"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="4dp"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateTint="@color/colorPrimary"
android:scaleType="fitCenter"
android:visibility="gone" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@ -144,16 +133,6 @@
app:titleTextColor="@color/fontAppbar"
tools:title="@string/nc_app_product_name">
<ProgressBar
android:id="@+id/toolbarProgressBar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="8dp"
android:visibility="gone"
android:indeterminateTint="@color/white"
android:scaleType="fitCenter" />
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>

View file

@ -26,6 +26,7 @@
tools:background="@color/white">
<ProgressBar
android:id="@+id/poll_loading_progressbar"
android:layout_width="25dp"
android:layout_height="25dp">
</ProgressBar>

View file

@ -104,17 +104,6 @@
app:iconSize="@dimen/avatar_size_app_bar"
tools:visibility="visible" />
<ProgressBar
android:id="@+id/searchProgressBar"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="4dp"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateTint="@color/colorPrimary"
android:scaleType="fitCenter"
android:visibility="gone" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>