|
|
@ -7,6 +7,10 @@ import android.os.Build
|
|
|
|
import android.os.Handler
|
|
|
|
import android.os.Handler
|
|
|
|
import android.provider.MediaStore
|
|
|
|
import android.provider.MediaStore
|
|
|
|
import androidx.annotation.RequiresApi
|
|
|
|
import androidx.annotation.RequiresApi
|
|
|
|
|
|
|
|
import org.session.libsignal.utilities.Log
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private const val TAG = "ScreenshotObserver"
|
|
|
|
|
|
|
|
|
|
|
|
class ScreenshotObserver(private val context: Context, handler: Handler, private val screenshotTriggered: ()->Unit): ContentObserver(handler) {
|
|
|
|
class ScreenshotObserver(private val context: Context, handler: Handler, private val screenshotTriggered: ()->Unit): ContentObserver(handler) {
|
|
|
|
|
|
|
|
|
|
|
@ -31,6 +35,7 @@ class ScreenshotObserver(private val context: Context, handler: Handler, private
|
|
|
|
val projection = arrayOf(
|
|
|
|
val projection = arrayOf(
|
|
|
|
MediaStore.Images.Media.DATA
|
|
|
|
MediaStore.Images.Media.DATA
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
try {
|
|
|
|
context.contentResolver.query(
|
|
|
|
context.contentResolver.query(
|
|
|
|
uri,
|
|
|
|
uri,
|
|
|
|
projection,
|
|
|
|
projection,
|
|
|
@ -48,6 +53,9 @@ class ScreenshotObserver(private val context: Context, handler: Handler, private
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e: SecurityException) {
|
|
|
|
|
|
|
|
Log.e(TAG, e)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(Build.VERSION_CODES.Q)
|
|
|
|
@RequiresApi(Build.VERSION_CODES.Q)
|
|
|
@ -56,6 +64,8 @@ class ScreenshotObserver(private val context: Context, handler: Handler, private
|
|
|
|
MediaStore.Images.Media.DISPLAY_NAME,
|
|
|
|
MediaStore.Images.Media.DISPLAY_NAME,
|
|
|
|
MediaStore.Images.Media.RELATIVE_PATH
|
|
|
|
MediaStore.Images.Media.RELATIVE_PATH
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
context.contentResolver.query(
|
|
|
|
context.contentResolver.query(
|
|
|
|
uri,
|
|
|
|
uri,
|
|
|
|
projection,
|
|
|
|
projection,
|
|
|
@ -78,6 +88,8 @@ class ScreenshotObserver(private val context: Context, handler: Handler, private
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e: IllegalStateException) {
|
|
|
|
|
|
|
|
Log.e(TAG, e)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|