Skip to content

Commit

Permalink
remove unused resource, refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
WirelessAlien committed Jan 4, 2025
1 parent 33bd3e7 commit 84bf375
Show file tree
Hide file tree
Showing 35 changed files with 212 additions and 750 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk 24
targetSdk 34
versionCode 15
versionName "5.0-beta"
versionName "5.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ class MainActivity : AppCompatActivity() {
val textView = dialogView.findViewById<TextView>(R.id.crash_log_text)
textView.text = crashLog.toString()

MaterialAlertDialogBuilder(this)
MaterialAlertDialogBuilder(this, R.style.MaterialDialog)
.setTitle(getString(R.string.crash_log))
.setView(dialogView)
.setPositiveButton(getString(R.string.copy_text)) { _: DialogInterface?, _: Int ->
val clipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("ShowCase Crash Log", crashLog.toString())
val clip = ClipData.newPlainText("ZipXtract Crash Log", crashLog.toString())
clipboard.setPrimaryClip(clip)
Toast.makeText(this@MainActivity, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ class OpenWithActivity : AppCompatActivity() {
val textView = dialogView.findViewById<TextView>(R.id.crash_log_text)
textView.text = crashLog.toString()

MaterialAlertDialogBuilder(this)
MaterialAlertDialogBuilder(this, R.style.MaterialDialog)
.setTitle(getString(R.string.crash_log))
.setView(dialogView)
.setPositiveButton(getString(R.string.copy_text)) { _: DialogInterface?, _: Int ->
val clipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("ShowCase Crash Log", crashLog.toString())
val clip = ClipData.newPlainText("ZipXtract Crash Log", crashLog.toString())
clipboard.setPrimaryClip(clip)
Toast.makeText(this@OpenWithActivity, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
}
Expand All @@ -89,8 +89,6 @@ class OpenWithActivity : AppCompatActivity() {

val uri = intent?.data
if (uri != null) {
Log.i("OpenWithActivity", "Received URI: $uri")
Log.i("OpenWithActivity", "Received URI path: ${uri.path}")
showPasswordInputDialog(uri)
} else {
Toast.makeText(this, getString(R.string.no_file_selected), Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SettingsActivity : AppCompatActivity() {

// Display the fragment as the main content.
supportFragmentManager.beginTransaction()
.replace(R.id.fragmentCntainer, SettingsFragment())
.replace(R.id.fragmentContainer, SettingsFragment())
.commit()

// Add back button to the activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ class FileAdapter(private val context: Context, private val mainFragment: MainFr
"FILE"
} else {
if (file.extension.length == 4) {
holder.fileExtension.textSize = 12f
holder.fileExtension.textSize = 16f
} else {
holder.fileExtension.textSize = 14f
holder.fileExtension.textSize = 18f
}
file.extension.uppercase(Locale.getDefault())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package com.wirelessalien.zipxtract.fragment

import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
Expand All @@ -31,6 +33,7 @@ import android.os.Environment
import android.os.Handler
import android.os.Looper
import android.os.storage.StorageManager
import android.text.Editable
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
Expand Down Expand Up @@ -420,7 +423,7 @@ class ArchiveFragment : Fragment(), FileAdapter.OnItemClickListener {
}

btnMultiExtract.setOnClickListener {
showPasswordInputMultiDialog(filePath)
showPasswordInputMultiRarDialog(filePath)
bottomSheetDialog.dismiss()
}

Expand Down Expand Up @@ -492,7 +495,7 @@ class ArchiveFragment : Fragment(), FileAdapter.OnItemClickListener {
.show()
}

private fun showPasswordInputMultiDialog(file: String) {
private fun showPasswordInputMultiRarDialog(file: String) {
val dialogView = layoutInflater.inflate(R.layout.password_input_dialog, null)
val passwordEditText = dialogView.findViewById<TextInputEditText>(R.id.passwordInput)

Expand Down Expand Up @@ -590,20 +593,37 @@ class ArchiveFragment : Fragment(), FileAdapter.OnItemClickListener {
private fun showFileInfo(file: File) {
val dialogView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_file_info, null)

val fileNameTextView = dialogView.findViewById<TextView>(R.id.file_name)
val filePathTextView = dialogView.findViewById<TextView>(R.id.file_path)
val fileNameTextView = dialogView.findViewById<TextInputEditText>(R.id.file_name)
val filePathTextView = dialogView.findViewById<TextInputEditText>(R.id.file_path)
val fileSizeTextView = dialogView.findViewById<TextView>(R.id.file_size)
val lastModifiedTextView = dialogView.findViewById<TextView>(R.id.last_modified)
val okButton = dialogView.findViewById<Button>(R.id.ok_button)

fileNameTextView.text = file.name
filePathTextView.text = file.absolutePath
fileNameTextView.text = Editable.Factory.getInstance().newEditable(file.name)
filePathTextView.text = Editable.Factory.getInstance().newEditable(file.absolutePath)
val fileSizeText = bytesToString(file.length())
fileSizeTextView.text = fileSizeText
val dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT, Locale.getDefault())
lastModifiedTextView.text = dateFormat.format(Date(file.lastModified()))

val clipboardManager = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
fileNameTextView.setOnLongClickListener {
val clip = ClipData.newPlainText("File Name", file.name)
clipboardManager.setPrimaryClip(clip)
Toast.makeText(requireContext(), getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show()
true
}

filePathTextView.setOnLongClickListener {
val clip = ClipData.newPlainText("File Path", file.absolutePath)
clipboardManager.setPrimaryClip(clip)
Toast.makeText(requireContext(), getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show()
true
}

val dialog = MaterialAlertDialogBuilder(requireContext(), R.style.MaterialDialog)
.setView(dialogView)
.setTitle(getString(R.string.file_info))
.create()

okButton.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
}
}
}

startFileObserver()

val filter = IntentFilter().apply {
Expand Down Expand Up @@ -1008,6 +1007,7 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
val btnGzip = view.findViewById<MaterialButton>(R.id.btnGzip)
val extractBtn = view.findViewById<MaterialButton>(R.id.btnExtract)
val btnOpenWith = view.findViewById<MaterialButton>(R.id.btnOpenWith)
val btnFileInfo = view.findViewById<MaterialButton>(R.id.btnFileInfo)
val fileNameTv = view.findViewById<TextView>(R.id.fileName)
val fileExtensionTv = view.findViewById<TextView>(R.id.fileExtension)
val fileModifiedTv = view.findViewById<TextView>(R.id.fileDate)
Expand All @@ -1022,9 +1022,9 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
"FILE"
} else {
if (file.extension.length == 4) {
fileExtensionTv.textSize = 12f
fileExtensionTv.textSize = 16f
} else {
fileExtensionTv.textSize = 14f
fileExtensionTv.textSize = 18f
}
file.extension.uppercase(Locale.getDefault())
}
Expand Down Expand Up @@ -1072,6 +1072,11 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
bottomSheetDialog.dismiss()
}

btnFileInfo.setOnClickListener {
showFileInfo(file)
bottomSheetDialog.dismiss()
}

btnDelete.setOnClickListener {
MaterialAlertDialogBuilder(requireContext(), R.style.MaterialDialog)
.setTitle(getString(R.string.confirm_delete))
Expand Down Expand Up @@ -1137,9 +1142,9 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On
"FILE"
} else {
if (file.extension.length == 4) {
fileExtensionTv.textSize = 12f
fileExtensionTv.textSize = 16f
} else {
fileExtensionTv.textSize = 14f
fileExtensionTv.textSize = 18f
}
file.extension.uppercase(Locale.getDefault())
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/app_icon_m.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="800dp"
android:height="800dp"
android:width="200dp"
android:height="200dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">>
android:tint="?attr/colorControlNormal">
<path
android:pathData="M3,14V10C3,6.229 3,4.343 4.172,3.172C5.343,2 7.229,2 11,2H13C16.771,2 18.657,2 19.828,3.172C20.482,3.825 20.771,4.7 20.899,6M21,10V14C21,17.771 21,19.657 19.828,20.828C18.657,22 16.771,22 13,22H11C7.229,22 5.343,22 4.172,20.828C3.518,20.175 3.229,19.3 3.101,18"
android:strokeWidth="1.6320000000000001"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</com.google.android.material.appbar.AppBarLayout>

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragmentCntainer"
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Expand Down
19 changes: 15 additions & 4 deletions app/src/main/res/layout/bottom_sheet_compressor_archive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
android:layout_width="48dp"
android:layout_height="48dp"
style="@style/Widget.Material3.CardView.Filled"
android:elevation="3dp"
android:elevation="0dp"
app:cardCornerRadius="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -79,7 +79,7 @@
android:layout_gravity="center"
android:fontFamily="@font/bebasneue_regular"
android:text="FILE"
android:textSize="14sp"
android:textSize="18sp"
android:textStyle="bold"/>
</com.google.android.material.card.MaterialCardView>

Expand Down Expand Up @@ -139,7 +139,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="16dp"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
Expand Down Expand Up @@ -193,13 +193,24 @@
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/btnDelete"
android:id="@+id/btnFileInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cornerRadius="5dp"
style="@style/Widget.Material3.Button.TonalButton"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:text="@string/file_info" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cornerRadius="5dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="20dp"
android:text="@string/delete" />
</LinearLayout>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/bottom_sheet_option.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
android:layout_width="48dp"
android:layout_height="48dp"
style="@style/Widget.Material3.CardView.Filled"
android:elevation="3dp"
android:elevation="0dp"
app:cardCornerRadius="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -63,7 +63,7 @@
android:layout_gravity="center"
android:fontFamily="@font/bebasneue_regular"
android:text="FILE"
android:textSize="14sp"
android:textSize="18sp"
android:textStyle="bold"/>
</com.google.android.material.card.MaterialCardView>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
app:chipIconVisible="true"
app:chipIcon="@drawable/ic_change"
app:chipCornerRadius="4dp"
android:text="Storage"/>
android:text="@string/storage"/>

<com.google.android.material.chip.Chip
android:id="@+id/internalStorageChip"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/item_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
android:id="@+id/card_view"
android:layout_width="48dp"
android:layout_height="48dp"
style="@style/Widget.Material3.CardView.Elevated"
android:elevation="3dp"
style="@style/Widget.Material3.CardView.Filled"
android:elevation="0dp"
app:cardCornerRadius="5dp"
android:layout_margin="5dp"
app:layout_constraintBottom_toBottomOf="parent"
Expand All @@ -66,7 +66,7 @@
android:id="@+id/file_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="10dp"
android:padding="8dp"
android:src="@drawable/ic_unknown"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -79,7 +79,7 @@
android:layout_gravity="center"
android:fontFamily="@font/bebasneue_regular"
android:text="FILE"
android:textSize="14sp"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="gone" />
</com.google.android.material.card.MaterialCardView>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/progress_dialog_extract.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:id="@+id/progressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/extracting"
android:text="@string/extraction_ongoing"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/seven_z_option_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clickable="true"
android:background="@color/md_theme_surface"
xmlns:app="http://schemas.android.com/apk/res-auto">

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/tar_option_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clickable="true"
android:background="@color/md_theme_surface"
xmlns:app="http://schemas.android.com/apk/res-auto">

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/zip_option_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clickable="true"
android:background="@color/md_theme_surface"
xmlns:app="http://schemas.android.com/apk/res-auto">

Expand Down
Loading

0 comments on commit 84bf375

Please sign in to comment.