[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] update new simpler notification with "new identity" button
commit c207a1eed8c801ab4fc94ca42b6c824c1c1aa3bb
Author: n8fr8 <nathan@xxxxxxxxxxx>
Date: Fri Oct 12 16:36:01 2018 -0400
update new simpler notification with "new identity" button
---
app/src/main/res/menu/orbot_main.xml | 2 +-
app/src/main/res/values/strings.xml | 3 +
.../android/service/TorEventHandler.java | 3 +-
.../org/torproject/android/service/TorService.java | 78 +++++-----------------
orbotservice/src/main/res/values/strings.xml | 2 +
5 files changed, 25 insertions(+), 63 deletions(-)
diff --git a/app/src/main/res/menu/orbot_main.xml b/app/src/main/res/menu/orbot_main.xml
index f965514c..cb25b9e0 100644
--- a/app/src/main/res/menu/orbot_main.xml
+++ b/app/src/main/res/menu/orbot_main.xml
@@ -23,7 +23,7 @@
<item android:id="@+id/menu_newnym"
- android:title="@string/newnym"
+ android:title="@string/menu_new_identity"
android:icon="@drawable/ic_refresh_white_24dp"
yourapp:showAsAction="always"
/>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e1ba7f9b..b9ccc2d0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -402,4 +402,7 @@
<string name="trouble_connecting">Trouble connecting?</string>
<string name="full_device_vpn">Full Device VPN</string>
<string name="vpn_disabled">VPN Disabled</string>
+
+ <string name="menu_new_identity">New Identity</string>
+
</resources>
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java b/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java
index 081a9974..9214df4e 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java
@@ -124,8 +124,7 @@ public class TorEventHandler implements EventHandler, TorServiceConstants {
if (read > 0 || written > 0)
iconId = R.drawable.ic_stat_tor_xfer;
- if (mService.hasConnectivity() && Prefs.expandedNotifications())
- mService.showToolbarNotification(sb.toString(), mService.getNotifyId(), iconId);
+ mService.showToolbarNotification(sb.toString(), mService.getNotifyId(), iconId);
mTotalTrafficWritten += written;
mTotalTrafficRead += read;
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
index 0851d7e3..fec88b1f 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -292,8 +292,23 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
mNotifyBuilder.setContentIntent(pendIntent);
- }
-
+ }
+
+
+
+ mNotifyBuilder.setCategory(Notification.CATEGORY_SERVICE);
+
+ mNotifyBuilder.setChannelId(NOTIFICATION_CHANNEL_ID);
+
+
+ Intent intentRefresh = new Intent();
+ intentRefresh.setAction(CMD_NEWNYM);
+ PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
+ mNotifyBuilder.addAction(R.drawable.ic_refresh_white_24dp, getString(R.string.menu_new_identity),
+ pendingIntentNewNym);
+
+ mNotifyBuilder.setOngoing(Prefs.persistNotifications());
+
}
mNotifyBuilder.setContentText(notifyMsg);
@@ -307,68 +322,11 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
{
mNotifyBuilder.setTicker(null);
}
-
- mNotifyBuilder.setOngoing(Prefs.persistNotifications());
if (!Prefs.persistNotifications())
- mNotifyBuilder.setPriority(Notification.PRIORITY_LOW);
-
- mNotifyBuilder.setCategory(Notification.CATEGORY_SERVICE);
-
- mNotifyBuilder.setChannelId(NOTIFICATION_CHANNEL_ID);
+ mNotifyBuilder.setPriority(Notification.PRIORITY_LOW);
mNotification = mNotifyBuilder.build();
-
- if (Build.VERSION.SDK_INT >= 16 && Prefs.expandedNotifications()) {
- // Create remote view that needs to be set as bigContentView for the notification.
- RemoteViews expandedView = new RemoteViews(this.getPackageName(),
- R.layout.layout_notification_expanded);
-
- StringBuffer sbInfo = new StringBuffer();
-
- if (notifyType == NOTIFY_ID)
- expandedView.setTextViewText(R.id.text, notifyMsg);
- else
- {
- expandedView.setTextViewText(R.id.info, notifyMsg);
- }
-
- if (mEventHandler != null && mEventHandler.getNodes().size() > 0)
- {
- Set<String> itBuiltNodes = mEventHandler.getNodes().keySet();
- for (String key : itBuiltNodes)
- {
- TorEventHandler.Node node = mEventHandler.getNodes().get(key);
-
- if (node.ipAddress != null)
- {
- sbInfo.append(node.ipAddress);
-
- if (node.country != null)
- sbInfo.append(' ').append(node.country);
-
- if (node.organization != null)
- sbInfo.append(" (").append(node.organization).append(')');
-
- sbInfo.append('\n');
- }
-
- }
-
- expandedView.setTextViewText(R.id.text2, sbInfo.toString());
- }
-
- expandedView.setTextViewText(R.id.title, getString(R.string.app_name));
-
- expandedView.setImageViewResource(R.id.icon, icon);
-
- Intent intentRefresh = new Intent();
- intentRefresh.setAction(CMD_NEWNYM);
- PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
- expandedView.setOnClickPendingIntent(R.id.action_refresh,pendingIntent);
- mNotification.bigContentView = expandedView;
- }
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(NOTIFY_ID, mNotification);
diff --git a/orbotservice/src/main/res/values/strings.xml b/orbotservice/src/main/res/values/strings.xml
index 197224c3..11485598 100644
--- a/orbotservice/src/main/res/values/strings.xml
+++ b/orbotservice/src/main/res/values/strings.xml
@@ -328,4 +328,6 @@
<string name="note_only_standard_tor_bridges_work_on_intel_x86_atom_devices">NOTE: Only standard Tor bridges work on Intel X86/ATOM devices</string>
<string name="vpn_default_world">World</string>
+
+ <string name="menu_new_identity">New Identity</string>
</resources>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits