Merge pull request #6 from SimpleMobileTools/master

update
This commit is contained in:
solokot 2017-12-02 01:01:38 +03:00 committed by GitHub
commit ddec2922a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 397 additions and 261 deletions

View file

@ -47,7 +47,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:2.41.8'
implementation 'com.simplemobiletools:commons:3.0.20'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
implementation 'com.android.support:multidex:1.0.2'

View file

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simplemobiletools.gallery">
package="com.simplemobiletools.gallery"
android:installLocation="auto">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_launcher_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
@ -60,8 +60,7 @@
<activity
android:name=".activities.ViewPagerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:parentActivityName=".activities.MediaActivity"
android:theme="@style/FullScreenTheme">
android:parentActivityName=".activities.MediaActivity">
<intent-filter>
<action android:name="com.android.camera.action.REVIEW"/>
@ -96,8 +95,7 @@
<activity
android:name=".activities.PhotoVideoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenTheme"/>
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity
android:name=".activities.IncludedFoldersActivity"
@ -111,8 +109,7 @@
<activity
android:name=".activities.PhotoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenTheme">
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
@ -125,8 +122,7 @@
<activity
android:name=".activities.VideoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenTheme">
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

View file

@ -2,24 +2,21 @@ package com.simplemobiletools.gallery
import android.support.multidex.MultiDexApplication
import com.github.ajalt.reprint.core.Reprint
import com.simplemobiletools.gallery.extensions.config
import java.util.*
import com.simplemobiletools.commons.extensions.checkUseEnglish
import com.simplemobiletools.gallery.BuildConfig.USE_LEAK_CANARY
import com.squareup.leakcanary.LeakCanary
class App : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
/*if (USE_LEAK_CANARY) {
if (USE_LEAK_CANARY) {
if (LeakCanary.isInAnalyzerProcess(this)) {
return
}
LeakCanary.install(this)
}*/
if (config.useEnglish) {
val conf = resources.configuration
conf.locale = Locale.ENGLISH
resources.updateConfiguration(conf, resources.displayMetrics)
}
checkUseEnglish()
Reprint.initialize(this)
}
}

View file

@ -68,7 +68,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
storeStoragePaths()
appLaunched()
mIsPickImageIntent = isPickImageIntent(intent)
mIsPickVideoIntent = isPickVideoIntent(intent)
@ -81,7 +81,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mIsGetAnyContentIntent || mIsSetWallpaperIntent
removeTempFolder()
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
directories_refresh_layout.setOnRefreshListener { getDirectories() }
mDirs = ArrayList()
storeStateVariables()
checkWhatsNewDialog()
@ -324,12 +324,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
}
override fun tryDeleteFolders(folders: ArrayList<File>) {
for (file in folders) {
deleteFolders(folders) {
runOnUiThread {
refreshItems()
}
override fun deleteFolders(folders: ArrayList<File>) {
deleteFolders(folders) {
runOnUiThread {
refreshItems()
}
}
}
@ -342,11 +340,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} else {
setupListLayoutManager()
}
getDirectoryAdapter()?.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
}
}
private fun setupGridLayoutManager() {
@ -360,20 +353,28 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
layoutManager.spanCount = config.dirColumnCnt
mZoomListener = object : MyRecyclerView.MyZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
}
override fun zoomOut() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
increaseColumnCount()
getRecyclerAdapter().finishActMode()
private fun initZoomListener() {
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
val layoutManager = directories_grid.layoutManager as GridLayoutManager
mZoomListener = object : MyRecyclerView.MyZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
override fun zoomOut() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
increaseColumnCount()
getRecyclerAdapter().finishActMode()
}
}
}
} else {
mZoomListener = null
}
}
@ -554,12 +555,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun setupAdapter() {
val currAdapter = directories_grid.adapter
if (currAdapter == null) {
directories_grid.adapter = DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) {
initZoomListener()
DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) {
itemClicked((it as Directory).path)
}.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
directories_grid.adapter = this
}
} else {
(currAdapter as DirectoryAdapter).updateDirs(mDirs)
}
setupScrollDirection()
}

View file

@ -176,8 +176,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
val currAdapter = media_grid.adapter
if (currAdapter == null) {
media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) {
initZoomListener()
MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) {
itemClicked((it as Medium).path)
}.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
media_grid.adapter = this
}
} else {
(currAdapter as MediaAdapter).updateMedia(mMedia)
@ -402,11 +407,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} else {
setupListLayoutManager()
}
getMediaAdapter()?.apply {
setupZoomListener(mZoomListener)
setupDragListener(true)
}
}
private fun setupGridLayoutManager() {
@ -420,20 +420,28 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
layoutManager.spanCount = config.mediaColumnCnt
mZoomListener = object : MyRecyclerView.MyZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
}
override fun zoomOut() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
increaseColumnCount()
getRecyclerAdapter().finishActMode()
private fun initZoomListener() {
if (config.viewTypeFiles == VIEW_TYPE_GRID) {
val layoutManager = media_grid.layoutManager as GridLayoutManager
mZoomListener = object : MyRecyclerView.MyZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
reduceColumnCount()
getRecyclerAdapter().finishActMode()
}
}
override fun zoomOut() {
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
increaseColumnCount()
getRecyclerAdapter().finishActMode()
}
}
}
} else {
mZoomListener = null
}
}

View file

@ -40,6 +40,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.fragment_holder)
setTranslucentNavigation()
handlePermission(PERMISSION_WRITE_STORAGE) {
if (it) {
checkIntent(savedInstanceState)

View file

@ -1,12 +1,10 @@
package com.simplemobiletools.gallery.activities
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.simplemobiletools.commons.activities.BaseSplashActivity
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
class SplashActivity : BaseSplashActivity() {
override fun initActivity() {
startActivity(Intent(this, MainActivity::class.java))
finish()
}

View file

@ -80,6 +80,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_medium)
setTranslucentNavigation()
handlePermission(PERMISSION_WRITE_STORAGE) {
if (it) {

View file

@ -1,7 +1,6 @@
package com.simplemobiletools.gallery.adapters
import android.graphics.PorterDuff
import android.util.SparseArray
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@ -36,10 +35,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
private var animateGifs = config.animateGifs
private var cropThumbnails = config.cropThumbnails
init {
selectableItemCount = dirs.count()
}
override fun getActionMenuId() = R.menu.cab_directories
override fun prepareItemSelection(view: View) {
@ -57,8 +52,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val dir = dirs[position]
val view = holder.bindView(dir, !isPickIntent) {
setupView(it, dir)
val view = holder.bindView(dir, !isPickIntent) { itemView, layoutPosition ->
setupView(itemView, dir)
}
bindViewHolder(holder, position, view)
}
@ -93,6 +88,15 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
}
}
override fun getSelectableItemCount() = dirs.size
override fun onViewRecycled(holder: ViewHolder?) {
super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) {
Glide.with(activity).clear(holder?.itemView?.dir_thumbnail)
}
}
private fun checkHideBtnVisibility(menu: Menu) {
var hiddenCnt = 0
var unhiddenCnt = 0
@ -163,6 +167,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
}
} else {
activity.removeNoMedia(it) {
activity.scanPath(it)
noMediaHandled()
}
}
@ -226,42 +231,33 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
}
private fun deleteFiles() {
if (selectedPositions.isEmpty()) {
return
}
val folders = ArrayList<File>(selectedPositions.size)
val removeFolders = ArrayList<Directory>(selectedPositions.size)
var needPermissionForPath = ""
var SAFPath = ""
selectedPositions.forEach {
if (dirs.size > it) {
val path = dirs[it].path
if (activity.needsStupidWritePermissions(path) && config.treeUri.isEmpty()) {
needPermissionForPath = path
SAFPath = path
}
}
}
activity.handleSAFDialog(File(needPermissionForPath)) {
activity.handleSAFDialog(File(SAFPath)) {
selectedPositions.sortedDescending().forEach {
if (dirs.size > it) {
val directory = dirs[it]
folders.add(File(directory.path))
removeFolders.add(directory)
notifyItemRemoved(it)
itemViews.put(it, null)
}
val directory = dirs[it]
folders.add(File(directory.path))
removeFolders.add(directory)
}
dirs.removeAll(removeFolders)
selectedPositions.clear()
listener?.tryDeleteFolders(folders)
val newItems = SparseArray<View>()
(0 until itemViews.size())
.filter { itemViews[it] != null }
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
itemViews = newItems
selectableItemCount = dirs.size
finishActMode()
listener?.deleteFolders(folders)
removeSelectedItems()
}
}
@ -306,16 +302,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
return paths
}
override fun onViewRecycled(holder: ViewHolder?) {
super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) {
Glide.with(activity).clear(holder?.itemView?.dir_thumbnail)
}
}
fun updateDirs(newDirs: ArrayList<Directory>) {
dirs = newDirs
selectableItemCount = dirs.size
notifyDataSetChanged()
finishActMode()
}
@ -363,7 +351,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Direc
interface DirOperationsListener {
fun refreshItems()
fun tryDeleteFolders(folders: ArrayList<File>)
fun deleteFolders(folders: ArrayList<File>)
fun recheckPinnedFolders()
}

View file

@ -1,6 +1,5 @@
package com.simplemobiletools.gallery.adapters
import android.util.SparseArray
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@ -19,10 +18,6 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<
private val config = activity.config
init {
selectableItemCount = folders.size
}
override fun getActionMenuId() = R.menu.cab_delete_only
override fun prepareActionMode(menu: Menu) {}
@ -39,12 +34,14 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<
}
}
override fun getSelectableItemCount() = folders.size
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int) = createViewHolder(R.layout.item_manage_folder, parent)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val folder = folders[position]
val view = holder.bindView(folder) {
setupView(it, folder)
val view = holder.bindView(folder) { itemView, layoutPosition ->
setupView(itemView, folder)
}
bindViewHolder(holder, position, view)
}
@ -72,8 +69,6 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<
selectedPositions.sortedDescending().forEach {
val folder = folders[it]
removeFolders.add(folder)
notifyItemRemoved(it)
itemViews.put(it, null)
if (isShowingExcludedFolders) {
config.removeExcludedFolder(folder)
} else {
@ -82,16 +77,7 @@ class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<
}
folders.removeAll(removeFolders)
selectedPositions.clear()
val newItems = SparseArray<View>()
(0 until itemViews.size())
.filter { itemViews[it] != null }
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
itemViews = newItems
selectableItemCount = folders.size
finishActMode()
removeSelectedItems()
if (folders.isEmpty()) {
listener?.refreshItems()
}

View file

@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.adapters
import android.graphics.PorterDuff
import android.net.Uri
import android.util.SparseArray
import android.view.Menu
import android.view.View
import android.view.ViewGroup
@ -36,10 +35,6 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
private var cropThumbnails = config.cropThumbnails
private var displayFilenames = config.displayFileNames
init {
selectableItemCount = media.count()
}
override fun getActionMenuId() = R.menu.cab_media
override fun prepareItemSelection(view: View) {
@ -57,8 +52,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val medium = media[position]
val view = holder.bindView(medium, !allowMultiplePicks) {
setupView(it, medium)
val view = holder.bindView(medium, !allowMultiplePicks) { itemView, layoutPosition ->
setupView(itemView, medium)
}
bindViewHolder(holder, position, view)
}
@ -93,6 +88,15 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
}
}
override fun getSelectableItemCount() = media.size
override fun onViewRecycled(holder: ViewHolder?) {
super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) {
Glide.with(activity).clear(holder?.itemView?.medium_thumbnail)
}
}
private fun checkHideBtnVisibility(menu: Menu) {
var hiddenCnt = 0
var unhiddenCnt = 0
@ -205,26 +209,17 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
return
}
activity.handleSAFDialog(File(media[selectedPositions.first()].path)) {
val SAFPath = media[selectedPositions.first()].path
activity.handleSAFDialog(File(SAFPath)) {
selectedPositions.sortedDescending().forEach {
val medium = media[it]
files.add(File(medium.path))
removeMedia.add(medium)
notifyItemRemoved(it)
itemViews.put(it, null)
}
media.removeAll(removeMedia)
listener?.deleteFiles(files)
val newItems = SparseArray<View>()
(0 until itemViews.size())
.filter { itemViews[it] != null }
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
itemViews = newItems
selectableItemCount = media.size
finishActMode()
removeSelectedItems()
}
}
@ -234,16 +229,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
return selectedMedia
}
override fun onViewRecycled(holder: ViewHolder?) {
super.onViewRecycled(holder)
if (!activity.isActivityDestroyed()) {
Glide.with(activity).clear(holder?.itemView?.medium_thumbnail)
}
}
fun updateMedia(newMedia: ArrayList<Medium>) {
media = newMedia
selectableItemCount = media.size
notifyDataSetChanged()
finishActMode()
}

View file

@ -14,7 +14,7 @@ import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.models.Medium
class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val media: MutableList<Medium>) : FragmentStatePagerAdapter(fm) {
private val mFragments = HashMap<Int, ViewPagerFragment>()
private val fragments = HashMap<Int, ViewPagerFragment>()
override fun getCount() = media.size
override fun getItem(position: Int): Fragment {
@ -38,19 +38,19 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val fragment = super.instantiateItem(container, position) as ViewPagerFragment
mFragments.put(position, fragment)
fragments.put(position, fragment)
return fragment
}
override fun destroyItem(container: ViewGroup, position: Int, any: Any) {
mFragments.remove(position)
fragments.remove(position)
super.destroyItem(container, position, any)
}
fun getCurrentFragment(position: Int) = mFragments.get(position)
fun getCurrentFragment(position: Int) = fragments.get(position)
fun toggleFullscreen(isFullscreen: Boolean) {
for ((pos, fragment) in mFragments) {
for ((pos, fragment) in fragments) {
fragment.fullscreenToggled(isFullscreen)
}
}

View file

@ -40,13 +40,13 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
private fun setupSortRadio() {
val sortingRadio = view.sorting_dialog_radio_sorting
var sortBtn = sortingRadio.sorting_dialog_radio_name
when {
currSorting and SORT_BY_PATH != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_path
currSorting and SORT_BY_SIZE != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_size
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_last_modified
currSorting and SORT_BY_DATE_TAKEN != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_date_taken
val sortBtn = when {
currSorting and SORT_BY_PATH != 0 -> sortingRadio.sorting_dialog_radio_path
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken
else -> sortingRadio.sorting_dialog_radio_name
}
sortBtn.isChecked = true
}

View file

@ -1,23 +1,22 @@
package com.simplemobiletools.gallery.dialogs
import android.content.Context
import android.app.Activity
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.R
import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.*
class DeleteWithRememberDialog(val context: Context, val callback: (remember: Boolean) -> Unit) {
var dialog: AlertDialog
val view = LayoutInflater.from(context).inflate(R.layout.dialog_delete_with_remember, null)
class DeleteWithRememberDialog(val activity: Activity, val callback: (remember: Boolean) -> Unit) {
private var dialog: AlertDialog
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!!
init {
val builder = AlertDialog.Builder(context)
val builder = AlertDialog.Builder(activity)
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() })
.setNegativeButton(R.string.no, null)
dialog = builder.create().apply {
context.setupDialogStuff(view, this)
activity.setupDialogStuff(view, this)
}
}

View file

@ -74,19 +74,20 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.resize_and_save)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val width = getViewValue(widthView)
val height = getViewValue(heightView)
if (width <= 0 || height <= 0) {
activity.toast(R.string.invalid_values)
return@setOnClickListener
}
activity.setupDialogStuff(view, this, R.string.resize_and_save) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val width = getViewValue(widthView)
val height = getViewValue(heightView)
if (width <= 0 || height <= 0) {
activity.toast(R.string.invalid_values)
return@setOnClickListener
}
val newSize = Point(getViewValue(widthView), getViewValue(heightView))
callback(newSize)
dismiss()
})
val newSize = Point(getViewValue(widthView), getViewValue(heightView))
callback(newSize)
dismiss()
}
}
}
}

View file

@ -46,38 +46,39 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.save_as)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val filename = view.save_as_name.value
val extension = view.save_as_extension.value
activity.setupDialogStuff(view, this, R.string.save_as) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.save_as_name.value
val extension = view.save_as_extension.value
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
}
if (extension.isEmpty()) {
activity.toast(R.string.extension_cannot_be_empty)
return@setOnClickListener
}
if (extension.isEmpty()) {
activity.toast(R.string.extension_cannot_be_empty)
return@setOnClickListener
}
val newFile = File(realPath, "$filename.$extension")
if (!newFile.name.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters)
return@setOnClickListener
}
val newFile = File(realPath, "$filename.$extension")
if (!newFile.name.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters)
return@setOnClickListener
}
if (newFile.exists()) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
ConfirmationDialog(activity, title) {
if (newFile.exists()) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
ConfirmationDialog(activity, title) {
callback(newFile.absolutePath)
dismiss()
}
} else {
callback(newFile.absolutePath)
dismiss()
}
} else {
callback(newFile.absolutePath)
dismiss()
}
})
}
}
}
}

View file

@ -73,17 +73,18 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
activity.setupDialogStuff(view, this)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) {
activity.toast(R.string.no_media_for_slideshow)
return@setOnClickListener
}
activity.setupDialogStuff(view, this) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) {
activity.toast(R.string.no_media_for_slideshow)
return@setOnClickListener
}
storeValues()
callback()
dismiss()
})
storeValues()
callback()
dismiss()
}
}
}
}

View file

@ -43,7 +43,7 @@ fun Activity.shareMedium(medium: Medium) {
}
fun Activity.shareMedia(media: List<Medium>) {
val uris = media.map { getFilePublicUri(File(it.path), BuildConfig.APPLICATION_ID) } as ArrayList
val uris = media.map { Uri.fromFile(File(it.path)) } as ArrayList
shareUris(uris)
}

View file

@ -224,12 +224,15 @@ class PhotoFragment : ViewPagerFragment() {
private fun addZoomableView() {
if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.isGone()) {
val exif = android.media.ExifInterface(medium.path)
val orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL)
ViewPagerActivity.wasDecodedByGlide = false
view.subsampling_view.apply {
maxScale = 10f
beVisible()
setImage(ImageSource.uri(medium.path))
orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF
this.orientation = degreesForRotation(orientation)
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
override fun onImageLoaded() {
}

View file

@ -119,7 +119,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
mSurfaceView = mView.video_surface
mSurfaceHolder = mSurfaceView!!.holder
mSurfaceHolder!!.addCallback(this)
mSurfaceView!!.setOnClickListener({ toggleFullscreen() })
mSurfaceView!!.setOnClickListener { toggleFullscreen() }
mView.video_holder.setOnClickListener { toggleFullscreen() }
mView.video_volume_controller.setOnTouchListener { v, event ->
handleVolumeTouched(event)
@ -423,7 +423,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
setDataSource(context, Uri.parse(mediumPath))
setDisplay(mSurfaceHolder)
setOnCompletionListener { videoCompleted() }
setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() })
setOnVideoSizeChangedListener { mediaPlayer, width, height -> setVideoSize() }
setOnPreparedListener { videoPrepared(it) }
setAudioStreamType(AudioManager.STREAM_MUSIC)
prepare()

View file

@ -0,0 +1,15 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillAlpha="1"
android:fillColor="#fff"
android:pathData="M63.8,39.95m-5.85,0a5.85,5.85 0,1 1,11.71 0a5.85,5.85 0,1 1,-11.71 0"/>
<path
android:fillAlpha="1"
android:fillColor="#fff"
android:pathData="M29.52,72.4l46.27,0l-10.05,-16.51l0,0l-6.01,8.57l-12.43,-17.93z"/>
</vector>

View file

@ -23,7 +23,8 @@
android:layout_margin="@dimen/small_margin"
android:background="@drawable/circle_background"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_check"/>
android:src="@drawable/ic_check"
android:visibility="gone"/>
<ImageView
android:id="@+id/play_outline"

View file

@ -24,7 +24,8 @@
android:layout_margin="@dimen/small_margin"
android:background="@drawable/circle_background"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_check"/>
android:src="@drawable/ic_check"
android:visibility="gone"/>
<TextView
android:id="@+id/photo_name"

View file

@ -0,0 +1,19 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillAlpha="1"
android:fillColor="#f57c00"
android:pathData="M54.31,5.43L54.31,5.43A48.88,48.88 0,0 1,103.18 54.31L103.18,54.31A48.88,48.88 0,0 1,54.31 103.18L54.31,103.18A48.88,48.88 0,0 1,5.43 54.31L5.43,54.31A48.88,48.88 0,0 1,54.31 5.43z"/>
<path
android:fillAlpha="1"
android:fillColor="#fff"
android:pathData="M65.83,37.53m-6.92,0a6.92,6.92 0,1 1,13.84 0a6.92,6.92 0,1 1,-13.84 0"/>
<path
android:fillAlpha="1"
android:fillColor="#fff"
android:pathData="M68.13,56.37l-7.11,10.13l-14.7,-21.2l-21.02,30.59l54.71,0l-11.88,-19.52z"/>
</vector>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/color_primary"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/color_primary"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

View file

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Simple Gallery</string>
<string name="app_launcher_name">Galerija</string>
<string name="edit">Uredi</string>
<string name="open_camera">Otvori kameru</string>
<string name="hidden">(skriveno)</string>
<string name="pin_folder">Prikači direktorij</string>
<string name="unpin_folder">Otkači direktorij</string>
<string name="show_all">Prikaži cijeli sadržaj direktorija</string>
<string name="all_folders">Svi direktoriji</string>
<string name="folder_view">Prebaci se na pogled direktorija</string>
<string name="other_folder">Ostali direktoriji</string>
<string name="show_on_map">Prikaži na karti</string>
<string name="unknown_location">Nepoznata lokacija</string>
<string name="no_map_application">Nije pronađena aplikacija za kartame</string>
<string name="no_camera_app_found">Nije pronađena aplikacija za kameru</string>
<string name="increase_column_count">Povećaj broj stupaca</string>
<string name="reduce_column_count">Smanji broj stupaca</string>
<string name="change_cover_image">Promjeni naslovnu sliku</string>
<string name="select_photo">Odaberi sliku</string>
<string name="use_default">Koristi zadano</string>
<string name="volume">Glasnoća</string>
<string name="brightness">Svjetlina</string>
<string name="do_not_ask_again">Ne pitaj me više u ovoj sesiji</string>
<string name="lock_orientation">Zaključaj orijentaciju</string>
<string name="unlock_orientation">Otključaj orijentaciju</string>
<!-- Filter -->
<string name="filter_media">Filtriraj slike i videe</string>
<string name="images">Slike</string>
<string name="videos">Videi</string>
<string name="gifs">GIFovi</string>
<string name="no_media_with_filters">Nije pronađena nijedna datoteka s odabranim filterom.</string>
<string name="change_filters_underlined"><u>Promjeni filter</u></string>
<!-- Hide / Exclude -->
<string name="hide_folder_description">Ova funkcija skriva direktorij dodavajući \'.nomedia\' datoteku u njega. Također će sakriti i sve poddirektorije. Možete ih vidjeti uključivanjem opcije \'Show hidden folders\' u Postavkama. Nastaviti?</string>
<string name="exclude">Izostavi</string>
<string name="excluded_folders">Izostavljeni direktoriji</string>
<string name="manage_excluded_folders">Upravljaj izostavljenim direktorijima</string>
<string name="exclude_folder_description">Ovo će izostaviti izabrano zajedno s poddirektorijima samo iz Simple Gallery aplikacije. Možete upravljati izostavljenim direktorijima u Postavkama.</string>
<string name="exclude_folder_parent">Izostavi glavni direktorij umjesto?</string>
<string name="excluded_activity_placeholder">Izostavljanje direktorija učiniti će ih nevidljivim zajedno s njihovim poddirektorijima samo u Simple Gallery, ali će oni biti vidljivi u drugim aplikacijama.\n\nAko ih želite sakriti od drugih aplikacija također, koristite Sakrij opciju.</string>
<string name="remove_all">Ukloni sve</string>
<string name="remove_all_description">Ukloni sve direktorije iz liste izostavljenih? Ovo neće izbrisati direktorije.</string>
<!-- Include folders -->
<string name="include_folders">Dodaj direktorije</string>
<string name="manage_included_folders">Upravljaj dodanim direktorijima</string>
<string name="add_folder">Dodaj direktorij</string>
<string name="included_activity_placeholder">Ako postoji direktorij koji sadrži slike i video sadržaj, ali ga aplikacija ne prepoznaje, možete ih ručno dodati ovdje.\n\nDodavanjem nekoliko stavki ovdje, neće se izostaviti niti jedan drugi direktorij.</string>
<!-- Resizing -->
<string name="resize">Promjeni veličinu</string>
<string name="resize_and_save">Promjeni veličinu odabranog i spremi</string>
<string name="width">Širina</string>
<string name="height">Visina</string>
<string name="keep_aspect_ratio">Zadrži omjer slike</string>
<string name="invalid_values">Molimo unesite valjanu rezoluciju</string>
<!-- Editor -->
<string name="editor">Uređivač</string>
<string name="save">Spremi</string>
<string name="rotate">Rotiraj</string>
<string name="path">Putanja</string>
<string name="invalid_image_path">Neispravna putanja slike</string>
<string name="image_editing_failed">Neuspješno uređivanje slike</string>
<string name="edit_image_with">Uredi sliku s:</string>
<string name="no_editor_found">Nije pronađen uređivač slika</string>
<string name="unknown_file_location">Nepoznata lokacija datoteke</string>
<string name="error_saving_file">Nije moguće presnimiti izvornu datoteku</string>
<string name="rotate_left">Rotiraj lijevo</string>
<string name="rotate_right">Rotiraj desno</string>
<string name="rotate_one_eighty">Rotiraj za 180º</string>
<string name="flip">Okreni</string>
<string name="flip_horizontally">Okreni horizontalno</string>
<string name="flip_vertically">Okreni vertikalno</string>
<string name="edit_with">Uredi s</string>
<!-- Set wallpaper -->
<string name="simple_wallpaper">Jednostavna pozadina</string>
<string name="set_as_wallpaper">Postavi kao pozadinu</string>
<string name="set_as_wallpaper_failed">Neuspješno postavljanje pozadine</string>
<string name="set_as_wallpaper_with">Postavi kao pozadinu s:</string>
<string name="no_capable_app_found">Nije pronađena aplikacija s ovim mogućnostima</string>
<string name="setting_wallpaper">Postavljanje pozadine&#8230;</string>
<string name="wallpaper_set_successfully">Uspješno postavljanje pozadine</string>
<string name="portrait_aspect_ratio">Portretni omjer slike</string>
<string name="landscape_aspect_ratio">Pejzažni omjer slike</string>
<!-- Slideshow -->
<string name="slideshow">Dijaprojekcija</string>
<string name="interval">Interval (sekunde):</string>
<string name="include_photos">Dodaj slike</string>
<string name="include_videos">Dodaj videe</string>
<string name="include_gifs">Dodaj GIFove</string>
<string name="random_order">Nasumični redoslijed</string>
<string name="use_fade">Koristi animaciju izbljeđivanja</string>
<string name="move_backwards">Pomakni unatrag</string>
<string name="loop_slideshow">Prikaži dijaprojekciju kao petlju</string>
<string name="slideshow_ended">Kraj dijaprojekcije</string>
<string name="no_media_for_slideshow">Nema datoteka za dijaprojekciju</string>
<!-- View types -->
<string name="change_view_type">Promjeni način pregleda</string>
<string name="grid">Rešetka</string>
<string name="list">Lista</string>
<!-- Settings -->
<string name="show_hidden_media">Prikaži skrivene datoteke</string>
<string name="autoplay_videos">Automatsko pokretanje videa</string>
<string name="toggle_filename">Uključi prikaz naziva datoteka</string>
<string name="loop_videos">Ponavljanje videa</string>
<string name="animate_gifs">Prikaz animacije GIFova na sličicama</string>
<string name="max_brightness">Maksimalna svjetlina pri pregledu datoteka</string>
<string name="crop_thumbnails">Izreži sličice u kvadrate</string>
<string name="screen_rotation_by">Rotiraj datoteku u punom zaslonu za</string>
<string name="screen_rotation_system_setting">Postavke sustava</string>
<string name="screen_rotation_device_rotation">Rotacija uređaja</string>
<string name="screen_rotation_aspect_ratio">Omjer slike</string>
<string name="dark_background_at_fullscreen">Crna pozadina pri pregledu datoteka</string>
<string name="scroll_thumbnails_horizontally">Listaj sličice horizontalno</string>
<string name="hide_system_ui_at_fullscreen">Automatski sakrij UI sustava pri pregledu datoteka</string>
<string name="delete_empty_folders">Izbriži prazne direktorije nakon brisanja njihovog sadržaja</string>
<string name="allow_video_gestures">Omogući kontrolu glasnoće videa i svjetline pomoću vertikalnih gesti</string>
<string name="show_media_count">Prikaži broj datoteka u direktoriju na glavnom zaslonu</string>
<string name="replace_share_with_rotate">Zamjeni Dijeli s Rotiraj pri pregledu datoteka</string>
<string name="show_extended_details">Prikaži detaljne informacije pri pregledu datoteka</string>
<string name="manage_extended_details">Upravljaj detaljnim informacijama</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
<string name="app_short_description">Galerija za pregledavanje slika, GIFova i videa bez reklama.</string>
<string name="app_long_description">
Jednostavan alat za pregled slika, GIFova i videa. Datoteke možete sortirati po datumu, veličini, imenu i to uzlazno i silazno. Također možete zumirati slike. Medijski sadržaj se prikazuje u višestrukim stupcima ovisno o veličini ekrana, a vi samo možete birati broj stupaca s gestom štipkanja. Možete preimenovati, dijeliti, brisati, kopirati, premještati datoteke. Slike također možete izrezati, rotirati ili postaviki kao pozadinu ekrana, odmah iz aplikacije.
Galerija se također može koristiti za pregledavanje slika i videa u drugim aplikacijama, prikačivanja datoteka u e-mail aplikacije itd. Savršeno za svakodnevno korištenje.
Ne sadrži reklame niti nepotrebna dopuštenja. Aplikacije je otvorenog koda, te pruža mogućnost promjene boja.
Ova aplikacija je samo dio veće skupine aplikacije. Ostatak možete pronaći na http://www.simplemobiletools.com
</string>
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View file

@ -1,7 +0,0 @@
<resources>
<style name="FullScreenTheme" parent="FullScreenTheme.Base">
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>

View file

@ -22,9 +22,9 @@
<string name="use_default">使用預設</string>
<string name="volume">音量</string>
<string name="brightness">亮度</string>
<string name="do_not_ask_again">Do not ask again in this session</string>
<string name="lock_orientation">Lock orientation</string>
<string name="unlock_orientation">Unlock orientation</string>
<string name="do_not_ask_again">這情況不再詢問</string>
<string name="lock_orientation">鎖定方向</string>
<string name="unlock_orientation">解除鎖定方向</string>
<!-- Filter -->
<string name="filter_media">篩選媒體檔案</string>
@ -92,20 +92,20 @@
<!-- Slideshow -->
<string name="slideshow">投影片</string>
<string name="interval">間隔 (秒):</string>
<string name="include_photos">Include photos</string>
<string name="include_photos">包含照片</string>
<string name="include_videos">包含影片</string>
<string name="include_gifs">Include GIFs</string>
<string name="include_gifs">包含GIF</string>
<string name="random_order">隨機順序</string>
<string name="use_fade">使用淡入淡出動畫</string>
<string name="move_backwards">反向播放</string>
<string name="loop_slideshow">Loop slideshow</string>
<string name="loop_slideshow">投影片循環</string>
<string name="slideshow_ended">投影片結束</string>
<string name="no_media_for_slideshow">找不到投影片的媒體檔案</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<string name="change_view_type">改變瀏覽類型</string>
<string name="grid">格狀</string>
<string name="list">列表</string>
<!-- Settings -->
<string name="show_hidden_media">顯示隱藏的媒體檔案</string>
@ -124,10 +124,10 @@
<string name="hide_system_ui_at_fullscreen">全螢幕時自動隱藏系統介面</string>
<string name="delete_empty_folders">刪除內容後刪除空白資料夾</string>
<string name="allow_video_gestures">允許用上下手勢來控制影片的音量和亮度</string>
<string name="show_media_count">Show folder media count on the main view</string>
<string name="show_media_count">主畫面顯示資料夾內媒體檔案數量</string>
<string name="replace_share_with_rotate">將全螢幕選單的分享取代為旋轉</string>
<string name="show_extended_details">Show extended details over fullscreen media</string>
<string name="manage_extended_details">Manage extended details</string>
<string name="show_extended_details">全螢幕時顯示詳細資訊</string>
<string name="manage_extended_details">管理詳細資訊</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View file

@ -5,6 +5,6 @@
<color name="circle_black_background">#66000000</color>
<!-- Default colors -->
<color name="default_text_color">@color/default_dark_theme_text_color</color>
<color name="default_background_color">@color/default_dark_theme_background_color</color>
<color name="default_text_color">@color/theme_dark_text_color</color>
<color name="default_background_color">@color/theme_dark_background_color</color>
</resources>

View file

@ -2,16 +2,4 @@
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="FullScreenTheme.Base" parent="AppTheme">
<item name="android:windowContentOverlay">@null</item>
<item name="actionBarStyle">@style/MyFullScreenActionBar</item>
<item name="android:actionBarStyle">@style/MyFullScreenActionBar</item>
</style>
<style name="FullScreenTheme" parent="FullScreenTheme.Base"/>
<style name="MyFullScreenActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
</style>
</resources>

View file

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.60'
ext.kotlin_version = '1.2.0'
repositories {
jcenter()