mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-09 08:28:51 +01:00
list favorite folders in the Manage favorites activity
This commit is contained in:
parent
20bfd48e3f
commit
9327542b7a
@ -1,11 +1,38 @@
|
||||
package com.simplemobiletools.filemanager.activities
|
||||
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.extensions.config
|
||||
import kotlinx.android.synthetic.main.activity_favorites.*
|
||||
import kotlinx.android.synthetic.main.item_favorite.view.*
|
||||
|
||||
class FavoritesActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_favorites)
|
||||
updateFavorites()
|
||||
}
|
||||
|
||||
private fun updateFavorites() {
|
||||
favorites_holder.removeAllViews()
|
||||
val folders = config.favorites
|
||||
|
||||
for (folder in folders) {
|
||||
layoutInflater.inflate(R.layout.item_favorite, null, false).apply {
|
||||
favorite_title.apply {
|
||||
text = folder
|
||||
setTextColor(config.textColor)
|
||||
}
|
||||
favorite_icon.apply {
|
||||
setColorFilter(config.textColor, PorterDuff.Mode.SRC_IN)
|
||||
setOnClickListener {
|
||||
config.removeFavorite(folder)
|
||||
updateFavorites()
|
||||
}
|
||||
}
|
||||
favorites_holder.addView(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
app/src/main/res/layout/item_favorite.xml
Normal file
29
app/src/main/res/layout/item_favorite.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/favorite_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/favorite_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/medium_margin"
|
||||
android:layout_marginRight="@dimen/medium_margin"
|
||||
android:layout_toLeftOf="@+id/favorite_icon"
|
||||
android:layout_toStartOf="@+id/favorite_icon"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favorite_icon"
|
||||
style="@style/MyBorderlessBackgroundStyle"
|
||||
android:layout_width="@dimen/manage_favorites_img_size"
|
||||
android:layout_height="@dimen/manage_favorites_img_size"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_cross"/>
|
||||
|
||||
</RelativeLayout>
|
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
|
||||
<dimen name="manage_favorites_img_size">48dp</dimen>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user