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

View file

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

View file

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