added styles to build the custom notification, minor tweaks to old code
This commit is contained in:
parent
a787fdf8cd
commit
99dfdd711d
|
@ -12,7 +12,7 @@
|
||||||
android:id="@+id/img"
|
android:id="@+id/img"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:src="@drawable/torerror"/>
|
android:src="@drawable/tor"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/orb"
|
android:id="@+id/orb"
|
||||||
|
@ -22,7 +22,8 @@
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:layout_toRightOf="@+id/img"
|
android:layout_toRightOf="@+id/img"
|
||||||
android:text="Orbot"/>
|
android:text="Orbot"
|
||||||
|
style="@style/NotificationTitle"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv"
|
android:id="@+id/tv"
|
||||||
|
@ -31,7 +32,8 @@
|
||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/NotificationText"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/but"
|
android:id="@+id/but"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
|
||||||
|
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />
|
||||||
|
</resources>
|
|
@ -228,21 +228,20 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
private void showToolbarNotification (String notifyMsg, int notifyId, int icon, boolean isOngoing)
|
private void showToolbarNotification (String notifyMsg, int notifyId, int icon, boolean isOngoing)
|
||||||
{
|
{
|
||||||
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(TorService.this, 0, new Intent(TorService.this , Orbot.class), 0);
|
//Reusable code.
|
||||||
|
Intent intent = new Intent(TorService.this, Orbot.class);
|
||||||
|
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0);
|
||||||
|
|
||||||
// Create remote view that needs to be set as bigContentView for the notification.
|
// Create remote view that needs to be set as bigContentView for the notification.
|
||||||
RemoteViews expandedView = new RemoteViews(this.getPackageName(),
|
RemoteViews expandedView = new RemoteViews(this.getPackageName(),
|
||||||
R.layout.layout_notification_expanded);
|
R.layout.layout_notification_expanded);
|
||||||
expandedView.setTextViewText(R.id.tv, notifyMsg);
|
expandedView.setTextViewText(R.id.tv, notifyMsg);
|
||||||
expandedView.setOnClickPendingIntent(R.id.but, pendingIntent);
|
expandedView.setOnClickPendingIntent(R.id.but, pendIntent);
|
||||||
expandedView.setImageViewResource(R.id.img, icon);
|
expandedView.setImageViewResource(R.id.img, icon);
|
||||||
|
|
||||||
if (mNotifyBuilder == null)
|
if (mNotifyBuilder == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Reusable code.
|
|
||||||
Intent intent = new Intent(TorService.this, Orbot.class);
|
|
||||||
PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0);
|
|
||||||
|
|
||||||
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
if (mNotifyBuilder == null)
|
if (mNotifyBuilder == null)
|
||||||
|
@ -270,7 +269,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
}
|
}
|
||||||
|
|
||||||
mNotification = mNotifyBuilder.build();
|
mNotification = mNotifyBuilder.build();
|
||||||
mNotification.bigContentView = expandedView;
|
//mNotification.bigContentView = expandedView;
|
||||||
|
|
||||||
if (isOngoing)
|
if (isOngoing)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue