From 536098bf0bcd74b6fa1dba0ecc962a6fea730c57 Mon Sep 17 00:00:00 2001 From: archroid Date: Fri, 20 May 2022 14:50:36 +0430 Subject: [PATCH] Updated some dialogs to md3 --- .../com/github/libretube/AddtoPlaylistDialog.kt | 14 +++++++++++++- .../github/libretube/CreatePlaylistDialog.kt | 12 ++++++++++++ .../java/com/github/libretube/DownloadDialog.kt | 15 ++++++++++++++- .../java/com/github/libretube/LoginDialog.kt | 16 +++++++++++++++- .../com/github/libretube/SettingsActivity.kt | 2 ++ .../main/res/layout/dialog_addtoplaylist.xml | 16 ++++++++++------ .../main/res/layout/dialog_create_playlist.xml | 17 ++++++++++------- app/src/main/res/layout/dialog_download.xml | 14 ++++++++------ app/src/main/res/layout/dialog_login.xml | 16 ++++++++++------ app/src/main/res/layout/dialog_logout.xml | 15 +++++++++------ 10 files changed, 103 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt b/app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt index b852d979c..693d88032 100644 --- a/app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/AddtoPlaylistDialog.kt @@ -4,14 +4,17 @@ import android.app.Dialog import android.content.Context import android.os.Bundle import android.util.Log +import android.util.TypedValue import android.view.View import android.widget.* import androidx.appcompat.app.AlertDialog +import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import com.github.libretube.adapters.PlaylistsAdapter import com.github.libretube.obj.PlaylistId +import com.google.android.material.dialog.MaterialAlertDialogBuilder import retrofit2.HttpException import java.io.IOException @@ -24,7 +27,7 @@ class AddtoPlaylistDialog : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return activity?.let { videoId = arguments?.getString("videoId")!! - val builder = AlertDialog.Builder(it) + val builder = MaterialAlertDialogBuilder(it) // Get the layout inflater val inflater = requireActivity().layoutInflater; val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) @@ -35,6 +38,15 @@ class AddtoPlaylistDialog : DialogFragment() { if(token!=""){ fetchPlaylists() } + val typedValue = TypedValue() + this.requireActivity().theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true) + val hexColor = String.format("#%06X", (0xFFFFFF and typedValue.data)) + val appName = HtmlCompat.fromHtml( + "LibreTube", + HtmlCompat.FROM_HTML_MODE_COMPACT + ) + view.findViewById(R.id.title).text = appName + builder.setView(view) builder.create() } ?: throw IllegalStateException("Activity cannot be null") diff --git a/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt index 1bbcc9d32..5aabdadb1 100644 --- a/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt @@ -1,12 +1,15 @@ package com.github.libretube import android.os.Bundle +import android.util.TypedValue import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button +import android.widget.TextView import android.widget.Toast import androidx.core.os.bundleOf +import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.setFragmentResult @@ -18,6 +21,15 @@ class CreatePlaylistDialog : DialogFragment() { ): View? { var rootView: View = inflater.inflate(R.layout.dialog_create_playlist, container, false) + val typedValue = TypedValue() + this.requireActivity().theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true) + val hexColor = String.format("#%06X", (0xFFFFFF and typedValue.data)) + val appName = HtmlCompat.fromHtml( + "LibreTube", + HtmlCompat.FROM_HTML_MODE_COMPACT + ) + rootView.findViewById(R.id.title).text = appName + val cancelBtn = rootView.findViewById