Compare commits
3 Commits
v2.2.1
...
v2.2.2-bet
Author | SHA1 | Date | |
---|---|---|---|
d2087d094f | |||
34fb35f2ab | |||
108ecdece0 |
BIN
.idea/caches/build_file_checksums.ser
generated
@ -22,8 +22,8 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 118
|
||||
versionName "2.2.1"
|
||||
versionCode 119
|
||||
versionName "2.2.2"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
buildConfigField("String", "GOOGLE_API_KEY", apikeyProperties['GOOGLE_API_KEY'])
|
||||
|
@ -150,9 +150,9 @@
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".services.UpdateCalendarJob"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"
|
||||
android:exported="true"/>
|
||||
android:name=".services.UpdateCalendarService"
|
||||
android:enabled="true"
|
||||
android:exported="false"/>
|
||||
<service
|
||||
android:name=".services.LocationService"
|
||||
android:enabled="true"
|
||||
|
@ -1,29 +1,16 @@
|
||||
package com.tommasoberlose.anotherwidget.helpers
|
||||
|
||||
import android.Manifest
|
||||
import android.app.job.JobInfo
|
||||
import android.app.job.JobParameters
|
||||
import android.app.job.JobScheduler
|
||||
import android.app.job.JobService
|
||||
import android.content.ComponentName
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.CalendarContract
|
||||
import android.util.Log
|
||||
import com.tommasoberlose.anotherwidget.services.EventListenerJob
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.services.UpdateCalendarJob
|
||||
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.services.UpdateCalendarService
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import me.everything.providers.android.calendar.CalendarProvider
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
import kotlin.Comparator
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
@ -32,7 +19,7 @@ import kotlin.collections.ArrayList
|
||||
|
||||
object CalendarHelper {
|
||||
fun updateEventList(context: Context) {
|
||||
UpdateCalendarJob.enqueueWork(context, Intent())
|
||||
UpdateCalendarService.enqueueWork(context)
|
||||
}
|
||||
|
||||
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {
|
||||
|
@ -63,10 +63,20 @@ object SettingsStringHelper {
|
||||
}
|
||||
|
||||
fun getVariantLabel(context: Context, variant: String): String = when {
|
||||
variant == "italic" -> context.getString(R.string.font_italic)
|
||||
variant.contains("100") && variant.contains("italic") -> context.getString(R.string.font_100_italic)
|
||||
variant.contains("200") && variant.contains("italic") -> context.getString(R.string.font_200_italic)
|
||||
variant.contains("300") && variant.contains("italic") -> context.getString(R.string.font_300_italic)
|
||||
variant.contains("400") && variant.contains("italic") -> context.getString(R.string.font_400_italic)
|
||||
variant.contains("500") && variant.contains("italic") -> context.getString(R.string.font_500_italic)
|
||||
variant.contains("600") && variant.contains("italic") -> context.getString(R.string.font_600_italic)
|
||||
variant.contains("700") && variant.contains("italic") -> context.getString(R.string.font_700_italic)
|
||||
variant.contains("800") && variant.contains("italic") -> context.getString(R.string.font_800_italic)
|
||||
variant.contains("900") && variant.contains("italic") -> context.getString(R.string.font_900_italic)
|
||||
variant == "regular" || variant.contains("400") -> context.getString(R.string.font_400)
|
||||
variant.contains("100") -> context.getString(R.string.font_100)
|
||||
variant.contains("200") -> context.getString(R.string.font_200)
|
||||
variant.contains("300") -> context.getString(R.string.font_300)
|
||||
variant.contains("regular") || variant.contains("400") -> context.getString(R.string.font_400)
|
||||
variant.contains("500") -> context.getString(R.string.font_500)
|
||||
variant.contains("600") -> context.getString(R.string.font_600)
|
||||
variant.contains("700") -> context.getString(R.string.font_700)
|
||||
|
@ -2,6 +2,7 @@ package com.tommasoberlose.anotherwidget.network
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.chibatching.kotpref.Kotpref
|
||||
import com.google.gson.internal.LinkedTreeMap
|
||||
import com.haroldadmin.cnradapter.NetworkResponse
|
||||
import com.haroldadmin.cnradapter.executeWithRetry
|
||||
@ -26,6 +27,7 @@ import java.util.*
|
||||
|
||||
class WeatherNetworkApi(val context: Context) {
|
||||
suspend fun updateWeather() {
|
||||
Kotpref.init(context)
|
||||
Preferences.weatherProviderError = "-"
|
||||
Preferences.weatherProviderLocationError = ""
|
||||
|
||||
|
@ -26,7 +26,7 @@ import kotlin.collections.ArrayList
|
||||
|
||||
class LocationService : Service() {
|
||||
|
||||
private val jobs: ArrayList<Job> = ArrayList()
|
||||
private var job: Job? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
@ -34,13 +34,13 @@ class LocationService : Service() {
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
|
||||
jobs += GlobalScope.launch(Dispatchers.IO) {
|
||||
job?.cancel()
|
||||
job = GlobalScope.launch(Dispatchers.IO) {
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
this@LocationService,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
LocationServices.getFusedLocationProviderClient(this@LocationService).lastLocation.addOnCompleteListener { task ->
|
||||
val networkApi = WeatherNetworkApi(this@LocationService)
|
||||
if (task.isSuccessful) {
|
||||
@ -67,18 +67,17 @@ class LocationService : Service() {
|
||||
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stopSelf()
|
||||
}
|
||||
} else {
|
||||
stopSelf()
|
||||
}
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
jobs.forEach {
|
||||
it.cancel()
|
||||
}
|
||||
job?.cancel()
|
||||
job = null
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -1,153 +0,0 @@
|
||||
package com.tommasoberlose.anotherwidget.services
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.CalendarContract
|
||||
import android.util.Log
|
||||
import androidx.core.app.JobIntentService
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper.applyFilters
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper.sortEvents
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import me.everything.providers.android.calendar.CalendarProvider
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
import kotlin.Comparator
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class UpdateCalendarJob : JobIntentService() {
|
||||
|
||||
companion object {
|
||||
private const val jobId = 1200
|
||||
|
||||
fun enqueueWork(context: Context, work: Intent) {
|
||||
enqueueWork(context, UpdateCalendarJob::class.java, jobId, work)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHandleWork(intent: Intent) {
|
||||
val eventRepository = EventRepository(this)
|
||||
if (Preferences.showEvents) {
|
||||
val eventList = ArrayList<Event>()
|
||||
|
||||
val now = Calendar.getInstance()
|
||||
val begin = Calendar.getInstance().apply {
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
set(Calendar.SECOND, 0)
|
||||
set(Calendar.MINUTE, 0)
|
||||
set(Calendar.HOUR_OF_DAY, 0)
|
||||
}
|
||||
val limit = Calendar.getInstance().apply {
|
||||
when (Preferences.showUntil) {
|
||||
0 -> add(Calendar.HOUR, 3)
|
||||
1 -> add(Calendar.HOUR, 6)
|
||||
2 -> add(Calendar.HOUR, 12)
|
||||
3 -> add(Calendar.DAY_OF_MONTH, 1)
|
||||
4 -> add(Calendar.DAY_OF_MONTH, 3)
|
||||
5 -> add(Calendar.DAY_OF_MONTH, 7)
|
||||
6 -> add(Calendar.MINUTE, 30)
|
||||
7 -> add(Calendar.HOUR, 1)
|
||||
else -> add(Calendar.HOUR, 6)
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkGrantedPermission(
|
||||
Manifest.permission.READ_CALENDAR
|
||||
)
|
||||
) {
|
||||
eventRepository.resetNextEventData()
|
||||
} else {
|
||||
try {
|
||||
val provider = CalendarProvider(this)
|
||||
val data = provider.getInstances(begin.timeInMillis, limit.timeInMillis)
|
||||
if (data != null) {
|
||||
val instances = data.list
|
||||
for (instance in instances) {
|
||||
try {
|
||||
val e = provider.getEvent(instance.eventId)
|
||||
if (e != null && !e.deleted && instance.begin <= limit.timeInMillis && now.timeInMillis < instance.end && !CalendarHelper.getFilteredCalendarIdList()
|
||||
.contains(e.calendarId)
|
||||
) {
|
||||
if (e.allDay) {
|
||||
val start = Calendar.getInstance()
|
||||
start.timeInMillis = instance.begin
|
||||
val end = Calendar.getInstance()
|
||||
end.timeInMillis = instance.end
|
||||
instance.begin =
|
||||
start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
|
||||
instance.end =
|
||||
end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
|
||||
}
|
||||
|
||||
// Check all day events
|
||||
val startDate = Calendar.getInstance()
|
||||
startDate.timeInMillis = instance.begin
|
||||
val endDate = Calendar.getInstance()
|
||||
endDate.timeInMillis = instance.end
|
||||
|
||||
val isAllDay = e.allDay || (
|
||||
startDate.get(Calendar.MILLISECOND) == 0
|
||||
&& startDate.get(Calendar.SECOND) == 0
|
||||
&& startDate.get(Calendar.MINUTE) == 0
|
||||
&& startDate.get(Calendar.HOUR_OF_DAY) == 0
|
||||
&& endDate.get(Calendar.MILLISECOND) == 0
|
||||
&& endDate.get(Calendar.SECOND) == 0
|
||||
&& endDate.get(Calendar.MINUTE) == 0
|
||||
&& endDate.get(Calendar.HOUR_OF_DAY) == 0
|
||||
)
|
||||
|
||||
eventList.add(
|
||||
Event(
|
||||
id = instance.id,
|
||||
eventID = e.id,
|
||||
title = e.title ?: "",
|
||||
startDate = instance.begin,
|
||||
endDate = instance.end,
|
||||
calendarID = e.calendarId.toInt(),
|
||||
allDay = isAllDay,
|
||||
address = e.eventLocation ?: "",
|
||||
selfAttendeeStatus = e.selfAttendeeStatus.toInt(),
|
||||
availability = e.availability
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val sortedEvents = eventList.sortEvents()
|
||||
val filteredEventList = sortedEvents
|
||||
.applyFilters()
|
||||
|
||||
if (filteredEventList.isEmpty()) {
|
||||
eventRepository.resetNextEventData()
|
||||
eventRepository.clearEvents()
|
||||
} else {
|
||||
eventRepository.saveEvents(
|
||||
sortedEvents
|
||||
)
|
||||
eventRepository.saveNextEventData(filteredEventList.first())
|
||||
}
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eventRepository.resetNextEventData()
|
||||
}
|
||||
|
||||
UpdatesReceiver.setUpdates(this)
|
||||
MainWidget.updateWidget(this)
|
||||
|
||||
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||
eventRepository.close()
|
||||
}
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package com.tommasoberlose.anotherwidget.services
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper.applyFilters
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper.sortEvents
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.ui.fragments.MainFragment
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import me.everything.providers.android.calendar.CalendarProvider
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class UpdateCalendarService : Service() {
|
||||
|
||||
companion object {
|
||||
fun enqueueWork(context: Context) {
|
||||
context.startService(Intent(context, UpdateCalendarService::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
private var job: Job? = null
|
||||
|
||||
override fun onBind(intent: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
job?.cancel()
|
||||
job = GlobalScope.launch(Dispatchers.IO) {
|
||||
|
||||
val eventRepository = EventRepository(this@UpdateCalendarService)
|
||||
if (Preferences.showEvents) {
|
||||
val eventList = ArrayList<Event>()
|
||||
|
||||
val now = Calendar.getInstance()
|
||||
val begin = Calendar.getInstance().apply {
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
set(Calendar.SECOND, 0)
|
||||
set(Calendar.MINUTE, 0)
|
||||
set(Calendar.HOUR_OF_DAY, 0)
|
||||
}
|
||||
val limit = Calendar.getInstance().apply {
|
||||
when (Preferences.showUntil) {
|
||||
0 -> add(Calendar.HOUR, 3)
|
||||
1 -> add(Calendar.HOUR, 6)
|
||||
2 -> add(Calendar.HOUR, 12)
|
||||
3 -> add(Calendar.DAY_OF_MONTH, 1)
|
||||
4 -> add(Calendar.DAY_OF_MONTH, 3)
|
||||
5 -> add(Calendar.DAY_OF_MONTH, 7)
|
||||
6 -> add(Calendar.MINUTE, 30)
|
||||
7 -> add(Calendar.HOUR, 1)
|
||||
else -> add(Calendar.HOUR, 6)
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkGrantedPermission(
|
||||
Manifest.permission.READ_CALENDAR
|
||||
)
|
||||
) {
|
||||
eventRepository.resetNextEventData()
|
||||
} else {
|
||||
try {
|
||||
val provider = CalendarProvider(this@UpdateCalendarService)
|
||||
val data = provider.getInstances(begin.timeInMillis, limit.timeInMillis)
|
||||
if (data != null) {
|
||||
val instances = data.list
|
||||
for (instance in instances) {
|
||||
try {
|
||||
val e = provider.getEvent(instance.eventId)
|
||||
if (e != null && !e.deleted && instance.begin <= limit.timeInMillis && now.timeInMillis < instance.end && !CalendarHelper.getFilteredCalendarIdList()
|
||||
.contains(e.calendarId)
|
||||
) {
|
||||
if (e.allDay) {
|
||||
val start = Calendar.getInstance()
|
||||
start.timeInMillis = instance.begin
|
||||
val end = Calendar.getInstance()
|
||||
end.timeInMillis = instance.end
|
||||
instance.begin =
|
||||
start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
|
||||
instance.end =
|
||||
end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
|
||||
}
|
||||
|
||||
// Check all day events
|
||||
val startDate = Calendar.getInstance()
|
||||
startDate.timeInMillis = instance.begin
|
||||
val endDate = Calendar.getInstance()
|
||||
endDate.timeInMillis = instance.end
|
||||
|
||||
val isAllDay = e.allDay || (
|
||||
startDate.get(Calendar.MILLISECOND) == 0
|
||||
&& startDate.get(Calendar.SECOND) == 0
|
||||
&& startDate.get(Calendar.MINUTE) == 0
|
||||
&& startDate.get(Calendar.HOUR_OF_DAY) == 0
|
||||
&& endDate.get(Calendar.MILLISECOND) == 0
|
||||
&& endDate.get(Calendar.SECOND) == 0
|
||||
&& endDate.get(Calendar.MINUTE) == 0
|
||||
&& endDate.get(Calendar.HOUR_OF_DAY) == 0
|
||||
)
|
||||
|
||||
eventList.add(
|
||||
Event(
|
||||
id = instance.id,
|
||||
eventID = e.id,
|
||||
title = e.title ?: "",
|
||||
startDate = instance.begin,
|
||||
endDate = instance.end,
|
||||
calendarID = e.calendarId.toInt(),
|
||||
allDay = isAllDay,
|
||||
address = e.eventLocation ?: "",
|
||||
selfAttendeeStatus = e.selfAttendeeStatus.toInt(),
|
||||
availability = e.availability
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val sortedEvents = eventList.sortEvents()
|
||||
val filteredEventList = sortedEvents
|
||||
.applyFilters()
|
||||
|
||||
if (filteredEventList.isEmpty()) {
|
||||
eventRepository.resetNextEventData()
|
||||
eventRepository.clearEvents()
|
||||
} else {
|
||||
eventRepository.saveEvents(
|
||||
sortedEvents
|
||||
)
|
||||
eventRepository.saveNextEventData(filteredEventList.first())
|
||||
}
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eventRepository.resetNextEventData()
|
||||
}
|
||||
|
||||
UpdatesReceiver.setUpdates(this@UpdateCalendarService)
|
||||
MainWidget.updateWidget(this@UpdateCalendarService)
|
||||
|
||||
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
|
||||
eventRepository.close()
|
||||
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
job?.cancel()
|
||||
job = null
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import android.graphics.Typeface
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
@ -18,6 +19,7 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chibatching.kotpref.blockingBulk
|
||||
import com.google.gson.Gson
|
||||
import com.koolio.library.Font
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.BottomSheetMenu
|
||||
@ -125,7 +127,7 @@ class CustomFontActivity : AppCompatActivity() {
|
||||
if (item.fontVariants.isEmpty()) {
|
||||
dialog.addItem(SettingsStringHelper.getVariantLabel(this, "regular"), -1)
|
||||
} else {
|
||||
item.fontVariants.filter { !it.contains("italic") }
|
||||
item.fontVariants
|
||||
.forEachIndexed { index, s ->
|
||||
dialog.addItem(SettingsStringHelper.getVariantLabel(this, s), index)
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ class MainFragment : Fragment() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Y, true)
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Y, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
@ -103,7 +103,7 @@ class MainFragment : Fragment() {
|
||||
|
||||
binding.actionSettings.setOnClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_appMainFragment_to_appSettingsFragment, null, null, FragmentNavigatorExtras(
|
||||
binding.actionBack to "action_back"
|
||||
// binding.fragmentTitle to "fragment_title"
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,9 @@ class SettingsFragment : Fragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
|
||||
// returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
|
||||
// sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move)
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Y, true)
|
||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Y, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -274,22 +274,23 @@ class GlanceTabFragment : Fragment() {
|
||||
}
|
||||
Constants.GlanceProviderId.EVENTS -> {
|
||||
isVisible =
|
||||
Preferences.showEventsAsGlanceProvider && Preferences.showEvents && requireContext().checkGrantedPermission(
|
||||
Manifest.permission.READ_CALENDAR
|
||||
)
|
||||
Preferences.showEventsAsGlanceProvider
|
||||
val hasError = !Preferences.showEvents || !requireContext().checkGrantedPermission(
|
||||
Manifest.permission.READ_CALENDAR
|
||||
)
|
||||
injector.text(
|
||||
R.id.label,
|
||||
if (isVisible) getString(R.string.settings_visible) else getString(
|
||||
if (isVisible && !hasError) getString(R.string.settings_visible) else getString(
|
||||
R.string.settings_not_visible
|
||||
)
|
||||
)
|
||||
injector.visibility(
|
||||
R.id.error_icon,
|
||||
if (isVisible) View.GONE else View.VISIBLE
|
||||
if (isVisible && hasError) View.VISIBLE else View.GONE
|
||||
)
|
||||
injector.visibility(
|
||||
R.id.info_icon,
|
||||
if (isVisible) View.VISIBLE else View.GONE
|
||||
if (!(isVisible && hasError)) View.VISIBLE else View.GONE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@ -29,7 +28,6 @@ import com.tommasoberlose.anotherwidget.ui.activities.tabs.CustomFontActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.tabs.CustomDateActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.isDarkTheme
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
|
@ -96,7 +96,6 @@ class MainViewModel(context: Application) : AndroidViewModel(context) {
|
||||
val showWallpaper = Preferences.asLiveData(Preferences::showWallpaper)
|
||||
val showPreview = Preferences.asLiveData(Preferences::showPreview)
|
||||
val installedIntegrations = Preferences.asLiveData(Preferences::installedIntegrations)
|
||||
var colorClipboard: ArrayList<String> = ArrayList()
|
||||
|
||||
// UI
|
||||
val fragmentScrollY = MutableLiveData<Int>()
|
||||
@ -169,19 +168,4 @@ class MainViewModel(context: Application) : AndroidViewModel(context) {
|
||||
|
||||
addSource(Preferences.asLiveData(Preferences::installedIntegrations)) { value = true }
|
||||
}
|
||||
|
||||
init {
|
||||
with(context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager) {
|
||||
if (hasPrimaryClip()) {
|
||||
(0..primaryClip!!.itemCount).forEach {
|
||||
try {
|
||||
val color = primaryClip!!.getItemAt(it).text.toString()
|
||||
if (color.isColor()) {
|
||||
colorClipboard.add(color)
|
||||
}
|
||||
} catch (ex: Exception) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable-night-hdpi/round_content_copy_24.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
app/src/main/res/drawable-night-hdpi/round_content_paste_24.png
Normal file
After Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
BIN
app/src/main/res/drawable-night-mdpi/round_content_copy_24.png
Normal file
After Width: | Height: | Size: 221 B |
BIN
app/src/main/res/drawable-night-mdpi/round_content_paste_24.png
Normal file
After Width: | Height: | Size: 253 B |
BIN
app/src/main/res/drawable-night-xhdpi/round_content_copy_24.png
Normal file
After Width: | Height: | Size: 344 B |
BIN
app/src/main/res/drawable-night-xhdpi/round_content_paste_24.png
Normal file
After Width: | Height: | Size: 434 B |
BIN
app/src/main/res/drawable-night-xxhdpi/round_content_copy_24.png
Normal file
After Width: | Height: | Size: 459 B |
After Width: | Height: | Size: 602 B |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 765 B |
10
app/src/main/res/drawable/round_content_copy_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M15,1L4,1c-1.1,0 -2,0.9 -2,2v13c0,0.55 0.45,1 1,1s1,-0.45 1,-1L4,4c0,-0.55 0.45,-1 1,-1h10c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM18,21L9,21c-0.55,0 -1,-0.45 -1,-1L8,8c0,-0.55 0.45,-1 1,-1h9c0.55,0 1,0.45 1,1v12c0,0.55 -0.45,1 -1,1z"/>
|
||||
</vector>
|
10
app/src/main/res/drawable/round_content_paste_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,2h-4.18C14.4,0.84 13.3,0 12,0S9.6,0.84 9.18,2L5,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,4c0,-1.1 -0.9,-2 -2,-2zM12,2c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM18,20L6,20c-0.55,0 -1,-0.45 -1,-1L5,5c0,-0.55 0.45,-1 1,-1h1v1c0,1.1 0.9,2 2,2h6c1.1,0 2,-0.9 2,-2L17,4h1c0.55,0 1,0.45 1,1v14c0,0.55 -0.45,1 -1,1z"/>
|
||||
</vector>
|
@ -38,7 +38,7 @@
|
||||
android:id="@+id/message"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:text="Messaggio molto lungo di cui voirre akjcbasaskdask flasdas fashbdfjah fahsbd ajsbd "
|
||||
android:text=""
|
||||
android:textColor="@color/colorPrimaryText"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
@ -24,6 +24,7 @@
|
||||
android:paddingRight="32dp"
|
||||
android:id="@+id/header_text"
|
||||
android:text=""
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/colorPrimaryText"/>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:textAppearance="@style/AnotherWidget.Settings.Subtitle"
|
||||
|
@ -16,23 +16,32 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/header"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:textAppearance="@style/AnotherWidget.Settings.Title"
|
||||
app:textAllCaps="false"
|
||||
android:letterSpacing="0"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="32dp"
|
||||
android:paddingRight="32dp"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:id="@+id/header_text"
|
||||
android:text=""
|
||||
android:textColor="@color/colorPrimaryText"/>
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="center_vertical">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:textAppearance="@style/AnotherWidget.Settings.Title"
|
||||
app:textAllCaps="false"
|
||||
android:letterSpacing="0"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="start"
|
||||
android:textSize="20sp"
|
||||
android:textAlignment="viewStart"
|
||||
android:id="@+id/header_text"
|
||||
android:text="@string/settings_font_color_title"
|
||||
android:textColor="@color/colorPrimaryText"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -31,7 +31,6 @@
|
||||
android:src="@drawable/round_arrow_back_24"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:transitionName="action_back"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:tint="@color/colorPrimaryText"
|
||||
android:layout_centerVertical="true"
|
||||
@ -65,6 +64,7 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:transitionName="action_back"
|
||||
android:padding="8dp"
|
||||
android:scaleX="-1"
|
||||
android:src="@drawable/round_short_text_24"
|
||||
|
@ -40,6 +40,16 @@
|
||||
<string name="font_700" translatable="false">Bold</string>
|
||||
<string name="font_800" translatable="false">Black</string>
|
||||
<string name="font_900" translatable="false">Heavy</string>
|
||||
<string name="font_italic" translatable="false">Italic</string>
|
||||
<string name="font_100_italic" translatable="false">Thin Italic</string>
|
||||
<string name="font_200_italic" translatable="false">Light Italic</string>
|
||||
<string name="font_300_italic" translatable="false">Book Italic</string>
|
||||
<string name="font_400_italic" translatable="false">Regular Italic</string>
|
||||
<string name="font_500_italic" translatable="false">Medium Italic</string>
|
||||
<string name="font_600_italic" translatable="false">Semi-bold Italic</string>
|
||||
<string name="font_700_italic" translatable="false">Bold Italic</string>
|
||||
<string name="font_800_italic" translatable="false">Black Italic</string>
|
||||
<string name="font_900_italic" translatable="false">Heavy Italic</string>
|
||||
|
||||
<!-- Calendar -->
|
||||
<string name="settings_calendar_title">Calendar</string>
|
||||
|