Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
Signed-off-by: parneet-guraya <[email protected]>
  • Loading branch information
parneet-guraya committed Oct 10, 2023
1 parent a0d4c97 commit 6458494
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,31 @@ class FullScreenImageActivity : AppCompatActivity() {
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == android.R.id.home) {
onBackPressedDispatcher.onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
File(path)
)

val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, shareUri)
type = IMAGE_PREFIX_GENERIC
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
return when (item.itemId) {
android.R.id.home -> {
onBackPressedDispatcher.onBackPressed()
true
}
R.id.share -> {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
File(path)
)

val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, shareUri)
type = IMAGE_PREFIX_GENERIC
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
startActivity(Intent.createChooser(shareIntent, resources.getText(R.string.send_to)))

true
}
else -> {
super.onOptionsItemSelected(item)
}
startActivity(Intent.createChooser(shareIntent, resources.getText(R.string.send_to)))

true
} else {
super.onOptionsItemSelected(item)
}
}

Expand All @@ -96,7 +100,7 @@ class FullScreenImageActivity : AppCompatActivity() {
WindowCompat.setDecorFitsSystemWindows(window, false)
initWindowInsetsController()
applyWindowInsets()
binding.photoView.setOnPhotoTapListener { view, x, y ->
binding.photoView.setOnPhotoTapListener { _, _, _ ->
toggleFullscreen()
}
binding.photoView.setOnOutsidePhotoTapListener {
Expand Down Expand Up @@ -185,7 +189,7 @@ class FullScreenImageActivity : AppCompatActivity() {
}

companion object {
private val TAG = "FullScreenImageActivity"
private const val TAG = "FullScreenImageActivity"
private const val HUNDRED_MB = 100 * 1024 * 1024
private const val MAX_SCALE = 6.0f
private const val MEDIUM_SCALE = 2.45f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,31 @@ class FullScreenMediaActivity : AppCompatActivity() {
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == android.R.id.home) {
onBackPressedDispatcher.onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
File(path)
)

val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, shareUri)
type = VIDEO_PREFIX_GENERIC
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
return when (item.itemId) {
android.R.id.home -> {
onBackPressedDispatcher.onBackPressed()
true
}
startActivity(Intent.createChooser(shareIntent, resources.getText(R.string.send_to)))
R.id.share -> {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
File(path)
)

val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, shareUri)
type = VIDEO_PREFIX_GENERIC
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
startActivity(Intent.createChooser(shareIntent, resources.getText(R.string.send_to)))

true
} else {
super.onOptionsItemSelected(item)
true
}
else -> {
super.onOptionsItemSelected(item)
}
}
}

Expand Down

0 comments on commit 6458494

Please sign in to comment.