Skip to content

Commit

Permalink
Implement night theme + Some improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
alibardide5124 committed Mar 19, 2023
1 parent c3959e4 commit 8189147
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<img src="/readme.files/imagine.png" alt="icon" title="imagine" width="60" height="60" align="left" />
<img src="/readme.files/icon-512.png" alt="icon" title="imagine" width="60" height="60" align="left" />

# Imagine

Android image compressor

You can reduse your image sizes with this app. Just in two simple step; Choose image and compress it... Exacly this easy.</br>
Download app from [**here**](https://github.com/alibardide5124/Imagine/releases/download/1.0.1/app-release.apk)
You can reduce your image sizes with this app. Just in two simple step; Choose image and compress it...</br>
Download app from [**here**](https://github.com/alibardide5124/Imagine/releases/download/1.2.0/app-release.apk)
</br></br>

Image Quality
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/com/alibardide/imagine/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.alibardide.imagine.databinding.ActivityMainBinding
import com.alibardide.imagine.databinding.DialogProgressBinding
import com.vmadalin.easypermissions.EasyPermissions
import com.vmadalin.easypermissions.dialogs.SettingsDialog
import id.zelory.compressor.Compressor
import id.zelory.compressor.constraint.resolution
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
Expand Down Expand Up @@ -74,8 +74,7 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks, I
// Check if image is not null
imageFile?.let { file ->
progress.show()
// Launch a GlobalScope
GlobalScope.launch(Dispatchers.IO) {
lifecycleScope.launch(Dispatchers.IO) {
val context = this@MainActivity
// Decode selected file, compress file and save compressed file
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
Expand All @@ -93,9 +92,8 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks, I
private fun aboutDialog(): AlertDialog {
// About alert dialog
// info for get app version
val info = packageManager.getPackageInfo(packageName, 0)
return AlertDialog.Builder(this)
.setTitle(getString(R.string.app_name) + " ${info.versionName}")
.setTitle(getString(R.string.app_name) + " ${BuildConfig.VERSION_NAME}")
.setMessage("Developed by Ali Bardide\nLicensed on Apache 2.0")
.setPositiveButton("ok", null)
.setNeutralButton("GitHub") { _: DialogInterface, _: Int ->
Expand All @@ -122,7 +120,7 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks, I
try {
progress.show()
// Load image into a file
GlobalScope.launch(Dispatchers.IO) {
lifecycleScope.launch(Dispatchers.IO) {
val context = this@MainActivity
imageFile = FileUtil.from(context, result.data?.data!!).also {
ImageUtil(context).loadImage(context, it, binding.mainPicture)
Expand Down Expand Up @@ -174,7 +172,10 @@ class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks, I

override fun onPermissionsDenied(requestCode: Int, perms: List<String>) {
when {
EasyPermissions.somePermissionPermanentlyDenied(this, perms) -> SettingsDialog.Builder(
EasyPermissions.somePermissionPermanentlyDenied(
this,
perms
) -> SettingsDialog.Builder(
this
).build().show()
requestCode == PERMISSION_READ_EXTERNAL_STORAGE_REQUEST_CODE -> requestReadExternalStoragePermission()
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_info_square"
app:tint="?android:textColorPrimary"
tools:ignore="ContentDescription" />

<ImageView
Expand All @@ -38,10 +39,10 @@
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/choose_image"
android:textColor="?android:textColorPrimaryInverse"
android:textColor="@color/colorWhite"
app:backgroundTint="@color/colorPrimary"
app:icon="@drawable/ic_download"
app:iconTint="?android:textColorPrimaryInverse"
app:iconTint="@color/colorWhite"
app:layout_constraintBottom_toTopOf="@+id/mainCompress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand All @@ -52,11 +53,11 @@
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:text="@string/compress_image"
android:textColor="?android:textColorPrimaryInverse"
android:textColor="@color/colorWhite"
android:visibility="invisible"
app:backgroundTint="@color/colorAccent"
app:icon="@drawable/ic_upload"
app:iconTint="?android:textColorPrimaryInverse"
app:iconTint="@color/colorWhite"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorWhite</item>
</style>

</resources>
Binary file added readme.files/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed readme.files/imagine.png
Binary file not shown.

0 comments on commit 8189147

Please sign in to comment.