mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
updating some things related to adding Commons library
This commit is contained in:
parent
13b00b7089
commit
e7b307401b
13 changed files with 89 additions and 379 deletions
|
@ -66,14 +66,14 @@
|
|||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.AboutActivity"
|
||||
android:name="com.simplemobiletools.commons.activities.AboutActivity"
|
||||
android:label="@string/about"
|
||||
android:parentActivityName=".activities.MainActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.LicenseActivity"
|
||||
android:label="@string/third_party_licences"
|
||||
android:parentActivityName=".activities.AboutActivity"/>
|
||||
android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.View
|
||||
import com.simplemobiletools.gallery.BuildConfig
|
||||
import com.simplemobiletools.gallery.R
|
||||
import kotlinx.android.synthetic.main.activity_about.*
|
||||
import java.util.*
|
||||
|
||||
class AboutActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
|
||||
setupEmail()
|
||||
setupMoreApps()
|
||||
setupRateUs()
|
||||
setupInvite()
|
||||
setupLicense()
|
||||
setupDonate()
|
||||
setupFacebook()
|
||||
setupGPlus()
|
||||
setupCopyright()
|
||||
}
|
||||
|
||||
private fun setupEmail() {
|
||||
val email = getString(R.string.email)
|
||||
val appName = getString(R.string.app_name)
|
||||
val href = "<a href=\"mailto:$email?subject=$appName\">$email</a>"
|
||||
about_email.text = Html.fromHtml(href)
|
||||
about_email.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
|
||||
private fun setupMoreApps() {
|
||||
about_more_apps.setOnClickListener {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/dev?id=9070296388022589266")))
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCopyright() {
|
||||
val versionName = BuildConfig.VERSION_NAME
|
||||
val year = Calendar.getInstance().get(Calendar.YEAR)
|
||||
val copyrightText = String.format(getString(R.string.copyright), versionName, year)
|
||||
about_copyright.text = copyrightText
|
||||
}
|
||||
|
||||
private fun setupRateUs() {
|
||||
if (mConfig.isFirstRun) {
|
||||
about_rate_us.visibility = View.GONE
|
||||
} else {
|
||||
about_rate_us.setOnClickListener {
|
||||
val uri = Uri.parse("market://details?id=$packageName")
|
||||
try {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, uri))
|
||||
} catch (ignored: ActivityNotFoundException) {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getStoreUrl())))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setupInvite() {
|
||||
about_invite.setOnClickListener {
|
||||
val text = String.format(getString(R.string.share_text), getString(R.string.app_name), getStoreUrl())
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name))
|
||||
putExtra(Intent.EXTRA_TEXT, text)
|
||||
type = "text/plain"
|
||||
startActivity(Intent.createChooser(this, getString(R.string.invite_via)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setupLicense() {
|
||||
about_license.setOnClickListener {
|
||||
val intent = Intent(applicationContext, LicenseActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun setupDonate() {
|
||||
about_donate.setOnClickListener {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://simplemobiletools.github.io/donate")))
|
||||
}
|
||||
}
|
||||
|
||||
fun setupFacebook() {
|
||||
about_facebook.setOnClickListener {
|
||||
var link = "https://www.facebook.com/simplemobiletools"
|
||||
try {
|
||||
packageManager.getPackageInfo("com.facebook.katana", 0)
|
||||
link = "fb://page/150270895341774"
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
|
||||
}
|
||||
}
|
||||
|
||||
fun setupGPlus() {
|
||||
about_gplus.setOnClickListener {
|
||||
val link = "https://plus.google.com/communities/104880861558693868382"
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStoreUrl() = "https://play.google.com/store/apps/details?id=$packageName"
|
||||
}
|
|
@ -129,7 +129,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
if (isShowingPermDialog(file))
|
||||
return
|
||||
|
||||
var document = getFileDocument(path, mConfig.treeUri)
|
||||
var document = getFileDocument(path, config.treeUri)
|
||||
if (!file.exists()) {
|
||||
document = document.createFile("", file.name)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ import com.simplemobiletools.gallery.R
|
|||
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.gallery.extensions.launchAbout
|
||||
import com.simplemobiletools.gallery.extensions.launchCamera
|
||||
import com.simplemobiletools.gallery.extensions.launchSettings
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Directory
|
||||
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
|
||||
|
@ -110,12 +113,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mConfig.isFirstRun = false
|
||||
config.isFirstRun = false
|
||||
}
|
||||
|
||||
private fun tryloadGallery() {
|
||||
if (hasStoragePermission()) {
|
||||
if (mConfig.showAll)
|
||||
if (config.showAll)
|
||||
showAllMedia()
|
||||
else
|
||||
getDirectories()
|
||||
|
@ -155,7 +158,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
}
|
||||
|
||||
private fun showAllMedia() {
|
||||
mConfig.showAll = true
|
||||
config.showAll = true
|
||||
Intent(this, MediaActivity::class.java).apply {
|
||||
putExtra(DIRECTORY, "/")
|
||||
startActivity(this)
|
||||
|
@ -215,7 +218,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
private fun deleteItem(file: File) {
|
||||
if (needsStupidWritePermissions(file.absolutePath)) {
|
||||
if (!isShowingPermDialog(file)) {
|
||||
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
|
||||
val document = getFileDocument(file.absolutePath, config.treeUri)
|
||||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||
|
@ -234,18 +237,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
private fun handleZooming() {
|
||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
||||
layoutManager.spanCount = mConfig.dirColumnCnt
|
||||
layoutManager.spanCount = config.dirColumnCnt
|
||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener {
|
||||
override fun zoomIn() {
|
||||
if (layoutManager.spanCount > 1) {
|
||||
mConfig.dirColumnCnt = --layoutManager.spanCount
|
||||
config.dirColumnCnt = --layoutManager.spanCount
|
||||
DirectoryAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun zoomOut() {
|
||||
if (layoutManager.spanCount < 10) {
|
||||
mConfig.dirColumnCnt = ++layoutManager.spanCount
|
||||
config.dirColumnCnt = ++layoutManager.spanCount
|
||||
DirectoryAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ import com.simplemobiletools.gallery.adapters.MediaAdapter
|
|||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.gallery.extensions.getHumanizedFilename
|
||||
import com.simplemobiletools.gallery.extensions.launchAbout
|
||||
import com.simplemobiletools.gallery.extensions.launchCamera
|
||||
import com.simplemobiletools.gallery.extensions.launchSettings
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
|
||||
|
@ -53,7 +56,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
media_holder.setOnRefreshListener({ getMedia() })
|
||||
mPath = intent.getStringExtra(DIRECTORY)
|
||||
mMedia = ArrayList<Medium>()
|
||||
mShowAll = mConfig.showAll
|
||||
mShowAll = config.showAll
|
||||
if (mShowAll)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||
}
|
||||
|
@ -93,14 +96,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_media, menu)
|
||||
|
||||
val isFolderHidden = mConfig.getIsFolderHidden(mPath)
|
||||
menu.findItem(R.id.hide_folder).isVisible = !isFolderHidden && !mShowAll
|
||||
menu.findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll
|
||||
val isFolderHidden = config.getIsFolderHidden(mPath)
|
||||
menu.apply {
|
||||
findItem(R.id.hide_folder).isVisible = !isFolderHidden && !mShowAll
|
||||
findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll
|
||||
|
||||
menu.findItem(R.id.folder_view).isVisible = mShowAll
|
||||
menu.findItem(R.id.open_camera).isVisible = mShowAll
|
||||
menu.findItem(R.id.settings).isVisible = mShowAll
|
||||
menu.findItem(R.id.about).isVisible = mShowAll
|
||||
findItem(R.id.folder_view).isVisible = mShowAll
|
||||
findItem(R.id.open_camera).isVisible = mShowAll
|
||||
findItem(R.id.settings).isVisible = mShowAll
|
||||
findItem(R.id.about).isVisible = mShowAll
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -144,9 +149,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun toggleFilenameVisibility() {
|
||||
mConfig.displayFileNames = !mConfig.displayFileNames
|
||||
config.displayFileNames = !config.displayFileNames
|
||||
if (media_grid.adapter != null)
|
||||
(media_grid.adapter as MediaAdapter).updateDisplayFilenames(mConfig.displayFileNames)
|
||||
(media_grid.adapter as MediaAdapter).updateDisplayFilenames(config.displayFileNames)
|
||||
}
|
||||
|
||||
private fun showSortingDialog() {
|
||||
|
@ -156,22 +161,22 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun switchToFolderView() {
|
||||
mConfig.showAll = false
|
||||
config.showAll = false
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun hideFolder() {
|
||||
mConfig.addHiddenFolder(mPath)
|
||||
config.addHiddenFolder(mPath)
|
||||
|
||||
if (!mConfig.showHiddenFolders)
|
||||
if (!config.showHiddenFolders)
|
||||
finish()
|
||||
else
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun unhideFolder() {
|
||||
mConfig.removeHiddenFolder(mPath)
|
||||
config.removeHiddenFolder(mPath)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
|
@ -203,18 +208,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
private fun handleZooming() {
|
||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
||||
layoutManager.spanCount = mConfig.mediaColumnCnt
|
||||
layoutManager.spanCount = config.mediaColumnCnt
|
||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener {
|
||||
override fun zoomIn() {
|
||||
if (layoutManager.spanCount > 1) {
|
||||
mConfig.mediaColumnCnt = --layoutManager.spanCount
|
||||
config.mediaColumnCnt = --layoutManager.spanCount
|
||||
MediaAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun zoomOut() {
|
||||
if (layoutManager.spanCount < 10) {
|
||||
mConfig.mediaColumnCnt = ++layoutManager.spanCount
|
||||
config.mediaColumnCnt = ++layoutManager.spanCount
|
||||
MediaAdapter.actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +233,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
if (isShowingPermDialog(it))
|
||||
return
|
||||
|
||||
val document = getFileDocument(it.absolutePath, mConfig.treeUri)
|
||||
val document = getFileDocument(it.absolutePath, config.treeUri)
|
||||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
if (document.uri.toString().endsWith(it.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
|
||||
|
|
|
@ -20,42 +20,42 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupDarkTheme() {
|
||||
settings_dark_theme.isChecked = mConfig.isDarkTheme
|
||||
settings_dark_theme.isChecked = config.isDarkTheme
|
||||
settings_dark_theme_holder.setOnClickListener {
|
||||
settings_dark_theme.toggle()
|
||||
mConfig.isDarkTheme = settings_dark_theme.isChecked
|
||||
config.isDarkTheme = settings_dark_theme.isChecked
|
||||
restartActivity()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSameSorting() {
|
||||
settings_same_sorting.isChecked = mConfig.isSameSorting
|
||||
settings_same_sorting.isChecked = config.isSameSorting
|
||||
settings_same_sorting_holder.setOnClickListener {
|
||||
settings_same_sorting.toggle()
|
||||
mConfig.isSameSorting = settings_same_sorting.isChecked
|
||||
config.isSameSorting = settings_same_sorting.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowHiddenFolders() {
|
||||
settings_show_hidden_folders.isChecked = mConfig.showHiddenFolders
|
||||
settings_show_hidden_folders.isChecked = config.showHiddenFolders
|
||||
settings_show_hidden_folders_holder.setOnClickListener {
|
||||
settings_show_hidden_folders.toggle()
|
||||
mConfig.showHiddenFolders = settings_show_hidden_folders.isChecked
|
||||
config.showHiddenFolders = settings_show_hidden_folders.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAutoplayVideos() {
|
||||
settings_autoplay_videos_holder.setOnClickListener {
|
||||
settings_autoplay_videos.toggle()
|
||||
mConfig.autoplayVideos = settings_autoplay_videos.isChecked
|
||||
config.autoplayVideos = settings_autoplay_videos.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowMedia() {
|
||||
settings_show_media.setSelection(mConfig.showMedia)
|
||||
settings_show_media.setSelection(config.showMedia)
|
||||
settings_show_media.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
mConfig.showMedia = settings_show_media.selectedItemPosition
|
||||
config.showMedia = settings_show_media.selectedItemPosition
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
|
|
|
@ -1,88 +1,14 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.helpers.OPEN_DOCUMENT_TREE
|
||||
import java.io.File
|
||||
|
||||
open class SimpleActivity : AppCompatActivity() {
|
||||
lateinit var mConfig: Config
|
||||
open class SimpleActivity : BaseSimpleActivity() {
|
||||
lateinit var config: Config
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mConfig = Config.newInstance(applicationContext)
|
||||
var theme = if (mConfig.isDarkTheme) R.style.AppTheme_Dark else R.style.AppTheme
|
||||
if (this is ViewPagerActivity || this is PhotoActivity || this is VideoActivity) {
|
||||
theme = if (mConfig.isDarkTheme) R.style.FullScreenTheme_Dark else R.style.FullScreenTheme
|
||||
}
|
||||
setTheme(theme)
|
||||
config = Config.newInstance(applicationContext)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
finish()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, resultData)
|
||||
if (requestCode == OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK && resultData != null) {
|
||||
saveTreeUri(resultData)
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
fun saveTreeUri(resultData: Intent) {
|
||||
val treeUri = resultData.data
|
||||
mConfig.treeUri = treeUri.toString()
|
||||
|
||||
val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
contentResolver.takePersistableUriPermission(treeUri, takeFlags)
|
||||
}
|
||||
|
||||
fun launchCamera() {
|
||||
startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA))
|
||||
}
|
||||
|
||||
fun launchSettings() {
|
||||
startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
}
|
||||
|
||||
fun launchAbout() {
|
||||
startActivity(Intent(applicationContext, AboutActivity::class.java))
|
||||
}
|
||||
|
||||
fun isShowingPermDialog(file: File) = isShowingWritePermissions(file, mConfig.treeUri, OPEN_DOCUMENT_TREE)
|
||||
|
||||
fun showSystemUI() {
|
||||
supportActionBar?.show()
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
}
|
||||
|
||||
fun hideSystemUI() {
|
||||
supportActionBar?.hide()
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LOW_PROFILE or
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,7 @@ import com.simplemobiletools.gallery.adapters.MyPagerAdapter
|
|||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||
import com.simplemobiletools.gallery.dialogs.RenameFileDialog
|
||||
import com.simplemobiletools.gallery.extensions.openEditor
|
||||
import com.simplemobiletools.gallery.extensions.openWith
|
||||
import com.simplemobiletools.gallery.extensions.setAsWallpaper
|
||||
import com.simplemobiletools.gallery.extensions.shareMedium
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.fragments.ViewPagerFragment
|
||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||
|
@ -66,7 +63,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
} else {
|
||||
mPath = intent.getStringExtra(MEDIUM)
|
||||
mShowAll = mConfig.showAll
|
||||
mShowAll = config.showAll
|
||||
}
|
||||
|
||||
if (mPath.isEmpty()) {
|
||||
|
@ -204,7 +201,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
if (needsStupidWritePermissions(mPath)) {
|
||||
if (!isShowingPermDialog(file)) {
|
||||
val document = getFileDocument(mPath, mConfig.treeUri)
|
||||
val document = getFileDocument(mPath, config.treeUri)
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||
document.delete()
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.app.Activity
|
|||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.KeyCharacterMap
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewConfiguration
|
||||
import com.simplemobiletools.filepicker.extensions.getMimeType
|
||||
import com.simplemobiletools.filepicker.extensions.toast
|
||||
|
@ -104,3 +106,21 @@ fun Activity.hasNavBar(): Boolean {
|
|||
!hasMenuKey && !hasBackKey
|
||||
}
|
||||
}
|
||||
|
||||
fun AppCompatActivity.showSystemUI() {
|
||||
supportActionBar?.show()
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
}
|
||||
|
||||
fun AppCompatActivity.hideSystemUI() {
|
||||
supportActionBar?.hide()
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LOW_PROFILE or
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.simplemobiletools.gallery.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.provider.MediaStore
|
||||
import com.simplemobiletools.commons.activities.AboutActivity
|
||||
import com.simplemobiletools.filepicker.extensions.humanizePath
|
||||
import com.simplemobiletools.gallery.activities.SettingsActivity
|
||||
|
||||
fun Context.getRealPathFromURI(uri: Uri): String? {
|
||||
var cursor: Cursor? = null
|
||||
|
@ -25,3 +28,15 @@ fun Context.getHumanizedFilename(path: String): String {
|
|||
val humanized = humanizePath(path)
|
||||
return humanized.substring(humanized.lastIndexOf("/") + 1)
|
||||
}
|
||||
|
||||
fun Context.launchCamera() {
|
||||
startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA))
|
||||
}
|
||||
|
||||
fun Context.launchSettings() {
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
}
|
||||
|
||||
fun Context.launchAbout() {
|
||||
startActivity(Intent(this, AboutActivity::class.java))
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ package com.simplemobiletools.gallery.helpers
|
|||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||
import com.simplemobiletools.gallery.R
|
||||
import java.util.*
|
||||
|
||||
class Config private constructor(val context: Context) {
|
||||
class Config(val context: Context) : BaseConfig(context) {
|
||||
private val mPrefs: SharedPreferences
|
||||
|
||||
companion object {
|
||||
|
@ -16,14 +17,6 @@ class Config private constructor(val context: Context) {
|
|||
mPrefs = context.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
var isFirstRun: Boolean
|
||||
get() = mPrefs.getBoolean(IS_FIRST_RUN, true)
|
||||
set(isFirstRun) = mPrefs.edit().putBoolean(IS_FIRST_RUN, isFirstRun).apply()
|
||||
|
||||
var isDarkTheme: Boolean
|
||||
get() = mPrefs.getBoolean(IS_DARK_THEME, true)
|
||||
set(isDarkTheme) = mPrefs.edit().putBoolean(IS_DARK_THEME, isDarkTheme).apply()
|
||||
|
||||
var isSameSorting: Boolean
|
||||
get() = mPrefs.getBoolean(IS_SAME_SORTING, true)
|
||||
set(isSameSorting) = mPrefs.edit().putBoolean(IS_SAME_SORTING, isSameSorting).apply()
|
||||
|
@ -90,10 +83,6 @@ class Config private constructor(val context: Context) {
|
|||
get() = mPrefs.getBoolean(AUTOPLAY_VIDEOS, false)
|
||||
set(autoplay) = mPrefs.edit().putBoolean(AUTOPLAY_VIDEOS, autoplay).apply()
|
||||
|
||||
var treeUri: String
|
||||
get() = mPrefs.getString(TREE_URI, "")
|
||||
set(uri) = mPrefs.edit().putString(TREE_URI, uri).apply()
|
||||
|
||||
var displayFileNames: Boolean
|
||||
get() = mPrefs.getBoolean(DISPLAY_FILE_NAMES, false)
|
||||
set(display) = mPrefs.edit().putBoolean(DISPLAY_FILE_NAMES, display).apply()
|
||||
|
|
|
@ -2,15 +2,12 @@ package com.simplemobiletools.gallery.helpers
|
|||
|
||||
// shared preferences
|
||||
val PREFS_KEY = "Gallery"
|
||||
val IS_FIRST_RUN = "is_first_run"
|
||||
val IS_DARK_THEME = "is_dark_theme"
|
||||
val IS_SAME_SORTING = "is_same_sorting"
|
||||
val SORT_ORDER = "sort_order"
|
||||
val DIRECTORY_SORT_ORDER = "directory_sort_order"
|
||||
val HIDDEN_FOLDERS = "hidden_folders"
|
||||
val SHOW_HIDDEN_FOLDERS = "show_hidden_folders"
|
||||
val AUTOPLAY_VIDEOS = "autoplay_videos"
|
||||
val TREE_URI = "tree_uri"
|
||||
val DISPLAY_FILE_NAMES = "display_file_names"
|
||||
val PINNED_FOLDERS = "pinned_folders"
|
||||
val DIR_COLUMN_CNT = "dir_column_cnt"
|
||||
|
@ -23,11 +20,8 @@ val SORT_BY_NAME = 1
|
|||
val SORT_BY_DATE_MODIFIED = 2
|
||||
val SORT_BY_SIZE = 4
|
||||
val SORT_BY_DATE_TAKEN = 8
|
||||
|
||||
val SORT_DESCENDING = 1024
|
||||
|
||||
// global intents
|
||||
val OPEN_DOCUMENT_TREE = 1000
|
||||
|
||||
val DIRECTORY = "directory"
|
||||
val MEDIUM = "medium"
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/about_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/about_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_website"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:text="@string/website"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_email_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_website"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:text="@string/email_label"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_email_label"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/email"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_more_apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_email"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/more_apps_underlined"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_invite"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_more_apps"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/invite_friends_underlined"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_rate_us"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_invite"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/rate_us_underlined"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_license"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_rate_us"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/third_party_licences_underlined"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_donate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_license"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/donate_underlined"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_follow_us"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_donate"
|
||||
android:paddingBottom="@dimen/social_padding"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/follow_us"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/about_facebook"
|
||||
android:layout_width="@dimen/social_logo"
|
||||
android:layout_height="@dimen/social_logo"
|
||||
android:layout_below="@+id/about_follow_us"
|
||||
android:src="@mipmap/facebook"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/about_gplus"
|
||||
android:layout_width="@dimen/social_logo"
|
||||
android:layout_height="@dimen/social_logo"
|
||||
android:layout_below="@+id/about_follow_us"
|
||||
android:layout_marginLeft="@dimen/social_padding"
|
||||
android:layout_marginRight="@dimen/social_padding"
|
||||
android:layout_toEndOf="@+id/about_facebook"
|
||||
android:layout_toRightOf="@+id/about_facebook"
|
||||
android:src="@mipmap/gplus"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_copyright"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@+id/about_gplus"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="v1.0\nCopyright © Simple Mobile Tools 2016"/>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
Loading…
Reference in a new issue