diff --git a/app/build.gradle b/app/build.gradle index 8b0d817f..5b2b81df 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.29.2' + compile 'com.simplemobiletools:commons:2.30.9' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt index 6437b0a5..3752a6fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt @@ -1,12 +1,9 @@ package com.simplemobiletools.filemanager.activities -import android.Manifest import android.content.Intent -import android.content.pm.PackageManager import android.os.Bundle import android.os.Handler import android.os.Parcelable -import android.support.v4.app.ActivityCompat import android.view.Menu import android.view.MenuItem import com.simplemobiletools.commons.dialogs.RadioGroupDialog @@ -14,6 +11,7 @@ import com.simplemobiletools.commons.dialogs.StoragePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT +import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.Release @@ -31,7 +29,6 @@ import kotlinx.android.synthetic.main.activity_main.* import java.util.* class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Breadcrumbs.BreadcrumbsListener { - private val STORAGE_PERMISSION = 1 private val BACK_PRESS_TIMEOUT = 5000 private var latestFragment: ItemsFragment? = null @@ -45,7 +42,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br setContentView(R.layout.activity_main) storeStoragePaths() storeConfigVariables() - breadcrumbs.setListener(this) + breadcrumbs.listener = this tryInitFileManager() checkWhatsNewDialog() checkIfRootAvailable() @@ -56,7 +53,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br updateTextColors(main_screen) if (storedTextColor != config.textColor) { storedTextColor = config.textColor - breadcrumbs.setTextColor(storedTextColor) + breadcrumbs.textColor = storedTextColor openPath(currentPath) } invalidateOptionsMenu() @@ -77,10 +74,13 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br } private fun tryInitFileManager() { - if (hasWriteStoragePermission()) { - initRootFileManager() - } else { - ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION) + handlePermission(PERMISSION_WRITE_STORAGE) { + if (it) { + initRootFileManager() + } else { + toast(R.string.no_storage_permissions) + finish() + } } } @@ -226,19 +226,6 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br } } - override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults) - - if (requestCode == STORAGE_PERMISSION) { - if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - initRootFileManager() - } else { - toast(R.string.no_storage_permissions) - finish() - } - } - } - override fun itemClicked(item: FileDirItem) { openPath(item.path) } diff --git a/build.gradle b/build.gradle index 0a26ece5..633d2030 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ allprojects { repositories { jcenter() maven { url "https://jitpack.io" } + maven { url "https://maven.google.com" } } }