Skip to content

Commit 2f0bda8

Browse files
committed
Remove call log overflowMenuButton invisible if number is null
1 parent bd11e79 commit 2f0bda8

File tree

5 files changed

+82
-64
lines changed

5 files changed

+82
-64
lines changed

app/src/main/java/com/addev/listaspam/SettingsActivity.kt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,6 @@ import org.json.JSONObject
1414
import java.io.File
1515

1616
class SettingsActivity : AppCompatActivity() {
17-
private val exportFileLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("application/json")) { uri: Uri? ->
18-
uri?.let {
19-
if (exportAllSharedPreferences(it)) {
20-
Toast.makeText(this, "Preferencias exportadas con éxito", Toast.LENGTH_SHORT).show()
21-
} else {
22-
Toast.makeText(this, "Error al exportar preferencias", Toast.LENGTH_SHORT).show()
23-
}
24-
}
25-
}
26-
27-
private val importFileLauncher = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri: Uri? ->
28-
uri?.let {
29-
if (importAllSharedPreferences(it)) {
30-
updateSettingsContainer()
31-
Toast.makeText(this, "Preferencias importadas con éxito", Toast.LENGTH_SHORT).show()
32-
} else {
33-
Toast.makeText(this, "Error al importar preferencias", Toast.LENGTH_SHORT).show()
34-
}
35-
}
36-
}
37-
3817
override fun onCreate(savedInstanceState: Bundle?) {
3918
super.onCreate(savedInstanceState)
4019
setContentView(R.layout.activity_settings)
@@ -67,6 +46,27 @@ class SettingsActivity : AppCompatActivity() {
6746
}
6847
}
6948

49+
private val exportFileLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("application/json")) { uri: Uri? ->
50+
uri?.let {
51+
if (exportAllSharedPreferences(it)) {
52+
Toast.makeText(this, "Preferencias exportadas con éxito", Toast.LENGTH_SHORT).show()
53+
} else {
54+
Toast.makeText(this, "Error al exportar preferencias", Toast.LENGTH_SHORT).show()
55+
}
56+
}
57+
}
58+
59+
private val importFileLauncher = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri: Uri? ->
60+
uri?.let {
61+
if (importAllSharedPreferences(it)) {
62+
updateSettingsContainer()
63+
Toast.makeText(this, "Preferencias importadas con éxito", Toast.LENGTH_SHORT).show()
64+
} else {
65+
Toast.makeText(this, "Error al importar preferencias", Toast.LENGTH_SHORT).show()
66+
}
67+
}
68+
}
69+
7070
private fun exportAllSharedPreferences(uri: Uri): Boolean {
7171
return try {
7272
val prefsDir = File(applicationInfo.dataDir, "shared_prefs")

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CallLogAdapter(
6868
private val overflowMenuButton = itemView.findViewById<ImageButton>(R.id.overflowMenuButton)
6969

7070
fun bind(callLog: CallLogEntry, isBlocked: Boolean, isWhitelisted: Boolean = false) {
71-
val number = callLog.number ?: ""
71+
val number = callLog.number ?: "Unknown number"
7272
val contactName = getContactName(context, number)
7373
val textToShow = if (isBlocked) {
7474
context.getString(R.string.blocked_text_format, contactName ?: number)
@@ -101,6 +101,12 @@ class CallLogAdapter(
101101
else -> numberTextView.setTextColor(ContextCompat.getColor(context, android.R.color.darker_gray))
102102
}
103103

104+
if (number.isNullOrBlank()) {
105+
overflowMenuButton.visibility = View.GONE
106+
return
107+
}
108+
109+
overflowMenuButton.visibility = View.VISIBLE
104110
overflowMenuButton.setOnClickListener {
105111
val popupMenu = PopupMenu(itemView.context, overflowMenuButton, Gravity.NO_GRAVITY, android.R.attr.popupMenuStyle, R.style.PopupMenuStyle)
106112
popupMenu.inflate(R.menu.item_actions)

app/src/main/java/com/addev/listaspam/util/NotificationUtils.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ fun sendNotification(context: Context, number: String) {
2222
) != PackageManager.PERMISSION_GRANTED ||
2323
!shouldShowNotification(context)
2424
) {
25-
// Aquí deberías solicitar el permiso si no está concedido.
2625
return
2726
}
2827

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
43
<LinearLayout
5-
xmlns:android="http://schemas.android.com/apk/res/android"
6-
android:layout_width="match_parent"
7-
android:layout_height="match_parent"
8-
android:orientation="vertical">
9-
10-
<FrameLayout
11-
android:id="@+id/settings_container"
4+
xmlns:android="http://schemas.android.com/apk/res/android"
125
android:layout_width="match_parent"
13-
android:layout_height="wrap_content" />
6+
android:layout_height="match_parent"
7+
android:orientation="vertical">
8+
149

15-
<LinearLayout
10+
11+
<ScrollView
1612
android:layout_width="match_parent"
17-
android:layout_height="match_parent"
18-
android:orientation="vertical"
19-
android:padding="16dp"
20-
android:gravity="center">
21-
22-
<Button
23-
android:id="@+id/btn_export"
24-
android:layout_width="wrap_content"
25-
android:layout_height="wrap_content"
26-
android:text="Exportar configuración y listas" />
27-
28-
<Button
29-
android:id="@+id/btn_import"
30-
android:layout_width="wrap_content"
31-
android:layout_height="wrap_content"
32-
android:text="Importar configuración y listas"
33-
android:layout_marginTop="16dp" />
34-
</LinearLayout>
35-
36-
</LinearLayout>
13+
android:layout_height="0dp"
14+
android:layout_weight="1"
15+
android:padding="16dp">
16+
17+
<LinearLayout
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:orientation="vertical"
21+
android:gravity="center">
22+
23+
<Button
24+
android:id="@+id/btn_export"
25+
android:layout_width="wrap_content"
26+
android:layout_height="wrap_content"
27+
android:text="Exportar configuración y listas" />
28+
29+
<Button
30+
android:id="@+id/btn_import"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="Importar configuración y listas"
34+
android:layout_marginTop="16dp"
35+
android:layout_marginBottom="16px" />
36+
37+
<FrameLayout
38+
android:id="@+id/settings_container"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content" />
41+
42+
</LinearLayout>
43+
</ScrollView>
44+
45+
</LinearLayout>

app/src/main/res/xml/preferences.xml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
2+
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
34

4-
<!-- Activar/desactivar bloqueo general -->
55
<CheckBoxPreference
6+
app:iconSpaceReserved="false"
67
android:key="pref_enable_blocking"
78
android:title="@string/pref_enable_blocking_title"
89
android:summary="@string/pref_enable_blocking_summary"
910
android:defaultValue="true" />
1011

11-
<!-- Filtrar con la base de datos de listaspam.com -->
1212
<CheckBoxPreference
13+
app:iconSpaceReserved="false"
1314
android:key="pref_filter_lista_spam"
1415
android:title="@string/pref_filter_lista_spam_title"
1516
android:summary="@string/pref_filter_lista_spam_summary"
1617
android:defaultValue="true" />
1718

18-
<!-- Filtrar con la base de datos de ResponderONo.es -->
1919
<CheckBoxPreference
20+
app:iconSpaceReserved="false"
2021
android:key="pref_filter_responder_o_no"
2122
android:title="@string/pref_filter_responder_o_no_title"
2223
android:summary="@string/pref_filter_responder_o_no_summary"
2324
android:defaultValue="true" />
2425

2526
<CheckBoxPreference
27+
app:iconSpaceReserved="false"
28+
android:key="pref_block_non_contacts"
29+
android:title="@string/pref_block_non_contacts_title"
30+
android:summary="@string/pref_block_non_contacts_summary"
31+
android:defaultValue="false" />
32+
33+
<CheckBoxPreference
34+
app:iconSpaceReserved="false"
2635
android:key="pref_block_hidden_numbers"
2736
android:title="@string/pref_block_hidden_numbers_title"
2837
android:summary="@string/pref_block_hidden_numbers_summary"
2938
android:defaultValue="true" />
3039

3140
<CheckBoxPreference
41+
app:iconSpaceReserved="false"
3242
android:key="pref_block_international_numbers"
3343
android:title="@string/pref_block_international_numbers_title"
3444
android:summary="@string/pref_block_international_numbers_summary"
3545
android:defaultValue="false" />
3646

37-
<!-- Bloquear todos los números que no sean contactos -->
38-
<CheckBoxPreference
39-
android:key="pref_block_non_contacts"
40-
android:title="@string/pref_block_non_contacts_title"
41-
android:summary="@string/pref_block_non_contacts_summary"
42-
android:defaultValue="false" />
43-
4447
<!-- Mostrar notificación al bloquear número -->
4548
<CheckBoxPreference
49+
app:iconSpaceReserved="false"
4650
android:key="pref_show_notification"
4751
android:title="@string/pref_show_notification_title"
4852
android:summary="@string/pref_show_notification_summary"

0 commit comments

Comments
 (0)