summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rwxr-xr-xjava/com/android/dialer/helplines/HelplineActivity.java17
-rw-r--r--java/com/android/dialer/helplines/utils/HelplineUtils.java23
2 files changed, 36 insertions, 4 deletions
diff --git a/java/com/android/dialer/helplines/HelplineActivity.java b/java/com/android/dialer/helplines/HelplineActivity.java
index 15e745d34..bf9746822 100755
--- a/java/com/android/dialer/helplines/HelplineActivity.java
+++ b/java/com/android/dialer/helplines/HelplineActivity.java
@@ -225,22 +225,31 @@ public class HelplineActivity extends Activity {
contentView.setText(content);
if (isUrl) {
contentView.setPaintFlags(contentView.getPaintFlags() | UNDERLINE_TEXT_FLAG);
+
// We want to warn the user that visiting a link might leave traces
contentView.setOnClickListener(v -> {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse(content));
+ boolean isIncognito = HelplineUtils.makeIncognito(HelplineActivity.this,
+ intent);
+ if (isIncognito) {
+ mDialog.dismiss();
+ finish(); // Finish activity to get rid of own traces
+ startActivity(intent);
+ } else {
new AlertDialog.Builder(HelplineActivity.this)
.setTitle(R.string.helpline_browser_history_title)
.setMessage(R.string.helpline_browser_history_message)
.setPositiveButton(android.R.string.ok, (dlg, which) -> {
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse(content));
mDialog.dismiss();
dlg.dismiss();
- startActivity(i);
- finish(); // Finish this activity to get rid of own traces
+ finish(); // Finish activity to get rid of own traces
+ startActivity(intent);
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
+ }
);
}
}
diff --git a/java/com/android/dialer/helplines/utils/HelplineUtils.java b/java/com/android/dialer/helplines/utils/HelplineUtils.java
index a31a9ec44..7303dddca 100644
--- a/java/com/android/dialer/helplines/utils/HelplineUtils.java
+++ b/java/com/android/dialer/helplines/utils/HelplineUtils.java
@@ -15,6 +15,10 @@
*/
package com.android.dialer.helplines.utils;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.text.TextUtils;
@@ -31,6 +35,8 @@ public class HelplineUtils {
private static final String CATEGORY_STR_FORMAT = "helpline_category_%s";
private static final String LANGUAGE_STR_FORMAT = "helpline_language_%s";
+ private static final String PKG_NAME_JELLY = "org.lineageos.jelly";
+
/* Get the name of the helpline, fall back to the number if not given */
public static String getName(Resources res, Item item, String countryIso) {
if (item != null) {
@@ -88,4 +94,21 @@ public class HelplineUtils {
}
return "";
}
+
+ /* Check if the browser is known and make it launch in incognito mode
+ * Returns true if it succeeded
+ */
+ public static boolean makeIncognito(Context context, Intent intent) {
+ final PackageManager pm = context.getPackageManager();
+ ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
+ if (info != null) {
+ String pkgName = info.activityInfo.applicationInfo.packageName;
+ if (PKG_NAME_JELLY.equals(pkgName)) {
+ intent.putExtra("extra_incognito", true);
+ return true;
+ }
+ }
+
+ return false;
+ }
}