Skip to content

Commit

Permalink
Improved the project readability and UI improvements to Image Optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai-Cristian Condrea committed Jul 23, 2024
1 parent fe5f251 commit 72b6622
Show file tree
Hide file tree
Showing 75 changed files with 1,643 additions and 1,642 deletions.
28 changes: 19 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
# Version 2.0.0:
- **New**: Added a progress bar to the main screen, offering an approximate visualization of storage usage.
- **New**: Users can now select specific files for deletion after the scan completes, allowing for granular control.
- **New**: Enhanced the post-scan screen to display previews of images and videos, aiding in file selection.
- **New**: Introduced the option to select all files for deletion, streamlining the cleaning process.
- **New**: Completely overhauled the memory manager, now showcasing storage usage categorized by file types.
- **New**: Added support for dynamic colors on compatible devices, allowing the app to adapt to system-wide color palettes.

- **New**: Added a progress bar to the main screen, offering an approximate visualization of storage
usage.
- **New**: Users can now select specific files for deletion after the scan completes, allowing for
granular control.
- **New**: Enhanced the post-scan screen to display previews of images and videos, aiding in file
selection.
- **New**: Introduced the option to select all files for deletion, streamlining the cleaning
process.
- **New**: Completely overhauled the memory manager, now showcasing storage usage categorized by
file types.
- **New**: Added support for dynamic colors on compatible devices, allowing the app to adapt to
system-wide color palettes.
- **New**: Refined the AMOLED theme for a more immersive dark mode experience.
- **New**: Incorporated updated translations thanks to valuable contributions from the community.
- **New**: Introduced a dedicated section for managing security and privacy settings within the app.
- **New**: Implemented new animations and improved overall app responsiveness for a smoother user experience.
- **Major**: Migrated the entire app to Jetpack Compose, providing a modern and improved user interface.
- **Major**: Completely reworked the app's logic using view models and coroutines for enhanced performance and maintainability.
- **New**: Implemented new animations and improved overall app responsiveness for a smoother user
experience.
- **Major**: Migrated the entire app to Jetpack Compose, providing a modern and improved user
interface.
- **Major**: Completely reworked the app's logic using view models and coroutines for enhanced
performance and maintainability.

# Version 1.1.0:

Expand Down
45 changes: 21 additions & 24 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ android {
applicationId = "com.d4rk.cleaner"
minSdk = 26
targetSdk = 34
versionCode = 96
versionCode = 97
versionName = "2.0.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += listOf(
"en",
"de",
"es",
"fr",
"hi",
"hu",
"in",
"it",
"ja",
"ro",
"ru",
"tr",
"sv",
"bg",
"pl",
"uk",
"b+zh+rTW",
"en" ,
"de" ,
"es" ,
"fr" ,
"hi" ,
"hu" ,
"in" ,
"it" ,
"ja" ,
"ro" ,
"ru" ,
"tr" ,
"sv" ,
"bg" ,
"pl" ,
"uk" ,
"b+zh+rTW" ,
)
vectorDrawables {
useSupportLibrary = true
Expand All @@ -49,17 +49,15 @@ android {
isDebuggable = false
versionNameSuffix = null
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
getDefaultProguardFile("proguard-android-optimize.txt") , "proguard-rules.pro"
)
}
debug {
multiDexEnabled = true
isDebuggable = true
versionNameSuffix = null
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
getDefaultProguardFile("proguard-android-optimize.txt") , "proguard-rules.pro"
)
}
}
Expand All @@ -73,7 +71,6 @@ android {
}

buildFeatures {
viewBinding = true
buildConfig = true
compose = true
}
Expand Down Expand Up @@ -150,7 +147,7 @@ dependencies {
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation(libs.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import java.io.File
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
private lateinit var fileScanner: FileScanner
private lateinit var fileScanner : FileScanner

@Before
fun init() {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
val path = File(Environment.getExternalStorageDirectory(), "")
val path = File(Environment.getExternalStorageDirectory() , "")
val res = appContext.resources
fileScanner = FileScanner(path, appContext).apply {
fileScanner = FileScanner(path , appContext).apply {
setAutoWhite(false)
setResources(res)
setDelete(true)
Expand All @@ -34,14 +34,19 @@ class ExampleInstrumentedTest {
@Test
fun useAppContext() {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
Assert.assertEquals("com.d4rk.cleaner", appContext.packageName)
Assert.assertEquals("com.d4rk.cleaner" , appContext.packageName)
}

@Test
fun checkLogFiles() {
val logFile = createFile("testfile.loG")
val clogFile = createFile("clogs.pnG")
fileScanner.setUpFilters(generic = true, aggressive = false, apk = false, archive = false)
fileScanner.setUpFilters(
generic = true ,
aggressive = false ,
apk = false ,
archive = false
)
fileScanner.startScan()
Assert.assertTrue(clogFile.exists())
Assert.assertFalse(logFile.exists())
Expand All @@ -50,47 +55,62 @@ class ExampleInstrumentedTest {
@Test
fun checkTempFiles() {
val tmpFile = createFile("testfile.tMp")
fileScanner.setUpFilters(generic = true, aggressive = false, apk = false, archive = false)
fileScanner.setUpFilters(
generic = true ,
aggressive = false ,
apk = false ,
archive = false
)
fileScanner.startScan()
Assert.assertFalse(tmpFile.exists())
}

@Test
fun checkThumbFiles() {
val thumbFile = createFile("thumbs.Db")
fileScanner.setUpFilters(generic = false, aggressive = true, apk = false, archive = false)
fileScanner.setUpFilters(
generic = false ,
aggressive = true ,
apk = false ,
archive = false
)
fileScanner.startScan()
Assert.assertFalse(thumbFile.exists())
}

@Test
fun checkAPKFiles() {
val thumbFile = createFile("chrome.aPk")
fileScanner.setUpFilters(generic = true, aggressive = true, apk = true, archive = false)
fileScanner.setUpFilters(generic = true , aggressive = true , apk = true , archive = false)
fileScanner.startScan()
Assert.assertFalse(thumbFile.exists())
}

@Test
fun checkEmptyDir() {
val emptyDir = createDir()
fileScanner.setUpFilters(generic = true, aggressive = false, apk = false, archive = false)
fileScanner.setUpFilters(
generic = true ,
aggressive = false ,
apk = false ,
archive = false
)
fileScanner.setEmptyDir(true)
fileScanner.startScan()
Assert.assertFalse(emptyDir.exists())
}

private fun createFile(name: String): File {
val file = File(Environment.getExternalStorageDirectory(), name)
private fun createFile(name : String) : File {
val file = File(Environment.getExternalStorageDirectory() , name)
file.createNewFile().let {
Assert.assertTrue(it)
}
Assert.assertTrue(file.exists())
return file
}

private fun createDir(): File {
val file = File(Environment.getExternalStorageDirectory(), "testdir")
private fun createDir() : File {
val file = File(Environment.getExternalStorageDirectory() , "testdir")
file.mkdir().let {
Assert.assertTrue(it)
}
Expand Down
60 changes: 28 additions & 32 deletions app/src/main/kotlin/com/d4rk/cleaner/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await

class MainActivity : AppCompatActivity() {
private lateinit var dataStore: DataStore
private lateinit var appUpdateManager: AppUpdateManager
private var appUpdateNotificationsManager: AppUpdateNotificationsManager =
AppUpdateNotificationsManager(this)
private lateinit var dataStore : DataStore
private lateinit var appUpdateManager : AppUpdateManager
private var appUpdateNotificationsManager : AppUpdateNotificationsManager =
AppUpdateNotificationsManager(this)

override fun onCreate(savedInstanceState: Bundle?) {
override fun onCreate(savedInstanceState : Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
enableEdgeToEdge()
Expand All @@ -49,7 +49,7 @@ class MainActivity : AppCompatActivity() {
setContent {
AppTheme {
Surface(
modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background
modifier = Modifier.fillMaxSize() , color = MaterialTheme.colorScheme.background
) {
MainComposable()
}
Expand Down Expand Up @@ -79,15 +79,11 @@ class MainActivity : AppCompatActivity() {
@Deprecated("Deprecated in Java")
@Suppress("DEPRECATION")
override fun onBackPressed() {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.close)
.setMessage(R.string.summary_close)
.setPositiveButton(android.R.string.yes) { _, _ ->
super.onBackPressed()
moveTaskToBack(true)
}
.setNegativeButton(android.R.string.no, null)
.apply { show() }
MaterialAlertDialogBuilder(this).setTitle(R.string.close).setMessage(R.string.summary_close)
.setPositiveButton(android.R.string.yes) { _ , _ ->
super.onBackPressed()
moveTaskToBack(true)
}.setNegativeButton(android.R.string.no , null).apply { show() }
}

/**
Expand All @@ -104,16 +100,16 @@ class MainActivity : AppCompatActivity() {
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*/
@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
override fun onActivityResult(requestCode : Int , resultCode : Int , data : Intent?) {
super.onActivityResult(requestCode , resultCode , data)
if (requestCode == 1) {
when (resultCode) {
RESULT_OK -> {
val snackbar = Snackbar.make(
findViewById(android.R.id.content),
R.string.snack_app_updated,
findViewById(android.R.id.content) ,
R.string.snack_app_updated ,
Snackbar.LENGTH_LONG
).setAction(android.R.string.ok, null)
).setAction(android.R.string.ok , null)
snackbar.show()
}

Expand Down Expand Up @@ -154,7 +150,7 @@ class MainActivity : AppCompatActivity() {
info.clientVersionStalenessDays()?.let {
if (it > 90) {
appUpdateManager.startUpdateFlowForResult(
info, AppUpdateType.IMMEDIATE, this@MainActivity, 1
info , AppUpdateType.IMMEDIATE , this@MainActivity , 1
)
}
}
Expand All @@ -166,29 +162,29 @@ class MainActivity : AppCompatActivity() {
info.clientVersionStalenessDays()?.let {
if (it < 90) {
appUpdateManager.startUpdateFlowForResult(
info, AppUpdateType.FLEXIBLE, this@MainActivity, 1
info , AppUpdateType.FLEXIBLE , this@MainActivity , 1
)
}
}
}
}
}
}
} catch (e: Exception) {
if (!BuildConfig.DEBUG) {
} catch (e : Exception) {
if (! BuildConfig.DEBUG) {
when (e) {
is NoConnectionError, is TimeoutError -> {
is NoConnectionError , is TimeoutError -> {
Snackbar.make(
findViewById(android.R.id.content),
getString(R.string.snack_network_error),
findViewById(android.R.id.content) ,
getString(R.string.snack_network_error) ,
Snackbar.LENGTH_LONG
).show()
}

else -> {
Snackbar.make(
findViewById(android.R.id.content),
getString(R.string.snack_general_error),
findViewById(android.R.id.content) ,
getString(R.string.snack_general_error) ,
Snackbar.LENGTH_LONG
).show()
}
Expand All @@ -207,7 +203,7 @@ class MainActivity : AppCompatActivity() {
*/
private fun showUpdateFailedSnackbar() {
val snackbar = Snackbar.make(
findViewById(android.R.id.content), R.string.snack_update_failed, Snackbar.LENGTH_LONG
findViewById(android.R.id.content) , R.string.snack_update_failed , Snackbar.LENGTH_LONG
).setAction(R.string.try_again) {
checkForFlexibleUpdate()
}
Expand Down Expand Up @@ -236,7 +232,7 @@ class MainActivity : AppCompatActivity() {
lifecycleScope.launch {
val isEnabled = dataStore.usageAndDiagnostics.first()
FirebaseAnalytics.getInstance(this@MainActivity)
.setAnalyticsCollectionEnabled(isEnabled)
.setAnalyticsCollectionEnabled(isEnabled)
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(isEnabled)
}
}
Expand All @@ -245,7 +241,7 @@ class MainActivity : AppCompatActivity() {
lifecycleScope.launch {
if (dataStore.startup.first()) {
dataStore.saveStartup(false)
startActivity(Intent(this@MainActivity, StartupActivity::class.java))
startActivity(Intent(this@MainActivity , StartupActivity::class.java))
}
}
}
Expand Down
Loading

0 comments on commit 72b6622

Please sign in to comment.