allow toggling folder name visibility at the widget config screen
This commit is contained in:
parent
dd537c63f3
commit
536eeaeee8
4 changed files with 51 additions and 23 deletions
|
@ -1048,18 +1048,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
}
|
||||
|
||||
val mediaTypes = curMedia.getDirMediaTypes()
|
||||
val dirName = when (path) {
|
||||
FAVORITES -> getString(R.string.favorites)
|
||||
RECYCLE_BIN -> getString(R.string.recycle_bin)
|
||||
else -> checkAppendingHidden(path, hiddenString, includedFolders)
|
||||
}
|
||||
|
||||
val firstItem = curMedia.first()
|
||||
val lastItem = curMedia.last()
|
||||
val dirName = checkAppendingHidden(path, hiddenString, includedFolders)
|
||||
val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified)
|
||||
val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken)
|
||||
val size = curMedia.sumByLong { it.size }
|
||||
val mediaTypes = curMedia.getDirMediaTypes()
|
||||
return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent
|
|||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.RemoteViews
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -45,7 +46,12 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
folder_picker_value.setOnClickListener { changeSelectedFolder() }
|
||||
config_image_holder.setOnClickListener { changeSelectedFolder() }
|
||||
folder_picker_show_folder_name.isChecked = config.showWidgetFolderName
|
||||
folder_picker_show_folder_name_holder.setOnClickListener { toggleFolderNameDisplay() }
|
||||
handleFolderNameDisplay()
|
||||
folder_picker_show_folder_name_holder.setOnClickListener {
|
||||
folder_picker_show_folder_name.toggle()
|
||||
handleFolderNameDisplay()
|
||||
}
|
||||
|
||||
updateTextColors(folder_picker_holder)
|
||||
folder_picker_holder.background = ColorDrawable(config.backgroundColor)
|
||||
|
||||
|
@ -124,6 +130,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
|
||||
private fun updateTextColor() {
|
||||
config_save.setTextColor(mTextColor)
|
||||
config_folder_name.setTextColor(mTextColor)
|
||||
config_text_color.setFillWithStroke(mTextColor, Color.BLACK)
|
||||
}
|
||||
|
||||
|
@ -146,13 +153,17 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun changeSelectedFolder() {
|
||||
PickDirectoryDialog(this, mFolderPath, false) {
|
||||
PickDirectoryDialog(this, "", false) {
|
||||
updateFolderImage(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateFolderImage(folderPath: String) {
|
||||
mFolderPath = folderPath
|
||||
runOnUiThread {
|
||||
config_folder_name.text = getFolderNameFromPath(folderPath)
|
||||
}
|
||||
|
||||
Thread {
|
||||
val path = directoryDB.getDirectoryThumbnail(folderPath)
|
||||
if (path != null) {
|
||||
|
@ -163,7 +174,9 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
}.start()
|
||||
}
|
||||
|
||||
private fun toggleFolderNameDisplay() {
|
||||
folder_picker_show_folder_name.toggle()
|
||||
private fun handleFolderNameDisplay() {
|
||||
val showFolderName = folder_picker_show_folder_name.isChecked
|
||||
config_folder_name.beVisibleIf(showFolderName)
|
||||
(config_image.layoutParams as RelativeLayout.LayoutParams).bottomMargin = if (showFolderName) 0 else resources.getDimension(R.dimen.normal_margin).toInt()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,10 +241,21 @@ fun Context.storeDirectoryItems(items: ArrayList<Directory>, directoryDao: Direc
|
|||
}
|
||||
|
||||
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>): String {
|
||||
val dirName = when (path) {
|
||||
val dirName = getFolderNameFromPath(path)
|
||||
return if (File(path).doesThisOrParentHaveNoMedia() && !path.isThisOrParentIncluded(includedFolders)) {
|
||||
"$dirName $hidden"
|
||||
} else {
|
||||
dirName
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getFolderNameFromPath(path: String): String {
|
||||
return when (path) {
|
||||
internalStoragePath -> getString(R.string.internal)
|
||||
sdCardPath -> getString(R.string.sd_card)
|
||||
OTG_PATH -> getString(R.string.otg)
|
||||
FAVORITES -> getString(R.string.favorites)
|
||||
RECYCLE_BIN -> getString(R.string.recycle_bin)
|
||||
else -> {
|
||||
if (path.startsWith(OTG_PATH)) {
|
||||
path.trimEnd('/').substringAfterLast('/')
|
||||
|
@ -253,12 +264,6 @@ fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return if (File(path).doesThisOrParentHaveNoMedia() && !path.isThisOrParentIncluded(includedFolders)) {
|
||||
"$dirName $hidden"
|
||||
} else {
|
||||
dirName
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/config_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -59,15 +60,29 @@
|
|||
|
||||
<RelativeLayout
|
||||
android:id="@+id/config_image_holder"
|
||||
android:layout_width="134dp"
|
||||
android:layout_height="134dp"
|
||||
android:layout_below="@+id/folder_picker_holder"
|
||||
android:padding="@dimen/normal_margin">
|
||||
android:layout_width="@dimen/widget_initial_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/folder_picker_holder">
|
||||
|
||||
<com.simplemobiletools.gallery.pro.views.MySquareImageView
|
||||
android:id="@+id/config_image"
|
||||
android:layout_width="@dimen/widget_initial_size"
|
||||
android:layout_height="@dimen/widget_initial_size"
|
||||
android:layout_marginLeft="@dimen/normal_margin"
|
||||
android:layout_marginTop="@dimen/normal_margin"
|
||||
android:layout_marginRight="@dimen/normal_margin"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/config_folder_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/config_image"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:lines="1"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="@string/internal"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue