From 4cbb5d702f3d749e41d1ed350f80131bb83c889d Mon Sep 17 00:00:00 2001 From: Tommaso Berlose <tommaso.berlose@gmail.com> Date: Fri, 27 Oct 2017 19:41:07 +0200 Subject: [PATCH] Release Beta Version --- app/build.gradle | 28 +-- app/release/output.json | 2 +- app/src/main/AndroidManifest.xml | 26 ++- .../anotherwidget/object/Constants.kt | 7 +- .../receiver/OpenWeatherIntentReceiver.kt | 17 ++ .../anotherwidget/receiver/UpdatesReceiver.kt | 4 +- .../anotherwidget/ui/activity/MainActivity.kt | 192 ++++++++++++------ .../ui/activity/WeatherProviderActivity.kt | 33 ++- .../anotherwidget/ui/widget/TheWidget.kt | 78 +++++-- .../anotherwidget/util/CalendarUtil.kt | 83 ++++---- .../tommasoberlose/anotherwidget/util/Util.kt | 55 +++-- .../anotherwidget/util/WeatherUtil.kt | 109 ++++++---- app/src/main/res/layout/activity_main.xml | 176 ++++++++++++---- .../res/layout/activity_weather_provider.xml | 49 ++--- app/src/main/res/layout/main_menu_layout.xml | 1 + app/src/main/res/layout/the_widget.xml | 8 +- app/src/main/res/layout/the_widget_sans.xml | 11 +- app/src/main/res/values-it-rIT/strings.xml | 20 +- app/src/main/res/values/strings.xml | 20 +- 19 files changed, 634 insertions(+), 285 deletions(-) create mode 100644 app/src/main/java/com/tommasoberlose/anotherwidget/receiver/OpenWeatherIntentReceiver.kt diff --git a/app/build.gradle b/app/build.gradle index 775ffef..e6e3de2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { applicationId "com.tommasoberlose.anotherwidget" minSdkVersion 19 targetSdkVersion 26 - versionCode 20 + versionCode 22 versionName "1.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -36,19 +36,21 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" - compile 'com.survivingwithandroid:weatherlib:1.6.0' - compile 'com.survivingwithandroid:weatherlib_volleyclient:1.6.0' - compile 'com.mcxiaoke.volley:library:1.0.6@aar' - compile 'com.android.support:customtabs:26.1.0' - compile 'com.android.support:cardview-v7:26.1.0' + implementation 'com.survivingwithandroid:weatherlib:1.6.0' + implementation 'com.survivingwithandroid:weatherlib_volleyclient:1.6.0' + implementation 'com.mcxiaoke.volley:library:1.0.6@aar' + implementation 'com.android.support:customtabs:26.1.0' + implementation 'com.android.support:cardview-v7:26.1.0' kapt 'com.android.databinding:compiler:2.3.3' - compile('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') { + implementation('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') { transitive = true; } - compile 'com.android.support:design:26.1.0' - compile 'org.greenrobot:eventbus:3.0.0' - compile 'com.android.support:recyclerview-v7:26.1.0' - compile 'com.google.android.gms:play-services-awareness:11.4.2' - compile 'joda-time:joda-time:2.9.9' - compile 'com.pes.materialcolorpicker:library:1.0.4' + implementation 'com.android.support:design:26.1.0' + implementation 'org.greenrobot:eventbus:3.0.0' + implementation 'com.android.support:recyclerview-v7:26.1.0' + implementation 'com.google.android.gms:play-services-awareness:11.4.2' + implementation 'joda-time:joda-time:2.9.9' + implementation 'com.pes.materialcolorpicker:library:1.0.4' + implementation 'com.andkulikov:transitionseverywhere:1.7.6' + implementation 'me.everything:providers-android:1.0.1' } diff --git a/app/release/output.json b/app/release/output.json index 3664756..70150de 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":20},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":22},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}] \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a455131..4025f72 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,10 +14,9 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - <meta-data android:name="com.google.android.awareness.API_KEY" - android:value="AIzaSyAMkqiQHTdZGOUxRd0ZEvvrIE1qN_3pJb4"/> + android:value="AIzaSyAMkqiQHTdZGOUxRd0ZEvvrIE1qN_3pJb4" /> <activity android:name=".ui.activity.MainActivity" @@ -60,11 +59,14 @@ <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="com.tommasoberlose.anotherwidget.action.ACTION_TIME_UPDATE" /> <action android:name="com.tommasoberlose.anotherwidget.action.ACTION_CALENDAR_UPDATE" /> + <action android:name="android.intent.action.USER_PRESENT" /> + <action android:name="com.sec.android.widgetapp.APPWIDGET_RESIZE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.PACKAGE_REPLACED" /> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> + <data android:scheme="package" /> </intent-filter> </receiver> @@ -81,6 +83,7 @@ <action android:name="android.intent.action.PACKAGE_REPLACED" /> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> + <data android:scheme="package" /> </intent-filter> </receiver> @@ -94,12 +97,23 @@ android:configChanges="keyboardHidden|orientation|screenSize" android:launchMode="singleInstance" android:screenOrientation="portrait" /> - <activity android:name=".ui.activity.ChooseApplicationActivity" - android:configChanges="keyboardHidden|orientation|screenSize" - android:screenOrientation="portrait"/> - <activity android:name=".ui.activity.WeatherProviderActivity" + <activity + android:name=".ui.activity.ChooseApplicationActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:screenOrientation="portrait" /> + <activity + android:name=".ui.activity.WeatherProviderActivity" + android:configChanges="keyboardHidden|orientation|screenSize" + android:screenOrientation="portrait" /> + + <receiver + android:name=".receiver.OpenWeatherIntentReceiver" + android:enabled="true" + android:exported="true"> + <intent-filter> + <action android:name="com.tommasoberlose.anotherwidget.action.ACTION_OPEN_WEATHER_INTENT" /> + </intent-filter> + </receiver> </application> </manifest> \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt index f20ea9c..cc7f617 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt @@ -57,10 +57,14 @@ object Constants { val PREF_TEXT_COLOR = "PREF_TEXT_COLOR" val PREF_TEXT_MAIN_SIZE = "PREF_TEXT_MAIN_SIZE" val PREF_TEXT_SECOND_SIZE = "PREF_TEXT_SECOND_SIZE" + val PREF_TEXT_CLOCK_SIZE = "PREF_TEXT_CLOCK_SIZE" val PREF_WEATHER_PROVIDER = "PREF_WEATHER_PROVIDER" val PREF_SHOW_CLOCK = "PREF_SHOW_CLOCK" val PREF_CLOCK_APP_NAME = "PREF_CLOCK_APP_NAME" val PREF_CLOCK_APP_PACKAGE = "PREF_CLOCK_APP_PACKAGE" + val PREF_TEXT_SHADOW = "PREF_TEXT_SHADOW" + val PREF_SHOW_DIFF_TIME = "PREF_SHOW_DIFF_TIME" + val PREF_SHOW_DECLINED_EVENTS = "PREF_SHOW_DECLINED_EVENTS" val ACTION_EXTRA_OPEN_WEATHER_PROVIDER = "ACTION_EXTRA_OPEN_WEATHER_PROVIDER" @@ -72,7 +76,8 @@ object Constants { val ACTION_TIME_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_TIME_UPDATE" val ACTION_CALENDAR_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_CALENDAR_UPDATE" val ACTION_WEATHER_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_WEATHER_UPDATE" - val ACTION_SOMETHING_APPENED = "com.tommasoberlose.anotherwidget.action.ACTION_SOMETHING_APPENED" + 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 WEATHER_PROVIDER_GOOGLE_AWARENESS = 1 val WEATHER_PROVIDER_OPEN_WEATHER = 2 diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/OpenWeatherIntentReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/OpenWeatherIntentReceiver.kt new file mode 100644 index 0000000..07de471 --- /dev/null +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/OpenWeatherIntentReceiver.kt @@ -0,0 +1,17 @@ +package com.tommasoberlose.anotherwidget.receiver + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.tommasoberlose.anotherwidget.`object`.Constants +import com.tommasoberlose.anotherwidget.util.Util + +class OpenWeatherIntentReceiver : BroadcastReceiver() { + + override fun onReceive(context: Context, intent: Intent) { + if (intent.action == Constants.ACTION_OPEN_WEATHER_INTENT) { + context.sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE)) + context.startActivity(Util.getWeatherIntent(context)) + } + } +} diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/UpdatesReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/UpdatesReceiver.kt index 000e585..b7947d9 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/UpdatesReceiver.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/UpdatesReceiver.kt @@ -13,7 +13,9 @@ import com.tommasoberlose.anotherwidget.`object`.Constants import com.tommasoberlose.anotherwidget.`object`.Event import com.tommasoberlose.anotherwidget.util.CalendarUtil import com.tommasoberlose.anotherwidget.util.Util +import java.sql.Time import java.util.* +import java.util.concurrent.TimeUnit class UpdatesReceiver : BroadcastReceiver() { @@ -21,7 +23,7 @@ class UpdatesReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action.equals(Intent.ACTION_BOOT_COMPLETED) || intent.action.equals(Intent.ACTION_MY_PACKAGE_REPLACED) || intent.action.equals("android.intent.action.PACKAGE_REPLACED") || intent.action.equals("android.intent.action.PACKAGE_ADDED")) { setUpdates(context) - } else if (intent.action.equals(Constants.ACTION_TIME_UPDATE)) { + } else if (intent.action.equals(Constants.ACTION_TIME_UPDATE) || intent.action.equals("com.sec.android.widgetapp.APPWIDGET_RESIZE") || intent.action == "android.intent.action.USER_PRESENT") { val e: Event = CalendarUtil.getNextEvent(context) if (e.id == 0 || e.endDate <= Calendar.getInstance().timeInMillis) { CalendarUtil.updateEventList(context) diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt index 2d5cfcb..36bec50 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/MainActivity.kt @@ -27,27 +27,25 @@ import android.graphics.Color import android.graphics.Typeface import android.graphics.drawable.Drawable import android.os.Build -import android.support.annotation.ColorInt import android.support.design.widget.BottomSheetDialog import android.support.v4.content.ContextCompat import android.text.Html -import android.util.Log import android.util.TypedValue import android.widget.Toast import com.crashlytics.android.Crashlytics import com.pes.androidmaterialcolorpickerdialog.ColorPicker import com.tommasoberlose.anotherwidget.`object`.CalendarSelector +import com.tommasoberlose.anotherwidget.receiver.UpdatesReceiver import io.fabric.sdk.android.Fabric import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.key_time_wait_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.view.* class MainActivity : AppCompatActivity() { - var mAppWidgetId: Int = -1 + private var mAppWidgetId: Int = -1 private val receiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { @@ -59,6 +57,8 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) Fabric.with(this, Crashlytics()) + sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE)) + sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE)) if (intent.extras?.containsKey(Constants.ACTION_EXTRA_OPEN_WEATHER_PROVIDER) == true) { startActivityForResult(Intent(this, WeatherProviderActivity::class.java), Constants.WEATHER_PROVIDER_REQUEST_CODE) @@ -84,12 +84,6 @@ class MainActivity : AppCompatActivity() { action_menu.setOnClickListener { val mBottomSheetDialog: BottomSheetDialog = BottomSheetDialog(this) val menuView: View = getLayoutInflater().inflate(R.layout.main_menu_layout, null) - menuView.action_support.setOnClickListener(object: View.OnClickListener { - override fun onClick(p0: View?) { - Util.openURI(this@MainActivity, "https://paypal.me/tommasoberlose") - mBottomSheetDialog.dismiss() - } - }) menuView.action_share.setOnClickListener(object: View.OnClickListener { override fun onClick(p0: View?) { @@ -143,7 +137,7 @@ class MainActivity : AppCompatActivity() { override fun onResume() { super.onResume() val filter = IntentFilter() - filter.addAction(Constants.ACTION_SOMETHING_APPENED); + filter.addAction(Constants.ACTION_SOMETHING_HAPPENED); registerReceiver(receiver, filter); updateUI() } @@ -182,10 +176,11 @@ class MainActivity : AppCompatActivity() { val wallpaper: Drawable? = Util.getCurrentWallpaper(this) if (wallpaper != null) { widget_bg.setImageDrawable(wallpaper) - updateCalendarView() - updateLocationView() - updateClockView() } + widget_bg.setBackgroundColor(Color.WHITE) + updateCalendarView() + updateLocationView() + updateClockView() } @SuppressLint("ApplySharedPref") @@ -226,20 +221,6 @@ class MainActivity : AppCompatActivity() { WeatherReceiver().setOneTimeUpdate(this) sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE)) updateSettings() - - val mBottomSheetDialog: BottomSheetDialog = BottomSheetDialog(this) - val provView: View = layoutInflater.inflate(R.layout.key_time_wait_layout, null) - provView.title.text = String.format("%s %s", Util.getEmojiByUnicode(0x1F389), getString(R.string.well_done)) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - provView.text.text = Html.fromHtml(getString(R.string.api_key_info_all_set), Html.FROM_HTML_MODE_LEGACY) - } else { - provView.text.text = Html.fromHtml(getString(R.string.api_key_info_all_set)) - } - provView.action_close.setOnClickListener { - mBottomSheetDialog.dismiss() - } - mBottomSheetDialog.setContentView(provView) - mBottomSheetDialog.show(); } } @@ -266,14 +247,18 @@ class MainActivity : AppCompatActivity() { dateStringValue = Util.getCapWordString(Constants.itDateFormat.format(now.time)) } empty_date.text = dateStringValue - //empty_date.setImageBitmap(Util.buildUpdate(this, String.format("%s%s", Constants.dateFormat.format(now.time)[0].toUpperCase(), Constants.dateFormat.format(now.time).substring(1)), "fonts/product_sans_regular.ttf")) if (calendarLayout) { val e = CalendarUtil.getNextEvent(this) if (e.id != 0) { next_event.text = e.title - next_event_difference_time.text = Util.getDifferenceText(this, now.timeInMillis, e.startDate) + 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.visibility = View.VISIBLE + } else { + next_event_difference_time.visibility = View.GONE + } if (!e.address.equals("") && SP.getBoolean(Constants.PREF_SHOW_EVENT_LOCATION, false)) { second_row_icon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_action_location)) @@ -320,6 +305,7 @@ class MainActivity : AppCompatActivity() { divider2.setTextColor(Util.getFontColor(SP)) calendar_temp.setTextColor(Util.getFontColor(SP)) second_row_icon.setColorFilter(Util.getFontColor(SP)) + time.setTextColor(Util.getFontColor(SP)) empty_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f)) @@ -330,6 +316,35 @@ class MainActivity : AppCompatActivity() { next_event_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) divider2.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)) + + val shadowRadius = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> 0f + 1 -> 5f + 2 -> 4f + else -> 5f + } + val shadowColor = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> Color.TRANSPARENT + 1 -> R.color.black_50 + 2 -> Color.BLACK + else -> R.color.black_50 + } + val shadowDy = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> 0f + 1 -> 0f + 2 -> 1f + else -> 0f + } + empty_date.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + divider1.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + temp.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + next_event.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + next_event_difference_time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + next_event_date.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + divider2.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor) + time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) val product_sans: Typeface = Typeface.createFromAsset(assets, "fonts/product_sans_regular.ttf") @@ -341,6 +356,7 @@ class MainActivity : AppCompatActivity() { next_event_date.typeface = product_sans divider2.typeface = product_sans calendar_temp.typeface = product_sans + time.typeface = product_sans } fun updateLocationView() { @@ -383,8 +399,6 @@ class MainActivity : AppCompatActivity() { .putBoolean(Constants.PREF_SHOW_CLOCK, false) .commit() sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE)) - updateSettings() - updateAppWidget() } show_clock_label.text = getString(R.string.show_clock_visible) } else { @@ -394,8 +408,6 @@ class MainActivity : AppCompatActivity() { .putBoolean(Constants.PREF_SHOW_CLOCK, true) .commit() sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE)) - updateSettings() - updateAppWidget() } show_clock_label.text = getString(R.string.show_clock_not_visible) } @@ -411,7 +423,7 @@ class MainActivity : AppCompatActivity() { updateSettings() updateAppWidget() } - show_clock_label.text = getString(R.string.show_events_visible) + show_events_label.text = getString(R.string.show_events_visible) } else { calendar_settings.visibility= View.GONE action_show_events.setOnClickListener { @@ -471,6 +483,20 @@ class MainActivity : AppCompatActivity() { 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) + action_show_diff_time.setOnClickListener { + SP.edit().putBoolean(Constants.PREF_SHOW_DIFF_TIME, !SP.getBoolean(Constants.PREF_SHOW_DIFF_TIME, true)).commit() + sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE)) + updateSettings() + } + + show_declined_events_label.text = if (SP.getBoolean(Constants.PREF_SHOW_DECLINED_EVENTS, true)) getString(R.string.settings_visible) else getString(R.string.settings_not_visible) + action_show_declined_events.setOnClickListener { + SP.edit().putBoolean(Constants.PREF_SHOW_DECLINED_EVENTS, !SP.getBoolean(Constants.PREF_SHOW_DECLINED_EVENTS, true)).commit() + sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE)) + updateSettings() + } + hour_format_label.text = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) getString(R.string.settings_hour_format_subtitle_12) else getString(R.string.settings_hour_format_subtitle_24) action_hour_format.setOnClickListener { SP.edit().putString(Constants.PREF_HOUR_FORMAT, if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) "24" else "12").commit() @@ -511,6 +537,17 @@ class MainActivity : AppCompatActivity() { updateAppWidget() } + clock_text_size_label.text = String.format("%.0f%s", SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f), "sp") + action_clock_text_size.setOnClickListener { + var fontSize = SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f) + 5 + if (fontSize > 110) { + fontSize = 70f + } + SP.edit().putFloat(Constants.PREF_TEXT_CLOCK_SIZE, fontSize).commit() + Util.updateWidget(this) + updateSettings() + updateAppWidget() + } val textColor = try { Color.parseColor(SP.getString(Constants.PREF_TEXT_COLOR, "#FFFFFF")) @@ -544,19 +581,25 @@ class MainActivity : AppCompatActivity() { updateSettings() } - label_weather_refresh_period.text = getString(Util.getRefreshPeriodString(SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1))) - action_weather_refresh_period.setOnClickListener { - SP.edit().putInt(Constants.PREF_WEATHER_REFRESH_PERIOD, when (SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1)) { - 0 -> 1 - 1 -> 2 - 2 -> 3 - 3 -> 4 - 4 -> 5 - 5 -> 0 - else -> 1 - }).commit() - updateSettings() - WeatherReceiver().setUpdates(this@MainActivity) + + if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) { + action_weather_refresh_period.visibility = View.GONE + } else { + label_weather_refresh_period.text = getString(Util.getRefreshPeriodString(SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1))) + action_weather_refresh_period.setOnClickListener { + SP.edit().putInt(Constants.PREF_WEATHER_REFRESH_PERIOD, when (SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1)) { + 0 -> 1 + 1 -> 2 + 2 -> 3 + 3 -> 4 + 4 -> 5 + 5 -> 0 + else -> 1 + }).commit() + updateSettings() + WeatherReceiver().setUpdates(this@MainActivity) + } + action_weather_refresh_period.visibility = View.VISIBLE } show_until_label.text = getString(Util.getShowUntilString(SP.getInt(Constants.PREF_SHOW_UNTIL, 1))) @@ -567,51 +610,78 @@ class MainActivity : AppCompatActivity() { 2 -> 3 3 -> 4 4 -> 5 - 5 -> 0 + 5 -> 6 + 6 -> 0 else -> 1 }).commit() updateSettings() sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE)) } - label_custom_location.text = SP.getString(Constants.PREF_CUSTOM_LOCATION_ADD, getString(R.string.custom_location_gps)) - action_custom_location.setOnClickListener { - startActivityForResult(Intent(this, CustomLocationActivity::class.java), Constants.RESULT_CODE_CUSTOM_LOCATION) + text_shadow_label.text = getString(Util.getTextshadowString(SP.getInt(Constants.PREF_TEXT_SHADOW, 1))) + action_text_shadow.setOnClickListener { + SP.edit().putInt(Constants.PREF_TEXT_SHADOW, when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> 1 + 1 -> 2 + 2 -> 0 + else -> 1 + }).commit() + sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE)) + updateSettings() + updateAppWidget() } - if (!SP.getString(Constants.PREF_WEATHER_PROVIDER_API_KEY, "").equals("")) { - label_weather_provider_api_key.text = getString(R.string.settings_weather_provider_api_key_subtitle_all_set) + if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) { + action_custom_location.visibility = View.GONE + } else { + label_custom_location.text = SP.getString(Constants.PREF_CUSTOM_LOCATION_ADD, getString(R.string.custom_location_gps)) + action_custom_location.setOnClickListener { + startActivityForResult(Intent(this, CustomLocationActivity::class.java), Constants.RESULT_CODE_CUSTOM_LOCATION) + } + action_custom_location.visibility = View.VISIBLE + } + + if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) { + label_weather_provider_api_key.text = getString(R.string.provider_google_awareness) alert_icon.visibility = View.GONE } else { - label_weather_provider_api_key.text = getString(R.string.settings_weather_provider_api_key_subtitle_not_set) - alert_icon.visibility = View.VISIBLE + if (SP.getString(Constants.PREF_WEATHER_PROVIDER_API_KEY, "") == ("")) { + label_weather_provider_api_key.text = getString(R.string.settings_weather_provider_api_key_subtitle_not_set) + alert_icon.visibility = View.VISIBLE + } else { + label_weather_provider_api_key.text = getString(when (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS)) { + Constants.WEATHER_PROVIDER_OPEN_WEATHER -> R.string.provider_open_weather + else -> R.string.settings_weather_provider_api_key_subtitle_all_set + }) + alert_icon.visibility = View.GONE + } } action_weather_provider_api_key.setOnClickListener { startActivityForResult(Intent(this, WeatherProviderActivity::class.java), Constants.WEATHER_PROVIDER_REQUEST_CODE) } - calendar_app_label.text = SP.getString(Constants.PREF_CALENDAR_APP_NAME, getString(R.string.default_name)) + calendar_app_label.text = SP.getString(Constants.PREF_CALENDAR_APP_NAME, getString(R.string.default_calendar_app)) action_calendar_app.setOnClickListener { startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.CALENDAR_APP_REQUEST_CODE) } - weather_app_label.text = SP.getString(Constants.PREF_WEATHER_APP_NAME, getString(R.string.default_name)) + weather_app_label.text = SP.getString(Constants.PREF_WEATHER_APP_NAME, getString(R.string.default_weather_app)) action_weather_app.setOnClickListener { startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.WEATHER_APP_REQUEST_CODE) } - clock_app_label.text = SP.getString(Constants.PREF_CLOCK_APP_NAME, getString(R.string.default_name)) + clock_app_label.text = SP.getString(Constants.PREF_CLOCK_APP_NAME, getString(R.string.default_clock_app)) action_clock_app.setOnClickListener { startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.CLOCK_APP_REQUEST_CODE) } - event_app_label.text = SP.getString(Constants.PREF_EVENT_APP_NAME, getString(R.string.default_name)) + event_app_label.text = SP.getString(Constants.PREF_EVENT_APP_NAME, getString(R.string.default_event_app)) action_event_app.setOnClickListener { startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.EVENT_APP_REQUEST_CODE) } action_filter_calendar.setOnClickListener { - val calendarSelectorList: List<CalendarSelector> = CalendarUtil.getCalendarList(this) + val calendarSelectorList: List<CalendarSelector> = CalendarUtil.getCalendarList(this).map { CalendarSelector(it.id.toInt(), it.displayName, it.accountName) } var calFiltered = SP.getString(Constants.PREF_CALENDAR_FILTER, "") if (!calendarSelectorList.isEmpty()) { diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/WeatherProviderActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/WeatherProviderActivity.kt index d090ac4..e10d8f9 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/WeatherProviderActivity.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/WeatherProviderActivity.kt @@ -22,6 +22,7 @@ import com.tommasoberlose.anotherwidget.util.CalendarUtil import com.tommasoberlose.anotherwidget.util.Util import com.tommasoberlose.anotherwidget.util.WeatherUtil import kotlinx.android.synthetic.main.activity_weather_provider.* +import kotlinx.android.synthetic.main.key_time_wait_layout.view.* import kotlinx.android.synthetic.main.main_menu_layout.view.* import kotlinx.android.synthetic.main.provider_info_layout.view.* @@ -35,12 +36,6 @@ class WeatherProviderActivity : AppCompatActivity() { setContentView(R.layout.activity_weather_provider) SP = PreferenceManager.getDefaultSharedPreferences(this) - action_paste.setOnClickListener { - val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - if (clipboard.primaryClip != null && clipboard.primaryClip.itemCount > 0) { - api_key.setText(clipboard.primaryClip.getItemAt(0).text) - } - } updateUI() @@ -71,27 +66,23 @@ class WeatherProviderActivity : AppCompatActivity() { action_open_provider.setOnClickListener { Util.openURI(this, "https://home.openweathermap.org/users/sign_up") } - - action_open_info_text.setOnClickListener { - val mBottomSheetDialog: BottomSheetDialog = BottomSheetDialog(this) - val provView: View = layoutInflater.inflate(R.layout.provider_info_layout, null) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - provView.text.text = Html.fromHtml(getString(R.string.api_key_info_text), Html.FROM_HTML_MODE_LEGACY) - } else { - provView.text.text = Html.fromHtml(getString(R.string.api_key_info_text)) - } - mBottomSheetDialog.setContentView(provView) - mBottomSheetDialog.show(); - } } @SuppressLint("ApplySharedPref") - fun updateUI() { + private fun updateUI() { val currentProvider = SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) if (currentProvider == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) { - api_key.visibility = View.GONE + api_key_container.visibility = View.GONE + content_info.visibility = View.GONE } else { - api_key.visibility = View.VISIBLE + api_key_container.visibility = View.VISIBLE + content_info.visibility = View.VISIBLE + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + last_info.text = Html.fromHtml(getString(R.string.api_key_info_all_set), Html.FROM_HTML_MODE_LEGACY) + } else { + last_info.text = Html.fromHtml(getString(R.string.api_key_info_all_set)) + } } label_weather_provider.text = when (currentProvider) { Constants.WEATHER_PROVIDER_OPEN_WEATHER -> getString(R.string.provider_open_weather) diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt index aa69365..5202061 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widget/TheWidget.kt @@ -31,7 +31,9 @@ import android.widget.TextView import android.content.ComponentName import android.graphics.Bitmap import android.graphics.BitmapFactory +import android.graphics.Color import android.graphics.drawable.BitmapDrawable +import android.os.Bundle import android.support.v4.content.ContextCompat.startActivity import android.provider.CalendarContract.Events import android.support.v4.content.ContextCompat @@ -51,6 +53,11 @@ class TheWidget : AppWidgetProvider() { } } + override fun onAppWidgetOptionsChanged(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int, newOptions: Bundle?) { + super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions) + updateAppWidget(context, appWidgetManager, appWidgetId) + } + override fun onEnabled(context: Context) { UpdatesReceiver().setUpdates(context) WeatherReceiver().setUpdates(context) @@ -67,16 +74,16 @@ class TheWidget : AppWidgetProvider() { internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int) { - val 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) v = updateCalendarViewByLayout(context, v) v = updateLocationViewByLayout(context, v) v = updateClockViewByLayout(context, v) views.setImageViewBitmap(R.id.bitmap_container, Util.getBitmapFromView(v)) - /* - views = updateCalendarView(context, views, appWidgetId) + views = updateCalendarView(context, views, appWidgetId) views = updateLocationView(context, views, appWidgetId) + views = updateClockView(context, views, appWidgetId) val SP = PreferenceManager.getDefaultSharedPreferences(context) views.setTextColor(R.id.empty_date, Util.getFontColor(SP)) @@ -96,7 +103,8 @@ 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.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)) - */ + + appWidgetManager.updateAppWidget(appWidgetId, views) } @@ -112,11 +120,10 @@ class TheWidget : AppWidgetProvider() { dateStringValue = Util.getCapWordString(Constants.itDateFormat.format(now.time)) } views.setTextViewText(R.id.empty_date, dateStringValue) - //views.setImageViewBitmap(R.id.empty_date, Util.buildUpdate(context, Constants.dateFormat.format(now.time)[0].toUpperCase() + Constants.dateFormat.format(now.time).substring(1), "fonts/product_sans_regular.ttf")) val calPIntent = PendingIntent.getActivity(context, widgetID, Util.getCalendarIntent(context), 0) - views.setOnClickPendingIntent(R.id.main_layout, calPIntent) + views.setOnClickPendingIntent(R.id.empty_date, calPIntent) if (calendarLayout) { @@ -124,7 +131,12 @@ class TheWidget : AppWidgetProvider() { if (e.id != 0) { views.setTextViewText(R.id.next_event, e.title) - views.setTextViewText(R.id.next_event_difference_time, Util.getDifferenceText(context, now.timeInMillis, e.startDate)) + 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.setViewVisibility(R.id.next_event_difference_time, View.VISIBLE) + } else { + views.setViewVisibility(R.id.next_event_difference_time, View.GONE) + } if (!e.address.equals("") && SP.getBoolean(Constants.PREF_SHOW_EVENT_LOCATION, false)) { @@ -173,7 +185,9 @@ class TheWidget : AppWidgetProvider() { views.setViewVisibility(R.id.calendar_layout, View.VISIBLE) val pIntent = PendingIntent.getActivity(context, widgetID, Util.getEventIntent(context, e), 0) - views.setOnClickPendingIntent(R.id.main_layout, pIntent) + views.setOnClickPendingIntent(R.id.next_event, pIntent) + views.setOnClickPendingIntent(R.id.next_event_difference_time, pIntent) + views.setOnClickPendingIntent(R.id.next_event_date, pIntent) } } @@ -205,7 +219,7 @@ class TheWidget : AppWidgetProvider() { views.setTextViewText(R.id.calendar_temp, temp) - val weatherPIntent = PendingIntent.getActivity(context, widgetID, Util.getWeatherIntent(context), 0) + val weatherPIntent = PendingIntent.getBroadcast(context, widgetID, Intent(Constants.ACTION_OPEN_WEATHER_INTENT), 0) views.setOnClickPendingIntent(R.id.weather, weatherPIntent) views.setOnClickPendingIntent(R.id.calendar_weather, weatherPIntent) @@ -216,7 +230,7 @@ class TheWidget : AppWidgetProvider() { return views } - fun updateClockView(context: Context, views: RemoteViews, widgetID: Int) { + fun updateClockView(context: Context, views: RemoteViews, widgetID: Int): RemoteViews { val SP = PreferenceManager.getDefaultSharedPreferences(context) if (!SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) { views.setViewVisibility(R.id.time, View.GONE) @@ -225,6 +239,11 @@ class TheWidget : AppWidgetProvider() { } 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)) + + val clockPIntent = PendingIntent.getActivity(context, widgetID, Util.getClockIntent(context), 0) + views.setOnClickPendingIntent(R.id.time, clockPIntent) + + return views } fun updateCalendarViewByLayout(context: Context, v: View): View { @@ -239,14 +258,18 @@ class TheWidget : AppWidgetProvider() { dateStringValue = Util.getCapWordString(Constants.itDateFormat.format(now.time)) } v.empty_date.text = dateStringValue - //empty_date.setImageBitmap(Util.buildUpdate(this, String.format("%s%s", Constants.dateFormat.format(now.time)[0].toUpperCase(), Constants.dateFormat.format(now.time).substring(1)), "fonts/product_sans_regular.ttf")) if (calendarLayout) { val e = CalendarUtil.getNextEvent(context) if (e.id != 0) { v.next_event.text = e.title - v.next_event_difference_time.text = Util.getDifferenceText(context, now.timeInMillis, e.startDate) + 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.visibility = View.VISIBLE + } else { + v.next_event_difference_time.visibility = View.GONE + } if (!e.address.equals("") && SP.getBoolean(Constants.PREF_SHOW_EVENT_LOCATION, false)) { v.second_row_icon.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_action_location)) @@ -293,6 +316,7 @@ class TheWidget : AppWidgetProvider() { v.divider2.setTextColor(Util.getFontColor(SP)) v.calendar_temp.setTextColor(Util.getFontColor(SP)) v.second_row_icon.setColorFilter(Util.getFontColor(SP)) + v.time.setTextColor(Util.getFontColor(SP)) v.empty_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f)) @@ -303,6 +327,35 @@ class TheWidget : AppWidgetProvider() { v.next_event_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f)) v.divider2.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)) + + val shadowRadius = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> 0f + 1 -> 5f + 2 -> 5f + else -> 5f + } + val shadowColor = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> Color.TRANSPARENT + 1 -> R.color.black_50 + 2 -> Color.BLACK + else -> R.color.black_50 + } + val shadowDy = when (SP.getInt(Constants.PREF_TEXT_SHADOW, 1)) { + 0 -> 0f + 1 -> 0f + 2 -> 1f + else -> 0f + } + v.empty_date.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.divider1.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.temp.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.next_event.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.next_event_difference_time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.next_event_date.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.divider2.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) + v.calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor) + v.time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor) val product_sans: Typeface = Typeface.createFromAsset(context.assets, "fonts/product_sans_regular.ttf") @@ -314,6 +367,7 @@ class TheWidget : AppWidgetProvider() { v.next_event_date.typeface = product_sans v.divider2.typeface = product_sans v.calendar_temp.typeface = product_sans + v.time.typeface = product_sans return v } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt index b94dc12..cf2f972 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt @@ -9,12 +9,17 @@ import android.net.Uri import android.preference.PreferenceManager import android.provider.CalendarContract import android.util.Log +import android.util.TimeUtils import android.widget.Toast import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.`object`.CalendarSelector import com.tommasoberlose.anotherwidget.`object`.Constants import com.tommasoberlose.anotherwidget.`object`.Event +import me.everything.providers.android.calendar.CalendarProvider +import me.everything.providers.android.contacts.ContactsProvider import java.util.* +import java.util.concurrent.TimeUnit +import kotlin.Comparator /** * Created by tommaso on 08/10/17. @@ -36,6 +41,7 @@ object CalendarUtil { 3 -> limit.add(Calendar.DAY_OF_MONTH, 1) 4 -> limit.add(Calendar.DAY_OF_MONTH, 3) 5 -> limit.add(Calendar.DAY_OF_MONTH, 7) + 6 -> limit.add(Calendar.HOUR, 1) else -> limit.add(Calendar.HOUR, 6) } @@ -47,49 +53,45 @@ object CalendarUtil { if (!Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) { resetNextEventData(context) } else { - - val instanceCursor = context.contentResolver.query(builder.build(), arrayOf(CalendarContract.Instances.EVENT_ID, CalendarContract.Instances.BEGIN, CalendarContract.Instances.END), null, null, null) - if (instanceCursor != null && instanceCursor.count > 0) { - instanceCursor.moveToFirst() - - for (i in 0 until instanceCursor.count) { - val ID = instanceCursor.getInt(0) - - val eventCursor = context.contentResolver.query(CalendarContract.Events.CONTENT_URI, arrayOf(CalendarContract.Events.TITLE, CalendarContract.Events.ALL_DAY, CalendarContract.Events.CALENDAR_ID, CalendarContract.Events.EVENT_LOCATION), - CalendarContract.Events._ID + " = ?", - arrayOf(Integer.toString(ID)), null) - - if (eventCursor != null && eventCursor.count > 0) { - eventCursor.moveToFirst() - - for (j in 0 until eventCursor.count) { - val e = Event(eventCursor, instanceCursor) - val allDay: Boolean = !eventCursor.getString(1).equals("0") - if ((SP.getBoolean(Constants.PREF_CALENDAR_ALL_DAY, false) || !allDay) && !(SP.getString(Constants.PREF_CALENDAR_FILTER, "").contains(" " + e.calendarID + ","))) { - eventList.add(e) - } - eventCursor.moveToNext() - } - - eventCursor.close() - } - - instanceCursor.moveToNext() + val provider = CalendarProvider(context) + val instances = provider.getInstances(now.timeInMillis, limit.timeInMillis).list + for (instance in instances) { + 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))) { + eventList.add(Event(e.id.toInt(), e.title, e.dTStart, e.dTend, e.calendarId.toInt(), e.allDay, e.eventLocation)) } - - instanceCursor.close() } if (eventList.isEmpty()) { resetNextEventData(context) } else { - Collections.sort(eventList, { event: Event, event1: Event -> - if (event.startDate > event1.startDate) { - return@sort 1 - } else if (event.startDate < event1.startDate) { - return@sort -1 + eventList.sortWith(Comparator { event: Event, event1: Event -> + if (event.allDay && event1.allDay) { + 0 + } else { + 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 + } else { + -1 + } + } 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 + } else { + 1 + } + } else { + if (event.startDate > event1.startDate) { + 1 + } else if (event.startDate < event1.startDate) { + -1 + } + 0 + } } - return@sort 0 }) saveNextEventData(context, eventList.get(0)) } @@ -100,13 +102,16 @@ object CalendarUtil { } - fun getCalendarList(context: Context): List<CalendarSelector> { - val calendarList = ArrayList<CalendarSelector>() + fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> { + val calendarList = ArrayList<me.everything.providers.android.calendar.Calendar>() if (!Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) { return calendarList } + val provider = CalendarProvider(context) + 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), @@ -157,7 +162,7 @@ object CalendarUtil { } } finally { return calendarList - } + }*/ } @SuppressLint("ApplySharedPref") diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt index 598ea92..c1bdc61 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt @@ -28,6 +28,7 @@ import android.util.TypedValue import android.content.Intent import android.content.ComponentName import android.preference.PreferenceManager +import android.provider.AlarmClock import android.provider.CalendarContract import android.provider.Settings import android.support.v4.graphics.drawable.DrawableCompat @@ -62,7 +63,7 @@ object Util { update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds) update.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE context.sendBroadcast(update) - context.sendBroadcast(Intent(Constants.ACTION_SOMETHING_APPENED)) + context.sendBroadcast(Intent(Constants.ACTION_SOMETHING_HAPPENED)) } fun showNotification(context: Context) { @@ -144,23 +145,6 @@ object Util { } } - fun buildUpdate(context: Context, time: String, fontPath: String): Bitmap { - val myBitmap:Bitmap = Bitmap.createBitmap(convertDpToPixel(300f, context).toInt(), convertDpToPixel(40f, context).toInt(), Bitmap.Config.ARGB_8888) - val myCanvas: Canvas = Canvas(myBitmap) - val paint: Paint = Paint() - val clock: Typeface = Typeface.createFromAsset(context.assets, fontPath) - paint.isAntiAlias = true - paint.isSubpixelText = true - paint.typeface = clock - paint.style = Paint.Style.FILL - paint.color = Color.WHITE - paint.textSize = convertSpToPixels(14f, context) - paint.textAlign = Paint.Align.CENTER - paint.setShadowLayer(5f,0f, 0f, R.color.black_50) - myCanvas.drawText("Ultra Pixel Meeting Ciao Ciao", convertDpToPixel(150f, context), convertDpToPixel(20f, context), paint) - return myBitmap; - } - fun getBitmapFromView(view: View): Bitmap { //Define a bitmap with the same size as the view val measuredWidth = View.MeasureSpec.makeMeasureSpec(view.width, View.MeasureSpec.UNSPECIFIED) @@ -223,10 +207,20 @@ object Util { 3 -> R.string.settings_show_until_subtitle_3 4 -> R.string.settings_show_until_subtitle_4 5 -> R.string.settings_show_until_subtitle_5 + 6 -> R.string.settings_show_until_subtitle_6 else -> R.string.settings_show_until_subtitle_1 } } + fun getTextshadowString(shadow: Int): Int { + return when (shadow) { + 0 -> R.string.settings_text_shadow_subtitle_none + 1 -> R.string.settings_text_shadow_subtitle_low + 2 -> R.string.settings_text_shadow_subtitle_high + else -> R.string.settings_text_shadow_subtitle_low + } + } + fun getCalendarIntent(context: Context): Intent { val SP = PreferenceManager.getDefaultSharedPreferences(context) if (SP.getString(Constants.PREF_CALENDAR_APP_PACKAGE, "").equals("")) { @@ -298,6 +292,26 @@ object Util { } } + fun getClockIntent(context: Context): Intent { + val SP = PreferenceManager.getDefaultSharedPreferences(context) + if (SP.getString(Constants.PREF_CLOCK_APP_PACKAGE, "").equals("")) { + val clockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) + clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + return clockIntent + } else { + val pm: PackageManager = context.packageManager + return try { + val intent: Intent = pm.getLaunchIntentForPackage(SP.getString(Constants.PREF_CLOCK_APP_PACKAGE, "")) + intent.addCategory(Intent.CATEGORY_LAUNCHER) + intent + } catch (e: Exception) { + val clockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) + clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + return clockIntent + } + } + } + fun getCapWordString(text: String): String { return try { val ar = text.split(" ") @@ -427,9 +441,10 @@ object Util { val nowDate = DateTime(now) val eventDate = DateTime(start) - val difference = start - now + var difference = start - now + difference += 60 * 1000 - (difference % (60 * 1000)) - if (difference < 0) { + if (difference <= 0) { return "" } else if (TimeUnit.MILLISECONDS.toHours(difference) < 1) { val minutes = TimeUnit.MILLISECONDS.toMinutes(difference) diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherUtil.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherUtil.kt index 3ce9264..5ded67f 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherUtil.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherUtil.kt @@ -20,10 +20,14 @@ import android.support.v4.content.ContextCompat.startActivity import android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS import android.content.Intent import android.location.LocationManager +import android.support.annotation.NonNull import android.util.Log import com.google.android.gms.awareness.Awareness import com.google.android.gms.awareness.snapshot.WeatherResponse +import com.google.android.gms.awareness.snapshot.WeatherResult import com.google.android.gms.awareness.state.Weather +import com.google.android.gms.common.api.GoogleApiClient +import com.google.android.gms.common.api.ResultCallback import com.google.android.gms.tasks.OnFailureListener import com.google.android.gms.tasks.OnSuccessListener import java.util.* @@ -40,40 +44,53 @@ object WeatherUtil { val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) if (SP.getString(Constants.PREF_CUSTOM_LOCATION_ADD, "").equals("") || SP.getString(Constants.PREF_CUSTOM_LOCATION_LAT, "").equals("") || SP.getString(Constants.PREF_CUSTOM_LOCATION_LON, "").equals("")) { - - newWeatherProvider(context) - return -/* - if (!Util.checkGrantedPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) { - return - } - var gpsEnabled = false - var networkEnabled = false - val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager - try { - gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) - } catch (ex: Exception) { - } - - try { - networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) - } catch (ex: Exception) { - } - - if (!gpsEnabled && !networkEnabled && SP.getBoolean(Constants.PREF_SHOW_WEATHER, true)) { - Util.showLocationNotification(context, true) + if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) { + newWeatherProvider(context) } else { - if (gpsEnabled) { - val gpsLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) - if (gpsLocation != null) { - getCurrentWeather(context, gpsLocation) - return + if (!Util.checkGrantedPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) { + return + } + val mGoogleApiClient = GoogleApiClient.Builder(context) + .addApi(Awareness.API) + .build() + mGoogleApiClient.connect() + Awareness.SnapshotApi.getLocation(mGoogleApiClient) + .setResultCallback({ locationResult -> + if (locationResult.status.isSuccess) { + getCurrentWeather(context, locationResult.location) + } + }) + + /* + var gpsEnabled = false + var networkEnabled = false + val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager + try { + gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) + } catch (ex: Exception) { + } + + try { + networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) + } catch (ex: Exception) { + } + + if (!gpsEnabled && !networkEnabled && SP.getBoolean(Constants.PREF_SHOW_WEATHER, true)) { + Util.showLocationNotification(context, true) + } else { + if (gpsEnabled) { + val gpsLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) + if (gpsLocation != null) { + getCurrentWeather(context, gpsLocation) + return + } + } + if (networkEnabled) { + getCurrentWeather(context, locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)) } } - if (networkEnabled) { - getCurrentWeather(context, locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)) - } - }*/ + */ + } } else { weatherNetworkRequest(context, SP.getString(Constants.PREF_CUSTOM_LOCATION_LAT, "").toDouble(), SP.getString(Constants.PREF_CUSTOM_LOCATION_LON, "").toDouble()) } @@ -84,17 +101,25 @@ object WeatherUtil { if (!Util.checkGrantedPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) { return } - Awareness.getSnapshotClient(context).weather - .addOnSuccessListener { weatherResponse -> - val weather: Weather = weatherResponse.weather - val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) - 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)) - .putString(Constants.PREF_WEATHER_ICON, getIconCodeFromAwareness(weather.conditions)) - .putString(Constants.PREF_WEATHER_REAL_TEMP_UNIT, SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F")) - .commit() - Util.updateWidget(context) - } + val mGoogleApiClient = GoogleApiClient.Builder(context) + .addApi(Awareness.API) + .build(); + mGoogleApiClient.connect() + + Awareness.SnapshotApi.getWeather(mGoogleApiClient) + .setResultCallback({ weatherResult -> + if (weatherResult.status.isSuccess) { + val weather: Weather = weatherResult.weather + val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + 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)) + .putString(Constants.PREF_WEATHER_ICON, getIconCodeFromAwareness(weather.conditions)) + .putString(Constants.PREF_WEATHER_REAL_TEMP_UNIT, SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F")) + .commit() + Util.updateWidget(context) + } + mGoogleApiClient.disconnect() + }) } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 46a4ebd..bbc4ed5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -81,31 +81,6 @@ android:layout_marginBottom="8dp" android:text="@string/settings_general_title" style="@style/AnotherWidget.Settings.Header"/> - - <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_font_color" - android:orientation="vertical"> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - style="@style/AnotherWidget.Settings.Title" - android:text="@string/settings_font_color_title"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/font_color_label" - style="@style/AnotherWidget.Settings.Subtitle"/> - </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" @@ -154,6 +129,54 @@ android:id="@+id/second_text_size_label" style="@style/AnotherWidget.Settings.Subtitle"/> </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_font_color" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/AnotherWidget.Settings.Title" + android:text="@string/settings_font_color_title"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/font_color_label" + style="@style/AnotherWidget.Settings.Subtitle"/> + </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_text_shadow" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/AnotherWidget.Settings.Title" + android:text="@string/title_text_shadow"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/text_shadow_label" + style="@style/AnotherWidget.Settings.Subtitle"/> + </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="1dp" @@ -179,24 +202,61 @@ android:background="?android:attr/selectableItemBackground" android:gravity="center_vertical" android:id="@+id/action_show_clock" - android:orientation="vertical"> + android:orientation="horizontal"> + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/AnotherWidget.Settings.Title" + android:text="@string/title_show_clock"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/show_clock_label" + android:text="@string/description_show_clock" + style="@style/AnotherWidget.Settings.Subtitle"/> + </LinearLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - style="@style/AnotherWidget.Settings.Title" - android:text="@string/title_show_clock"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/show_clock_label" - android:text="@string/description_show_clock" - style="@style/AnotherWidget.Settings.Subtitle"/> + android:text="@string/beta" + android:layout_marginLeft="8dp" + android:layout_gravity="center_vertical|right" + style="@style/AnotherWidget.Settings.Header"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/clock_settings" android:orientation="vertical"> + <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_clock_text_size" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/AnotherWidget.Settings.Title" + android:text="@string/settings_clock_text_size_title"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/clock_text_size_label" + style="@style/AnotherWidget.Settings.Subtitle"/> + </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" @@ -361,6 +421,30 @@ android:id="@+id/all_day_label" style="@style/AnotherWidget.Settings.Subtitle"/> </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_declined_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_declined_events_title"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/show_declined_events_label" + style="@style/AnotherWidget.Settings.Subtitle"/> + </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" @@ -385,6 +469,30 @@ android:id="@+id/show_until_label" style="@style/AnotherWidget.Settings.Subtitle"/> </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_diff_time" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="@style/AnotherWidget.Settings.Title" + android:text="@string/settings_show_diff_time_title"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/show_diff_time_label" + style="@style/AnotherWidget.Settings.Subtitle"/> + </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/app/src/main/res/layout/activity_weather_provider.xml b/app/src/main/res/layout/activity_weather_provider.xml index 47db210..bcccd8e 100644 --- a/app/src/main/res/layout/activity_weather_provider.xml +++ b/app/src/main/res/layout/activity_weather_provider.xml @@ -72,18 +72,22 @@ style="@style/AnotherWidget.Settings.Subtitle" android:textColor="@android:color/black"/> </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/black_10"/> <LinearLayout android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:orientation="horizontal" android:descendantFocusability="beforeDescendants" android:focusable="true" + android:id="@+id/api_key_container" android:focusableInTouchMode="true" android:gravity="center_vertical"> <EditText - android:layout_width="0dp" + android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_weight="1" android:background="@android:color/white" android:padding="16dp" android:inputType="textCapWords" @@ -93,13 +97,6 @@ android:nextFocusLeft="@id/api_key" android:gravity="center_vertical" android:hint="@string/api_key_hint"/> - <ImageView - android:layout_width="48dp" - android:layout_height="48dp" - android:padding="12dp" - android:id="@+id/action_paste" - android:src="@drawable/ic_action_paste" - android:tint="@android:color/black"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" @@ -122,6 +119,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="true" + android:id="@+id/content_info" android:focusableInTouchMode="true" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" @@ -134,27 +132,14 @@ android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> - <LinearLayout + <TextView android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:layout_gravity="center_vertical"> - <TextView - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="2" - android:text="@string/api_key_info_title" - android:gravity="start" - style="@style/AnotherWidget.Main.Title" - android:textSize="20sp" - android:textColor="@android:color/black"/> - <ImageView - android:layout_width="24dp" - android:layout_height="24dp" - android:id="@+id/action_open_info_text" - android:tint="@android:color/black" - android:src="@drawable/ic_action_info"/> - </LinearLayout> + android:text="@string/api_key_info_title" + android:gravity="start" + style="@style/AnotherWidget.Main.Title" + android:textSize="20sp" + android:textColor="@android:color/black"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" @@ -211,6 +196,14 @@ android:textSize="16sp" android:gravity="start" android:text="@string/api_key_subtitle_3"/> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="@android:color/black" + style="@style/AnotherWidget.Main.Subtitle" + android:textSize="16sp" + android:gravity="start" + android:id="@+id/last_info"/> </LinearLayout> </ScrollView> </android.support.v7.widget.CardView> diff --git a/app/src/main/res/layout/main_menu_layout.xml b/app/src/main/res/layout/main_menu_layout.xml index 072fa40..17b61a3 100644 --- a/app/src/main/res/layout/main_menu_layout.xml +++ b/app/src/main/res/layout/main_menu_layout.xml @@ -123,6 +123,7 @@ android:clickable="true" android:focusable="true" android:padding="16dp" + android:visibility="gone" android:id="@+id/action_support" android:orientation="horizontal"> <ImageView diff --git a/app/src/main/res/layout/the_widget.xml b/app/src/main/res/layout/the_widget.xml index 2670c74..df15dc1 100644 --- a/app/src/main/res/layout/the_widget.xml +++ b/app/src/main/res/layout/the_widget.xml @@ -7,20 +7,21 @@ android:id="@+id/time" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="20:16" + android:layout_marginTop="-16dp" android:layout_centerHorizontal="true" android:gravity="center" android:lineSpacingMultiplier="1" android:lineSpacingExtra="0dp" + android:visibility="gone" android:includeFontPadding="false" android:padding="0dp" - android:visibility="gone" style="@style/AnotherWidget.Title" android:textSize="90sp"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" + android:layout_marginTop="-8dp" android:layout_centerHorizontal="true" android:layout_below="@+id/time" android:orientation="horizontal" @@ -35,7 +36,7 @@ android:gravity="right" android:ellipsize="end" android:text="@string/loading_text" - style="@style/AnotherWidget.Title" /> + style="@style/AnotherWidget.Title"/> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" @@ -71,6 +72,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:visibility="gone" + android:layout_marginTop="-8dp" android:layout_centerHorizontal="true" android:layout_below="@+id/time" android:id="@+id/calendar_layout" diff --git a/app/src/main/res/layout/the_widget_sans.xml b/app/src/main/res/layout/the_widget_sans.xml index 08ae23e..87915ad 100644 --- a/app/src/main/res/layout/the_widget_sans.xml +++ b/app/src/main/res/layout/the_widget_sans.xml @@ -1,11 +1,20 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_layout"> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:id="@+id/bitmap_container"/> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:alpha="0"> + <include layout="@layout/the_widget" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:id="@+id/intent_container" /> + </LinearLayout> </RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index f30b826..0edbbb5 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -93,7 +93,7 @@ <string name="api_key_info_start">Ciao a tutti.</string> <string name="api_key_info_text"><![CDATA[Another widget è e rimarrà gratuita e senza banner pubblicitari.<BR /><BR />Però a causa del successo dell\'applicazione, sicuramente oltre ogni mia aspettativa, il provider del meteo non riesce a supportare il numero di richieste che arrivano (a causa dell\'utilizzo di un account gratuito).<BR /><BR />Sono costretto a chiedervi di registrarvi su OpenWeather.com; l\'operazione richiederà solo alcuni minuti e dopo non avrete più problemi con la fruizione delle informazioni sul meteo!<BR /><BR />Mi dispiace per l\'inconveniente ma continuate a supportarmi!!]]></string> <string name="well_done">Ben Fatto!</string> - <string name="api_key_info_all_set"><![CDATA[Posso essere necessari fino a <b>dieci minuti</b> prima che la tua chiave sia attivata.<BR /><BR />Quindi <i>rilassati</i>! Il meteo verrà aggiornato non appena sarà disponibile!]]></string> + <string name="api_key_info_all_set"><![CDATA[Posso essere necessari fino a <b>dieci minuti</b> prima che la tua chiave sia attivata.<BR />Quindi <i>rilassati</i>! Il meteo verrà aggiornato non appena sarà disponibile!]]></string> <string name="hs_code">" ore"</string> <string name="tomorrow">Domani</string> <string name="today">Oggi</string> @@ -110,4 +110,22 @@ <string name="description_show_clock">Mostra l\'ora sopra eventi e meteo</string> <string name="show_clock_visible">Orologio visibile</string> <string name="show_clock_not_visible">Orologio non visibile</string> + <string name="settings_clock_text_size_title">Dimensione Testo Orologio</string> + <string name="title_text_shadow">Ombra Testo</string> + <string name="settings_text_shadow_subtitle_none">Nessuna</string> + <string name="settings_text_shadow_subtitle_low">Bassa</string> + <string name="settings_text_shadow_subtitle_high">Alta</string> + <string name="advanced_settings_title">Impostazioni Avanzate</string> + <string name="beta">Beta</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_show_until_subtitle_6">1 Ora dopo</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_visible">Visibile</string> + <string name="settings_not_visible">Non Visibile</string> + <string name="default_event_app">Dettagli Evento Google Calendar</string> + <string name="default_calendar_app">App Calendario di Default</string> + <string name="default_weather_app">Meteo Google</string> + <string name="default_clock_app">App Orologio di Default</string> </resources> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a970cf..6f1345d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -94,7 +94,7 @@ <string name="api_key_subtitle_3">Enter the key in this section and save it. Once the key is activated the weather will be visible.</string> <string name="api_key_info_start">Hi Everyone!</string> <string name="action_open_provider">Go to OpenWeather.com</string> - <string name="api_key_info_all_set"><![CDATA[It may take up to <b>ten minutes</b> before your API key is activated.<BR /><BR />So <i>relax</i>! The weather will be updated as soon as it is available!!]]></string> + <string name="api_key_info_all_set"><![CDATA[It may take up to <b>ten minutes</b> before your API key is activated.<BR />So <i>relax</i>! The weather will be updated as soon as it is available!!]]></string> <string name="well_done">Well Done!</string> <string name="hs_code">h</string> <string name="tomorrow">Tomorrow</string> @@ -114,4 +114,22 @@ <string name="description_show_clock">View the time over events and weather</string> <string name="show_clock_visible">Clock is visible</string> <string name="show_clock_not_visible">Clock is not visible</string> + <string name="settings_clock_text_size_title">Clock Text Size</string> + <string name="title_text_shadow">Text Shadow</string> + <string name="settings_text_shadow_subtitle_none">None</string> + <string name="settings_text_shadow_subtitle_low">Low</string> + <string name="settings_text_shadow_subtitle_high">High</string> + <string name="advanced_settings_title">Advanced Settings</string> + <string name="beta">Beta</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_show_until_subtitle_6">1 hour later</string> + <string name="settings_show_diff_time_title">Time left for the event</string> + <string name="settings_visible">Visible</string> + <string name="settings_not_visible">Not Visible</string> + <string name="settings_show_declined_events_title">Declined Events</string> + <string name="default_weather_app">Google Weather</string> + <string name="default_event_app">Google Calendar Event Details</string> + <string name="default_calendar_app">Default Calendar App</string> + <string name="default_clock_app">Default Clock App</string> </resources>