Fix events order, fix horizontal resize, add widget preview toggle, fix next event function, fix weather icon click listner and relase v1.3-beta1
@ -17,7 +17,7 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 27
|
versionCode 28
|
||||||
versionName "1.3"
|
versionName "1.3"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":27},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":28},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
|
@ -12,6 +12,7 @@
|
|||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:name=".ui.AWApplication"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
@ -113,7 +114,7 @@
|
|||||||
<receiver
|
<receiver
|
||||||
android:name=".receiver.OpenWeatherIntentReceiver"
|
android:name=".receiver.OpenWeatherIntentReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.tommasoberlose.anotherwidget.action.ACTION_OPEN_WEATHER_INTENT" />
|
<action android:name="com.tommasoberlose.anotherwidget.action.ACTION_OPEN_WEATHER_INTENT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@ -121,10 +122,12 @@
|
|||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".util.CrocodileService"
|
android:name=".util.CrocodileService"
|
||||||
android:enabled="true"
|
android:enabled="true"/>
|
||||||
android:exported="true" />
|
|
||||||
|
|
||||||
<activity android:name=".ui.activity.SupportDevActivity"></activity>
|
<activity android:name=".ui.activity.SupportDevActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
|
android:launchMode="singleInstance"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -32,6 +32,7 @@ object Constants {
|
|||||||
val PREF_CALENDAR_ALL_DAY = "PREF_CALENDAR_ALL_DAY"
|
val PREF_CALENDAR_ALL_DAY = "PREF_CALENDAR_ALL_DAY"
|
||||||
val PREF_CALENDAR_FILTER = "PREF_CALENDAR_FILTER"
|
val PREF_CALENDAR_FILTER = "PREF_CALENDAR_FILTER"
|
||||||
|
|
||||||
|
val PREF_EVENT_ID = "PREF_EVENT_ID"
|
||||||
val PREF_NEXT_EVENT_ID = "PREF_NEXT_EVENT_ID"
|
val PREF_NEXT_EVENT_ID = "PREF_NEXT_EVENT_ID"
|
||||||
val PREF_NEXT_EVENT_NAME = "PREF_NEXT_EVENT_NAME"
|
val PREF_NEXT_EVENT_NAME = "PREF_NEXT_EVENT_NAME"
|
||||||
val PREF_NEXT_EVENT_START_DATE = "PREF_NEXT_EVENT_START_DATE"
|
val PREF_NEXT_EVENT_START_DATE = "PREF_NEXT_EVENT_START_DATE"
|
||||||
@ -69,6 +70,8 @@ object Constants {
|
|||||||
val PREF_SECOND_ROW_INFORMATION = "PREF_SECOND_ROW_INFORMATION"
|
val PREF_SECOND_ROW_INFORMATION = "PREF_SECOND_ROW_INFORMATION"
|
||||||
val PREF_CUSTOM_FONT = "PREF_CUSTOM_FONT"
|
val PREF_CUSTOM_FONT = "PREF_CUSTOM_FONT"
|
||||||
val PREF_SHOW_NEXT_EVENT = "PREF_SHOW_NEXT_EVENT"
|
val PREF_SHOW_NEXT_EVENT = "PREF_SHOW_NEXT_EVENT"
|
||||||
|
val PREF_SHOW_WIDGET_PREVIEW = "PREF_SHOW_WIDGET_PREVIEW"
|
||||||
|
val PREF_SCHEMA_VERSION = "PREF_SCHEMA_VERSION"
|
||||||
|
|
||||||
val CUSTOM_FONT_PRODUCT_SANS = 1
|
val CUSTOM_FONT_PRODUCT_SANS = 1
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ import java.util.Date
|
|||||||
* Created by tommaso on 05/10/17.
|
* Created by tommaso on 05/10/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
open class Event(var id: Int = 0,
|
open class Event(var id: Long = 0,
|
||||||
|
var eventID: Long = 0,
|
||||||
var title: String = "",
|
var title: String = "",
|
||||||
var startDate: Long = 0,
|
var startDate: Long = 0,
|
||||||
var endDate: Long = 0,
|
var endDate: Long = 0,
|
||||||
|
@ -3,6 +3,7 @@ package com.tommasoberlose.anotherwidget.receiver
|
|||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.util.Log
|
||||||
import com.tommasoberlose.anotherwidget.`object`.Constants
|
import com.tommasoberlose.anotherwidget.`object`.Constants
|
||||||
import com.tommasoberlose.anotherwidget.util.Util
|
import com.tommasoberlose.anotherwidget.util.Util
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class UpdatesReceiver : BroadcastReceiver() {
|
|||||||
setUpdates(context)
|
setUpdates(context)
|
||||||
} else if (intent.action.equals(Constants.ACTION_TIME_UPDATE) || intent.action.equals("com.sec.android.widgetapp.APPWIDGET_RESIZE") || intent.action == "android.intent.action.USER_PRESENT") {
|
} else if (intent.action.equals(Constants.ACTION_TIME_UPDATE) || intent.action.equals("com.sec.android.widgetapp.APPWIDGET_RESIZE") || intent.action == "android.intent.action.USER_PRESENT") {
|
||||||
val e: Event = CalendarUtil.getNextEvent(context)
|
val e: Event = CalendarUtil.getNextEvent(context)
|
||||||
if (e.id == 0 || e.endDate <= Calendar.getInstance().timeInMillis) {
|
if (e.id == 0.toLong() || e.endDate <= Calendar.getInstance().timeInMillis) {
|
||||||
CalendarUtil.updateEventList(context)
|
CalendarUtil.updateEventList(context)
|
||||||
} else {
|
} else {
|
||||||
Util.updateWidget(context)
|
Util.updateWidget(context)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.ui
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.preference.PreferenceManager
|
||||||
|
import android.util.Log
|
||||||
|
import com.tommasoberlose.anotherwidget.`object`.Constants
|
||||||
|
import com.tommasoberlose.anotherwidget.util.MyMigration
|
||||||
|
import com.tommasoberlose.anotherwidget.util.Util
|
||||||
|
|
||||||
|
import io.realm.Realm
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
|
|
||||||
|
class AWApplication : Application() {
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
Realm.init(this)
|
||||||
|
val config = RealmConfiguration.Builder()
|
||||||
|
.schemaVersion(2)
|
||||||
|
.migration(MyMigration())
|
||||||
|
.deleteRealmIfMigrationNeeded()
|
||||||
|
.build()
|
||||||
|
Realm.setDefaultConfiguration(config)
|
||||||
|
}
|
||||||
|
}
|
@ -59,6 +59,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
@ -66,6 +67,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE))
|
sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE))
|
||||||
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
|
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
|
||||||
|
|
||||||
|
val SP = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
|
||||||
if (intent.extras?.containsKey(Constants.ACTION_EXTRA_OPEN_WEATHER_PROVIDER) == true) {
|
if (intent.extras?.containsKey(Constants.ACTION_EXTRA_OPEN_WEATHER_PROVIDER) == true) {
|
||||||
startActivityForResult(Intent(this, WeatherProviderActivity::class.java), Constants.WEATHER_PROVIDER_REQUEST_CODE)
|
startActivityForResult(Intent(this, WeatherProviderActivity::class.java), Constants.WEATHER_PROVIDER_REQUEST_CODE)
|
||||||
}
|
}
|
||||||
@ -98,6 +101,28 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (SP.getBoolean(Constants.PREF_SHOW_WIDGET_PREVIEW, true)) {
|
||||||
|
menuView.widget_preview_icon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_action_hide_preview))
|
||||||
|
menuView.widget_preview_label.text = getString(R.string.action_hide_widget_preview)
|
||||||
|
menuView.action_toggle_widget_preview.setOnClickListener {
|
||||||
|
SP.edit()
|
||||||
|
.putBoolean(Constants.PREF_SHOW_WIDGET_PREVIEW, false)
|
||||||
|
.commit()
|
||||||
|
updateUI()
|
||||||
|
mBottomSheetDialog.dismiss()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
menuView.widget_preview_icon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_action_show_preview))
|
||||||
|
menuView.widget_preview_label.text = getString(R.string.action_show_widget_preview)
|
||||||
|
menuView.action_toggle_widget_preview.setOnClickListener {
|
||||||
|
SP.edit()
|
||||||
|
.putBoolean(Constants.PREF_SHOW_WIDGET_PREVIEW, true)
|
||||||
|
.commit()
|
||||||
|
updateUI()
|
||||||
|
mBottomSheetDialog.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menuView.action_rate.setOnClickListener(object: View.OnClickListener {
|
menuView.action_rate.setOnClickListener(object: View.OnClickListener {
|
||||||
override fun onClick(p0: View?) {
|
override fun onClick(p0: View?) {
|
||||||
Util.rateApp(this@MainActivity, "https://play.google.com/store/apps/details?id=com.tommasoberlose.anotherwidget")
|
Util.rateApp(this@MainActivity, "https://play.google.com/store/apps/details?id=com.tommasoberlose.anotherwidget")
|
||||||
@ -183,6 +208,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
updateClockView()
|
updateClockView()
|
||||||
|
|
||||||
val SP = PreferenceManager.getDefaultSharedPreferences(this)
|
val SP = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
|
||||||
|
if (SP.getBoolean(Constants.PREF_SHOW_WIDGET_PREVIEW, true)) {
|
||||||
val displayMetrics = Resources.getSystem().displayMetrics
|
val displayMetrics = Resources.getSystem().displayMetrics
|
||||||
var height = Util.convertDpToPixel(120f, this).toInt()
|
var height = Util.convertDpToPixel(120f, this).toInt()
|
||||||
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
|
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
|
||||||
@ -193,6 +220,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
widget_bitmap.setImageBitmap(Util.getBitmapFromView(main_layout, displayMetrics.widthPixels, height - Util.convertDpToPixel(32f, this).toInt()))
|
widget_bitmap.setImageBitmap(Util.getBitmapFromView(main_layout, displayMetrics.widthPixels, height - Util.convertDpToPixel(32f, this).toInt()))
|
||||||
widget.layoutParams.height = height + Util.convertDpToPixel(16f, this).toInt()
|
widget.layoutParams.height = height + Util.convertDpToPixel(16f, this).toInt()
|
||||||
|
|
||||||
|
widget.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
widget.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -283,7 +315,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (calendarLayout) {
|
if (calendarLayout) {
|
||||||
val e = CalendarUtil.getNextEvent(this)
|
val e = CalendarUtil.getNextEvent(this)
|
||||||
|
|
||||||
if (e.id != 0) {
|
if (e.id != 0.toLong()) {
|
||||||
next_event.text = e.title
|
next_event.text = e.title
|
||||||
|
|
||||||
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(this) > 1) {
|
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(this) > 1) {
|
||||||
@ -364,8 +396,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
||||||
second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
||||||
|
|
||||||
weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 20f
|
weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
||||||
weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 20f
|
weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
||||||
|
|
||||||
empty_weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
empty_weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
||||||
empty_weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
empty_weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
||||||
|
@ -32,6 +32,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
|
|||||||
|
|
||||||
override fun onBillingInitialized() {
|
override fun onBillingInitialized() {
|
||||||
loader.visibility = View.GONE
|
loader.visibility = View.GONE
|
||||||
|
try {
|
||||||
val isAvailable = BillingProcessor.isIabServiceAvailable(this)
|
val isAvailable = BillingProcessor.isIabServiceAvailable(this)
|
||||||
val isOneTimePurchaseSupported = bp!!.isOneTimePurchaseSupported
|
val isOneTimePurchaseSupported = bp!!.isOneTimePurchaseSupported
|
||||||
if (isAvailable && isOneTimePurchaseSupported) {
|
if (isAvailable && isOneTimePurchaseSupported) {
|
||||||
@ -90,6 +91,9 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
|
|||||||
} else {
|
} else {
|
||||||
products_card.visibility = View.GONE
|
products_card.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
products_card.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPurchaseHistoryRestored() {
|
override fun onPurchaseHistoryRestored() {
|
||||||
|
@ -45,6 +45,7 @@ import android.text.style.StyleSpan
|
|||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import com.tommasoberlose.anotherwidget.receiver.OpenWeatherIntentReceiver
|
||||||
import com.tommasoberlose.anotherwidget.ui.view.CustomTypefaceSpan
|
import com.tommasoberlose.anotherwidget.ui.view.CustomTypefaceSpan
|
||||||
import kotlinx.android.synthetic.main.the_widget.*
|
import kotlinx.android.synthetic.main.the_widget.*
|
||||||
import kotlinx.android.synthetic.main.the_widget.view.*
|
import kotlinx.android.synthetic.main.the_widget.view.*
|
||||||
@ -136,6 +137,8 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
views = updateLocationView(context, views, appWidgetId)
|
views = updateLocationView(context, views, appWidgetId)
|
||||||
views = updateClockView(context, views, appWidgetId)
|
views = updateClockView(context, views, appWidgetId)
|
||||||
|
|
||||||
|
views = fixViewsMargin(context, views)
|
||||||
|
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +163,7 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
if (calendarLayout) {
|
if (calendarLayout) {
|
||||||
val e = CalendarUtil.getNextEvent(context)
|
val e = CalendarUtil.getNextEvent(context)
|
||||||
|
|
||||||
if (e.id != 0) {
|
if (e.id != 0.toLong()) {
|
||||||
views.setTextViewText(R.id.next_event, e.title)
|
views.setTextViewText(R.id.next_event, e.title)
|
||||||
|
|
||||||
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(context) > 1) {
|
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(context) > 1) {
|
||||||
@ -277,8 +280,9 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
views.setTextViewText(R.id.temp, temp)
|
views.setTextViewText(R.id.temp, temp)
|
||||||
views.setTextViewText(R.id.calendar_temp, temp)
|
views.setTextViewText(R.id.calendar_temp, temp)
|
||||||
|
|
||||||
|
val i = Intent(context, OpenWeatherIntentReceiver::class.java)
|
||||||
val weatherPIntent = PendingIntent.getBroadcast(context, widgetID, Intent(Constants.ACTION_OPEN_WEATHER_INTENT), 0)
|
i.action = Constants.ACTION_OPEN_WEATHER_INTENT
|
||||||
|
val weatherPIntent = PendingIntent.getBroadcast(context, widgetID, i, 0)
|
||||||
|
|
||||||
views.setOnClickPendingIntent(R.id.weather, weatherPIntent)
|
views.setOnClickPendingIntent(R.id.weather, weatherPIntent)
|
||||||
views.setOnClickPendingIntent(R.id.calendar_weather, weatherPIntent)
|
views.setOnClickPendingIntent(R.id.calendar_weather, weatherPIntent)
|
||||||
@ -293,9 +297,7 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
if (!SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
|
if (!SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
|
||||||
views.setViewVisibility(R.id.time, View.GONE)
|
views.setViewVisibility(R.id.time, View.GONE)
|
||||||
views.setViewVisibility(R.id.bottom_divider, View.VISIBLE)
|
|
||||||
} else {
|
} else {
|
||||||
views.setViewVisibility(R.id.bottom_divider, View.GONE)
|
|
||||||
val now = Calendar.getInstance()
|
val now = Calendar.getInstance()
|
||||||
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
|
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
|
||||||
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
|
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
|
||||||
@ -315,6 +317,26 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
return views
|
return views
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fixViewsMargin(context: Context, views: RemoteViews): RemoteViews {
|
||||||
|
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
views.setViewVisibility(R.id.bottom_divider_24, View.GONE)
|
||||||
|
views.setViewVisibility(R.id.bottom_divider_16, View.GONE)
|
||||||
|
views.setViewVisibility(R.id.bottom_divider_8, View.GONE)
|
||||||
|
val eVisible = SP.getBoolean(Constants.PREF_SHOW_EVENTS, true) && Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)
|
||||||
|
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
|
||||||
|
if (eVisible) {
|
||||||
|
views.setViewVisibility(R.id.bottom_divider_8, View.VISIBLE)
|
||||||
|
} else {
|
||||||
|
views.setViewVisibility(R.id.bottom_divider_24, View.VISIBLE)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (eVisible) {
|
||||||
|
views.setViewVisibility(R.id.bottom_divider_8, View.VISIBLE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return views
|
||||||
|
}
|
||||||
|
|
||||||
fun updateCalendarViewByLayout(context: Context, v: View): View {
|
fun updateCalendarViewByLayout(context: Context, v: View): View {
|
||||||
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val now = Calendar.getInstance()
|
val now = Calendar.getInstance()
|
||||||
@ -332,7 +354,7 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
if (calendarLayout) {
|
if (calendarLayout) {
|
||||||
val e = CalendarUtil.getNextEvent(context)
|
val e = CalendarUtil.getNextEvent(context)
|
||||||
|
|
||||||
if (e.id != 0) {
|
if (e.id != 0.toLong()) {
|
||||||
v.next_event.text = e.title
|
v.next_event.text = e.title
|
||||||
|
|
||||||
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(context) > 1) {
|
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(context) > 1) {
|
||||||
@ -418,8 +440,8 @@ class TheWidget : AppWidgetProvider() {
|
|||||||
v.second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
v.second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
||||||
v.second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
v.second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
|
||||||
|
|
||||||
v.weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 20f
|
v.weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
|
||||||
v.weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 20f
|
v.weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
|
||||||
|
|
||||||
v.empty_weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
v.empty_weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
||||||
v.empty_weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
v.empty_weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
|
||||||
|
@ -72,7 +72,7 @@ object CalendarUtil {
|
|||||||
instance.begin = start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
|
instance.begin = start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
|
||||||
instance.end = end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
|
instance.end = end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
|
||||||
}
|
}
|
||||||
eventList.add(Event(e.id.toInt(), e.title, instance.begin, instance.end, e.calendarId.toInt(), e.allDay, e.eventLocation ?: ""))
|
eventList.add(Event(instance.id, e.id, e.title, instance.begin, instance.end, e.calendarId.toInt(), e.allDay, e.eventLocation ?: ""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,8 +118,7 @@ object CalendarUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveEvents(context: Context, eventList: ArrayList<Event>) {
|
fun saveEvents(context: Context, eventList: ArrayList<Event>) {
|
||||||
Realm.init(context)
|
val db = Util.getRealInstance(context)
|
||||||
val db = Realm.getDefaultInstance()
|
|
||||||
db.executeTransaction { realm ->
|
db.executeTransaction { realm ->
|
||||||
realm.where(Event::class.java).findAll().deleteAllFromRealm()
|
realm.where(Event::class.java).findAll().deleteAllFromRealm()
|
||||||
realm.copyToRealm(eventList)
|
realm.copyToRealm(eventList)
|
||||||
@ -128,13 +127,13 @@ object CalendarUtil {
|
|||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
fun resetNextEventData(context: Context) {
|
fun resetNextEventData(context: Context) {
|
||||||
Realm.init(context)
|
val db = Util.getRealInstance(context)
|
||||||
val db = Realm.getDefaultInstance()
|
|
||||||
db.executeTransaction {
|
db.executeTransaction {
|
||||||
db.where(Event::class.java).findAll().deleteAllFromRealm()
|
db.where(Event::class.java).findAll().deleteAllFromRealm()
|
||||||
}
|
}
|
||||||
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
SP.edit()
|
SP.edit()
|
||||||
|
.remove(Constants.PREF_EVENT_ID)
|
||||||
.remove(Constants.PREF_NEXT_EVENT_ID)
|
.remove(Constants.PREF_NEXT_EVENT_ID)
|
||||||
.remove(Constants.PREF_NEXT_EVENT_NAME)
|
.remove(Constants.PREF_NEXT_EVENT_NAME)
|
||||||
.remove(Constants.PREF_NEXT_EVENT_START_DATE)
|
.remove(Constants.PREF_NEXT_EVENT_START_DATE)
|
||||||
@ -150,34 +149,20 @@ object CalendarUtil {
|
|||||||
fun saveNextEventData(context: Context, event: Event) {
|
fun saveNextEventData(context: Context, event: Event) {
|
||||||
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
SP.edit()
|
SP.edit()
|
||||||
.putInt(Constants.PREF_NEXT_EVENT_ID, event.id)
|
.putLong(Constants.PREF_EVENT_ID, event.id)
|
||||||
.commit()
|
.commit()
|
||||||
Util.updateWidget(context)
|
Util.updateWidget(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNextEvent(context: Context): Event {
|
fun getNextEvent(context: Context): Event {
|
||||||
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
Realm.init(context)
|
val db = Util.getRealInstance(context)
|
||||||
val db = Realm.getDefaultInstance()
|
val nextEvent = db.where(Event::class.java).equalTo("id", SP.getLong(Constants.PREF_EVENT_ID, 0)).findFirst()
|
||||||
val nextEvent = db.where(Event::class.java).equalTo("id", SP.getInt(Constants.PREF_NEXT_EVENT_ID, 0)).findFirst()
|
|
||||||
return if (nextEvent != null) {
|
return if (nextEvent != null) {
|
||||||
nextEvent
|
nextEvent
|
||||||
} else {
|
} else {
|
||||||
val eventList = db.where(Event::class.java).findAll()
|
val eventList = db.where(Event::class.java).findAll()
|
||||||
|
|
||||||
if (eventList.isNotEmpty()) {
|
if (eventList.isNotEmpty()) {
|
||||||
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
|
||||||
if (event.allDay && event1.allDay) {
|
|
||||||
event.startDate.compareTo(event1.startDate)
|
|
||||||
} else if (event.allDay) {
|
|
||||||
1
|
|
||||||
} else if (event1.allDay) {
|
|
||||||
-1
|
|
||||||
} else {
|
|
||||||
event1.startDate.compareTo(event.startDate)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
eventList.reverse()
|
|
||||||
eventList[0] ?: Event()
|
eventList[0] ?: Event()
|
||||||
} else {
|
} else {
|
||||||
Event()
|
Event()
|
||||||
@ -187,36 +172,21 @@ object CalendarUtil {
|
|||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
fun goToNextEvent(context: Context) {
|
fun goToNextEvent(context: Context) {
|
||||||
Realm.init(context)
|
val db = Util.getRealInstance(context)
|
||||||
val db = Realm.getDefaultInstance()
|
|
||||||
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val eventList = db.where(Event::class.java).findAll()
|
val eventList = db.where(Event::class.java).findAll()
|
||||||
|
|
||||||
if (eventList.isNotEmpty()) {
|
if (eventList.isNotEmpty()) {
|
||||||
/*
|
|
||||||
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
|
||||||
if (event.allDay && event1.allDay) {
|
|
||||||
event.startDate.compareTo(event1.startDate)
|
|
||||||
} else if (event.allDay) {
|
|
||||||
1
|
|
||||||
} else if (event1.allDay) {
|
|
||||||
-1
|
|
||||||
} else {
|
|
||||||
event1.startDate.compareTo(event.startDate)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
eventList.reverse()*/
|
|
||||||
|
|
||||||
var found = false
|
var found = false
|
||||||
for (e in eventList) {
|
for (e in eventList) {
|
||||||
if (e.id == SP.getInt(Constants.PREF_NEXT_EVENT_ID, 0)) {
|
if (e.id == SP.getLong(Constants.PREF_EVENT_ID, 0)) {
|
||||||
if (eventList.indexOf(e) < eventList.size - 1) {
|
if (eventList.indexOf(e) < eventList.size - 1) {
|
||||||
SP.edit()
|
SP.edit()
|
||||||
.putInt(Constants.PREF_NEXT_EVENT_ID, eventList[eventList.indexOf(e) + 1]?.id ?: 0)
|
.putLong(Constants.PREF_EVENT_ID, eventList[eventList.indexOf(e) + 1]?.id ?: 0)
|
||||||
.commit()
|
.commit()
|
||||||
} else {
|
} else {
|
||||||
SP.edit()
|
SP.edit()
|
||||||
.putInt(Constants.PREF_NEXT_EVENT_ID, eventList[0]?.id ?: 0)
|
.putLong(Constants.PREF_EVENT_ID, eventList[0]?.id ?: 0)
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
@ -226,7 +196,7 @@ object CalendarUtil {
|
|||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
SP.edit()
|
SP.edit()
|
||||||
.putInt(Constants.PREF_NEXT_EVENT_ID, eventList[0]?.id ?: 0)
|
.putLong(Constants.PREF_EVENT_ID, eventList[0]?.id ?: 0)
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -237,8 +207,7 @@ object CalendarUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getEventsCount(context: Context): Int {
|
fun getEventsCount(context: Context): Int {
|
||||||
Realm.init(context)
|
val db = Util.getRealInstance(context)
|
||||||
val db = Realm.getDefaultInstance()
|
|
||||||
return db.where(Event::class.java).findAll().size
|
return db.where(Event::class.java).findAll().size
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -51,7 +51,7 @@ class CrocodileService : Service() {
|
|||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(this, "Settings")
|
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(this, "Config")
|
||||||
.setSmallIcon(R.drawable.ic_stat_name)
|
.setSmallIcon(R.drawable.ic_stat_name)
|
||||||
.setPriority(Notification.PRIORITY_MIN)
|
.setPriority(Notification.PRIORITY_MIN)
|
||||||
.setColor(ContextCompat.getColor(this, R.color.colorPrimary))
|
.setColor(ContextCompat.getColor(this, R.color.colorPrimary))
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.tommasoberlose.anotherwidget.util;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import io.realm.DynamicRealm;
|
||||||
|
import io.realm.DynamicRealmObject;
|
||||||
|
import io.realm.RealmMigration;
|
||||||
|
import io.realm.RealmObjectSchema;
|
||||||
|
import io.realm.RealmSchema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by tommaso on 06/11/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MyMigration implements RealmMigration {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull DynamicRealm realm, long oldVersion, long newVersion) {
|
||||||
|
|
||||||
|
RealmSchema schema = realm.getSchema();
|
||||||
|
if (oldVersion == 1) {
|
||||||
|
RealmObjectSchema event = schema.get("Event");
|
||||||
|
if (event != null) {
|
||||||
|
if (!event.hasField("eventID")) {
|
||||||
|
event.addField("eventID", long.class);
|
||||||
|
}
|
||||||
|
event
|
||||||
|
.addField("id_tmp", long.class)
|
||||||
|
.transform(new RealmObjectSchema.Function() {
|
||||||
|
@Override
|
||||||
|
public void apply(@NonNull DynamicRealmObject obj) {
|
||||||
|
obj.setLong("id_tmp", obj.getInt("id"));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.removeField("id")
|
||||||
|
.renameField("id_tmp", "id");
|
||||||
|
}
|
||||||
|
oldVersion++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return 37;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return (o instanceof MyMigration);
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,8 @@ import android.widget.RemoteViews
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.tommasoberlose.anotherwidget.`object`.Constants
|
import com.tommasoberlose.anotherwidget.`object`.Constants
|
||||||
import com.tommasoberlose.anotherwidget.`object`.Event
|
import com.tommasoberlose.anotherwidget.`object`.Event
|
||||||
|
import io.realm.Realm
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
@ -68,7 +70,7 @@ object Util {
|
|||||||
val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
||||||
|
|
||||||
if (!Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) {
|
if (!Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) {
|
||||||
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Settings")
|
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Config")
|
||||||
.setSmallIcon(R.drawable.ic_stat_name)
|
.setSmallIcon(R.drawable.ic_stat_name)
|
||||||
.setPriority(Notification.PRIORITY_MIN)
|
.setPriority(Notification.PRIORITY_MIN)
|
||||||
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
||||||
@ -284,7 +286,7 @@ object Util {
|
|||||||
if (SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, "").equals("")) {
|
if (SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, "").equals("")) {
|
||||||
val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
|
val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
|
||||||
weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||||
weatherIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
weatherIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
|
weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
|
||||||
weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
|
weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
|
||||||
return weatherIntent
|
return weatherIntent
|
||||||
@ -295,12 +297,12 @@ object Util {
|
|||||||
return try {
|
return try {
|
||||||
val intent: Intent = pm.getLaunchIntentForPackage(SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, ""))
|
val intent: Intent = pm.getLaunchIntentForPackage(SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, ""))
|
||||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
intent
|
intent
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
|
val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
|
||||||
weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||||
weatherIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
weatherIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
|
weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
|
||||||
weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
|
weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
|
||||||
weatherIntent
|
weatherIntent
|
||||||
@ -311,7 +313,7 @@ object Util {
|
|||||||
fun getEventIntent(context: Context, e: Event): Intent {
|
fun getEventIntent(context: Context, e: Event): Intent {
|
||||||
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
if (SP.getString(Constants.PREF_EVENT_APP_PACKAGE, "").equals("")) {
|
if (SP.getString(Constants.PREF_EVENT_APP_PACKAGE, "").equals("")) {
|
||||||
val uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, e.id.toLong())
|
val uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, e.eventID)
|
||||||
val intent = Intent(Intent.ACTION_VIEW)
|
val intent = Intent(Intent.ACTION_VIEW)
|
||||||
.setData(uri)
|
.setData(uri)
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
@ -380,7 +382,7 @@ object Util {
|
|||||||
val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
||||||
|
|
||||||
if (show) {
|
if (show) {
|
||||||
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Settings")
|
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Config")
|
||||||
.setSmallIcon(R.drawable.ic_stat_name)
|
.setSmallIcon(R.drawable.ic_stat_name)
|
||||||
.setPriority(Notification.PRIORITY_MIN)
|
.setPriority(Notification.PRIORITY_MIN)
|
||||||
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
||||||
@ -402,7 +404,7 @@ object Util {
|
|||||||
val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
val mNotificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager;
|
||||||
|
|
||||||
if (show) {
|
if (show) {
|
||||||
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Settings")
|
val mBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "Config")
|
||||||
.setSmallIcon(R.drawable.ic_stat_name)
|
.setSmallIcon(R.drawable.ic_stat_name)
|
||||||
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
|
||||||
.setContentTitle(context.getString(R.string.settings_weather_provider_api_key_title))
|
.setContentTitle(context.getString(R.string.settings_weather_provider_api_key_title))
|
||||||
@ -566,7 +568,7 @@ object Util {
|
|||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
fun updateSettingsByDefault(context: Context) {
|
fun updateSettingsByDefault(context: Context) {
|
||||||
try {
|
try {
|
||||||
context.startService(Intent(context, CrocodileService::class.java))
|
// context.startService(Intent(context, CrocodileService::class.java))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -584,6 +586,10 @@ object Util {
|
|||||||
editor.commit()
|
editor.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getRealInstance(context: Context): Realm {
|
||||||
|
return Realm.getDefaultInstance()
|
||||||
|
}
|
||||||
|
|
||||||
fun getNextAlarm(context: Context): String? {
|
fun getNextAlarm(context: Context): String? {
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
@ -188,18 +188,13 @@ object WeatherUtil {
|
|||||||
icon = "82"
|
icon = "82"
|
||||||
}
|
}
|
||||||
|
|
||||||
val uiManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
|
return if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 19 || Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 7) {
|
||||||
return when {
|
|
||||||
uiManager.nightMode == UiModeManager.MODE_NIGHT_YES -> icon + "n"
|
|
||||||
uiManager.nightMode == UiModeManager.MODE_NIGHT_NO -> icon + "d"
|
|
||||||
else -> return if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 19 || Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 7) {
|
|
||||||
icon + "n"
|
icon + "n"
|
||||||
} else {
|
} else {
|
||||||
icon + "d"
|
icon + "d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun getWeatherIconResource(icon: String): Int {
|
fun getWeatherIconResource(icon: String): Int {
|
||||||
when (icon) {
|
when (icon) {
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/ic_action_hide_preview.png
Normal file
After Width: | Height: | Size: 854 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_show_preview.png
Normal file
After Width: | Height: | Size: 770 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_hide_preview.png
Normal file
After Width: | Height: | Size: 527 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_show_preview.png
Normal file
After Width: | Height: | Size: 500 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_hide_preview.png
Normal file
After Width: | Height: | Size: 981 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_show_preview.png
Normal file
After Width: | Height: | Size: 980 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_hide_preview.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_show_preview.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
@ -36,6 +36,35 @@
|
|||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:textColor="@android:color/black" />
|
android:textColor="@android:color/black" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:id="@+id/action_toggle_widget_preview"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:id="@+id/widget_preview_icon"
|
||||||
|
android:tint="@android:color/black"
|
||||||
|
android:src="@drawable/ic_action_rate"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/action_hide_widget_preview"
|
||||||
|
style="@style/AnotherWidget.Settings.Title"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:id="@+id/widget_preview_label"
|
||||||
|
android:textColor="@android:color/black"/>
|
||||||
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:gravity="right"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:text="@string/loading_text"
|
android:text="@string/loading_text"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
|
@ -18,11 +18,23 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:id="@+id/intent_container" />
|
android:id="@+id/intent_container" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/bottom_divider_8"
|
||||||
|
android:orientation="vertical" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="16dp"
|
android:layout_height="16dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:id="@+id/bottom_divider"
|
android:id="@+id/bottom_divider_16"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/bottom_divider_24"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -151,4 +151,6 @@
|
|||||||
<string name="donation_lunch">Una Pranzo Veloce</string>
|
<string name="donation_lunch">Una Pranzo Veloce</string>
|
||||||
<string name="background_service_title">Another Widget è attivo</string>
|
<string name="background_service_title">Another Widget è attivo</string>
|
||||||
<string name="background_service_subtitle">AW è attivo in background</string>
|
<string name="background_service_subtitle">AW è attivo in background</string>
|
||||||
|
<string name="action_show_widget_preview">Mostra Anteprima Widget</string>
|
||||||
|
<string name="action_hide_widget_preview">Nascondi Anteprima Widget</string>
|
||||||
</resources>
|
</resources>
|
@ -156,4 +156,6 @@
|
|||||||
<string name="donation_lunch">A Quick Lunch</string>
|
<string name="donation_lunch">A Quick Lunch</string>
|
||||||
<string name="background_service_title">Another Widget is Running</string>
|
<string name="background_service_title">Another Widget is Running</string>
|
||||||
<string name="background_service_subtitle">AW is running in the background</string>
|
<string name="background_service_subtitle">AW is running in the background</string>
|
||||||
|
<string name="action_show_widget_preview">Show Widget Preview</string>
|
||||||
|
<string name="action_hide_widget_preview">Hide Widget Preview</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
android:minResizeHeight="60dp"
|
android:minResizeHeight="60dp"
|
||||||
android:minResizeWidth="300dp"
|
android:minResizeWidth="300dp"
|
||||||
android:previewImage="@drawable/widget_preview"
|
android:previewImage="@drawable/widget_preview"
|
||||||
android:resizeMode="vertical"
|
android:resizeMode="vertical|horizontal"
|
||||||
android:updatePeriodMillis="60000"
|
android:updatePeriodMillis="60000"
|
||||||
android:widgetCategory="home_screen" />
|
android:widgetCategory="home_screen" />
|
@ -7,6 +7,6 @@
|
|||||||
android:minResizeHeight="60dp"
|
android:minResizeHeight="60dp"
|
||||||
android:minResizeWidth="300dp"
|
android:minResizeWidth="300dp"
|
||||||
android:previewImage="@drawable/widget_preview"
|
android:previewImage="@drawable/widget_preview"
|
||||||
android:resizeMode="vertical"
|
android:resizeMode="vertical|horizontal"
|
||||||
android:updatePeriodMillis="60000"
|
android:updatePeriodMillis="60000"
|
||||||
android:widgetCategory="home_screen" />
|
android:widgetCategory="home_screen" />
|