newNotification.patch
| project.properties | ||
|---|---|---|
| 8 | 8 |
# project structure. |
| 9 | 9 | |
| 10 | 10 |
# Project target. |
| 11 |
target=android-19
|
|
| 11 |
target=android-18
|
|
| 12 | 12 |
android.library.reference.1=external/ActionBarSherlock/actionbarsherlock |
| res/layout/layout_notification.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
android:layout_width="match_parent" |
|
| 4 |
android:layout_height="match_parent" |
|
| 5 |
android:orientation="vertical" > |
|
| 6 |
|
|
| 7 | ||
| 8 |
</LinearLayout> |
|
| 0 |
- |
|
| res/values/styles.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<resources> |
|
| 3 |
<style name="NotificationText"> |
|
| 4 |
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item> |
|
| 5 |
</style> |
|
| 6 |
<style name="NotificationTitle"> |
|
| 7 |
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item> |
|
| 8 |
<item name="android:textStyle">bold</item> |
|
| 9 |
</style> |
|
| 10 |
</resources> |
|
| 0 |
- |
|
| res/values-v9/styles.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<resources> |
|
| 3 |
<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" /> |
|
| 4 |
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" /> |
|
| 5 |
</resources> |
|
| 0 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
| 3 |
android:layout_width="match_parent"
|
|
| 4 |
android:layout_height="match_parent"
|
|
| 5 |
android:orientation="vertical" >
|
|
| 6 |
|
|
| 2 |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
| 3 |
android:id="@+id/custom_notification"
|
|
| 4 |
android:layout_width="fill_parent"
|
|
| 5 |
android:layout_height="fill_parent"
|
|
| 6 |
android:gravity="center" > |
|
| 7 | 7 | |
| 8 |
</LinearLayout> |
|
| 8 |
<ImageView |
|
| 9 |
android:id="@+id/notification_image" |
|
| 10 |
android:layout_width="wrap_content" |
|
| 11 |
android:layout_height="wrap_content" |
|
| 12 |
/> |
|
| 13 | ||
| 14 |
<TextView |
|
| 15 |
android:id="@+id/notification_title" |
|
| 16 |
android:layout_width="wrap_content" |
|
| 17 |
android:layout_height="wrap_content" |
|
| 18 |
android:layout_toRightOf="@id/notification_image" |
|
| 19 |
android:layout_alignTop="@+id/notification_image" |
|
| 20 |
style="@style/NotificationTitle" |
|
| 21 |
/> |
|
| 22 | ||
| 23 |
<TextView |
|
| 24 |
android:id="@+id/notification_text" |
|
| 25 |
android:layout_width="wrap_content" |
|
| 26 |
android:layout_height="wrap_content" |
|
| 27 |
android:layout_toRightOf="@+id/notification_image" |
|
| 28 |
android:layout_below="@+id/notification_title" |
|
| 29 |
style="@style/NotificationText" |
|
| 30 |
/> |
|
| 31 | ||
| 32 |
</RelativeLayout> |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 31 | 31 |
import org.torproject.android.Utils; |
| 32 | 32 |
import org.torproject.android.settings.AppManager; |
| 33 | 33 | |
| 34 |
import android.annotation.SuppressLint; |
|
| 35 | 34 |
import android.app.Application; |
| 36 | 35 |
import android.app.Notification; |
| 37 | 36 |
import android.app.NotificationManager; |
| ... | ... | |
| 46 | 45 |
import android.graphics.Color; |
| 47 | 46 |
import android.net.ConnectivityManager; |
| 48 | 47 |
import android.os.Build; |
| 49 |
import android.os.Handler; |
|
| 50 | 48 |
import android.os.IBinder; |
| 51 | 49 |
import android.os.RemoteCallbackList; |
| 52 | 50 |
import android.os.RemoteException; |
| 53 |
import android.support.v4.app.NotificationCompat; |
|
| 54 | 51 |
import android.support.v4.app.NotificationCompat.Builder; |
| 55 | 52 |
import android.util.Log; |
| 53 |
import android.widget.RemoteViews; |
|
| 56 | 54 | |
| 57 | 55 |
public class TorService extends Service implements TorServiceConstants, TorConstants, Runnable, EventHandler |
| 58 | 56 |
{
|
| ... | ... | |
| 1016 | 1014 |
//Reusable code. |
| 1017 | 1015 |
Intent intent = new Intent(TorService.this, Orbot.class); |
| 1018 | 1016 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 1019 |
|
|
| 1017 |
/* |
|
| 1020 | 1018 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 1021 | 1019 |
|
| 1022 | 1020 |
if (mNotifyBuilder == null) |
| ... | ... | |
| 1035 | 1033 |
mNotificationManager.notify( |
| 1036 | 1034 |
NOTIFY_ID, |
| 1037 | 1035 |
mNotifyBuilder.getNotification()); |
| 1038 |
|
|
| 1039 | ||
| 1036 |
*/ |
|
| 1037 |
//Testing new code for notification here. |
|
| 1038 |
Notification notification = new Notification(R.drawable.ic_stat_tor,"Test Notificaiton",System.currentTimeMillis()); |
|
| 1039 |
|
|
| 1040 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
|
| 1041 |
contentView.setImageViewResource(R.id.n, R.drawable.ic_action_settings); |
|
| 1042 |
contentView.setTextViewText(R.id.notification_title, "My custom notification title"); |
|
| 1043 |
contentView.setTextViewText(R.id.notification_text, "My custom notification text"); |
|
| 1044 |
notification.contentView = contentView; |
|
| 1045 |
|
|
| 1040 | 1046 |
} |
| 1041 | 1047 | |
| 1042 | 1048 | |
| 1043 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1038 | 1038 |
Notification notification = new Notification(R.drawable.ic_stat_tor,"Test Notificaiton",System.currentTimeMillis()); |
| 1039 | 1039 |
|
| 1040 | 1040 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
| 1041 |
contentView.setImageViewResource(R.id.n, R.drawable.ic_action_settings); |
|
| 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings);
|
|
| 1042 | 1042 |
contentView.setTextViewText(R.id.notification_title, "My custom notification title"); |
| 1043 | 1043 |
contentView.setTextViewText(R.id.notification_text, "My custom notification text"); |
| 1044 | 1044 |
notification.contentView = contentView; |
| 1045 | 1045 |
|
| 1046 |
notification.contentIntent=pendIntent; |
|
| 1047 |
|
|
| 1048 |
notification.flags |= Notification.FLAG_NO_CLEAR; |
|
| 1049 |
|
|
| 1050 |
mNotificationManager.notify(NOTIFICATION_ID, notification); |
|
| 1046 | 1051 |
} |
| 1047 | 1052 | |
| 1048 | 1053 | |
| 1049 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1047 | 1047 |
|
| 1048 | 1048 |
notification.flags |= Notification.FLAG_NO_CLEAR; |
| 1049 | 1049 |
|
| 1050 |
mNotificationManager.notify(NOTIFICATION_ID, notification);
|
|
| 1050 |
mNotificationManager.notify(NOTIFY_ID, notification);
|
|
| 1051 | 1051 |
} |
| 1052 | 1052 | |
| 1053 | 1053 | |
| 1054 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 5 | 5 |
android:layout_height="fill_parent" |
| 6 | 6 |
android:gravity="center" > |
| 7 | 7 | |
| 8 |
<ImageView |
|
| 9 |
android:id="@+id/notification_image" |
|
| 10 |
android:layout_width="wrap_content" |
|
| 11 |
android:layout_height="wrap_content" |
|
| 12 |
/> |
|
| 13 | ||
| 14 | 8 |
<TextView |
| 15 | 9 |
android:id="@+id/notification_title" |
| 16 | 10 |
android:layout_width="wrap_content" |
| 17 | 11 |
android:layout_height="wrap_content" |
| 18 |
android:layout_toRightOf="@id/notification_image" |
|
| 19 |
android:layout_alignTop="@+id/notification_image" |
|
| 20 | 12 |
style="@style/NotificationTitle" |
| 21 | 13 |
/> |
| 22 | 14 | |
| ... | ... | |
| 24 | 16 |
android:id="@+id/notification_text" |
| 25 | 17 |
android:layout_width="wrap_content" |
| 26 | 18 |
android:layout_height="wrap_content" |
| 27 |
android:layout_toRightOf="@+id/notification_image" |
|
| 28 | 19 |
android:layout_below="@+id/notification_title" |
| 29 | 20 |
style="@style/NotificationText" |
| 30 | 21 |
/> |
| 22 |
|
|
| 31 | 23 | |
| 32 | 24 |
</RelativeLayout> |
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1038 | 1038 |
Notification notification = new Notification(R.drawable.ic_stat_tor,"Test Notificaiton",System.currentTimeMillis()); |
| 1039 | 1039 |
|
| 1040 | 1040 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
| 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
|
| 1041 |
//contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings);
|
|
| 1042 | 1042 |
contentView.setTextViewText(R.id.notification_title, "My custom notification title"); |
| 1043 | 1043 |
contentView.setTextViewText(R.id.notification_text, "My custom notification text"); |
| 1044 | 1044 |
notification.contentView = contentView; |
| 1045 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 20 | 20 |
style="@style/NotificationText" |
| 21 | 21 |
/> |
| 22 | 22 |
|
| 23 |
<ImageView |
|
| 24 |
android:id="@+id/notification_image" |
|
| 25 |
android:layout_width="wrap_content" |
|
| 26 |
android:layout_height="wrap_content" |
|
| 27 |
android:layout_toRightOf="@+id/notification_title" |
|
| 28 |
/> |
|
| 23 | 29 | |
| 24 | 30 |
</RelativeLayout> |
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1038 | 1038 |
Notification notification = new Notification(R.drawable.ic_stat_tor,"Test Notificaiton",System.currentTimeMillis()); |
| 1039 | 1039 |
|
| 1040 | 1040 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
| 1041 |
//contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings);
|
|
| 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
|
| 1042 | 1042 |
contentView.setTextViewText(R.id.notification_title, "My custom notification title"); |
| 1043 | 1043 |
contentView.setTextViewText(R.id.notification_text, "My custom notification text"); |
| 1044 | 1044 |
notification.contentView = contentView; |
| 1045 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 48 | 48 |
import android.os.IBinder; |
| 49 | 49 |
import android.os.RemoteCallbackList; |
| 50 | 50 |
import android.os.RemoteException; |
| 51 |
import android.support.v4.app.NotificationCompat; |
|
| 51 | 52 |
import android.support.v4.app.NotificationCompat.Builder; |
| 52 | 53 |
import android.util.Log; |
| 53 | 54 |
import android.widget.RemoteViews; |
| ... | ... | |
| 1014 | 1015 |
//Reusable code. |
| 1015 | 1016 |
Intent intent = new Intent(TorService.this, Orbot.class); |
| 1016 | 1017 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 1017 |
/* |
|
| 1018 |
|
|
| 1019 |
Notification notification = new Notification(); |
|
| 1020 |
|
|
| 1018 | 1021 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 1019 | 1022 |
|
| 1020 | 1023 |
if (mNotifyBuilder == null) |
| ... | ... | |
| 1029 | 1032 |
|
| 1030 | 1033 |
mNotifyBuilder.setOngoing(persistent); |
| 1031 | 1034 |
mNotifyBuilder.setContentText(message); |
| 1032 |
|
|
| 1035 |
/* |
|
| 1033 | 1036 |
mNotificationManager.notify( |
| 1034 | 1037 |
NOTIFY_ID, |
| 1035 | 1038 |
mNotifyBuilder.getNotification()); |
| 1036 |
*/
|
|
| 1039 |
*/ |
|
| 1037 | 1040 |
//Testing new code for notification here. |
| 1038 |
Notification notification = new Notification(R.drawable.ic_stat_tor,"Test Notificaiton",System.currentTimeMillis()); |
|
| 1039 | 1041 |
|
| 1040 | 1042 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
| 1041 | 1043 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
| 1042 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1016 | 1016 |
Intent intent = new Intent(TorService.this, Orbot.class); |
| 1017 | 1017 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 1018 | 1018 |
|
| 1019 |
Notification notification = new Notification();
|
|
| 1019 |
Notification notification = null;
|
|
| 1020 | 1020 |
|
| 1021 | 1021 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 1022 | 1022 |
|
| ... | ... | |
| 1043 | 1043 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
| 1044 | 1044 |
contentView.setTextViewText(R.id.notification_title, "My custom notification title"); |
| 1045 | 1045 |
contentView.setTextViewText(R.id.notification_text, "My custom notification text"); |
| 1046 |
|
|
| 1047 |
notification = mNotifyBuilder.getNotification(); |
|
| 1046 | 1048 |
notification.contentView = contentView; |
| 1047 | 1049 |
|
| 1048 | 1050 |
notification.contentIntent=pendIntent; |
| 1049 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1016 | 1016 |
Intent intent = new Intent(TorService.this, Orbot.class); |
| 1017 | 1017 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 1018 | 1018 |
|
| 1019 |
//This is the remote view that will be used for the notification |
|
| 1020 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
|
| 1021 |
//contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
|
| 1022 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
|
| 1023 |
|
|
| 1019 | 1024 |
Notification notification = null; |
| 1020 | 1025 |
|
| 1021 | 1026 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| ... | ... | |
| 1024 | 1029 |
{
|
| 1025 | 1030 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
| 1026 | 1031 |
.setContentTitle(getString(R.string.app_name)) |
| 1027 |
.setContentText( getString(R.string.status_activated)) |
|
| 1028 |
.setSmallIcon(R.drawable.ic_stat_tor); |
|
| 1032 |
.setContentText( getString(R.string.status_activated)); |
|
| 1029 | 1033 | |
| 1030 | 1034 |
mNotifyBuilder.setContentIntent(pendIntent); |
| 1031 | 1035 |
} |
| ... | ... | |
| 1036 | 1040 |
mNotificationManager.notify( |
| 1037 | 1041 |
NOTIFY_ID, |
| 1038 | 1042 |
mNotifyBuilder.getNotification()); |
| 1039 |
*/ |
|
| 1040 |
//Testing new code for notification here. |
|
| 1043 |
*/ |
|
| 1041 | 1044 |
|
| 1042 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
|
| 1043 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
|
| 1044 |
contentView.setTextViewText(R.id.notification_title, "My custom notification title"); |
|
| 1045 |
contentView.setTextViewText(R.id.notification_text, "My custom notification text"); |
|
| 1045 |
contentView.setTextViewText(R.id.notification_text, message); |
|
| 1046 | 1046 |
|
| 1047 | 1047 |
notification = mNotifyBuilder.getNotification(); |
| 1048 | 1048 |
notification.contentView = contentView; |
| 1049 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1028 | 1028 |
if (mNotifyBuilder == null) |
| 1029 | 1029 |
{
|
| 1030 | 1030 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
| 1031 |
.setContentTitle(getString(R.string.app_name)) |
|
| 1032 |
.setContentText( getString(R.string.status_activated)); |
|
| 1033 | ||
| 1031 |
/*.setContentTitle(getString(R.string.app_name)) |
|
| 1032 |
.setContentText( getString(R.string.status_activated))*/ |
|
| 1033 |
.setSmallIcon(R.drawable.ic_stat_tor); |
|
| 1034 |
|
|
| 1034 | 1035 |
mNotifyBuilder.setContentIntent(pendIntent); |
| 1035 | 1036 |
} |
| 1036 | 1037 |
|
| 1037 |
mNotifyBuilder.setOngoing(persistent); |
|
| 1038 |
mNotifyBuilder.setContentText(message); |
|
| 1039 |
/* |
|
| 1038 |
mNotifyBuilder.setOngoing(persistent); |
|
| 1039 |
mNotifyBuilder.setContent(contentView); |
|
| 1040 |
contentView.setTextViewText(R.id.notification_text, message); |
|
| 1041 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
|
| 1042 |
|
|
| 1040 | 1043 |
mNotificationManager.notify( |
| 1041 | 1044 |
NOTIFY_ID, |
| 1042 | 1045 |
mNotifyBuilder.getNotification()); |
| 1043 |
*/ |
|
| 1044 |
|
|
| 1045 |
contentView.setTextViewText(R.id.notification_text, message); |
|
| 1046 |
|
|
| 1047 |
notification = mNotifyBuilder.getNotification(); |
|
| 1048 |
notification.contentView = contentView; |
|
| 1049 |
|
|
| 1050 |
notification.contentIntent=pendIntent; |
|
| 1051 |
|
|
| 1052 |
notification.flags |= Notification.FLAG_NO_CLEAR; |
|
| 1053 | 1046 |
|
| 1054 |
mNotificationManager.notify(NOTIFY_ID, notification); |
|
| 1055 | 1047 |
} |
| 1056 | 1048 | |
| 1057 | 1049 | |
| 1058 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 3 | 3 |
android:id="@+id/custom_notification" |
| 4 | 4 |
android:layout_width="fill_parent" |
| 5 | 5 |
android:layout_height="fill_parent" |
| 6 |
android:gravity="center" >
|
|
| 6 |
android:gravity="left" >
|
|
| 7 | 7 | |
| 8 |
<ImageView |
|
| 9 |
android:id="@+id/notification_image" |
|
| 10 |
android:layout_width="wrap_content" |
|
| 11 |
android:layout_height="wrap_content" |
|
| 12 |
android:layout_toRightOf="@+id/notification_title" |
|
| 13 |
/> |
|
| 14 |
|
|
| 8 | 15 |
<TextView |
| 9 | 16 |
android:id="@+id/notification_title" |
| 10 | 17 |
android:layout_width="wrap_content" |
| ... | ... | |
| 19 | 26 |
android:layout_below="@+id/notification_title" |
| 20 | 27 |
style="@style/NotificationText" |
| 21 | 28 |
/> |
| 22 |
|
|
| 23 |
<ImageView |
|
| 24 |
android:id="@+id/notification_image" |
|
| 25 |
android:layout_width="wrap_content" |
|
| 26 |
android:layout_height="wrap_content" |
|
| 27 |
android:layout_toRightOf="@+id/notification_title" |
|
| 28 |
/> |
|
| 29 | 29 | |
| 30 | 30 |
</RelativeLayout> |
| 31 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 11 | 11 |
android:layout_height="wrap_content" |
| 12 | 12 |
android:layout_toRightOf="@+id/notification_title" |
| 13 | 13 |
/> |
| 14 |
|
|
| 14 |
|
|
| 15 | 15 |
<TextView |
| 16 | 16 |
android:id="@+id/notification_title" |
| 17 | 17 |
android:layout_width="wrap_content" |
| 18 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1028 | 1028 |
if (mNotifyBuilder == null) |
| 1029 | 1029 |
{
|
| 1030 | 1030 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
| 1031 |
/*.setContentTitle(getString(R.string.app_name)) |
|
| 1032 |
.setContentText( getString(R.string.status_activated))*/ |
|
| 1033 | 1031 |
.setSmallIcon(R.drawable.ic_stat_tor); |
| 1034 | 1032 |
|
| 1035 | 1033 |
mNotifyBuilder.setContentIntent(pendIntent); |
| ... | ... | |
| 1037 | 1035 |
|
| 1038 | 1036 |
mNotifyBuilder.setOngoing(persistent); |
| 1039 | 1037 |
mNotifyBuilder.setContent(contentView); |
| 1038 |
|
|
| 1040 | 1039 |
contentView.setTextViewText(R.id.notification_text, message); |
| 1041 | 1040 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
| 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_stat_tor); |
|
| 1042 | 1042 |
|
| 1043 | 1043 |
mNotificationManager.notify( |
| 1044 | 1044 |
NOTIFY_ID, |
| 1045 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 9 | 9 |
android:id="@+id/notification_image" |
| 10 | 10 |
android:layout_width="wrap_content" |
| 11 | 11 |
android:layout_height="wrap_content" |
| 12 |
android:layout_toRightOf="@+id/notification_title" |
|
| 13 | 12 |
/> |
| 14 | 13 |
|
| 15 | 14 |
<TextView |
| 16 | 15 |
android:id="@+id/notification_title" |
| 17 | 16 |
android:layout_width="wrap_content" |
| 18 | 17 |
android:layout_height="wrap_content" |
| 18 |
android:layout_toRightOf="@+id/notification_image" |
|
| 19 | 19 |
style="@style/NotificationTitle" |
| 20 | 20 |
/> |
| 21 | 21 | |
| ... | ... | |
| 23 | 23 |
android:id="@+id/notification_text" |
| 24 | 24 |
android:layout_width="wrap_content" |
| 25 | 25 |
android:layout_height="wrap_content" |
| 26 |
android:layout_toRightOf="@+id/notification_image" |
|
| 26 | 27 |
android:layout_below="@+id/notification_title" |
| 27 | 28 |
style="@style/NotificationText" |
| 28 | 29 |
/> |
| 29 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 7 | 7 | |
| 8 | 8 |
<ImageView |
| 9 | 9 |
android:id="@+id/notification_image" |
| 10 |
android:layout_width="wrap_content"
|
|
| 11 |
android:layout_height="wrap_content"
|
|
| 10 |
android:layout_width="24dp"
|
|
| 11 |
android:layout_height="24dp"
|
|
| 12 | 12 |
/> |
| 13 | 13 |
|
| 14 | 14 |
<TextView |
| 15 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 7 | 7 | |
| 8 | 8 |
<ImageView |
| 9 | 9 |
android:id="@+id/notification_image" |
| 10 |
android:layout_width="24dp"
|
|
| 11 |
android:layout_height="24dp"
|
|
| 10 |
android:layout_width="48dp"
|
|
| 11 |
android:layout_height="48dp"
|
|
| 12 | 12 |
/> |
| 13 | 13 |
|
| 14 | 14 |
<TextView |
| 15 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 4 | 4 |
android:layout_width="fill_parent" |
| 5 | 5 |
android:layout_height="fill_parent" |
| 6 | 6 |
android:gravity="left" > |
| 7 | ||
| 7 |
|
|
| 8 |
<FrameLayout |
|
| 9 |
android:id="@+id/notification_frame" |
|
| 10 |
android:layout_width="65dp" |
|
| 11 |
android:layout_height="fill_parent" |
|
| 12 |
> |
|
| 8 | 13 |
<ImageView |
| 9 | 14 |
android:id="@+id/notification_image" |
| 10 |
android:layout_width="48dp" |
|
| 11 |
android:layout_height="48dp" |
|
| 15 |
android:layout_width="wrap_content" |
|
| 16 |
android:layout_height="wrap_content" |
|
| 17 |
android:layout_gravity="center" |
|
| 12 | 18 |
/> |
| 13 |
|
|
| 19 |
</FrameLayout> |
|
| 20 |
|
|
| 14 | 21 |
<TextView |
| 15 | 22 |
android:id="@+id/notification_title" |
| 16 | 23 |
android:layout_width="wrap_content" |
| 17 | 24 |
android:layout_height="wrap_content" |
| 18 |
android:layout_toRightOf="@+id/notification_image"
|
|
| 25 |
android:layout_toRightOf="@+id/notification_frame"
|
|
| 19 | 26 |
style="@style/NotificationTitle" |
| 20 | 27 |
/> |
| 21 | 28 | |
| ... | ... | |
| 23 | 30 |
android:id="@+id/notification_text" |
| 24 | 31 |
android:layout_width="wrap_content" |
| 25 | 32 |
android:layout_height="wrap_content" |
| 26 |
android:layout_toRightOf="@+id/notification_image"
|
|
| 33 |
android:layout_toRightOf="@+id/notification_frame"
|
|
| 27 | 34 |
android:layout_below="@+id/notification_title" |
| 28 | 35 |
style="@style/NotificationText" |
| 29 | 36 |
/> |
| 30 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 7 | 7 |
|
| 8 | 8 |
<FrameLayout |
| 9 | 9 |
android:id="@+id/notification_frame" |
| 10 |
android:layout_width="65dp"
|
|
| 10 |
android:layout_width="64dp"
|
|
| 11 | 11 |
android:layout_height="fill_parent" |
| 12 | 12 |
> |
| 13 | 13 |
<ImageView |
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1039 | 1039 |
contentView.setTextViewText(R.id.notification_text, message); |
| 1040 | 1040 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
| 1041 | 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_stat_tor); |
| 1042 |
contentView.setInt(R.id.notification_frame, "setBackgroundColor",Color.parseColor("#FFFFFF"));
|
|
| 1042 | 1043 |
|
| 1043 | 1044 |
mNotificationManager.notify( |
| 1044 | 1045 |
NOTIFY_ID, |
| 1045 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1039 | 1039 |
contentView.setTextViewText(R.id.notification_text, message); |
| 1040 | 1040 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
| 1041 | 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_stat_tor); |
| 1042 |
contentView.setInt(R.id.notification_frame, "setBackgroundColor",Color.parseColor("#FFFFFF"));
|
|
| 1042 |
contentView.setInt(R.id.notification_frame, "setBackgroundColor",Color.parseColor("#000000"));
|
|
| 1043 | 1043 |
|
| 1044 | 1044 |
mNotificationManager.notify( |
| 1045 | 1045 |
NOTIFY_ID, |
| 1046 |
- |
|
| src/org/torproject/android/service/NotificationHandler.java | ||
|---|---|---|
| 1 |
package org.torproject.android.service; |
|
| 2 | ||
| 3 |
public class NotificationHandler {
|
|
| 4 | ||
| 5 |
} |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1039 | 1039 |
contentView.setTextViewText(R.id.notification_text, message); |
| 1040 | 1040 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
| 1041 | 1041 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_stat_tor); |
| 1042 |
contentView.setInt(R.id.notification_frame, "setBackgroundColor",Color.parseColor("#000000"));
|
|
| 1042 |
//contentView.setInt(R.id.notification_frame, "setBackgroundColor",R.color.abs__bright_foreground_disabled_holo_light);
|
|
| 1043 | 1043 |
|
| 1044 | 1044 |
mNotificationManager.notify( |
| 1045 | 1045 |
NOTIFY_ID, |
| 1046 |
- |
|
| AndroidManifest.xml | ||
|---|---|---|
| 74 | 74 |
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/> |
| 75 | 75 |
<activity android:name=".settings.AppManager" android:label="@string/app_name"/> |
| 76 | 76 |
|
| 77 |
<activity android:name=".service.NotificationHandler" android:label="@string/app_name"></activity> |
|
| 78 |
|
|
| 77 | 79 |
<service android:enabled="true" |
| 78 | 80 |
android:name=".service.TorService" |
| 79 | 81 |
android:exported="false" |
| 80 |
- |
|
| src/org/torproject/android/service/NotificationHandler.java | ||
|---|---|---|
| 1 | 1 |
package org.torproject.android.service; |
| 2 | 2 | |
| 3 |
public class NotificationHandler {
|
|
| 3 |
import org.torproject.android.R; |
|
| 4 | 4 | |
| 5 |
import android.app.Activity; |
|
| 6 |
import android.os.Bundle; |
|
| 7 | ||
| 8 |
public class NotificationHandler extends Activity{
|
|
| 9 | ||
| 10 |
@Override |
|
| 11 |
protected void onCreate(Bundle savedInstanceState) {
|
|
| 12 |
// TODO Auto-generated method stub |
|
| 13 |
super.onCreate(savedInstanceState); |
|
| 14 |
setContentView(R.layout.layout_main); |
|
| 15 |
} |
|
| 5 | 16 |
} |
| 6 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1013 | 1013 |
private void startNotification (String message, boolean persistent) |
| 1014 | 1014 |
{
|
| 1015 | 1015 |
//Reusable code. |
| 1016 |
Intent intent = new Intent(TorService.this, Orbot.class);
|
|
| 1016 |
Intent intent = new Intent(TorService.this, NotificationHandler.class);
|
|
| 1017 | 1017 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 1018 | 1018 |
|
| 1019 | 1019 |
//This is the remote view that will be used for the notification |
| 1020 |
- |
|
| src/org/torproject/android/service/NotificationHandler.java | ||
|---|---|---|
| 11 | 11 |
protected void onCreate(Bundle savedInstanceState) {
|
| 12 | 12 |
// TODO Auto-generated method stub |
| 13 | 13 |
super.onCreate(savedInstanceState); |
| 14 |
setContentView(R.layout.layout_main); |
|
| 14 |
|
|
| 15 | 15 |
} |
| 16 | 16 |
} |
| 17 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1020 | 1020 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
| 1021 | 1021 |
//contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
| 1022 | 1022 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
| 1023 |
|
|
| 1024 |
Notification notification = null; |
|
| 1025 |
|
|
| 1023 |
|
|
| 1026 | 1024 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 1027 | 1025 |
|
| 1028 | 1026 |
if (mNotifyBuilder == null) |
| 1029 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 1031 | 1031 |
|
| 1032 | 1032 |
} |
| 1033 | 1033 |
} |
| 1034 |
|
|
| 1035 |
private void startNotification (String message, boolean persistent) |
|
| 1036 |
{
|
|
| 1037 |
//Reusable code. |
|
| 1038 |
Intent intent = new Intent(TorService.this, NotificationHandler.class); |
|
| 1039 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
|
| 1040 |
|
|
| 1041 |
//This is the remote view that will be used for the notification |
|
| 1042 |
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout_notification); |
|
| 1043 |
//contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_action_settings); |
|
| 1044 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
|
| 1045 |
|
|
| 1046 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
|
| 1047 |
|
|
| 1048 |
if (mNotifyBuilder == null) |
|
| 1049 |
{
|
|
| 1050 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
|
| 1051 |
.setSmallIcon(R.drawable.ic_stat_tor); |
|
| 1052 |
|
|
| 1053 |
mNotifyBuilder.setContentIntent(pendIntent); |
|
| 1054 |
} |
|
| 1055 |
|
|
| 1056 |
mNotifyBuilder.setOngoing(persistent); |
|
| 1057 |
mNotifyBuilder.setContent(contentView); |
|
| 1058 |
|
|
| 1059 |
contentView.setTextViewText(R.id.notification_text, message); |
|
| 1060 |
contentView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
|
| 1061 |
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_stat_tor); |
|
| 1062 |
//contentView.setInt(R.id.notification_frame, "setBackgroundColor",R.color.abs__bright_foreground_disabled_holo_light); |
|
| 1063 |
|
|
| 1064 |
mNotificationManager.notify( |
|
| 1065 |
NOTIFY_ID, |
|
| 1066 |
mNotifyBuilder.getNotification()); |
|
| 1067 |
|
|
| 1068 |
} |
|
| 1069 | 1034 | |
| 1070 | 1035 |
public void message(String severity, String msg) {
|
| 1071 | 1036 |
|
| 1072 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 209 | 209 |
Intent intent = new Intent(TorService.this, Orbot.class); |
| 210 | 210 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 211 | 211 |
|
| 212 |
//This is the remote view that will be used for the notification |
|
| 213 |
RemoteViews notificationView = new RemoteViews(getPackageName(),R.layout.layout_notification); |
|
| 214 |
|
|
| 212 | 215 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 213 | 216 |
|
| 214 | 217 |
if (mNotifyBuilder == null) |
| 215 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 213 | 213 |
RemoteViews notificationView = new RemoteViews(getPackageName(),R.layout.layout_notification); |
| 214 | 214 |
|
| 215 | 215 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 216 |
|
|
| 217 |
if (mNotifyBuilder == null) |
|
| 218 |
{
|
|
| 219 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
|
| 220 |
.setContentTitle(getString(R.string.app_name)) |
|
| 221 |
.setContentText( getString(R.string.status_activated)) |
|
| 222 |
.setSmallIcon(R.drawable.ic_stat_tor); |
|
| 216 |
|
|
| 217 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
|
| 218 |
.setContentTitle(getString(R.string.app_name)) |
|
| 219 |
.setContentText( getString(R.string.status_activated)) |
|
| 220 |
.setSmallIcon(R.drawable.ic_stat_tor); |
|
| 223 | 221 | |
| 224 |
mNotifyBuilder.setContentIntent(pendIntent); |
|
| 225 |
} |
|
| 222 |
mNotifyBuilder.setContentIntent(pendIntent); |
|
| 226 | 223 |
|
| 227 | 224 |
} |
| 228 | 225 | |
| 229 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 215 | 215 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 216 | 216 |
|
| 217 | 217 |
mNotifyBuilder = new NotificationCompat.Builder(this) |
| 218 |
.setContentTitle(getString(R.string.app_name)) |
|
| 219 |
.setContentText( getString(R.string.status_activated)) |
|
| 220 | 218 |
.setSmallIcon(R.drawable.ic_stat_tor); |
| 221 | ||
| 219 |
|
|
| 220 |
notificationView.setTextViewText(R.id.notification_title, getString(R.string.app_name)); |
|
| 221 |
notificationView.setTextViewText(R.id.notification_text, getString(R.string.status_activated)); |
|
| 222 |
|
|
| 222 | 223 |
mNotifyBuilder.setContentIntent(pendIntent); |
| 223 | 224 |
|
| 224 | 225 |
} |
| 225 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 201 | 201 |
|
| 202 | 202 |
private void showToolbarNotification (String notifyMsg, int notifyId, int icon, int flags, boolean isOngoing) |
| 203 | 203 |
{
|
| 204 |
//This is the remote view that will be used for the notification |
|
| 205 |
RemoteViews notificationView = new RemoteViews(getPackageName(),R.layout.layout_notification); |
|
| 204 | 206 |
|
| 205 | 207 |
if (mNotifyBuilder == null) |
| 206 | 208 |
{
|
| ... | ... | |
| 209 | 211 |
Intent intent = new Intent(TorService.this, Orbot.class); |
| 210 | 212 |
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); |
| 211 | 213 |
|
| 212 |
//This is the remote view that will be used for the notification |
|
| 213 |
RemoteViews notificationView = new RemoteViews(getPackageName(),R.layout.layout_notification); |
|
| 214 | 214 |
|
| 215 | 215 |
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| 216 | 216 |
|
| ... | ... | |
| 223 | 223 |
mNotifyBuilder.setContentIntent(pendIntent); |
| 224 | 224 |
|
| 225 | 225 |
} |
| 226 | ||
| 226 |
|
|
| 227 |
|
|
| 227 | 228 |
mNotifyBuilder.setContentText(notifyMsg); |
| 228 | 229 |
mNotifyBuilder.setSmallIcon(icon); |
| 229 | 230 |
mNotifyBuilder.setOngoing(isOngoing); |
| 230 |
- |
|
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 225 | 225 |
} |
| 226 | 226 |
|
| 227 | 227 |
|
| 228 |
mNotifyBuilder.setContentText(notifyMsg); |
|
| 229 |
mNotifyBuilder.setSmallIcon(icon); |
|
| 228 |
notificationView.setTextViewText(R.id.notification_text, notifyMsg); |
|
| 229 |
notificationView.setImageViewResource(R.id.notification_image, icon); |
|
| 230 |
|
|
| 230 | 231 |
mNotifyBuilder.setOngoing(isOngoing); |
| 231 | 232 |
|
| 232 | 233 |
if (notifyId == ERROR_NOTIFY_ID) |
| 233 |
- |
|
| res/layout/layout_notification.xml | ||
|---|---|---|
| 16 | 16 |
android:layout_height="wrap_content" |
| 17 | 17 |
android:layout_gravity="center" |
| 18 | 18 |
/> |
| 19 |
</FrameLayout> |
|
| 20 |
|
|
| 19 |
</FrameLayout> |
|
| 21 | 20 |
<TextView |
| 22 | 21 |
android:id="@+id/notification_title" |
| 23 | 22 |
android:layout_width="wrap_content" |
| 24 | 23 |
android:layout_height="wrap_content" |
| 25 | 24 |
android:layout_toRightOf="@+id/notification_frame" |
| 25 |
android:paddingLeft="5dp" |
|
| 26 | 26 |
style="@style/NotificationTitle" |
| 27 | 27 |
/> |
| 28 | 28 | |
| ... | ... | |
| 32 | 32 |
android:layout_height="wrap_content" |
| 33 | 33 |
android:layout_toRightOf="@+id/notification_frame" |
| 34 | 34 |
android:layout_below="@+id/notification_title" |
| 35 |
android:paddingLeft="5dp" |
|
| 35 | 36 |
style="@style/NotificationText" |
| 36 | 37 |
/> |
| 37 | 38 | |
| src/org/torproject/android/service/TorService.java | ||
|---|---|---|
| 237 | 237 |
mNotifyBuilder.setLights(Color.GREEN, 1000, 1000); |
| 238 | 238 |
} |
| 239 | 239 |
|
| 240 |
mNotifyBuilder.setContent(notificationView); |
|
| 240 | 241 |
|
| 241 | 242 |
mNotificationManager.notify( |
| 242 | 243 |
notifyId, |
| 243 |
- |
|