adding a helper function for getting the notificationManager
This commit is contained in:
parent
ae06cac8e8
commit
ab82011667
4 changed files with 36 additions and 36 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
|||
propMinSdkVersion = 21
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '5.26.27'
|
||||
propVersionName = '5.26.28'
|
||||
kotlin_version = '1.3.72'
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean, val
|
|||
private var mDestinationPath = ""
|
||||
|
||||
// progress indication
|
||||
private var mNotificationManager: NotificationManager
|
||||
private var mNotificationBuilder: NotificationCompat.Builder
|
||||
private var mCurrFilename = ""
|
||||
private var mCurrentProgress = 0L
|
||||
|
@ -46,7 +45,6 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean, val
|
|||
|
||||
init {
|
||||
mListener = WeakReference(listener)
|
||||
mNotificationManager = activity.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
mNotificationBuilder = NotificationCompat.Builder(activity)
|
||||
}
|
||||
|
||||
|
@ -114,7 +112,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean, val
|
|||
}
|
||||
|
||||
mProgressHandler.removeCallbacksAndMessages(null)
|
||||
mNotificationManager.cancel(mNotifId)
|
||||
activity.notificationManager.cancel(mNotifId)
|
||||
val listener = mListener?.get() ?: return
|
||||
|
||||
if (success) {
|
||||
|
@ -132,7 +130,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean, val
|
|||
NotificationChannel(channelId, title, importance).apply {
|
||||
enableLights(false)
|
||||
enableVibration(false)
|
||||
mNotificationManager.createNotificationChannel(this)
|
||||
activity.notificationManager.createNotificationChannel(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +141,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean, val
|
|||
|
||||
private fun updateProgress() {
|
||||
if (mIsTaskOver) {
|
||||
mNotificationManager.cancel(mNotifId)
|
||||
activity.notificationManager.cancel(mNotifId)
|
||||
cancel(true)
|
||||
return
|
||||
}
|
||||
|
@ -151,7 +149,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean, val
|
|||
mNotificationBuilder.apply {
|
||||
setContentText(mCurrFilename)
|
||||
setProgress(mMaxSize, (mCurrentProgress / 1000).toInt(), false)
|
||||
mNotificationManager.notify(mNotifId, build())
|
||||
activity.notificationManager.notify(mNotifId, build())
|
||||
}
|
||||
|
||||
mProgressHandler.removeCallbacksAndMessages(null)
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.commons.extensions
|
|||
import android.Manifest
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Activity
|
||||
import android.app.NotificationManager
|
||||
import android.app.role.RoleManager
|
||||
import android.content.*
|
||||
import android.content.pm.PackageManager
|
||||
|
@ -73,21 +74,21 @@ fun Context.updateTextColors(viewGroup: ViewGroup, tmpTextColor: Int = 0, tmpAcc
|
|||
|
||||
val cnt = viewGroup.childCount
|
||||
(0 until cnt).map { viewGroup.getChildAt(it) }
|
||||
.forEach {
|
||||
when (it) {
|
||||
is MyTextView -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyAppCompatSpinner -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MySwitchCompat -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyCompatRadioButton -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyAppCompatCheckbox -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyEditText -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyAutoCompleteTextView -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyFloatingActionButton -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MySeekBar -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyButton -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is ViewGroup -> updateTextColors(it, textColor, accentColor)
|
||||
}
|
||||
.forEach {
|
||||
when (it) {
|
||||
is MyTextView -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyAppCompatSpinner -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MySwitchCompat -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyCompatRadioButton -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyAppCompatCheckbox -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyEditText -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyAutoCompleteTextView -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyFloatingActionButton -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MySeekBar -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is MyButton -> it.setColors(textColor, accentColor, backgroundColor)
|
||||
is ViewGroup -> updateTextColors(it, textColor, accentColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getLinkTextColor(): Int {
|
||||
|
@ -152,7 +153,7 @@ fun Context.isFingerPrintSensorAvailable() = isMarshmallowPlus() && Reprint.isHa
|
|||
|
||||
fun Context.getLatestMediaId(uri: Uri = Files.getContentUri("external")): Long {
|
||||
val projection = arrayOf(
|
||||
BaseColumns._ID
|
||||
BaseColumns._ID
|
||||
)
|
||||
val sortOrder = "${BaseColumns._ID} DESC LIMIT 1"
|
||||
try {
|
||||
|
@ -169,7 +170,7 @@ fun Context.getLatestMediaId(uri: Uri = Files.getContentUri("external")): Long {
|
|||
|
||||
fun Context.getLatestMediaByDateId(uri: Uri = Files.getContentUri("external")): Long {
|
||||
val projection = arrayOf(
|
||||
BaseColumns._ID
|
||||
BaseColumns._ID
|
||||
)
|
||||
val sortOrder = "${Images.ImageColumns.DATE_TAKEN} DESC LIMIT 1"
|
||||
try {
|
||||
|
@ -316,13 +317,13 @@ fun Context.getMediaContent(path: String, uri: Uri): Uri? {
|
|||
}
|
||||
|
||||
fun Context.queryCursor(
|
||||
uri: Uri,
|
||||
projection: Array<String>,
|
||||
selection: String? = null,
|
||||
selectionArgs: Array<String>? = null,
|
||||
sortOrder: String? = null,
|
||||
showErrors: Boolean = false,
|
||||
callback: (cursor: Cursor) -> Unit
|
||||
uri: Uri,
|
||||
projection: Array<String>,
|
||||
selection: String? = null,
|
||||
selectionArgs: Array<String>? = null,
|
||||
sortOrder: String? = null,
|
||||
showErrors: Boolean = false,
|
||||
callback: (cursor: Cursor) -> Unit
|
||||
) {
|
||||
try {
|
||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, sortOrder)
|
||||
|
@ -718,6 +719,7 @@ fun Context.getTextSize() = when (baseConfig.fontSize) {
|
|||
|
||||
val Context.telecomManager: TelecomManager get() = getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
||||
val Context.windowManager: WindowManager get() = getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
val Context.notificationManager: NotificationManager get() = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||
val Context.navigationBarRight: Boolean get() = usableScreenSize.x < realScreenSize.x
|
||||
val Context.navigationBarBottom: Boolean get() = usableScreenSize.y < realScreenSize.y
|
||||
|
@ -796,9 +798,9 @@ fun Context.getBlockedNumbers(): ArrayList<BlockedNumber> {
|
|||
|
||||
val uri = BlockedNumbers.CONTENT_URI
|
||||
val projection = arrayOf(
|
||||
BlockedNumbers.COLUMN_ID,
|
||||
BlockedNumbers.COLUMN_ORIGINAL_NUMBER,
|
||||
BlockedNumbers.COLUMN_E164_NUMBER
|
||||
BlockedNumbers.COLUMN_ID,
|
||||
BlockedNumbers.COLUMN_ORIGINAL_NUMBER,
|
||||
BlockedNumbers.COLUMN_E164_NUMBER
|
||||
)
|
||||
|
||||
queryCursor(uri, projection) { cursor ->
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M4.8073,3.1721C4.5832,7.2678 5.8611,11.4587 8.7292,14.8376 11.5973,18.2165 15.5248,20.1584 19.6025,20.6027c0.2477,0.0203 0.5032,-0.0558 0.7116,-0.2327 0.2084,-0.1769 0.325,-0.4167 0.3452,-0.6644l0.2791,-3.4125c0.0203,-0.2477 -0.0558,-0.5032 -0.2327,-0.7116 -0.1706,-0.2009 -0.4104,-0.3175 -0.6506,-0.3441 -1.0498,-0.1205 -2.0798,-0.3986 -3.0573,-0.811 -0.3276,-0.1445 -0.7259,-0.1009 -1.0236,0.1518l-2.3072,1.9584C12.3938,15.7606 11.2285,14.7649 10.2177,13.5741 9.207,12.3833 8.4138,11.0718 7.8476,9.6957L10.1548,7.7373C10.4451,7.4909 10.5603,7.0986 10.4709,6.752 10.2165,5.713 10.1231,4.6527 10.161,3.5961 10.1813,3.3484 10.0978,3.0992 9.9272,2.8982 9.7503,2.6898 9.5105,2.5732 9.2629,2.553L5.8504,2.2739C5.6027,2.2537 5.3472,2.3297 5.1388,2.5066 4.9304,2.6835 4.8276,2.9244 4.8073,3.1721Z" />
|
||||
</vector>
|
||||
|
|
Loading…
Reference in a new issue