This commit is contained in:
Tommaso Berlose
2018-08-03 10:52:18 +02:00
parent 6d297911ee
commit 05a0308f8f
29 changed files with 211 additions and 119 deletions

View File

@ -27,6 +27,7 @@ import android.content.res.Resources
import android.graphics.Color
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.support.design.widget.BottomSheetDialog
import android.support.v4.content.ContextCompat
@ -47,11 +48,13 @@ 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.*
import kotlinx.android.synthetic.main.the_widget.view.*
import java.io.File
class MainActivity : AppCompatActivity() {
private var mAppWidgetId: Int = -1
private lateinit var SP: SharedPreferences
private val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
@ -67,31 +70,12 @@ class MainActivity : AppCompatActivity() {
sendBroadcast(Intent(Constants.ACTION_CALENDAR_UPDATE))
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
val SP = PreferenceManager.getDefaultSharedPreferences(this)
if (intent.extras?.containsKey(Constants.ACTION_EXTRA_OPEN_WEATHER_PROVIDER) == true) {
startActivityForResult(Intent(this, WeatherProviderActivity::class.java), Constants.WEATHER_PROVIDER_REQUEST_CODE)
}
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_add_widget.visibility = View.VISIBLE
action_add_widget.setOnClickListener {
addNewWidget()
}
}
}
SP = PreferenceManager.getDefaultSharedPreferences(this)
controlExtras(intent)
action_menu.setOnClickListener {
val mBottomSheetDialog: BottomSheetDialog = BottomSheetDialog(this)
val mBottomSheetDialog = BottomSheetDialog(this)
val menuView: View = getLayoutInflater().inflate(R.layout.main_menu_layout, null)
menuView.action_share.setOnClickListener(object: View.OnClickListener {
@ -150,7 +134,7 @@ class MainActivity : AppCompatActivity() {
}
mBottomSheetDialog.setContentView(menuView)
mBottomSheetDialog.show();
mBottomSheetDialog.show()
}
}
@ -163,6 +147,43 @@ class MainActivity : AppCompatActivity() {
}
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
if (intent != null) {
controlExtras(intent)
}
}
fun controlExtras(intent: Intent) {
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_add_widget.visibility = View.VISIBLE
action_add_widget.setOnClickListener {
addNewWidget()
}
}
if (extras.containsKey(Constants.ACTION_EXTRA_OPEN_WEATHER_PROVIDER)) {
startActivityForResult(Intent(this, WeatherProviderActivity::class.java), Constants.WEATHER_PROVIDER_REQUEST_CODE)
}
if (extras.containsKey(Constants.ACTION_EXTRA_DISABLE_GPS_NOTIFICATION)) {
SP.edit()
.putBoolean(Constants.PREF_SHOW_GPS_NOTIFICATION, false)
.apply()
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
finish()
}
}
}
fun addNewWidget() {
val resultValue = Intent()
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId)
@ -207,8 +228,6 @@ class MainActivity : AppCompatActivity() {
updateAppWidget()
updateClockView()
val SP = PreferenceManager.getDefaultSharedPreferences(this)
if (SP.getBoolean(Constants.PREF_SHOW_WIDGET_PREVIEW, true)) {
val displayMetrics = Resources.getSystem().displayMetrics
var width = displayMetrics.widthPixels
@ -245,7 +264,6 @@ class MainActivity : AppCompatActivity() {
@SuppressLint("ApplySharedPref")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
if (requestCode == Constants.RESULT_CODE_CUSTOM_LOCATION && resultCode == Activity.RESULT_OK) {
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
updateSettings()
@ -281,11 +299,20 @@ class MainActivity : AppCompatActivity() {
WeatherReceiver().setOneTimeUpdate(this)
sendBroadcast(Intent(Constants.ACTION_WEATHER_UPDATE))
updateSettings()
} else if (requestCode == Constants.CUSTOM_FONT_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
/*val uri = data.data
Log.d("AW", "File Uri: " + uri.toString())
val path = Util.getPath(this, uri)
Log.d("AW", "File Path: " + path)
SP.edit()
.putString(Constants.PREF_CUSTOM_FONT_FILE, path)
.commit()
sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
updateSettings()*/
}
}
fun updateClockView() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
if (!SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
time.visibility = View.GONE
} else {
@ -293,18 +320,19 @@ class MainActivity : AppCompatActivity() {
}
val now = Calendar.getInstance()
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12") == "12") {
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis))
textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
textBadHour.length, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
time.text = textBadHour
// time.format12Hour = "hh:mm a"
// val textBadHour = SpannableString(Constants.badHourFormat.format(time.))
// textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
// textBadHour.length, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
//
// time.text = textBadHour
} else {
time.text = Constants.goodHourFormat.format(now.timeInMillis)
// time.format24Hour = "HH:mm"
// time.text = Constants.goodHourFormat.format(now.timeInMillis)
}
}
fun updateCalendarView() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
val now = Calendar.getInstance()
val calendarLayout = SP.getBoolean(Constants.PREF_SHOW_EVENTS, true) && Util.checkGrantedPermission(this, Manifest.permission.READ_CALENDAR)
@ -384,7 +412,7 @@ class MainActivity : AppCompatActivity() {
divider2.setTextColor(Util.getFontColor(SP))
calendar_temp.setTextColor(Util.getFontColor(SP))
second_row_icon.setColorFilter(Util.getFontColor(SP))
time.setTextColor(Util.getFontColor(SP))
// time.setTextColor(Util.getFontColor(SP))
empty_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f))
@ -395,7 +423,7 @@ class MainActivity : AppCompatActivity() {
next_event_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
divider2.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
calendar_temp.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
time.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
// time.setTextSize(TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
@ -435,10 +463,20 @@ class MainActivity : AppCompatActivity() {
next_event_date.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor)
divider2.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor)
calendar_temp.setShadowLayer(shadowRadius, 0f, 0f, shadowColor)
time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor)
// time.setShadowLayer(shadowRadius, 0f, shadowDy, shadowColor)
if (SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS) == Constants.CUSTOM_FONT_PRODUCT_SANS) {
val product_sans: Typeface = Typeface.createFromAsset(assets, "fonts/product_sans_regular.ttf")
val product_sans_light: Typeface = Typeface.createFromAsset(assets, "fonts/product_sans_light.ttf")
/*if (SP.getString(Constants.PREF_CUSTOM_FONT_FILE, "") != "") {
val file = File(SP.getString(Constants.PREF_CUSTOM_FONT_FILE, ""))
if (file.exists()) {
Log.d("AW", "OK")
}
// product_sans = Typeface.createFromFile("")
}*/
empty_date.typeface = product_sans
divider1.typeface = product_sans
temp.typeface = product_sans
@ -447,7 +485,7 @@ class MainActivity : AppCompatActivity() {
next_event_date.typeface = product_sans
divider2.typeface = product_sans
calendar_temp.typeface = product_sans
time.typeface = product_sans
//time.typeface = product_sans_light
} else {
empty_date.typeface = Typeface.DEFAULT
divider1.typeface = Typeface.DEFAULT
@ -457,12 +495,11 @@ class MainActivity : AppCompatActivity() {
next_event_date.typeface = Typeface.DEFAULT
divider2.typeface = Typeface.DEFAULT
calendar_temp.typeface = Typeface.DEFAULT
time.typeface = Typeface.DEFAULT
//time.typeface = Typeface.DEFAULT
}
}
fun updateLocationView() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
val locationLayout = SP.getBoolean(Constants.PREF_SHOW_WEATHER, true)
if (locationLayout && SP.contains(Constants.PREF_WEATHER_TEMP) && SP.contains(Constants.PREF_WEATHER_ICON)) {
@ -492,7 +529,6 @@ class MainActivity : AppCompatActivity() {
@SuppressLint("ApplySharedPref")
fun updateSettings() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
clock_settings.visibility = View.VISIBLE
@ -739,11 +775,24 @@ class MainActivity : AppCompatActivity() {
custom_font_label.text = getString(Util.getCustomFontLabel(SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS)))
action_custom_font.setOnClickListener {
SP.edit().putInt(Constants.PREF_CUSTOM_FONT, when (SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS)) {
0 -> Constants.CUSTOM_FONT_PRODUCT_SANS
Constants.CUSTOM_FONT_PRODUCT_SANS -> 0
else -> Constants.CUSTOM_FONT_PRODUCT_SANS
}).commit()
/*
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "* / *" TO FIX WITHOUT SPACE
intent.addCategory(Intent.CATEGORY_OPENABLE)
try {
startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), Constants.CUSTOM_FONT_CHOOSER_REQUEST_CODE)
} catch (ex: android.content.ActivityNotFoundException) {
Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show()
}
*/
sendBroadcast(Intent(Constants.ACTION_TIME_UPDATE))
updateSettings()
updateAppWidget()
@ -763,10 +812,7 @@ class MainActivity : AppCompatActivity() {
label_weather_provider_api_key.text = getString(R.string.provider_google_awareness)
alert_icon.visibility = View.GONE
} else {
if (SP.getString(when (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS)) {
Constants.WEATHER_PROVIDER_OPEN_WEATHER -> Constants.PREF_OPEN_WEATHER_API_KEY
else -> Constants.PREF_OPEN_WEATHER_API_KEY
}, "") == ("")) {
if (WeatherUtil.getWeatherProviderKey(this, SP) == ("")) {
label_weather_provider_api_key.text = getString(R.string.settings_weather_provider_api_key_subtitle_not_set)
alert_icon.visibility = View.VISIBLE
} else {

View File

@ -108,7 +108,7 @@ class SupportDevActivity : AppCompatActivity(), BillingProcessor.IBillingHandler
Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (!bp.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data)
}

View File

@ -41,10 +41,7 @@ class WeatherProviderActivity : AppCompatActivity() {
action_save.setOnClickListener {
SP.edit()
.putString(when (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS)) {
Constants.WEATHER_PROVIDER_OPEN_WEATHER -> Constants.PREF_OPEN_WEATHER_API_KEY
else -> Constants.PREF_OPEN_WEATHER_API_KEY
}, api_key.text.toString())
.putString(WeatherUtil.getWeatherProviderKeyConstant(this, SP), api_key.text.toString())
.commit()
setResult(Activity.RESULT_OK)
finish()
@ -53,10 +50,7 @@ class WeatherProviderActivity : AppCompatActivity() {
api_key.addTextChangedListener(object: TextWatcher {
override fun afterTextChanged(text: Editable?) {
if (text.toString().equals("") || text.toString().equals(
SP.getString(when (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS)) {
Constants.WEATHER_PROVIDER_OPEN_WEATHER -> Constants.PREF_OPEN_WEATHER_API_KEY
else -> Constants.PREF_OPEN_WEATHER_API_KEY
}, ""))) {
WeatherUtil.getWeatherProviderKey(this@WeatherProviderActivity, SP))) {
Util.collapse(button_container)
} else {
Util.expand(button_container)
@ -105,18 +99,12 @@ class WeatherProviderActivity : AppCompatActivity() {
}
Util.collapse(button_container)
api_key.setText(SP.getString(when (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS)) {
Constants.WEATHER_PROVIDER_OPEN_WEATHER -> Constants.PREF_OPEN_WEATHER_API_KEY
else -> Constants.PREF_OPEN_WEATHER_API_KEY
}, ""))
api_key.setText(WeatherUtil.getWeatherProviderKey(this, SP))
}
override fun onBackPressed() {
val SP = PreferenceManager.getDefaultSharedPreferences(this)
if (!SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS).equals(Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) && (api_key.text.toString().equals("") || !api_key.text.toString().equals(SP.getString(when (SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS)) {
Constants.WEATHER_PROVIDER_OPEN_WEATHER -> Constants.PREF_OPEN_WEATHER_API_KEY
else -> Constants.PREF_OPEN_WEATHER_API_KEY
}, "")))) {
if (!SP.getInt(Constants.PREF_WEATHER_PROVIDER, Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS).equals(Constants.WEATHER_PROVIDER_GOOGLE_AWARENESS) && (api_key.text.toString().equals("") || !api_key.text.toString().equals(WeatherUtil.getWeatherProviderKey(this, SP)))) {
AlertDialog.Builder(this)
.setMessage(getString(R.string.error_weather_api_key))
.setNegativeButton(android.R.string.cancel, null)

View File

@ -86,12 +86,8 @@ class TheWidget : AppWidgetProvider() {
appWidgetId: Int) {
val SP = PreferenceManager.getDefaultSharedPreferences(context)
val displayMetrics = Resources.getSystem().displayMetrics
val widgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId)
var height = Util.convertDpToPixel(80f, context).toInt()
var height = Util.convertDpToPixel(110f, context).toInt()
val width = displayMetrics.widthPixels
if (widgetInfo != null) {
height = widgetInfo.minHeight
}
if (SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
height += Util.convertSpToPixels(SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f), context).toInt() + Util.convertDpToPixel(16f, context).toInt()
}
@ -115,7 +111,7 @@ class TheWidget : AppWidgetProvider() {
views.setTextColor(R.id.next_event_date, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextColor(R.id.divider2, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextColor(R.id.calendar_temp, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextColor(R.id.time, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
//views.setTextColor(R.id.time, Util.getFontColor(PreferenceManager.getDefaultSharedPreferences(context)))
views.setTextViewTextSize(R.id.empty_date, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f))
views.setTextViewTextSize(R.id.divider1, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
@ -125,7 +121,7 @@ class TheWidget : AppWidgetProvider() {
views.setTextViewTextSize(R.id.next_event_date, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
views.setTextViewTextSize(R.id.divider2, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
views.setTextViewTextSize(R.id.calendar_temp, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f))
views.setTextViewTextSize(R.id.time, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
//views.setTextViewTextSize(R.id.time, TypedValue.COMPLEX_UNIT_SP, SP.getFloat(Constants.PREF_TEXT_CLOCK_SIZE, 90f))
v = updateCalendarViewByLayout(context, v)
v = updateLocationViewByLayout(context, v)
@ -297,16 +293,16 @@ class TheWidget : AppWidgetProvider() {
if (!SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
views.setViewVisibility(R.id.time, View.GONE)
} else {
val now = Calendar.getInstance()
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
textBadHour.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
views.setTextViewText(R.id.time, textBadHour)
} else {
views.setTextViewText(R.id.time, Constants.goodHourFormat.format(now.timeInMillis))
}
// val now = Calendar.getInstance()
// if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
// val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
// textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
// textBadHour.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
//
// views.setTextViewText(R.id.time, textBadHour)
// } else {
// views.setTextViewText(R.id.time, Constants.goodHourFormat.format(now.timeInMillis))
// }
val clockPIntent = PendingIntent.getActivity(context, widgetID, Util.getClockIntent(context), 0)
views.setOnClickPendingIntent(R.id.time, clockPIntent)
@ -439,8 +435,8 @@ class TheWidget : AppWidgetProvider() {
v.second_row_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
v.second_row_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
v.weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
v.weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 16f
v.weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
v.weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_SECOND_SIZE, 16f) / 18f
v.empty_weather_icon.scaleX = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
v.empty_weather_icon.scaleY = SP.getFloat(Constants.PREF_TEXT_MAIN_SIZE, 24f) / 24f
@ -478,6 +474,7 @@ class TheWidget : AppWidgetProvider() {
if (SP.getInt(Constants.PREF_CUSTOM_FONT, Constants.CUSTOM_FONT_PRODUCT_SANS) == Constants.CUSTOM_FONT_PRODUCT_SANS) {
val product_sans: Typeface = Typeface.createFromAsset(context.assets, "fonts/product_sans_regular.ttf")
val product_sans_light: Typeface = Typeface.createFromAsset(context.assets, "fonts/product_sans_light.ttf")
v.empty_date.typeface = product_sans
v.divider1.typeface = product_sans
v.temp.typeface = product_sans
@ -486,7 +483,7 @@ class TheWidget : AppWidgetProvider() {
v.next_event_date.typeface = product_sans
v.divider2.typeface = product_sans
v.calendar_temp.typeface = product_sans
v.time.typeface = product_sans
v.time.typeface = product_sans_light
}
return v
@ -527,16 +524,16 @@ class TheWidget : AppWidgetProvider() {
if (!SP.getBoolean(Constants.PREF_SHOW_CLOCK, false)) {
v.time.visibility = View.GONE
} else {
val now = Calendar.getInstance()
if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
textBadHour.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
v.time.text = textBadHour
} else {
v.time.text = Constants.goodHourFormat.format(now.timeInMillis)
}
// val now = Calendar.getInstance()
// if (SP.getString(Constants.PREF_HOUR_FORMAT, "12").equals("12")) {
// val textBadHour = SpannableString(Constants.badHourFormat.format(now.timeInMillis).replace(" ", ""))
// textBadHour.setSpan(RelativeSizeSpan(0.4f), textBadHour.length - 2,
// textBadHour.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//
// v.time.text = textBadHour
// } else {
// v.time.text = Constants.goodHourFormat.format(now.timeInMillis)
// }
v.time.visibility = View.VISIBLE
}
return v