added styles to build the custom notification, minor tweaks to old code

This commit is contained in:
Amogh Pradeep 2014-05-29 04:56:06 +05:30
parent a787fdf8cd
commit 99dfdd711d
3 changed files with 18 additions and 12 deletions

View File

@ -12,7 +12,7 @@
android:id="@+id/img"
android:layout_height="64dp"
android:layout_width="64dp"
android:src="@drawable/torerror"/>
android:src="@drawable/tor"/>
<TextView
android:id="@+id/orb"
@ -22,7 +22,8 @@
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:layout_toRightOf="@+id/img"
android:text="Orbot"/>
android:text="Orbot"
style="@style/NotificationTitle"/>
<TextView
android:id="@+id/tv"
@ -31,7 +32,8 @@
android:paddingLeft="15dp"
android:textSize="10sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
style="@style/NotificationText"/>
<Button
android:id="@+id/but"

5
res/values/styles.xml Normal file
View File

@ -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>

View File

@ -227,22 +227,21 @@ public class TorService extends Service implements TorServiceConstants, TorConst
@SuppressLint("NewApi")
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);
// Create remote view that needs to be set as bigContentView for the notification.
//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.
RemoteViews expandedView = new RemoteViews(this.getPackageName(),
R.layout.layout_notification_expanded);
expandedView.setTextViewText(R.id.tv, notifyMsg);
expandedView.setOnClickPendingIntent(R.id.but, pendingIntent);
expandedView.setOnClickPendingIntent(R.id.but, pendIntent);
expandedView.setImageViewResource(R.id.img, icon);
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);
if (mNotifyBuilder == null)
@ -270,7 +269,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
mNotification = mNotifyBuilder.build();
mNotification.bigContentView = expandedView;
//mNotification.bigContentView = expandedView;
if (isOngoing)
{