Fix navigation drawer handling on MainFragment
This commit is contained in:
parent
d854022691
commit
ae673fc992
1 changed files with 6 additions and 3 deletions
|
@ -21,7 +21,6 @@ import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.ui.AppBarConfiguration
|
import androidx.navigation.ui.AppBarConfiguration
|
||||||
import androidx.navigation.ui.onNavDestinationSelected
|
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.wbrawner.simplemarkdown.R
|
import com.wbrawner.simplemarkdown.R
|
||||||
|
@ -89,6 +88,10 @@ class MainFragment : Fragment(), ActivityCompat.OnRequestPermissionsResultCallba
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
return when (item.itemId) {
|
return when (item.itemId) {
|
||||||
|
android.R.id.home -> {
|
||||||
|
drawerLayout.open()
|
||||||
|
true
|
||||||
|
}
|
||||||
R.id.action_save -> {
|
R.id.action_save -> {
|
||||||
launch {
|
launch {
|
||||||
if (!viewModel.save(requireContext())) {
|
if (!viewModel.save(requireContext())) {
|
||||||
|
@ -130,7 +133,7 @@ class MainFragment : Fragment(), ActivityCompat.OnRequestPermissionsResultCallba
|
||||||
pager!!.setSwipeLocked(item.isChecked)
|
pager!!.setSwipeLocked(item.isChecked)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> item.onNavDestinationSelected(findNavController())
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +254,7 @@ class MainFragment : Fragment(), ActivityCompat.OnRequestPermissionsResultCallba
|
||||||
private fun requestFileOp(requestType: Int) {
|
private fun requestFileOp(requestType: Int) {
|
||||||
val context = context ?: return
|
val context = context ?: return
|
||||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED && Build.VERSION.SDK_INT > 22) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
requestPermissions(
|
requestPermissions(
|
||||||
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
||||||
requestType
|
requestType
|
||||||
|
|
Loading…
Reference in a new issue