Rename conflict dialog resolver binding variables

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-08-21 10:48:57 +02:00
parent dfd13650d6
commit 15997940a6
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
3 changed files with 45 additions and 45 deletions

View file

@ -209,7 +209,7 @@ public class ConflictsResolveActivityIT extends AbstractIT {
getInstrumentation().waitForIdleSync(); getInstrumentation().waitForIdleSync();
onView(withId(R.id.existing_checkbox)).perform(click()); onView(withId(R.id.right_checkbox)).perform(click());
DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog"); DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog");
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView()); screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
@ -255,7 +255,7 @@ public class ConflictsResolveActivityIT extends AbstractIT {
getInstrumentation().waitForIdleSync(); getInstrumentation().waitForIdleSync();
onView(withId(R.id.new_checkbox)).perform(click()); onView(withId(R.id.left_checkbox)).perform(click());
DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog"); DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog");
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView()); screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
@ -300,8 +300,8 @@ public class ConflictsResolveActivityIT extends AbstractIT {
getInstrumentation().waitForIdleSync(); getInstrumentation().waitForIdleSync();
onView(withId(R.id.existing_checkbox)).perform(click()); onView(withId(R.id.right_checkbox)).perform(click());
onView(withId(R.id.new_checkbox)).perform(click()); onView(withId(R.id.left_checkbox)).perform(click());
DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog"); DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog");
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView()); screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());

View file

@ -149,20 +149,20 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = ConflictResolveDialogBinding.inflate(requireActivity().layoutInflater) binding = ConflictResolveDialogBinding.inflate(requireActivity().layoutInflater)
viewThemeUtils.platform.themeCheckbox(binding.newCheckbox) viewThemeUtils.platform.themeCheckbox(binding.leftCheckbox)
viewThemeUtils.platform.themeCheckbox(binding.existingCheckbox) viewThemeUtils.platform.themeCheckbox(binding.rightCheckbox)
val builder = MaterialAlertDialogBuilder(requireContext()) val builder = MaterialAlertDialogBuilder(requireContext())
.setView(binding.root) .setView(binding.root)
.setPositiveButton(R.string.common_ok) { _: DialogInterface?, _: Int -> .setPositiveButton(R.string.common_ok) { _: DialogInterface?, _: Int ->
val decision = when { val decision = when {
binding.newCheckbox.isChecked && binding.existingCheckbox.isChecked -> binding.leftCheckbox.isChecked && binding.rightCheckbox.isChecked ->
if (offlineOperation != null && serverFile != null) Decision.KEEP_BOTH_FOLDER else Decision.KEEP_BOTH if (offlineOperation != null && serverFile != null) Decision.KEEP_BOTH_FOLDER else Decision.KEEP_BOTH
binding.newCheckbox.isChecked -> binding.leftCheckbox.isChecked ->
if (offlineOperation != null && serverFile != null) Decision.KEEP_OFFLINE_FOLDER else Decision.KEEP_LOCAL if (offlineOperation != null && serverFile != null) Decision.KEEP_OFFLINE_FOLDER else Decision.KEEP_LOCAL
binding.existingCheckbox.isChecked -> binding.rightCheckbox.isChecked ->
if (offlineOperation != null && serverFile != null) Decision.KEEP_SERVER_FOLDER else Decision.KEEP_SERVER if (offlineOperation != null && serverFile != null) Decision.KEEP_SERVER_FOLDER else Decision.KEEP_SERVER
else -> null else -> null
@ -184,7 +184,7 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
setOnClickListeners() setOnClickListeners()
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.existingFileContainer.context, builder) viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.rightFileContainer.context, builder)
return builder.create() return builder.create()
} }
@ -194,19 +194,19 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
folderName.visibility = View.GONE folderName.visibility = View.GONE
title.visibility = View.GONE title.visibility = View.GONE
description.text = getString(R.string.conflict_message_description_for_folder) description.text = getString(R.string.conflict_message_description_for_folder)
newCheckbox.text = getString(R.string.prefs_synced_folders_local_path_title) leftCheckbox.text = getString(R.string.prefs_synced_folders_local_path_title)
existingCheckbox.text = getString(R.string.prefs_synced_folders_remote_path_title) rightCheckbox.text = getString(R.string.prefs_synced_folders_remote_path_title)
val folderIcon = MimeTypeUtil.getDefaultFolderIcon(requireContext(), viewThemeUtils) val folderIcon = MimeTypeUtil.getDefaultFolderIcon(requireContext(), viewThemeUtils)
newThumbnail.setImageDrawable(folderIcon) leftThumbnail.setImageDrawable(folderIcon)
newTimestamp.text = leftTimestamp.text =
DisplayUtils.getRelativeTimestamp(requireContext(), offlineOperation?.createdAt?.times(1000L) ?: 0) DisplayUtils.getRelativeTimestamp(requireContext(), offlineOperation?.createdAt?.times(1000L) ?: 0)
newSize.text = DisplayUtils.bytesToHumanReadable(0) leftFileSize.text = DisplayUtils.bytesToHumanReadable(0)
existingThumbnail.setImageDrawable(folderIcon) rightThumbnail.setImageDrawable(folderIcon)
existingTimestamp.text = rightTimestamp.text =
DisplayUtils.getRelativeTimestamp(requireContext(), serverFile?.modificationTimestamp ?: 0) DisplayUtils.getRelativeTimestamp(requireContext(), serverFile?.modificationTimestamp ?: 0)
existingSize.text = DisplayUtils.bytesToHumanReadable(serverFile?.fileLength ?: 0) rightFileSize.text = DisplayUtils.bytesToHumanReadable(serverFile?.fileLength ?: 0)
} }
} }
@ -219,29 +219,29 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
} }
// set info for new file // set info for new file
binding.newSize.text = newFile?.length()?.let { DisplayUtils.bytesToHumanReadable(it) } binding.leftFileSize.text = newFile?.length()?.let { DisplayUtils.bytesToHumanReadable(it) }
binding.newTimestamp.text = newFile?.lastModified()?.let { DisplayUtils.getRelativeTimestamp(context, it) } binding.leftTimestamp.text = newFile?.lastModified()?.let { DisplayUtils.getRelativeTimestamp(context, it) }
binding.newThumbnail.tag = newFile?.hashCode() binding.leftThumbnail.tag = newFile?.hashCode()
LocalFileListAdapter.setThumbnail( LocalFileListAdapter.setThumbnail(
newFile, newFile,
binding.newThumbnail, binding.leftThumbnail,
context, context,
viewThemeUtils viewThemeUtils
) )
// set info for existing file // set info for existing file
binding.existingSize.text = existingFile?.fileLength?.let { DisplayUtils.bytesToHumanReadable(it) } binding.rightFileSize.text = existingFile?.fileLength?.let { DisplayUtils.bytesToHumanReadable(it) }
binding.existingTimestamp.text = existingFile?.modificationTimestamp?.let { binding.rightTimestamp.text = existingFile?.modificationTimestamp?.let {
DisplayUtils.getRelativeTimestamp( DisplayUtils.getRelativeTimestamp(
context, context,
it it
) )
} }
binding.existingThumbnail.tag = existingFile?.fileId binding.rightThumbnail.tag = existingFile?.fileId
DisplayUtils.setThumbnail( DisplayUtils.setThumbnail(
existingFile, existingFile,
binding.existingThumbnail, binding.rightThumbnail,
user, user,
FileDataStorageManager( FileDataStorageManager(
user, user,
@ -260,20 +260,20 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
private fun setOnClickListeners() { private fun setOnClickListeners() {
binding.run { binding.run {
val checkBoxClickListener = View.OnClickListener { val checkBoxClickListener = View.OnClickListener {
positiveButton?.isEnabled = newCheckbox.isChecked || existingCheckbox.isChecked positiveButton?.isEnabled = leftCheckbox.isChecked || rightCheckbox.isChecked
} }
newCheckbox.setOnClickListener(checkBoxClickListener) leftCheckbox.setOnClickListener(checkBoxClickListener)
existingCheckbox.setOnClickListener(checkBoxClickListener) rightCheckbox.setOnClickListener(checkBoxClickListener)
newFileContainer.setOnClickListener { leftFileContainer.setOnClickListener {
newCheckbox.isChecked = !newCheckbox.isChecked leftCheckbox.isChecked = !leftCheckbox.isChecked
positiveButton?.isEnabled = newCheckbox.isChecked || existingCheckbox.isChecked positiveButton?.isEnabled = leftCheckbox.isChecked || rightCheckbox.isChecked
} }
existingFileContainer.setOnClickListener { rightFileContainer.setOnClickListener {
existingCheckbox.isChecked = !existingCheckbox.isChecked rightCheckbox.isChecked = !rightCheckbox.isChecked
positiveButton?.isEnabled = newCheckbox.isChecked || existingCheckbox.isChecked positiveButton?.isEnabled = leftCheckbox.isChecked || rightCheckbox.isChecked
} }
} }
} }

View file

@ -43,20 +43,20 @@
android:baselineAligned="false"> android:baselineAligned="false">
<LinearLayout <LinearLayout
android:id="@+id/newFileContainer" android:id="@+id/leftFileContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<androidx.appcompat.widget.AppCompatCheckBox <androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/new_checkbox" android:id="@+id/left_checkbox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/conflict_local_file" /> android:text="@string/conflict_local_file" />
<ImageView <ImageView
android:id="@+id/new_thumbnail" android:id="@+id/left_thumbnail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
android:layout_margin="@dimen/standard_half_margin" android:layout_margin="@dimen/standard_half_margin"
@ -64,33 +64,33 @@
android:contentDescription="@string/thumbnail_for_new_file_desc" /> android:contentDescription="@string/thumbnail_for_new_file_desc" />
<TextView <TextView
android:id="@+id/new_timestamp" android:id="@+id/left_timestamp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="12. Dec 2020 - 23:10:20" /> tools:text="12. Dec 2020 - 23:10:20" />
<TextView <TextView
android:id="@+id/new_size" android:id="@+id/left_file_size"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="5 Mb" /> tools:text="5 Mb" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/existingFileContainer" android:id="@+id/rightFileContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<androidx.appcompat.widget.AppCompatCheckBox <androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/existing_checkbox" android:id="@+id/right_checkbox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/conflict_server_file" /> android:text="@string/conflict_server_file" />
<ImageView <ImageView
android:id="@+id/existing_thumbnail" android:id="@+id/right_thumbnail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
android:layout_margin="@dimen/standard_half_margin" android:layout_margin="@dimen/standard_half_margin"
@ -98,13 +98,13 @@
android:contentDescription="@string/thumbnail_for_existing_file_description" /> android:contentDescription="@string/thumbnail_for_existing_file_description" />
<TextView <TextView
android:id="@+id/existing_timestamp" android:id="@+id/right_timestamp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="10. Dec 2020 - 10:10:10" /> tools:text="10. Dec 2020 - 10:10:10" />
<TextView <TextView
android:id="@+id/existing_size" android:id="@+id/right_file_size"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="3 Mb" /> tools:text="3 Mb" />