notification layout for the expanded notification, still in testing. Also includes integration of remote view for the big layout
This commit is contained in:
parent
cfc8a995a0
commit
a787fdf8cd
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img"
|
||||
android:layout_height="64dp"
|
||||
android:layout_width="64dp"
|
||||
android:src="@drawable/torerror"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/orb"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:textSize="20sp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:layout_toRightOf="@+id/img"
|
||||
android:text="Orbot"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv"
|
||||
android:layout_toRightOf="@+id/img"
|
||||
android:layout_below="@+id/orb"
|
||||
android:paddingLeft="15dp"
|
||||
android:textSize="10sp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/but"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/tv"
|
||||
android:text="test" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -532,7 +532,12 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
protected void onNewIntent(Intent intent) {
|
||||
|
||||
super.onNewIntent(intent);
|
||||
|
||||
try {
|
||||
Log.d("lala", ""+mService.getStatus());
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
updateStatus("");
|
||||
handleIntents();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.torproject.android.settings.AppManager;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
|
@ -58,6 +59,9 @@ import android.os.RemoteException;
|
|||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
public class TorService extends Service implements TorServiceConstants, TorConstants, EventHandler
|
||||
{
|
||||
|
@ -106,6 +110,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
private NotificationManager mNotificationManager = null;
|
||||
private Builder mNotifyBuilder;
|
||||
private Notification mNotification;
|
||||
|
||||
private boolean mHasRoot = false;
|
||||
private boolean mEnableTransparentProxy = false;
|
||||
|
@ -219,9 +224,18 @@ 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.
|
||||
RemoteViews expandedView = new RemoteViews(this.getPackageName(),
|
||||
R.layout.layout_notification_expanded);
|
||||
expandedView.setTextViewText(R.id.tv, notifyMsg);
|
||||
expandedView.setOnClickPendingIntent(R.id.but, pendingIntent);
|
||||
expandedView.setImageViewResource(R.id.img, icon);
|
||||
|
||||
if (mNotifyBuilder == null)
|
||||
{
|
||||
|
||||
|
@ -246,6 +260,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
mNotifyBuilder.setContentText(notifyMsg);
|
||||
mNotifyBuilder.setSmallIcon(icon);
|
||||
|
||||
|
||||
if (notifyId == ERROR_NOTIFY_ID)
|
||||
{
|
||||
mNotifyBuilder.setTicker(notifyMsg);
|
||||
|
@ -254,17 +269,17 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
mNotifyBuilder.setSmallIcon(R.drawable.ic_stat_notifyerr);
|
||||
}
|
||||
|
||||
mNotification = mNotifyBuilder.build();
|
||||
mNotification.bigContentView = expandedView;
|
||||
|
||||
if (isOngoing)
|
||||
{
|
||||
startForeground(notifyId,
|
||||
mNotifyBuilder.build());
|
||||
startForeground(notifyId, mNotification);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
mNotificationManager.notify(
|
||||
notifyId,
|
||||
mNotifyBuilder.build());
|
||||
mNotificationManager.notify(notifyId, mNotification);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue