Skip to content

Commit

Permalink
Merge pull request #554 from DHD2280/additions10
Browse files Browse the repository at this point in the history
Misc Toast Improvements, Toast Style 12 addition
  • Loading branch information
DHD2280 authored Aug 2, 2024
2 parents 1b54af2 + 0e90c2b commit 689bed3
Show file tree
Hide file tree
Showing 42 changed files with 223 additions and 828 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<gradient
android:angle="315.0"
android:endColor="@*android:color/holo_blue_dark"
android:startColor="@*android:color/holo_blue_light" />
<corners
android:bottomLeftRadius="14dp"
android:bottomRightRadius="24dp"
android:topLeftRadius="24dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item
android:bottom="4.0dp"
android:end="4.0dp"
android:start="4.0dp"
android:top="4.0dp">
<shape>
<solid android:color="@color/toast_color_bg" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="10dp" />
</shape>
</item>
</layer-list>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<gradient
android:angle="315.0"
android:endColor="@*android:color/holo_blue_dark"
android:startColor="@*android:color/holo_blue_light" />
<corners
android:bottomLeftRadius="14dp"
android:bottomRightRadius="24dp"
android:topLeftRadius="24dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item
android:bottom="4.0dp"
android:end="4.0dp"
android:start="4.0dp"
android:top="4.0dp">
<shape>
<solid android:color="@color/toast_color_bg" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="10dp" />
</shape>
</item>
</layer-list>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="toast_color_bg">@android:color/system_neutral2_800</color>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="toast_color_bg">@android:color/system_neutral1_50</color>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ToastAdapter (

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val model = itemList[holder.bindingAdapterPosition]
holder.binding.styleName.text = appContextLocale.resources.getString(model.title)
holder.binding.styleName.text = model.title
holder.binding.toastContainer.background = ContextCompat.getDrawable(appContext, model.style)
if (model.selected) {
holder.binding.styleName.setTextColor(
Expand Down
40 changes: 27 additions & 13 deletions app/src/main/java/com/drdisagree/iconify/ui/fragments/ToastFrame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
import com.drdisagree.iconify.Iconify.Companion.appContext
import com.drdisagree.iconify.Iconify.Companion.appContextLocale
import com.drdisagree.iconify.R
Expand Down Expand Up @@ -54,7 +55,19 @@ class ToastFrame : BaseFragment() {
loadingDialog = LoadingDialog(requireContext())

// Toast Frame style
binding.toastStylesContainer.setLayoutManager(GridLayoutManager(requireContext(), 2))
val gridLayout = GridLayoutManager(requireContext(), 2)
gridLayout.spanSizeLookup = object : SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
val lastIndex = binding.toastStylesContainer.adapter?.itemCount?.minus(1) ?: 0

return if (position == lastIndex && lastIndex % gridLayout.spanCount == 0) {
2
} else {
1
}
}
}
binding.toastStylesContainer.setLayoutManager(gridLayout)
binding.toastStylesContainer.setAdapter(initToastFrameItems())
binding.toastStylesContainer.setHasFixedSize(true)

Expand All @@ -64,18 +77,19 @@ class ToastFrame : BaseFragment() {
private fun initToastFrameItems(): ToastAdapter {
val selectedStyle = getInt(SELECTED_TOAST_FRAME, -1)
val toastFrameStyle = ArrayList<ToastModel>().apply {
add(ToastModel(R.drawable.toast_frame_style_1, R.string.style_0))
add(ToastModel(R.drawable.toast_frame_style_1, R.string.style_1))
add(ToastModel(R.drawable.toast_frame_style_2, R.string.style_2))
add(ToastModel(R.drawable.toast_frame_style_3, R.string.style_3))
add(ToastModel(R.drawable.toast_frame_style_4, R.string.style_4))
add(ToastModel(R.drawable.toast_frame_style_5, R.string.style_5))
add(ToastModel(R.drawable.toast_frame_style_6, R.string.style_6))
add(ToastModel(R.drawable.toast_frame_style_7, R.string.style_7))
add(ToastModel(R.drawable.toast_frame_style_8, R.string.style_8))
add(ToastModel(R.drawable.toast_frame_style_9, R.string.style_9))
add(ToastModel(R.drawable.toast_frame_style_10, R.string.style_10))
add(ToastModel(R.drawable.toast_frame_style_11, R.string.style_11))
add(ToastModel(R.drawable.toast_frame_style_1, appContextLocale.resources.getString(R.string.style_0)))
add(ToastModel(R.drawable.toast_frame_style_1, String.format(appContextLocale.resources.getString(R.string.style), 1)))
add(ToastModel(R.drawable.toast_frame_style_2, String.format(appContextLocale.resources.getString(R.string.style), 2)))
add(ToastModel(R.drawable.toast_frame_style_3, String.format(appContextLocale.resources.getString(R.string.style), 3)))
add(ToastModel(R.drawable.toast_frame_style_4, String.format(appContextLocale.resources.getString(R.string.style), 4)))
add(ToastModel(R.drawable.toast_frame_style_5, String.format(appContextLocale.resources.getString(R.string.style), 5)))
add(ToastModel(R.drawable.toast_frame_style_6, String.format(appContextLocale.resources.getString(R.string.style), 6)))
add(ToastModel(R.drawable.toast_frame_style_7, String.format(appContextLocale.resources.getString(R.string.style), 7)))
add(ToastModel(R.drawable.toast_frame_style_8, String.format(appContextLocale.resources.getString(R.string.style), 8)))
add(ToastModel(R.drawable.toast_frame_style_9, String.format(appContextLocale.resources.getString(R.string.style), 9)))
add(ToastModel(R.drawable.toast_frame_style_10, String.format(appContextLocale.resources.getString(R.string.style), 10)))
add(ToastModel(R.drawable.toast_frame_style_11, String.format(appContextLocale.resources.getString(R.string.style), 11)))
add(ToastModel(R.drawable.toast_frame_style_12, String.format(appContextLocale.resources.getString(R.string.style), 12)))
}

return ToastAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.drdisagree.iconify.Iconify.Companion.appContext
import com.drdisagree.iconify.Iconify.Companion.appContextLocale
import com.drdisagree.iconify.R
import com.drdisagree.iconify.common.Const.SWITCH_ANIMATION_DELAY
import com.drdisagree.iconify.common.Preferences.CHIP_QSSTATUSICONS_STYLE
Expand Down Expand Up @@ -127,26 +128,26 @@ class XposedBackgroundChip : BaseFragment() {

private fun initStatusBarChipStyles(): ArrayList<Array<Any>> {
val statusBarChipStyle = ArrayList<Array<Any>>().apply {
add(arrayOf(R.drawable.chip_status_bar_1, R.string.style_1))
add(arrayOf(R.drawable.chip_status_bar_2, R.string.style_2))
add(arrayOf(R.drawable.chip_status_bar_3, R.string.style_3))
add(arrayOf(R.drawable.chip_status_bar_4, R.string.style_4))
add(arrayOf(R.drawable.chip_status_bar_5, R.string.style_5))
add(arrayOf(R.drawable.chip_status_bar_6, R.string.style_6))
add(arrayOf(R.drawable.chip_status_bar_7, R.string.style_7))
add(arrayOf(R.drawable.chip_status_bar_1, String.format(appContextLocale.resources.getString(R.string.style), 1)))
add(arrayOf(R.drawable.chip_status_bar_2, String.format(appContextLocale.resources.getString(R.string.style), 2)))
add(arrayOf(R.drawable.chip_status_bar_3, String.format(appContextLocale.resources.getString(R.string.style), 3)))
add(arrayOf(R.drawable.chip_status_bar_4, String.format(appContextLocale.resources.getString(R.string.style), 4)))
add(arrayOf(R.drawable.chip_status_bar_5, String.format(appContextLocale.resources.getString(R.string.style), 5)))
add(arrayOf(R.drawable.chip_status_bar_6, String.format(appContextLocale.resources.getString(R.string.style), 6)))
add(arrayOf(R.drawable.chip_status_bar_7, String.format(appContextLocale.resources.getString(R.string.style), 7)))
}

return statusBarChipStyle
}

private fun initStatusIconsChipStyles(): ArrayList<Array<Any>> {
val statusIconsChipStyle = ArrayList<Array<Any>>().apply {
add(arrayOf(R.drawable.chip_status_icons_1, R.string.style_1))
add(arrayOf(R.drawable.chip_status_icons_2, R.string.style_2))
add(arrayOf(R.drawable.chip_status_icons_3, R.string.style_3))
add(arrayOf(R.drawable.chip_status_icons_4, R.string.style_4))
add(arrayOf(R.drawable.chip_status_icons_5, R.string.style_5))
add(arrayOf(R.drawable.chip_status_icons_6, R.string.style_6))
add(arrayOf(R.drawable.chip_status_icons_1, String.format(appContextLocale.resources.getString(R.string.style), 1)))
add(arrayOf(R.drawable.chip_status_icons_2, String.format(appContextLocale.resources.getString(R.string.style), 2)))
add(arrayOf(R.drawable.chip_status_icons_3, String.format(appContextLocale.resources.getString(R.string.style), 3)))
add(arrayOf(R.drawable.chip_status_icons_4, String.format(appContextLocale.resources.getString(R.string.style), 4)))
add(arrayOf(R.drawable.chip_status_icons_5, String.format(appContextLocale.resources.getString(R.string.style), 5)))
add(arrayOf(R.drawable.chip_status_icons_6, String.format(appContextLocale.resources.getString(R.string.style), 6)))
}

return statusIconsChipStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.drdisagree.iconify.ui.models

class ToastModel (
var style: Int,
var title: Int,
var title: String,
var selected: Boolean = false
)
34 changes: 34 additions & 0 deletions app/src/main/res/drawable-night-v24/toast_frame_style_12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<gradient
android:angle="315.0"
android:endColor="@color/holo_blue_dark"
android:startColor="@color/holo_blue_light" />
<corners
android:bottomLeftRadius="14dp"
android:bottomRightRadius="24dp"
android:topLeftRadius="24dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item
android:bottom="4.0dp"
android:end="4.0dp"
android:start="4.0dp"
android:top="4.0dp">
<shape>
<solid android:color="@android:color/system_neutral1_800" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="10dp" />
</shape>
</item>
</layer-list>
</item>
</layer-list>
34 changes: 34 additions & 0 deletions app/src/main/res/drawable-v24/toast_frame_style_12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<gradient
android:angle="315.0"
android:endColor="@color/holo_blue_dark"
android:startColor="@color/holo_blue_light" />
<corners
android:bottomLeftRadius="14dp"
android:bottomRightRadius="24dp"
android:topLeftRadius="24dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item
android:bottom="4.0dp"
android:end="4.0dp"
android:start="4.0dp"
android:top="4.0dp">
<shape>
<solid android:color="@android:color/system_neutral1_50" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="10dp" />
</shape>
</item>
</layer-list>
</item>
</layer-list>
26 changes: 1 addition & 25 deletions app/src/main/res/values-af-rZA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -761,31 +761,7 @@
<string name="exported_settings">Saved settings successfully</string>
<!-- Style List -->
<string name="style_0">None</string>
<string name="style_1">Style 1</string>
<string name="style_2">Style 2</string>
<string name="style_3">Style 3</string>
<string name="style_4">Style 4</string>
<string name="style_5">Style 5</string>
<string name="style_6">Style 6</string>
<string name="style_7">Style 7</string>
<string name="style_8">Style 8</string>
<string name="style_9">Style 9</string>
<string name="style_10">Style 10</string>
<string name="style_11">Style 11</string>
<string name="style_12">Style 12</string>
<string name="style_13">Style 13</string>
<string name="style_14">Style 14</string>
<string name="style_15">Style 15</string>
<string name="style_16">Style 16</string>
<string name="style_17">Style 17</string>
<string name="style_18">Style 18</string>
<string name="style_19">Style 19</string>
<string name="style_20">Style 20</string>
<string name="style_21">Style 21</string>
<string name="style_22">Style 22</string>
<string name="style_23">Style 23</string>
<string name="style_24">Style 24</string>
<string name="style_25">Style 25</string>
<string name="style">Style %d</string>
<!-- Buttons -->
<string name="btn_continue">Continue</string>
<string name="btn_restart">Restart</string>
Expand Down
26 changes: 1 addition & 25 deletions app/src/main/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -761,31 +761,7 @@
<string name="exported_settings">تم حفظ الإعدادات بنجاح</string>
<!-- Style List -->
<string name="style_0">لا شيء</string>
<string name="style_1">النمط 1</string>
<string name="style_2">النمط 2</string>
<string name="style_3">النمط 3</string>
<string name="style_4">النمط 4</string>
<string name="style_5">النمط 5</string>
<string name="style_6">النمط 6</string>
<string name="style_7">النمط 7</string>
<string name="style_8">النمط 8</string>
<string name="style_9">النمط 9</string>
<string name="style_10">النمط 10</string>
<string name="style_11">النمط 11</string>
<string name="style_12">النمط 12</string>
<string name="style_13">النمط 13</string>
<string name="style_14">النمط 14</string>
<string name="style_15">النمط 15</string>
<string name="style_16">النمط 16</string>
<string name="style_17">النمط 17</string>
<string name="style_18">النمط 18</string>
<string name="style_19">النمط 19</string>
<string name="style_20">النمط 20</string>
<string name="style_21">النمط 21</string>
<string name="style_22">النمط 22</string>
<string name="style_23">النمط 23</string>
<string name="style_24">النمط 24</string>
<string name="style_25">النمط 25</string>
<string name="style">النمط %d</string>
<!-- Buttons -->
<string name="btn_continue">استمر</string>
<string name="btn_restart">إعداة تشغيل</string>
Expand Down
26 changes: 1 addition & 25 deletions app/src/main/res/values-ca-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -761,31 +761,7 @@
<string name="exported_settings">Saved settings successfully</string>
<!-- Style List -->
<string name="style_0">None</string>
<string name="style_1">Style 1</string>
<string name="style_2">Style 2</string>
<string name="style_3">Style 3</string>
<string name="style_4">Style 4</string>
<string name="style_5">Style 5</string>
<string name="style_6">Style 6</string>
<string name="style_7">Style 7</string>
<string name="style_8">Style 8</string>
<string name="style_9">Style 9</string>
<string name="style_10">Style 10</string>
<string name="style_11">Style 11</string>
<string name="style_12">Style 12</string>
<string name="style_13">Style 13</string>
<string name="style_14">Style 14</string>
<string name="style_15">Style 15</string>
<string name="style_16">Style 16</string>
<string name="style_17">Style 17</string>
<string name="style_18">Style 18</string>
<string name="style_19">Style 19</string>
<string name="style_20">Style 20</string>
<string name="style_21">Style 21</string>
<string name="style_22">Style 22</string>
<string name="style_23">Style 23</string>
<string name="style_24">Style 24</string>
<string name="style_25">Style 25</string>
<string name="style">Style %d</string>
<!-- Buttons -->
<string name="btn_continue">Continue</string>
<string name="btn_restart">Restart</string>
Expand Down
Loading

0 comments on commit 689bed3

Please sign in to comment.