New changes and fixes

This commit is contained in:
Tommaso Berlose 2017-10-15 15:02:49 +02:00
parent 4d80c53b67
commit 891977612e
43 changed files with 1004 additions and 319 deletions

View File

@ -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'
}

View File

@ -21,6 +21,7 @@
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
@ -72,7 +73,12 @@
android:name="io.fabric.ApiKey"
android:value="5232fd734b08a20a984c2de02b37df19269608ef" />
<activity android:name=".ui.activity.CustomLocationActivity"></activity>
<activity
android:name=".ui.activity.CustomLocationActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleInstance"
android:screenOrientation="portrait" />
<activity android:name=".ui.activity.ChooseApplicationActivity"></activity>
</application>
</manifest>

View File

@ -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<ApplicationInfo>, filtered: Boolean) {
var apps: List<ApplicationInfo> = ArrayList()
var filtered: Boolean = false
init {
this.apps = apps
this.filtered = filtered
}
}

View File

@ -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"

View File

@ -0,0 +1,14 @@
package com.tommasoberlose.anotherwidget.`object`
import android.location.Address
/**
* Created by tommaso on 14/10/17.
*/
class CustomLocationEvent(addresses: ArrayList<Address>) {
var addresses: ArrayList<Address> = ArrayList()
init {
this.addresses = addresses
}
}

View File

@ -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<String>
val appList = ArrayList<ApplicationInfo>()
val appListFiltered = ArrayList<ApplicationInfo>()
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()
}
}

View File

@ -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<String>
val addressesList = ArrayList<Address>()
@SuppressLint("ApplySharedPref")
override fun onCreate(savedInstanceState: Bundle?) {
@ -34,11 +45,7 @@ class CustomLocationActivity : AppCompatActivity() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
val list = ArrayList<String>()
val addressesList = ArrayList<Address>()
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<Address>
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<Address>
EventBus.getDefault().post(CustomLocationEvent(addresses))
} catch (ignored: Exception) {
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
}
}
}
@ -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()
}
}

View File

@ -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<CalendarSelector> = CalendarUtil.getCalendarList(this)
var calFiltered = SP.getString(Constants.PREF_CALENDAR_FILTER, "")

View File

@ -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)

View File

@ -25,12 +25,21 @@ object CalendarUtil {
val eventList = ArrayList<Event>()
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
}

View File

@ -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
}
}
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0"
android:toYDelta="100%p" />
</set>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="100%p"
android:toYDelta="0" />
</set>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="0%p"
android:toYDelta="0%p" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/gradient_background"
tools:context="com.tommasoberlose.anotherwidget.ui.activity.ChooseApplicationActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="32dp"
android:id="@+id/toolbar"
android:gravity="center_vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_pre_title"
android:alpha="0.6"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center_vertical"
style="@style/AnotherWidget.Main.Subtitle"
android:textAllCaps="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:gravity="center_vertical"
style="@style/AnotherWidget.Main.Title"
android:textAllCaps="true"/>
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
app:cardCornerRadius="3dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:background="@android:color/white"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/white"
android:padding="16dp"
android:inputType="textCapWords"
android:id="@+id/location"
android:textStyle="bold"
android:gravity="center_vertical"
android:hint="@string/action_choose_application"/>
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/custom_location_gps"
android:id="@+id/action_default"
android:src="@drawable/ic_action_reset"
android:tint="@android:color/primary_text_light"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black_10"/>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list_view" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

View File

@ -1,31 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/gradient_background"
tools:context="com.tommasoberlose.anotherwidget.ui.activity.CustomLocationActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="32dp"
android:id="@+id/toolbar"
android:gravity="center_vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/main_pre_title"
android:alpha="0.6"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:gravity="center_vertical"
style="@style/AnotherWidget.Main.Subtitle"
android:textAllCaps="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:gravity="center_vertical"
style="@style/AnotherWidget.Main.Title"
android:textAllCaps="true"/>
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_height="wrap_content"
android:padding="8dp"
app:cardCornerRadius="0dp"
android:id="@+id/toolbar"
android:background="@android:color/white">
<EditText
app:cardCornerRadius="3dp"
android:layout_margin="16dp"
android:background="@android:color/white"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:padding="16dp"
android:inputType="textCapWords"
android:id="@+id/location"
android:gravity="center_vertical"
android:hint="@string/settings_custom_location_title"/>
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/white"
android:padding="16dp"
android:inputType="textCapWords"
android:id="@+id/location"
android:textStyle="bold"
android:gravity="center_vertical"
android:hint="@string/settings_custom_location_title"/>
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="12dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/custom_location_gps"
android:id="@+id/action_geolocation"
android:src="@drawable/ic_action_gps"
android:tint="@android:color/primary_text_light"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black_10"/>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list_view" />
</LinearLayout>
</android.support.v7.widget.CardView>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list_view"
android:layout_below="@+id/toolbar" />
</RelativeLayout>
</LinearLayout>

View File

@ -54,7 +54,8 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/all_set_container">
android:id="@+id/all_set_container"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -79,90 +80,169 @@
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_date_format"
android:id="@+id/action_show_events"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_date_format_title"/>
android:text="@string/title_permission_calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/date_format_label"
android:id="@+id/show_events_label"
android:text="@string/description_permission_calendar"
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_hour_format"
android:id="@+id/calendar_settings"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_hour_format_title"/>
<TextView
android:layout_width="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_date_format"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_date_format_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/date_format_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/hour_format_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_filter_calendar"
android:orientation="vertical">
<TextView
android:layout_width="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_hour_format"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_hour_format_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hour_format_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_filter_calendar_title"/>
<TextView
android:layout_width="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_filter_calendar"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_filter_calendar_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_filter_calendar_subtitle"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings_filter_calendar_subtitle"
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_all_day"
android:orientation="vertical">
<TextView
android:layout_width="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_all_day"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_all_day_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/all_day_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_all_day_title"/>
<TextView
android:layout_width="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_until"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_show_until_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_until_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/all_day_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_calendar_app_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/calendar_app_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -190,150 +270,124 @@
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_custom_location"
android:visibility="gone"
android:id="@+id/action_show_weather"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_custom_location_title"/>
android:text="@string/title_permission_location"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_custom_location"
android:id="@+id/show_weather_label"
android:text="@string/description_permission_location"
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_change_unit"
android:id="@+id/weather_settings"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_unit_title"/>
<TextView
android:layout_width="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:id="@+id/action_custom_location"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_custom_location_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_custom_location"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/temp_unit"
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_weather_refresh_period"
android:orientation="vertical">
<TextView
android:layout_width="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_change_unit"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_unit_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/temp_unit"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_weather_refresh_period_title"/>
<TextView
android:layout_width="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_weather_refresh_period"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_weather_refresh_period_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_weather_refresh_period"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/label_weather_refresh_period"
style="@style/AnotherWidget.Settings.Subtitle"/>
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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Settings.Title"
android:text="@string/settings_weather_app_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/weather_app_label"
style="@style/AnotherWidget.Settings.Subtitle"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:visibility="gone"
android:id="@+id/no_calendar_permission_container"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="14dp"
android:visibility="gone"
android:tint="@android:color/white"
android:background="@drawable/circle_background"
android:src="@drawable/ic_action_calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Main.Title"
android:paddingTop="16dp"
android:paddingRight="32dp"
android:paddingLeft="32dp"
android:text="@string/title_permission_calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Main.Description"
android:paddingBottom="32dp"
android:paddingRight="32dp"
android:paddingLeft="32dp"
android:text="@string/description_permission_calendar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Main.Button"
android:id="@+id/request_calendar"
android:text="@string/button_request_permission"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="@+id/no_location_permission_container"
android:layout_centerInParent="true"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="14dp"
android:visibility="gone"
android:tint="@android:color/white"
android:background="@drawable/circle_background"
android:src="@drawable/ic_action_location"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Main.Title"
android:paddingTop="16dp"
android:paddingRight="32dp"
android:paddingLeft="32dp"
android:text="@string/title_permission_location"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Main.Description"
android:paddingBottom="32dp"
android:paddingRight="32dp"
android:paddingLeft="32dp"
android:text="@string/description_permission_location"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AnotherWidget.Main.Button"
android:id="@+id/request_location"
android:text="@string/button_request_permission"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
@ -342,8 +396,18 @@
android:gravity="center"
android:baselineAligned="false"
android:id="@+id/menu_container"
android:orientation="horizontal"
android:background="@color/midnight_blue"
android:layout_gravity="bottom">
<TextView
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="@string/add_widget"
android:visibility="gone"
android:gravity="center"
android:background="?android:attr/selectableItemBackground"
android:id="@+id/action_add_widget"
style="@style/AnotherWidget.Main.Button"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
@ -354,18 +418,18 @@
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:id="@+id/action_rate"
android:id="@+id/action_refresh"
android:orientation="vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="2dp"
android:layout_marginTop="8dp"
android:src="@drawable/ic_action_rate"/>
android:src="@drawable/ic_action_refresh"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/action_rate"
android:text="@string/action_refresh_widget"
style="@style/AnotherWidget.Main.Button.TabBar"
android:background="@android:color/transparent"/>
</LinearLayout>

View File

@ -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"/>

View File

@ -16,6 +16,7 @@
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:text="@string/loading_text"
style="@style/AnotherWidget.Title" />
<LinearLayout
android:orientation="horizontal"

View File

@ -48,4 +48,24 @@
<string name="settings_weather_refresh_period_subtitle_5">24 Ore</string>
<string name="settings_custom_location_title">Località Meteo</string>
<string name="custom_location_gps">Geolocalizzazione</string>
<string name="action_refresh_widget">Aggiorna</string>
<string name="show_events_visible">Eventi Visibili</string>
<string name="show_events_not_visible">Eventi non Visibili</string>
<string name="show_weather_visible">Meteo Visibile</string>
<string name="show_weather_not_visible">Meteo non Visibile</string>
<string name="settings_show_until_subtitle_0">3 Ore dopo</string>
<string name="settings_show_until_subtitle_1">6 Ore dopo</string>
<string name="settings_show_until_subtitle_2">12 Ore dopo</string>
<string name="settings_show_until_subtitle_3">24 Ore dopo</string>
<string name="settings_show_until_subtitle_4">3 Giorni dopo</string>
<string name="settings_show_until_subtitle_5">7 Giorni dopo</string>
<string name="settings_show_until_title">Vedi eventi al massimo fino a</string>
<string name="day_char">g</string>
<string name="error_opening_uri">Errore apertura URL: Link copiato negli appunti.</string>
<string name="loading_text">Caricamento...</string>
<string name="error_opening_app">Errore apertura App.</string>
<string name="settings_calendar_app_title">La data apre</string>
<string name="settings_weather_app_title">Il meteo apre</string>
<string name="default_name">App Predefinita</string>
<string name="action_choose_application">Scegli Applicazione</string>
</resources>

View File

@ -49,4 +49,25 @@
<string name="settings_weather_refresh_period_subtitle_5">24 Hours</string>
<string name="settings_custom_location_title">Custom Location</string>
<string name="custom_location_gps">Geolocation</string>
<string name="action_refresh_widget">Refresh</string>
<string name="show_events_visible">Events are Visible</string>
<string name="show_events_not_visible">Events are not Visible</string>
<string name="show_weather_visible">Weather Info are Visible</string>
<string name="show_weather_not_visible">Weather Info are not Visible</string>
<string name="settings_show_until_subtitle_0">3 Hours later</string>
<string name="settings_show_until_subtitle_1">6 Hours later</string>
<string name="settings_show_until_subtitle_2">12 Hours later</string>
<string name="settings_show_until_subtitle_3">24 Hours later</string>
<string name="settings_show_until_subtitle_4">3 Days later</string>
<string name="settings_show_until_subtitle_5">7 Days later</string>
<string name="settings_show_until_title">See events at most until</string>
<string name="day_char">d</string>
<string name="toolbar_transition_name" translatable="false">toolbar</string>
<string name="error_opening_uri">Error opening URL: Link copied to clipboard.</string>
<string name="loading_text">Loading Data...</string>
<string name="error_opening_app">Error opening App.</string>
<string name="settings_calendar_app_title">Tap on date opens</string>
<string name="settings_weather_app_title">Tap on weather opens</string>
<string name="default_name">Default App</string>
<string name="action_choose_application">Choose Application</string>
</resources>

View File

@ -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"

View File

@ -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.+'