Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions app/src/main/java/com/certified/audionote/ui/EditNoteFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.certified.audionote.ui
import android.Manifest
import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.content.Context
import android.media.MediaPlayer
import android.media.MediaRecorder
import android.os.Bundle
Expand Down Expand Up @@ -75,7 +76,6 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
private var mediaRecorder: MediaRecorder? = null
private var mediaPlayer: MediaPlayer? = null
private var file: File? = null
private val noteIsRequired = "The note title is required"
private var stopWatch: Stopwatch? = null
private var timer: Timer? = null

Expand Down Expand Up @@ -113,7 +113,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
openEditReminderDialog()
}
btnShare.setOnClickListener { shareNote(_note) }
btnDelete.setOnClickListener { launchDeleteNoteDialog() }
btnDelete.setOnClickListener { launchDeleteNoteDialog(requireContext()) }
btnRecord.setOnClickListener(this@EditNoteFragment)
fabSaveNote.setOnClickListener(this@EditNoteFragment)

Expand Down Expand Up @@ -152,7 +152,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
etNoteTitle.apply {
// inputType = InputType.TYPE_NULL
keyListener = null
setOnClickListener { showToast("You can't edit the note title") }
setOnClickListener { showToast(requireContext().getString(R.string.cant_edit_note_title)) }
}
btnRecord.setImageDrawable(
ResourcesCompat.getDrawable(
Expand Down Expand Up @@ -248,7 +248,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
startAlarm(requireContext(), pickedDateTime!!.timeInMillis, note)
navController.navigate(R.id.action_editNoteFragment_to_homeFragment)
} else {
showToast(noteIsRequired)
showToast(requireContext().getString(R.string.title_required))
etNoteTitle.requestFocus()
}
}
Expand All @@ -274,13 +274,13 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
startRecording()
}
else {
showToast(noteIsRequired)
showToast(requireContext().getString(R.string.title_required))
etNoteTitle.requestFocus()
}
else
requestPermission(
requireActivity(),
"This permission is required to enable audio recording",
requireContext().getString(R.string.permission_required),
MainActivity.RECORD_AUDIO_PERMISSION_CODE,
Manifest.permission.RECORD_AUDIO
)
Expand All @@ -304,12 +304,12 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
description = etNoteDescription.text.toString().trim()
)
viewModel.insertNote(note)
showToast("Note saved")
showToast(requireContext().getString(R.string.note_saved))
if (pickedDateTime?.timeInMillis != null && pickedDateTime!!.timeInMillis <= currentDateTime.timeInMillis)
startAlarm(requireContext(), pickedDateTime!!.timeInMillis, note)
navController.navigate(R.id.action_editNoteFragment_to_homeFragment)
} else {
showToast(noteIsRequired)
showToast(requireContext().getString(R.string.title_required))
etNoteTitle.requestFocus()
}
}
Expand Down Expand Up @@ -373,13 +373,13 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
bottomSheetDialog.show()
}

private fun launchDeleteNoteDialog() {
private fun launchDeleteNoteDialog(context: Context) {
val materialDialog = MaterialAlertDialogBuilder(requireContext())
materialDialog.apply {
setTitle("Delete Note")
setMessage("Are you sure you want to delete ${_note.title}?")
setNegativeButton("No") { dialog, _ -> dialog?.dismiss() }
setPositiveButton("Yes") { _, _ ->
setTitle(context.getString(R.string.delete_note))
setMessage("${context.getString(R.string.confirm_deletion)} ${_note.title}?")
setNegativeButton(context.getString(R.string.no)) { dialog, _ -> dialog?.dismiss() }
setPositiveButton(context.getString(R.string.yes)) { _, _ ->
viewModel.deleteNote(_note)
lifecycleScope.launch(Dispatchers.IO) { file?.delete() }
navController.navigate(R.id.action_editNoteFragment_to_homeFragment)
Expand All @@ -392,7 +392,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
val filePath = filePath(requireActivity())
val fileName = "${binding.etNoteTitle.text.toString().trim()}.3gp"
_note.filePath = "$filePath/$fileName"
showToast("Started recording")
showToast(requireContext().getString(R.string.started_recording))

stopWatch = StopwatchBuilder()
.startFormat("MM:SS")
Expand All @@ -412,7 +412,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
stopWatch!!.start()
disableNoteTitleEdit()
} catch (e: IOException) {
showToast("An error occurred")
showToast(requireContext().getString(R.string.error_occurred))
}
}
}
Expand All @@ -433,7 +433,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
val fileByte = (file.readBytes().size.toDouble() / 1048576.00)
val fileSize = roundOffDecimal(fileByte).toString()
_note.size = fileSize
showToast("Stopped recording")
showToast(requireContext().getString(R.string.stopped_recording))
}

private fun startPlayingRecording() {
Expand Down Expand Up @@ -462,18 +462,18 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
start()
}
timer!!.start()
showToast("Started playing recording")
showToast(requireContext().getString(R.string.started_playing_recording))
} catch (e: IOException) {
e.printStackTrace()
Log.d("TAG", "startPlayingRecording: ${e.localizedMessage}")
showToast("An error occurred")
showToast(requireContext().getString(R.string.error_occurred))
}
}

private fun disableNoteTitleEdit() {
binding.etNoteTitle.apply {
keyListener = null
setOnClickListener { showToast("You can't edit the note title") }
setOnClickListener { showToast(requireContext().getString(R.string.cant_edit_note_title)) }
}
}

Expand All @@ -497,7 +497,7 @@ class EditNoteFragment : Fragment(), View.OnClickListener, DatePickerDialog.OnDa
stop()
}
timer = null
showToast("Stopped playing recording")
showToast(requireContext().getString(R.string.stopped_playing_recording))
}

private fun shareNote(note: Note) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/bottom_sheet_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Now playing"
android:text="@string/now_playing"
android:textSize="@dimen/_12ssp"
android:textColor="@color/black_day_white_night"
android:fontFamily="@font/open_sans_regular"
Expand Down
86 changes: 86 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!--
~ Copyright (c) 2021 Samson Achiaga
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<resources>
<string name="app_name">Audio Notes</string>
<string name="display">Visualizzazione</string>
<string name="theme">Tema</string>
<string name="choose_theme">Scegli tema</string>
<string name="description">Descrizione</string>
<string name="note_title_required">Titolo della nota (obbligatorio)</string>
<string name="new_note">Nuova Nota</string>
<string name="save">Salva</string>
<string name="add_note_button">Pulsante Aggiungi nota</string>
<string name="back_button">Pulsante Indietro</string>
<string name="delete_button">Pulsante Elimina</string>
<string name="share_button">Pulsante Condividi</string>
<string name="click_to_add_a_reminder_to_this_note">Clicca per aggiungere un promemoria a questa nota</string>
<string name="record_button">Registra</string>
<string name="reminder_button">Pulsante Promemoria</string>
<string name="welcome_back">Bentornato</string>
<string name="hi_there">Ehilà,</string>
<string name="your_record_list_is_empty_click_the_button_below_to_get_started">L\'elenco delle registrazioni è vuoto. Clicca sul pulsante in basso per iniziare</string>
<string name="about">Informazioni</string>
<string name="attributions_amp_licence">Attribuzioni e Licenze</string>
<string name="licenced_under_apache_licence_version_2_0">Rilasciato sotto Licenza Apache, Versione 2.0</string>
<string name="app_version_licence_and_more">Versione dell\'app, licenza e altro</string>
<string name="settings">Impostazioni</string>
<string name="edit_note">Modifica Nota</string>
<string name="alarm_icon">Icona Sveglia</string>
<string name="modify">Modifica</string>
<string name="delete">Elimina</string>
<string name="no_reminder_set">Nessun promemoria</string>
<string name="channelId">Notifica di Audio Notes</string>
<string name="view_pager_title_audio_recording">Registra audio facilmente</string>
<string name="view_pager_description_audio_recording">Prendere appunti non dovrebbe riguardare la digitazione o la scrittura da sole. Usa la funzione di registrazione vocale per registrare la tua nota in modo facile e veloce per migliorare la tua produttività</string>
<string name="view_pager_title_notification">Notifiche Personalizzate</string>
<string name="view_pager_description_notification">Imposta un promemoria per le tue note e ricevi una notifica all\'ora esatta per cui hai impostato il promemoria. Non devi più preoccuparti di dimenticare di controllare una nota.</string>
<string name="view_pager_title_dark_mode">Progettato per te</string>
<string name="view_pager_description_dark_mode">Prendere appunti non dovrebbe essere fantascienza. L\'app è stata progettata pensando a te per facilitare il modo in cui prendi appunti e anche per migliorare la tua produttività</string>
<string name="record_player">Registratore</string>
<string name="developer">Sviluppatore</string>
<string name="contribute">Contribuisci</string>
<string name="contribute_summary">Visualizza il progetto su GitHub</string>
<string name="contact_feedback">Contatto e Feedback</string>
<string name="get_started">Iniziamo</string>
<string name="just_now">Proprio ora</string>
<string name="a_minute_ago">un minuto fa</string>
<string name="minutes_ago">minuti fa</string>
<string name="an_hour_ago">un\'ora fa</string>
<string name="hours_ago">ore fa</string>
<string name="a_day_ago">un giorno fa</string>
<string name="theme_system_default">Predefinito di sistema</string>
<string name="theme_light">Chiaro</string>
<string name="theme_dark">Scuro</string>
<string name="now_playing">In riproduzione</string>
<string name="cant_edit_note_title">Non puoi modificare il titolo della nota</string>
<string name="title_required">Il titolo della nota è obbligatorio</string>
<string name="permission_required">Questa autorizzazione è richiesta per abilitare le registrazioni audio</string>
<string name="note_saved">Nota salvata</string>
<string name="started_recording">Registrazione avviata</string>
<string name="stopped_recording">Registrazione terminata</string>
<string name="started_playing_recording">Riproduzione della registrazione avviata</string>
<string name="stopped_playing_recording">Riproduzione della registrazione terminata</string>
<string name="error_occurred">Si è verificato un errore</string>
<string name="yes">Sì</string>
<string name="no">No</string>
<string name="delete_note">Elimina Nota</string>
<string name="confirm_deletion">Sei sicuro di voler eliminare</string>
<string name="all">Tutte</string>
<string name="today">Oggi</string>
<string name="upcoming">Imminenti</string>
<string name="completed">Completate</string>
</resources>
14 changes: 7 additions & 7 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<resources>
<!-- Theme Preference -->
<string-array name="pref_theme">
<item>System default</item>
<item>Light</item>
<item>Dark</item>
<item>@string/theme_system_default</item>
<item>@string/theme_light</item>
<item>@string/theme_dark</item>
</string-array>

<string-array name="pref_theme_values">
Expand All @@ -29,9 +29,9 @@
</string-array>

<string-array name="filter_array">
<item>All</item>
<item>Today</item>
<item>Upcoming</item>
<item>Completed</item>
<item>@string/all</item>
<item>@string/today</item>
<item>@string/upcoming</item>
<item>@string/completed</item>
</string-array>
</resources>
21 changes: 21 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,25 @@
<string name="an_hour_ago">an hour ago</string>
<string name="hours_ago">hours ago</string>
<string name="a_day_ago">a day ago</string>
<string name="theme_system_default">System default</string>
<string name="theme_light">Light</string>
<string name="theme_dark">Dark</string>
<string name="now_playing">Now playing</string>
<string name="cant_edit_note_title">You can\'t edit the note title</string>
<string name="title_required">The note title is required</string>
<string name="permission_required">This permission is required to enable audio recording</string>
<string name="note_saved">Note saved</string>
<string name="started_recording">Started recording</string>
<string name="stopped_recording">Stopped recording</string>
<string name="started_playing_recording">Started playing recording</string>
<string name="stopped_playing_recording">Stopped playing recording</string>
<string name="error_occurred">An error occurred</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="delete_note">Delete Note</string>
<string name="confirm_deletion">Are you sure you want to delete</string>
<string name="all">All</string>
<string name="today">Today</string>
<string name="upcoming">Upcoming</string>
<string name="completed">Completed</string>
</resources>