Merge pull request #40 from coolrc136/pr-branch

fix: request for storage permission at startup
This commit is contained in:
Kiva 2019-02-26 23:25:21 +08:00 committed by GitHub
commit 0156b76989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package io.neoterm.ui.term
import android.Manifest
import android.app.Activity
import android.app.AlertDialog
import android.content.*
@ -8,6 +9,7 @@ import android.content.res.Configuration
import android.os.Bundle
import android.os.IBinder
import android.preference.PreferenceManager
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
import android.support.v4.view.OnApplyWindowInsetsListener
import android.support.v4.view.ViewCompat
@ -72,6 +74,19 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
WindowManager.LayoutParams.FLAG_FULLSCREEN)
}
val SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1
if (ContextCompat.checkSelfPermission(
this,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) != PackageManager.PERMISSION_GRANTED
) {
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
)
}
setContentView(R.layout.ui_main)
toolbar = findViewById(R.id.terminal_toolbar)