Bug fixes, move clock format settings, fix network provider for weather updates and add notification when location is turned off with google awareness as provider

This commit is contained in:
Tommaso Berlose
2017-11-09 18:15:52 +01:00
parent 0a289d82b2
commit 2757f7f66f
16 changed files with 170 additions and 100 deletions

View File

@ -211,6 +211,10 @@ class MainActivity : AppCompatActivity() {
if (SP.getBoolean(Constants.PREF_SHOW_WIDGET_PREVIEW, true)) {
val displayMetrics = Resources.getSystem().displayMetrics
var width = displayMetrics.widthPixels
if (width <= 0) {
width = Util.convertDpToPixel(300f, this).toInt()
}
var height = Util.convertDpToPixel(120f, this).toInt()
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
height += Util.convertSpToPixels(SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f), this).toInt() + Util.convertDpToPixel(8f, this).toInt()
@ -218,7 +222,7 @@ class MainActivity : AppCompatActivity() {
if (SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) + SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) > 50) {
height += Util.convertDpToPixel(24f, this).toInt()
}
widget_bitmap.setImageBitmap(Util.getBitmapFromView(main_layout, displayMetrics.widthPixels, height - Util.convertDpToPixel(32f, this).toInt()))
widget_bitmap.setImageBitmap(Util.getBitmapFromView(main_layout, width, height - Util.convertDpToPixel(32f, this).toInt()))
widget.layoutParams.height = height + Util.convertDpToPixel(16f, this).toInt()
widget.visibility = View.VISIBLE
@ -649,7 +653,7 @@ class MainActivity : AppCompatActivity() {
action_clock_text_size.setOnClickListener {
var fontSize = SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f) + 5
if (fontSize > 110) {
fontSize = 70f
fontSize = 50f
}
SP.edit().putFloat(Constants.PREF_TEXT_CLOCK_SIZE, fontSize).commit()
Util.updateWidget(this)
@ -688,25 +692,19 @@ class MainActivity : AppCompatActivity() {
updateSettings()
}
if (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) == Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) {
action_weather_refresh_period.visibility = View.GONE
} else {
label_weather_refresh_period.text = getString(Util.getRefreshPeriodString(SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1)))
action_weather_refresh_period.setOnClickListener {
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)
}
action_weather_refresh_period.visibility = View.VISIBLE
label_weather_refresh_period.text = getString(Util.getRefreshPeriodString(SP.getInt(Constants.PREF_WEATHER_REFRESH_PERIOD, 1)))
action_weather_refresh_period.setOnClickListener {
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)
}
show_until_label.text = getString(Util.getShowUntilString(SP.getInt(Constants.PREF_SHOW_UNTIL, 1)))

View File

@ -12,7 +12,7 @@ import com.tommasoberlose.anotherwidget.util.Util
import kotlinx.android.synthetic.main.activity_support_dev.*
class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler {
internal var bp: BillingProcessor? = null
internal lateinit var bp: BillingProcessor
internal val BILLING_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAox5CcxuoLJ6CmNS7s6lVQzJ253njKKGF8MoQ/gQ5gEw2Fr03fBvtHpiVMpnjhNLw5NMeIpzRvkVqeQ7BfkC7c0BLCJUqf/fFA11ArQe8na6QKt5O4d+v4sbHtP7mm3GQNPOBaqRzcpFZaiAbfk6mnalo+tzM47GXrQFt5bNSrMctCs7bbChqJfH2cyMW0F8DHWEEeO5xElBmH3lh4FVpwIUTPYJIV3n0yhE3qqRA0WXkDej66g/uAt/rebmMZLmwNwIive5cObU4o41YyKRv2wSAicrv3W40LftzXAOOordIbmzDFN8ksh3VrnESqwCDGG97nZVbPG/+3LD0xHWiRwIDAQAB"
@ -34,18 +34,18 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
loader.visibility = View.GONE
try {
val isAvailable = BillingProcessor.isIabServiceAvailable(this)
val isOneTimePurchaseSupported = bp!!.isOneTimePurchaseSupported
val isOneTimePurchaseSupported = bp.isOneTimePurchaseSupported
if (isAvailable && isOneTimePurchaseSupported) {
val coffee = bp!!.getPurchaseListingDetails("donation_coffee")
val donuts = bp!!.getPurchaseListingDetails("donation_donuts")
val breakfast = bp!!.getPurchaseListingDetails("donation_breakfast")
val lunch = bp!!.getPurchaseListingDetails("donation_lunch")
val dinner = bp!!.getPurchaseListingDetails("donation_dinner")
val coffee = bp.getPurchaseListingDetails("donation_coffee")
val donuts = bp.getPurchaseListingDetails("donation_donuts")
val breakfast = bp.getPurchaseListingDetails("donation_breakfast")
val lunch = bp.getPurchaseListingDetails("donation_lunch")
val dinner = bp.getPurchaseListingDetails("donation_dinner")
if (coffee != null) {
import_donation_coffee.text = coffee.priceText
action_donation_coffee.setOnClickListener {
bp!!.purchase(this, "donation_coffee")
bp.purchase(this, "donation_coffee")
}
} else {
action_donation_coffee.visibility = View.GONE
@ -54,7 +54,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
if (donuts != null) {
import_donation_donuts.text = donuts.priceText
action_donation_donuts.setOnClickListener {
bp!!.purchase(this, "donation_donuts")
bp.purchase(this, "donation_donuts")
}
} else {
action_donation_donuts.visibility = View.GONE
@ -63,7 +63,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
if (breakfast != null) {
import_donation_breakfast.text = breakfast.priceText
action_donation_breakfast.setOnClickListener {
bp!!.purchase(this, "donation_breakfast")
bp.purchase(this, "donation_breakfast")
}
} else {
action_donation_breakfast.visibility = View.GONE
@ -72,7 +72,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
if (lunch != null) {
import_donation_lunch.text = lunch.priceText
action_donation_lunch.setOnClickListener {
bp!!.purchase(this, "donation_lunch")
bp.purchase(this, "donation_lunch")
}
} else {
action_donation_lunch.visibility = View.GONE
@ -81,7 +81,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
if (dinner != null) {
import_donation_dinner.text = dinner.priceText
action_donation_dinner.setOnClickListener {
bp!!.purchase(this, "donation_dinner")
bp.purchase(this, "donation_dinner")
}
} else {
action_donation_dinner.visibility = View.GONE
@ -101,7 +101,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
override fun onProductPurchased(productId: String, details: TransactionDetails?) {
Toast.makeText(this, R.string.thanks, Toast.LENGTH_SHORT).show()
bp!!.consumePurchase(productId)
bp.consumePurchase(productId)
}
override fun onBillingError(errorCode: Int, error: Throwable?) {
@ -109,15 +109,13 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
if (!bp!!.handleActivityResult(requestCode, resultCode, data)) {
if (!bp.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data)
}
}
public override fun onDestroy() {
if (bp != null) {
bp!!.release()
}
bp.release()
super.onDestroy()
}
}

View File

@ -73,7 +73,6 @@ class TheWidget : AppWidgetProvider() {
override fun onEnabled(context: Context) {
UpdatesReceiver().setUpdates(context)
WeatherReceiver().setUpdates(context)
Util.showNotification(context)
}
override fun onDisabled(context: Context) {