Update: Almost Full Rewrite of theme

This commit is contained in:
LooKeR
2021-10-16 18:57:01 +05:30
parent ac79953c7c
commit 524b804336
21 changed files with 86 additions and 94 deletions

View File

@ -1,6 +1,5 @@
package com.looker.droidify.screen
import android.app.AlertDialog
import android.content.ClipboardManager
import android.content.Context
import android.graphics.PorterDuff
@ -18,8 +17,10 @@ import android.view.ViewGroup
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.looker.droidify.R
import com.looker.droidify.database.Database
import com.looker.droidify.entity.Repository
@ -474,7 +475,7 @@ class EditRepositoryFragment() : ScreenFragment() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe { result, throwable ->
checkDisposable = null
throwable?.printStackTrace()
throwable.printStackTrace()
val resultAddress =
result?.let { if (it.isEmpty()) null else it } ?: address
val allow = resultAddress == address || run {
@ -544,7 +545,7 @@ class EditRepositoryFragment() : ScreenFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): AlertDialog {
val mirrors = requireArguments().getStringArrayList(EXTRA_MIRRORS)!!
return AlertDialog.Builder(requireContext())
return MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.select_mirror)
.setItems(mirrors.toTypedArray()) { _, position ->
(parentFragment as EditRepositoryFragment)

View File

@ -1,13 +1,14 @@
package com.looker.droidify.screen
import android.app.AlertDialog
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Parcel
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.looker.droidify.R
import com.looker.droidify.entity.Release
import com.looker.droidify.utility.KParcelable
@ -139,7 +140,7 @@ class MessageDialog() : DialogFragment() {
}
override fun onCreateDialog(savedInstanceState: Bundle?): AlertDialog {
val dialog = AlertDialog.Builder(requireContext())
val dialog = MaterialAlertDialogBuilder(requireContext())
when (val message = requireArguments().getParcelable<Message>(EXTRA_MESSAGE)!!) {
is Message.DeleteRepositoryConfirm -> {
dialog.setTitle(R.string.confirmation)

View File

@ -1,6 +1,5 @@
package com.looker.droidify.screen
import android.app.AlertDialog
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Intent
@ -13,11 +12,13 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.looker.droidify.R
import com.looker.droidify.content.ProductPreferences
import com.looker.droidify.database.Database
@ -554,7 +555,7 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
override fun onCreateDialog(savedInstanceState: Bundle?): AlertDialog {
val names = requireArguments().getStringArrayList(EXTRA_NAMES)!!
val labels = requireArguments().getStringArrayList(EXTRA_LABELS)!!
return AlertDialog.Builder(requireContext())
return MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.launch)
.setItems(labels.toTypedArray()) { _, position ->
(parentFragment as ProductFragment)

View File

@ -1,6 +1,5 @@
package com.looker.droidify.screen
import android.app.AlertDialog
import android.app.Dialog
import android.content.Context
import android.content.Intent
@ -12,10 +11,12 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar
import androidx.core.net.toUri
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.switchmaterial.SwitchMaterial
import com.looker.droidify.BuildConfig
import com.looker.droidify.R
@ -24,7 +25,6 @@ import com.looker.droidify.utility.extension.resources.*
import com.topjohnwu.superuser.Shell
import io.reactivex.rxjava3.disposables.Disposable
class SettingsFragment : ScreenFragment() {
private val preferences = mutableMapOf<Preferences.Key<*>, Preference<*>>()
private var disposable: Disposable? = null
@ -253,7 +253,7 @@ class SettingsFragment : ScreenFragment() {
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
AlertDialog.Builder(it)
MaterialAlertDialogBuilder(it)
.setTitle(title)
.setView(scroll)
.setPositiveButton(R.string.ok) { _, _ ->
@ -295,7 +295,7 @@ class SettingsFragment : ScreenFragment() {
) {
addPreference(key, title, { valueToString(Preferences[key]) }) {
val values = key.default.value.values
AlertDialog.Builder(it)
MaterialAlertDialogBuilder(it)
.setTitle(title)
.setSingleChoiceItems(
values.map(valueToString).toTypedArray(),

View File

@ -202,9 +202,9 @@ class TabsFragment : ScreenFragment() {
ProductsFragment.Source.values().forEach {
val tab = TextView(layout.tabs.context)
val selectedColor =
tab.context.getColorFromAttr(android.R.attr.textColorPrimary).defaultColor
tab.context.getColorFromAttr(R.attr.colorOnSurface).defaultColor
val normalColor =
tab.context.getColorFromAttr(android.R.attr.textColorSecondary).defaultColor
tab.context.getColorFromAttr(R.attr.colorOnBackground).defaultColor
tab.gravity = Gravity.CENTER
tab.typeface = TypefaceExtra.medium
tab.setTextColor(
@ -300,6 +300,7 @@ class TabsFragment : ScreenFragment() {
this.adapter = adapter
addItemDecoration(DividerItemDecoration(context, adapter::configureDivider))
setBackgroundResource(R.drawable.background_border)
setBackgroundColor(context.getColorFromAttr(R.attr.colorSurface).defaultColor)
elevation = resources.sizeScaled(4).toFloat()
content.addView(this, FrameLayout.LayoutParams.MATCH_PARENT, 0)
visibility = View.GONE

View File

@ -52,7 +52,9 @@ object Utils {
fun getToolbarIcon(context: Context, resId: Int): Drawable {
val drawable = context.getDrawableCompat(resId).mutate()
drawable.setTintList(context.getColorFromAttr(android.R.attr.titleTextColor))
if (Android.sdk(23)) {
drawable.setTintList(context.getColorFromAttr(R.attr.colorOnPrimarySurface))
}
return drawable
}