diff --git a/app/build.gradle b/app/build.gradle
index 74b413b..7ff6c26 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -15,7 +15,7 @@ android {
applicationId "com.tommasoberlose.anotherwidget"
minSdkVersion 19
targetSdkVersion 26
- versionCode 12
+ versionCode 14
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
diff --git a/app/release/output.json b/app/release/output.json
index a4ed11c..647a792 100644
--- a/app/release/output.json
+++ b/app/release/output.json
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":12},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":14},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
\ No newline at end of file
diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/WeatherReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/WeatherReceiver.kt
index 19e2eb0..713f1e5 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/WeatherReceiver.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receiver/WeatherReceiver.kt
@@ -48,6 +48,16 @@ class WeatherReceiver : BroadcastReceiver() {
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 * refresh, pi)
}
+ fun setOneTimeUpdate(context: Context) {
+ val am = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
+ val i = Intent(context, WeatherReceiver::class.java)
+ i.action = Constants.ACTION_WEATHER_UPDATE
+ val pi = PendingIntent.getBroadcast(context, 1, i, 0)
+ am.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000 * 60 * 10, pi)
+ am.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000 * 60 * 15, pi)
+ am.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000 * 60 * 20, pi)
+ }
+
fun removeUpdates(context: Context) {
val intent = Intent(context, WeatherReceiver::class.java)
val sender = PendingIntent.getBroadcast(context, 1, intent, 0)
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 d17dbee..4eb17a8 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
@@ -24,13 +24,16 @@ import com.tommasoberlose.anotherwidget.util.CalendarUtil
import com.tommasoberlose.anotherwidget.util.WeatherUtil
import android.content.DialogInterface
import android.graphics.drawable.Drawable
+import android.os.Build
import android.support.design.widget.BottomSheetDialog
+import android.text.Html
import android.util.Log
import android.widget.Toast
import com.crashlytics.android.Crashlytics
import com.tommasoberlose.anotherwidget.`object`.CalendarSelector
import io.fabric.sdk.android.Fabric
import kotlinx.android.synthetic.main.activity_main.*
+import kotlinx.android.synthetic.main.key_time_wait_layout.view.*
import kotlinx.android.synthetic.main.main_menu_layout.view.*
import kotlinx.android.synthetic.main.the_widget.*
@@ -196,8 +199,23 @@ class MainActivity : AppCompatActivity() {
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))
updateSettings()
+
+ val mBottomSheetDialog: BottomSheetDialog = BottomSheetDialog(this)
+ val provView: View = layoutInflater.inflate(R.layout.key_time_wait_layout, null)
+ provView.title.text = String.format("%s %s", Util.getEmojiByUnicode(0x1F389), getString(R.string.well_done))
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ provView.text.text = Html.fromHtml(getString(R.string.api_key_info_all_set), Html.FROM_HTML_MODE_LEGACY)
+ } else {
+ provView.text.text = Html.fromHtml(getString(R.string.api_key_info_all_set))
+ }
+ provView.action_close.setOnClickListener {
+ mBottomSheetDialog.dismiss()
+ }
+ mBottomSheetDialog.setContentView(provView)
+ mBottomSheetDialog.show();
}
}
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 d7b247d..75326ab 100644
--- a/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt
+++ b/app/src/main/java/com/tommasoberlose/anotherwidget/util/Util.kt
@@ -356,4 +356,8 @@ object Util {
v.startAnimation(a)
}
}
+
+ fun getEmojiByUnicode(unicode: Int): String {
+ return String(Character.toChars(unicode))
+ }
}
diff --git a/app/src/main/res/layout/key_time_wait_layout.xml b/app/src/main/res/layout/key_time_wait_layout.xml
new file mode 100644
index 0000000..9a84147
--- /dev/null
+++ b/app/src/main/res/layout/key_time_wait_layout.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml
index d2c3dc0..9305749 100644
--- a/app/src/main/res/values-it-rIT/strings.xml
+++ b/app/src/main/res/values-it-rIT/strings.xml
@@ -92,4 +92,6 @@
Configura l\'App
Ciao a tutti.
Però a causa del successo dell\'applicazione, sicuramente oltre ogni mia aspettativa, il provider del meteo non riesce a supportare il numero di richieste che arrivano (a causa dell\'utilizzo di un account gratuito).
Sono costretto a chiedervi di registrarvi su OpenWeather.com; l\'operazione richiederà solo alcuni minuti e dopo non avrete più problemi con la fruizione delle informazioni sul meteo!
Mi dispiace per l\'inconveniente ma continuate a supportarmi!!]]>
+ Ben Fatto!
+ dieci minuti prima che la tua chiave sia attivata.
Quindi rilassati! Il meteo verrà aggiornato non appena sarà disponibile!]]>
\ 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 917f43a..0e3833f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -94,4 +94,6 @@
Enter the key in this section and save it. Once the key is activated the weather will be visible.
Hi Everyone!
Go to OpenWeather.com
+ ten minutes before your API key is activated.
So relax! The weather will be updated as soon as it is available!!]]>
+ Well Done!