Merge pull request #1 from SimpleMobileTools/master

merge
This commit is contained in:
fiepi 2017-05-28 20:01:00 -05:00 committed by GitHub
commit 742a17582e
8 changed files with 87 additions and 81 deletions

View file

@ -32,7 +32,7 @@ android {
} }
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.18.5' compile 'com.simplemobiletools:commons:2.18.8'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'

View file

@ -127,8 +127,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.removeCallbacksAndMessages(null)
} }
override fun onStop() { override fun onDestroy() {
super.onStop() super.onDestroy()
config.temporarilyShowHidden = false config.temporarilyShowHidden = false
} }
@ -342,9 +342,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} }
private fun storeDirectories() { private fun storeDirectories() {
if (!config.temporarilyShowHidden) {
val directories = Gson().toJson(mDirs) val directories = Gson().toJson(mDirs)
config.directories = directories config.directories = directories
} }
}
private fun setupAdapter() { private fun setupAdapter() {
val adapter = DirectoryAdapter(this, mDirs, this) { val adapter = DirectoryAdapter(this, mDirs, this) {

View file

@ -92,8 +92,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.removeCallbacksAndMessages(null)
} }
override fun onStop() { override fun onDestroy() {
super.onStop() super.onDestroy()
config.temporarilyShowHidden = false config.temporarilyShowHidden = false
} }
@ -399,10 +399,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} }
private fun storeFolder() { private fun storeFolder() {
if (!config.temporarilyShowHidden) {
val subList = mMedia.subList(0, Math.min(SAVE_MEDIA_CNT, mMedia.size)) val subList = mMedia.subList(0, Math.min(SAVE_MEDIA_CNT, mMedia.size))
val json = Gson().toJson(subList) val json = Gson().toJson(subList)
config.saveFolderMedia(mPath, json) config.saveFolderMedia(mPath, json)
} }
}
override fun deleteFiles(files: ArrayList<File>) { override fun deleteFiles(files: ArrayList<File>) {
val filtered = files.filter { it.isImageVideoGif() } as ArrayList val filtered = files.filter { it.isImageVideoGif() } as ArrayList

View file

@ -145,7 +145,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
fun checkHideBtnVisibility(menu: Menu) { fun checkHideBtnVisibility(menu: Menu) {
var hiddenCnt = 0 var hiddenCnt = 0
var unhiddenCnt = 0 var unhiddenCnt = 0
selectedPositions.map { dirs[it].path }.forEach { selectedPositions.map { dirs.getOrNull(it)?.path }.filterNotNull().forEach {
if (File(it).containsNoMedia()) if (File(it).containsNoMedia())
hiddenCnt++ hiddenCnt++
else else
@ -160,7 +160,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
val pinnedFolders = config.pinnedFolders val pinnedFolders = config.pinnedFolders
var pinnedCnt = 0 var pinnedCnt = 0
var unpinnedCnt = 0 var unpinnedCnt = 0
selectedPositions.map { dirs[it].path }.forEach { selectedPositions.map { dirs.getOrNull(it)?.path }.filterNotNull().forEach {
if (pinnedFolders.contains(it)) if (pinnedFolders.contains(it))
pinnedCnt++ pinnedCnt++
else else

View file

@ -140,7 +140,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
fun checkHideBtnVisibility(menu: Menu) { fun checkHideBtnVisibility(menu: Menu) {
var hiddenCnt = 0 var hiddenCnt = 0
var unhiddenCnt = 0 var unhiddenCnt = 0
selectedPositions.map { media[it] }.forEach { selectedPositions.map { media.getOrNull(it) }.filterNotNull().forEach {
if (it.name.startsWith('.')) if (it.name.startsWith('.'))
hiddenCnt++ hiddenCnt++
else else

View file

@ -58,9 +58,7 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo
val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%") val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%")
val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath))
cur.use { cur ->
return parseCursor(this, cur, isPickImage, isPickVideo, curPath) return parseCursor(this, cur, isPickImage, isPickVideo, curPath)
}
} }
private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList<Medium> { private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList<Medium> {
@ -69,6 +67,7 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
val showMedia = config.showMedia val showMedia = config.showMedia
val showHidden = config.shouldShowHidden val showHidden = config.shouldShowHidden
cur.use { cur ->
if (cur.moveToFirst()) { if (cur.moveToFirst()) {
var filename: String var filename: String
var path: String var path: String
@ -142,6 +141,7 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
} }
} while (cur.moveToNext()) } while (cur.moveToNext())
} }
}
Medium.sorting = config.getFileSorting(curPath) Medium.sorting = config.getFileSorting(curPath)
curMedia.sort() curMedia.sort()

View file

@ -306,8 +306,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
return return
initMediaPlayer() initMediaPlayer()
if (mMediaPlayer == null) if (mMediaPlayer == null) {
activity.toast(R.string.unknown_error_occurred) activity.toast(R.string.unknown_error_occurred)
return
}
val videoProportion = mMediaPlayer!!.videoWidth.toFloat() / mMediaPlayer!!.videoHeight.toFloat() val videoProportion = mMediaPlayer!!.videoWidth.toFloat() / mMediaPlayer!!.videoHeight.toFloat()
val display = activity.windowManager.defaultDisplay val display = activity.windowManager.defaultDisplay

View file

@ -74,7 +74,7 @@
<string name="setting_wallpaper">A definir como fundo de ecrã&#8230;</string> <string name="setting_wallpaper">A definir como fundo de ecrã&#8230;</string>
<string name="wallpaper_set_successfully">Fundo definido com sucesso</string> <string name="wallpaper_set_successfully">Fundo definido com sucesso</string>
<string name="portrait_aspect_ratio">Proporção na vertical</string> <string name="portrait_aspect_ratio">Proporção na vertical</string>
<string name="landscape_aspect_ratio">proporção na horizontal</string> <string name="landscape_aspect_ratio">Proporção na horizontal</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Mostrar pastas ocultas</string> <string name="show_hidden_media">Mostrar pastas ocultas</string>
@ -83,8 +83,8 @@
<string name="show_media">Mostrar multimédia</string> <string name="show_media">Mostrar multimédia</string>
<string name="images">Apenas imagens</string> <string name="images">Apenas imagens</string>
<string name="videos">Apenas vídeos</string> <string name="videos">Apenas vídeos</string>
<string name="gifs">Gifs only</string> <string name="gifs">Apenas gifs</string>
<string name="images_videos_gifs">Images, videos, gifs</string> <string name="images_videos_gifs">Imagens, vídeos e gifs</string>
<string name="images_and_videos">Imagens e vídeos</string> <string name="images_and_videos">Imagens e vídeos</string>
<string name="loop_videos">Vídeos em ciclo</string> <string name="loop_videos">Vídeos em ciclo</string>
<string name="animate_gifs">Animação de gifs nas miniaturas</string> <string name="animate_gifs">Animação de gifs nas miniaturas</string>