From 489287d6a7a77039016626a8115d9d2036d3f2b6 Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Sat, 16 Dec 2023 10:49:11 +0530 Subject: [PATCH 01/10] Fixes in pdf viewer --- app/build.gradle | 2 +- .../fileutilities/home_page/ui/files/FilesFragment.kt | 8 ++++---- app/src/main/res/drawable/background_curved_dark_2.xml | 7 ------- app/src/main/res/menu/generic_list_overflow.xml | 4 ---- 4 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 app/src/main/res/drawable/background_curved_dark_2.xml diff --git a/app/build.gradle b/app/build.gradle index b61da4d4..55fb9c60 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -287,7 +287,7 @@ dependencies { api "com.caverock:androidsvg:1.4" implementation 'com.burhanrashid52:photoeditor:2.0.0' implementation 'com.github.CanHub:Android-Image-Cropper:4.3.1' - api 'com.github.TeamAmaze:mupdf-android-viewer:1.0.26' + api 'com.github.TeamAmaze:mupdf-android-viewer:1.0.27' implementation "androidx.documentfile:documentfile:1.0.1" implementation 'id.zelory:compressor:3.0.1' implementation('com.github.AbedElazizShe:LightCompressor:1.3.1') { diff --git a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt index d2d6ec5f..011cb92b 100644 --- a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt +++ b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt @@ -72,6 +72,10 @@ class FilesFragment : ItemsActionBarFragment() { false ) val root: View = binding.root + val slideUpAnimation: Animation = + AnimationUtils.loadAnimation(requireContext(), R.anim.slide_up_fade_in) + binding.listFragmentParent.startAnimation(slideUpAnimation) + binding.listFragmentParent.visibility = View.VISIBLE // needed to avoid NPE in progress library when closing activity binding.storagePercent.isSaveEnabled = false filesViewModel.run { @@ -370,10 +374,6 @@ class FilesFragment : ItemsActionBarFragment() { } binding.storagePercent.setAdaptiveColorProvider(colorProvider) - val slideUpAnimation: Animation = - AnimationUtils.loadAnimation(requireContext(), R.anim.slide_up_fade_in) - binding.listFragmentParent.startAnimation(slideUpAnimation) - binding.listFragmentParent.visibility = View.VISIBLE return root } diff --git a/app/src/main/res/drawable/background_curved_dark_2.xml b/app/src/main/res/drawable/background_curved_dark_2.xml deleted file mode 100644 index 81ca2bcd..00000000 --- a/app/src/main/res/drawable/background_curved_dark_2.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/generic_list_overflow.xml b/app/src/main/res/menu/generic_list_overflow.xml index ac06b1ec..040c1622 100644 --- a/app/src/main/res/menu/generic_list_overflow.xml +++ b/app/src/main/res/menu/generic_list_overflow.xml @@ -12,8 +12,4 @@ android:id="@+id/delete" android:title="@string/delete" /> - \ No newline at end of file From bf77aba89b2757fd2f200a057100d6be8bda8ec8 Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Thu, 21 Dec 2023 01:24:36 +0530 Subject: [PATCH 02/10] 153: Show file paths in list fragments --- .../home_page/ui/files/FilesFragment.kt | 6 ------ .../ui/files/MediaInfoRecyclerViewHolder.kt | 3 +++ .../utilis/AbstractMediaFilesAdapter.kt | 21 ++++++++++++------- .../res/layout/media_info_grid_layout.xml | 11 ++++++++++ .../main/res/layout/media_info_row_layout.xml | 14 ++++++++++++- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt index 011cb92b..12f9c7d5 100644 --- a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt +++ b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesFragment.kt @@ -25,8 +25,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.view.animation.Animation -import android.view.animation.AnimationUtils import androidx.core.graphics.ColorUtils import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels @@ -72,10 +70,6 @@ class FilesFragment : ItemsActionBarFragment() { false ) val root: View = binding.root - val slideUpAnimation: Animation = - AnimationUtils.loadAnimation(requireContext(), R.anim.slide_up_fade_in) - binding.listFragmentParent.startAnimation(slideUpAnimation) - binding.listFragmentParent.visibility = View.VISIBLE // needed to avoid NPE in progress library when closing activity binding.storagePercent.isSaveEnabled = false filesViewModel.run { diff --git a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/MediaInfoRecyclerViewHolder.kt b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/MediaInfoRecyclerViewHolder.kt index 057682d7..5f58c43d 100644 --- a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/MediaInfoRecyclerViewHolder.kt +++ b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/MediaInfoRecyclerViewHolder.kt @@ -37,6 +37,9 @@ class MediaInfoRecyclerViewHolder(view: View) : RecyclerView.ViewHolder(view) { @JvmField val infoSummary: TextView = view.findViewById(R.id.info_summary) + @JvmField + val infoSubSummary: TextView = view.findViewById(R.id.info_sub_summary) + @JvmField val extraInfo: TextView = view.findViewById(R.id.extra_info) diff --git a/app/src/main/java/com/amaze/fileutilities/utilis/AbstractMediaFilesAdapter.kt b/app/src/main/java/com/amaze/fileutilities/utilis/AbstractMediaFilesAdapter.kt index 5fc79a90..21fe1a46 100644 --- a/app/src/main/java/com/amaze/fileutilities/utilis/AbstractMediaFilesAdapter.kt +++ b/app/src/main/java/com/amaze/fileutilities/utilis/AbstractMediaFilesAdapter.kt @@ -214,6 +214,7 @@ abstract class AbstractMediaFilesAdapter( holder.infoTitle.text = mediaFileInfo.title Utils.marqueeAfterDelay(3000, holder.infoTitle) Utils.marqueeAfterDelay(3000, holder.infoSummary) + Utils.marqueeAfterDelay(3000, holder.infoSubSummary) Glide.with(superContext).clear(holder.iconView) superPreloader.loadImage(mediaFileInfo, holder.iconView, isGrid) if (isChecked) { @@ -233,6 +234,9 @@ abstract class AbstractMediaFilesAdapter( superContext.resources.getDrawable(R.drawable.ripple) } } + if (!isGrid) { + holder.infoSubSummary.text = mediaFileInfo.path + } holder.root.setOnLongClickListener { toggleChecked(this, position) invalidateCheckedTitle(getOnlyItemsCount()) @@ -305,13 +309,14 @@ abstract class AbstractMediaFilesAdapter( formattedDate: String, formattedSize: String ) { - holder.infoSummary.text = if (mediaFileInfo.extraInfo?.imageMetaData?.width != null) { - "${mediaFileInfo.extraInfo!!.imageMetaData?.width}" + + if (mediaFileInfo.extraInfo?.imageMetaData?.width != null) { + holder.infoSummary.visibility = View.GONE + holder.extraInfo.text = "${mediaFileInfo.extraInfo!!.imageMetaData?.width}" + "x${mediaFileInfo.extraInfo!!.imageMetaData?.height}" } else { - "$formattedDate | $formattedSize" + holder.infoSummary.text = "$formattedDate | $formattedSize" + holder.extraInfo.visibility = View.GONE } - holder.extraInfo.text = "" } private fun processAudioMediaInfo( @@ -320,7 +325,7 @@ abstract class AbstractMediaFilesAdapter( formattedDate: String, formattedSize: String ) { - if (mediaFileInfo.extraInfo?.audioMetaData?.duration != null) { + if (mediaFileInfo.extraInfo?.audioMetaData != null) { holder.infoSummary.text = "${mediaFileInfo.extraInfo!!.audioMetaData?.albumName} " + "| ${mediaFileInfo.extraInfo!!.audioMetaData?.artistName}" mediaFileInfo.extraInfo!!.audioMetaData?.duration?.let { @@ -328,7 +333,7 @@ abstract class AbstractMediaFilesAdapter( } } else { holder.infoSummary.text = "$formattedDate | $formattedSize" - holder.extraInfo.text = "" + holder.extraInfo.visibility = View.GONE } } @@ -338,7 +343,7 @@ abstract class AbstractMediaFilesAdapter( formattedDate: String, formattedSize: String ) { - if (mediaFileInfo.extraInfo?.videoMetaData?.duration != null) { + if (mediaFileInfo.extraInfo?.videoMetaData != null) { holder.infoSummary.text = "${mediaFileInfo.extraInfo!!.videoMetaData?.width}" + "x${mediaFileInfo.extraInfo!!.videoMetaData?.height}" @@ -347,7 +352,7 @@ abstract class AbstractMediaFilesAdapter( } } else { holder.infoSummary.text = "$formattedDate | $formattedSize" - holder.extraInfo.text = "" + holder.extraInfo.visibility = View.GONE } } diff --git a/app/src/main/res/layout/media_info_grid_layout.xml b/app/src/main/res/layout/media_info_grid_layout.xml index ccae6c79..c6a5f6ec 100644 --- a/app/src/main/res/layout/media_info_grid_layout.xml +++ b/app/src/main/res/layout/media_info_grid_layout.xml @@ -107,6 +107,17 @@ android:marqueeRepeatLimit="marquee_forever" android:ellipsize="marquee" /> + + + + Date: Thu, 21 Dec 2023 01:31:27 +0530 Subject: [PATCH 03/10] Add documentation for finding similar images --- .../home_page/ui/files/FilesViewModel.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt index 66d400c5..a86e64af 100644 --- a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt +++ b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt @@ -657,6 +657,22 @@ class FilesViewModel(val applicationContext: Application) : } } + /** + * We find histogram for a given image, divide it in 256/8 windows. + * For each window of this histogram, we find the red, green and blue channel peaks individually, along with it's position for a given window. + * All these data points are then saved in database table for all images. + * This process starts as soon as app starts and keeps running in background (ofcourse there are multiple optimisations done so as to not fill up RAM, for all the background running analysis in the app). + * Then once we have all the histograms data (all analysis resumes from last point in case user closes the app, or users take new images till the time we have processed all the images), so however multiple runs the app takes, once we have all the histogram data, it's time to figure out the similar images. + * To figure out the similar images, we compare the peaks of the rgb channel of each window, once we have x number of windows that matches, say 6 out of 8 windows, we can say that image may be similar (the number was decided based on multiple tests in real life). + * In order to make results more realistic, we also compare the position of peak along with the peak rgb channel for a given window. Ofcourse, you can't have the exact same pixel position for a peak, so a normalization was also done. + * Finally, when we have a matching image that satisfies above criteria, we take a checksum of all the rgb channel windows along with it's parent path (this is done so that we only match similar images in the same directory, as chances are, similar images will be in the same directory and helps to minimize false positives), and then save checksum value of all the images in the table. + * This second part of the analysis is also done in the background. + * So till here we have figured out the similar images and can uniquely identify them from their checksum, so that we don't have to repeat the second step at the runtime. + * Finally when a user opens the analysis section of the app, all we have to do is to group images by same checksum and list them to the user. + * Ofcourse there may be some false positives in this (or any other) analysis algorithm in the app, so we already have a feature where all user have to do is select the analysis result, and press the thumbs down button at top of the screen, and then that analysis will be marked false positive in the database and will not be shown to user again. + * Phew, this was something, I had to write this down so that I don't forget in future again instead of going through the code. + * I know there are multiple algorithms online, too complicated for me to understand and write from scratch in java (they're native functions in python). So I had to resort to write on my own. + */ fun analyseSimilarImages( mediaFileInfoList: List, pathPreferencesList: List From a96cb7f77763bcc13fb78e53ff88a9991d636636 Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Thu, 21 Dec 2023 02:00:52 +0530 Subject: [PATCH 04/10] 146: keep screen awake on video player activity --- .../amaze/fileutilities/audio_player/AudioPlayerService.kt | 6 ++++-- app/src/main/res/layout/video_player_activity.xml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt b/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt index a8cb47f4..b40198ac 100644 --- a/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt +++ b/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt @@ -54,11 +54,12 @@ import com.google.android.exoplayer2.C import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.PlaybackParameters +import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.audio.AudioAttributes -import org.slf4j.Logger -import org.slf4j.LoggerFactory import java.lang.ref.WeakReference import java.util.concurrent.atomic.AtomicReference +import org.slf4j.Logger +import org.slf4j.LoggerFactory class AudioPlayerService : Service(), ServiceOperationCallback, OnPlayerRepeatingCallback { @@ -610,6 +611,7 @@ class AudioPlayerService : Service(), ServiceOperationCallback, OnPlayerRepeatin private fun initializePlayer() { exoPlayer = ExoPlayer.Builder(this).build() + exoPlayer?.setWakeMode(Player.STATE_READY) // reset playback parameter getAppCommonSharedPreferences().edit() .remove(PreferencesConstants.KEY_PLAYBACK_SEMITONES).apply() diff --git a/app/src/main/res/layout/video_player_activity.xml b/app/src/main/res/layout/video_player_activity.xml index 2f3650aa..e722e5c8 100644 --- a/app/src/main/res/layout/video_player_activity.xml +++ b/app/src/main/res/layout/video_player_activity.xml @@ -4,6 +4,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:keepScreenOn="true" xmlns:app="http://schemas.android.com/apk/res-auto"> Date: Thu, 21 Dec 2023 02:55:57 +0530 Subject: [PATCH 05/10] 42: overlay notch area in video player landscape --- .../audio_player/AudioPlayerService.kt | 4 +-- .../video_player/VideoPlayerActivity.kt | 31 +++++++++++++++++++ app/src/main/res/values-v27/themes.xml | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt b/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt index b40198ac..f44958ea 100644 --- a/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt +++ b/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt @@ -56,10 +56,10 @@ import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.PlaybackParameters import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.audio.AudioAttributes -import java.lang.ref.WeakReference -import java.util.concurrent.atomic.AtomicReference import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.lang.ref.WeakReference +import java.util.concurrent.atomic.AtomicReference class AudioPlayerService : Service(), ServiceOperationCallback, OnPlayerRepeatingCallback { diff --git a/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt b/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt index 98cfcfff..3a516278 100644 --- a/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt +++ b/app/src/main/java/com/amaze/fileutilities/video_player/VideoPlayerActivity.kt @@ -20,7 +20,13 @@ package com.amaze.fileutilities.video_player +import android.content.res.Configuration +import android.os.Build import android.os.Bundle +import android.view.View +import android.view.WindowInsets +import android.view.WindowInsetsController +import android.view.WindowManager class VideoPlayerActivity : BaseVideoPlayerActivity() { @@ -36,5 +42,30 @@ class VideoPlayerActivity : BaseVideoPlayerActivity() { initLocalVideoModel(intent) super.onCreate(savedInstanceState) handleVideoPlayerActivityResources() + val orientation = resources.configuration.orientation + if (orientation == Configuration.ORIENTATION_LANDSCAPE) { + // allow to go in notch area in landscape mode + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + // Set the system UI visibility flags + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + + // Get the WindowInsetsController + val controller = window.insetsController + + // Hide the system bars (navigation bar, status bar) + controller?.hide(WindowInsets.Type.systemBars()) + + // Enable the extended layout to be displayed in the notch area + controller?.systemBarsBehavior = + WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } else { + window.setFlags( + WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN + ) + } + } } } diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml index 7e2a1cff..29a13c59 100644 --- a/app/src/main/res/values-v27/themes.xml +++ b/app/src/main/res/values-v27/themes.xml @@ -1,7 +1,7 @@ From acad9f081a3936780a43ac119e2c6128eb86009d Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Thu, 21 Dec 2023 03:12:06 +0530 Subject: [PATCH 06/10] 42: Fix default screen brightness for video player --- .../com/amaze/fileutilities/utilis/Extensions.kt | 13 +++++++++++++ .../video_player/BaseVideoPlayerActivity.kt | 12 +++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/amaze/fileutilities/utilis/Extensions.kt b/app/src/main/java/com/amaze/fileutilities/utilis/Extensions.kt index e4b792d3..0680aa0a 100644 --- a/app/src/main/java/com/amaze/fileutilities/utilis/Extensions.kt +++ b/app/src/main/java/com/amaze/fileutilities/utilis/Extensions.kt @@ -33,6 +33,7 @@ import android.os.Environment import android.os.ParcelFileDescriptor import android.os.TransactionTooLargeException import android.provider.MediaStore +import android.provider.Settings import android.util.DisplayMetrics import android.view.Gravity import android.view.View @@ -686,3 +687,15 @@ fun View.fadInAnimation(duration: Long = 300, completion: (() -> Unit)? = null) } } } + +fun Context.getScreenBrightness(): Float { + var brightness = 0 + try { + val contentResolver = this.contentResolver + brightness = Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS) + } catch (e: Exception) { + log.warn("failed to get system brightness", e) + return -1f + } + return (brightness / 255).toFloat() +} diff --git a/app/src/main/java/com/amaze/fileutilities/video_player/BaseVideoPlayerActivity.kt b/app/src/main/java/com/amaze/fileutilities/video_player/BaseVideoPlayerActivity.kt index 4ad39931..717b868e 100644 --- a/app/src/main/java/com/amaze/fileutilities/video_player/BaseVideoPlayerActivity.kt +++ b/app/src/main/java/com/amaze/fileutilities/video_player/BaseVideoPlayerActivity.kt @@ -78,6 +78,7 @@ import com.amaze.fileutilities.utilis.dialog_picker.FileFilter import com.amaze.fileutilities.utilis.getAppCommonSharedPreferences import com.amaze.fileutilities.utilis.getExternalStorageDirectory import com.amaze.fileutilities.utilis.getFileFromUri +import com.amaze.fileutilities.utilis.getScreenBrightness import com.amaze.fileutilities.utilis.hideFade import com.amaze.fileutilities.utilis.isNetworkAvailable import com.amaze.fileutilities.utilis.removeExtension @@ -990,7 +991,16 @@ abstract class BaseVideoPlayerActivity : private fun invalidateBrightness() { val layout = window.attributes - layout.screenBrightness = videoPlayerViewModel?.brightnessLevel ?: 0.3f + val systemBrightness = this.getScreenBrightness() + layout.screenBrightness = if (videoPlayerViewModel != null && + videoPlayerViewModel?.brightnessLevel != 0.3f + ) { + videoPlayerViewModel!!.brightnessLevel + } else if (systemBrightness != -1f) { + systemBrightness + } else { + 0.3f + } window.attributes = layout } From 5aebda616ab152ac33f7041d71f407c9109806af Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Thu, 21 Dec 2023 22:43:18 +0530 Subject: [PATCH 07/10] Revert wakemode for audio player service --- .../com/amaze/fileutilities/audio_player/AudioPlayerService.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt b/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt index f44958ea..a8cb47f4 100644 --- a/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt +++ b/app/src/main/java/com/amaze/fileutilities/audio_player/AudioPlayerService.kt @@ -54,7 +54,6 @@ import com.google.android.exoplayer2.C import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.PlaybackParameters -import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.audio.AudioAttributes import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -611,7 +610,6 @@ class AudioPlayerService : Service(), ServiceOperationCallback, OnPlayerRepeatin private fun initializePlayer() { exoPlayer = ExoPlayer.Builder(this).build() - exoPlayer?.setWakeMode(Player.STATE_READY) // reset playback parameter getAppCommonSharedPreferences().edit() .remove(PreferencesConstants.KEY_PLAYBACK_SEMITONES).apply() From 3b1b2da4ada58960f4c0089fe0c8deb190ebf609 Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Thu, 21 Dec 2023 23:41:16 +0530 Subject: [PATCH 08/10] Fixes in junk files analysis --- .../home_page/ui/files/FilesViewModel.kt | 71 +++++++++++-------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt index a86e64af..5cd37124 100644 --- a/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt +++ b/app/src/main/java/com/amaze/fileutilities/home_page/ui/files/FilesViewModel.kt @@ -1972,6 +1972,12 @@ class FilesViewModel(val applicationContext: Application) : } } + /** + * installedAppsDao contains all the apps installed at a given instance, the list gets updated each time we fetch all apps. + * We fetch list of installed apps right now here again, and compare with the installedAppsDao list + * apps installed right now will be a subset of installedAppsDao + * We find the difference first, then for apps that aren't installed now, we check to see if there is any data directory present or not. + */ fun getJunkFilesLiveData(): LiveData, String>?> { if (junkFilesLiveData == null) { junkFilesLiveData = MutableLiveData() @@ -1985,38 +1991,39 @@ class FilesViewModel(val applicationContext: Application) : viewModelScope.launch(Dispatchers.IO) { loadAllInstalledApps(packageManager) val dao = AppDatabase.getInstance(applicationContext).installedAppsDao() - val savedInstalledApps = dao.findAll().filter { - savedAppData -> - allApps.get()?.any { - !it.first.packageName.equals(savedAppData.packageName) - } == false - } - log.info("found following apps not installed {}", savedInstalledApps) - val result = ArrayList() - savedInstalledApps.forEach { - savedApp -> - savedApp.dataDirs.forEach { - result.add( - MediaFileInfo.fromFile( - File(it), - MediaFileInfo.ExtraInfo( - MediaFileInfo.MEDIA_TYPE_UNKNOWN, - null, null, null + val savedInstalledApps = dao.findAll() + allApps.get()?.map { it.first.packageName }?.toSet()?.let { + installedAppsPackageNames -> + val difference = savedInstalledApps.filter { + it.packageName !in installedAppsPackageNames + } + log.info("found following apps not installed {}", difference) + val result = ArrayList() + difference.forEach { + savedApp -> + savedApp.dataDirs.forEach { + result.add( + MediaFileInfo.fromFile( + File(it), + MediaFileInfo.ExtraInfo( + MediaFileInfo.MEDIA_TYPE_UNKNOWN, + null, null, null + ) ) ) - ) + } } - } - var size = 0L - result.forEach { - size += it.longSize - } - junkFilesLiveData?.postValue( - Pair( - result, - Formatter.formatFileSize(applicationContext, size) + var size = 0L + result.forEach { + size += it.longSize + } + junkFilesLiveData?.postValue( + Pair( + result, + Formatter.formatFileSize(applicationContext, size) + ) ) - ) + } } } @@ -2415,7 +2422,13 @@ class FilesViewModel(val applicationContext: Application) : allApps.get()?.let { infoListPair -> val installedApps = infoListPair.map { - InstalledApps(it.first.packageName, listOf(it.first.sourceDir, it.first.dataDir)) + InstalledApps( + it.first.packageName, + listOf( + it.first.sourceDir, + it.first.dataDir, it.first.publicSourceDir + ) + ) } val dao = AppDatabase.getInstance(applicationContext).installedAppsDao() dao.insert(installedApps) From f227845c5dd69c70c0307994590dab30a8126ca4 Mon Sep 17 00:00:00 2001 From: Vishal Nehra Date: Wed, 27 Dec 2023 01:35:56 +0530 Subject: [PATCH 09/10] 147: change video player and image viewer backgrounds to dark; fix popup bg; fix backpress on viewers --- .github/workflows/android-build.yml | 45 +++++++++++++++++++ .github/workflows/android-main.yml | 2 +- app/src/main/AndroidManifest.xml | 9 +--- .../home_page/ui/analyse/AnalyseFragment.kt | 5 +++ .../res/drawable/button_curved_selected.xml | 2 +- .../res/drawable/popup_item_background.xml | 16 +++++++ .../drawable/ripple_curved_16_trans_70.xml | 17 +++++++ app/src/main/res/values-v27/themes.xml | 1 + app/src/main/res/values/themes.xml | 3 ++ 9 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/android-build.yml create mode 100644 app/src/main/res/drawable/popup_item_background.xml create mode 100644 app/src/main/res/drawable/ripple_curved_16_trans_70.xml diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml new file mode 100644 index 00000000..6466f798 --- /dev/null +++ b/.github/workflows/android-build.yml @@ -0,0 +1,45 @@ +name: Android Build CI + +on: + push: + branches: + - '*' + - '!master' + - '!release/*' +concurrency: + group: build-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + check_spotless: + name: Check spotless + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 11 + - name: Check formatting using spotless + uses: gradle/gradle-build-action@v2.4.2 + with: + arguments: spotlessCheck + build: + name: Build debug + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 11 + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.4.2 + with: + arguments: assembledebug --stacktrace + env: + TZ: UTC \ No newline at end of file diff --git a/.github/workflows/android-main.yml b/.github/workflows/android-main.yml index b46834d8..83e81f71 100644 --- a/.github/workflows/android-main.yml +++ b/.github/workflows/android-main.yml @@ -40,7 +40,7 @@ jobs: - name: Build with Gradle uses: gradle/gradle-build-action@v2.4.2 with: - arguments: assembledebug + arguments: assembledebug --stacktrace env: TZ: UTC - name: Publish on Telegram diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c43662cd..278da6d2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -57,7 +57,6 @@ android:theme="@style/Theme.AmazeFileUtilities" android:screenOrientation="portrait" tools:ignore="LockedOrientationActivity" - android:launchMode="singleInstance" > @@ -96,7 +95,6 @@ android:name=".image_viewer.ImageViewerActivity" android:label="@string/image_viewer" android:theme="@style/Theme.AmazeFileUtilities.FullScreen.Dark" - android:launchMode="singleInstance" android:exported="true" > @@ -198,7 +194,7 @@ android:exported="true" android:label="@string/docx_viewer" android:theme="@style/Theme.AmazeFileUtilities" - android:launchMode="singleInstance"> + > @@ -214,7 +210,7 @@ android:name=".home_page.ui.options.AboutActivity" android:exported="true" android:theme="@style/Custom.Dialog.Dark" - android:launchMode="singleInstance"> + > - + diff --git a/app/src/main/res/drawable/popup_item_background.xml b/app/src/main/res/drawable/popup_item_background.xml new file mode 100644 index 00000000..8f50be99 --- /dev/null +++ b/app/src/main/res/drawable/popup_item_background.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/ripple_curved_16_trans_70.xml b/app/src/main/res/drawable/ripple_curved_16_trans_70.xml new file mode 100644 index 00000000..a2aee21d --- /dev/null +++ b/app/src/main/res/drawable/ripple_curved_16_trans_70.xml @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-v27/themes.xml b/app/src/main/res/values-v27/themes.xml index 29a13c59..0ec0e6b3 100644 --- a/app/src/main/res/values-v27/themes.xml +++ b/app/src/main/res/values-v27/themes.xml @@ -4,5 +4,6 @@ always false true + @color/black \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 73bdd710..bdc0c588 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -63,6 +63,7 @@