Skip to content

Commit

Permalink
refactor: changed the snackbar string
Browse files Browse the repository at this point in the history
  • Loading branch information
joragua committed Oct 8, 2024
1 parent 39b79b1 commit ca5c106
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ class PreviewAudioFragment : FileFragment() {

R.id.action_set_available_offline -> {
fileOperationsViewModel.performOperation(FileOperation.SetFilesAsAvailableOffline(listOf(file)))
Snackbar.make(requireView(), R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG).show()
showSnackbarMessage()
true
}

R.id.action_unset_available_offline -> {
fileOperationsViewModel.performOperation(FileOperation.UnsetFilesAsAvailableOffline(listOf(file)))
Snackbar.make(requireView(), R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG).show()
showSnackbarMessage()
true
}

Expand Down Expand Up @@ -359,6 +359,15 @@ class PreviewAudioFragment : FileFragment() {
}
}

private fun showSnackbarMessage(){
val snackbarString = if (file.isAvailableOffline){
R.string.confirmation_unset_available_offline
} else {
R.string.confirmation_set_available_offline
}
Snackbar.make(requireView(), snackbarString, Snackbar.LENGTH_LONG).show()
}

/**
* Defines callbacks for service binding, passed to bindService()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,12 @@ class PreviewImageFragment : FileFragment() {
}

private fun showSnackbarMessage() {
val snackbar = Snackbar.make(requireView(), R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG)
val snackbarString = if (file.isAvailableOffline){
R.string.confirmation_unset_available_offline
} else {
R.string.confirmation_set_available_offline
}
val snackbar = Snackbar.make(requireView(), snackbarString, Snackbar.LENGTH_LONG)
val params = snackbar.view.layoutParams as ViewGroup.MarginLayoutParams
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, 100)
snackbar.view.layoutParams = params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ class PreviewTextFragment : FileFragment() {
val fileToSetAsAvailableOffline = ArrayList<OCFile>()
fileToSetAsAvailableOffline.add(file)
fileOperationsViewModel.performOperation(FileOperation.SetFilesAsAvailableOffline(fileToSetAsAvailableOffline))
Snackbar.make(requireView(), R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG).show()
showSnackbarMessage()
true
}

R.id.action_unset_available_offline -> {
val fileToUnsetAsAvailableOffline = ArrayList<OCFile>()
fileToUnsetAsAvailableOffline.add(file)
fileOperationsViewModel.performOperation(FileOperation.UnsetFilesAsAvailableOffline(fileToUnsetAsAvailableOffline))
Snackbar.make(requireView(), R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG).show()
showSnackbarMessage()
true
}

Expand Down Expand Up @@ -275,6 +275,15 @@ class PreviewTextFragment : FileFragment() {
requireActivity().onBackPressed()
}

private fun showSnackbarMessage(){
val snackbarString = if (file.isAvailableOffline){
R.string.confirmation_unset_available_offline
} else {
R.string.confirmation_set_available_offline
}
Snackbar.make(requireView(), snackbarString, Snackbar.LENGTH_LONG).show()
}

private inner class TextLoadAsyncTask(
var textViewReference: TextView,
var rootView: RelativeLayout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ class PreviewVideoActivity : FileActivity(), Player.Listener, OnPrepareVideoPlay
val fileToSetAsAvailableOffline = ArrayList<OCFile>()
fileToSetAsAvailableOffline.add(file)
fileOperationsViewModel.performOperation(SetFilesAsAvailableOffline(fileToSetAsAvailableOffline))
Snackbar.make(binding.root, R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG).show()
showSnackbarMessage()
true
}

R.id.action_unset_available_offline -> {
val fileToUnsetAsAvailableOffline = ArrayList<OCFile>()
fileToUnsetAsAvailableOffline.add(file)
fileOperationsViewModel.performOperation(UnsetFilesAsAvailableOffline(fileToUnsetAsAvailableOffline))
Snackbar.make(binding.root, R.string.sync_file_nothing_to_do_msg, Snackbar.LENGTH_LONG).show()
showSnackbarMessage()
true
}

Expand All @@ -435,6 +435,15 @@ class PreviewVideoActivity : FileActivity(), Player.Listener, OnPrepareVideoPlay
}
}

private fun showSnackbarMessage(){
val snackbarString = if (file.isAvailableOffline){
R.string.confirmation_unset_available_offline
} else {
R.string.confirmation_set_available_offline
}
Snackbar.make(binding.root, snackbarString, Snackbar.LENGTH_LONG).show()
}

// The main_menu won't be displayed
override fun onCreateOptionsMenu(menu: Menu): Boolean {
return false
Expand Down
2 changes: 2 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@

<string name="set_available_offline">Set as available offline</string>
<string name="unset_available_offline">Unset as available offline</string>
<string name="confirmation_set_available_offline">The file was set as available offline correctly</string>
<string name="confirmation_unset_available_offline">The file was set as unavailable offline correctly</string>
<string name="common_rename">Rename</string>
<string name="common_remove">Remove</string>
<string name="confirmation_remove_file_alert">Do you really want to remove %1$s?</string>
Expand Down

0 comments on commit ca5c106

Please sign in to comment.