Fix #191
This commit is contained in:
parent
59dc5de21a
commit
ca6fb75dfd
app/src/main
java/com/tommasoberlose/anotherwidget
global
ui
res
layout
values-it
values
@ -15,6 +15,13 @@ object Constants {
|
||||
LARGE(3)
|
||||
}
|
||||
|
||||
enum class SecondRowTopMargin(val value: Int) {
|
||||
NONE(0),
|
||||
SMALL(1),
|
||||
MEDIUM(2),
|
||||
LARGE(3)
|
||||
}
|
||||
|
||||
enum class GlanceProviderId(val id: String) {
|
||||
PLAYING_SONG("PLAYING_SONG"),
|
||||
NEXT_CLOCK_ALARM("NEXT_CLOCK_ALARM"),
|
||||
|
@ -65,6 +65,7 @@ object Preferences : KotprefModel() {
|
||||
var textSecondSize by floatPref(key = "PREF_TEXT_SECOND_SIZE", default = 18f)
|
||||
var clockTextSize by floatPref(key = "PREF_TEXT_CLOCK_SIZE", default = 90f)
|
||||
var clockBottomMargin by intPref(default = Constants.ClockBottomMargin.MEDIUM.value)
|
||||
var secondRowTopMargin by intPref(default = Constants.SecondRowTopMargin.NONE.value)
|
||||
var showClock by booleanPref(key = "PREF_SHOW_CLOCK", default = false)
|
||||
var clockAppName by stringPref(key = "PREF_CLOCK_APP_NAME", default = "")
|
||||
var clockAppPackage by stringPref(key = "PREF_CLOCK_APP_PACKAGE", default = "")
|
||||
|
@ -17,6 +17,7 @@ import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
import com.tommasoberlose.anotherwidget.databinding.FragmentGeneralSettingsBinding
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.global.RequestCode
|
||||
import com.tommasoberlose.anotherwidget.helpers.ColorHelper
|
||||
@ -27,7 +28,9 @@ import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.CustomDateActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_clock_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_general_settings.*
|
||||
import kotlinx.android.synthetic.main.fragment_general_settings.scrollView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@ -141,6 +144,17 @@ class GeneralTabFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.secondRowTopMargin.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
second_row_top_margin_label?.text = when (it) {
|
||||
Constants.SecondRowTopMargin.NONE.value -> getString(R.string.settings_clock_bottom_margin_subtitle_none)
|
||||
Constants.SecondRowTopMargin.SMALL.value -> getString(R.string.settings_clock_bottom_margin_subtitle_small)
|
||||
Constants.SecondRowTopMargin.LARGE.value -> getString(R.string.settings_clock_bottom_margin_subtitle_large)
|
||||
else -> getString(R.string.settings_clock_bottom_margin_subtitle_medium)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.backgroundCardColor.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
if (Preferences.backgroundCardAlpha == "00") {
|
||||
@ -244,6 +258,32 @@ class GeneralTabFragment : Fragment() {
|
||||
).show()
|
||||
}
|
||||
|
||||
action_second_row_top_margin_size.setOnClickListener {
|
||||
BottomSheetMenu<Int>(
|
||||
requireContext(),
|
||||
header = getString(R.string.settings_secondary_row_top_margin_title)
|
||||
).setSelectedValue(Preferences.secondRowTopMargin)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_none),
|
||||
Constants.SecondRowTopMargin.NONE.value
|
||||
)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_small),
|
||||
Constants.SecondRowTopMargin.SMALL.value
|
||||
)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_medium),
|
||||
Constants.SecondRowTopMargin.MEDIUM.value
|
||||
)
|
||||
.addItem(
|
||||
getString(R.string.settings_clock_bottom_margin_subtitle_large),
|
||||
Constants.SecondRowTopMargin.LARGE.value
|
||||
)
|
||||
.addOnSelectItemListener { value ->
|
||||
Preferences.secondRowTopMargin = value
|
||||
}.show()
|
||||
}
|
||||
|
||||
action_date_format.setOnClickListener {
|
||||
val now = Calendar.getInstance()
|
||||
val dialog = BottomSheetMenu<String>(requireContext(), header = getString(R.string.settings_date_format_title)).setSelectedValue(Preferences.dateFormat)
|
||||
|
@ -19,6 +19,7 @@ class MainViewModel : ViewModel() {
|
||||
val customFont = Preferences.asLiveData(Preferences::customFont)
|
||||
val secondRowInformation = Preferences.asLiveData(Preferences::secondRowInformation)
|
||||
val showDividers = Preferences.asLiveData(Preferences::showDividers)
|
||||
val secondRowTopMargin = Preferences.asLiveData(Preferences::secondRowTopMargin)
|
||||
|
||||
// Calendar Settings
|
||||
val showEvents = Preferences.asLiveData(Preferences::showEvents)
|
||||
|
@ -261,7 +261,21 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_small_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_medium_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_large_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
} else if (GlanceProviderHelper.showGlanceProviders(context) && v.calendar_layout.isVisible) {
|
||||
var showSomething = false
|
||||
loop@ for (provider:Constants.GlanceProviderId in GlanceProviderHelper.getGlanceProviders(context)) {
|
||||
when (provider) {
|
||||
Constants.GlanceProviderId.PLAYING_SONG -> {
|
||||
@ -273,6 +287,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, musicIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -285,6 +300,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, alarmIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -299,6 +315,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, batteryIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
@ -317,26 +334,44 @@ class MainWidget : AppWidgetProvider() {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.second_row_rect, fitIntent)
|
||||
showSomething = true
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
views.setImageViewBitmap(
|
||||
R.id.next_event_rect,
|
||||
BitmapHelper.getBitmapFromView(v.next_event, draw = false)
|
||||
)
|
||||
|
||||
views.setImageViewBitmap(
|
||||
R.id.second_row_rect,
|
||||
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
||||
)
|
||||
if (showSomething) {
|
||||
views.setImageViewBitmap(
|
||||
R.id.next_event_rect,
|
||||
BitmapHelper.getBitmapFromView(v.next_event, draw = false)
|
||||
)
|
||||
|
||||
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
||||
views.setImageViewBitmap(
|
||||
R.id.second_row_rect,
|
||||
BitmapHelper.getBitmapFromView(v.second_row, draw = false)
|
||||
)
|
||||
|
||||
views.setViewVisibility(R.id.second_row_rect, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.empty_layout_rect, View.GONE)
|
||||
views.setViewVisibility(R.id.calendar_layout_rect, View.VISIBLE)
|
||||
views.setOnClickPendingIntent(R.id.next_event_rect, calPIntent)
|
||||
|
||||
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_small_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_medium_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
views.setViewVisibility(
|
||||
R.id.second_row_top_margin_large_sans,
|
||||
if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
@ -534,6 +569,10 @@ class MainWidget : AppWidgetProvider() {
|
||||
|
||||
v.empty_layout.visibility = View.GONE
|
||||
v.calendar_layout.visibility = View.VISIBLE
|
||||
|
||||
v.second_row_top_margin_small.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_medium.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_large.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
} else if (GlanceProviderHelper.showGlanceProviders(context)) {
|
||||
v.second_row_icon.isVisible = true
|
||||
var showSomething = false
|
||||
@ -612,6 +651,10 @@ class MainWidget : AppWidgetProvider() {
|
||||
v.next_event.text = DateHelper.getDateText(context, now)
|
||||
v.empty_layout.visibility = View.GONE
|
||||
v.calendar_layout.visibility = View.VISIBLE
|
||||
|
||||
v.second_row_top_margin_small.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.SMALL.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_medium.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.MEDIUM.value) View.VISIBLE else View.GONE
|
||||
v.second_row_top_margin_large.visibility = if (Preferences.secondRowTopMargin == Constants.SecondRowTopMargin.LARGE.value) View.VISIBLE else View.GONE
|
||||
} else {
|
||||
v.second_row_icon.isVisible = false
|
||||
}
|
||||
|
@ -227,6 +227,43 @@
|
||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/action_second_row_top_margin_size"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/round_format_line_spacing"
|
||||
app:tint="@color/colorPrimaryText"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AnotherWidget.Settings.Title"
|
||||
android:text="@string/settings_secondary_row_top_margin_title"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/second_row_top_margin_label"
|
||||
style="@style/AnotherWidget.Settings.Subtitle"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -133,6 +133,24 @@
|
||||
android:id="@+id/special_temp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/second_row_top_margin_small" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/second_row_top_margin_medium" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="12dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/second_row_top_margin_large" />
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -128,6 +128,24 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/special_weather_rect" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/second_row_top_margin_small_sans" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/second_row_top_margin_medium_sans" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="12dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/second_row_top_margin_large_sans" />
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -26,6 +26,7 @@
|
||||
<string name="action_capitalize_the_date">Data maiuscola</string>
|
||||
<string name="settings_date_format_title">Formato data</string>
|
||||
<string name="header_widget_background">Sfondo widget</string>
|
||||
<string name="settings_secondary_row_top_margin_title">Margine</string>
|
||||
|
||||
<!-- Calendar -->
|
||||
<string name="settings_calendar_title">Calendario</string>
|
||||
|
@ -28,6 +28,7 @@
|
||||
<string name="action_capitalize_the_date">Capitalize the date</string>
|
||||
<string name="settings_date_format_title">Date format</string>
|
||||
<string name="header_widget_background">Widget background</string>
|
||||
<string name="settings_secondary_row_top_margin_title">Margin</string>
|
||||
|
||||
<!-- Calendar -->
|
||||
<string name="settings_calendar_title">Calendar</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user