update wallpaper ui, update color picker ui, update intents and add custom logger for the widget
This commit is contained in:
parent
37cb43dc80
commit
5ca06e817e
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -18,7 +18,7 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 71
|
||||
versionCode 74
|
||||
versionName "2.0.5"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
Binary file not shown.
@ -13,6 +13,7 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="@xml/my_backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:name=".AWApplication"
|
||||
@ -93,7 +94,8 @@
|
||||
<receiver
|
||||
android:name=".receivers.PlayerReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
android:exported="true"
|
||||
tools:ignore="ExportedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.music.metachanged" />
|
||||
<action android:name="com.android.music.playstatechanged" />
|
||||
@ -126,6 +128,15 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".receivers.CrashlyticsReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.tommasoberlose.anotherwidget.action.ACTION_REPORT_CRASH" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name=".services.EventListenerJob" android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
|
||||
</application>
|
||||
|
@ -8,18 +8,23 @@ import android.text.TextWatcher
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.GridLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.helpers.ColorHelper
|
||||
import com.tommasoberlose.anotherwidget.helpers.ColorHelper.isColorDark
|
||||
import com.tommasoberlose.anotherwidget.utils.expand
|
||||
import com.tommasoberlose.anotherwidget.utils.reveal
|
||||
import com.tommasoberlose.anotherwidget.utils.toPixel
|
||||
import com.warkiz.widget.IndicatorSeekBar
|
||||
import com.warkiz.widget.OnSeekChangeListener
|
||||
import com.warkiz.widget.SeekParams
|
||||
@ -28,13 +33,14 @@ import kotlinx.android.synthetic.main.bottom_sheet_menu_hor.view.*
|
||||
import kotlinx.android.synthetic.main.bottom_sheet_menu_hor.view.color_loader
|
||||
import kotlinx.android.synthetic.main.color_picker_menu_item.view.*
|
||||
import kotlinx.coroutines.*
|
||||
import net.idik.lib.slimadapter.SlimAdapter
|
||||
import java.lang.Exception
|
||||
import java.util.prefs.Preferences
|
||||
|
||||
class BottomSheetColorPicker(
|
||||
context: Context,
|
||||
private val colors: IntArray = intArrayOf(),
|
||||
private val selected: Int? = null,
|
||||
private val getSelected: (() -> Int)? = null,
|
||||
private val header: String? = null,
|
||||
private val onColorSelected: ((selectedValue: Int) -> Unit)? = null,
|
||||
private val showAlphaSelector: Boolean = false,
|
||||
@ -42,15 +48,19 @@ class BottomSheetColorPicker(
|
||||
private val onAlphaChangeListener: ((alpha: Int) -> Unit)? = null
|
||||
) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) {
|
||||
|
||||
private val loadingJob: Job? = null
|
||||
private var loadingJobs: ArrayList<Job> = ArrayList()
|
||||
private lateinit var adapter: SlimAdapter
|
||||
|
||||
override fun show() {
|
||||
val view = View.inflate(context, R.layout.bottom_sheet_menu_hor, null)
|
||||
|
||||
window?.setDimAmount(0f)
|
||||
|
||||
// Header
|
||||
view.header.isVisible = header != null
|
||||
view.header_text.text = header ?: ""
|
||||
|
||||
// Alpha
|
||||
view.alpha_selector_container.isVisible = showAlphaSelector
|
||||
view.alpha_selector.setProgress(alpha.toFloat())
|
||||
view.text_alpha.text = "%s: %s%%".format(context.getString(R.string.alpha), alpha)
|
||||
@ -67,44 +77,72 @@ class BottomSheetColorPicker(
|
||||
}
|
||||
}
|
||||
|
||||
val itemViews: ArrayList<View> = ArrayList()
|
||||
// List
|
||||
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
for (@ColorInt color: Int in colors) {
|
||||
val itemView = View.inflate(context, R.layout.color_picker_menu_item, null)
|
||||
itemView.color.setCardBackgroundColor(ColorStateList.valueOf(color))
|
||||
itemView.check.setColorFilter(ContextCompat.getColor(context,
|
||||
if (color.isColorDark()) android.R.color.white else android.R.color.black
|
||||
), android.graphics.PorterDuff.Mode.MULTIPLY)
|
||||
itemView.check.isVisible = selected == color
|
||||
itemView.color.setOnClickListener {
|
||||
onColorSelected?.invoke(color)
|
||||
this@BottomSheetColorPicker.dismiss()
|
||||
view.menu.setHasFixedSize(true)
|
||||
val mLayoutManager = GridLayoutManager(context, 6)
|
||||
view.menu.layoutManager = mLayoutManager
|
||||
|
||||
adapter = SlimAdapter.create()
|
||||
|
||||
adapter
|
||||
.register<Int>(R.layout.color_picker_menu_item) { item, injector ->
|
||||
injector
|
||||
.with<MaterialCardView>(R.id.color) {
|
||||
loadingJobs.add(GlobalScope.launch(Dispatchers.IO) {
|
||||
val colorList = ColorStateList.valueOf(item)
|
||||
withContext(Dispatchers.Main) {
|
||||
it.setCardBackgroundColor(colorList)
|
||||
}
|
||||
})
|
||||
}
|
||||
.with<AppCompatImageView>(R.id.check) {
|
||||
if (getSelected?.invoke() == item) {
|
||||
loadingJobs.add(GlobalScope.launch(Dispatchers.IO) {
|
||||
val colorList = ContextCompat.getColor(
|
||||
context,
|
||||
if (item.isColorDark()) android.R.color.white else android.R.color.black
|
||||
)
|
||||
withContext(Dispatchers.Main) {
|
||||
it.setColorFilter(
|
||||
colorList,
|
||||
android.graphics.PorterDuff.Mode.MULTIPLY
|
||||
)
|
||||
it.isVisible = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
it.isVisible = false
|
||||
}
|
||||
}
|
||||
injector.clicked(R.id.color) {
|
||||
adapter.notifyItemChanged(adapter.data.indexOf(getSelected?.invoke()))
|
||||
onColorSelected?.invoke(item)
|
||||
val position = adapter.data.indexOf(item)
|
||||
adapter.notifyItemChanged(position)
|
||||
(view.menu.layoutManager as GridLayoutManager).scrollToPositionWithOffset(position,0)
|
||||
}
|
||||
itemViews.add(itemView)
|
||||
}
|
||||
.attachTo(view.menu)
|
||||
|
||||
loadingJobs.add(GlobalScope.launch(Dispatchers.IO) {
|
||||
|
||||
adapter.updateData(colors.toList())
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
itemViews.forEach {
|
||||
view.menu.addView(it, GridLayout.LayoutParams(
|
||||
GridLayout.spec(GridLayout.UNDEFINED, 1f),
|
||||
GridLayout.spec(GridLayout.UNDEFINED, 1f)
|
||||
))
|
||||
}
|
||||
color_loader.isVisible = false
|
||||
view.menu.isVisible = true
|
||||
view.color_loader.isVisible = false
|
||||
this@BottomSheetColorPicker.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
// this@BottomSheetColorPicker.behavior.isFitToContents = false
|
||||
view.menu.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
// Menu
|
||||
})
|
||||
|
||||
setContentView(view)
|
||||
super.show()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
loadingJob?.cancel()
|
||||
loadingJobs.forEach { it.cancel() }
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,11 @@ object Actions {
|
||||
const val ACTION_EXTRA_OPEN_WEATHER_PROVIDER = "ACTION_EXTRA_OPEN_WEATHER_PROVIDER"
|
||||
const val ACTION_EXTRA_DISABLE_GPS_NOTIFICATION = "ACTION_EXTRA_DISABLE_GPS_NOTIFICATION"
|
||||
|
||||
const val ACTION_TIME_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_TIME_UPDATE"
|
||||
const val ACTION_CALENDAR_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_CALENDAR_UPDATE"
|
||||
const val ACTION_WEATHER_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_WEATHER_UPDATE"
|
||||
const val ACTION_OPEN_WEATHER_INTENT = "com.tommasoberlose.anotherwidget.action.ACTION_OPEN_WEATHER_INTENT"
|
||||
const val ACTION_TIME_UPDATE = "com.tommasoberlose.anotherwidget.action.TIME_UPDATE"
|
||||
const val ACTION_CALENDAR_UPDATE = "com.tommasoberlose.anotherwidget.action.CALENDAR_UPDATE"
|
||||
const val ACTION_WEATHER_UPDATE = "com.tommasoberlose.anotherwidget.action.WEATHER_UPDATE"
|
||||
const val ACTION_OPEN_WEATHER_INTENT = "com.tommasoberlose.anotherwidget.action.OPEN_WEATHER_INTENT"
|
||||
const val ACTION_GO_TO_NEXT_EVENT = "com.tommasoberlose.anotherwidget.action.GO_TO_NEXT_EVENT"
|
||||
const val ACTION_GO_TO_PREVIOUS_EVENT = "com.tommasoberlose.anotherwidget.action.GO_TO_PREVIOUS_EVENT"
|
||||
const val ACTION_REPORT_CRASH = "com.tommasoberlose.anotherwidget.action.REPORT_CRASH"
|
||||
}
|
@ -19,6 +19,14 @@ object BitmapHelper {
|
||||
val measuredHeight = View.MeasureSpec.makeMeasureSpec(height ?: view.height, if (height != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.UNSPECIFIED)
|
||||
view.measure(measuredWidth, measuredHeight)
|
||||
|
||||
if (draw) {
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredWidth", view.measuredWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredWidth_spec", measuredWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredHeight", view.measuredHeight)
|
||||
FirebaseCrashlytics.getInstance()
|
||||
.setCustomKey("measuredHeight_spec", measuredHeight)
|
||||
}
|
||||
|
||||
return try {
|
||||
val btm = Bitmap.createBitmap(
|
||||
view.measuredWidth,
|
||||
|
@ -4,6 +4,7 @@ import android.Manifest
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
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
|
||||
|
@ -15,6 +15,22 @@ object ColorHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun getFontColorAlpha(): Int {
|
||||
return try {
|
||||
Preferences.textGlobalAlpha.toIntValue().toDouble() * 255 / 100
|
||||
} catch (e: Exception) {
|
||||
"FF".toIntValue().toDouble() * 255 / 100
|
||||
}.roundToInt()
|
||||
}
|
||||
|
||||
fun getFontColorRgb(): Int {
|
||||
return try {
|
||||
Color.parseColor(Preferences.textGlobalColor)
|
||||
} catch (e: Exception) {
|
||||
Color.parseColor("#000000")
|
||||
}
|
||||
}
|
||||
|
||||
fun getBackgroundColor(): Int {
|
||||
return try {
|
||||
Color.parseColor("#%s%s".format(Preferences.backgroundCardAlpha, Preferences.backgroundCardColor.replace("#", "")))
|
||||
|
@ -10,6 +10,7 @@ import android.net.Uri
|
||||
import android.provider.AlarmClock
|
||||
import android.provider.CalendarContract
|
||||
import android.provider.CalendarContract.Events
|
||||
import android.util.Log
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
@ -78,14 +79,12 @@ object IntentHelper {
|
||||
val calendarUri = CalendarContract.CONTENT_URI
|
||||
.buildUpon()
|
||||
.appendPath("time")
|
||||
.appendPath(Date(Calendar.getInstance().timeInMillis).toString())
|
||||
.appendPath("0".toString())
|
||||
.build()
|
||||
return when (Preferences.calendarAppPackage) {
|
||||
"" -> {
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
// data = calendarUri
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
Intent(Intent.ACTION_VIEW).apply {
|
||||
data = calendarUri
|
||||
}
|
||||
}
|
||||
"_" -> {
|
||||
@ -95,16 +94,13 @@ object IntentHelper {
|
||||
val pm: PackageManager = context.packageManager
|
||||
try {
|
||||
pm.getLaunchIntentForPackage(Preferences.calendarAppPackage)!!.apply {
|
||||
// data = calendarUri
|
||||
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
action = Intent.ACTION_VIEW
|
||||
data = calendarUri
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
// data = calendarUri
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
addCategory(Intent.CATEGORY_APP_CALENDAR)
|
||||
Intent(Intent.ACTION_VIEW).apply {
|
||||
data = calendarUri
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,7 +114,6 @@ object IntentHelper {
|
||||
if (Preferences.calendarAppPackage == "") {
|
||||
Intent(Intent.ACTION_VIEW).apply {
|
||||
data = uri
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, e.startDate)
|
||||
putExtra(CalendarContract.EXTRA_EVENT_END_TIME, e.endDate)
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.tommasoberlose.anotherwidget.helpers
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.EventLog
|
||||
import android.util.Log
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.kwabenaberko.openweathermaplib.constants.Units
|
||||
@ -12,8 +13,10 @@ import com.kwabenaberko.openweathermaplib.models.currentweather.CurrentWeather
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
|
||||
/**
|
||||
@ -35,6 +38,7 @@ object WeatherHelper {
|
||||
Preferences.customLocationLon = location.longitude.toString()
|
||||
|
||||
networkApi.updateWeather()
|
||||
EventBus.getDefault().post(MainActivity.UpdateUiMessageEvent())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ open class Event(var id: Long = 0,
|
||||
var allDay: Boolean = false,
|
||||
var address: String = "") : RealmObject() {
|
||||
override fun toString(): String {
|
||||
return "Event:\nID: " + eventID + "\nTITLE: " + title + "\nSTART DATE: " + Date(startDate) + "\nEND DATE: " + Date(endDate) + "\nCAL ID: " + calendarID + "\nADDRESS: " + address
|
||||
return "Event:\nEVENT ID: " + eventID + "\nTITLE: " + title + "\nSTART DATE: " + Date(startDate) + "\nEND DATE: " + Date(endDate) + "\nCAL ID: " + calendarID + "\nADDRESS: " + address
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.tommasoberlose.anotherwidget.receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.tommasoberlose.anotherwidget.global.Actions
|
||||
import java.lang.Exception
|
||||
|
||||
class CrashlyticsReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Actions.ACTION_REPORT_CRASH) {
|
||||
val exception: Exception = intent.getSerializableExtra(EXCEPTION) as Exception
|
||||
FirebaseCrashlytics.getInstance().recordException(exception)
|
||||
FirebaseCrashlytics.getInstance().sendUnsentReports()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private const val EXCEPTION = "EXCEPTION"
|
||||
|
||||
fun sendCrash(context: Context, exception: Exception) {
|
||||
context.sendBroadcast(Intent(context, CrashlyticsReceiver::class.java).apply {
|
||||
action = Actions.ACTION_REPORT_CRASH
|
||||
putExtra(EXCEPTION, exception)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -6,10 +6,14 @@ import android.app.Activity
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Matrix
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
@ -267,7 +271,16 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||
|
||||
private fun subscribeUi(viewModel: MainViewModel) {
|
||||
viewModel.showWallpaper.observe(this, Observer {
|
||||
widget_bg.setImageDrawable(if (it) getCurrentWallpaper() else null)
|
||||
val wallpaper = getCurrentWallpaper()
|
||||
widget_bg.setImageDrawable(if (it) wallpaper else null)
|
||||
widget_bg.layoutParams = widget_bg.layoutParams.apply {
|
||||
|
||||
val metrics = DisplayMetrics()
|
||||
windowManager.defaultDisplay.getMetrics(metrics)
|
||||
|
||||
height = metrics.heightPixels
|
||||
width = (wallpaper?.intrinsicWidth ?: 1) * metrics.heightPixels / (wallpaper?.intrinsicWidth ?: 1)
|
||||
}
|
||||
})
|
||||
|
||||
logo.setOnClickListener {
|
||||
|
@ -106,9 +106,7 @@ class ClockSettingsFragment : Fragment() {
|
||||
})
|
||||
|
||||
viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
show_next_alarm_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
}
|
||||
updateNextAlarmWarningUi()
|
||||
})
|
||||
|
||||
viewModel.clockAppName.observe(viewLifecycleOwner, Observer {
|
||||
@ -168,17 +166,20 @@ class ClockSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun updateNextAlarmWarningUi() {
|
||||
show_next_alarm_warning.isVisible = AlarmHelper.isAlarmProbablyWrong(requireContext())
|
||||
with(requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
|
||||
val alarm = nextAlarmClock
|
||||
if (alarm != null) {
|
||||
if (AlarmHelper.isAlarmProbablyWrong(requireContext()) && alarm != null && alarm.showIntent != null) {
|
||||
val pm = requireContext().packageManager as PackageManager
|
||||
val appNameOrPackage = try {
|
||||
pm.getApplicationLabel(pm.getApplicationInfo(nextAlarmClock.showIntent.creatorPackage ?: "", 0))
|
||||
pm.getApplicationLabel(pm.getApplicationInfo(alarm.showIntent?.creatorPackage ?: "", 0))
|
||||
} catch (e: Exception) {
|
||||
nextAlarmClock.showIntent.creatorPackage
|
||||
alarm.showIntent?.creatorPackage ?: ""
|
||||
}
|
||||
show_next_alarm_warning.text = getString(R.string.next_alarm_warning).format(appNameOrPackage)
|
||||
} else {
|
||||
maintainScrollPosition {
|
||||
show_next_alarm_label?.text = if (Preferences.showNextAlarm) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class GeneralSettingsFragment : Fragment() {
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_font_color_title),
|
||||
selected = ColorHelper.getFontColor(),
|
||||
getSelected = ColorHelper::getFontColorRgb,
|
||||
onColorSelected = { color: Int ->
|
||||
val colorString = Integer.toHexString(color)
|
||||
Preferences.textGlobalColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
@ -201,7 +201,7 @@ class GeneralSettingsFragment : Fragment() {
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_background_color_title),
|
||||
selected = ColorHelper.getBackgroundColor(),
|
||||
getSelected = { ColorHelper.getBackgroundColorRgb() },
|
||||
onColorSelected = { color: Int ->
|
||||
val colorString = Integer.toHexString(color)
|
||||
Preferences.backgroundCardColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
|
||||
|
@ -26,10 +26,7 @@ import com.tommasoberlose.anotherwidget.global.Actions
|
||||
import com.tommasoberlose.anotherwidget.global.Constants
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.helpers.*
|
||||
import com.tommasoberlose.anotherwidget.receivers.NewCalendarEventReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.WeatherReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.WidgetClickListenerReceiver
|
||||
import com.tommasoberlose.anotherwidget.receivers.*
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.getCapWordString
|
||||
import com.tommasoberlose.anotherwidget.utils.toPixel
|
||||
@ -95,26 +92,46 @@ class MainWidget : AppWidgetProvider() {
|
||||
private fun generateWidgetView(context: Context, appWidgetId: Int, appWidgetManager: AppWidgetManager, w: Int) {
|
||||
var views = RemoteViews(context.packageName, R.layout.the_widget_sans)
|
||||
|
||||
val generatedView = generateWidgetView(context)
|
||||
views.setImageViewBitmap(R.id.bitmap_container, BitmapHelper.getBitmapFromView(generatedView, width = w))
|
||||
|
||||
// Background
|
||||
views.setInt(R.id.widget_shape_background, "setColorFilter", ColorHelper.getBackgroundColorRgb())
|
||||
views.setInt(R.id.widget_shape_background, "setImageAlpha", ColorHelper.getBackgroundAlpha())
|
||||
val refreshIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
appWidgetId,
|
||||
IntentHelper.getWidgetUpdateIntent(context),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.widget_shape_background, refreshIntent)
|
||||
try {
|
||||
// Background
|
||||
views.setInt(
|
||||
R.id.widget_shape_background,
|
||||
"setColorFilter",
|
||||
ColorHelper.getBackgroundColorRgb()
|
||||
)
|
||||
views.setInt(
|
||||
R.id.widget_shape_background,
|
||||
"setImageAlpha",
|
||||
ColorHelper.getBackgroundAlpha()
|
||||
)
|
||||
val refreshIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
appWidgetId,
|
||||
IntentHelper.getWidgetUpdateIntent(context),
|
||||
0
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.widget_shape_background, refreshIntent)
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
}
|
||||
|
||||
// Clock
|
||||
views = updateClockView(context, views, appWidgetId)
|
||||
|
||||
// Setup listener
|
||||
views = updateCalendarView(context, generatedView, views, appWidgetId)
|
||||
views = updateWeatherView(context, generatedView, views, appWidgetId)
|
||||
try {
|
||||
val generatedView = generateWidgetView(context)
|
||||
views.setImageViewBitmap(
|
||||
R.id.bitmap_container,
|
||||
BitmapHelper.getBitmapFromView(generatedView, width = w)
|
||||
)
|
||||
views = updateCalendarView(context, generatedView, views, appWidgetId)
|
||||
views = updateWeatherView(context, generatedView, views, appWidgetId)
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
}
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
}
|
||||
@ -267,7 +284,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
}
|
||||
|
||||
return views
|
||||
@ -301,7 +318,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
}
|
||||
return views
|
||||
}
|
||||
@ -358,7 +375,7 @@ class MainWidget : AppWidgetProvider() {
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
FirebaseCrashlytics.getInstance().recordException(ex)
|
||||
CrashlyticsReceiver.sendCrash(context, ex)
|
||||
}
|
||||
|
||||
return views
|
||||
|
@ -59,14 +59,17 @@
|
||||
android:layout_marginLeft="16dp"
|
||||
app:cardCornerRadius="9dp"
|
||||
app:cardElevation="0dp">
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-80dp"
|
||||
android:layout_marginStart="-80dp"
|
||||
android:scaleType="fitStart"
|
||||
android:adjustViewBounds="true"
|
||||
android:id="@+id/widget_bg" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:id="@+id/widget_bg" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -4,6 +4,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="6dp"
|
||||
app:cardCornerRadius="3dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:cardBackgroundColor="@color/disabledButtonBackground"
|
||||
app:cardElevation="0dp" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -32,80 +40,76 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@color/disabledButtonBackground" />
|
||||
</LinearLayout>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/alpha_selector_container"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
|
||||
app:textAllCaps="false"
|
||||
android:letterSpacing="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:id="@+id/alpha_selector_container"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
|
||||
app:textAllCaps="false"
|
||||
android:letterSpacing="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:textSize="15sp"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:id="@+id/text_alpha"
|
||||
android:text="Alpha : 20%"
|
||||
android:textColor="@color/colorSecondaryText"/>
|
||||
<com.warkiz.widget.IndicatorSeekBar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:isb_max="100"
|
||||
app:isb_min="0"
|
||||
app:isb_seek_smoothly="true"
|
||||
app:isb_show_thumb_text="false"
|
||||
app:isb_thumb_adjust_auto="true"
|
||||
app:isb_track_rounded_corners="true"
|
||||
app:isb_thumb_text_color="@color/colorAccent"
|
||||
app:isb_progress_value_float="false"
|
||||
app:isb_show_tick_texts="false"
|
||||
app:isb_show_indicator="none"
|
||||
app:isb_thumb_color="@color/colorAccent"
|
||||
app:isb_thumb_size="12dp"
|
||||
android:id="@+id/alpha_selector"
|
||||
app:isb_track_background_color="@color/disabledButtonBackground"
|
||||
app:isb_track_background_size="4dp"
|
||||
app:isb_track_progress_color="@color/disabledButtonBackground"
|
||||
app:isb_track_progress_size="4dp"
|
||||
app:isb_only_thumb_draggable="false"/>
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<GridLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/menu"
|
||||
android:visibility="gone"
|
||||
android:layout_margin="16dp"
|
||||
android:columnCount="6"/>
|
||||
<ProgressBar
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:indeterminateTint="@color/colorPrimaryText"
|
||||
android:indeterminate="true"
|
||||
android:layout_margin="32dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/color_loader" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="32dp"
|
||||
android:paddingRight="32dp"
|
||||
android:textSize="15sp"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:id="@+id/text_alpha"
|
||||
android:text="Alpha : 20%"
|
||||
android:textColor="@color/colorSecondaryText"/>
|
||||
<com.warkiz.widget.IndicatorSeekBar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:isb_max="100"
|
||||
app:isb_min="0"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
app:isb_seek_smoothly="true"
|
||||
app:isb_show_thumb_text="false"
|
||||
app:isb_thumb_adjust_auto="true"
|
||||
app:isb_track_rounded_corners="true"
|
||||
app:isb_thumb_text_color="@color/colorAccent"
|
||||
app:isb_progress_value_float="false"
|
||||
app:isb_show_tick_texts="false"
|
||||
app:isb_show_indicator="none"
|
||||
app:isb_thumb_color="@color/colorAccent"
|
||||
app:isb_thumb_size="12dp"
|
||||
android:id="@+id/alpha_selector"
|
||||
app:isb_track_background_color="@color/disabledButtonBackground"
|
||||
app:isb_track_background_size="4dp"
|
||||
app:isb_track_progress_color="@color/disabledButtonBackground"
|
||||
app:isb_track_progress_size="4dp"
|
||||
app:isb_only_thumb_draggable="false"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@color/disabledButtonBackground" />
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:id="@+id/menu"
|
||||
android:visibility="gone"
|
||||
android:clipToPadding="false"
|
||||
android:padding="16dp"/>
|
||||
<ProgressBar
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:indeterminateTint="@color/colorPrimaryText"
|
||||
android:indeterminate="true"
|
||||
android:layout_margin="32dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/color_loader" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
4
app/src/main/res/xml/my_backup_rules.xml
Normal file
4
app/src/main/res/xml/my_backup_rules.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<full-backup-content>
|
||||
<include domain="sharedpref" path="."/>
|
||||
</full-backup-content>
|
@ -4,10 +4,10 @@
|
||||
android:initialKeyguardLayout="@layout/the_widget"
|
||||
android:initialLayout="@layout/the_widget"
|
||||
android:minHeight="50dp"
|
||||
android:minWidth="300dp"
|
||||
android:minWidth="250dp"
|
||||
android:configure="com.tommasoberlose.anotherwidget.ui.activities.MainActivity"
|
||||
android:minResizeHeight="50dp"
|
||||
android:minResizeWidth="300dp"
|
||||
android:minResizeWidth="250dp"
|
||||
android:previewImage="@drawable/widget_preview"
|
||||
android:resizeMode="vertical|horizontal"
|
||||
android:updatePeriodMillis="86400000"
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:versionCode="71"
|
||||
android:versionCode="74"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk
|
||||
|
@ -1,4 +1,4 @@
|
||||
#Wed May 06 21:31:44 CEST 2020
|
||||
#Thu May 07 12:28:58 CEST 2020
|
||||
base.0=/Users/tommaso/Documents/MyCode/another-widget/tasksintegration/build/intermediates/dex/debug/mergeProjectDexDebug/out/classes.dex
|
||||
path.0=classes.dex
|
||||
renamed.0=classes.dex
|
||||
|
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:targetSandboxVersion="2"
|
||||
android:versionCode="71"
|
||||
android:versionCode="74"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk
|
||||
|
@ -3,7 +3,7 @@
|
||||
3 xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
4 featureSplit="tasksintegration"
|
||||
5 package="com.tommasoberlose.anotherwidget"
|
||||
6 android:versionCode="71"
|
||||
6 android:versionCode="74"
|
||||
7 android:versionName="2.0.5" >
|
||||
8
|
||||
9 <uses-sdk
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:versionCode="71"
|
||||
android:versionCode="74"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:dist="http://schemas.android.com/apk/distribution"
|
||||
featureSplit="tasksintegration"
|
||||
package="com.tommasoberlose.anotherwidget"
|
||||
android:versionCode="71"
|
||||
android:versionCode="74"
|
||||
android:versionName="2.0.5" >
|
||||
|
||||
<uses-sdk android:targetSdkVersion="29" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user