Skip to content

Commit 9327542

Browse files
committed
list favorite folders in the Manage favorites activity
1 parent 20bfd48 commit 9327542

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
11
package com.simplemobiletools.filemanager.activities
22

3+
import android.graphics.PorterDuff
34
import android.os.Bundle
45
import com.simplemobiletools.filemanager.R
6+
import com.simplemobiletools.filemanager.extensions.config
7+
import kotlinx.android.synthetic.main.activity_favorites.*
8+
import kotlinx.android.synthetic.main.item_favorite.view.*
59

610
class FavoritesActivity : SimpleActivity() {
711
override fun onCreate(savedInstanceState: Bundle?) {
812
super.onCreate(savedInstanceState)
913
setContentView(R.layout.activity_favorites)
14+
updateFavorites()
15+
}
16+
17+
private fun updateFavorites() {
18+
favorites_holder.removeAllViews()
19+
val folders = config.favorites
20+
21+
for (folder in folders) {
22+
layoutInflater.inflate(R.layout.item_favorite, null, false).apply {
23+
favorite_title.apply {
24+
text = folder
25+
setTextColor(config.textColor)
26+
}
27+
favorite_icon.apply {
28+
setColorFilter(config.textColor, PorterDuff.Mode.SRC_IN)
29+
setOnClickListener {
30+
config.removeFavorite(folder)
31+
updateFavorites()
32+
}
33+
}
34+
favorites_holder.addView(this)
35+
}
36+
}
1037
}
1138
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@+id/favorite_holder"
5+
android:layout_width="match_parent"
6+
android:layout_height="wrap_content"
7+
android:padding="@dimen/activity_margin">
8+
9+
<com.simplemobiletools.commons.views.MyTextView
10+
android:id="@+id/favorite_title"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:layout_centerVertical="true"
14+
android:layout_marginLeft="@dimen/medium_margin"
15+
android:layout_marginRight="@dimen/medium_margin"
16+
android:layout_toLeftOf="@+id/favorite_icon"
17+
android:layout_toStartOf="@+id/favorite_icon"/>
18+
19+
<ImageView
20+
android:id="@+id/favorite_icon"
21+
style="@style/MyBorderlessBackgroundStyle"
22+
android:layout_width="@dimen/manage_favorites_img_size"
23+
android:layout_height="@dimen/manage_favorites_img_size"
24+
android:layout_alignParentEnd="true"
25+
android:layout_alignParentRight="true"
26+
android:padding="@dimen/medium_margin"
27+
android:src="@drawable/ic_cross"/>
28+
29+
</RelativeLayout>

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
2+
<dimen name="manage_favorites_img_size">48dp</dimen>
33
</resources>

0 commit comments

Comments
 (0)