add a cross for removing excluded folders

This commit is contained in:
tibbi 2017-02-26 21:10:52 +01:00
parent a3bf684aea
commit b4975a2bbd
6 changed files with 38 additions and 3 deletions

View file

@ -11,11 +11,19 @@ class ExcludedFoldersActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_excluded_folders)
addExcludedFolders()
}
private fun addExcludedFolders() {
excluded_folders_holder.removeAllViews()
val folders = config.excludedFolders
for (folder in folders) {
layoutInflater.inflate(R.layout.item_excluded_folder, null, false).apply {
excluded_folder_title.text = folder
excluded_folders_icon.setOnClickListener {
config.removeExcludedFolder(folder)
addExcludedFolders()
}
excluded_folders_holder.addView(this)
}
}

View file

@ -64,6 +64,12 @@ class Config(context: Context) : BaseConfig(context) {
excludedFolders = currExcludedFolders
}
fun removeExcludedFolder(path: String) {
val currExcludedFolders = HashSet<String>(excludedFolders)
currExcludedFolders.remove(path)
excludedFolders = currExcludedFolders
}
var excludedFolders: MutableSet<String>
get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet<String>())
set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply()

View file

@ -4,13 +4,26 @@
android:id="@+id/excluded_folder_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/excluded_folder_title"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"/>
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/medium_margin"
android:layout_marginRight="@dimen/medium_margin"
android:layout_toLeftOf="@+id/excluded_folders_icon"
android:layout_toStartOf="@+id/excluded_folders_icon"/>
<com.simplemobiletools.gallery.views.MyImageView
android:id="@+id/excluded_folders_icon"
style="@style/MyBorderlessBackgroundStyle"
android:layout_width="@dimen/exclude_folder_img_size"
android:layout_height="@dimen/exclude_folder_img_size"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_cross"/>
</RelativeLayout>

View file

@ -4,4 +4,7 @@
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="MyBorderlessBackgroundStyle">
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
</style>
</resources>

View file

@ -7,4 +7,5 @@
<dimen name="play_outline_size_big">160dp</dimen>
<dimen name="timer_padding">24dp</dimen>
<dimen name="tmb_shadow_height">50dp</dimen>
<dimen name="exclude_folder_img_size">48dp</dimen>
</resources>

View file

@ -15,4 +15,8 @@
<style name="MyFullScreenActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyBorderlessBackgroundStyle">
<item name="android:background">?attr/selectableItemBackground</item>
</style>
</resources>