diff --git a/app/build.gradle b/app/build.gradle
index 7aa2b7a..fb03c0e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -48,4 +48,5 @@ dependencies {
compile 'com.android.support:design:26.1.0'
compile 'com.github.rubensousa:bottomsheetbuilder:1.6.0'
compile 'com.github.johnhiott:DarkSkyApi:v0.1.5'
+ compile 'org.greenrobot:eventbus:3.0.0'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 83723f1..a40cddd 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -21,6 +21,7 @@
android:screenOrientation="portrait">
+
@@ -72,7 +73,12 @@
android:name="io.fabric.ApiKey"
android:value="5232fd734b08a20a984c2de02b37df19269608ef" />
-
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/object/ApplicationListEvent.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/object/ApplicationListEvent.kt
new file mode 100644
index 0000000..0ab019d
--- /dev/null
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/ApplicationListEvent.kt
@@ -0,0 +1,16 @@
+package com.tommasoberlose.anotherwidget.`object`
+
+import android.content.pm.ApplicationInfo
+
+/**
+ * Created by tommaso on 15/10/17.
+ */
+
+class ApplicationListEvent(apps: List, filtered: Boolean) {
+ var apps: List = ArrayList()
+ var filtered: Boolean = false
+ init {
+ this.apps = apps
+ this.filtered = filtered
+ }
+}
\ 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 2aaecad..ce590c9 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/Constants.kt
@@ -12,10 +12,16 @@ import java.util.*
object Constants {
val CALENDAR_REQUEST_CODE = 1
val LOCATION_REQUEST_CODE = 2
+ val CALENDAR_APP_REQUEST_CODE = 3
+ val WEATHER_APP_REQUEST_CODE = 4
+
val RESULT_CODE_CUSTOM_LOCATION = 45
+ val RESULT_APP_NAME = "RESULT_APP_NAME"
+ val RESULT_APP_PACKAGE = "RESULT_APP_PACKAGE"
- val PREF_FIRST_STEP = "PREF_FIRST_STEP"
+ val PREF_SHOW_EVENTS = "PREF_SHOW_EVENTS"
+ val PREF_SHOW_WEATHER = "PREF_SHOW_WEATHER"
val PREF_WEATHER_ICON = "PREF_WEATHER_ICON"
val PREF_WEATHER_TEMP = "PREF_WEATHER_TEMP"
val PREF_WEATHER_TEMP_UNIT = "PREF_WEATHER_TEMP_UNIT"
@@ -34,11 +40,16 @@ object Constants {
val PREF_HOUR_FORMAT = "PREF_HOUR_FORMAT"
val PREF_ITA_FORMAT_DATE = "PREF_ITA_FORMAT_DATE"
val PREF_WEATHER_REFRESH_PERIOD = "PREF_WEATHER_REFRESH_PERIOD"
+ val PREF_SHOW_UNTIL = "PREF_SHOW_UNTIL"
+ val PREF_CALENDAR_APP_NAME = "PREF_CALENDAR_APP_NAME"
+ val PREF_CALENDAR_APP_PACKAGE = "PREF_CALENDAR_APP_PACKAGE"
+ val PREF_WEATHER_APP_NAME = "PREF_WEATHER_APP_NAME"
+ val PREF_WEATHER_APP_PACKAGE = "PREF_WEATHER_APP_PACKAGE"
val itDateFormat = SimpleDateFormat("EEEE, d MMM")
val engDateFormat = SimpleDateFormat("EEEE, MMM d")
val goodHourFormat = SimpleDateFormat("HH:mm")
- val badHourFormat = SimpleDateFormat("KK:mm aa")
+ val badHourFormat = SimpleDateFormat("hh:mm a")
val ACTION_TIME_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_TIME_UPDATE"
val ACTION_CALENDAR_UPDATE = "com.tommasoberlose.anotherwidget.action.ACTION_CALENDAR_UPDATE"
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/object/CustomLocationEvent.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/object/CustomLocationEvent.kt
new file mode 100644
index 0000000..3757f23
--- /dev/null
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/object/CustomLocationEvent.kt
@@ -0,0 +1,14 @@
+package com.tommasoberlose.anotherwidget.`object`
+
+import android.location.Address
+
+/**
+ * Created by tommaso on 14/10/17.
+ */
+
+class CustomLocationEvent(addresses: ArrayList) {
+ var addresses: ArrayList = ArrayList()
+ init {
+ this.addresses = addresses
+ }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..b976c0b
--- /dev/null
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/activity/ChooseApplicationActivity.kt
@@ -0,0 +1,114 @@
+package com.tommasoberlose.anotherwidget.ui.activity
+
+import android.app.Activity
+import android.location.Address
+import android.support.v7.app.AppCompatActivity
+import android.os.Bundle
+import android.preference.PreferenceManager
+import com.tommasoberlose.anotherwidget.R
+import com.tommasoberlose.anotherwidget.`object`.Constants
+import com.tommasoberlose.anotherwidget.`object`.CustomLocationEvent
+import kotlinx.android.synthetic.main.activity_choose_application.*
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
+import android.content.Intent
+import android.content.pm.ApplicationInfo
+import android.widget.AdapterView
+import android.widget.ArrayAdapter
+import com.tommasoberlose.anotherwidget.`object`.ApplicationListEvent
+import android.content.pm.PackageManager
+import android.location.Geocoder
+import android.text.Editable
+import android.text.TextWatcher
+import android.util.Log
+
+
+class ChooseApplicationActivity : AppCompatActivity() {
+ lateinit var adapter: ArrayAdapter
+ val appList = ArrayList()
+ val appListFiltered = ArrayList()
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_choose_application)
+ val pm = packageManager
+
+ action_default.setOnClickListener {
+ selectDefaultApp()
+ }
+
+ adapter = ArrayAdapter(this, R.layout.custom_location_item, appList.map { it.name })
+ list_view.adapter = adapter
+
+ list_view.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
+ val resultIntent = Intent()
+ resultIntent.putExtra(Constants.RESULT_APP_NAME, pm.getApplicationLabel(appListFiltered[position]).toString())
+ resultIntent.putExtra(Constants.RESULT_APP_PACKAGE, appListFiltered[position].packageName)
+ setResult(Activity.RESULT_OK, resultIntent)
+ finish()
+ }
+
+ location.addTextChangedListener(object: TextWatcher {
+ override fun afterTextChanged(text: Editable?) {
+ Thread().run {
+ val appsFiltered = appList.filter { pm.getApplicationLabel(it).toString().contains(text.toString(), true) }
+ EventBus.getDefault().post(ApplicationListEvent(appsFiltered, true))
+ }
+ }
+
+ override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
+ }
+
+ override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
+ }
+ })
+
+ }
+
+ fun selectDefaultApp() {
+ val resultIntent = Intent()
+ resultIntent.putExtra(Constants.RESULT_APP_NAME, getString(R.string.default_name))
+ resultIntent.putExtra(Constants.RESULT_APP_PACKAGE, "")
+ setResult(Activity.RESULT_OK, intent)
+ finish()
+ }
+
+ public override fun onStart() {
+ super.onStart()
+ EventBus.getDefault().register(this)
+ }
+
+ public override fun onResume() {
+ super.onResume()
+ Thread().run {
+ val pm = packageManager
+ val apps = pm.getInstalledApplications(0)
+ EventBus.getDefault().post(ApplicationListEvent(apps, false))
+ }
+ }
+
+ public override fun onStop() {
+ EventBus.getDefault().unregister(this)
+ super.onStop()
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
+ fun onMessageEvent(event: ApplicationListEvent) {
+ val pm = packageManager
+ adapter.clear()
+ if (!event.filtered) {
+ appList.clear()
+ event.apps.mapTo(appList, {it})
+ for (a:ApplicationInfo in appList) {
+ adapter.add(pm.getApplicationLabel(a).toString())
+ }
+ }
+ appListFiltered.clear()
+ event.apps.mapTo(appListFiltered, {it})
+ for (a:ApplicationInfo in appListFiltered) {
+ adapter.add(pm.getApplicationLabel(a).toString())
+ }
+ adapter.notifyDataSetChanged()
+ }
+}
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 c535e19..684b64c 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
@@ -19,13 +19,24 @@ import android.util.Log
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
+import android.widget.ListView
import android.widget.Toast
import com.tommasoberlose.anotherwidget.`object`.Constants
+import com.tommasoberlose.anotherwidget.`object`.CustomLocationEvent
import com.tommasoberlose.anotherwidget.util.WeatherUtil
import kotlinx.android.synthetic.main.activity_custom_location.*
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.ThreadMode
+import org.greenrobot.eventbus.Subscribe
+
+
+
+
class CustomLocationActivity : AppCompatActivity() {
+ lateinit var adapter: ArrayAdapter
+ val addressesList = ArrayList()
@SuppressLint("ApplySharedPref")
override fun onCreate(savedInstanceState: Bundle?) {
@@ -34,11 +45,7 @@ class CustomLocationActivity : AppCompatActivity() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
- val list = ArrayList()
- val addressesList = ArrayList()
- val thread: Thread = Thread()
-
- var adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, list)
+ adapter = ArrayAdapter(this, R.layout.custom_location_item, addressesList.map { it.getAddressLine(0) })
list_view.adapter = adapter
list_view.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
@@ -51,21 +58,26 @@ class CustomLocationActivity : AppCompatActivity() {
finish()
}
+ action_geolocation.setOnClickListener {
+ SP.edit()
+ .remove(Constants.PREF_CUSTOM_LOCATION_LAT)
+ .remove(Constants.PREF_CUSTOM_LOCATION_LON)
+ .remove(Constants.PREF_CUSTOM_LOCATION_ADD)
+ .commit()
+ setResult(Activity.RESULT_OK)
+ finish()
+ }
+
location.addTextChangedListener(object: TextWatcher {
override fun afterTextChanged(text: Editable?) {
- val coder = Geocoder(this@CustomLocationActivity)
- try {
- val addresses = coder.getFromLocationName(text.toString(), 10) as ArrayList
- list.clear()
- addressesList.clear()
-
- addresses.mapTo(list) { it.getAddressLine(0) }
- addresses.mapTo(addressesList) { it }
-
- adapter = ArrayAdapter(this@CustomLocationActivity, R.layout.custom_location_item, list)
- list_view.adapter = adapter
- } catch (ignored: Exception) {
- Toast.makeText(this@CustomLocationActivity, "Erroreeeee", Toast.LENGTH_SHORT).show()
+ 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()))
+ }
}
}
@@ -77,4 +89,25 @@ class CustomLocationActivity : AppCompatActivity() {
})
}
+
+ public override fun onStart() {
+ super.onStart()
+ EventBus.getDefault().register(this)
+ }
+
+ public override fun onStop() {
+ EventBus.getDefault().unregister(this)
+ super.onStop()
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
+ fun onMessageEvent(event: CustomLocationEvent) {
+ adapter.clear()
+ addressesList.clear()
+ event.addresses.mapTo(addressesList, {it})
+ for (a:Address in addressesList) {
+ adapter.add(a.getAddressLine(0))
+ }
+ adapter.notifyDataSetChanged()
+ }
}
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 f47077f..fb9bc53 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
@@ -15,7 +15,6 @@ import android.view.View
import com.tommasoberlose.anotherwidget.`object`.Constants
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.util.Util
-import com.tommasoberlose.anotherwidget.receiver.UpdatesReceiver
import com.tommasoberlose.anotherwidget.receiver.WeatherReceiver
import java.util.*
import java.util.concurrent.TimeUnit
@@ -25,13 +24,9 @@ import com.tommasoberlose.anotherwidget.util.CalendarUtil
import com.tommasoberlose.anotherwidget.util.WeatherUtil
import android.content.DialogInterface
import android.graphics.drawable.Drawable
-import android.support.v4.content.ContextCompat
import android.util.Log
-import android.view.MenuItem
import android.widget.Toast
import com.crashlytics.android.Crashlytics
-import com.github.rubensousa.bottomsheetbuilder.BottomSheetBuilder
-import com.github.rubensousa.bottomsheetbuilder.BottomSheetMenuDialog
import com.tommasoberlose.anotherwidget.`object`.CalendarSelector
import io.fabric.sdk.android.Fabric
import kotlinx.android.synthetic.main.activity_main.*
@@ -40,18 +35,38 @@ import kotlinx.android.synthetic.main.the_widget.*
class MainActivity : AppCompatActivity() {
+ var mAppWidgetId: Int = -1
+
private val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
updateUI()
}
}
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Fabric.with(this, Crashlytics())
+ val extras = intent.extras
+ if (extras != null) {
+ mAppWidgetId = extras.getInt(
+ AppWidgetManager.EXTRA_APPWIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID)
+
+ if (mAppWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
+
+ action_refresh.visibility = View.GONE
+ action_support.visibility = View.GONE
+ action_share.visibility = View.GONE
+ action_add_widget.visibility = View.VISIBLE
+
+ action_add_widget.setOnClickListener {
+ addNewWidget()
+ }
+ }
+ }
+
action_support.setOnClickListener(object: View.OnClickListener {
override fun onClick(p0: View?) {
Util.openURI(this@MainActivity, "https://paypal.me/tommasoberlose")
@@ -64,11 +79,28 @@ class MainActivity : AppCompatActivity() {
}
})
- action_rate.setOnClickListener(object: View.OnClickListener {
- override fun onClick(p0: View?) {
- Util.openURI(this@MainActivity, "https://play.google.com/store/apps/details?id=com.tommasoberlose.anotherwidget")
- }
- })
+ action_refresh.setOnClickListener {
+ WeatherUtil.updateWeather(this)
+ CalendarUtil.updateEventList(this)
+ Util.updateWidget(this)
+ }
+ }
+
+ override fun onBackPressed() {
+ if (mAppWidgetId > 0) {
+ addNewWidget()
+ } else {
+ super.onBackPressed()
+ }
+ }
+
+ fun addNewWidget() {
+ val resultValue = Intent()
+ resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId)
+ setResult(Activity.RESULT_OK, resultValue)
+ finish()
+ sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE))
+ sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
}
override fun onResume() {
@@ -89,38 +121,19 @@ class MainActivity : AppCompatActivity() {
when (requestCode) {
Constants.CALENDAR_REQUEST_CODE -> if (!(permissions.size != 1 || grantResults.size != 1 || grantResults[0] != PackageManager.PERMISSION_GRANTED)) {
CalendarUtil.updateEventList(this)
+ updateAppWidget()
+ updateSettings()
}
Constants.LOCATION_REQUEST_CODE -> if (!(permissions.size != 1 || grantResults.size != 1 || grantResults[0] != PackageManager.PERMISSION_GRANTED)) {
WeatherUtil.updateWeather(this)
+ updateAppWidget()
+ updateSettings()
}
}
}
fun updateUI() {
- no_calendar_permission_container.visibility= View.GONE
- no_location_permission_container.visibility= View.GONE
- all_set_container.visibility = View.GONE
updateSettings()
-
- if (!Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)) {
- no_calendar_permission_container.visibility = View.VISIBLE
- request_calendar.setOnClickListener(object: View.OnClickListener {
- override fun onClick(view: View?) {
- ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.READ_CALENDAR), Constants.CALENDAR_REQUEST_CODE)
- }
- })
- } else {
- if (!Util.checkGrantedPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
- no_location_permission_container.visibility = View.VISIBLE
- request_location.setOnClickListener(object: View.OnClickListener {
- override fun onClick(view: View?) {
- ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), Constants.LOCATION_REQUEST_CODE)
- }
- })
- } else {
- all_set_container.visibility = View.VISIBLE
- }
- }
updateAppWidget()
}
@@ -134,19 +147,35 @@ class MainActivity : AppCompatActivity() {
}
}
+ @SuppressLint("ApplySharedPref")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- if (requestCode == Constants.RESULT_CODE_CUSTOM_LOCATION) {
- if (resultCode == Activity.RESULT_OK) {
+ val SP = PreferenceManager.getDefaultSharedPreferences(this)
+ if (requestCode == Constants.RESULT_CODE_CUSTOM_LOCATION && resultCode == Activity.RESULT_OK) {
updateSettings()
WeatherUtil.updateWeather(this)
- }
+ } else if (requestCode == Constants.CALENDAR_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
+ SP.edit()
+ .putString(Constants.PREF_CALENDAR_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME))
+ .putString(Constants.PREF_CALENDAR_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
+ .commit()
+ Util.updateWidget(this)
+ updateSettings()
+ updateAppWidget()
+ } else if (requestCode == Constants.WEATHER_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
+ SP.edit()
+ .putString(Constants.PREF_WEATHER_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME))
+ .putString(Constants.PREF_WEATHER_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
+ .commit()
+ Util.updateWidget(this)
+ updateSettings()
+ updateAppWidget()
}
}
fun updateCalendarView() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
val now = Calendar.getInstance()
- val calendarLayout = Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)
+ val calendarLayout = SP.getBoolean(Constants.PREF_SHOW_EVENTS, true) && Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)
empty_layout.visibility = View.VISIBLE
calendar_layout.visibility = View.GONE
@@ -184,7 +213,22 @@ class MainActivity : AppCompatActivity() {
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)
val endHour: String = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(e.endDate) else Constants.goodHourFormat.format(e.endDate)
- next_event_date.text = String.format("%s - %s", startHour, endHour)
+ var dayDiff = TimeUnit.MILLISECONDS.toDays(e.endDate - e.startDate)
+
+ val startCal = Calendar.getInstance()
+ startCal.timeInMillis = e.startDate
+
+ val endCal = Calendar.getInstance()
+ endCal.timeInMillis = e.endDate
+
+ if (startCal.get(Calendar.HOUR_OF_DAY) >= endCal.get(Calendar.HOUR_OF_DAY)) {
+ dayDiff++
+ }
+ var multipleDay: String = ""
+ if (dayDiff > 0) {
+ multipleDay = String.format(" (+%s%s)", dayDiff, getString(R.string.day_char))
+ }
+ next_event_date.text = String.format("%s - %s%s", startHour, endHour, multipleDay)
} else {
next_event_date.text = dateStringValue
}
@@ -196,9 +240,9 @@ class MainActivity : AppCompatActivity() {
}
fun updateLocationView() {
- val locationLayout = Util.checkGrantedPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
-
val SP = PreferenceManager.getDefaultSharedPreferences(this)
+ val locationLayout = SP.getBoolean(Constants.PREF_SHOW_WEATHER, true) && Util.checkGrantedPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+
if (locationLayout && SP.contains(Constants.PREF_WEATHER_TEMP) && SP.contains(Constants.PREF_WEATHER_ICON)) {
weather.visibility = View.VISIBLE
calendar_weather.visibility = View.VISIBLE
@@ -227,6 +271,63 @@ class MainActivity : AppCompatActivity() {
@SuppressLint("ApplySharedPref")
fun updateSettings() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
+
+ if (SP.getBoolean(Constants.PREF_SHOW_EVENTS, true) && Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)) {
+ calendar_settings.visibility = View.VISIBLE
+ action_show_events.setOnClickListener {
+ SP.edit()
+ .putBoolean(Constants.PREF_SHOW_EVENTS, false)
+ .commit()
+ updateSettings()
+ updateAppWidget()
+ Util.updateWidget(this)
+ }
+ show_events_label.text = getString(R.string.show_events_visible)
+ } else {
+ calendar_settings.visibility= View.GONE
+ action_show_events.setOnClickListener {
+ if (Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)) {
+ SP.edit()
+ .putBoolean(Constants.PREF_SHOW_EVENTS, true)
+ .commit()
+ updateSettings()
+ updateAppWidget()
+ Util.updateWidget(this)
+ } else {
+ ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.READ_CALENDAR), Constants.CALENDAR_REQUEST_CODE)
+ }
+ }
+ show_events_label.text = if (Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)) getString(R.string.show_events_not_visible) else getString(R.string.description_permission_calendar)
+ }
+
+ if (SP.getBoolean(Constants.PREF_SHOW_WEATHER, true) && Util.checkGrantedPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
+ weather_settings.visibility = View.VISIBLE
+ action_show_weather.setOnClickListener {
+ SP.edit()
+ .putBoolean(Constants.PREF_SHOW_WEATHER, false)
+ .commit()
+ updateSettings()
+ updateAppWidget()
+ Util.updateWidget(this)
+ }
+ show_weather_label.text = getString(R.string.show_weather_visible)
+ } else {
+ weather_settings.visibility= View.GONE
+ action_show_weather.setOnClickListener {
+ if (Util.checkGrantedPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
+ SP.edit()
+ .putBoolean(Constants.PREF_SHOW_WEATHER, true)
+ .commit()
+ updateSettings()
+ updateAppWidget()
+ Util.updateWidget(this)
+ } else {
+ ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), Constants.LOCATION_REQUEST_CODE)
+ }
+ }
+ show_weather_label.text = if (Util.checkGrantedPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) getString(R.string.show_weather_not_visible) else getString(R.string.description_permission_location)
+ }
+
temp_unit.text = if (SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F").equals("F")) getString(R.string.fahrenheit) else getString(R.string.celsius)
action_change_unit.setOnClickListener {
SP.edit().putString(Constants.PREF_WEATHER_TEMP_UNIT, if (SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F").equals("F")) "C" else "F").commit()
@@ -244,8 +345,9 @@ class MainActivity : AppCompatActivity() {
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()
- sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE))
updateSettings()
+ updateAppWidget()
+ Util.updateWidget(this)
}
val now = Calendar.getInstance()
@@ -257,31 +359,38 @@ class MainActivity : AppCompatActivity() {
action_date_format.setOnClickListener {
SP.edit().putBoolean(Constants.PREF_ITA_FORMAT_DATE, !SP.getBoolean(Constants.PREF_ITA_FORMAT_DATE, false)).commit()
updateSettings()
+ updateAppWidget()
Util.updateWidget(this)
}
label_weather_refresh_period.text = getString(Util.getRefreshPeriodString(SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1)))
action_weather_refresh_period.setOnClickListener {
- val dialog: BottomSheetMenuDialog = BottomSheetBuilder(this, R.style.Theme_Design_Light_BottomSheetDialog)
- .setMode(BottomSheetBuilder.MODE_LIST)
- .setMenu(R.menu.weather_refresh_period_menu)
- .setIconTintColor(ContextCompat.getColor(this, R.color.black_50))
- .delayDismissOnItemClick(false)
- .setItemClickListener({ item: MenuItem ->
- SP.edit().putInt(Constants.PREF_WEATHER_REFRESH_PERIOD, when (item.itemId) {
- R.id.refresh_1 -> 1
- R.id.refresh_2 -> 2
- R.id.refresh_3 -> 3
- R.id.refresh_4 -> 4
- R.id.refresh_5 -> 5
- else -> 1
- }).commit()
- updateSettings()
- WeatherReceiver().setUpdates(this@MainActivity)
- })
- .createDialog()
+ 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)
+ }
- dialog.show()
+ show_until_label.text = getString(Util.getShowUntilString(SP.getInt(Constants.PREF_SHOW_UNTIL, 1)))
+ action_show_until.setOnClickListener {
+ SP.edit().putInt(Constants.PREF_SHOW_UNTIL, when (SP.getInt(Constants.PREF_SHOW_UNTIL, 1)) {
+ 0 -> 1
+ 1 -> 2
+ 2 -> 3
+ 3 -> 4
+ 4 -> 5
+ 5 -> 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))
@@ -289,6 +398,16 @@ class MainActivity : AppCompatActivity() {
startActivityForResult(Intent(this, CustomLocationActivity::class.java), Constants.RESULT_CODE_CUSTOM_LOCATION)
}
+ calendar_app_label.text = SP.getString(Constants.PREF_CALENDAR_APP_NAME, getString(R.string.default_name))
+ 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))
+ action_weather_app.setOnClickListener {
+ startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.WEATHER_APP_REQUEST_CODE)
+ }
+
action_filter_calendar.setOnClickListener {
val calendarSelectorList: List = CalendarUtil.getCalendarList(this)
var calFiltered = SP.getString(Constants.PREF_CALENDAR_FILTER, "")
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 a7fdb2b..a203cbd 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
@@ -29,6 +29,10 @@ import android.net.Uri
import android.widget.TextClock
import android.widget.TextView
import android.content.ComponentName
+import android.support.v4.content.ContextCompat.startActivity
+import android.provider.CalendarContract.Events
+
+
@@ -72,7 +76,7 @@ class TheWidget : AppWidgetProvider() {
fun updateCalendarView(context: Context, views: RemoteViews, widgetID: Int): RemoteViews {
val SP = PreferenceManager.getDefaultSharedPreferences(context)
val now = Calendar.getInstance()
- val calendarLayout = Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)
+ val calendarLayout = SP.getBoolean(Constants.PREF_SHOW_EVENTS, true) && Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)
views.setViewVisibility(R.id.empty_layout, View.VISIBLE)
views.setViewVisibility(R.id.calendar_layout, View.GONE)
@@ -83,9 +87,8 @@ class TheWidget : AppWidgetProvider() {
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 calIntent = Intent(Intent.ACTION_MAIN)
- calIntent.addCategory(Intent.CATEGORY_APP_CALENDAR)
- val calPIntent = PendingIntent.getActivity(context, widgetID, calIntent, 0)
+
+ val calPIntent = PendingIntent.getActivity(context, widgetID, Util.getCalendarIntent(context), 0)
views.setOnClickPendingIntent(R.id.main_layout, calPIntent)
@@ -114,7 +117,24 @@ class TheWidget : AppWidgetProvider() {
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)
val endHour: String = if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) Constants.badHourFormat.format(e.endDate) else Constants.goodHourFormat.format(e.endDate)
- views.setTextViewText(R.id.next_event_date, String.format("%s - %s", startHour, endHour))
+ var dayDiff = TimeUnit.MILLISECONDS.toDays(e.endDate - e.startDate)
+
+ val startCal = Calendar.getInstance()
+ startCal.timeInMillis = e.startDate
+
+ val endCal = Calendar.getInstance()
+ endCal.timeInMillis = e.endDate
+
+ if (startCal.get(Calendar.HOUR_OF_DAY) >= endCal.get(Calendar.HOUR_OF_DAY)) {
+ dayDiff++
+ }
+
+ var multipleDay: String = ""
+ if (dayDiff > 0) {
+ multipleDay = String.format(" (+%s%s)", dayDiff, context.getString(R.string.day_char))
+ }
+
+ views.setTextViewText(R.id.next_event_date, String.format("%s - %s%s", startHour, endHour, multipleDay))
} else {
views.setTextViewText(R.id.next_event_date, dateStringValue)
}
@@ -122,11 +142,12 @@ class TheWidget : AppWidgetProvider() {
views.setViewVisibility(R.id.empty_layout, View.GONE)
views.setViewVisibility(R.id.calendar_layout, View.VISIBLE)
- val builder = CalendarContract.CONTENT_URI.buildUpon()
- builder.appendPath("time")
- ContentUris.appendId(builder, e.startDate)
+
+ val uri = ContentUris.withAppendedId(Events.CONTENT_URI, e.id.toLong())
val intent = Intent(Intent.ACTION_VIEW)
- .setData(builder.build())
+ .setData(uri)
+ intent.putExtra("beginTime", e.startDate);
+ intent.putExtra("endTime", e.endDate);
val pIntent = PendingIntent.getActivity(context, widgetID, intent, 0)
views.setOnClickPendingIntent(R.id.main_layout, pIntent)
}
@@ -136,9 +157,9 @@ class TheWidget : AppWidgetProvider() {
}
fun updateLocationView(context: Context, views: RemoteViews, widgetID: Int): RemoteViews {
- val locationLayout = Util.checkGrantedPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
-
val SP = PreferenceManager.getDefaultSharedPreferences(context)
+ val locationLayout = SP.getBoolean(Constants.PREF_SHOW_WEATHER, true) && Util.checkGrantedPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
+
if (locationLayout && SP.contains(Constants.PREF_WEATHER_TEMP) && SP.contains(Constants.PREF_WEATHER_ICON)) {
views.setViewVisibility(R.id.weather, View.VISIBLE)
views.setViewVisibility(R.id.calendar_weather, View.VISIBLE)
@@ -159,12 +180,8 @@ class TheWidget : AppWidgetProvider() {
views.setTextViewText(R.id.temp, temp)
views.setTextViewText(R.id.calendar_temp, temp)
- val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
- weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
- weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
- weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
- val weatherPIntent = PendingIntent.getActivity(context, widgetID, weatherIntent, 0)
+ val weatherPIntent = PendingIntent.getActivity(context, widgetID, Util.getWeatherIntent(context), 0)
views.setOnClickPendingIntent(R.id.weather, weatherPIntent)
views.setOnClickPendingIntent(R.id.calendar_weather, weatherPIntent)
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 82d4b95..bb569c0 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/CalendarUtil.kt
@@ -25,12 +25,21 @@ object CalendarUtil {
val eventList = ArrayList()
val now = Calendar.getInstance()
- val hourLimit = Calendar.getInstance()
- hourLimit.add(Calendar.HOUR, 8)
+ val limit = Calendar.getInstance()
+ when (SP.getInt(Constants.PREF_SHOW_UNTIL, 1)) {
+ 0 -> limit.add(Calendar.HOUR, 3)
+ 1 -> limit.add(Calendar.HOUR, 6)
+ 2 -> limit.add(Calendar.HOUR, 12)
+ 3 -> limit.add(Calendar.DAY_OF_MONTH, 1)
+ 4 -> limit.add(Calendar.DAY_OF_MONTH, 3)
+ 5 -> limit.add(Calendar.DAY_OF_MONTH, 7)
+ else -> limit.add(Calendar.HOUR, 6)
+ }
+
val builder = CalendarContract.Instances.CONTENT_URI.buildUpon()
ContentUris.appendId(builder, now.timeInMillis)
- ContentUris.appendId(builder, hourLimit.timeInMillis)
+ ContentUris.appendId(builder, limit.timeInMillis)
if (!Util.checkGrantedPermission(context, Manifest.permission.READ_CALENDAR)) {
resetNextEventData(context)
@@ -107,10 +116,13 @@ object CalendarUtil {
calendarList.add(CalendarSelector(calendarCursor.getInt(0), calendarCursor.getString(1), calendarCursor.getString(2)))
calendarCursor.moveToNext()
}
+ } else {
+ Log.d("AW", "No calendar")
}
calendarCursor.close()
} catch (ignored: Exception) {
+ ignored.printStackTrace()
try {
val calendarCursor = context.contentResolver.query(CalendarContract.Calendars.CONTENT_URI,
arrayOf(CalendarContract.Calendars._ID, CalendarContract.Calendars.NAME, CalendarContract.Calendars.ACCOUNT_NAME),
@@ -130,7 +142,7 @@ object CalendarUtil {
calendarCursor.close()
} catch (ignore: Exception) {
-
+ ignore.printStackTrace()
} finally {
return calendarList
}
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 97e32f2..8a1ae5f 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt
@@ -24,8 +24,12 @@ import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.support.annotation.StringRes
import android.util.TypedValue
-
-
+import android.content.Intent
+import android.content.ComponentName
+import android.preference.PreferenceManager
+import android.util.Log
+import android.widget.Toast
+import com.tommasoberlose.anotherwidget.`object`.Constants
/**
@@ -34,7 +38,6 @@ import android.util.TypedValue
object Util {
-
fun checkGrantedPermission(context: Context, permission: String): Boolean {
return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED
}
@@ -43,7 +46,7 @@ object Util {
val widgetManager = AppWidgetManager.getInstance(context)
val widgetComponent = ComponentName(context, TheWidget::class.java)
val widgetIds = widgetManager.getAppWidgetIds(widgetComponent)
- val update = Intent()
+ val update = Intent(context, TheWidget::class.java)
update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds)
update.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
context.sendBroadcast(update)
@@ -78,9 +81,20 @@ object Util {
val customTabsIntent: CustomTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
} catch (e: Exception) {
- val legalIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url));
- context.startActivity(legalIntent);
+ try {
+ val openIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ context.startActivity(openIntent);
+ } catch (ignored: Exception) {
+ val clipboard:ClipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
+ val clip = ClipData.newPlainText(context.getString(R.string.app_name), url);
+ clipboard.primaryClip = clip;
+ Toast.makeText(context, R.string.error_opening_uri, Toast.LENGTH_LONG).show()
+ }
}
+ val clipboard:ClipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
+ val clip = ClipData.newPlainText(context.getString(R.string.app_name), url);
+ clipboard.primaryClip = clip;
+ Toast.makeText(context, R.string.error_opening_uri, Toast.LENGTH_LONG).show()
}
fun share(context: Context) {
@@ -157,4 +171,62 @@ object Util {
else -> R.string.settings_weather_refresh_period_subtitle_0
}
}
+
+ fun getShowUntilString(period: Int): Int {
+ return when (period) {
+ 0 -> R.string.settings_show_until_subtitle_0
+ 1 -> R.string.settings_show_until_subtitle_1
+ 2 -> R.string.settings_show_until_subtitle_2
+ 3 -> R.string.settings_show_until_subtitle_3
+ 4 -> R.string.settings_show_until_subtitle_4
+ 5 -> R.string.settings_show_until_subtitle_5
+ else -> R.string.settings_show_until_subtitle_1
+ }
+ }
+
+ fun getCalendarIntent(context: Context): Intent {
+ val SP = PreferenceManager.getDefaultSharedPreferences(context)
+ if (SP.getString(Constants.PREF_CALENDAR_APP_PACKAGE, "").equals("")) {
+ val calIntent = Intent(Intent.ACTION_MAIN)
+ calIntent.addCategory(Intent.CATEGORY_APP_CALENDAR)
+ return calIntent
+ } else {
+ val pm: PackageManager = context.packageManager
+ return try {
+ val intent: Intent = pm.getLaunchIntentForPackage(SP.getString(Constants.PREF_CALENDAR_APP_PACKAGE, ""))
+ intent.addCategory(Intent.CATEGORY_LAUNCHER)
+ intent
+ } catch (e: Exception) {
+ e.printStackTrace()
+ val calIntent = Intent(Intent.ACTION_MAIN)
+ calIntent.addCategory(Intent.CATEGORY_APP_CALENDAR)
+ calIntent
+ }
+ }
+ }
+
+ fun getWeatherIntent(context: Context): Intent {
+ val SP = PreferenceManager.getDefaultSharedPreferences(context)
+ if (SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, "").equals("")) {
+ val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
+ weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
+ weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
+ weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
+ return weatherIntent
+ } else {
+ val pm: PackageManager = context.packageManager
+ return try {
+ val intent: Intent = pm.getLaunchIntentForPackage(SP.getString(Constants.PREF_WEATHER_APP_PACKAGE, ""))
+ intent.addCategory(Intent.CATEGORY_LAUNCHER)
+ intent
+ } catch (e: Exception) {
+ val weatherIntent: Intent = Intent(Intent.ACTION_VIEW)
+ weatherIntent.addCategory(Intent.CATEGORY_DEFAULT)
+ weatherIntent.data = Uri.parse("dynact://velour/weather/ProxyActivity")
+ weatherIntent.component = ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velour.DynamicActivityTrampoline")
+ weatherIntent
+ }
+ }
+ }
+
}
diff --git a/app/src/main/res/anim/slide_down.xml b/app/src/main/res/anim/slide_down.xml
new file mode 100644
index 0000000..04b4878
--- /dev/null
+++ b/app/src/main/res/anim/slide_down.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/slide_up.xml b/app/src/main/res/anim/slide_up.xml
new file mode 100644
index 0000000..a70ce80
--- /dev/null
+++ b/app/src/main/res/anim/slide_up.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/stay.xml b/app/src/main/res/anim/stay.xml
new file mode 100644
index 0000000..0f9dfd0
--- /dev/null
+++ b/app/src/main/res/anim/stay.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-hdpi/ic_action_aw.png b/app/src/main/res/drawable-hdpi/ic_action_aw.png
new file mode 100644
index 0000000..ee22b41
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_aw.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_action_geolocation.png b/app/src/main/res/drawable-hdpi/ic_action_geolocation.png
new file mode 100644
index 0000000..cb729bb
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_geolocation.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_action_gps.png b/app/src/main/res/drawable-hdpi/ic_action_gps.png
new file mode 100644
index 0000000..cb729bb
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_gps.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_action_refresh.png b/app/src/main/res/drawable-hdpi/ic_action_refresh.png
new file mode 100644
index 0000000..a61eb24
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_refresh.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_action_reset.png b/app/src/main/res/drawable-hdpi/ic_action_reset.png
new file mode 100644
index 0000000..9b008a0
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_reset.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_action_aw.png b/app/src/main/res/drawable-mdpi/ic_action_aw.png
new file mode 100644
index 0000000..532811f
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_aw.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_action_geolocation.png b/app/src/main/res/drawable-mdpi/ic_action_geolocation.png
new file mode 100644
index 0000000..5f5c47b
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_geolocation.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_action_gps.png b/app/src/main/res/drawable-mdpi/ic_action_gps.png
new file mode 100644
index 0000000..5f5c47b
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_gps.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_action_refresh.png b/app/src/main/res/drawable-mdpi/ic_action_refresh.png
new file mode 100644
index 0000000..85f0b3b
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_refresh.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_action_reset.png b/app/src/main/res/drawable-mdpi/ic_action_reset.png
new file mode 100644
index 0000000..2e3a2e3
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_reset.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_aw.png b/app/src/main/res/drawable-xhdpi/ic_action_aw.png
new file mode 100644
index 0000000..1dd0bff
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_aw.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_geolocation.png b/app/src/main/res/drawable-xhdpi/ic_action_geolocation.png
new file mode 100644
index 0000000..896f73d
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_geolocation.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_gps.png b/app/src/main/res/drawable-xhdpi/ic_action_gps.png
new file mode 100644
index 0000000..896f73d
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_gps.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_refresh.png b/app/src/main/res/drawable-xhdpi/ic_action_refresh.png
new file mode 100644
index 0000000..6c9b809
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_refresh.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_reset.png b/app/src/main/res/drawable-xhdpi/ic_action_reset.png
new file mode 100644
index 0000000..b14fa22
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_reset.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_aw.png b/app/src/main/res/drawable-xxhdpi/ic_action_aw.png
new file mode 100644
index 0000000..3f179c8
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_aw.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_geolocation.png b/app/src/main/res/drawable-xxhdpi/ic_action_geolocation.png
new file mode 100644
index 0000000..2fb3918
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_geolocation.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_gps.png b/app/src/main/res/drawable-xxhdpi/ic_action_gps.png
new file mode 100644
index 0000000..2fb3918
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_gps.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_refresh.png b/app/src/main/res/drawable-xxhdpi/ic_action_refresh.png
new file mode 100644
index 0000000..77dffe9
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_refresh.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_reset.png b/app/src/main/res/drawable-xxhdpi/ic_action_reset.png
new file mode 100644
index 0000000..0e22581
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_reset.png differ
diff --git a/app/src/main/res/layout/activity_choose_application.xml b/app/src/main/res/layout/activity_choose_application.xml
new file mode 100644
index 0000000..914bf5f
--- /dev/null
+++ b/app/src/main/res/layout/activity_choose_application.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_custom_location.xml b/app/src/main/res/layout/activity_custom_location.xml
index e902b13..c5b87ed 100644
--- a/app/src/main/res/layout/activity_custom_location.xml
+++ b/app/src/main/res/layout/activity_custom_location.xml
@@ -1,31 +1,83 @@
-
+
+
+
+
-
+
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+
+
+
+
+
-
-
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index df4a556..de579af 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -54,7 +54,8 @@
+ android:id="@+id/all_set_container"
+ tools:ignore="UselessParent">
+ android:text="@string/title_permission_calendar"/>
-
-
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+ 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_calendar_app"
+ android:orientation="vertical">
+
+
+
+ android:text="@string/title_permission_location"/>
-
-
+
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+ 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_weather_app"
+ android:orientation="vertical">
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ android:src="@drawable/ic_action_refresh"/>
diff --git a/app/src/main/res/layout/custom_location_item.xml b/app/src/main/res/layout/custom_location_item.xml
index 99cafe2..6d41d9f 100644
--- a/app/src/main/res/layout/custom_location_item.xml
+++ b/app/src/main/res/layout/custom_location_item.xml
@@ -5,4 +5,5 @@
android:layout_height="?android:attr/actionBarSize"
android:gravity="center_vertical"
android:padding="16dp"
+ android:textColor="@android:color/primary_text_light"
style="@style/AnotherWidget.Settings.Title"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/the_widget.xml b/app/src/main/res/layout/the_widget.xml
index ffd834a..a40a484 100644
--- a/app/src/main/res/layout/the_widget.xml
+++ b/app/src/main/res/layout/the_widget.xml
@@ -16,6 +16,7 @@
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
+ android:text="@string/loading_text"
style="@style/AnotherWidget.Title" />
24 Ore
Località Meteo
Geolocalizzazione
+ Aggiorna
+ Eventi Visibili
+ Eventi non Visibili
+ Meteo Visibile
+ Meteo non Visibile
+ 3 Ore dopo
+ 6 Ore dopo
+ 12 Ore dopo
+ 24 Ore dopo
+ 3 Giorni dopo
+ 7 Giorni dopo
+ Vedi eventi al massimo fino a
+ g
+ Errore apertura URL: Link copiato negli appunti.
+ Caricamento...
+ Errore apertura App.
+ La data apre
+ Il meteo apre
+ App Predefinita
+ Scegli Applicazione
\ 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 b3712bb..f67012d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -49,4 +49,25 @@
24 Hours
Custom Location
Geolocation
+ Refresh
+ Events are Visible
+ Events are not Visible
+ Weather Info are Visible
+ Weather Info are not Visible
+ 3 Hours later
+ 6 Hours later
+ 12 Hours later
+ 24 Hours later
+ 3 Days later
+ 7 Days later
+ See events at most until
+ d
+ toolbar
+ Error opening URL: Link copied to clipboard.
+ Loading Data...
+ Error opening App.
+ Tap on date opens
+ Tap on weather opens
+ Default App
+ Choose Application
diff --git a/app/src/main/res/xml/the_widget_info.xml b/app/src/main/res/xml/the_widget_info.xml
index 6b20927..4a62b5a 100644
--- a/app/src/main/res/xml/the_widget_info.xml
+++ b/app/src/main/res/xml/the_widget_info.xml
@@ -4,6 +4,7 @@
android:initialLayout="@layout/the_widget"
android:minHeight="128dp"
android:minWidth="300dp"
+ android:configure="com.tommasoberlose.anotherwidget.ui.activity.MainActivity"
android:minResizeHeight="40dp"
android:minResizeWidth="250dp"
android:previewImage="@drawable/widget_preview"
diff --git a/build.gradle b/build.gradle
index 0a25535..ee06b7e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,7 +8,7 @@ buildscript {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0-beta7'
+ classpath 'com.android.tools.build:gradle:3.0.0-rc1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.+'