Update main design

This commit is contained in:
Tommaso Berlose 2021-01-05 10:46:12 +01:00
parent 0aec34dcd2
commit 6b6ec633ee
24 changed files with 838 additions and 437 deletions

Binary file not shown.

82
.idea/navEditor.xml generated
View File

@ -46,6 +46,88 @@
</LayoutPositions>
</value>
</entry>
<entry key="settings_nav_graph.xml">
<value>
<LayoutPositions>
<option name="myPositions">
<map>
<entry key="calendarTabFragment">
<value>
<LayoutPositions>
<option name="myPosition">
<Point>
<option name="x" value="190" />
<option name="y" value="4" />
</Point>
</option>
</LayoutPositions>
</value>
</entry>
<entry key="clockTabFragment">
<value>
<LayoutPositions>
<option name="myPosition">
<Point>
<option name="x" value="494" />
<option name="y" value="302" />
</Point>
</option>
</LayoutPositions>
</value>
</entry>
<entry key="generalTabFragment">
<value>
<LayoutPositions>
<option name="myPosition">
<Point>
<option name="x" value="-48" />
<option name="y" value="133" />
</Point>
</option>
</LayoutPositions>
</value>
</entry>
<entry key="glanceTabFragment">
<value>
<LayoutPositions>
<option name="myPosition">
<Point>
<option name="x" value="2" />
<option name="y" value="-198" />
</Point>
</option>
</LayoutPositions>
</value>
</entry>
<entry key="tabSelectorFragment">
<value>
<LayoutPositions>
<option name="myPosition">
<Point>
<option name="x" value="-537" />
<option name="y" value="216" />
</Point>
</option>
</LayoutPositions>
</value>
</entry>
<entry key="weatherTabFragment">
<value>
<LayoutPositions>
<option name="myPosition">
<Point>
<option name="x" value="-301" />
<option name="y" value="-160" />
</Point>
</option>
</LayoutPositions>
</value>
</entry>
</map>
</option>
</LayoutPositions>
</value>
</entry>
</map>
</option>
</component>

View File

@ -77,6 +77,7 @@ dependencies {
implementation 'androidx.browser:browser:1.3.0'
implementation 'net.idik:slimadapter:2.1.2'
implementation 'com.google.android:flexbox:2.0.1'
implementation 'com.kyleduo.switchbutton:library:2.0.3'
// Lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

View File

@ -13,7 +13,7 @@
<uses-permission android:name="android.gms.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<application
android:allowBackup="true"
@ -163,5 +163,8 @@
<queries>
<package android:name="com.google.android.apps.fitness"/>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
</queries>
</manifest>

View File

@ -68,6 +68,12 @@ class MainActivity : AppCompatActivity() {
R.id.content_fragment
)
}
private val settingsNavController: NavController? by lazy {
Navigation.findNavController(
this,
R.id.settings_fragment
)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -83,11 +89,13 @@ class MainActivity : AppCompatActivity() {
override fun onBackPressed() {
if (mainNavController?.currentDestination?.id == R.id.appMainFragment) {
if (mAppWidgetId > 0) {
addNewWidget()
} else {
setResult(Activity.RESULT_OK)
finish()
if (settingsNavController?.navigateUp() == false) {
if (mAppWidgetId > 0) {
addNewWidget()
} else {
setResult(Activity.RESULT_OK)
finish()
}
}
} else {
super.onBackPressed()

View File

@ -15,6 +15,7 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.chibatching.kotpref.bulk
import com.google.android.material.transition.MaterialSharedAxis
import com.karumi.dexter.Dexter
import com.karumi.dexter.MultiplePermissionsReport
import com.karumi.dexter.PermissionToken
@ -52,6 +53,8 @@ class CalendarTabFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}
override fun onCreateView(
@ -88,21 +91,6 @@ class CalendarTabFragment : Fragment() {
binding.isCalendarEnabled = Preferences.showEvents
binding.isDiffEnabled = Preferences.showDiffTime || !Preferences.showEvents
viewModel.showEvents.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
binding.isCalendarEnabled = it
if (it) {
CalendarHelper.setEventUpdatesAndroidN(requireContext())
} else {
CalendarHelper.removeEventUpdatesAndroidN(requireContext())
}
binding.isDiffEnabled = Preferences.showDiffTime || !it
}
checkReadEventsPermission()
updateCalendar()
})
viewModel.calendarAllDay.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
all_day_label?.text =
@ -175,20 +163,6 @@ class CalendarTabFragment : Fragment() {
private fun setupListener() {
action_show_events.setOnClickListener {
Preferences.showEvents = !Preferences.showEvents
if (Preferences.showEvents) {
requirePermission()
}
}
show_events_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showEvents = enabled
if (Preferences.showEvents) {
requirePermission()
}
}
action_filter_calendar.setOnClickListener {
val calendarSelectorList: List<CalendarSelector> = CalendarHelper.getCalendarList(requireContext()).map {
CalendarSelector(
@ -380,51 +354,12 @@ class CalendarTabFragment : Fragment() {
}
}
private fun checkReadEventsPermission(showEvents: Boolean = Preferences.showEvents) {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
show_events_label?.text = if (showEvents) getString(R.string.show_events_visible) else getString(R.string.show_events_not_visible)
read_calendar_permission_alert?.isVisible = false
} else {
show_events_label?.text = if (showEvents) getString(R.string.description_permission_calendar) else getString(R.string.show_events_not_visible)
read_calendar_permission_alert?.isVisible = showEvents
read_calendar_permission_alert?.setOnClickListener {
requirePermission()
}
}
}
private fun updateCalendar() {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
CalendarHelper.updateEventList(requireContext())
}
}
private fun requirePermission() {
Dexter.withContext(requireContext())
.withPermissions(
Manifest.permission.READ_CALENDAR
).withListener(object: MultiplePermissionsListener {
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
report?.let {
if (report.areAllPermissionsGranted()){
checkReadEventsPermission()
} else {
Preferences.showEvents = false
}
}
}
override fun onPermissionRationaleShouldBeShown(
permissions: MutableList<PermissionRequest>?,
token: PermissionToken?
) {
// Remember to invoke this method when the custom rationale is closed
// or just by default if you don't want to use any custom rationale.
token?.continuePermissionRequest()
}
})
.check()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK) {
when (requestCode) {

View File

@ -20,6 +20,7 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.chibatching.kotpref.bulk
import com.google.android.material.transition.MaterialSharedAxis
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
@ -58,6 +59,8 @@ class ClockTabFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}
override fun onCreateView(
@ -103,14 +106,6 @@ class ClockTabFragment : Fragment() {
small_clock_warning?.isVisible = !it
})
viewModel.showClock.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
show_clock_label?.text =
if (it) getString(R.string.show_clock_visible) else getString(R.string.show_clock_not_visible)
binding.isClockVisible = it
}
})
viewModel.clockTextSize.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
clock_text_size_label?.text = String.format("%.0fsp", it)
@ -201,14 +196,6 @@ class ClockTabFragment : Fragment() {
Preferences.showBigClockWarning = false
}
action_show_clock.setOnClickListener {
Preferences.showClock = !Preferences.showClock
}
show_clock_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showClock = enabled
}
action_clock_text_size.setOnClickListener {
if (Preferences.showClock) {
val dialog = BottomSheetMenu<Float>(

View File

@ -21,6 +21,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.chibatching.kotpref.blockingBulk
import com.chibatching.kotpref.bulk
import com.google.android.material.transition.MaterialSharedAxis
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.components.BottomSheetColorPicker
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
@ -62,7 +63,8 @@ class GeneralTabFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}
override fun onCreateView(

View File

@ -29,6 +29,7 @@ import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.common.api.ApiException
import com.google.android.material.card.MaterialCardView
import com.google.android.material.transition.MaterialSharedAxis
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.components.CustomNotesDialog
import com.tommasoberlose.anotherwidget.components.GlanceSettingsDialog
@ -65,6 +66,8 @@ class GlanceTabFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}
override fun onCreateView(
@ -354,30 +357,9 @@ class GlanceTabFragment : Fragment() {
viewModel: MainViewModel,
) {
binding.isGlanceVisible = Preferences.showGlance
viewModel.showGlance.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
binding.isGlanceVisible = it
show_glance_label.text =
if (it) getString(R.string.description_show_glance_visible) else getString(
R.string.description_show_glance_not_visible)
}
})
}
private fun setupListener() {
action_show_glance.setOnClickListener {
Preferences.showGlance = !Preferences.showGlance
}
show_glance_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showGlance = enabled
}
action_show_glance.setOnLongClickListener {
Preferences.enabledGlanceProviderOrder = ""
true
}
}
private val nextAlarmChangeBroadcastReceiver = object : BroadcastReceiver() {

View File

@ -22,6 +22,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.google.android.material.badge.BadgeDrawable
import com.google.android.material.tabs.TabLayoutMediator
@ -72,20 +73,6 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
// Viewpager
pager.adapter = ViewPagerAdapter(requireActivity())
pager.offscreenPageLimit = 4
TabLayoutMediator(tabs, pager) { tab, position ->
tab.text = when (position) {
0 -> getString(R.string.settings_general_title)
1 -> getString(R.string.settings_calendar_title)
2 -> getString(R.string.settings_weather_title)
3 -> getString(R.string.settings_clock_title)
4 -> getString(R.string.settings_at_a_glance_title)
else -> ""
}
}.attach()
// Init clock
if (Preferences.showClock) {
time.setTextColor(ColorHelper.getClockFontColor(activity?.isDarkTheme() == true))
@ -126,6 +113,7 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
preview?.clearAnimation()
time_container?.clearAnimation()
bottom_padding.isVisible = Preferences.showPreview
if (Preferences.showPreview) {
preview?.setCardBackgroundColor(
@ -293,9 +281,6 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
}.start()
}
}
showErrorBadge()
}
private fun subscribeUi(viewModel: MainViewModel) {
@ -337,43 +322,10 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
}
}
private fun showErrorBadge() {
// Calendar error indicator
tabs?.getTabAt(1)?.orCreateBadge?.apply {
backgroundColor = ContextCompat.getColor(requireContext(), R.color.errorColorText)
badgeGravity = BadgeDrawable.TOP_END
}?.isVisible = Preferences.showEvents && activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) != true
// Weather error indicator
tabs?.getTabAt(2)?.orCreateBadge?.apply {
backgroundColor = ContextCompat.getColor(requireContext(), R.color.errorColorText)
badgeGravity = BadgeDrawable.TOP_END
}?.isVisible = if (Preferences.showWeather) {
(WeatherHelper.isKeyRequired() && WeatherHelper.getApiKey() == "")
|| (Preferences.customLocationAdd == "" && activity?.checkGrantedPermission(
Manifest.permission.ACCESS_FINE_LOCATION
) != true)
|| (Preferences.weatherProviderError != "" && Preferences.weatherProviderError != "-")
|| (Preferences.weatherProviderLocationError != "")
} else {
false
}
// Glance error indicator
tabs?.getTabAt(4)?.orCreateBadge?.apply {
backgroundColor = ContextCompat.getColor(requireContext(), R.color.errorColorText)
badgeGravity = BadgeDrawable.TOP_END
}?.isVisible = ((Preferences.showMusic || Preferences.showNotifications) && !ActiveNotificationsHelper.checkNotificationAccess(requireContext())) ||
(Preferences.showDailySteps && !(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || requireActivity().checkGrantedPermission(Manifest.permission.ACTIVITY_RECOGNITION))) ||
(AlarmHelper.isAlarmProbablyWrong(requireContext())) ||
(Preferences.showEventsAsGlanceProvider && (!Preferences.showEvents || !requireContext().checkGrantedPermission(Manifest.permission.READ_CALENDAR)))
}
override fun onResume() {
super.onResume()
Preferences.preferences.registerOnSharedPreferenceChangeListener(this)
EventBus.getDefault().register(this)
showErrorBadge()
updateUI()
}
@ -409,11 +361,4 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onMessageEvent(event: ChangeTabEvent?) {
event?.let {
pager.setCurrentItem(event.page, true)
}
}
}

View File

@ -0,0 +1,249 @@
package com.tommasoberlose.anotherwidget.ui.fragments
import android.Manifest
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.provider.CalendarContract
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.navigation.Navigation
import androidx.navigation.findNavController
import com.chibatching.kotpref.bulk
import com.google.android.material.transition.MaterialSharedAxis
import com.karumi.dexter.Dexter
import com.karumi.dexter.MultiplePermissionsReport
import com.karumi.dexter.PermissionToken
import com.karumi.dexter.listener.PermissionRequest
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
import com.tommasoberlose.anotherwidget.components.MaterialBottomSheetDialog
import com.tommasoberlose.anotherwidget.databinding.FragmentTabSelectorBinding
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.global.RequestCode
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
import com.tommasoberlose.anotherwidget.helpers.IntentHelper
import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
import com.tommasoberlose.anotherwidget.models.CalendarSelector
import com.tommasoberlose.anotherwidget.receivers.WeatherReceiver
import com.tommasoberlose.anotherwidget.ui.activities.ChooseApplicationActivity
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
import com.tommasoberlose.anotherwidget.utils.*
import kotlinx.android.synthetic.main.fragment_tab_selector.*
import kotlinx.android.synthetic.main.fragment_tab_selector.scrollView
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
class TabSelectorFragment : Fragment() {
companion object {
fun newInstance() = TabSelectorFragment()
}
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java)
val binding = DataBindingUtil.inflate<FragmentTabSelectorBinding>(inflater, R.layout.fragment_tab_selector, container, false)
subscribeUi(binding, viewModel)
binding.lifecycleOwner = this
binding.viewModel = viewModel
return binding.root
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setupListener()
}
private fun subscribeUi(
binding: FragmentTabSelectorBinding,
viewModel: MainViewModel
) {
binding.isCalendarEnabled = Preferences.showEvents
binding.isWeatherVisible = Preferences.showWeather
binding.isClockVisible = Preferences.showClock
binding.isGlanceVisible = Preferences.showGlance
viewModel.showEvents.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
binding.isCalendarEnabled = it
if (it) {
CalendarHelper.setEventUpdatesAndroidN(requireContext())
} else {
CalendarHelper.removeEventUpdatesAndroidN(requireContext())
}
}
checkReadEventsPermission()
updateCalendar()
})
viewModel.showWeather.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
binding.isWeatherVisible = it
}
checkLocationPermission()
})
viewModel.showClock.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
binding.isClockVisible = it
}
})
viewModel.showGlance.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
binding.isGlanceVisible = it
}
})
}
private fun setupListener() {
action_general_settings.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_generalTabFragment)
}
action_show_events.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_calendarTabFragment)
}
show_events_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showEvents = enabled
if (Preferences.showEvents) {
requirePermission()
}
}
action_show_weather.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_weatherTabFragment)
}
show_weather_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showWeather = enabled
}
action_show_clock.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_clockTabFragment)
}
show_clock_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showClock = enabled
}
action_show_glance.setOnClickListener {
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_glanceTabFragment)
}
show_glance_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showGlance = enabled
}
}
private fun checkReadEventsPermission(showEvents: Boolean = Preferences.showEvents) {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
} else {
}
}
private fun updateCalendar() {
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
CalendarHelper.updateEventList(requireContext())
}
}
private fun requirePermission() {
Dexter.withContext(requireContext())
.withPermissions(
Manifest.permission.READ_CALENDAR
).withListener(object: MultiplePermissionsListener {
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
report?.let {
if (report.areAllPermissionsGranted()){
checkReadEventsPermission()
} else {
Preferences.showEvents = false
}
}
}
override fun onPermissionRationaleShouldBeShown(
permissions: MutableList<PermissionRequest>?,
token: PermissionToken?
) {
// Remember to invoke this method when the custom rationale is closed
// or just by default if you don't want to use any custom rationale.
token?.continuePermissionRequest()
}
})
.check()
}
private fun checkLocationPermission() {
if (requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
WeatherReceiver.setUpdates(requireContext())
} else if (Preferences.showWeather && Preferences.customLocationAdd == "") {
MaterialBottomSheetDialog(requireContext(), message = getString(R.string.background_location_warning))
.setPositiveButton(getString(android.R.string.ok)) {
requirePermission()
}
.show()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK) {
when (requestCode) {
RequestCode.CALENDAR_APP_REQUEST_CODE.code -> {
Preferences.bulk {
calendarAppName = data?.getStringExtra(Constants.RESULT_APP_NAME) ?: getString(
R.string.default_calendar_app)
calendarAppPackage = data?.getStringExtra(Constants.RESULT_APP_PACKAGE) ?: ""
}
}
RequestCode.EVENT_APP_REQUEST_CODE.code -> {
Preferences.bulk {
eventAppName = data?.getStringExtra(Constants.RESULT_APP_NAME) ?: getString(
R.string.default_event_app)
eventAppPackage = data?.getStringExtra(Constants.RESULT_APP_PACKAGE) ?: ""
}
}
}
}
super.onActivityResult(requestCode, resultCode, data)
}
private fun maintainScrollPosition(callback: () -> Unit) {
scrollView.isScrollable = false
callback.invoke()
lifecycleScope.launch {
delay(200)
scrollView.isScrollable = true
}
}
}

View File

@ -18,6 +18,7 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.chibatching.kotpref.bulk
import com.google.android.material.transition.MaterialSharedAxis
import com.karumi.dexter.Dexter
import com.karumi.dexter.MultiplePermissionsReport
import com.karumi.dexter.PermissionToken
@ -59,6 +60,8 @@ class WeatherTabFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}
override fun onCreateView(
@ -79,7 +82,6 @@ class WeatherTabFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setupListener()
}
@ -89,17 +91,6 @@ class WeatherTabFragment : Fragment() {
) {
binding.isWeatherVisible = Preferences.showWeather
viewModel.showWeather.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
show_weather_label?.text =
if (it) getString(R.string.show_weather_visible) else getString(R.string.show_weather_not_visible)
checkWeatherProviderConfig()
binding.isWeatherVisible = it
}
checkLocationPermission()
checkWeatherProviderConfig()
})
viewModel.weatherProvider.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
label_weather_provider.text = WeatherHelper.getProviderName(requireContext(), Constants.WeatherProvider.fromInt(it)!!)
@ -197,13 +188,6 @@ class WeatherTabFragment : Fragment() {
}
private fun setupListener() {
action_show_weather.setOnClickListener {
Preferences.showWeather = !Preferences.showWeather
}
show_weather_switch.setOnCheckedChangeListener { _, enabled: Boolean ->
Preferences.showWeather = enabled
}
action_weather_provider.setOnClickListener {
if (Preferences.showWeather) {

View File

@ -63,7 +63,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="2dp"
app:cardCornerRadius="0dp"
style="@style/CustomCardViewStyle"
app:cardBackgroundColor="@color/colorPrimary">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"

View File

@ -5,16 +5,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="?android:attr/colorPrimary"
android:background="?android:attr/colorPrimaryDark"
tools:context=".ui.activities.MainActivity">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:cardElevation="2dp"
app:cardCornerRadius="0dp"
android:id="@+id/toolbar"
android:transitionName="@string/toolbar_transition_name"
style="@style/CustomCardViewStyle"
app:cardBackgroundColor="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
@ -72,6 +72,7 @@
app:cardBackgroundColor="@color/colorPrimary"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="9dp"
app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatImageView
@ -103,43 +104,26 @@
android:id="@+id/widget_loader" />
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
app:tabGravity="start"
app:tabIndicatorColor="@color/colorAccent"
app:tabBackground="@color/colorPrimary"
app:tabIndicatorFullWidth="false"
app:tabMode="scrollable"
app:tabIndicatorHeight="3dp"
app:tabUnboundedRipple="true"
app:tabRippleColor="@color/colorPrimary"
app:tabTextColor="@color/colorSecondaryText"
app:tabSelectedTextColor="@color/colorAccent"
app:tabIndicator="@drawable/custom_tab_indicator"
app:tabPadding="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clipToPadding="false"
app:tabMinWidth="110dp"
app:tabMaxWidth="0dp"
android:background="@color/colorPrimary"
app:tabTextAppearance="@style/AnotherWidget.Settings.Header" />
android:layout_height="16dp"
android:orientation="vertical"
android:id="@+id/bottom_padding" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:defaultNavHost="true"
app:navGraph="@navigation/settings_nav_graph"
android:layout_width="match_parent"
android:elevation="0dp"
android:layout_height="match_parent" />
</RelativeLayout>
android:layout_height="match_parent"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -25,72 +25,11 @@
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
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_show_events"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_today_24"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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/title_permission_calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_events_label"
android:text="@string/description_permission_calendar"
style="@style/AnotherWidget.Settings.Subtitle"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="36dp"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:letterSpacing="0"
android:textAllCaps="false"
android:clickable="true"
android:layout_marginStart="-8dp"
android:layout_marginBottom="-8dp"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:focusable="true"
android:id="@+id/read_calendar_permission_alert"
android:textColor="@color/errorColorText"
android:text="@string/action_grant_permission"/>
</LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:checked="@{isCalendarEnabled}"
android:id="@+id/show_events_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/calendar_settings"
android:alpha="@{isCalendarEnabled ? 1f : 0.2f, default=1}"
android:alpha="@{isCalendarEnabled ? 1f : 1f, default=1}"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"

View File

@ -68,56 +68,11 @@
android:layout_gravity="end" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
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_show_clock"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_schedule_24"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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/title_show_clock"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_clock_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:checked="@{isClockVisible}"
android:id="@+id/show_clock_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/clock_settings"
android:alpha="@{isClockVisible ? 1f : 0.2f, default=1}"
android:alpha="@{isClockVisible ? 1f : 1f, default=1}"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"

View File

@ -30,7 +30,6 @@
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="@color/colorAccent"
android:textAppearance="@style/AnotherWidget.Settings.Header"
app:textAllCaps="false" />
<LinearLayout
@ -51,7 +50,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_text_fields_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -88,7 +87,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_palette_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
@ -147,7 +146,7 @@
android:layout_height="48dp"
android:padding="10dp"
android:src="@drawable/round_text_format_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -174,7 +173,6 @@
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="@color/colorAccent"
android:textAppearance="@style/AnotherWidget.Settings.Header"
app:textAllCaps="false" />
<LinearLayout
@ -195,7 +193,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_text_fields_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -232,7 +230,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_palette_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
@ -291,7 +289,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_format_line_spacing"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -318,7 +316,6 @@
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="@color/colorAccent"
android:textAppearance="@style/AnotherWidget.Settings.Header"
app:textAllCaps="false" />
<LinearLayout
@ -339,7 +336,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_texture_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
@ -398,7 +395,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_font_download_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -436,7 +433,7 @@
android:padding="12dp"
android:src="@drawable/round_vertical_align_center_24"
android:rotation="90"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
@ -470,7 +467,6 @@
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="@color/colorAccent"
android:textAppearance="@style/AnotherWidget.Settings.Header"
app:textAllCaps="false" />
<LinearLayout
@ -491,7 +487,7 @@
android:layout_height="48dp"
android:padding="12dp"
android:src="@drawable/round_aspect_ratio_24"
app:tint="@color/colorPrimaryText"/>
app:tint="@color/colorAccent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"

View File

@ -22,56 +22,11 @@
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
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_show_glance"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="10dp"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_pageview"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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/title_show_glance"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_glance_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:checked="@{isGlanceVisible}"
android:id="@+id/show_glance_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/calendar_settings"
android:alpha="@{isGlanceVisible ? 1f : 0.2f, default=1}"
android:alpha="@{isGlanceVisible ? 1f : 1f, default=1}"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"

View File

@ -0,0 +1,382 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel" />
<variable
name="isCalendarEnabled"
type="Boolean" />
<variable
name="isWeatherVisible"
type="Boolean" />
<variable
name="isClockVisible"
type="Boolean" />
<variable
name="isGlanceVisible"
type="Boolean" />
<import type="android.view.View" />
</data>
<com.tommasoberlose.anotherwidget.components.FixedFocusScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:scrollbarThumbVertical="@color/colorPrimary"
android:background="@color/colorPrimaryDark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apperances"
android:paddingTop="16dp"
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="@color/colorAccent"
android:textAppearance="@style/AnotherWidget.Settings.Header"
app:textAllCaps="false" />
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
app:strokeColor="@color/cardBorder"
app:strokeWidth="1dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_general_settings"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/round_palette_24"
app:tint="@color/colorPrimaryText"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
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="Look &amp; feel"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change the widget design"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="8dp"
android:src="@drawable/round_chevron_right_24"
app:tint="@color/colorPrimaryText"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:text="Content"
android:textColor="@color/colorAccent"
android:textAlignment="viewStart"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textAppearance="@style/AnotherWidget.Settings.Header"
app:textAllCaps="false" />
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
app:strokeColor="@color/cardBorder"
app:strokeWidth="1dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_show_events"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_today_24"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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="Calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change the widget design"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/cardBorder"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:alpha="0.6" />
<com.kyleduo.switchbutton.SwitchButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:checked="@{isCalendarEnabled}"
app:kswBackRadius="16dp"
app:kswTintColor="@color/colorAccent"
android:id="@+id/show_events_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
app:strokeColor="@color/cardBorder"
app:strokeWidth="1dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_show_weather"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:id="@+id/weather_icon_pack"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_brightness_5_24"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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="Weather"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change the widget design"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/cardBorder"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:alpha="0.6" />
<com.kyleduo.switchbutton.SwitchButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:kswBackRadius="16dp"
app:kswTintColor="@color/colorAccent"
android:checked="@{isWeatherVisible}"
android:id="@+id/show_weather_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
app:strokeColor="@color/cardBorder"
app:strokeWidth="1dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_show_clock"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_schedule_24"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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="Clock"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change the clock "
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/cardBorder"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:alpha="0.6" />
<com.kyleduo.switchbutton.SwitchButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:kswBackRadius="16dp"
app:kswTintColor="@color/colorAccent"
android:checked="@{isClockVisible}"
android:id="@+id/show_clock_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
app:strokeColor="@color/cardBorder"
app:strokeWidth="1dp"
app:cardBackgroundColor="@color/colorPrimaryDark"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingStart="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_show_glance"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="10dp"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_pageview"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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="Glance"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change glace info"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/cardBorder"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:alpha="0.6" />
<com.kyleduo.switchbutton.SwitchButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:kswBackRadius="16dp"
app:kswTintColor="@color/colorAccent"
android:checked="@{isGlanceVisible}"
android:id="@+id/show_glance_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</com.tommasoberlose.anotherwidget.components.FixedFocusScrollView>
</layout>

View File

@ -21,58 +21,11 @@
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
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_show_weather"
android:orientation="horizontal">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:id="@+id/weather_icon_pack"
app:tint="@color/colorPrimaryText"
android:src="@drawable/round_brightness_5_24"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
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/title_permission_location"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_weather_label"
android:text="@string/description_permission_location"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:checked="@{isWeatherVisible}"
android:id="@+id/show_weather_switch"
android:buttonTint="@color/colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/weather_settings"
android:alpha="@{isWeatherVisible ? 1f : 0.2f, default=1}"
android:alpha="@{isWeatherVisible ? 1f : 1f, default=1}"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/settings_nav_graph"
app:startDestination="@id/tabSelectorFragment">
<fragment
android:id="@+id/calendarTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.CalendarTabFragment"
android:label="CalendarTabFragment" />
<fragment
android:id="@+id/clockTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.ClockTabFragment"
android:label="ClockTabFragment" />
<fragment
android:id="@+id/glanceTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.GlanceTabFragment"
android:label="GlanceTabFragment" />
<fragment
android:id="@+id/generalTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.GeneralTabFragment"
android:label="GeneralTabFragment" />
<fragment
android:id="@+id/weatherTabFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.WeatherTabFragment"
android:label="WeatherTabFragment" />
<fragment
android:id="@+id/tabSelectorFragment"
android:name="com.tommasoberlose.anotherwidget.ui.fragments.TabSelectorFragment"
android:label="TabSelectorFragment" >
<action
android:id="@+id/action_tabSelectorFragment_to_generalTabFragment"
app:destination="@id/generalTabFragment" />
<action
android:id="@+id/action_tabSelectorFragment_to_weatherTabFragment"
app:destination="@id/weatherTabFragment" />
<action
android:id="@+id/action_tabSelectorFragment_to_glanceTabFragment"
app:destination="@id/glanceTabFragment" />
<action
android:id="@+id/action_tabSelectorFragment_to_calendarTabFragment"
app:destination="@id/calendarTabFragment" />
<action
android:id="@+id/action_tabSelectorFragment_to_clockTabFragment"
app:destination="@id/clockTabFragment" />
</fragment>
</navigation>

View File

@ -25,4 +25,5 @@
<!-- <color name="disabledButtonBackground">#131D28</color>-->
<color name="disabledButtonBackground">#33000000</color>
<color name="badgeBackground">#202020</color>
<color name="cardBorder">#252525</color>
</resources>

View File

@ -34,5 +34,6 @@
<color name="disabledButtonBackground">#efefef</color>
<color name="success">#43A047</color>
<color name="badgeBackground">#efefef</color>
<color name="cardBorder">#DADADA</color>
</resources>

View File

@ -72,7 +72,7 @@
</style>
<style name="AnotherWidget.Settings.Header" parent="TextAppearance.AppCompat.Medium">
<item name="android:textColor">@color/colorPrimaryText</item>
<item name="android:textColor">@color/colorSecondaryText</item>
<item name="android:textSize">15sp</item>
<item name="android:textStyle">bold</item>
<item name="android:fontFamily">@font/google_sans</item>
@ -150,5 +150,16 @@
<style name="BottomSheetDialogTheme" parent="BaseBottomSheetDialog" />
<style name="CustomCardViewStyle" parent="@style/Widget.MaterialComponents.CardView">
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.MaterialCardView.Cut</item>
</style>
<style name="ShapeAppearanceOverlay.MaterialCardView.Cut" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopRight">0dp</item>
<item name="cornerSizeTopLeft">0dp</item>
<item name="cornerSizeBottomRight">24dp</item>
<item name="cornerSizeBottomLeft">24dp</item>
</style>
</resources>