Added ability to delete comments.

fixes #60
Added translations for german and italian
pull/1157/head
Romedius Weiss 4 years ago
parent cceced7729
commit 0caaeb0d77

@ -6,6 +6,7 @@
package com.todoroo.astrid.notes
import android.app.Activity
import android.app.AlertDialog
import android.graphics.Color
import android.net.Uri
import android.text.Html
@ -14,11 +15,12 @@ import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.todoroo.andlib.utility.DateUtilities
import com.todoroo.astrid.data.Task
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import org.tasks.R
import org.tasks.data.UserActivity
import org.tasks.data.UserActivityDao
@ -29,6 +31,7 @@ import org.tasks.locale.Locale
import org.tasks.preferences.Preferences
import java.util.*
import javax.inject.Inject
import kotlin.coroutines.coroutineContext
import kotlin.math.min
class CommentsController @Inject constructor(
@ -94,6 +97,35 @@ class CommentsController @Inject constructor(
// picture
val commentPictureView = view.findViewById<ImageView>(R.id.comment_picture)
setupImagePopupForCommentView(view, commentPictureView, item.pictureUri, activity)
// delete button
val deleteBtn = view.findViewById<ImageView>(R.id.delete)
deleteBtn.setOnClickListener(){
val builder = AlertDialog.Builder(commentsContainer!!.context)
// Display a message on alert dialog
builder.setMessage(R.string.delete_comment)
// Set a positive button and its click listener on alert dialog
builder.setPositiveButton(R.string.delete){dialog, which ->
(activity as AppCompatActivity).lifecycleScope.launch {
withContext(NonCancellable) {
userActivityDao.delete(item)
}
reloadView()
}
}
// Display a negative button on alert dialog
builder.setNegativeButton(android.R.string.cancel){dialog,which ->
}
// Finally, make the alert dialog using builder
val dialog: AlertDialog = builder.create()
// Display the alert dialog on app interface
dialog.show()
}
}
companion object {

@ -3,36 +3,53 @@
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="@dimen/keyline_first"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"/>
<TextView
android:id="@+id/date"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"/>
<ImageView
android:id="@+id/comment_picture"
android:layout_width="50dip"
android:layout_height="50dip"
android:scaleType="fitCenter"
android:visibility="gone"
tools:ignore="ContentDescription"/>
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/comment_row"
style="@style/CommentsRow"
android:background="?attr/selectableItemBackground"
android:paddingRight="@dimen/widget_padding">
<include layout="@layout/control_set_delete_button" />
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/delete"
android:padding="@dimen/keyline_first"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"/>
<!-- add Edit button here -->
<TextView
android:id="@+id/date"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"/>
<ImageView
android:id="@+id/comment_picture"
android:layout_width="50dip"
android:layout_height="50dip"
android:scaleType="fitCenter"
android:visibility="gone"
tools:ignore="ContentDescription"/>
</LinearLayout>
</RelativeLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:alpha="@dimen/alpha_secondary"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_outline_delete_24px"
android:padding="@dimen/widget_padding"
app:tint="@color/icon_tint"
android:clickable="true" />

@ -82,7 +82,7 @@
<string name="EPr_edit_screen_options">Bildschirmeinstellungen bearbeiten</string>
<string name="EPr_beastMode_reset">Auf Standardeinstellungen zurücksetzen</string>
<string name="EPr_fullTask_title">Aufgabentitel ganz anzeigen</string>
<string name="EPr_show_task_edit_comments">Kommentare bei Aufgabeneingabe anzeigen </string>
<string name="EPr_show_task_edit_comments">Kommentare bei Aufgabeneingabe anzeigen</string>
<string name="task_list_options">Aufgabenlisten-Optionen</string>
<string name="EPr_cal_end_or_start_at_due_time">Zeitpunkt für Kalendereintrag</string>
<string name="EPr_cal_end_at_due_time">Kalendereintrag endet zur Fälligkeitsuhrzeit</string>
@ -641,4 +641,5 @@
<string name="last_backup_never">nie</string>
<string name="device_settings">Geräteeinstellungen</string>
<string name="account">Konto</string>
<string name="delete_comment">Kommentar löschen?</string>
</resources>

@ -640,4 +640,5 @@
<string name="automatic_backups">Backup automatici</string>
<string name="background_location_permission_required">Sono necessari i relativi permessi per i promemoria basati sulla localizzazione. Se in precedenza è stata negata una richiesta di autorizzazione alla localizzazione, sarà necessario concedere manualmente tale autorizzazione nelle impostazioni del dispositivo.</string>
<string name="no_app_found">Nessuna app è in grado di gestire questa richiesta</string>
<string name="delete_comment">Elimina questo commento?</string>
</resources>

@ -646,4 +646,5 @@ File %1$s contained %2$s.\n\n
<string name="backups_ignore_warnings">Ignore warnings</string>
<string name="backups_ignore_warnings_summary">Ignore backup warnings if you do not need backups or have your own backup solution</string>
<string name="backup_location_warning">WARNING: Files located in %s will be deleted if Tasks is uninstalled! Please choose a custom location to prevent Android from deleting your files.</string>
<string name="delete_comment">Delete this comment?</string>
</resources>

@ -70,6 +70,12 @@
<item name="android:editTextColor">@color/black_87</item>
</style>
<style name="CommentsRow" >
<item name="android:focusable">true</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="TagSettingsRow" parent="Widget.Design.TextInputLayout">
<item name="android:textSize">18sp</item>
<item name="android:clickable">true</item>

Loading…
Cancel
Save