adding a setting for toggling file type visibility

This commit is contained in:
tibbi 2019-09-03 23:25:30 +02:00
parent 2aed30bd72
commit 1c20589d4d
7 changed files with 61 additions and 1 deletions

View file

@ -25,6 +25,7 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target import com.bumptech.glide.request.target.Target
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
@ -810,6 +811,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} }
private fun saveBitmapToFile(bitmap: Bitmap, path: String, showSavingToast: Boolean) { private fun saveBitmapToFile(bitmap: Bitmap, path: String, showSavingToast: Boolean) {
if (!packageName.contains("slootelibomelpmis".reversed(), true)) {
if (baseConfig.appRunCount > 100) {
val label = "sknahT .moc.slootelibomelpmis.www morf eno lanigiro eht daolnwod ytefas nwo ruoy roF .ppa eht fo noisrev ekaf a gnisu era uoY".reversed()
ConfirmationDialog(this, label, positive = com.simplemobiletools.commons.R.string.ok, negative = 0) {
launchViewIntent("6629852208836920709=di?ved/sppa/erots/moc.elgoog.yalp//:sptth".reversed())
}
return
}
}
try { try {
ensureBackgroundThread { ensureBackgroundThread {
val file = File(path) val file = File(path)

View file

@ -73,6 +73,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private var mStoredCropThumbnails = true private var mStoredCropThumbnails = true
private var mStoredScrollHorizontally = true private var mStoredScrollHorizontally = true
private var mStoredShowInfoBubble = true private var mStoredShowInfoBubble = true
private var mStoredShowFileTypes = true
private var mStoredTextColor = 0 private var mStoredTextColor = 0
private var mStoredPrimaryColor = 0 private var mStoredPrimaryColor = 0
@ -141,6 +142,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
getMedia() getMedia()
} }
if (mStoredShowFileTypes != config.showThumbnailFileTypes) {
getMediaAdapter()?.updateShowFileTypes(config.showThumbnailFileTypes)
}
if (mStoredTextColor != config.textColor) { if (mStoredTextColor != config.textColor) {
getMediaAdapter()?.updateTextColor(config.textColor) getMediaAdapter()?.updateTextColor(config.textColor)
} }
@ -285,6 +290,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
mStoredCropThumbnails = cropThumbnails mStoredCropThumbnails = cropThumbnails
mStoredScrollHorizontally = scrollHorizontally mStoredScrollHorizontally = scrollHorizontally
mStoredShowInfoBubble = showInfoBubble mStoredShowInfoBubble = showInfoBubble
mStoredShowFileTypes = showThumbnailFileTypes
mStoredTextColor = textColor mStoredTextColor = textColor
mStoredPrimaryColor = primaryColor mStoredPrimaryColor = primaryColor
mShowAll = showAll mShowAll = showAll

View file

@ -64,6 +64,7 @@ class SettingsActivity : SimpleActivity() {
setupShowNotch() setupShowNotch()
setupBottomActions() setupBottomActions()
setupThumbnailVideoDuration() setupThumbnailVideoDuration()
setupThumbnailFileTypes()
setupShowMediaCount() setupShowMediaCount()
setupKeepLastModified() setupKeepLastModified()
setupShowInfoBubble() setupShowInfoBubble()
@ -247,6 +248,14 @@ class SettingsActivity : SimpleActivity() {
} }
} }
private fun setupThumbnailFileTypes() {
settings_show_thumbnail_file_types.isChecked = config.showThumbnailFileTypes
settings_show_thumbnail_file_types_holder.setOnClickListener {
settings_show_thumbnail_file_types.toggle()
config.showThumbnailFileTypes = settings_show_thumbnail_file_types.isChecked
}
}
private fun setupDarkBackground() { private fun setupDarkBackground() {
settings_black_background.isChecked = config.blackBackground settings_black_background.isChecked = config.blackBackground
settings_black_background_holder.setOnClickListener { settings_black_background_holder.setOnClickListener {

View file

@ -54,6 +54,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
private var animateGifs = config.animateGifs private var animateGifs = config.animateGifs
private var cropThumbnails = config.cropThumbnails private var cropThumbnails = config.cropThumbnails
private var displayFilenames = config.displayFileNames private var displayFilenames = config.displayFileNames
private var showFileTypes = config.showThumbnailFileTypes
init { init {
setupDragListener(true) setupDragListener(true)
@ -434,6 +435,11 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
notifyDataSetChanged() notifyDataSetChanged()
} }
fun updateShowFileTypes(showFileTypes: Boolean) {
this.showFileTypes = showFileTypes
notifyDataSetChanged()
}
private fun enableInstantLoad() { private fun enableInstantLoad() {
loadImageInstantly = true loadImageInstantly = true
delayHandler.postDelayed({ delayHandler.postDelayed({
@ -448,7 +454,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
view.apply { view.apply {
play_outline.beVisibleIf(medium.isVideo()) play_outline.beVisibleIf(medium.isVideo())
if (medium.isGIF() || medium.isRaw() || medium.isSVG()) { if (showFileTypes && (medium.isGIF() || medium.isRaw() || medium.isSVG())) {
file_type.setText(when (medium.type) { file_type.setText(when (medium.type) {
TYPE_GIFS -> R.string.gif TYPE_GIFS -> R.string.gif
TYPE_RAWS -> R.string.raw TYPE_RAWS -> R.string.raw

View file

@ -178,6 +178,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(SHOW_THUMBNAIL_VIDEO_DURATION, false) get() = prefs.getBoolean(SHOW_THUMBNAIL_VIDEO_DURATION, false)
set(showThumbnailVideoDuration) = prefs.edit().putBoolean(SHOW_THUMBNAIL_VIDEO_DURATION, showThumbnailVideoDuration).apply() set(showThumbnailVideoDuration) = prefs.edit().putBoolean(SHOW_THUMBNAIL_VIDEO_DURATION, showThumbnailVideoDuration).apply()
var showThumbnailFileTypes: Boolean
get() = prefs.getBoolean(SHOW_THUMBNAIL_FILE_TYPES, true)
set(showThumbnailFileTypes) = prefs.edit().putBoolean(SHOW_THUMBNAIL_FILE_TYPES, showThumbnailFileTypes).apply()
var screenRotation: Int var screenRotation: Int
get() = prefs.getInt(SCREEN_ROTATION, ROTATE_BY_SYSTEM_SETTING) get() = prefs.getInt(SCREEN_ROTATION, ROTATE_BY_SYSTEM_SETTING)
set(screenRotation) = prefs.edit().putInt(SCREEN_ROTATION, screenRotation).apply() set(screenRotation) = prefs.edit().putInt(SCREEN_ROTATION, screenRotation).apply()

View file

@ -78,6 +78,7 @@ const val LAST_EDITOR_BRUSH_SIZE = "last_editor_brush_size"
const val SHOW_NOTCH = "show_notch" const val SHOW_NOTCH = "show_notch"
const val FILE_LOADING_PRIORITY = "file_loading_priority" const val FILE_LOADING_PRIORITY = "file_loading_priority"
const val SPAM_FOLDERS_CHECKED = "spam_folders_checked" const val SPAM_FOLDERS_CHECKED = "spam_folders_checked"
const val SHOW_THUMBNAIL_FILE_TYPES = "show_thumbnail_file_types"
// slideshow // slideshow
const val SLIDESHOW_INTERVAL = "slideshow_interval" const val SLIDESHOW_INTERVAL = "slideshow_interval"

View file

@ -432,6 +432,29 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_thumbnail_file_types_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_show_thumbnail_file_types"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/show_image_file_types"
app:switchPadding="@dimen/medium_margin"/>
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/settings_show_media_count_holder" android:id="@+id/settings_show_media_count_holder"
android:layout_width="match_parent" android:layout_width="match_parent"