Merge pull request #39 from SimpleMobileTools/master

upd
This commit is contained in:
solokot 2018-10-25 23:37:36 +03:00 committed by GitHub
commit 3ac7b158b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 88 additions and 71 deletions

View file

@ -1,6 +1,11 @@
Changelog Changelog
========== ==========
Version 5.1.1 *(2018-10-23)*
----------------------------
* Fixing the inability to delete SD card files
Version 5.1.0 *(2018-10-23)* Version 5.1.0 *(2018-10-23)*
---------------------------- ----------------------------

View file

@ -11,8 +11,8 @@ android {
applicationId "com.simplemobiletools.gallery" applicationId "com.simplemobiletools.gallery"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode 204 versionCode 205
versionName "5.1.0" versionName "5.1.1"
multiDexEnabled true multiDexEnabled true
setProperty("archivesBaseName", "gallery") setProperty("archivesBaseName", "gallery")
} }
@ -48,7 +48,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.2.0' implementation 'com.simplemobiletools:commons:5.2.8'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'androidx.multidex:multidex:2.0.0' implementation 'androidx.multidex:multidex:2.0.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -982,10 +982,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
private fun refreshViewPager() { private fun refreshViewPager() {
if (config.getFileSorting(mDirectory) and SORT_BY_RANDOM == 0) {
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) { GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
gotMedia(it) gotMedia(it)
}.execute() }.execute()
} }
}
private fun gotMedia(thumbnailItems: ArrayList<ThumbnailItem>) { private fun gotMedia(thumbnailItems: ArrayList<ThumbnailItem>) {
val media = thumbnailItems.filter { it is Medium }.map { it as Medium } as ArrayList<Medium> val media = thumbnailItems.filter { it is Medium }.map { it as Medium } as ArrayList<Medium>

View file

@ -1,9 +1,10 @@
package com.simplemobiletools.gallery.databases package com.simplemobiletools.gallery.databases
import android.content.Context
import androidx.room.Database import androidx.room.Database
import androidx.room.Room import androidx.room.Room
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
import android.content.Context import com.simplemobiletools.gallery.objects.MyExecutor
import com.simplemobiletools.gallery.interfaces.DirectoryDao import com.simplemobiletools.gallery.interfaces.DirectoryDao
import com.simplemobiletools.gallery.interfaces.MediumDao import com.simplemobiletools.gallery.interfaces.MediumDao
import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Directory
@ -25,6 +26,7 @@ abstract class GalleryDatabase : RoomDatabase() {
if (db == null) { if (db == null) {
db = Room.databaseBuilder(context.applicationContext, GalleryDatabase::class.java, "gallery.db") db = Room.databaseBuilder(context.applicationContext, GalleryDatabase::class.java, "gallery.db")
.fallbackToDestructiveMigration() .fallbackToDestructiveMigration()
.setQueryExecutor(MyExecutor.myExecutor)
.build() .build()
db!!.openHelper.setWriteAheadLoggingEnabled(true) db!!.openHelper.setWriteAheadLoggingEnabled(true)
} }

View file

@ -47,6 +47,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size 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_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken
currSorting and SORT_BY_RANDOM != 0 -> sortingRadio.sorting_dialog_radio_random
else -> sortingRadio.sorting_dialog_radio_name else -> sortingRadio.sorting_dialog_radio_name
} }
sortBtn.isChecked = true sortBtn.isChecked = true
@ -69,6 +70,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
R.id.sorting_dialog_radio_path -> SORT_BY_PATH R.id.sorting_dialog_radio_path -> SORT_BY_PATH
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
R.id.sorting_dialog_radio_last_modified -> SORT_BY_DATE_MODIFIED R.id.sorting_dialog_radio_last_modified -> SORT_BY_DATE_MODIFIED
R.id.sorting_dialog_radio_random -> SORT_BY_RANDOM
else -> SORT_BY_DATE_TAKEN else -> SORT_BY_DATE_TAKEN
} }

View file

@ -1,15 +1,10 @@
package com.simplemobiletools.gallery.dialogs package com.simplemobiletools.gallery.dialogs
import android.graphics.Point import android.graphics.Point
import androidx.appcompat.app.AlertDialog
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.showKeyboard
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import kotlinx.android.synthetic.main.resize_image.view.* import kotlinx.android.synthetic.main.resize_image.view.*
@ -24,8 +19,7 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
val ratio = size.x / size.y.toFloat() val ratio = size.x / size.y.toFloat()
widthView.addTextChangedListener(object : TextWatcher { widthView.onTextChangeListener {
override fun afterTextChanged(s: Editable?) {
if (widthView.hasFocus()) { if (widthView.hasFocus()) {
var width = getViewValue(widthView) var width = getViewValue(widthView)
if (width > size.x) { if (width > size.x) {
@ -39,15 +33,7 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
} }
} }
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { heightView.onTextChangeListener {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
})
heightView.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
if (heightView.hasFocus()) { if (heightView.hasFocus()) {
var height = getViewValue(heightView) var height = getViewValue(heightView)
if (height > size.y) { if (height > size.y) {
@ -61,13 +47,6 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
} }
} }
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
})
AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)

View file

@ -139,6 +139,11 @@ fun Context.getSortedDirectories(source: ArrayList<Directory>): ArrayList<Direct
val sorting = config.directorySorting val sorting = config.directorySorting
val dirs = source.clone() as ArrayList<Directory> val dirs = source.clone() as ArrayList<Directory>
if (sorting and SORT_BY_RANDOM != 0) {
dirs.shuffle()
return movePinnedDirectoriesToFront(dirs)
}
dirs.sortWith(Comparator { o1, o2 -> dirs.sortWith(Comparator { o1, o2 ->
o1 as Directory o1 as Directory
o2 as Directory o2 as Directory

View file

@ -344,6 +344,11 @@ class MediaFetcher(val context: Context) {
} }
fun sortMedia(media: ArrayList<Medium>, sorting: Int) { fun sortMedia(media: ArrayList<Medium>, sorting: Int) {
if (sorting and SORT_BY_RANDOM != 0) {
media.shuffle()
return
}
media.sortWith(Comparator { o1, o2 -> media.sortWith(Comparator { o1, o2 ->
o1 as Medium o1 as Medium
o2 as Medium o2 as Medium

View file

@ -0,0 +1,7 @@
package com.simplemobiletools.gallery.objects
import java.util.concurrent.Executors
object MyExecutor {
val myExecutor = Executors.newSingleThreadExecutor()
}

View file

@ -11,8 +11,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin" android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"> android:paddingRight="@dimen/activity_margin">
<RadioGroup <RadioGroup
android:id="@+id/sorting_dialog_radio_sorting" android:id="@+id/sorting_dialog_radio_sorting"
@ -24,42 +24,50 @@
android:id="@+id/sorting_dialog_radio_name" android:id="@+id/sorting_dialog_radio_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/name"/> android:text="@string/name"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_path" android:id="@+id/sorting_dialog_radio_path"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/path"/> android:text="@string/path"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_size" android:id="@+id/sorting_dialog_radio_size"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/size"/> android:text="@string/size"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_last_modified" android:id="@+id/sorting_dialog_radio_last_modified"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/last_modified"/> android:text="@string/last_modified"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_date_taken" android:id="@+id/sorting_dialog_radio_date_taken"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/date_taken"/> android:text="@string/date_taken"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_random"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/random"/>
</RadioGroup> </RadioGroup>
<include <include
@ -76,16 +84,16 @@
android:id="@+id/sorting_dialog_radio_ascending" android:id="@+id/sorting_dialog_radio_ascending"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/ascending"/> android:text="@string/ascending"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_descending" android:id="@+id/sorting_dialog_radio_descending"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/descending"/> android:text="@string/descending"/>
</RadioGroup> </RadioGroup>
@ -97,8 +105,8 @@
android:id="@+id/sorting_dialog_use_for_this_folder" android:id="@+id/sorting_dialog_use_for_this_folder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/use_for_this_folder"/> android:text="@string/use_for_this_folder"/>
</LinearLayout> </LinearLayout>

View file

@ -5,7 +5,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/activity_margin"> android:paddingLeft="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/image_width_label" android:id="@+id/image_width_label"
@ -29,8 +31,8 @@
android:id="@+id/image_height_label" android:id="@+id/image_height_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginStart="50dp" android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:layout_toRightOf="@+id/image_width_label" android:layout_toRightOf="@+id/image_width_label"
android:text="@string/height"/> android:text="@string/height"/>
@ -38,9 +40,9 @@
android:id="@+id/image_height" android:id="@+id/image_height"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/image_height_label"
android:layout_alignStart="@+id/image_height_label"
android:layout_below="@+id/image_width_label" android:layout_below="@+id/image_width_label"
android:layout_alignStart="@+id/image_height_label"
android:layout_alignLeft="@+id/image_height_label"
android:inputType="number" android:inputType="number"
android:maxLength="6" android:maxLength="6"
android:maxLines="1" android:maxLines="1"
@ -54,8 +56,8 @@
android:layout_below="@+id/image_height" android:layout_below="@+id/image_height"
android:layout_marginTop="@dimen/activity_margin" android:layout_marginTop="@dimen/activity_margin"
android:checked="true" android:checked="true"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/keep_aspect_ratio"/> android:text="@string/keep_aspect_ratio"/>
</RelativeLayout> </RelativeLayout>

View file

@ -162,7 +162,7 @@
<string name="deep_zoomable_images">Immagini ingrandibili a fondo</string> <string name="deep_zoomable_images">Immagini ingrandibili a fondo</string>
<string name="show_highest_quality">Mostra le immagini alla massima qualità possibile</string> <string name="show_highest_quality">Mostra le immagini alla massima qualità possibile</string>
<string name="show_recycle_bin_last">Mostra il cestino come ultimo elemento nella schermata principale</string> <string name="show_recycle_bin_last">Mostra il cestino come ultimo elemento nella schermata principale</string>
<string name="allow_down_gesture">Allow closing the fullscreen view with a down gesture</string> <string name="allow_down_gesture">Chiudi la visuale a schermo intero con un gesto verso il basso</string>
<!-- Setting sections --> <!-- Setting sections -->
<string name="thumbnails">Miniature</string> <string name="thumbnails">Miniature</string>

View file

@ -146,8 +146,8 @@
<string name="scroll_thumbnails_horizontally">Horizontaal scrollen</string> <string name="scroll_thumbnails_horizontally">Horizontaal scrollen</string>
<string name="hide_system_ui_at_fullscreen">Statusbalk automatisch verbergen in volledig scherm</string> <string name="hide_system_ui_at_fullscreen">Statusbalk automatisch verbergen in volledig scherm</string>
<string name="delete_empty_folders">Lege mappen verwijderen na leegmaken</string> <string name="delete_empty_folders">Lege mappen verwijderen na leegmaken</string>
<string name="allow_photo_gestures">Helderheid voor afbeeldingen aanpassen met verticale gebaren</string> <string name="allow_photo_gestures">Helderheid voor afbeeldingen aanpassen met verticale veeggebaren</string>
<string name="allow_video_gestures">Volume en helderheid voor video\'s aanpassen met verticale gebaren</string> <string name="allow_video_gestures">Volume en helderheid voor video\'s aanpassen met verticale veeggebaren</string>
<string name="show_media_count">Aantallen in mappen tonen</string> <string name="show_media_count">Aantallen in mappen tonen</string>
<string name="replace_share_with_rotate">Menu-item Draaien vastzetten in volledig scherm (in plaats van Delen)</string> <string name="replace_share_with_rotate">Menu-item Draaien vastzetten in volledig scherm (in plaats van Delen)</string>
<string name="show_extended_details">Uitgebreide informatie tonen in volledig scherm</string> <string name="show_extended_details">Uitgebreide informatie tonen in volledig scherm</string>
@ -162,7 +162,7 @@
<string name="deep_zoomable_images">Afbeeldingen ver inzoomen</string> <string name="deep_zoomable_images">Afbeeldingen ver inzoomen</string>
<string name="show_highest_quality">Afbeeldingen in de hoogst mogelijke kwaliteit weergeven</string> <string name="show_highest_quality">Afbeeldingen in de hoogst mogelijke kwaliteit weergeven</string>
<string name="show_recycle_bin_last">Prullenbak als laatste item tonen</string> <string name="show_recycle_bin_last">Prullenbak als laatste item tonen</string>
<string name="allow_down_gesture">Allow closing the fullscreen view with a down gesture</string> <string name="allow_down_gesture">Naar beneden vegen om volledig scherm af te sluiten</string>
<!-- Setting sections --> <!-- Setting sections -->
<string name="thumbnails">Miniatuurvoorbeelden</string> <string name="thumbnails">Miniatuurvoorbeelden</string>

View file

@ -142,7 +142,7 @@
<string name="screen_rotation_system_setting">系统设置</string> <string name="screen_rotation_system_setting">系统设置</string>
<string name="screen_rotation_device_rotation">设备方向</string> <string name="screen_rotation_device_rotation">设备方向</string>
<string name="screen_rotation_aspect_ratio">根据长宽比</string> <string name="screen_rotation_aspect_ratio">根据长宽比</string>
<string name="black_background_at_fullscreen">全屏时使用黑色背景和状态栏</string> <string name="black_background_at_fullscreen">全屏时使用黑色背景和状态栏</string>
<string name="scroll_thumbnails_horizontally">水平滚动缩略图</string> <string name="scroll_thumbnails_horizontally">水平滚动缩略图</string>
<string name="hide_system_ui_at_fullscreen">全屏时自动隐藏状态栏</string> <string name="hide_system_ui_at_fullscreen">全屏时自动隐藏状态栏</string>
<string name="delete_empty_folders">删除没有内容的空文件夹</string> <string name="delete_empty_folders">删除没有内容的空文件夹</string>
@ -162,7 +162,7 @@
<string name="deep_zoomable_images">深度放大图像</string> <string name="deep_zoomable_images">深度放大图像</string>
<string name="show_highest_quality">以最高质量显示图像</string> <string name="show_highest_quality">以最高质量显示图像</string>
<string name="show_recycle_bin_last">在主屏幕界面的最后一项显示回收站</string> <string name="show_recycle_bin_last">在主屏幕界面的最后一项显示回收站</string>
<string name="allow_down_gesture">Allow closing the fullscreen view with a down gesture</string> <string name="allow_down_gesture">使用下滑手势关闭全屏视图</string>
<!-- Setting sections --> <!-- Setting sections -->
<string name="thumbnails">缩略图</string> <string name="thumbnails">缩略图</string>