Correct the widget layout.
Adjust the layout carefully, so that remote grid views perfectly overlap the bitmap generated from the binding view, whether left-aligned, right-aligned or centered, and regardless of the size of the widget, text, margins or spacing. Display the clock in the correct text size.
This commit is contained in:
parent
6d7d90e762
commit
183901534c
@ -106,6 +106,9 @@ class EventRepository(val context: Context) {
|
||||
resetNextEventData()
|
||||
}
|
||||
MainWidget.updateWidget(context)
|
||||
org.greenrobot.eventbus.EventBus.getDefault().post(
|
||||
com.tommasoberlose.anotherwidget.ui.fragments.MainFragment.UpdateUiMessageEvent()
|
||||
)
|
||||
}
|
||||
|
||||
fun goToPreviousEvent() {
|
||||
@ -121,6 +124,9 @@ class EventRepository(val context: Context) {
|
||||
resetNextEventData()
|
||||
}
|
||||
MainWidget.updateWidget(context)
|
||||
org.greenrobot.eventbus.EventBus.getDefault().post(
|
||||
com.tommasoberlose.anotherwidget.ui.fragments.MainFragment.UpdateUiMessageEvent()
|
||||
)
|
||||
}
|
||||
|
||||
fun getFutureEvents(): List<Event> {
|
||||
|
@ -93,9 +93,9 @@ object Preferences : KotprefModel() {
|
||||
var altTimezoneId by stringPref(default = "")
|
||||
|
||||
// Global
|
||||
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 26f)
|
||||
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 18f)
|
||||
var clockTextSize by floatPref(key = "PREF_TEXT_CLOCK_SIZE", default = 26f)
|
||||
var textMainSize by floatPref(key = "PREF_TEXT_MAIN_SIZE", default = 24f)
|
||||
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 16f)
|
||||
var clockTextSize by floatPref(key = "PREF_TEXT_CLOCK_SIZE", default = 72f)
|
||||
var clockBottomMargin by intPref(default = Constants.ClockBottomMargin.MEDIUM.rawValue)
|
||||
var secondRowTopMargin by intPref(default = Constants.SecondRowTopMargin.NONE.rawValue)
|
||||
var showClock by booleanPref(key = "PREF_SHOW_CLOCK", default = false)
|
||||
|
@ -44,8 +44,8 @@ object BitmapHelper {
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("HEIGHT SPEC", measuredHeight)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("VIEW measuredWidth", view.measuredWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("VIEW measuredHeight", view.measuredHeight)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("WIDGET final width", measuredWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("WIDGET final height", view.measuredHeight)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("WIDGET final width", widgetWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("WIDGET final height", widgetHeight)
|
||||
}
|
||||
|
||||
return try {
|
||||
@ -58,7 +58,7 @@ object BitmapHelper {
|
||||
//Bind a canvas to it
|
||||
val canvas = Canvas(btm)
|
||||
// draw the view on the canvas
|
||||
view.layout(0, 0, measuredWidth, measuredHeight)
|
||||
view.layout(0, 0, widgetWidth, widgetHeight)
|
||||
view.draw(canvas)
|
||||
//return the bitmap
|
||||
}
|
||||
|
@ -25,8 +25,15 @@ object WidgetHelper {
|
||||
) {
|
||||
|
||||
fun getWidgetsSize(widgetId: Int): Pair<Int, Int> {
|
||||
val width = getWidgetWidth(widgetId)
|
||||
val height = getWidgetHeight(widgetId)
|
||||
val portrait = context.resources.configuration.orientation == ORIENTATION_PORTRAIT
|
||||
val width = getWidgetSizeInDp(
|
||||
widgetId,
|
||||
if (portrait) AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH else AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH
|
||||
)
|
||||
val height = getWidgetSizeInDp(
|
||||
widgetId,
|
||||
if (portrait) AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT else AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT
|
||||
)
|
||||
val widthInPx = context.dip(width)
|
||||
val heightInPx = context.dip(height)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("widthInPx", widthInPx)
|
||||
|
@ -153,7 +153,11 @@ class MainFragment : Fragment() {
|
||||
WidgetHelper.runWithCustomTypeface(requireContext()) { typeface ->
|
||||
uiJob?.cancel()
|
||||
uiJob = lifecycleScope.launch(Dispatchers.IO) {
|
||||
val generatedView = MainWidget.getWidgetView(requireContext(), binding.widget.width, typeface)
|
||||
val generatedView = MainWidget.getWidgetView(
|
||||
requireContext(),
|
||||
binding.widget.width - binding.widget.paddingStart - binding.widget.paddingEnd,
|
||||
typeface
|
||||
)
|
||||
|
||||
if (generatedView != null) {
|
||||
withContext(Dispatchers.Main) {
|
||||
|
@ -236,6 +236,7 @@ class CalendarFragment : Fragment() {
|
||||
|
||||
binding.showDiffTimeToggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
Preferences.showDiffTime = isChecked
|
||||
updateCalendar()
|
||||
}
|
||||
|
||||
binding.actionShowNextEventOnMultipleLines.setOnClickListener {
|
||||
|
@ -146,7 +146,7 @@ class ClockFragment : Fragment() {
|
||||
binding.actionClockTextSize.setOnClickListener {
|
||||
BottomSheetPicker(
|
||||
requireContext(),
|
||||
items = (46 downTo 12).map { BottomSheetPicker.MenuItem("${it}sp", it.toFloat()) },
|
||||
items = (120 downTo 30).filter { it % 2 == 0 }.map { BottomSheetPicker.MenuItem("${it}sp", it.toFloat()) },
|
||||
getSelected = { Preferences.clockTextSize },
|
||||
header = getString(R.string.settings_clock_text_size_title),
|
||||
onItemSelected = {value ->
|
||||
|
@ -317,6 +317,17 @@ class TypographyFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == android.app.Activity.RESULT_OK) {
|
||||
when (requestCode) {
|
||||
RequestCode.CUSTOM_FONT_CHOOSER_REQUEST_CODE.code -> {
|
||||
com.tommasoberlose.anotherwidget.ui.widgets.MainWidget.updateWidget(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
private fun maintainScrollPosition(callback: () -> Unit) {
|
||||
binding.scrollView.isScrollable = false
|
||||
callback.invoke()
|
||||
|
@ -79,9 +79,10 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
try {
|
||||
val generatedBinding = generateWidgetView(typeface) ?: return null
|
||||
|
||||
val width = w - (Preferences.widgetPadding.convertDpToPixel(context) + Preferences.widgetMargin.convertDpToPixel(context)).toInt() * 2
|
||||
views.setImageViewBitmap(
|
||||
R.id.bitmap_container,
|
||||
BitmapHelper.getBitmapFromView(generatedBinding.root, width = w)
|
||||
BitmapHelper.getBitmapFromView(generatedBinding.root, width)
|
||||
)
|
||||
views = updateGridView(generatedBinding, views, appWidgetId)
|
||||
} catch (ex: Exception) {
|
||||
@ -241,10 +242,6 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
views.setViewVisibility(R.id.sub_line_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.weather_sub_line_rect, if (Preferences.showWeather && Preferences.weatherIcon != "") View.VISIBLE else View.GONE)
|
||||
views.setViewVisibility(R.id.first_line_rect, View.GONE)
|
||||
|
||||
views.setViewVisibility(R.id.sub_line_top_margin_small_sans, View.GONE)
|
||||
views.setViewVisibility(R.id.sub_line_top_margin_medium_sans, View.GONE)
|
||||
views.setViewVisibility(R.id.sub_line_top_margin_large_sans, View.GONE)
|
||||
} else if (GlanceProviderHelper.showGlanceProviders(context)) {
|
||||
var showSomething = false
|
||||
var isWeatherShown = false
|
||||
@ -297,6 +294,7 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
}
|
||||
Constants.GlanceProviderId.CUSTOM_INFO -> {
|
||||
if (Preferences.customNotes.isNotEmpty()) {
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -601,9 +599,12 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
bindingView.subLine.isVisible = true
|
||||
bindingView.weatherSubLine.isVisible = Preferences.showWeather && Preferences.weatherIcon != ""
|
||||
|
||||
bindingView.subLineTopMarginSmall.visibility = View.GONE
|
||||
bindingView.subLineTopMarginMedium.visibility = View.GONE
|
||||
bindingView.subLineTopMarginLarge.visibility = View.GONE
|
||||
bindingView.subLineTopMarginSmall.visibility =
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.rawValue) View.VISIBLE else View.GONE
|
||||
bindingView.subLineTopMarginMedium.visibility =
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.rawValue) View.VISIBLE else View.GONE
|
||||
bindingView.subLineTopMarginLarge.visibility =
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.rawValue) View.VISIBLE else View.GONE
|
||||
} else if (GlanceProviderHelper.showGlanceProviders(context)) {
|
||||
bindingView.subLineIcon.isVisible = true
|
||||
var showSomething = false
|
||||
@ -844,24 +845,30 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
bindingView.nextEvent to Preferences.textMainSize,
|
||||
bindingView.nextEventDifferenceTime to Preferences.textMainSize,
|
||||
bindingView.subLineText to Preferences.textSecondSize,
|
||||
bindingView.weatherSubLineDivider to (Preferences.textSecondSize - 2),
|
||||
bindingView.weatherSubLineDivider to (Preferences.textSecondSize * 0.9f),
|
||||
bindingView.weatherSubLineTemperature to Preferences.textSecondSize,
|
||||
).forEach {
|
||||
it.first.setTextSize(TypedValue.COMPLEX_UNIT_SP, it.second)
|
||||
if (!it.first.includeFontPadding && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P)
|
||||
it.first.isFallbackLineSpacing = false
|
||||
}
|
||||
|
||||
// Icons scale
|
||||
bindingView.subLineIcon.scaleX = Preferences.textSecondSize / 18f
|
||||
bindingView.subLineIcon.scaleY = Preferences.textSecondSize / 18f
|
||||
|
||||
bindingView.weatherSubLineWeatherIcon.scaleX = Preferences.textSecondSize / 18f
|
||||
bindingView.weatherSubLineWeatherIcon.scaleY = Preferences.textSecondSize / 18f
|
||||
|
||||
bindingView.weatherDateLineWeatherIcon.scaleX = ((Preferences.textMainSize + Preferences.textSecondSize) / 2) / 20f
|
||||
bindingView.weatherDateLineWeatherIcon.scaleY = ((Preferences.textMainSize + Preferences.textSecondSize) / 2) / 20f
|
||||
|
||||
bindingView.actionNext.scaleX = Preferences.textMainSize / 28f
|
||||
bindingView.actionNext.scaleY = Preferences.textMainSize / 28f
|
||||
listOf(
|
||||
bindingView.subLineIcon to Preferences.textSecondSize / 16f,
|
||||
bindingView.subLineIconShadow to Preferences.textSecondSize / 16f,
|
||||
bindingView.weatherSubLineWeatherIcon to Preferences.textSecondSize / 16f,
|
||||
bindingView.weatherDateLineWeatherIcon to ((Preferences.textMainSize + Preferences.textSecondSize) / 2) / 24f,
|
||||
bindingView.actionNext to Preferences.textMainSize / 24f,
|
||||
bindingView.actionNextShadow to Preferences.textMainSize / 24f
|
||||
).forEach {
|
||||
if (it.first.tag == null)
|
||||
it.first.tag = it.first.layoutParams.height
|
||||
it.first.layoutParams = it.first.layoutParams.apply {
|
||||
height = ((it.first.tag as Int) * it.second).roundToInt()
|
||||
width = height
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Shadows
|
||||
@ -910,7 +917,7 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
it.second.isVisible = it.first.isVisible
|
||||
it.second.scaleX = it.first.scaleX
|
||||
it.second.scaleY = it.first.scaleY
|
||||
it.second.applyShadow(it.first)
|
||||
it.second.applyShadow(it.first, 0.7f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -968,10 +975,7 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
|
||||
// Dividers
|
||||
arrayOf(bindingView.weatherSubLineDivider).forEach {
|
||||
it.visibility = if (Preferences.showDividers) View.VISIBLE else View.INVISIBLE
|
||||
it.layoutParams = (it.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
this.marginEnd = if (Preferences.showDividers) 8f.convertDpToPixel(context).toInt() else 0
|
||||
}
|
||||
it.visibility = if (Preferences.showDividers) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
// Right Aligned
|
||||
@ -981,8 +985,11 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
||||
}
|
||||
bindingView.mainContent.gravity = Gravity.END
|
||||
bindingView.dateLayout.gravity = Gravity.END
|
||||
bindingView.date.gravity = Gravity.END
|
||||
bindingView.calendarLayout.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
bindingView.nextEvent.gravity = Gravity.END
|
||||
bindingView.subLineContainer.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
bindingView.subLineText.gravity = Gravity.END
|
||||
}
|
||||
|
||||
return bindingView
|
||||
|
@ -32,12 +32,12 @@ class ClockWidget(val context: Context) {
|
||||
views.setTextViewTextSize(
|
||||
R.id.time,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
Preferences.clockTextSize.toPixel(context)
|
||||
Preferences.clockTextSize
|
||||
)
|
||||
views.setTextViewTextSize(
|
||||
R.id.time_am_pm,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
Preferences.clockTextSize.toPixel(context) / 5 * 2
|
||||
Preferences.clockTextSize / 5 * 2
|
||||
)
|
||||
val clockPIntent = IntentHelper.getPendingIntent(
|
||||
context,
|
||||
@ -80,19 +80,29 @@ class ClockWidget(val context: Context) {
|
||||
views.setTextViewTextSize(
|
||||
R.id.alt_timezone_time,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
Preferences.clockTextSize.toPixel(context) / 3
|
||||
Preferences.clockTextSize / 3
|
||||
)
|
||||
views.setTextViewTextSize(
|
||||
R.id.alt_timezone_time_am_pm,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
(Preferences.clockTextSize.toPixel(context) / 3) / 5 * 2
|
||||
(Preferences.clockTextSize / 3) / 5 * 2
|
||||
)
|
||||
views.setTextViewTextSize(
|
||||
R.id.alt_timezone_label,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
(Preferences.clockTextSize.toPixel(context) / 3) / 5 * 2
|
||||
(Preferences.clockTextSize / 3) / 5 * 2
|
||||
)
|
||||
|
||||
val padding = (TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
Preferences.clockTextSize,
|
||||
context.resources.displayMetrics
|
||||
) * 0.2).toInt()
|
||||
if (Preferences.widgetAlign == Constants.WidgetAlign.RIGHT.rawValue)
|
||||
views.setViewPadding(R.id.timezones_container, 0, padding, padding, 0)
|
||||
else
|
||||
views.setViewPadding(R.id.timezones_container, padding, padding, 0,0)
|
||||
|
||||
views.setOnClickPendingIntent(R.id.timezones_container, clockPIntent)
|
||||
views.setViewVisibility(R.id.timezones_container, View.VISIBLE)
|
||||
} else {
|
||||
|
@ -63,17 +63,13 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager,
|
||||
appWidgetId: Int) {
|
||||
val displayMetrics = Resources.getSystem().displayMetrics
|
||||
val width = displayMetrics.widthPixels
|
||||
val height = displayMetrics.heightPixels
|
||||
|
||||
val dimensions = WidgetHelper.WidgetSizeProvider(context, appWidgetManager).getWidgetsSize(appWidgetId)
|
||||
|
||||
WidgetHelper.runWithCustomTypeface(context) {
|
||||
val views = when (Preferences.widgetAlign) {
|
||||
Constants.WidgetAlign.LEFT.rawValue -> AlignedWidget(context).generateWidget(appWidgetId, min(dimensions.first - 8.toPixel(context), min(width, height) - 16.toPixel(context)), it)
|
||||
Constants.WidgetAlign.RIGHT.rawValue -> AlignedWidget(context, rightAligned = true).generateWidget(appWidgetId, min(dimensions.first - 8.toPixel(context), min(width, height) - 16.toPixel(context)), it)
|
||||
else -> StandardWidget(context).generateWidget(appWidgetId, min(dimensions.first - 8.toPixel(context), min(width, height) - 16.toPixel(context)), it)
|
||||
Constants.WidgetAlign.LEFT.rawValue -> AlignedWidget(context).generateWidget(appWidgetId, dimensions.first, it)
|
||||
Constants.WidgetAlign.RIGHT.rawValue -> AlignedWidget(context, rightAligned = true).generateWidget(appWidgetId, dimensions.first, it)
|
||||
else -> StandardWidget(context).generateWidget(appWidgetId, dimensions.first, it)
|
||||
}
|
||||
try {
|
||||
if (views != null) appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
|
@ -82,9 +82,10 @@ class StandardWidget(val context: Context) {
|
||||
try {
|
||||
val generatedBinding = generateWidgetView(typeface) ?: return null
|
||||
|
||||
val width = w - (Preferences.widgetPadding.convertDpToPixel(context) + Preferences.widgetMargin.convertDpToPixel(context)).toInt() * 2
|
||||
views.setImageViewBitmap(
|
||||
R.id.bitmap_container,
|
||||
BitmapHelper.getBitmapFromView(generatedBinding.root, width = w)
|
||||
BitmapHelper.getBitmapFromView(generatedBinding.root, width)
|
||||
)
|
||||
views = updateGridView(generatedBinding, views, appWidgetId)
|
||||
} catch (ex: Exception) {
|
||||
@ -325,6 +326,7 @@ class StandardWidget(val context: Context) {
|
||||
}
|
||||
Constants.GlanceProviderId.CUSTOM_INFO -> {
|
||||
if (Preferences.customNotes.isNotEmpty()) {
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -874,33 +876,37 @@ class StandardWidget(val context: Context) {
|
||||
// Text Size
|
||||
listOf<Pair<TextView, Float>>(
|
||||
bindingView.date to Preferences.textMainSize,
|
||||
bindingView.weatherDateLineDivider to (Preferences.textMainSize - 2),
|
||||
bindingView.weatherDateLineDivider to (Preferences.textMainSize * 0.9f),
|
||||
bindingView.weatherDateLineTemperature to Preferences.textMainSize,
|
||||
bindingView.nextEvent to Preferences.textMainSize,
|
||||
bindingView.nextEventDifferenceTime to Preferences.textMainSize,
|
||||
bindingView.subLineText to Preferences.textSecondSize,
|
||||
bindingView.weatherSubLineDivider to (Preferences.textSecondSize - 2),
|
||||
bindingView.weatherSubLineDivider to (Preferences.textSecondSize * 0.9f),
|
||||
bindingView.weatherSubLineTemperature to Preferences.textSecondSize,
|
||||
).forEach {
|
||||
it.first.setTextSize(TypedValue.COMPLEX_UNIT_SP, it.second)
|
||||
if (!it.first.includeFontPadding && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P)
|
||||
it.first.isFallbackLineSpacing = false
|
||||
}
|
||||
|
||||
// Icons scale
|
||||
bindingView.subLineIcon.scaleX = Preferences.textSecondSize / 18f
|
||||
bindingView.subLineIcon.scaleY = Preferences.textSecondSize / 18f
|
||||
|
||||
bindingView.weatherSubLineWeatherIcon.scaleX = Preferences.textSecondSize / 18f
|
||||
bindingView.weatherSubLineWeatherIcon.scaleY = Preferences.textSecondSize / 18f
|
||||
|
||||
bindingView.weatherDateLineWeatherIcon.scaleX = Preferences.textMainSize / 18f
|
||||
bindingView.weatherDateLineWeatherIcon.scaleY = Preferences.textMainSize / 18f
|
||||
|
||||
bindingView.actionNext.scaleX = Preferences.textMainSize / 28f
|
||||
bindingView.actionNext.scaleY = Preferences.textMainSize / 28f
|
||||
|
||||
bindingView.actionPrevious.scaleX = Preferences.textMainSize / 28f
|
||||
bindingView.actionPrevious.scaleY = Preferences.textMainSize / 28f
|
||||
|
||||
listOf(
|
||||
bindingView.subLineIcon to Preferences.textSecondSize / 16f,
|
||||
bindingView.subLineIconShadow to Preferences.textSecondSize / 16f,
|
||||
bindingView.weatherSubLineWeatherIcon to Preferences.textSecondSize / 16f,
|
||||
bindingView.weatherDateLineWeatherIcon to Preferences.textMainSize / 24f,
|
||||
bindingView.actionNext to Preferences.textMainSize / 24f,
|
||||
bindingView.actionNextShadow to Preferences.textMainSize / 24f,
|
||||
bindingView.actionPrevious to Preferences.textMainSize / 24f,
|
||||
bindingView.actionPreviousShadow to Preferences.textMainSize / 24f
|
||||
).forEach {
|
||||
if (it.first.tag == null)
|
||||
it.first.tag = it.first.layoutParams.height
|
||||
it.first.layoutParams = it.first.layoutParams.apply {
|
||||
height = ((it.first.tag as Int) * it.second).roundToInt()
|
||||
width = height
|
||||
}
|
||||
}
|
||||
|
||||
// Shadows
|
||||
val shadowRadius =
|
||||
@ -949,7 +955,7 @@ class StandardWidget(val context: Context) {
|
||||
it.second.isVisible = it.first.isVisible
|
||||
it.second.scaleX = it.first.scaleX
|
||||
it.second.scaleY = it.first.scaleY
|
||||
it.second.applyShadow(it.first)
|
||||
it.second.applyShadow(it.first, 0.7f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1013,10 +1019,7 @@ class StandardWidget(val context: Context) {
|
||||
|
||||
// Dividers
|
||||
arrayOf(bindingView.weatherDateLineDivider, bindingView.weatherSubLineDivider).forEach {
|
||||
it.visibility = if (Preferences.showDividers) View.VISIBLE else View.INVISIBLE
|
||||
it.layoutParams = (it.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
this.marginEnd = if (Preferences.showDividers) 8f.convertDpToPixel(context).toInt() else 0
|
||||
}
|
||||
it.visibility = if (Preferences.showDividers) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,8 +94,7 @@
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:padding="8dp"
|
||||
android:id="@+id/widget"
|
||||
android:alpha="0"
|
||||
android:animateLayoutChanges="true"
|
||||
|
@ -22,7 +22,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="vertical"
|
||||
android:layoutDirection="locale"
|
||||
android:id="@+id/date_layout">
|
||||
@ -30,6 +29,7 @@
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:lines="1"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:maxLines="1"
|
||||
@ -44,15 +44,14 @@
|
||||
android:visibility="gone"
|
||||
android:id="@+id/weather_date_line">
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:id="@+id/weather_date_line_weather_icon"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
android:layout_marginStart="4dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Widget.Date.Big"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
android:id="@+id/weather_date_line_temperature"/>
|
||||
@ -85,6 +84,7 @@
|
||||
android:id="@+id/next_event_difference_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
style="@style/AnotherWidget.Widget.Title" />
|
||||
</LinearLayout>
|
||||
@ -138,6 +138,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/sub_line"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal">
|
||||
@ -145,14 +146,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:cropToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp">
|
||||
android:clipChildren="false">
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:cropToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:id="@+id/sub_line_icon_shadow"
|
||||
android:src="@drawable/round_today_24"/>
|
||||
<ImageView
|
||||
@ -160,6 +160,7 @@
|
||||
android:layout_height="16dp"
|
||||
android:cropToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:id="@+id/sub_line_icon"
|
||||
android:src="@drawable/round_today_24"/>
|
||||
</RelativeLayout>
|
||||
@ -167,7 +168,9 @@
|
||||
android:id="@+id/sub_line_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="start"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Widget.Subtitle" />
|
||||
@ -178,12 +181,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:id="@+id/weather_sub_line">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:id="@+id/weather_sub_line_divider"
|
||||
android:text="@string/divider"
|
||||
@ -193,12 +195,12 @@
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:id="@+id/weather_sub_line_weather_icon"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Widget.Date.Big"
|
||||
style="@style/AnotherWidget.Widget.Subtitle"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
android:id="@+id/weather_sub_line_temperature"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
android:id="@+id/main_layout"
|
||||
android:animateLayoutChanges="true">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="10000dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/time_container"
|
||||
android:layoutDirection="locale"
|
||||
@ -48,9 +48,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/timezones_container"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -117,16 +114,16 @@
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/clock_bottom_margin_large" />
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="10000dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/content">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitStart"
|
||||
android:scaleType="matrix"
|
||||
android:id="@+id/bitmap_container"/>
|
||||
</RelativeLayout>
|
||||
<LinearLayout
|
||||
@ -141,7 +138,6 @@
|
||||
android:background="@color/errorColorText"
|
||||
android:layoutDirection="locale"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:id="@+id/first_line_rect">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
@ -163,9 +159,8 @@
|
||||
android:id="@+id/calendar_layout_rect"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/colorAccent"
|
||||
android:id="@+id/next_event_rect" />
|
||||
<ImageView
|
||||
@ -204,24 +199,26 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorNightDark"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:layoutDirection="locale"
|
||||
android:gravity="center_vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:background="@color/colorAccent"
|
||||
android:id="@+id/sub_line_rect" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -15,10 +15,10 @@
|
||||
android:id="@+id/main_layout"
|
||||
android:animateLayoutChanges="true">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="10000dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/time_container"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="end"
|
||||
android:layoutDirection="locale"
|
||||
android:orientation="horizontal">
|
||||
<LinearLayout
|
||||
@ -26,9 +26,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/timezones_container"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:gravity="end"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -61,7 +59,7 @@
|
||||
<TextView
|
||||
android:id="@+id/alt_timezone_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="start"
|
||||
android:gravity="end"
|
||||
android:maxLines="1"
|
||||
android:textStyle="bold"
|
||||
android:includeFontPadding="false"
|
||||
@ -118,14 +116,14 @@
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/clock_bottom_margin_large" />
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="10000dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:id="@+id/content">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitEnd"
|
||||
android:scaleType="matrix"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:id="@+id/bitmap_container"/>
|
||||
<LinearLayout
|
||||
@ -143,7 +141,6 @@
|
||||
android:layoutDirection="locale"
|
||||
android:visibility="gone"
|
||||
android:gravity="end"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:id="@+id/first_line_rect">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
@ -165,9 +162,8 @@
|
||||
android:id="@+id/calendar_layout_rect"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/colorAccent"
|
||||
android:id="@+id/next_event_rect" />
|
||||
<ImageView
|
||||
@ -206,24 +202,26 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorNightDark"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:layoutDirection="locale"
|
||||
android:gravity="center_vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:background="@color/colorAccent"
|
||||
android:id="@+id/sub_line_rect" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -45,26 +45,25 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:id="@+id/weather_date_line">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:id="@+id/weather_date_line_divider"
|
||||
android:text="@string/divider"
|
||||
android:includeFontPadding="false"
|
||||
style="@style/AnotherWidget.Widget.Subtitle"/>
|
||||
style="@style/AnotherWidget.Widget.Title"/>
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:id="@+id/weather_date_line_weather_icon"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
android:layout_marginStart="2dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Widget.Date.Big"
|
||||
style="@style/AnotherWidget.Widget.Title"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
android:id="@+id/weather_date_line_temperature"/>
|
||||
@ -100,7 +99,6 @@
|
||||
android:layout_weight="1"
|
||||
android:maxLines="1"
|
||||
android:lines="1"
|
||||
android:gravity="end"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_height="wrap_content"
|
||||
@ -113,7 +111,7 @@
|
||||
android:id="@+id/next_event_difference_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
style="@style/AnotherWidget.Widget.Title" />
|
||||
</LinearLayout>
|
||||
@ -173,13 +171,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:cropToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginEnd="4dp">
|
||||
android:clipChildren="false">
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:cropToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:id="@+id/sub_line_icon_shadow"
|
||||
android:src="@drawable/round_today_24"/>
|
||||
<ImageView
|
||||
@ -187,6 +185,7 @@
|
||||
android:layout_height="16dp"
|
||||
android:cropToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:id="@+id/sub_line_icon"
|
||||
android:src="@drawable/round_today_24"/>
|
||||
</RelativeLayout>
|
||||
@ -206,12 +205,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:id="@+id/weather_sub_line">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:id="@+id/weather_sub_line_divider"
|
||||
android:text="@string/divider"
|
||||
android:includeFontPadding="false"
|
||||
@ -220,12 +219,12 @@
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:id="@+id/weather_sub_line_weather_icon"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Widget.Date.Big"
|
||||
style="@style/AnotherWidget.Widget.Subtitle"
|
||||
android:maxLines="1"
|
||||
android:includeFontPadding="false"
|
||||
android:id="@+id/weather_sub_line_temperature"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
android:id="@+id/main_layout"
|
||||
android:animateLayoutChanges="true">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="10000dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/time_container"
|
||||
android:gravity="center_horizontal"
|
||||
@ -49,9 +49,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/timezones_container"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -118,23 +115,22 @@
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/clock_bottom_margin_large" />
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="10000dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/content">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingTop="4dp">
|
||||
android:layout_centerInParent="true">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitCenter"
|
||||
android:scaleType="matrix"
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/bitmap_container"/>
|
||||
</RelativeLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:alpha="0"
|
||||
@ -148,11 +144,11 @@
|
||||
android:background="@color/colorNightDark"
|
||||
android:orientation="horizontal"
|
||||
android:layoutDirection="locale"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:id="@+id/first_line_rect">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorAccent"
|
||||
android:id="@+id/date_rect"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
@ -175,9 +171,9 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/action_previous_rect" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/colorAccent"
|
||||
android:id="@+id/next_event_rect" />
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
@ -213,11 +209,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:layoutDirection="locale"
|
||||
android:gravity="center">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
@ -225,12 +222,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorNightDark"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/sub_line_rect" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
x
Reference in New Issue
Block a user