Skip to content

Commit 3a7958c

Browse files
committed
Add button to report numbers
1 parent dc48fb2 commit 3a7958c

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

app/src/main/java/com/addev/listaspam/calllog/CallLogAdapter.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
// CallLogAdapter.kt
21
package com.addev.listaspam.calllog
32

43
import android.content.Context
4+
import android.content.Intent
5+
import android.net.Uri
56
import android.view.LayoutInflater
67
import android.view.View
78
import android.view.ViewGroup
9+
import android.widget.Button
810
import android.widget.TextView
911
import androidx.core.content.ContextCompat
1012
import androidx.recyclerview.widget.RecyclerView
1113
import com.addev.listaspam.R
14+
import com.addev.listaspam.utils.SpamUtils
1215

1316
class CallLogAdapter(
1417
private val context: Context,
@@ -32,16 +35,21 @@ class CallLogAdapter(
3235
private val numberTextView: TextView = itemView.findViewById(R.id.numberTextView)
3336
private val dateTextView: TextView = itemView.findViewById(R.id.dateTextView)
3437
private val durationTextView: TextView = itemView.findViewById(R.id.durationTextView)
38+
private val reportButton: Button = itemView.findViewById(R.id.reportButton)
3539

3640
fun bind(callLog: CallLogEntry, isBlocked: Boolean) {
3741
numberTextView.text = "${callLog.number}${if (isBlocked) " (blocked)" else ""}"
3842
dateTextView.text = callLog.date.toString()
3943
durationTextView.text = "Duration: ${callLog.duration} seconds"
4044

4145
if (isBlocked) {
42-
numberTextView.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_dark))
43-
} else {
44-
numberTextView.setTextColor(ContextCompat.getColor(context, android.R.color.black))
46+
numberTextView.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
47+
}
48+
49+
reportButton.setOnClickListener {
50+
val url = String.format(SpamUtils.REPORT_URL_TEMPLATE, callLog.number)
51+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
52+
context.startActivity(intent)
4553
}
4654
}
4755
}

app/src/main/java/com/addev/listaspam/utils/SpamUtils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class SpamUtils {
3030
companion object {
3131
const val SPAM_PREFS = "SPAM_PREFS"
3232
const val BLOCK_NUMBERS_KEY = "BLOCK_NUMBERS"
33-
private const val SPAM_URL_TEMPLATE = "https://www.listaspam.com/busca.php?Telefono=%s"
33+
const val SPAM_URL_TEMPLATE = "https://www.listaspam.com/busca.php?Telefono=%s"
34+
const val REPORT_URL_TEMPLATE = "https://www.listaspam.com/busca.php?Telefono=%s#denuncia"
3435
private const val RESPONDERONO_URL_TEMPLATE =
3536
"https://www.responderono.es/numero-de-telefono/%s"
3637
private const val NOTIFICATION_CHANNEL_ID = "NOTIFICATION_CHANNEL"
Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="wrap_content"
5-
android:orientation="vertical"
65
android:padding="16dp">
76

87
<TextView
98
android:id="@+id/numberTextView"
10-
android:layout_width="match_parent"
9+
android:layout_width="wrap_content"
1110
android:layout_height="wrap_content"
12-
android:textSize="18sp" />
11+
android:textSize="18sp"
12+
android:layout_alignParentStart="true"
13+
android:layout_toStartOf="@id/reportButton"
14+
android:layout_alignBaseline="@id/reportButton"/>
1315

1416
<TextView
1517
android:id="@+id/dateTextView"
16-
android:layout_width="match_parent"
18+
android:layout_width="wrap_content"
1719
android:layout_height="wrap_content"
18-
android:textSize="14sp" />
20+
android:textSize="14sp"
21+
android:layout_below="@id/numberTextView"
22+
android:layout_alignParentStart="true"
23+
android:layout_alignStart="@id/numberTextView"/>
1924

2025
<TextView
2126
android:id="@+id/durationTextView"
22-
android:layout_width="match_parent"
27+
android:layout_width="wrap_content"
2328
android:layout_height="wrap_content"
24-
android:textSize="14sp" />
25-
</LinearLayout>
29+
android:textSize="14sp"
30+
android:layout_below="@id/dateTextView"
31+
android:layout_alignParentStart="true"
32+
android:layout_alignStart="@id/numberTextView"/>
33+
34+
<Button
35+
android:id="@+id/reportButton"
36+
android:layout_width="wrap_content"
37+
android:layout_height="wrap_content"
38+
android:text="Report"
39+
android:layout_alignParentEnd="true"
40+
android:layout_alignParentTop="true"/>
41+
</RelativeLayout>

0 commit comments

Comments
 (0)