Skip to content

Commit

Permalink
Merge remote-tracking branch 'dwoffinden/manager' into imalison-get-g…
Browse files Browse the repository at this point in the history
…it-working
  • Loading branch information
colonelpanic8 committed Aug 20, 2023
2 parents 7f628ef + 0d0dc29 commit f423372
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

<!-- For BroadcastReceiver below -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/com/orgzly/android/ui/repos/ReposActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.orgzly.android.ui.repos

import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.provider.Settings
import android.view.ContextMenu
import android.view.MenuItem
import android.view.View
Expand All @@ -29,6 +33,7 @@ import com.orgzly.android.ui.showSnackbar
import com.orgzly.databinding.ActivityReposBinding
import javax.inject.Inject


/**
* List of user-configured repositories.
*/
Expand Down Expand Up @@ -220,14 +225,18 @@ class ReposActivity : CommonActivity(), AdapterView.OnItemClickListener, Activit
}

R.id.repos_options_menu_item_new_git -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
GitRepoActivity.start(this)
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
val uri = Uri.parse("package:" + BuildConfig.APPLICATION_ID)
startActivity(
Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri))
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// TODO: Show explanation why possibly, if ActivityCompat.shouldShowRequestPermissionRationale() says so?
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
ACTIVITY_REQUEST_CODE_FOR_READ_WRITE_EXTERNAL_STORAGE)
} else {
GitRepoActivity.start(this)
}
return
}
Expand Down

0 comments on commit f423372

Please sign in to comment.