Text Shadow, Clock, Product Sans Font, Multiple Events and more

This commit is contained in:
Tommaso Berlose 2017-11-05 22:06:39 +01:00
parent fde3fdfab1
commit 748249fed5
45 changed files with 1101 additions and 224 deletions

View File

@ -8,6 +8,8 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
apply plugin: 'realm-android'
android { android {
compileSdkVersion 26 compileSdkVersion 26
buildToolsVersion "26.0.2" buildToolsVersion "26.0.2"
@ -15,8 +17,8 @@ android {
applicationId "com.tommasoberlose.anotherwidget" applicationId "com.tommasoberlose.anotherwidget"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 26 targetSdkVersion 26
versionCode 22 versionCode 25
versionName "1.2" versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@ -53,4 +55,5 @@ dependencies {
implementation 'com.pes.materialcolorpicker:library:1.0.4' implementation 'com.pes.materialcolorpicker:library:1.0.4'
implementation 'com.andkulikov:transitionseverywhere:1.7.6' implementation 'com.andkulikov:transitionseverywhere:1.7.6'
implementation 'me.everything:providers-android:1.0.1' implementation 'me.everything:providers-android:1.0.1'
compile 'com.anjlab.android.iab.v3:library:1.0.44'
} }

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":22},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}] [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":24},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]

View File

@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.android.vending.BILLING" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -50,6 +51,9 @@
<data android:scheme="content" /> <data android:scheme="content" />
<data android:host="com.android.calendar" /> <data android:host="com.android.calendar" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="com.tommasoberlose.anotherwidget.action.GO_TO_NEXT_EVENT" />
</intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name=".receiver.UpdatesReceiver" android:name=".receiver.UpdatesReceiver"
@ -114,6 +118,13 @@
<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>
</receiver> </receiver>
<service
android:name=".util.CrocodileService"
android:enabled="true"
android:exported="true" />
<activity android:name=".ui.activity.SupportDevActivity"></activity>
</application> </application>
</manifest> </manifest>

View File

@ -67,6 +67,10 @@ object Constants {
val PREF_SHOW_DECLINED_EVENTS = "PREF_SHOW_DECLINED_EVENTS" val PREF_SHOW_DECLINED_EVENTS = "PREF_SHOW_DECLINED_EVENTS"
val PREF_OPEN_WEATHER_API_KEY = "PREF_OPEN_WEATHER_API_KEY" val PREF_OPEN_WEATHER_API_KEY = "PREF_OPEN_WEATHER_API_KEY"
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_SHOW_NEXT_EVENT = "PREF_SHOW_NEXT_EVENT"
val CUSTOM_FONT_PRODUCT_SANS = 1
val ACTION_EXTRA_OPEN_WEATHER_PROVIDER = "ACTION_EXTRA_OPEN_WEATHER_PROVIDER" val ACTION_EXTRA_OPEN_WEATHER_PROVIDER = "ACTION_EXTRA_OPEN_WEATHER_PROVIDER"
@ -80,6 +84,7 @@ object Constants {
val ACTION_WEATHER_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_WEATHER_UPDATE" val ACTION_WEATHER_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_WEATHER_UPDATE"
val ACTION_SOMETHING_HAPPENED = "com.tommasoberlose.anotherwidget.action.ACTION_SOMETHING_HAPPENED" val ACTION_SOMETHING_HAPPENED = "com.tommasoberlose.anotherwidget.action.ACTION_SOMETHING_HAPPENED"
val ACTION_OPEN_WEATHER_INTENT = "com.tommasoberlose.anotherwidget.action.ACTION_OPEN_WEATHER_INTENT" val ACTION_OPEN_WEATHER_INTENT = "com.tommasoberlose.anotherwidget.action.ACTION_OPEN_WEATHER_INTENT"
val ACTION_GO_TO_NEXT_EVENT = "com.tommasoberlose.anotherwidget.action.GO_TO_NEXT_EVENT"
val WEATHER_PROVIDER_GOOGLE_AWARENESS = 1 val WEATHER_PROVIDER_GOOGLE_AWARENESS = 1
val WEATHER_PROVIDER_OPEN_WEATHER = 2 val WEATHER_PROVIDER_OPEN_WEATHER = 2

View File

@ -1,6 +1,8 @@
package com.tommasoberlose.anotherwidget.`object` package com.tommasoberlose.anotherwidget.`object`
import android.database.Cursor import android.database.Cursor
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.Date import java.util.Date
@ -8,37 +10,15 @@ import java.util.Date
* Created by tommaso on 05/10/17. * Created by tommaso on 05/10/17.
*/ */
class Event { open class Event(var id: Int = 0,
var id: Int = 0 var title: String = "",
var title: String = "" var startDate: Long = 0,
var startDate: Long = 0 var endDate: Long = 0,
var endDate: Long = 0 var calendarID: Int = 0,
var calendarID: Int = 0 var allDay: Boolean = false,
var allDay: Boolean = false var address: String = ""): RealmObject(){
var address: String = ""
constructor(id:Int, title:String, startDate:Long, endDate:Long, calendarID: Int, allDay: Boolean, address: String) {
this.id = id
this.title = title
this.startDate = startDate
this.endDate = endDate
this.calendarID = calendarID
this.allDay = allDay
this.address = address
}
constructor(eventCursor: Cursor, instanceCursor: Cursor) {
id = instanceCursor.getInt(0)
startDate = instanceCursor.getLong(1)
endDate = instanceCursor.getLong(2)
title = eventCursor.getString(0)?: ""
allDay = !eventCursor.getString(1).equals("0")
calendarID = eventCursor.getInt(2)
address = eventCursor.getString(3)?: ""
}
override fun toString(): String { override fun toString(): String {
return "Event:\nID" + id + "\nTITLE: " + title + "\nSTART DATE: " + Date(startDate) + "\nEND DATE: " + Date(endDate) return "Event:\nID: " + id + "\nTITLE: " + title + "\nSTART DATE: " + Date(startDate) + "\nEND DATE: " + Date(endDate) + "\nCAL DAY: " + calendarID + "\nADDRESS: " + address
} }
} }

View File

@ -4,6 +4,7 @@ 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 android.util.Log
import com.tommasoberlose.anotherwidget.`object`.Constants
import com.tommasoberlose.anotherwidget.util.CalendarUtil import com.tommasoberlose.anotherwidget.util.CalendarUtil
import com.tommasoberlose.anotherwidget.util.Util import com.tommasoberlose.anotherwidget.util.Util
@ -12,6 +13,8 @@ class NewCalendarEventReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
if (intent.action.equals(Intent.ACTION_PROVIDER_CHANGED)) { if (intent.action.equals(Intent.ACTION_PROVIDER_CHANGED)) {
CalendarUtil.updateEventList(context) CalendarUtil.updateEventList(context)
} else if (intent.action == Constants.ACTION_GO_TO_NEXT_EVENT) {
CalendarUtil.goToNextEvent(context)
} }
} }
} }

View File

@ -12,6 +12,7 @@ import android.util.Log
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 com.tommasoberlose.anotherwidget.util.CalendarUtil import com.tommasoberlose.anotherwidget.util.CalendarUtil
import com.tommasoberlose.anotherwidget.util.CrocodileService
import com.tommasoberlose.anotherwidget.util.Util import com.tommasoberlose.anotherwidget.util.Util
import java.sql.Time import java.sql.Time
import java.util.* import java.util.*
@ -36,8 +37,10 @@ class UpdatesReceiver : BroadcastReceiver() {
} }
fun setUpdates(context: Context) { fun setUpdates(context: Context) {
removeUpdates(context)
CalendarUtil.updateEventList(context) CalendarUtil.updateEventList(context)
removeUpdates(context)
context.startService(Intent(context, CrocodileService::class.java))
/*
val now = Calendar.getInstance() val now = Calendar.getInstance()
now.set(Calendar.MILLISECOND, 0) now.set(Calendar.MILLISECOND, 0)
now.set(Calendar.SECOND, 0) now.set(Calendar.SECOND, 0)
@ -46,7 +49,7 @@ class UpdatesReceiver : BroadcastReceiver() {
val i = Intent(context, UpdatesReceiver::class.java) val i = Intent(context, UpdatesReceiver::class.java)
i.action = Constants.ACTION_TIME_UPDATE i.action = Constants.ACTION_TIME_UPDATE
val pi = PendingIntent.getBroadcast(context, 0, i, 0) val pi = PendingIntent.getBroadcast(context, 0, i, 0)
am.setRepeating(AlarmManager.RTC_WAKEUP, now.timeInMillis, (1000 * 60).toLong(), pi) am.setRepeating(AlarmManager.RTC_WAKEUP, now.timeInMillis, (1000 * 60).toLong(), pi) */
} }
fun removeUpdates(context: Context) { fun removeUpdates(context: Context) {

View File

@ -23,6 +23,7 @@ import android.support.v7.widget.LinearLayoutManager
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.util.Log import android.util.Log
import android.view.View
import com.tommasoberlose.anotherwidget.`object`.AppInfoSavedEvent import com.tommasoberlose.anotherwidget.`object`.AppInfoSavedEvent
import com.tommasoberlose.anotherwidget.ui.adapter.ApplicationInfoAdapter import com.tommasoberlose.anotherwidget.ui.adapter.ApplicationInfoAdapter
@ -41,6 +42,14 @@ class ChooseApplicationActivity : AppCompatActivity() {
selectDefaultApp() selectDefaultApp()
} }
action_back.setOnClickListener {
onBackPressed()
}
action_none.setOnClickListener {
removeClickAction()
}
list_view.setHasFixedSize(true); list_view.setHasFixedSize(true);
val mLayoutManager = LinearLayoutManager(this); val mLayoutManager = LinearLayoutManager(this);
list_view.layoutManager = mLayoutManager; list_view.layoutManager = mLayoutManager;
@ -67,9 +76,25 @@ class ChooseApplicationActivity : AppCompatActivity() {
fun selectDefaultApp() { fun selectDefaultApp() {
val resultIntent = Intent() val resultIntent = Intent()
resultIntent.putExtra(Constants.RESULT_APP_NAME, getString(R.string.default_name)) resultIntent.putExtra(Constants.RESULT_APP_NAME, "")
resultIntent.putExtra(Constants.RESULT_APP_PACKAGE, "") resultIntent.putExtra(Constants.RESULT_APP_PACKAGE, "")
setResult(Activity.RESULT_OK, intent) setResult(Activity.RESULT_OK, resultIntent)
finish()
}
fun removeClickAction() {
val resultIntent = Intent()
resultIntent.putExtra(Constants.RESULT_APP_NAME, getString(R.string.action_none))
resultIntent.putExtra(Constants.RESULT_APP_PACKAGE, "_")
setResult(Activity.RESULT_OK, resultIntent)
finish()
}
fun multiEventAction() {
val resultIntent = Intent()
resultIntent.putExtra(Constants.RESULT_APP_NAME, getString(R.string.action_go_to_next_event))
resultIntent.putExtra(Constants.RESULT_APP_PACKAGE, Constants.PREF_SHOW_NEXT_EVENT)
setResult(Activity.RESULT_OK, resultIntent)
finish() finish()
} }

View File

@ -30,6 +30,9 @@ import android.os.Build
import android.support.design.widget.BottomSheetDialog import android.support.design.widget.BottomSheetDialog
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.text.Html import android.text.Html
import android.text.Spannable
import android.text.SpannableString
import android.text.style.RelativeSizeSpan
import android.util.Log import android.util.Log
import android.util.TypedValue import android.util.TypedValue
import android.widget.Toast import android.widget.Toast
@ -42,6 +45,7 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.key_time_wait_layout.view.* import kotlinx.android.synthetic.main.key_time_wait_layout.view.*
import kotlinx.android.synthetic.main.main_menu_layout.view.* import kotlinx.android.synthetic.main.main_menu_layout.view.*
import kotlinx.android.synthetic.main.the_widget.* import kotlinx.android.synthetic.main.the_widget.*
import kotlinx.android.synthetic.main.the_widget.view.*
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -113,6 +117,12 @@ class MainActivity : AppCompatActivity() {
Util.updateWidget(this) Util.updateWidget(this)
mBottomSheetDialog.dismiss() mBottomSheetDialog.dismiss()
} }
menuView.action_support.setOnClickListener {
startActivity(Intent(this, SupportDevActivity::class.java))
mBottomSheetDialog.dismiss()
}
mBottomSheetDialog.setContentView(menuView) mBottomSheetDialog.setContentView(menuView)
mBottomSheetDialog.show(); mBottomSheetDialog.show();
} }
@ -193,28 +203,28 @@ class MainActivity : AppCompatActivity() {
updateSettings() updateSettings()
} else if (requestCode == Constants.CALENDAR_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) { } else if (requestCode == Constants.CALENDAR_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
SP.edit() SP.edit()
.putString(Constants.PREF_CALENDAR_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME)) .putString(Constants.PREF_CALENDAR_APP_NAME, if (data.getStringExtra(Constants.RESULT_APP_NAME) != "") data.getStringExtra(Constants.RESULT_APP_NAME) else getString(R.string.default_calendar_app))
.putString(Constants.PREF_CALENDAR_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE)) .putString(Constants.PREF_CALENDAR_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
.commit() .commit()
Util.updateWidget(this) Util.updateWidget(this)
updateSettings() updateSettings()
} else if (requestCode == Constants.WEATHER_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) { } else if (requestCode == Constants.WEATHER_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
SP.edit() SP.edit()
.putString(Constants.PREF_WEATHER_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME)) .putString(Constants.PREF_WEATHER_APP_NAME, if (data.getStringExtra(Constants.RESULT_APP_NAME) != "") data.getStringExtra(Constants.RESULT_APP_NAME) else getString(R.string.default_weather_app))
.putString(Constants.PREF_WEATHER_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE)) .putString(Constants.PREF_WEATHER_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
.commit() .commit()
Util.updateWidget(this) Util.updateWidget(this)
updateSettings() updateSettings()
} else if (requestCode == Constants.EVENT_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) { } else if (requestCode == Constants.EVENT_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
SP.edit() SP.edit()
.putString(Constants.PREF_EVENT_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME)) .putString(Constants.PREF_EVENT_APP_NAME, if (data.getStringExtra(Constants.RESULT_APP_NAME) != "") data.getStringExtra(Constants.RESULT_APP_NAME) else getString(R.string.default_event_app))
.putString(Constants.PREF_EVENT_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE)) .putString(Constants.PREF_EVENT_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
.commit() .commit()
Util.updateWidget(this) Util.updateWidget(this)
updateSettings() updateSettings()
} else if (requestCode == Constants.CLOCK_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) { } else if (requestCode == Constants.CLOCK_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
SP.edit() SP.edit()
.putString(Constants.PREF_CLOCK_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME)) .putString(Constants.PREF_CLOCK_APP_NAME, if (data.getStringExtra(Constants.RESULT_APP_NAME) != "") data.getStringExtra(Constants.RESULT_APP_NAME) else getString(R.string.default_clock_app))
.putString(Constants.PREF_CLOCK_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE)) .putString(Constants.PREF_CLOCK_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
.commit() .commit()
Util.updateWidget(this) Util.updateWidget(this)
@ -234,7 +244,15 @@ class MainActivity : AppCompatActivity() {
time.visibility = View.VISIBLE time.visibility = View.VISIBLE
} }
val now = Calendar.getInstance() val now = Calendar.getInstance()
time.text = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(now.timeInMillis) else Constants.goodHourFormat.format(now.timeInMillis) if (SP.getString(Constants.PREF_HOUR_FORMAT, "12") == "12") {
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis))
textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
textBadHour.length, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
time.text = textBadHour
} else {
time.text = Constants.goodHourFormat.format(now.timeInMillis)
}
} }
fun updateCalendarView() { fun updateCalendarView() {
@ -255,6 +273,13 @@ class MainActivity : AppCompatActivity() {
if (e.id != 0) { if (e.id != 0) {
next_event.text = e.title next_event.text = e.title
if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, false) && CalendarUtil.getEventsCount(this) > 1) {
multiple_events.visibility = View.VISIBLE
} else {
multiple_events.visibility = View.GONE
}
if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) { if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) {
next_event_difference_time.text = Util.getDifferenceText(this, now.timeInMillis, e.startDate) next_event_difference_time.text = Util.getDifferenceText(this, now.timeInMillis, e.startDate)
next_event_difference_time.visibility = View.VISIBLE next_event_difference_time.visibility = View.VISIBLE
@ -324,6 +349,12 @@ class MainActivity : AppCompatActivity() {
calendar_temp.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) calendar_temp.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
time.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f)) time.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
multiple_events.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
multiple_events.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
val shadowRadius = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { val shadowRadius = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) {
0 -> 0f 0 -> 0f
1 -> 5f 1 -> 5f
@ -352,7 +383,7 @@ class MainActivity : AppCompatActivity() {
calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor) calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor)
time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor)
if (SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS) == Constants.CUSTOM_FONT_PRODUCT_SANS) {
val product_sans: Typeface = Typeface.createFromAsset(assets, "fonts/product_sans_regular.ttf") val product_sans: Typeface = Typeface.createFromAsset(assets, "fonts/product_sans_regular.ttf")
empty_date.typeface = product_sans empty_date.typeface = product_sans
divider1.typeface = product_sans divider1.typeface = product_sans
@ -363,6 +394,17 @@ class MainActivity : AppCompatActivity() {
divider2.typeface = product_sans divider2.typeface = product_sans
calendar_temp.typeface = product_sans calendar_temp.typeface = product_sans
time.typeface = product_sans time.typeface = product_sans
} else {
empty_date.typeface = Typeface.DEFAULT
divider1.typeface = Typeface.DEFAULT
temp.typeface = Typeface.DEFAULT
next_event.typeface = Typeface.DEFAULT
next_event_difference_time.typeface = Typeface.DEFAULT
next_event_date.typeface = Typeface.DEFAULT
divider2.typeface = Typeface.DEFAULT
calendar_temp.typeface = Typeface.DEFAULT
time.typeface = Typeface.DEFAULT
}
} }
fun updateLocationView() { fun updateLocationView() {
@ -489,6 +531,13 @@ class MainActivity : AppCompatActivity() {
updateSettings() updateSettings()
} }
show_multiple_events_label.text = if (SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, true)) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
action_show_multiple_events.setOnClickListener {
SP.edit().putBoolean(Constants.PREF_SHOW_NEXT_EVENT, !SP.getBoolean(Constants.PREF_SHOW_NEXT_EVENT, true)).commit()
sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
updateSettings()
}
show_diff_time_label.text = if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) getString(R.string.settings_visible) else getString(R.string.settings_not_visible) show_diff_time_label.text = if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
action_show_diff_time.setOnClickListener { action_show_diff_time.setOnClickListener {
SP.edit().putBoolean(Constants.PREF_SHOW_DIFF_TIME, !SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)).commit() SP.edit().putBoolean(Constants.PREF_SHOW_DIFF_TIME, !SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)).commit()
@ -526,7 +575,7 @@ class MainActivity : AppCompatActivity() {
main_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f), "sp") main_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f), "sp")
action_main_text_size.setOnClickListener { action_main_text_size.setOnClickListener {
var fontSize = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) + 1 var fontSize = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) + 1
if (fontSize > 30) { if (fontSize > 36) {
fontSize = 20f fontSize = 20f
} }
SP.edit().putFloat(Constants.PREF_TEXT_MAIN_SIZE, fontSize).commit() SP.edit().putFloat(Constants.PREF_TEXT_MAIN_SIZE, fontSize).commit()
@ -538,13 +587,12 @@ class MainActivity : AppCompatActivity() {
second_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f), "sp") second_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f), "sp")
action_second_text_size.setOnClickListener { action_second_text_size.setOnClickListener {
var fontSize = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) + 1 var fontSize = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) + 1
if (fontSize > 20) { if (fontSize > 28) {
fontSize = 12f fontSize = 12f
} }
SP.edit().putFloat(Constants.PREF_TEXT_SECOND_SIZE, fontSize).commit() SP.edit().putFloat(Constants.PREF_TEXT_SECOND_SIZE, fontSize).commit()
Util.updateWidget(this) Util.updateWidget(this)
updateSettings() updateSettings()
updateAppWidget()
} }
clock_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f), "sp") clock_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f), "sp")
@ -556,7 +604,6 @@ class MainActivity : AppCompatActivity() {
SP.edit().putFloat(Constants.PREF_TEXT_CLOCK_SIZE, fontSize).commit() SP.edit().putFloat(Constants.PREF_TEXT_CLOCK_SIZE, fontSize).commit()
Util.updateWidget(this) Util.updateWidget(this)
updateSettings() updateSettings()
updateAppWidget()
} }
val textColor = try { val textColor = try {
@ -621,14 +668,15 @@ class MainActivity : AppCompatActivity() {
3 -> 4 3 -> 4
4 -> 5 4 -> 5
5 -> 6 5 -> 6
6 -> 0 6 -> 7
7 -> 0
else -> 1 else -> 1
}).commit() }).commit()
updateSettings() updateSettings()
sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE)) sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE))
} }
text_shadow_label.text = getString(Util.getTextshadowString(SP.getInt(Constants.PREF_TEXT_SHADOW, 1))) text_shadow_label.text = getString(Util.getTextShadowString(SP.getInt(Constants.PREF_TEXT_SHADOW, 1)))
action_text_shadow.setOnClickListener { action_text_shadow.setOnClickListener {
SP.edit().putInt(Constants.PREF_TEXT_SHADOW, when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { SP.edit().putInt(Constants.PREF_TEXT_SHADOW, when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) {
0 -> 1 0 -> 1
@ -641,6 +689,18 @@ class MainActivity : AppCompatActivity() {
updateAppWidget() updateAppWidget()
} }
custom_font_label.text = getString(Util.getCustomFontLabel(SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS)))
action_custom_font.setOnClickListener {
SP.edit().putInt(Constants.PREF_CUSTOM_FONT, when (SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS)) {
0 -> Constants.CUSTOM_FONT_PRODUCT_SANS
Constants.CUSTOM_FONT_PRODUCT_SANS -> 0
else -> Constants.CUSTOM_FONT_PRODUCT_SANS
}).commit()
sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
updateSettings()
updateAppWidget()
}
if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) { if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) {
action_custom_location.visibility = View.GONE action_custom_location.visibility = View.GONE
} else { } else {
@ -675,7 +735,9 @@ class MainActivity : AppCompatActivity() {
calendar_app_label.text = SP.getString(Constants.PREF_CALENDAR_APP_NAME, getString(R.string.default_calendar_app)) calendar_app_label.text = SP.getString(Constants.PREF_CALENDAR_APP_NAME, getString(R.string.default_calendar_app))
action_calendar_app.setOnClickListener { action_calendar_app.setOnClickListener {
startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.CALENDAR_APP_REQUEST_CODE) val i = Intent(this, ChooseApplicationActivity::class.java)
i.putExtra("requestCode", Constants.CALENDAR_APP_REQUEST_CODE)
startActivityForResult(i, Constants.CALENDAR_APP_REQUEST_CODE)
} }
weather_app_label.text = SP.getString(Constants.PREF_WEATHER_APP_NAME, getString(R.string.default_weather_app)) weather_app_label.text = SP.getString(Constants.PREF_WEATHER_APP_NAME, getString(R.string.default_weather_app))

View File

@ -0,0 +1,99 @@
package com.tommasoberlose.anotherwidget.ui.activity
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.anjlab.android.iab.v3.BillingProcessor
import com.anjlab.android.iab.v3.TransactionDetails
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.util.Util
import kotlinx.android.synthetic.main.activity_support_dev.*
class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler {
internal var bp: BillingProcessor? = null
internal val BILLING_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAox5CcxuoLJ6CmNS7s6lVQzJ253njKKGF8MoQ/gQ5gEw2Fr03fBvtHpiVMpnjhNLw5NMeIpzRvkVqeQ7BfkC7c0BLCJUqf/fFA11ArQe8na6QKt5O4d+v4sbHtP7mm3GQNPOBaqRzcpFZaiAbfk6mnalo+tzM47GXrQFt5bNSrMctCs7bbChqJfH2cyMW0F8DHWEEeO5xElBmH3lh4FVpwIUTPYJIV3n0yhE3qqRA0WXkDej66g/uAt/rebmMZLmwNwIive5cObU4o41YyKRv2wSAicrv3W40LftzXAOOordIbmzDFN8ksh3VrnESqwCDGG97nZVbPG/+3LD0xHWiRwIDAQAB"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_support_dev)
bp = BillingProcessor(this, BILLING_KEY, this)
action_website.setOnClickListener {
Util.openURI(this, "http://tommasoberlose.com/")
}
action_translate.setOnClickListener {
Util.openURI(this, "https://github.com/tommasoberlose/another-widget/blob/master/app/src/main/res/values/strings.xml")
}
}
override fun onBillingInitialized() {
loader.visibility = View.GONE
val isAvailable = BillingProcessor.isIabServiceAvailable(this)
val isOneTimePurchaseSupported = bp!!.isOneTimePurchaseSupported
if (isAvailable && isOneTimePurchaseSupported) {
val coffee = bp!!.getPurchaseListingDetails("donation_coffee")
val donuts = bp!!.getPurchaseListingDetails("donation_donuts")
val breakfast = bp!!.getPurchaseListingDetails("donation_breakfast")
val lunch = bp!!.getPurchaseListingDetails("donation_lunch")
val dinner = bp!!.getPurchaseListingDetails("donation_dinner")
import_donation_coffee.text = coffee.priceText
action_donation_coffee.setOnClickListener {
bp!!.purchase(this, "donation_coffee")
}
import_donation_donuts.text = donuts.priceText
action_donation_donuts.setOnClickListener {
bp!!.purchase(this, "donation_donuts")
}
import_donation_breakfast.text = breakfast.priceText
action_donation_breakfast.setOnClickListener {
bp!!.purchase(this, "donation_breakfast")
}
import_donation_lunch.text = lunch.priceText
action_donation_lunch.setOnClickListener {
bp!!.purchase(this, "donation_lunch")
}
import_donation_dinner.text = dinner.priceText
action_donation_dinner.setOnClickListener {
bp!!.purchase(this, "donation_dinner")
}
products_list.visibility = View.VISIBLE
} else {
products_card.visibility = View.GONE
}
}
override fun onPurchaseHistoryRestored() {
}
override fun onProductPurchased(productId: String, details: TransactionDetails?) {
Toast.makeText(this, R.string.thanks, Toast.LENGTH_SHORT).show()
bp!!.consumePurchase(productId)
}
override fun onBillingError(errorCode: Int, error: Throwable?) {
Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
if (!bp!!.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data)
}
}
public override fun onDestroy() {
if (bp != null) {
bp!!.release()
}
super.onDestroy()
}
}

View File

@ -0,0 +1,38 @@
package com.tommasoberlose.anotherwidget.ui.view
import android.graphics.Paint
import android.graphics.Typeface
import android.text.TextPaint
import android.text.style.TypefaceSpan
class CustomTypefaceSpan(family: String, private val newType: Typeface) : TypefaceSpan(family) {
override fun updateDrawState(ds: TextPaint) {
applyCustomTypeFace(ds, newType)
}
override fun updateMeasureState(paint: TextPaint) {
applyCustomTypeFace(paint, newType)
}
private fun applyCustomTypeFace(paint: Paint, tf: Typeface) {
val oldStyle: Int
val old = paint.typeface
if (old == null) {
oldStyle = 0
} else {
oldStyle = old.style
}
val fake = oldStyle and tf.style.inv()
if (fake and Typeface.BOLD != 0) {
paint.isFakeBoldText = true
}
if (fake and Typeface.ITALIC != 0) {
paint.textSkewX = -0.25f
}
paint.typeface = tf
}
}

View File

@ -38,8 +38,13 @@ import android.os.Bundle
import android.support.v4.content.ContextCompat.startActivity import android.support.v4.content.ContextCompat.startActivity
import android.provider.CalendarContract.Events import android.provider.CalendarContract.Events
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.text.Spannable
import android.text.SpannableString
import android.text.style.RelativeSizeSpan
import android.text.style.StyleSpan
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.util.TypedValue import android.util.TypedValue
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.*
@ -77,25 +82,21 @@ class TheWidget : AppWidgetProvider() {
internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager,
appWidgetId: Int) { appWidgetId: Int) {
val displayMetrics = Resources.getSystem().getDisplayMetrics() val SP = PreferenceManager.getDefaultSharedPreferences(context)
val height = displayMetrics.heightPixels val displayMetrics = Resources.getSystem().displayMetrics
val widgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId)
var height = widgetInfo.minHeight
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
height += Util.convertSpToPixels(SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f), context).toInt() + Util.convertDpToPixel(8f, context).toInt()
}
val width = displayMetrics.widthPixels val width = displayMetrics.widthPixels
val widgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId) generateWidgetView(context, appWidgetId, appWidgetManager, width - Util.convertDpToPixel(16f, context).toInt(), height)
generateWidgetView(context, appWidgetId, appWidgetManager, width - Util.convertDpToPixel(32f, context).toInt(), widgetInfo.minHeight)
} }
fun generateWidgetView(context: Context, appWidgetId: Int, appWidgetManager: AppWidgetManager, w: Int, h: Int) { fun generateWidgetView(context: Context, appWidgetId: Int, appWidgetManager: AppWidgetManager, w: Int, h: Int) {
var views = RemoteViews(context.packageName, R.layout.the_widget_sans) var views = RemoteViews(context.packageName, R.layout.the_widget_sans)
var v = View.inflate(context, R.layout.the_widget, null) var v = View.inflate(context, R.layout.the_widget, null)
v = updateCalendarViewByLayout(context, v)
v = updateLocationViewByLayout(context, v)
v = updateClockViewByLayout(context, v)
views.setImageViewBitmap(R.id.bitmap_container, Util.getBitmapFromView(v, w, h))
views = updateCalendarView(context, views, appWidgetId)
views = updateLocationView(context, views, appWidgetId)
views = updateClockView(context, views, appWidgetId)
val SP = PreferenceManager.getDefaultSharedPreferences(context) val SP = PreferenceManager.getDefaultSharedPreferences(context)
views.setTextColor(R.id.empty_date, Util.getFontColor(SP)) views.setTextColor(R.id.empty_date, Util.getFontColor(SP))
@ -106,6 +107,7 @@ class TheWidget : AppWidgetProvider() {
views.setTextColor(R.id.next_event_date, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context))) views.setTextColor(R.id.next_event_date, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextColor(R.id.divider2, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context))) views.setTextColor(R.id.divider2, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextColor(R.id.calendar_temp, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context))) views.setTextColor(R.id.calendar_temp, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextColor(R.id.time, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextViewTextSize(R.id.empty_date, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f)) views.setTextViewTextSize(R.id.empty_date, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f))
views.setTextViewTextSize(R.id.divider1, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) views.setTextViewTextSize(R.id.divider1, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
@ -115,6 +117,16 @@ class TheWidget : AppWidgetProvider() {
views.setTextViewTextSize(R.id.next_event_date, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) views.setTextViewTextSize(R.id.next_event_date, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
views.setTextViewTextSize(R.id.divider2, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) views.setTextViewTextSize(R.id.divider2, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
views.setTextViewTextSize(R.id.calendar_temp, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) views.setTextViewTextSize(R.id.calendar_temp, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
views.setTextViewTextSize(R.id.time, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
v = updateCalendarViewByLayout(context, v)
v = updateLocationViewByLayout(context, v)
v = updateClockViewByLayout(context, v)
views.setImageViewBitmap(R.id.bitmap_container, Util.getBitmapFromView(v, w, h))
views = updateCalendarView(context, views, appWidgetId)
views = updateLocationView(context, views, appWidgetId)
views = updateClockView(context, views, appWidgetId)
appWidgetManager.updateAppWidget(appWidgetId, views) appWidgetManager.updateAppWidget(appWidgetId, views)
} }
@ -142,6 +154,19 @@ class TheWidget : AppWidgetProvider() {
if (e.id != 0) { if (e.id != 0) {
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) {
val multipleIntent = PendingIntent.getBroadcast(context, widgetID, Intent(Constants.ACTION_GO_TO_NEXT_EVENT), 0)
views.setViewVisibility(R.id.multiple_events, View.VISIBLE)
views.setOnClickPendingIntent(R.id.multiple_events, multipleIntent)
} else {
views.setViewVisibility(R.id.multiple_events, View.GONE)
}
val pIntent = PendingIntent.getActivity(context, widgetID, Util.getEventIntent(context, e), 0)
views.setOnClickPendingIntent(R.id.next_event, pIntent)
views.setOnClickPendingIntent(R.id.next_event_difference_time, pIntent)
if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) { if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) {
views.setTextViewText(R.id.next_event_difference_time, Util.getDifferenceText(context, now.timeInMillis, e.startDate)) views.setTextViewText(R.id.next_event_difference_time, Util.getDifferenceText(context, now.timeInMillis, e.startDate))
views.setViewVisibility(R.id.next_event_difference_time, View.VISIBLE) views.setViewVisibility(R.id.next_event_difference_time, View.VISIBLE)
@ -174,8 +199,12 @@ class TheWidget : AppWidgetProvider() {
views.setImageViewBitmap(R.id.second_row_icon, result) views.setImageViewBitmap(R.id.second_row_icon, result)
if (!e.allDay) { if (!e.allDay) {
val startHour: String = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(e.startDate) else Constants.goodHourFormat.format(e.startDate) var startHour = Constants.goodHourFormat.format(e.startDate)
val endHour: String = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(e.endDate) else Constants.goodHourFormat.format(e.endDate) var endHour = Constants.goodHourFormat.format(e.endDate)
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
startHour = Constants.badHourFormat.format(e.startDate)
endHour = Constants.badHourFormat.format(e.endDate)
}
var dayDiff = TimeUnit.MILLISECONDS.toDays(e.endDate - e.startDate) var dayDiff = TimeUnit.MILLISECONDS.toDays(e.endDate - e.startDate)
val startCal = Calendar.getInstance() val startCal = Calendar.getInstance()
@ -199,15 +228,11 @@ class TheWidget : AppWidgetProvider() {
} else { } else {
views.setTextViewText(R.id.next_event_date, dateStringValue) views.setTextViewText(R.id.next_event_date, dateStringValue)
} }
views.setOnClickPendingIntent(R.id.next_event_date, pIntent)
} }
views.setViewVisibility(R.id.empty_layout, View.GONE) views.setViewVisibility(R.id.empty_layout, View.GONE)
views.setViewVisibility(R.id.calendar_layout, View.VISIBLE) views.setViewVisibility(R.id.calendar_layout, View.VISIBLE)
val pIntent = PendingIntent.getActivity(context, widgetID, Util.getEventIntent(context, e), 0)
views.setOnClickPendingIntent(R.id.next_event, pIntent)
views.setOnClickPendingIntent(R.id.next_event_difference_time, pIntent)
views.setOnClickPendingIntent(R.id.next_event_date, pIntent)
} }
} }
@ -258,7 +283,18 @@ class TheWidget : AppWidgetProvider() {
views.setViewVisibility(R.id.time, View.VISIBLE) views.setViewVisibility(R.id.time, View.VISIBLE)
} }
val now = Calendar.getInstance() val now = Calendar.getInstance()
views.setTextViewText(R.id.time, if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(now.timeInMillis) else Constants.goodHourFormat.format(now.timeInMillis))
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
textBadHour.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
views.setTextViewText(R.id.time, textBadHour)
} else {
views.setTextViewText(R.id.time, Constants.goodHourFormat.format(now.timeInMillis))
}
val clockPIntent = PendingIntent.getActivity(context, widgetID, Util.getClockIntent(context), 0) val clockPIntent = PendingIntent.getActivity(context, widgetID, Util.getClockIntent(context), 0)
views.setOnClickPendingIntent(R.id.time, clockPIntent) views.setOnClickPendingIntent(R.id.time, clockPIntent)
@ -285,6 +321,13 @@ class TheWidget : AppWidgetProvider() {
if (e.id != 0) { if (e.id != 0) {
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) {
v.multiple_events.visibility = View.VISIBLE
} else {
v.multiple_events.visibility = View.GONE
}
if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) { if (SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)) {
v.next_event_difference_time.text = Util.getDifferenceText(context, now.timeInMillis, e.startDate) v.next_event_difference_time.text = Util.getDifferenceText(context, now.timeInMillis, e.startDate)
v.next_event_difference_time.visibility = View.VISIBLE v.next_event_difference_time.visibility = View.VISIBLE
@ -301,8 +344,12 @@ class TheWidget : AppWidgetProvider() {
} else { } else {
v.second_row_icon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_action_calendar)) v.second_row_icon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_action_calendar))
if (!e.allDay) { if (!e.allDay) {
val startHour: String = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(e.startDate) else Constants.goodHourFormat.format(e.startDate) var startHour = Constants.goodHourFormat.format(e.startDate)
val endHour: String = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(e.endDate) else Constants.goodHourFormat.format(e.endDate) var endHour = Constants.goodHourFormat.format(e.endDate)
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
startHour = Constants.badHourFormat.format(e.startDate)
endHour = Constants.badHourFormat.format(e.endDate)
}
var dayDiff = TimeUnit.MILLISECONDS.toDays(e.endDate - e.startDate) var dayDiff = TimeUnit.MILLISECONDS.toDays(e.endDate - e.startDate)
val startCal = Calendar.getInstance() val startCal = Calendar.getInstance()
@ -321,6 +368,7 @@ class TheWidget : AppWidgetProvider() {
multipleDay = String.format(" (+%s%s)", dayDiff, context.getString(R.string.day_char)) multipleDay = String.format(" (+%s%s)", dayDiff, context.getString(R.string.day_char))
} }
v.next_event_date.text = String.format("%s - %s%s", startHour, endHour, multipleDay) v.next_event_date.text = String.format("%s - %s%s", startHour, endHour, multipleDay)
} else { } else {
v.next_event_date.text = dateStringValue v.next_event_date.text = dateStringValue
} }
@ -341,6 +389,7 @@ class TheWidget : AppWidgetProvider() {
v.calendar_temp.setTextColor(Util.getFontColor(SP)) v.calendar_temp.setTextColor(Util.getFontColor(SP))
v.second_row_icon.setColorFilter(Util.getFontColor(SP)) v.second_row_icon.setColorFilter(Util.getFontColor(SP))
v.time.setTextColor(Util.getFontColor(SP)) v.time.setTextColor(Util.getFontColor(SP))
v.multiple_events.setColorFilter(Util.getFontColor(SP))
v.empty_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f)) v.empty_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f))
@ -353,6 +402,12 @@ class TheWidget : AppWidgetProvider() {
v.calendar_temp.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) v.calendar_temp.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
v.time.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f)) v.time.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
v.second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
v.second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
v.multiple_events.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
v.multiple_events.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
val shadowRadius = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { val shadowRadius = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) {
0 -> 0f 0 -> 0f
1 -> 5f 1 -> 5f
@ -381,7 +436,7 @@ class TheWidget : AppWidgetProvider() {
v.calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor) v.calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor)
v.time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) v.time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor)
if (SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS) == Constants.CUSTOM_FONT_PRODUCT_SANS) {
val product_sans: Typeface = Typeface.createFromAsset(context.assets, "fonts/product_sans_regular.ttf") val product_sans: Typeface = Typeface.createFromAsset(context.assets, "fonts/product_sans_regular.ttf")
v.empty_date.typeface = product_sans v.empty_date.typeface = product_sans
v.divider1.typeface = product_sans v.divider1.typeface = product_sans
@ -392,6 +447,7 @@ class TheWidget : AppWidgetProvider() {
v.divider2.typeface = product_sans v.divider2.typeface = product_sans
v.calendar_temp.typeface = product_sans v.calendar_temp.typeface = product_sans
v.time.typeface = product_sans v.time.typeface = product_sans
}
return v return v
} }
@ -434,7 +490,15 @@ class TheWidget : AppWidgetProvider() {
v.time.visibility = View.VISIBLE v.time.visibility = View.VISIBLE
} }
val now = Calendar.getInstance() val now = Calendar.getInstance()
v.time.text = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(now.timeInMillis) else Constants.goodHourFormat.format(now.timeInMillis) if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
textBadHour.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
v.time.text = textBadHour
} else {
v.time.text = Constants.goodHourFormat.format(now.timeInMillis)
}
return v return v
} }
} }

View File

@ -4,6 +4,7 @@ import android.Manifest
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.ContentUris import android.content.ContentUris
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.net.Uri import android.net.Uri
import android.preference.PreferenceManager import android.preference.PreferenceManager
@ -15,11 +16,13 @@ import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.`object`.CalendarSelector import com.tommasoberlose.anotherwidget.`object`.CalendarSelector
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 me.everything.providers.android.calendar.CalendarProvider import me.everything.providers.android.calendar.CalendarProvider
import me.everything.providers.android.contacts.ContactsProvider import me.everything.providers.android.contacts.ContactsProvider
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.Comparator import kotlin.Comparator
import kotlin.collections.ArrayList
/** /**
* Created by tommaso on 08/10/17. * Created by tommaso on 08/10/17.
@ -41,7 +44,8 @@ object CalendarUtil {
3 -> limit.add(Calendar.DAY_OF_MONTH, 1) 3 -> limit.add(Calendar.DAY_OF_MONTH, 1)
4 -> limit.add(Calendar.DAY_OF_MONTH, 3) 4 -> limit.add(Calendar.DAY_OF_MONTH, 3)
5 -> limit.add(Calendar.DAY_OF_MONTH, 7) 5 -> limit.add(Calendar.DAY_OF_MONTH, 7)
6 -> limit.add(Calendar.HOUR, 1) 6 -> limit.add(Calendar.MINUTE, 30)
7 -> limit.add(Calendar.HOUR, 1)
else -> limit.add(Calendar.HOUR, 6) else -> limit.add(Calendar.HOUR, 6)
} }
@ -58,7 +62,15 @@ object CalendarUtil {
for (instance in instances) { for (instance in instances) {
val e = provider.getEvent(instance.eventId) val e = provider.getEvent(instance.eventId)
if (e != null && (SP.getBoolean(Constants.PREF_CALENDAR_ALL_DAY, false) || !e.allDay) && !(SP.getString(Constants.PREF_CALENDAR_FILTER, "").contains(" " + e.calendarId + ",")) && (SP.getBoolean(Constants.PREF_SHOW_DECLINED_EVENTS, true) || !e.selfAttendeeStatus.equals(CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED))) { if (e != null && (SP.getBoolean(Constants.PREF_CALENDAR_ALL_DAY, false) || !e.allDay) && !(SP.getString(Constants.PREF_CALENDAR_FILTER, "").contains(" " + e.calendarId + ",")) && (SP.getBoolean(Constants.PREF_SHOW_DECLINED_EVENTS, true) || !e.selfAttendeeStatus.equals(CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED))) {
eventList.add(Event(e.id.toInt(), e.title, e.dTStart, e.dTend, e.calendarId.toInt(), e.allDay, e.eventLocation)) 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)
}
eventList.add(Event(e.id.toInt(), e.title, instance.begin, instance.end, e.calendarId.toInt(), e.allDay, e.eventLocation?: ""))
} }
} }
@ -67,33 +79,17 @@ object CalendarUtil {
} else { } else {
eventList.sortWith(Comparator { event: Event, event1: Event -> eventList.sortWith(Comparator { event: Event, event1: Event ->
if (event.allDay && event1.allDay) { if (event.allDay && event1.allDay) {
0 event.startDate.compareTo(event1.startDate)
} else { } else if (event.allDay) {
if (event.allDay) {
Log.d("AW1", event.title + " " + event.startDate + " - " + event1.title + " " + event1.startDate)
if (TimeUnit.MILLISECONDS.toMinutes(event1.startDate - now.timeInMillis) > 31 || now.timeInMillis > event1.endDate) {
1 1
} else {
-1
}
} else if (event1.allDay) { } else if (event1.allDay) {
Log.d("AW2", event.title + " " + event.startDate + " - " + event1.title + " " + event1.startDate)
if (TimeUnit.MILLISECONDS.toMinutes(event.startDate - now.timeInMillis) > 31 || now.timeInMillis > event.endDate) {
-1 -1
} else { } else {
1 event1.startDate.compareTo(event.startDate)
}
} else {
if (event.startDate > event1.startDate) {
1
} else if (event.startDate < event1.startDate) {
-1
}
0
}
} }
}) })
saveNextEventData(context, eventList.get(0)) saveEvents(context, eventList)
saveNextEventData(context, eventList[0])
} }
} }
} else { } else {
@ -111,58 +107,15 @@ object CalendarUtil {
val provider = CalendarProvider(context) val provider = CalendarProvider(context)
return provider.calendars.list return provider.calendars.list
/*
try {
val calendarCursor = context.contentResolver.query(Uri.parse("content://com.android.calendar/calendars"),
arrayOf(CalendarContract.Calendars._ID, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, CalendarContract.Calendars.ACCOUNT_NAME),
null,
null,
null)
if (calendarCursor != null && calendarCursor.count > 0) {
calendarCursor.moveToFirst()
for (j in 0 until calendarCursor.count) {
val id = calendarCursor.getInt(0)
val name = calendarCursor.getString(1)
val account = calendarCursor.getString(2)
calendarList.add(CalendarSelector(id, name, account))
calendarCursor.moveToNext()
} }
calendarCursor.close() fun saveEvents(context: Context, eventList: ArrayList<Event>) {
} else { Realm.init(context)
Toast.makeText(context, R.string.error_no_calendar, Toast.LENGTH_SHORT).show() val db = Realm.getDefaultInstance()
db.executeTransaction { realm ->
realm.where(Event::class.java).findAll().deleteAllFromRealm()
realm.copyToRealm(eventList)
} }
} catch (ignored: Exception) {
ignored.printStackTrace()
try {
val calendarCursor = context.contentResolver.query(CalendarContract.Calendars.CONTENT_URI,
arrayOf(CalendarContract.Calendars._ID, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, CalendarContract.Calendars.ACCOUNT_NAME),
null,
null,
null)
if (calendarCursor != null && calendarCursor.count > 0) {
calendarCursor.moveToFirst()
for (j in 0 until calendarCursor.count) {
calendarList.add(CalendarSelector(calendarCursor.getInt(0), calendarCursor.getString(1), calendarCursor.getString(2)))
calendarCursor.moveToNext()
}
calendarCursor.close()
}
} catch (ignore: Exception) {
ignore.printStackTrace()
} finally {
return calendarList
}
} finally {
return calendarList
}*/
} }
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
@ -185,18 +138,59 @@ object CalendarUtil {
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
SP.edit() SP.edit()
.putInt(Constants.PREF_NEXT_EVENT_ID, event.id) .putInt(Constants.PREF_NEXT_EVENT_ID, event.id)
.putString(Constants.PREF_NEXT_EVENT_NAME, event.title)
.putLong(Constants.PREF_NEXT_EVENT_START_DATE, event.startDate)
.putLong(Constants.PREF_NEXT_EVENT_END_DATE, event.endDate)
.putBoolean(Constants.PREF_NEXT_EVENT_ALL_DAY, event.allDay)
.putInt(Constants.PREF_NEXT_EVENT_CALENDAR_ID, event.calendarID)
.putString(Constants.PREF_NEXT_EVENT_LOCATION, event.address)
.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)
return Event(SP.getInt(Constants.PREF_NEXT_EVENT_ID, 0), SP.getString(Constants.PREF_NEXT_EVENT_NAME, ""), SP.getLong(Constants.PREF_NEXT_EVENT_START_DATE, 0), SP.getLong(Constants.PREF_NEXT_EVENT_END_DATE, 0), SP.getInt(Constants.PREF_NEXT_EVENT_CALENDAR_ID, 0), SP.getBoolean(Constants.PREF_NEXT_EVENT_ALL_DAY, false), SP.getString(Constants.PREF_NEXT_EVENT_LOCATION, "")) Realm.init(context)
val db = Realm.getDefaultInstance()
val nextEvent = db.where(Event::class.java).equalTo("id", SP.getInt(Constants.PREF_NEXT_EVENT_ID, 0)).findFirst()
return if (nextEvent != null) {
nextEvent
} else {
val eventList = db.where(Event::class.java).findAll()
eventList[0]?: Event()
}
}
@SuppressLint("ApplySharedPref")
fun goToNextEvent(context: Context) {
Realm.init(context)
val db = Realm.getDefaultInstance()
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val eventList = db.where(Event::class.java).findAll()
var found = false
for (e in eventList) {
if (e.id == SP.getInt(Constants.PREF_NEXT_EVENT_ID, 0)) {
if (eventList.indexOf(e) < eventList.size - 1) {
SP.edit()
.putInt(Constants.PREF_NEXT_EVENT_ID, eventList[eventList.indexOf(e) + 1]?.id ?: 0)
.commit()
} else {
SP.edit()
.putInt(Constants.PREF_NEXT_EVENT_ID, eventList[0]?.id ?: 0)
.commit()
}
found = true
break
}
}
if (!found) {
SP.edit()
.putInt(Constants.PREF_NEXT_EVENT_ID, eventList[0]?.id ?: 0)
.commit()
}
context.sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
}
fun getEventsCount(context: Context): Int {
Realm.init(context)
val db = Realm.getDefaultInstance()
return db.where(Event::class.java).findAll().size
} }
} }

View File

@ -0,0 +1,51 @@
package com.tommasoberlose.anotherwidget.util
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.content.BroadcastReceiver
import android.content.Context
import com.tommasoberlose.anotherwidget.`object`.Constants
import android.content.IntentFilter
import android.util.Log
class CrocodileService : Service() {
private val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_TIME_TICK && isScreenOn) {
sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
} else if (intent.action == Intent.ACTION_SCREEN_OFF) {
isScreenOn = false
} else if (intent.action == Intent.ACTION_SCREEN_ON) {
isScreenOn = true
sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
}
}
}
private var isScreenOn = true
override fun onCreate() {
super.onCreate()
val filter = IntentFilter()
filter.addAction(Intent.ACTION_TIME_TICK)
filter.addAction(Intent.ACTION_SCREEN_OFF)
filter.addAction(Intent.ACTION_SCREEN_ON)
registerReceiver(receiver, filter)
}
override fun onDestroy() {
unregisterReceiver(receiver)
super.onDestroy()
}
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
return Service.START_NOT_STICKY
}
override fun onBind(intent: Intent): IBinder? {
return null
}
}

View File

@ -149,7 +149,6 @@ object Util {
val measuredHeight = View.MeasureSpec.makeMeasureSpec(view.height, View.MeasureSpec.UNSPECIFIED) val measuredHeight = View.MeasureSpec.makeMeasureSpec(view.height, View.MeasureSpec.UNSPECIFIED)
view.measure(measuredWidth, measuredHeight) view.measure(measuredWidth, measuredHeight)
view.layout(0,0, measuredWidth, measuredHeight) view.layout(0,0, measuredWidth, measuredHeight)
Log.d("AW", "W: " + view.measuredWidth +" - H: " + view.measuredHeight)
val returnedBitmap = Bitmap.createBitmap(view.measuredWidth, view.measuredHeight, Bitmap.Config.ARGB_8888) val returnedBitmap = Bitmap.createBitmap(view.measuredWidth, view.measuredHeight, Bitmap.Config.ARGB_8888)
//Bind a canvas to it //Bind a canvas to it
val canvas = Canvas(returnedBitmap) val canvas = Canvas(returnedBitmap)
@ -222,6 +221,7 @@ object Util {
4 -> R.string.settings_show_until_subtitle_4 4 -> R.string.settings_show_until_subtitle_4
5 -> R.string.settings_show_until_subtitle_5 5 -> R.string.settings_show_until_subtitle_5
6 -> R.string.settings_show_until_subtitle_6 6 -> R.string.settings_show_until_subtitle_6
7 -> R.string.settings_show_until_subtitle_7
else -> R.string.settings_show_until_subtitle_1 else -> R.string.settings_show_until_subtitle_1
} }
} }
@ -235,7 +235,7 @@ object Util {
} }
} }
fun getTextshadowString(shadow: Int): Int { fun getTextShadowString(shadow: Int): Int {
return when (shadow) { return when (shadow) {
0 -> R.string.settings_text_shadow_subtitle_none 0 -> R.string.settings_text_shadow_subtitle_none
1 -> R.string.settings_text_shadow_subtitle_low 1 -> R.string.settings_text_shadow_subtitle_low
@ -244,12 +244,23 @@ object Util {
} }
} }
fun getCustomFontLabel(shadow: Int): Int {
return when (shadow) {
0 -> R.string.custom_font_subtitle_0
1 -> R.string.custom_font_subtitle_1
else -> R.string.custom_font_subtitle_1
}
}
fun getCalendarIntent(context: Context): Intent { fun getCalendarIntent(context: Context): Intent {
val SP = PreferenceManager.getDefaultSharedPreferences(context) val SP = PreferenceManager.getDefaultSharedPreferences(context)
if (SP.getString(Constants.PREF_CALENDAR_APP_PACKAGE, "").equals("")) { if (SP.getString(Constants.PREF_CALENDAR_APP_PACKAGE, "").equals("")) {
val calIntent = Intent(Intent.ACTION_MAIN) val calIntent = Intent(Intent.ACTION_MAIN)
calIntent.addCategory(Intent.CATEGORY_APP_CALENDAR) calIntent.addCategory(Intent.CATEGORY_APP_CALENDAR)
return calIntent return calIntent
} else if (SP.getString(Constants.PREF_CALENDAR_APP_PACKAGE, "").equals("_")) {
return Intent()
} else { } else {
val pm: PackageManager = context.packageManager val pm: PackageManager = context.packageManager
return try { return try {
@ -273,6 +284,8 @@ object Util {
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
} else if (SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, "").equals("_")) {
return Intent()
} else { } else {
val pm: PackageManager = context.packageManager val pm: PackageManager = context.packageManager
return try { return try {
@ -298,6 +311,8 @@ object Util {
intent.putExtra("beginTime", e.startDate); intent.putExtra("beginTime", e.startDate);
intent.putExtra("endTime", e.endDate); intent.putExtra("endTime", e.endDate);
return intent return intent
} else if (SP.getString(Constants.PREF_EVENT_APP_PACKAGE, "") == ("_")) {
return Intent()
} else { } else {
val pm: PackageManager = context.packageManager val pm: PackageManager = context.packageManager
return try { return try {
@ -321,6 +336,8 @@ object Util {
val clockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) val clockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
return clockIntent return clockIntent
} else if (SP.getString(Constants.PREF_CLOCK_APP_PACKAGE, "").equals("_")) {
return Intent()
} else { } else {
val pm: PackageManager = context.packageManager val pm: PackageManager = context.packageManager
return try { return try {
@ -498,7 +515,10 @@ object Util {
} else if (eventDate.dayOfYear == nowDate.dayOfYear) { } else if (eventDate.dayOfYear == nowDate.dayOfYear) {
return String.format("%s", context.getString(R.string.today)) return String.format("%s", context.getString(R.string.today))
} else { } else {
val days = TimeUnit.MILLISECONDS.toDays(difference) var days = TimeUnit.MILLISECONDS.toDays(difference)
if (eventDate.hourOfDay < nowDate.hourOfDay || (eventDate.hourOfDay == nowDate.hourOfDay && eventDate.minuteOfHour <= nowDate.minuteOfHour)) {
days++
}
return String.format("%s %s%s", context.getString(R.string.in_code), days, context.getString(R.string.day_char)) return String.format("%s %s%s", context.getString(R.string.in_code), days, context.getString(R.string.day_char))
} }
@ -536,6 +556,7 @@ object Util {
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
fun updateSettingsByDefault(context: Context) { fun updateSettingsByDefault(context: Context) {
context.startService(Intent(context, CrocodileService::class.java))
val SP = PreferenceManager.getDefaultSharedPreferences(context) val SP = PreferenceManager.getDefaultSharedPreferences(context)
val editor = SP.edit() val editor = SP.edit()
if (SP.contains(Constants.PREF_SHOW_EVENT_LOCATION)) { if (SP.contains(Constants.PREF_SHOW_EVENT_LOCATION)) {

View File

@ -2,6 +2,7 @@ package com.tommasoberlose.anotherwidget.util
import android.Manifest import android.Manifest
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.UiModeManager
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.location.* import android.location.*
@ -21,6 +22,7 @@ import android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS
import android.content.Intent import android.content.Intent
import android.location.LocationManager import android.location.LocationManager
import android.support.annotation.NonNull import android.support.annotation.NonNull
import android.support.v7.app.AppCompatDelegate
import android.util.Log import android.util.Log
import com.google.android.gms.awareness.Awareness import com.google.android.gms.awareness.Awareness
import com.google.android.gms.awareness.snapshot.WeatherResponse import com.google.android.gms.awareness.snapshot.WeatherResponse
@ -83,7 +85,7 @@ object WeatherUtil {
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
SP.edit() SP.edit()
.putFloat(Constants.PREF_WEATHER_TEMP, weather.getTemperature(if (SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F").equals("F")) Weather.FAHRENHEIT else Weather.CELSIUS)) .putFloat(Constants.PREF_WEATHER_TEMP, weather.getTemperature(if (SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F").equals("F")) Weather.FAHRENHEIT else Weather.CELSIUS))
.putString(Constants.PREF_WEATHER_ICON, getIconCodeFromAwareness(weather.conditions)) .putString(Constants.PREF_WEATHER_ICON, getIconCodeFromAwareness(context, weather.conditions))
.putString(Constants.PREF_WEATHER_REAL_TEMP_UNIT, SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F")) .putString(Constants.PREF_WEATHER_REAL_TEMP_UNIT, SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F"))
.commit() .commit()
Util.updateWidget(context) Util.updateWidget(context)
@ -161,7 +163,7 @@ object WeatherUtil {
Util.updateWidget(context) Util.updateWidget(context)
} }
fun getIconCodeFromAwareness(conditions: IntArray): String { fun getIconCodeFromAwareness(context: Context, conditions: IntArray): String {
var icon = "" var icon = ""
return if (conditions.contains(Weather.CONDITION_UNKNOWN)) { return if (conditions.contains(Weather.CONDITION_UNKNOWN)) {
"" ""
@ -186,13 +188,18 @@ object WeatherUtil {
icon = "82" icon = "82"
} }
return if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 19 || Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 7) { val uiManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
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) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners
android:radius="3dp" />
<solid
android:color="@android:color/white"/>
</shape>
</item>
</selector>

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/gradient_background" android:background="@drawable/gradient_background"
tools:context="com.tommasoberlose.anotherwidget.ui.activity.ChooseApplicationActivity"> tools:context="com.tommasoberlose.anotherwidget.ui.activity.ChooseApplicationActivity">
<LinearLayout <LinearLayout
@ -37,6 +36,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="8dp"
app:cardCornerRadius="3dp" app:cardCornerRadius="3dp"
android:layout_below="@+id/toolbar"
android:layout_above="@+id/bottom_buttons"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
@ -66,9 +67,8 @@
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:padding="12dp" android:padding="12dp"
android:contentDescription="@string/custom_location_gps" android:id="@+id/action_back"
android:id="@+id/action_default" android:src="@drawable/ic_action_close"
android:src="@drawable/ic_action_reset"
android:tint="@android:color/black"/> android:tint="@android:color/black"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -81,4 +81,37 @@
android:id="@+id/list_view" /> android:id="@+id/list_view" />
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="3dp"
android:id="@+id/bottom_buttons"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="?android:attr/actionBarSize"
android:text="@string/action_default"
android:id="@+id/action_default"
android:textColor="@android:color/black"
style="@style/AnotherWidget.Main.Button"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="?android:attr/actionBarSize"
android:text="@string/action_none"
android:id="@+id/action_none"
android:textColor="@android:color/black"
style="@style/AnotherWidget.Main.Button"/>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

View File

@ -153,6 +153,30 @@
android:id="@+id/font_color_label" android:id="@+id/font_color_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_custom_font"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_custom_font_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/custom_font_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -469,6 +493,30 @@
android:id="@+id/show_until_label" android:id="@+id/show_until_label"
style="@style/AnotherWidget.Settings.Subtitle"/> style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_show_multiple_events"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_show_multiple_events_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_multiple_events_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -0,0 +1,368 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_background"
android:orientation="vertical"
tools:context="com.tommasoberlose.anotherwidget.ui.activity.SupportDevActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="32dp"
android:id="@+id/toolbar"
android:gravity="center_vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_pre_title"
android:alpha="0.6"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center_vertical"
style="@style/AnotherWidget.Main.Subtitle"
android:textAllCaps="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_custom_app_name"
android:gravity="center_vertical"
style="@style/AnotherWidget.Main.Title"
android:textAllCaps="true"/>
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="3dp"
android:id="@+id/products_card"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:background="@android:color/white"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/ic_action_gift"
android:tint="@color/dark_grey"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_main_title"
android:textColor="@android:color/black"
android:fontFamily="sans-serif-medium"
android:padding="8dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
android:textAppearance="?android:textAppearanceListItem"/>
</LinearLayout>
</LinearLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/loader"
android:layout_margin="16dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/products_list"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:visibility="gone"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:id="@+id/action_donation_coffee"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="@string/donation_coffee"
android:paddingRight="8dp"
android:paddingLeft="40dp"
android:textColor="@color/dark_grey"
android:textAppearance="?android:textAppearanceButton"/>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="2dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/black_10"
app:cardPreventCornerOverlap="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="@color/black_50"
android:id="@+id/import_donation_coffee"
android:textSize="12sp"/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:id="@+id/action_donation_donuts"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="@string/donation_donuts"
android:paddingRight="8dp"
android:paddingLeft="40dp"
android:textColor="@color/dark_grey"
android:textAppearance="?android:textAppearanceButton"/>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="2dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/black_10"
app:cardPreventCornerOverlap="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="@color/black_50"
android:id="@+id/import_donation_donuts"
android:textSize="12sp"/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:id="@+id/action_donation_breakfast"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="@string/donation_breakfast"
android:paddingRight="8dp"
android:paddingLeft="40dp"
android:textColor="@color/dark_grey"
android:textAppearance="?android:textAppearanceButton"/>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="2dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/black_10"
app:cardPreventCornerOverlap="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="@color/black_50"
android:id="@+id/import_donation_breakfast"
android:textSize="12sp"/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:id="@+id/action_donation_lunch"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="@string/donation_lunch"
android:paddingRight="8dp"
android:paddingLeft="40dp"
android:textColor="@color/dark_grey"
android:textAppearance="?android:textAppearanceButton"/>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="2dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/black_10"
app:cardPreventCornerOverlap="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="@color/black_50"
android:id="@+id/import_donation_lunch"
android:textSize="12sp"/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:id="@+id/action_donation_dinner"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="@string/donation_dinner"
android:paddingRight="8dp"
android:paddingLeft="40dp"
android:textColor="@color/dark_grey"
android:textAppearance="?android:textAppearanceButton"/>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="2dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/black_10"
app:cardPreventCornerOverlap="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="@color/black_50"
android:id="@+id/import_donation_dinner"
android:textSize="12sp"/>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="3dp"
android:id="@+id/action_translate"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:background="@android:color/white"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="8dp"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/ic_action_translate"
android:tint="@color/dark_grey"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_translations_title"
android:textColor="@color/dark_grey"
style="@style/AnotherWidget.Settings.Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_translations_subtitle"
android:textColor="@android:color/black"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="3dp"
android:id="@+id/action_website"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:background="@android:color/white"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="8dp"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/ic_action_dev"
android:tint="@color/dark_grey"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_website_title"
android:textColor="@color/dark_grey"
style="@style/AnotherWidget.Settings.Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_website_subtitle"
android:textColor="@android:color/black"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

View File

@ -123,7 +123,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="16dp" android:padding="16dp"
android:visibility="gone"
android:id="@+id/action_support" android:id="@+id/action_support"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView

View File

@ -7,9 +7,9 @@
android:id="@+id/time" android:id="@+id/time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="-16dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:gravity="center" android:gravity="center"
android:layout_marginTop="-16dp"
android:lineSpacingMultiplier="1" android:lineSpacingMultiplier="1"
android:lineSpacingExtra="0dp" android:lineSpacingExtra="0dp"
android:visibility="gone" android:visibility="gone"
@ -21,16 +21,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:layout_marginTop="-8dp" android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_below="@+id/time" android:layout_below="@+id/time"
android:orientation="horizontal" android:orientation="horizontal"
android:id="@+id/empty_layout"> android:id="@+id/empty_layout">
<TextView <TextView
android:id="@+id/empty_date" android:id="@+id/empty_date"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:lines="1" android:lines="1"
android:maxLines="1" android:maxLines="1"
android:gravity="right" android:gravity="right"
@ -72,7 +70,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
android:layout_marginTop="-8dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_below="@+id/time" android:layout_below="@+id/time"
android:id="@+id/calendar_layout" android:id="@+id/calendar_layout"
@ -84,13 +81,17 @@
<TextView <TextView
android:id="@+id/next_event" android:id="@+id/next_event"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="2" android:layout_weight="1"
android:maxLines="1" android:maxLines="1"
android:lines="1" android:lines="1"
android:gravity="end" android:gravity="right"
android:ellipsize="end" android:ellipsize="end"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/AnotherWidget.Title" /> style="@style/AnotherWidget.Title" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView <TextView
android:id="@+id/next_event_difference_time" android:id="@+id/next_event_difference_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -98,6 +99,7 @@
android:ellipsize="marquee" android:ellipsize="marquee"
style="@style/AnotherWidget.Title" /> style="@style/AnotherWidget.Title" />
</LinearLayout> </LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -125,6 +127,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/AnotherWidget.Subtitle" /> style="@style/AnotherWidget.Subtitle" />
</LinearLayout> </LinearLayout>
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginLeft="6dp"
android:id="@+id/multiple_events"
android:src="@drawable/ic_action_next"/>
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -136,7 +144,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="2dp"
android:id="@+id/divider2" android:id="@+id/divider2"
android:text="@string/divider" android:text="@string/divider"
style="@style/AnotherWidget.Subtitle"/> style="@style/AnotherWidget.Subtitle"/>

View File

@ -6,12 +6,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:id="@+id/bitmap_container"/> android:id="@+id/bitmap_container"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:alpha="0"
android:alpha="0"> android:layout_centerInParent="true">
<include layout="@layout/the_widget" <include layout="@layout/the_widget"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -120,7 +120,6 @@
<string name="beta">Beta</string> <string name="beta">Beta</string>
<string name="settings_product_sans_font_title">Font Product Sans</string> <string name="settings_product_sans_font_title">Font Product Sans</string>
<string name="settings_product_sans_font_subtitle">L\'utilizzo del Product Sans disabilita i tap sugli elementi del widget. Ci sto attualmente lavorando.</string> <string name="settings_product_sans_font_subtitle">L\'utilizzo del Product Sans disabilita i tap sugli elementi del widget. Ci sto attualmente lavorando.</string>
<string name="settings_show_until_subtitle_6">1 Ora dopo</string>
<string name="settings_show_diff_time_title">Tempo rimanente all\'evento</string> <string name="settings_show_diff_time_title">Tempo rimanente all\'evento</string>
<string name="settings_show_declined_events_title">Event Rifiutati</string> <string name="settings_show_declined_events_title">Event Rifiutati</string>
<string name="settings_visible">Visibile</string> <string name="settings_visible">Visibile</string>
@ -129,4 +128,25 @@
<string name="default_calendar_app">App Calendario di Default</string> <string name="default_calendar_app">App Calendario di Default</string>
<string name="default_weather_app">Meteo Google</string> <string name="default_weather_app">Meteo Google</string>
<string name="default_clock_app">App Orologio di Default</string> <string name="default_clock_app">App Orologio di Default</string>
<string name="settings_show_until_subtitle_7">1 Ora dopo</string>
<string name="settings_show_until_subtitle_6">30 Minuti dopo</string>
<string name="action_default">Predefinita</string>
<string name="action_none">Disabilita</string>
<string name="custom_font_subtitle_0">Font Dispositivo</string>
<string name="custom_font_subtitle_1">Product Sans</string>
<string name="settings_custom_font_title">Font Widget</string>
<string name="action_go_to_next_event">Mostra Evento\nSuccessivo</string>
<string name="settings_show_multiple_events_title">Contatore Eventi Multipli</string>
<string name="support_main_title">Supporta lo Sviluppatore con</string>
<string name="support_translations_title">Aiuta con le Traduzioni</string>
<string name="support_translations_subtitle">Apri una pull request su GitHub</string>
<string name="support_website_title">Scopri i miei progetti</string>
<string name="support_website_subtitle">Stesso sviluppatore, più possibilità</string>
<string name="error">Ops, sembra che qualcosa non abbia funzionato!</string>
<string name="thanks">Grazie per il supporto!</string>
<string name="donation_coffee">Un Caffè Italiano</string>
<string name="donation_donuts">Qualche Ciambella</string>
<string name="donation_dinner">Una Cena Costosa</string>
<string name="donation_breakfast">Una Colazione Inglese</string>
<string name="donation_lunch">Una Pranzo Veloce</string>
</resources> </resources>

View File

@ -11,4 +11,5 @@
<color name="white_80">#CCFFFFFF</color> <color name="white_80">#CCFFFFFF</color>
<color name="white_50">#80FFFFFF</color> <color name="white_50">#80FFFFFF</color>
<color name="midnight_blue">#204A85</color> <color name="midnight_blue">#204A85</color>
<color name="dark_grey">#222222</color>
</resources> </resources>

View File

@ -124,7 +124,6 @@
<string name="beta">Beta</string> <string name="beta">Beta</string>
<string name="settings_product_sans_font_title">Product Sans Font</string> <string name="settings_product_sans_font_title">Product Sans Font</string>
<string name="settings_product_sans_font_subtitle">Using Product Sans disabled the possibilty to tap widget elements. I\'m working on it.</string> <string name="settings_product_sans_font_subtitle">Using Product Sans disabled the possibilty to tap widget elements. I\'m working on it.</string>
<string name="settings_show_until_subtitle_6">1 hour later</string>
<string name="settings_show_diff_time_title">Time left for the event</string> <string name="settings_show_diff_time_title">Time left for the event</string>
<string name="settings_visible">Visible</string> <string name="settings_visible">Visible</string>
<string name="settings_not_visible">Not Visible</string> <string name="settings_not_visible">Not Visible</string>
@ -133,4 +132,26 @@
<string name="default_event_app">Google Calendar Event Details</string> <string name="default_event_app">Google Calendar Event Details</string>
<string name="default_calendar_app">Default Calendar App</string> <string name="default_calendar_app">Default Calendar App</string>
<string name="default_clock_app">Default Clock App</string> <string name="default_clock_app">Default Clock App</string>
<string name="settings_show_until_subtitle_7">1 hour later</string>
<string name="settings_show_until_subtitle_6">30 Minutes later</string>
<string name="action_default">Default</string>
<string name="action_none">Disabled</string>
<string name="settings_custom_font_title">Widget Font</string>
<string name="custom_font_subtitle_0">Device Font</string>
<string name="custom_font_subtitle_1">Product Sans</string>
<string name="action_go_to_next_event">Show Next\nEvent</string>
<string name="settings_show_multiple_events_title">Multiple Events Counter</string>
<string name="support_custom_app_name" translatable="false">Another Developer</string>
<string name="support_main_title">Support the Developer with</string>
<string name="support_translations_title">Help with translations</string>
<string name="support_translations_subtitle">Open a pull request on GitHub</string>
<string name="support_website_title">Find out my projects</string>
<string name="support_website_subtitle">Same developer, more possibilities</string>
<string name="error">Ops, something went wrong!</string>
<string name="thanks">Thanks for support me!</string>
<string name="donation_coffee">An Italian Coffee</string>
<string name="donation_donuts">Some Glazed Donuts</string>
<string name="donation_dinner">An Expensive Dinner</string>
<string name="donation_breakfast">An English Breakfast</string>
<string name="donation_lunch">A Quick Lunch</string>
</resources> </resources>

View File

@ -2,11 +2,11 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/the_widget" android:initialKeyguardLayout="@layout/the_widget"
android:initialLayout="@layout/the_widget" android:initialLayout="@layout/the_widget"
android:minHeight="150dp" android:minHeight="80dp"
android:minWidth="400dp" android:minWidth="380dp"
android:configure="com.tommasoberlose.anotherwidget.ui.activity.MainActivity" android:configure="com.tommasoberlose.anotherwidget.ui.activity.MainActivity"
android:minResizeHeight="150dp" android:minResizeHeight="60dp"
android:minResizeWidth="400dp" android:minResizeWidth="380dp"
android:previewImage="@drawable/widget_preview" android:previewImage="@drawable/widget_preview"
android:resizeMode="vertical" android:resizeMode="vertical"
android:updatePeriodMillis="60000" android:updatePeriodMillis="60000"

View File

@ -2,10 +2,10 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/the_widget" android:initialKeyguardLayout="@layout/the_widget"
android:initialLayout="@layout/the_widget" android:initialLayout="@layout/the_widget"
android:minHeight="150dp" android:minHeight="80dp"
android:minWidth="400dp" android:minWidth="380dp"
android:minResizeHeight="150dp" android:minResizeHeight="60dp"
android:minResizeWidth="400dp" android:minResizeWidth="380dp"
android:previewImage="@drawable/widget_preview" android:previewImage="@drawable/widget_preview"
android:resizeMode="vertical" android:resizeMode="vertical"
android:updatePeriodMillis="60000" android:updatePeriodMillis="60000"

View File

@ -5,12 +5,14 @@ buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.+' classpath 'io.fabric.tools:gradle:1.+'
classpath 'io.realm:realm-gradle-plugin:4.1.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files