summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjava/com/android/dialer/helplines/HelplineActivity.java15
-rw-r--r--java/com/android/dialer/helplines/HelplineAdapter.java6
-rw-r--r--java/com/android/dialer/helplines/HelplineItem.java23
-rw-r--r--java/com/android/dialer/helplines/LoadHelplinesTask.java8
-rw-r--r--java/com/android/dialer/helplines/utils/HelplineUtils.java14
5 files changed, 37 insertions, 29 deletions
diff --git a/java/com/android/dialer/helplines/HelplineActivity.java b/java/com/android/dialer/helplines/HelplineActivity.java
index 906b6fd2c..15e745d34 100755
--- a/java/com/android/dialer/helplines/HelplineActivity.java
+++ b/java/com/android/dialer/helplines/HelplineActivity.java
@@ -43,6 +43,8 @@ import com.android.dialer.R;
import com.android.dialer.app.calllog.IntentProvider;
import com.android.dialer.helplines.utils.HelplineUtils;
+import org.lineageos.lib.phone.spn.Item;
+
import java.util.List;
import static android.graphics.Paint.UNDERLINE_TEXT_FLAG;
@@ -180,16 +182,17 @@ public class HelplineActivity extends Activity {
}
@Override
- public void onItemClicked(@NonNull HelplineItem item) {
+ public void onItemClicked(@NonNull HelplineItem helplineItem) {
LayoutInflater inflater = LayoutInflater.from(HelplineActivity.this);
final View dialogView = inflater.inflate(R.layout.dialog_helpline_details, null);
+ Item item = helplineItem.getItem();
- fillOrHideDialogRow(item.getName(), dialogView, R.id.name_title, R.id.name);
- fillOrHideDialogRow(item.get("organization"), dialogView, R.id.org_title, R.id.org);
- fillOrHideDialogRow(HelplineUtils.getCategories(getResources(), item),
+ fillOrHideDialogRow(helplineItem.getName(), dialogView, R.id.name_title, R.id.name);
+ fillOrHideDialogRow(item.getOrganization(), dialogView, R.id.org_title, R.id.org);
+ fillOrHideDialogRow(HelplineUtils.getCategories(getResources(), helplineItem),
dialogView, R.id.categories_title, R.id.categories);
- fillOrHideDialogRow(item.get("number"), dialogView, R.id.number_title, R.id.number);
- fillOrHideDialogRow(item.get("website"), dialogView, R.id.website_title, R.id.website,
+ fillOrHideDialogRow(item.getNumber(), dialogView, R.id.number_title, R.id.number);
+ fillOrHideDialogRow(item.getWebsite(), dialogView, R.id.website_title, R.id.website,
true);
mDialog = new AlertDialog.Builder(HelplineActivity.this)
diff --git a/java/com/android/dialer/helplines/HelplineAdapter.java b/java/com/android/dialer/helplines/HelplineAdapter.java
index 6dd748e9b..7a1a5637e 100644
--- a/java/com/android/dialer/helplines/HelplineAdapter.java
+++ b/java/com/android/dialer/helplines/HelplineAdapter.java
@@ -94,8 +94,8 @@ class HelplineAdapter extends RecyclerView.Adapter<HelplineAdapter.ViewHolder> {
@Override
public boolean areItemsTheSame(int iOld, int iNew) {
- String oldNumber = mOldList.get(iOld).get("number");
- String newNumber = mOldList.get(iNew).get("number");
+ String oldNumber = mOldList.get(iOld).getItem().getNumber();
+ String newNumber = mOldList.get(iNew).getItem().getNumber();
return oldNumber.equals(newNumber);
}
@@ -146,7 +146,7 @@ class HelplineAdapter extends RecyclerView.Adapter<HelplineAdapter.ViewHolder> {
mLanguageView.setText(languages);
}
- String number = item.get("number");
+ String number = item.getItem().getNumber();
if (!TextUtils.isEmpty(number)) {
mCallIcon.setVisibility(View.VISIBLE);
mCallIcon.setOnClickListener(v -> {
diff --git a/java/com/android/dialer/helplines/HelplineItem.java b/java/com/android/dialer/helplines/HelplineItem.java
index 8ac4cc969..e8f3d9528 100644
--- a/java/com/android/dialer/helplines/HelplineItem.java
+++ b/java/com/android/dialer/helplines/HelplineItem.java
@@ -19,22 +19,27 @@ import android.content.res.Resources;
import com.android.dialer.helplines.utils.HelplineUtils;
-import org.lineageos.lib.phone.SensitivePhoneNumberInfo;
+import org.lineageos.lib.phone.spn.Item;
+/* When loading all the items we modify the name based on the subscription.
+ * Using the setter would modify it permanently, resulting in modifications on each load.
+ * Therefore we don't use Item directly but use this little helper class so the modified
+ * name can be stored
+ */
public class HelplineItem {
- private final SensitivePhoneNumberInfo mInfo;
+ private final Item mItem;
private final String mName;
- public HelplineItem(Resources res, SensitivePhoneNumberInfo info, String countryIso) {
- mInfo = info;
- mName = HelplineUtils.getName(res, info, countryIso);
+ public HelplineItem(Resources res, Item item, String countryIso) {
+ mItem = item;
+ mName = HelplineUtils.getName(res, item, countryIso);
}
- public String getName() {
- return mName;
+ public Item getItem() {
+ return mItem;
}
- public String get(String key) {
- return mInfo.get(key);
+ public String getName() {
+ return mName;
}
}
diff --git a/java/com/android/dialer/helplines/LoadHelplinesTask.java b/java/com/android/dialer/helplines/LoadHelplinesTask.java
index 7cc0a0152..7c8de9c5a 100644
--- a/java/com/android/dialer/helplines/LoadHelplinesTask.java
+++ b/java/com/android/dialer/helplines/LoadHelplinesTask.java
@@ -23,8 +23,8 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.Log;
-import org.lineageos.lib.phone.SensitivePhoneNumberInfo;
import org.lineageos.lib.phone.SensitivePhoneNumbers;
+import org.lineageos.lib.phone.spn.Item;
import java.util.ArrayList;
import java.util.Collections;
@@ -72,11 +72,11 @@ public class LoadHelplinesTask extends AsyncTask<Void, Integer, List<HelplineIte
alreadyProcessedMccs.add(mcc);
SensitivePhoneNumbers spn = SensitivePhoneNumbers.getInstance();
- ArrayList<SensitivePhoneNumberInfo> pns = spn.getSensitivePnInfosForMcc(mcc);
+ ArrayList<Item> pns = spn.getSensitivePnInfosForMcc(mcc);
int numPns = pns.size();
for (int i = 0; i < numPns; i++) {
- SensitivePhoneNumberInfo info = pns.get(i);
- helplineList.add(new HelplineItem(mResources, info,
+ Item item = pns.get(i);
+ helplineList.add(new HelplineItem(mResources, item,
addCountryCode ? subCountryIso : ""));
publishProgress(Math.round(i * 100 / numPns / subList.size()));
}
diff --git a/java/com/android/dialer/helplines/utils/HelplineUtils.java b/java/com/android/dialer/helplines/utils/HelplineUtils.java
index 4ff20b93c..a31a9ec44 100644
--- a/java/com/android/dialer/helplines/utils/HelplineUtils.java
+++ b/java/com/android/dialer/helplines/utils/HelplineUtils.java
@@ -20,7 +20,7 @@ import android.text.TextUtils;
import com.android.dialer.R;
import com.android.dialer.helplines.HelplineItem;
-import org.lineageos.lib.phone.SensitivePhoneNumberInfo;
+import org.lineageos.lib.phone.spn.Item;
import java.util.ArrayList;
@@ -32,12 +32,12 @@ public class HelplineUtils {
private static final String LANGUAGE_STR_FORMAT = "helpline_language_%s";
/* Get the name of the helpline, fall back to the number if not given */
- public static String getName(Resources res, SensitivePhoneNumberInfo info, String countryIso) {
- if (info != null) {
- String name = info.get("name");
+ public static String getName(Resources res, Item item, String countryIso) {
+ if (item != null) {
+ String name = item.getName();
String displayName = !TextUtils.isEmpty(name)
? getDisplayString(res, name, NAME_STR_FORMAT)
- : info.get("number");
+ : item.getNumber();
if (!TextUtils.isEmpty(countryIso)) {
return res.getString(R.string.helpline_name_format_country, displayName,
countryIso);
@@ -52,7 +52,7 @@ public class HelplineUtils {
/* Split the given categories and translate them, fall back to "generic" if not given */
public static String getCategories(Resources res, HelplineItem item) {
if (item != null) {
- String str = getDisplayString(res, item.get("categories"), CATEGORY_STR_FORMAT);
+ String str = getDisplayString(res, item.getItem().getCategories(), CATEGORY_STR_FORMAT);
if (!TextUtils.isEmpty(str)) {
return str;
}
@@ -64,7 +64,7 @@ public class HelplineUtils {
/* Split and translate the given languages, return empty string if not given */
public static String getLanguages(Resources res, HelplineItem item) {
if (item != null) {
- return getDisplayString(res, item.get("languages"), LANGUAGE_STR_FORMAT);
+ return getDisplayString(res, item.getItem().getLanguages(), LANGUAGE_STR_FORMAT);
}
return "";