Skip to content

Commit

Permalink
Monkeypatch WelcomePermissionScreen to prevent unintentional Intents
Browse files Browse the repository at this point in the history
  • Loading branch information
TranceLove committed Sep 21, 2023
1 parent 1ddf5a3 commit ae58e47
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.core.app.ActivityCompat
import com.amaze.fileutilities.R
import com.amaze.fileutilities.utilis.showToastInCenter
import com.stephentuso.welcome.WelcomeActivity
import com.stephentuso.welcome.WelcomeUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand Down Expand Up @@ -327,6 +328,19 @@ abstract class WelcomePermissionScreen :
return grantResults.size == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED
}

/**
* Remove all flags and URI that put into the Intent.
* We are finishing the app here, so any URI provided will not be useful anyway.
*/
override fun cancelWelcomeScreen() {
val intent = this.intent
intent.flags = -1
intent.data = null
intent.putExtra(WELCOME_SCREEN_KEY, WelcomeUtils.getKey(this.javaClass))
this.setResult(RESULT_CANCELED, intent)
finish()
}

interface OnPermissionGranted {
fun onPermissionGranted(isGranted: Boolean)
}
Expand Down

0 comments on commit ae58e47

Please sign in to comment.