diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index f4345f291..b265d2e5e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -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) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index eebddb6a6..050590036 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -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() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 17b0a2db9..7e523220c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -241,10 +241,21 @@ fun Context.storeDirectoryItems(items: ArrayList, directoryDao: Direc } fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet): 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) { diff --git a/app/src/main/res/layout/activity_widget_config.xml b/app/src/main/res/layout/activity_widget_config.xml index cda0e7f48..b1b73a73d 100644 --- a/app/src/main/res/layout/activity_widget_config.xml +++ b/app/src/main/res/layout/activity_widget_config.xml @@ -2,6 +2,7 @@ + android:layout_width="@dimen/widget_initial_size" + android:layout_height="wrap_content" + android:layout_below="@+id/folder_picker_holder"> + + + 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"/>