Skip to content

Commit 2861653

Browse files
committed
Fixing the fixes
- Intermediate search results in real-time! - Fix ConcurrentModificationException caused by various file operations in ItemsAdapter not saving list of selected files BEFORE starting async operation - Move compression code into ListItem - Fix STATUS_SHARING_VIOLATION in SMB after file write due to not properly closing file handle - Fix display bugs in FilePickerDialog by forking FilepickerItemsAdapter - Fix view breaking on rotation in list view mode, caused by updateFragmentColumnCounts/columnCountChanged - Rollback target SDK from 25 to 24 to fix weird status bar transparency glitch - Update all favs inside of moved/deleted folders - Fix proguard rules for APK build
1 parent 6237dd2 commit 2861653

22 files changed

Lines changed: 402 additions & 294 deletions

app/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/build
22
/foss/
3-
/gplay/
3+
/gplay/

app/proguard-rules.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
-dontnote android.net.http.*
22
-dontnote org.apache.http.**
33
-keep class org.fossify.** { *; }
4-
-dontwarn org.fossify.**
4+
-dontwarn org.fossify.**
5+
-dontwarn javax.el.*
6+
-dontwarn org.ietf.jgss.*

app/src/main/kotlin/org/fossify/filemanager/about/AboutActivityAlt.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ class AboutActivityAlt: BaseComposeActivity() {
6464
}
6565
}
6666

67-
private fun getGithubUrl(): String {
68-
return "https://github.com/Pecacheu/${intent.getStringExtra(APP_REPOSITORY_NAME)}"
69-
}
67+
private fun getGithubUrl() =
68+
"https://github.com/Pecacheu/${intent.getStringExtra(APP_REPOSITORY_NAME)}"
7069

7170
@Composable
7271
private fun showFAQ() = remember {!(intent.getSerializableExtra(APP_FAQ) as? ArrayList<FAQItem>).isNullOrEmpty()}
@@ -126,9 +125,9 @@ class AboutActivityAlt: BaseComposeActivity() {
126125
startActivity(Intent(applicationContext, DonationActivity::class.java))
127126
}
128127

129-
private fun onGithubClick() {launchViewIntent("https://github.com/Pecacheu")}
130-
private fun onRedditClick() {launchViewIntent("https://www.reddit.com/r/Fossify")}
131-
private fun onTelegramClick() {launchViewIntent("https://t.me/Fossify")}
128+
private fun onGithubClick() = launchViewIntent("https://github.com/Pecacheu")
129+
private fun onRedditClick() = launchViewIntent("https://www.reddit.com/r/Fossify")
130+
private fun onTelegramClick() = launchViewIntent("https://t.me/Fossify")
132131

133132
private fun onPrivacyPolicyClick() {
134133
val appId = config.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("org.fossify.")

app/src/main/kotlin/org/fossify/filemanager/about/AboutScreen.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,8 @@ internal fun HelpUsSection(onRateUsClick: ()->Unit, onInviteClick: ()->Unit, onC
4646
}
4747

4848
@Composable
49-
internal fun OtherSection(
50-
showMoreApps: Boolean,
51-
onMoreAppsClick: ()->Unit,
52-
onPrivacyPolicyClick: ()->Unit,
53-
onLicenseClick: ()->Unit,
54-
versionName: String,
55-
packageName: String,
56-
onVersionClick: ()->Unit,
57-
) {
49+
internal fun OtherSection(showMoreApps: Boolean, onMoreAppsClick: ()->Unit, onPrivacyPolicyClick: ()->Unit,
50+
onLicenseClick: ()->Unit, versionName: String, packageName: String, onVersionClick: ()->Unit) {
5851
SettingsGroup(title = {
5952
SettingsTitleTextComponent(text = stringResource(id = R.string.other), modifier = titleStartPadding)
6053
}) {

app/src/main/kotlin/org/fossify/filemanager/activities/MainActivity.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import org.fossify.filemanager.fragments.MyViewPagerFragment
3535
import org.fossify.filemanager.fragments.RecentsFragment
3636
import org.fossify.filemanager.fragments.FavoritesFragment
3737
import org.fossify.filemanager.fragments.StorageFragment
38-
import org.fossify.filemanager.interfaces.ItemOperationsListener
3938
import java.io.File
4039
import androidx.core.net.toUri
4140
import androidx.viewpager2.widget.ViewPager2
@@ -84,7 +83,6 @@ class MainActivity: SimpleActivity() {
8483
setupOptionsMenu()
8584
storeStateVariables()
8685
setupTabs(getTabsToShow())
87-
refreshMenuItems()
8886

8987
setupViews(binding.mainCoordinator, null, null, null) {iAll, iNav ->
9088
val mc = binding.mainCoordinator.layoutParams as MarginLayoutParams
@@ -93,7 +91,7 @@ class MainActivity: SimpleActivity() {
9391
val mm = mainMenu.layoutParams as MarginLayoutParams
9492
mm.setMargins(iAll.left, 0, iAll.right, 0)
9593

96-
for(frag in getAllFragments()) frag?.getRecyclerAdapter()?.actMode?.let {
94+
for(frag in getAllFragments()) frag?.recyclerAdapter?.actMode?.let {
9795
val tb = it.customView.parent as ActionBarContextView
9896
tb.setPadding(iAll.left, iAll.top, iAll.right, 0)
9997
tb.contentHeight = iAll.top + mainMenu.measuredHeight
@@ -129,10 +127,10 @@ class MainActivity: SimpleActivity() {
129127

130128
for(f in getAllFragments()) f?.onResume(getProperTextColor())
131129
if(mStoredFontSize != config.fontSize) {
132-
for(f in getAllFragments()) (f as? ItemOperationsListener)?.setupFontSize()
130+
for(f in getAllFragments()) f?.setupFontSize()
133131
}
134132
if(mStoredDateFormat != config.dateFormat || mStoredTimeFormat != getTimeFormat()) {
135-
for(f in getAllFragments()) (f as? ItemOperationsListener)?.setupDateTimeFormat()
133+
for(f in getAllFragments()) f?.setupDateTimeFormat()
136134
}
137135
if(binding.mainViewPager.adapter == null) initFragments()
138136
else if(config.reloadPath) openPath(config.lastPath)
@@ -146,8 +144,8 @@ class MainActivity: SimpleActivity() {
146144
config.lastPath = getItemsFragment()?.currentPath?:""
147145
}
148146

149-
override fun onConfigurationChanged(newCon: Configuration) {
150-
super.onConfigurationChanged(newCon)
147+
override fun onConfigurationChanged(newConfig: Configuration) {
148+
super.onConfigurationChanged(newConfig)
151149
updateFragmentColumnCounts()
152150

153151
//Reload Main Menu
@@ -205,7 +203,7 @@ class MainActivity: SimpleActivity() {
205203
private fun beginScroll(by: Int) {
206204
endScroll()
207205
scrollTmr = fixedRateTimer(startAt = Date(), period = 30) {
208-
runOnUiThread {getCurrentFragment()?.getRecyclerAdapter()?.recyclerView?.scrollBy(0, by)}
206+
runOnUiThread {getCurrentFragment()?.getRecyclerView()?.scrollBy(0, by)}
209207
}
210208
}
211209
private fun endScroll() {
@@ -216,14 +214,14 @@ class MainActivity: SimpleActivity() {
216214
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
217215
if(!mainMenu.isSearchOpen) {
218216
if(event?.isCtrlPressed == true) {
219-
val adapter = getCurrentFragment()?.getRecyclerAdapter()
217+
val adapter = getCurrentFragment()?.recyclerAdapter
220218
if(keyCode == KeyEvent.KEYCODE_A) {
221219
adapter?.selectAll()
222220
return true
223221
}
224222
if(adapter?.isActMode() == true) when(keyCode) { //Action mode
225223
KeyEvent.KEYCODE_D -> {
226-
(getCurrentFragment() as? ItemOperationsListener)?.finishActMode()
224+
getCurrentFragment()?.finishActMode()
227225
return true
228226
} KeyEvent.KEYCODE_S -> {
229227
adapter.shareFiles()
@@ -432,7 +430,7 @@ class MainActivity: SimpleActivity() {
432430
registerOnPageChangeCallback(object: ViewPager2.OnPageChangeCallback() {
433431
override fun onPageSelected(position: Int) {
434432
binding.mainTabsHolder.getTabAt(position)?.select()
435-
for(f in getAllFragments()) (f as? ItemOperationsListener)?.finishActMode()
433+
for(f in getAllFragments()) f?.finishActMode()
436434
refreshMenuItems()
437435
}
438436
})
@@ -564,7 +562,7 @@ class MainActivity: SimpleActivity() {
564562

565563
private fun toggleFilenameVisibility() {
566564
config.displayFilenames = !config.displayFilenames
567-
for(f in getAllFragments()) (f as? ItemOperationsListener)?.toggleFilenameVisibility()
565+
for(f in getAllFragments()) f?.toggleFilenameVisibility()
568566
}
569567

570568
private fun changeColumnCount() {
@@ -578,12 +576,13 @@ class MainActivity: SimpleActivity() {
578576
if(colCount != newColCount) {
579577
config.fileColumnCnt = newColCount
580578
updateFragmentColumnCounts()
579+
refreshMenuItems()
581580
}
582581
}
583582
}
584583

585584
fun updateFragmentColumnCounts() {
586-
for(f in getAllFragments()) (f as? ItemOperationsListener)?.columnCountChanged()
585+
for(f in getAllFragments()) f?.columnCountChanged()
587586
}
588587

589588
private fun setAsHome() {

app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.provider.MediaStore
66
import android.view.Menu
77
import android.view.MenuItem
88
import androidx.appcompat.widget.SearchView
9-
import androidx.core.view.MenuItemCompat
109
import androidx.recyclerview.widget.GridLayoutManager
1110
import org.fossify.commons.extensions.*
1211
import org.fossify.commons.helpers.NavigationIcon
@@ -129,7 +128,7 @@ class MimeTypesActivity: SimpleActivity(), ItemOperationsListener {
129128
override fun toggleFilenameVisibility() {}
130129
override fun finishActMode() {}
131130

132-
override fun columnCountChanged() {
131+
private fun columnCountChanged() {
133132
layoutManager.spanCount = fileColumnCnt
134133
getRecyclerAdapter()?.apply {notifyItemRangeChanged(0, listItems.size)}
135134
}
@@ -258,7 +257,9 @@ class MimeTypesActivity: SimpleActivity(), ItemOperationsListener {
258257
}
259258
}
260259

261-
private fun setupListLayoutManager() {layoutManager.spanCount = 1}
260+
private fun setupListLayoutManager() {
261+
layoutManager.spanCount = 1
262+
}
262263

263264
private fun incColCount(by: Int) {
264265
if(currentViewType == VIEW_TYPE_GRID) {
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package org.fossify.filemanager.adapters
2+
3+
import android.annotation.SuppressLint
4+
import android.graphics.drawable.Drawable
5+
import android.util.TypedValue
6+
import android.view.Menu
7+
import android.view.ViewGroup
8+
import com.bumptech.glide.Glide
9+
import com.bumptech.glide.load.engine.DiskCacheStrategy
10+
import com.bumptech.glide.load.resource.bitmap.CenterCrop
11+
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
12+
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
13+
import com.bumptech.glide.request.RequestOptions
14+
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
15+
import org.fossify.commons.R
16+
import org.fossify.commons.activities.BaseSimpleActivity
17+
import org.fossify.commons.adapters.MyRecyclerViewAdapter
18+
import org.fossify.commons.extensions.*
19+
import org.fossify.commons.helpers.getFilePlaceholderDrawables
20+
import org.fossify.commons.views.MyRecyclerView
21+
import org.fossify.filemanager.adapters.ItemsAdapter.Binding
22+
import org.fossify.filemanager.models.ListItem
23+
import java.util.HashMap
24+
import java.util.Locale
25+
26+
class FilepickerItemsAdapter(activity: BaseSimpleActivity, val listItems: List<ListItem>,
27+
recyclerView: MyRecyclerView, itemClick: (Any)->Unit,
28+
): MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
29+
private lateinit var fileDrawable: Drawable
30+
private lateinit var folderDrawable: Drawable
31+
private var fileDrawables = HashMap<String, Drawable>()
32+
private var fontSize = 0f
33+
private val dateFormat = activity.baseConfig.dateFormat
34+
private val timeFormat = activity.getTimeFormat()
35+
36+
init {
37+
initDrawables()
38+
fontSize = activity.getTextSize()
39+
}
40+
41+
override fun getActionMenuId() = 0
42+
43+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
44+
val binding = Binding.ItemFileDirList.inflate(layoutInflater, parent, false)
45+
return ViewHolder(binding.root)
46+
}
47+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
48+
val item = listItems[position]
49+
holder.bindView(item, true, false) {view, pos ->
50+
setupView(Binding.ItemFileDirList.bind(view), item)
51+
}
52+
bindViewHolder(holder)
53+
}
54+
55+
override fun getItemCount() = listItems.size
56+
override fun prepareActionMode(menu: Menu) {}
57+
override fun actionItemPressed(id: Int) {}
58+
override fun getSelectableItemCount() = listItems.size
59+
override fun getIsItemSelectable(position: Int) = false
60+
override fun getItemKeyPosition(key: Int) = listItems.indexOfFirst {it.path.hashCode() == key}
61+
override fun getItemSelectionKey(position: Int) = listItems[position].path.hashCode()
62+
override fun onActionModeCreated() {}
63+
override fun onActionModeDestroyed() {}
64+
65+
override fun onViewRecycled(holder: ViewHolder) {
66+
super.onViewRecycled(holder)
67+
if(!activity.isDestroyed && !activity.isFinishing) {
68+
val icon = Binding.ItemFileDirList.bind(holder.itemView).itemIcon
69+
if(icon != null) Glide.with(activity).clear(icon)
70+
}
71+
}
72+
73+
private fun setupView(binding: ItemsAdapter.ItemViewBinding, item: ListItem) {
74+
binding.apply {
75+
root.setupViewBackground(activity)
76+
itemName?.text = item.name
77+
itemName?.setTextColor(textColor)
78+
itemName?.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
79+
itemDetails?.setTextColor(textColor)
80+
itemDetails?.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
81+
itemDate?.beGone()
82+
83+
if(item.isDir) {
84+
itemIcon?.setImageDrawable(folderDrawable)
85+
if(item.children == -2) itemDetails?.beGone()
86+
else {
87+
itemDetails?.text = if(item.children == -1) ""
88+
else activity.resources.getQuantityString(R.plurals.items, item.children, item.children)
89+
itemDetails?.beVisible()
90+
}
91+
} else {
92+
itemDetails?.text = item.size.formatSize()
93+
val drawable = fileDrawables.getOrElse(item.name.substringAfterLast('.').lowercase(Locale.getDefault())) {fileDrawable}
94+
val opts = RequestOptions().signature(item.getKey())
95+
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
96+
.error(drawable)
97+
.transform(CenterCrop(), RoundedCorners(10))
98+
99+
val imgPath = item.previewPath()
100+
if(!activity.isDestroyed && itemIcon != null) {
101+
Glide.with(activity).load(imgPath)
102+
.transition(DrawableTransitionOptions.withCrossFade())
103+
.apply(opts).into(itemIcon!!)
104+
}
105+
}
106+
}
107+
}
108+
109+
@SuppressLint("UseCompatLoadingForDrawables")
110+
private fun initDrawables() {
111+
folderDrawable = resources.getColoredDrawableWithColor(R.drawable.ic_folder_vector, properPrimaryColor)
112+
folderDrawable.alpha = 180
113+
fileDrawable = resources.getDrawable(R.drawable.ic_file_generic, null)
114+
fileDrawables = getFilePlaceholderDrawables(activity)
115+
}
116+
117+
override fun onChange(position: Int) = listItems.getOrNull(position)?.getBubbleText(activity, dateFormat, timeFormat)?:""
118+
}

0 commit comments

Comments
 (0)