diff --git a/.idea/misc.xml b/.idea/misc.xml index d5ae2ac..bdcf934 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -80,7 +80,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index aae0326..775ffef 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { applicationId "com.tommasoberlose.anotherwidget" minSdkVersion 19 targetSdkVersion 26 - versionCode 18 + versionCode 20 versionName "1.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/release/output.json b/app/release/output.json index ab592c5..3664756 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":18},"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":20},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}] \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt index a7348ed..95a862f 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Event.kt @@ -32,10 +32,10 @@ class Event { startDate = instanceCursor.getLong(1) endDate = instanceCursor.getLong(2) - title = eventCursor.getString(0) + title = eventCursor.getString(0)?: "" allDay = !eventCursor.getString(1).equals("0") calendarID = eventCursor.getInt(2) - address = eventCursor.getString(3) + address = eventCursor.getString(3)?: "" } override fun toString(): String { diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/ChooseApplicationActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/ChooseApplicationActivity.kt index 5e63c4f..342c7cf 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/ChooseApplicationActivity.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/ChooseApplicationActivity.kt @@ -51,7 +51,7 @@ class ChooseApplicationActivity : AppCompatActivity() { location.addTextChangedListener(object: TextWatcher { override fun afterTextChanged(text: Editable?) { Thread().run { - val appsFiltered = appList.filter { pm.getApplicationLabel(it).toString().contains(text.toString(), true) } + val appsFiltered = if (text == null || text.equals("")) appList else appList.filter { pm.getApplicationLabel(it).toString().contains(text.toString(), true) } EventBus.getDefault().post(ApplicationListEvent(appsFiltered, true)) } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/CustomLocationActivity.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/CustomLocationActivity.kt index 684b64c..3a57818 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/CustomLocationActivity.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/CustomLocationActivity.kt @@ -70,14 +70,18 @@ class CustomLocationActivity : AppCompatActivity() { location.addTextChangedListener(object: TextWatcher { override fun afterTextChanged(text: Editable?) { - Thread().run { - val coder = Geocoder(this@CustomLocationActivity) - try { - val addresses = coder.getFromLocationName(text.toString(), 10) as ArrayList
- EventBus.getDefault().post(CustomLocationEvent(addresses)) - } catch (ignored: Exception) { - EventBus.getDefault().post(CustomLocationEvent(ArrayList
())) + if (text != null && !text.equals("")) { + Thread().run { + val coder = Geocoder(this@CustomLocationActivity) + try { + val addresses = coder.getFromLocationName(text.toString(), 10) as ArrayList
+ EventBus.getDefault().post(CustomLocationEvent(addresses)) + } catch (ignored: Exception) { + EventBus.getDefault().post(CustomLocationEvent(ArrayList
())) + } } + } else { + EventBus.getDefault().post(CustomLocationEvent(ArrayList
())) } } 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 e5a8a4f..b94dc12 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt @@ -56,7 +56,7 @@ object CalendarUtil { 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 + " is ?", + CalendarContract.Events._ID + " = ?", arrayOf(Integer.toString(ID)), null) if (eventCursor != null && eventCursor.count > 0) { @@ -70,15 +70,15 @@ object CalendarUtil { } eventCursor.moveToNext() } - } - eventCursor.close() + eventCursor.close() + } instanceCursor.moveToNext() } - } - instanceCursor.close() + instanceCursor.close() + } if (eventList.isEmpty()) { resetNextEventData(context) @@ -125,11 +125,11 @@ object CalendarUtil { calendarList.add(CalendarSelector(id, name, account)) calendarCursor.moveToNext() } + + calendarCursor.close() } else { Toast.makeText(context, R.string.error_no_calendar, Toast.LENGTH_SHORT).show() } - - calendarCursor.close() } catch (ignored: Exception) { ignored.printStackTrace() try { @@ -147,9 +147,9 @@ object CalendarUtil { calendarList.add(CalendarSelector(calendarCursor.getInt(0), calendarCursor.getString(1), calendarCursor.getString(2))) calendarCursor.moveToNext() } - } - calendarCursor.close() + calendarCursor.close() + } } catch (ignore: Exception) { ignore.printStackTrace() } finally { 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 2c5cb91..3ce9264 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherUtil.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/WeatherUtil.kt @@ -86,7 +86,7 @@ object WeatherUtil { } Awareness.getSnapshotClient(context).weather .addOnSuccessListener { weatherResponse -> - val weather = weatherResponse.weather + 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))