Add Weather Provider Dialog
This commit is contained in:
parent
4e7fd95fcf
commit
42dbe7e235
@ -15,7 +15,7 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 12
|
versionCode 14
|
||||||
versionName "1.1"
|
versionName "1.1"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":12},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":14},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
|
@ -48,6 +48,16 @@ class WeatherReceiver : BroadcastReceiver() {
|
|||||||
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 * refresh, pi)
|
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) {
|
fun removeUpdates(context: Context) {
|
||||||
val intent = Intent(context, WeatherReceiver::class.java)
|
val intent = Intent(context, WeatherReceiver::class.java)
|
||||||
val sender = PendingIntent.getBroadcast(context, 1, intent, 0)
|
val sender = PendingIntent.getBroadcast(context, 1, intent, 0)
|
||||||
|
@ -24,13 +24,16 @@ import com.tommasoberlose.anotherwidget.util.CalendarUtil
|
|||||||
import com.tommasoberlose.anotherwidget.util.WeatherUtil
|
import com.tommasoberlose.anotherwidget.util.WeatherUtil
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Build
|
||||||
import android.support.design.widget.BottomSheetDialog
|
import android.support.design.widget.BottomSheetDialog
|
||||||
|
import android.text.Html
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.crashlytics.android.Crashlytics
|
import com.crashlytics.android.Crashlytics
|
||||||
import com.tommasoberlose.anotherwidget.`object`.CalendarSelector
|
import com.tommasoberlose.anotherwidget.`object`.CalendarSelector
|
||||||
import io.fabric.sdk.android.Fabric
|
import io.fabric.sdk.android.Fabric
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
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.main_menu_layout.view.*
|
||||||
import kotlinx.android.synthetic.main.the_widget.*
|
import kotlinx.android.synthetic.main.the_widget.*
|
||||||
|
|
||||||
@ -196,8 +199,23 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Util.updateWidget(this)
|
Util.updateWidget(this)
|
||||||
updateSettings()
|
updateSettings()
|
||||||
} else if (requestCode == Constants.WEATHER_PROVIDER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
} else if (requestCode == Constants.WEATHER_PROVIDER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
||||||
|
WeatherReceiver().setOneTimeUpdate(this)
|
||||||
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
|
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
|
||||||
updateSettings()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,4 +356,8 @@ object Util {
|
|||||||
v.startAnimation(a)
|
v.startAnimation(a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getEmojiByUnicode(unicode: Int): String {
|
||||||
|
return String(Character.toChars(unicode))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
44
app/src/main/res/layout/key_time_wait_layout.xml
Normal file
44
app/src/main/res/layout/key_time_wait_layout.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start"
|
||||||
|
android:id="@+id/title"
|
||||||
|
style="@style/AnotherWidget.Main.Title"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="@android:color/primary_text_light"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/primary_text_light"
|
||||||
|
style="@style/AnotherWidget.Main.Subtitle"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:id="@+id/text"/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_gravity="end">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/colorAccent"
|
||||||
|
style="@style/AnotherWidget.Settings.Title"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:id="@+id/action_close"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:text="@android:string/ok"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@ -92,4 +92,6 @@
|
|||||||
<string name="api_key_title_3">Configura l\'App</string>
|
<string name="api_key_title_3">Configura l\'App</string>
|
||||||
<string name="api_key_info_start">Ciao a tutti.</string>
|
<string name="api_key_info_start">Ciao a tutti.</string>
|
||||||
<string name="api_key_info_text"><![CDATA[Another widget è e rimarrà gratuita e senza banner pubblicitari.<BR /><BR />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).<BR /><BR />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!<BR /><BR />Mi dispiace per l\'inconveniente ma continuate a supportarmi!!]]></string>
|
<string name="api_key_info_text"><![CDATA[Another widget è e rimarrà gratuita e senza banner pubblicitari.<BR /><BR />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).<BR /><BR />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!<BR /><BR />Mi dispiace per l\'inconveniente ma continuate a supportarmi!!]]></string>
|
||||||
|
<string name="well_done">Ben Fatto!</string>
|
||||||
|
<string name="api_key_info_all_set"><![CDATA[Posso essere necessari fino a <b>dieci minuti</b> prima che la tua chiave sia attivata.<BR /><BR />Quindi <i>rilassati</i>! Il meteo verrà aggiornato non appena sarà disponibile!]]></string>
|
||||||
</resources>
|
</resources>
|
@ -94,4 +94,6 @@
|
|||||||
<string name="api_key_subtitle_3">Enter the key in this section and save it. Once the key is activated the weather will be visible.</string>
|
<string name="api_key_subtitle_3">Enter the key in this section and save it. Once the key is activated the weather will be visible.</string>
|
||||||
<string name="api_key_info_start">Hi Everyone!</string>
|
<string name="api_key_info_start">Hi Everyone!</string>
|
||||||
<string name="action_open_provider">Go to OpenWeather.com</string>
|
<string name="action_open_provider">Go to OpenWeather.com</string>
|
||||||
|
<string name="api_key_info_all_set"><![CDATA[It may take up to <b>ten minutes</b> before your API key is activated.<BR /><BR />So <i>relax</i>! The weather will be updated as soon as it is available!!]]></string>
|
||||||
|
<string name="well_done">Well Done!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user