OH: fix upload

This commit is contained in:
Milos Kozak 2022-05-27 21:01:24 +02:00
parent e02e55ce32
commit 60f5115ce6

View file

@ -234,9 +234,6 @@ class OpenHumansUploader @Inject internal constructor(
val displayMetrics = DisplayMetrics() val displayMetrics = DisplayMetrics()
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
context.display?.getRealMetrics(displayMetrics)
else
(context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getMetrics(displayMetrics) (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getMetrics(displayMetrics)
val displayInfo = JSONObject() val displayInfo = JSONObject()
@ -620,7 +617,8 @@ class OpenHumansUploader @Inject internal constructor(
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
}, },
0 0
)) )
)
.build() .build()
NotificationManagerCompat.from(context).notify(SIGNED_OUT_NOTIFICATION_ID, notification) NotificationManagerCompat.from(context).notify(SIGNED_OUT_NOTIFICATION_ID, notification)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
@ -646,7 +644,9 @@ class OpenHumansUploader @Inject internal constructor(
} }
private companion object { private companion object {
val HEX_DIGITS = "0123456789ABCDEF".toCharArray() val HEX_DIGITS = "0123456789ABCDEF".toCharArray()
@Suppress("PrivatePropertyName") @Suppress("PrivatePropertyName")
private val FILE_NAME_DATE_FORMAT = SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") } private val FILE_NAME_DATE_FORMAT = SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }
const val WORK_NAME_PERIODIC = "Open Humans Periodic" const val WORK_NAME_PERIODIC = "Open Humans Periodic"