Skip to content

Commit

Permalink
Merge pull request #127 from TeamAmaze/bugfix/welcomescreen
Browse files Browse the repository at this point in the history
Monkeypatch WelcomePermissionScreen to prevent unintentional Intents
  • Loading branch information
VishalNehra authored Oct 9, 2023
2 parents 1ddf5a3 + ae58e47 commit 62d0220
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 62d0220

Please sign in to comment.