Skip to content

Commit

Permalink
Trim padding on non-material themes
Browse files Browse the repository at this point in the history
  • Loading branch information
hwki committed Sep 30, 2021
1 parent 86202c6 commit 87d5deb
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.brentpanther.bitcoinwidget"
minSdk 23
targetSdk 31
versionCode 275
versionName "8.0"
versionCode 276
versionName "8.0.1"

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.util.TypedValue
import android.widget.TextView
import com.brentpanther.bitcoinwidget.Coin
import com.brentpanther.bitcoinwidget.R
import com.brentpanther.bitcoinwidget.Theme
import com.brentpanther.bitcoinwidget.WidgetApplication.Companion.dpToPx
import com.brentpanther.bitcoinwidget.db.ConfigurationWithSizes
import com.brentpanther.bitcoinwidget.db.Widget
Expand All @@ -24,7 +25,12 @@ open class SolidPriceWidgetDisplayStrategy(context: Context, widget: Widget, wid
val widgetSize = widgetPresenter.getWidgetSize(appContext, widget.widgetId)
// add padding
widgetSize.bottom -= 16.dpToPx()
widgetSize.right -= 16.dpToPx()
val horizontalPadding = when (widget.theme) {
Theme.MATERIAL -> 8
Theme.TRANSPARENT -> if (widget.nightMode.isDark(appContext)) 2 else 0
else -> 4
}
widgetSize.right = horizontalPadding.dpToPx()

updateIcon()
RectF(widgetSize).also {
Expand Down
6 changes: 3 additions & 3 deletions bitcoin/src/main/res/layout/widget_price_solid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:padding="8dp"
android:paddingVertical="8dp"
android:paddingHorizontal="?attr/appWidgetHorizontalPadding"
android:orientation="vertical">

<TextView
Expand All @@ -31,8 +32,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="56"
android:orientation="horizontal"
android:paddingHorizontal="8dp">
android:orientation="horizontal">

<ImageView
android:id="@+id/icon"
Expand Down
3 changes: 2 additions & 1 deletion bitcoin/src/main/res/layout/widget_value_solid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:padding="8dp">
android:paddingVertical="8dp"
android:paddingHorizontal="?attr/appWidgetHorizontalPadding">

<LinearLayout
android:id="@+id/coin_layout"
Expand Down
3 changes: 3 additions & 0 deletions bitcoin/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<item name="appWidgetRadius">@android:dimen/system_app_widget_background_radius</item>
<item name="appWidgetTextStyle">@style/SolidWidgetText</item>
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText</item>
<item name="appWidgetHorizontalPadding">4dp</item>
</style>

<style name="Theme.MyApp.WidgetContainer.Light.Material">
Expand All @@ -13,6 +14,7 @@
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText.LightMaterial.Secondary</item>
<item name="appWidgetLoadingColor">@android:color/system_accent2_600</item>
<item name="appWidgetDefaultIcon">@drawable/ic_btc</item>
<item name="appWidgetHorizontalPadding">8dp</item>
</style>

<style name="Theme.MyApp.WidgetContainer.Dark.Material">
Expand All @@ -21,6 +23,7 @@
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText.DarkMaterial.Secondary</item>
<item name="appWidgetLoadingColor">@android:color/system_accent1_600</item>
<item name="appWidgetDefaultIcon">@drawable/ic_btc_dark</item>
<item name="appWidgetHorizontalPadding">8dp</item>
</style>

</resources>
1 change: 1 addition & 0 deletions bitcoin/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<attr name="appWidgetLoadingColor" format="color"/>
<attr name="appWidgetTextStyle" format="reference"/>
<attr name="appWidgetSecondaryTextStyle" format="reference"/>
<attr name="appWidgetHorizontalPadding" format="dimension"/>
</resources>
3 changes: 3 additions & 0 deletions bitcoin/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<item name="appWidgetRadius">8dp</item>
<item name="appWidgetTextStyle">@style/SolidWidgetText</item>
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText</item>
<item name="appWidgetHorizontalPadding">4dp</item>
</style>

<style name="Theme.MyApp.WidgetContainer.Light">
Expand All @@ -33,6 +34,7 @@
<item name="appWidgetBackgroundColor">@android:color/transparent</item>
<item name="appWidgetTextStyle">@style/SolidWidgetText.Transparent</item>
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText.Transparent</item>
<item name="appWidgetHorizontalPadding">0dp</item>
</style>

<style name="Theme.MyApp.WidgetContainer.Dark">
Expand All @@ -47,5 +49,6 @@
<item name="appWidgetBackgroundColor">#88000000</item>
<item name="appWidgetTextStyle">@style/SolidWidgetText.DarkTransparent</item>
<item name="appWidgetSecondaryTextStyle">@style/SolidWidgetText.DarkTransparent</item>
<item name="appWidgetHorizontalPadding">2dp</item>
</style>
</resources>

0 comments on commit 87d5deb

Please sign in to comment.