Skip to content

Commit

Permalink
:Request for storage permission, bug fixs for ligi#216 and ligi#220
Browse files Browse the repository at this point in the history
  • Loading branch information
icehong committed Mar 9, 2020
1 parent f4df574 commit c12a434
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ android {
defaultConfig {
versionCode 259
versionName "2.5.9"
minSdkVersion 14
minSdkVersion 16
targetSdkVersion 29
applicationId "org.ligi.gobandroid_hd"
testInstrumentationRunner "org.ligi.gobandroid_hd.AppReplacingRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import java.util.*
/**
* Activity for a Go Game
*/
@RuntimePermissions
open class GoActivity : GobandroidFragmentActivity(), OnTouchListener, OnKeyListener {

var sound_man: GoSoundManager? = null
Expand Down Expand Up @@ -243,7 +244,7 @@ open class GoActivity : GobandroidFragmentActivity(), OnTouchListener, OnKeyList
}

R.id.menu_write_sgf -> {
SaveSGFDialog(this).show()
prepareSaveWithPermissionCheck()
return true
}

Expand All @@ -262,6 +263,11 @@ open class GoActivity : GobandroidFragmentActivity(), OnTouchListener, OnKeyList
return super.onOptionsItemSelected(item)
}

@NeedsPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
fun prepareSave() {
SaveSGFDialog(this).show()
}

@TargetApi(19)
fun doPrint() {
val printManager = getSystemService(Context.PRINT_SERVICE) as PrintManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,46 @@ import org.ligi.gobandroid_hd.App
import org.ligi.gobandroid_hd.InteractionScope
import org.ligi.gobandroid_hd.R
import org.ligi.gobandroid_hd.ui.application.GobandroidFragmentActivity
import permissions.dispatcher.NeedsPermission
import permissions.dispatcher.OnPermissionDenied
import permissions.dispatcher.RuntimePermissions
import java.io.File

/**
* Activity to replay GO Games in TV / Lean back style
*/
@RuntimePermissions
open class GobanDroidTVActivity : GobandroidFragmentActivity() {

private val path_to_play_from: File by lazy { File(env.reviewPath, "commented") }

open val intent2start: Intent
get() = Intent(this, GobanDroidTVActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)

override fun onCreate(savedInstanceState: Bundle?) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
interactionScope.mode = InteractionScope.Mode.TELEVIZE

supportActionBar!!.setLogo(R.drawable.gobandroid_tv)

App.tracker.init(this)

checkStorageWithPermissionCheck()
}

@NeedsPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE, android.Manifest.permission.WRITE_EXERNAL_STORAGE)
fun checkStorage(){
if (path_to_play_from.listFiles() == null) {
setContentView(R.layout.empty)
App.tracker.trackEvent("intern", "unzip", "gtv", null)
UnzipSGFsDialog(this, intent2start, env).show()
} else {
startTV()
}

}
@OnPermissionDenied(android.Manifest.permission.READ_EXTERNAL_STORAGE, android.Manifest.permission.WRITE_EXERNAL_STORAGE)
fun onStorageDenied() {
finish()
}

private fun startTV() {
Expand Down Expand Up @@ -71,4 +83,10 @@ open class GobanDroidTVActivity : GobandroidFragmentActivity() {
startTV()
super.onNewIntent(intent)
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
// NOTE: delegate the permission handling to generated function
onRequestPermissionsResult(requestCode, grantResults)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ open class GobandroidFragmentActivity : AppCompatActivity() {

}


override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
onRequestPermissionsResult(requestCode, grantResults)
Expand Down

0 comments on commit c12a434

Please sign in to comment.