From ef8dfab7f7b849e00bf5b175352761e509dc5933 Mon Sep 17 00:00:00 2001 From: WirelessAlien <121420261+WirelessAlien@users.noreply.github.com> Date: Mon, 23 Dec 2024 22:56:34 +0530 Subject: [PATCH] update AboutFragment, add privacy policy, cleanup --- .../wirelessalien/zipxtract/AboutFragment.kt | 34 +++-- .../zipxtract/DonationFragment.kt | 7 +- .../zipxtract/fragment/ArchiveFragment.kt | 19 +++ .../zipxtract/fragment/MainFragment.kt | 16 ++ app/src/main/res/drawable/app_icon_m.xml | 56 +++++++ app/src/main/res/drawable/ic_7z.xml | 10 -- app/src/main/res/drawable/ic_archive.xml | 10 ++ app/src/main/res/drawable/ic_copy_all.xml | 22 --- app/src/main/res/drawable/ic_copy_file.xml | 22 --- app/src/main/res/drawable/ic_currency.xml | 22 --- app/src/main/res/drawable/ic_description.xml | 10 -- app/src/main/res/drawable/ic_files_copy.xml | 22 --- app/src/main/res/drawable/ic_folder_copy.xml | 22 --- app/src/main/res/drawable/ic_folder_zip.xml | 10 -- app/src/main/res/drawable/ic_home.xml | 10 ++ app/src/main/res/drawable/ic_rar.xml | 10 -- app/src/main/res/drawable/ic_search.xml | 7 +- app/src/main/res/layout/fragment_about.xml | 141 +++++++++--------- app/src/main/res/layout/fragment_donation.xml | 52 ++++--- app/src/main/res/menu/bottom_nav.xml | 4 +- app/src/main/res/menu/menu_main.xml | 6 + app/src/main/res/values/strings.xml | 6 + 22 files changed, 253 insertions(+), 265 deletions(-) create mode 100644 app/src/main/res/drawable/app_icon_m.xml delete mode 100644 app/src/main/res/drawable/ic_7z.xml create mode 100644 app/src/main/res/drawable/ic_archive.xml delete mode 100644 app/src/main/res/drawable/ic_copy_all.xml delete mode 100644 app/src/main/res/drawable/ic_copy_file.xml delete mode 100644 app/src/main/res/drawable/ic_currency.xml delete mode 100644 app/src/main/res/drawable/ic_description.xml delete mode 100644 app/src/main/res/drawable/ic_files_copy.xml delete mode 100644 app/src/main/res/drawable/ic_folder_copy.xml delete mode 100644 app/src/main/res/drawable/ic_folder_zip.xml create mode 100644 app/src/main/res/drawable/ic_home.xml delete mode 100644 app/src/main/res/drawable/ic_rar.xml diff --git a/app/src/main/java/com/wirelessalien/zipxtract/AboutFragment.kt b/app/src/main/java/com/wirelessalien/zipxtract/AboutFragment.kt index 9cb0550..79b3efd 100644 --- a/app/src/main/java/com/wirelessalien/zipxtract/AboutFragment.kt +++ b/app/src/main/java/com/wirelessalien/zipxtract/AboutFragment.kt @@ -21,29 +21,45 @@ import android.app.Dialog import android.content.Intent import android.net.Uri import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.Window import androidx.fragment.app.DialogFragment -import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.wirelessalien.zipxtract.databinding.FragmentAboutBinding class AboutFragment : DialogFragment() { + private lateinit var binding: FragmentAboutBinding + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = FragmentAboutBinding.inflate(inflater, container, false) + return binding.root + } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val binding = FragmentAboutBinding.inflate(layoutInflater) - val dialogView = binding.root + val dialog = super.onCreateDialog(savedInstanceState) + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) + return dialog + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) binding.versionNumberText.text = BuildConfig.VERSION_NAME - binding.githubIcon.setOnClickListener { + binding.sourceCode.setOnClickListener { openUrl("https://github.com/WirelessAlien/ZipXtract") } - binding.githubIssueButton.setOnClickListener { + binding.reportIssue.setOnClickListener { openUrl("https://github.com/WirelessAlien/ZipXtract/issues") } binding.licenseText.setOnClickListener { - openUrl("https://www.apache.org/licenses/LICENSE-2.0.txt") + openUrl("https://www.gnu.org/licenses/gpl-3.0.txt") } binding.donate.setOnClickListener { @@ -61,9 +77,9 @@ class AboutFragment : DialogFragment() { startActivity(Intent.createChooser(shareIntent, getString(R.string.share))) } - return MaterialAlertDialogBuilder(requireContext()) - .setView(dialogView) - .create() + binding.privacyPolicyLink.setOnClickListener { + openUrl("https://sites.google.com/view/privacy-policy-zipxtract/home") + } } private fun openUrl(url: String) { diff --git a/app/src/main/java/com/wirelessalien/zipxtract/DonationFragment.kt b/app/src/main/java/com/wirelessalien/zipxtract/DonationFragment.kt index f3eb26f..b135aae 100644 --- a/app/src/main/java/com/wirelessalien/zipxtract/DonationFragment.kt +++ b/app/src/main/java/com/wirelessalien/zipxtract/DonationFragment.kt @@ -18,15 +18,10 @@ package com.wirelessalien.zipxtract import android.app.Dialog -import android.content.ClipData -import android.content.ClipboardManager -import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle -import android.widget.Toast import androidx.fragment.app.DialogFragment -import com.google.android.material.button.MaterialButton import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.wirelessalien.zipxtract.databinding.FragmentDonationBinding @@ -48,7 +43,7 @@ class DonationFragment : DialogFragment() { startActivity(intent) } - return MaterialAlertDialogBuilder(requireContext()) + return MaterialAlertDialogBuilder(requireContext(), R.style.MaterialDialog) .setView(dView) .create() } diff --git a/app/src/main/java/com/wirelessalien/zipxtract/fragment/ArchiveFragment.kt b/app/src/main/java/com/wirelessalien/zipxtract/fragment/ArchiveFragment.kt index 980fc5f..5f7a692 100644 --- a/app/src/main/java/com/wirelessalien/zipxtract/fragment/ArchiveFragment.kt +++ b/app/src/main/java/com/wirelessalien/zipxtract/fragment/ArchiveFragment.kt @@ -45,6 +45,7 @@ import androidx.core.content.FileProvider import androidx.core.view.MenuHost import androidx.core.view.MenuProvider import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentTransaction import androidx.lifecycle.Lifecycle import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.recyclerview.widget.LinearLayoutManager @@ -53,6 +54,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.progressindicator.LinearProgressIndicator import com.google.android.material.snackbar.Snackbar import com.google.android.material.textfield.TextInputEditText +import com.wirelessalien.zipxtract.AboutFragment import com.wirelessalien.zipxtract.BuildConfig import com.wirelessalien.zipxtract.R import com.wirelessalien.zipxtract.adapter.FileAdapter @@ -82,6 +84,7 @@ class ArchiveFragment : Fragment(), FileAdapter.OnItemClickListener { SORT_BY_NAME, SORT_BY_SIZE, SORT_BY_MODIFIED, SORT_BY_EXTENSION } private var isSearchActive: Boolean = false + private var isLargeLayout: Boolean = false private var sortBy: SortBy = SortBy.SORT_BY_NAME private var sortAscending: Boolean = true @@ -146,6 +149,7 @@ class ArchiveFragment : Fragment(), FileAdapter.OnItemClickListener { sharedPreferences = requireActivity().getPreferences(Context.MODE_PRIVATE) sortBy = SortBy.valueOf(sharedPreferences.getString("sortBy", SortBy.SORT_BY_NAME.name) ?: SortBy.SORT_BY_NAME.name) sortAscending = sharedPreferences.getBoolean("sortAscending", true) + isLargeLayout = resources.getBoolean(R.bool.large_layout) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) adapter = FileAdapter(requireContext(), null, ArrayList()) @@ -207,6 +211,21 @@ class ArchiveFragment : Fragment(), FileAdapter.OnItemClickListener { sortAscending = false editor.putBoolean("sortAscending", sortAscending) } + R.id.menu_about -> { + val fragmentManager = parentFragmentManager + val newFragment = AboutFragment() + if (isLargeLayout) { + // Show the fragment as a dialog. + newFragment.show(fragmentManager, "AboutFragment") + } else { + // Show the fragment fullscreen. + val transaction = fragmentManager.beginTransaction() + transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) + transaction.add(android.R.id.content, newFragment) + .addToBackStack(null) + .commit() + } + } } editor.apply() updateAdapterWithFullList() diff --git a/app/src/main/java/com/wirelessalien/zipxtract/fragment/MainFragment.kt b/app/src/main/java/com/wirelessalien/zipxtract/fragment/MainFragment.kt index 824af08..e5626a3 100644 --- a/app/src/main/java/com/wirelessalien/zipxtract/fragment/MainFragment.kt +++ b/app/src/main/java/com/wirelessalien/zipxtract/fragment/MainFragment.kt @@ -65,6 +65,7 @@ import com.google.android.material.chip.Chip import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.progressindicator.LinearProgressIndicator import com.google.android.material.textfield.TextInputEditText +import com.wirelessalien.zipxtract.AboutFragment import com.wirelessalien.zipxtract.BuildConfig import com.wirelessalien.zipxtract.R import com.wirelessalien.zipxtract.adapter.FileAdapter @@ -268,6 +269,21 @@ class MainFragment : Fragment(), FileAdapter.OnItemClickListener, FileAdapter.On sortAscending = false editor.putBoolean("sortAscending", sortAscending) } + R.id.menu_about -> { + val fragmentManager = parentFragmentManager + val newFragment = AboutFragment() + if (isLargeLayout) { + // Show the fragment as a dialog. + newFragment.show(fragmentManager, "AboutFragment") + } else { + // Show the fragment fullscreen. + val transaction = fragmentManager.beginTransaction() + transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) + transaction.add(android.R.id.content, newFragment) + .addToBackStack(null) + .commit() + } + } } editor.apply() initRecyclerView() diff --git a/app/src/main/res/drawable/app_icon_m.xml b/app/src/main/res/drawable/app_icon_m.xml new file mode 100644 index 0000000..6a9d3f3 --- /dev/null +++ b/app/src/main/res/drawable/app_icon_m.xml @@ -0,0 +1,56 @@ + + +> + + + + + + + diff --git a/app/src/main/res/drawable/ic_7z.xml b/app/src/main/res/drawable/ic_7z.xml deleted file mode 100644 index 5fbd0eb..0000000 --- a/app/src/main/res/drawable/ic_7z.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_archive.xml b/app/src/main/res/drawable/ic_archive.xml new file mode 100644 index 0000000..e30cd92 --- /dev/null +++ b/app/src/main/res/drawable/ic_archive.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_copy_all.xml b/app/src/main/res/drawable/ic_copy_all.xml deleted file mode 100644 index 5e2e53a..0000000 --- a/app/src/main/res/drawable/ic_copy_all.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ic_copy_file.xml b/app/src/main/res/drawable/ic_copy_file.xml deleted file mode 100644 index 43971d0..0000000 --- a/app/src/main/res/drawable/ic_copy_file.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ic_currency.xml b/app/src/main/res/drawable/ic_currency.xml deleted file mode 100644 index c94c779..0000000 --- a/app/src/main/res/drawable/ic_currency.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ic_description.xml b/app/src/main/res/drawable/ic_description.xml deleted file mode 100644 index 88228ee..0000000 --- a/app/src/main/res/drawable/ic_description.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_files_copy.xml b/app/src/main/res/drawable/ic_files_copy.xml deleted file mode 100644 index 8c568d8..0000000 --- a/app/src/main/res/drawable/ic_files_copy.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ic_folder_copy.xml b/app/src/main/res/drawable/ic_folder_copy.xml deleted file mode 100644 index b2c5b99..0000000 --- a/app/src/main/res/drawable/ic_folder_copy.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ic_folder_zip.xml b/app/src/main/res/drawable/ic_folder_zip.xml deleted file mode 100644 index 671672e..0000000 --- a/app/src/main/res/drawable/ic_folder_zip.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_home.xml b/app/src/main/res/drawable/ic_home.xml new file mode 100644 index 0000000..8e36707 --- /dev/null +++ b/app/src/main/res/drawable/ic_home.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_rar.xml b/app/src/main/res/drawable/ic_rar.xml deleted file mode 100644 index 0e4f604..0000000 --- a/app/src/main/res/drawable/ic_rar.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml index 1e3507d..6be9175 100644 --- a/app/src/main/res/drawable/ic_search.xml +++ b/app/src/main/res/drawable/ic_search.xml @@ -3,9 +3,8 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" - android:tint="?attr/colorControlNormal" - android:autoMirrored="true"> + android:tint="?attr/colorControlNormal"> + android:fillColor="#FF000000" + android:pathData="M380,640q-109,0 -184.5,-75.5T120,380q0,-109 75.5,-184.5T380,120q109,0 184.5,75.5T640,380q0,44 -14,83t-38,69l224,224q11,11 11,28t-11,28q-11,11 -28,11t-28,-11L532,588q-30,24 -69,38t-83,14ZM380,560q75,0 127.5,-52.5T560,380q0,-75 -52.5,-127.5T380,200q-75,0 -127.5,52.5T200,380q0,75 52.5,127.5T380,560Z"/> diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 9cc47d1..ec35311 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -20,84 +20,91 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:padding="15dp" + android:background="@color/md_theme_surface" + android:padding="16dp" android:gravity="center"> + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_gravity="center" + android:src="@drawable/app_icon_m" /> - + + + + + + + android:text="@string/license" + android:textColor="?attr/colorPrimary" + android:paddingTop="8dp" /> - - - - + + + + - + android:text="@string/donate" + app:cornerRadius="5dp" + style="@style/Widget.Material3.Button.TonalButton" + android:layout_marginTop="20dp" /> - + - + - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_donation.xml b/app/src/main/res/layout/fragment_donation.xml index 0eb684c..fb7bb9f 100644 --- a/app/src/main/res/layout/fragment_donation.xml +++ b/app/src/main/res/layout/fragment_donation.xml @@ -17,39 +17,37 @@ ~ along with this program. If not, see . --> - - + + - - + android:textSize="18sp" + android:text="@string/donate"/> - + - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav.xml b/app/src/main/res/menu/bottom_nav.xml index 3683b6f..69324d2 100644 --- a/app/src/main/res/menu/bottom_nav.xml +++ b/app/src/main/res/menu/bottom_nav.xml @@ -20,11 +20,11 @@ \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 81c597f..65aa0f8 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -40,5 +40,11 @@ android:title="@string/descending" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 669ae65..3513ef4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -132,4 +132,10 @@ Extracting… %1$d %% Compressing… %1$d %% Home + Privacy Policy + Source Code + License + Author: WirelessAlien + Report an Issue + About \ No newline at end of file