Bug fixes, Start supporting google awareness API
This commit is contained in:
@ -198,6 +198,13 @@ class MainActivity : AppCompatActivity() {
|
||||
.commit()
|
||||
Util.updateWidget(this)
|
||||
updateSettings()
|
||||
} else if (requestCode == Constants.EVENT_APP_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
|
||||
SP.edit()
|
||||
.putString(Constants.PREF_EVENT_APP_NAME, data.getStringExtra(Constants.RESULT_APP_NAME))
|
||||
.putString(Constants.PREF_EVENT_APP_PACKAGE, data.getStringExtra(Constants.RESULT_APP_PACKAGE))
|
||||
.commit()
|
||||
Util.updateWidget(this)
|
||||
updateSettings()
|
||||
} else if (requestCode == Constants.WEATHER_PROVIDER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
||||
WeatherReceiver().setOneTimeUpdate(this)
|
||||
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
|
||||
@ -237,25 +244,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val e = CalendarUtil.getNextEvent(this)
|
||||
|
||||
if (e.id != 0) {
|
||||
val difference = e.startDate - now.timeInMillis
|
||||
|
||||
|
||||
|
||||
if (difference > 1000 * 60) {
|
||||
var time = ""
|
||||
val hour = TimeUnit.MILLISECONDS.toHours(difference)
|
||||
if (hour > 0) {
|
||||
time = hour.toString() + getString(R.string.h_code) + " "
|
||||
}
|
||||
val minutes = TimeUnit.MILLISECONDS.toMinutes(difference - hour * 3600 * 1000)
|
||||
if (minutes > 0) {
|
||||
time += "" + minutes + getString(R.string.min_code)
|
||||
}
|
||||
|
||||
next_event.text = String.format("%s %s %s", e.title, getString(R.string.in_code), time)
|
||||
} else {
|
||||
next_event.text = String.format("%s", e.title)
|
||||
}
|
||||
next_event.text = Util.getDifferenceText(this, e.title, now.timeInMillis, e.startDate)
|
||||
|
||||
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)
|
||||
@ -268,7 +257,9 @@ class MainActivity : AppCompatActivity() {
|
||||
val endCal = Calendar.getInstance()
|
||||
endCal.timeInMillis = e.endDate
|
||||
|
||||
if (startCal.get(Calendar.HOUR_OF_DAY) >= endCal.get(Calendar.HOUR_OF_DAY)) {
|
||||
if (startCal.get(Calendar.HOUR_OF_DAY) > endCal.get(Calendar.HOUR_OF_DAY)) {
|
||||
dayDiff++
|
||||
} else if (startCal.get(Calendar.HOUR_OF_DAY) == endCal.get(Calendar.HOUR_OF_DAY) && startCal.get(Calendar.MINUTE) >= endCal.get(Calendar.MINUTE)) {
|
||||
dayDiff++
|
||||
}
|
||||
var multipleDay: String = ""
|
||||
@ -455,6 +446,11 @@ class MainActivity : AppCompatActivity() {
|
||||
startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.WEATHER_APP_REQUEST_CODE)
|
||||
}
|
||||
|
||||
event_app_label.text = SP.getString(Constants.PREF_EVENT_APP_NAME, getString(R.string.default_name))
|
||||
action_event_app.setOnClickListener {
|
||||
startActivityForResult(Intent(this, ChooseApplicationActivity::class.java), Constants.EVENT_APP_REQUEST_CODE)
|
||||
}
|
||||
|
||||
if (!SP.getString(Constants.PREF_WEATHER_PROVIDER_API_KEY, "").equals("")) {
|
||||
label_weather_provider_api_key.text = getString(R.string.settings_weather_provider_api_key_subtitle_all_set)
|
||||
alert_icon.visibility = View.GONE
|
||||
|
@ -34,7 +34,9 @@ class WeatherProviderActivity : AppCompatActivity() {
|
||||
val SP = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
action_paste.setOnClickListener {
|
||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
api_key.setText(clipboard.primaryClip.getItemAt(0).text)
|
||||
if (clipboard.primaryClip != null && clipboard.primaryClip.itemCount > 0) {
|
||||
api_key.setText(clipboard.primaryClip.getItemAt(0).text)
|
||||
}
|
||||
}
|
||||
|
||||
Util.collapse(button_container)
|
||||
|
@ -96,23 +96,7 @@ class TheWidget : AppWidgetProvider() {
|
||||
val e = CalendarUtil.getNextEvent(context)
|
||||
|
||||
if (e.id != 0) {
|
||||
val difference = e.startDate - now.timeInMillis
|
||||
|
||||
if (difference > 1000 * 60) {
|
||||
var time = ""
|
||||
val hour = TimeUnit.MILLISECONDS.toHours(difference)
|
||||
if (hour > 0) {
|
||||
time = hour.toString() + context.getString(R.string.h_code) + " "
|
||||
}
|
||||
val minutes = TimeUnit.MILLISECONDS.toMinutes(difference - hour * 3600 * 1000)
|
||||
if (minutes > 0) {
|
||||
time += "" + minutes + context.getString(R.string.min_code)
|
||||
}
|
||||
|
||||
views.setTextViewText(R.id.next_event, String.format("%s %s %s", e.title, context.getString(R.string.in_code), time))
|
||||
} else {
|
||||
views.setTextViewText(R.id.next_event, String.format("%s", e.title))
|
||||
}
|
||||
views.setTextViewText(R.id.next_event, Util.getDifferenceText(context, e.title, now.timeInMillis, e.startDate))
|
||||
|
||||
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)
|
||||
@ -125,7 +109,9 @@ class TheWidget : AppWidgetProvider() {
|
||||
val endCal = Calendar.getInstance()
|
||||
endCal.timeInMillis = e.endDate
|
||||
|
||||
if (startCal.get(Calendar.HOUR_OF_DAY) >= endCal.get(Calendar.HOUR_OF_DAY)) {
|
||||
if (startCal.get(Calendar.HOUR_OF_DAY) > endCal.get(Calendar.HOUR_OF_DAY)) {
|
||||
dayDiff++
|
||||
} else if (startCal.get(Calendar.HOUR_OF_DAY) == endCal.get(Calendar.HOUR_OF_DAY) && startCal.get(Calendar.MINUTE) >= endCal.get(Calendar.MINUTE)) {
|
||||
dayDiff++
|
||||
}
|
||||
|
||||
@ -143,12 +129,8 @@ class TheWidget : AppWidgetProvider() {
|
||||
views.setViewVisibility(R.id.calendar_layout, View.VISIBLE)
|
||||
|
||||
|
||||
val uri = ContentUris.withAppendedId(Events.CONTENT_URI, e.id.toLong())
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
.setData(uri)
|
||||
intent.putExtra("beginTime", e.startDate);
|
||||
intent.putExtra("endTime", e.endDate);
|
||||
val pIntent = PendingIntent.getActivity(context, widgetID, intent, 0)
|
||||
|
||||
val pIntent = PendingIntent.getActivity(context, widgetID, Util.getEventIntent(context, e), 0)
|
||||
views.setOnClickPendingIntent(R.id.main_layout, pIntent)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user