online/offline notification tray implemented (issue #353)

parent b80d53d5
......@@ -41,14 +41,6 @@ public class NetService implements Runnable {
private NotificationCompat.Builder builder;
public NetService(int delay) {
this.builder = new NotificationCompat.Builder(PCBcontext.getContext());
Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
this.builder.setContentIntent(resultPendingIntent);
this.updated=RestapiWrapper.ping(PCBcontext.getContext().getResources().getString(R.string.server), ping_session, new iRestapiListener() {
......@@ -118,6 +110,7 @@ public class NetService implements Runnable {
public void error(Exception e) {
updated = false;
Log.i(this.getClass().getName(), "PCB offline because exception happens: " + e.getMessage());
notifyStatus();
}
});
}
......@@ -125,11 +118,23 @@ public class NetService implements Runnable {
private void notifyStatus() {
int notifyID=1;
this.builder = new NotificationCompat.Builder(PCBcontext.getContext());
Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
this.builder.setContentIntent(resultPendingIntent);
if (updated)
this.builder.setSmallIcon(R.drawable.picton)
.setContentTitle("Pictogram online")
.setContentText(PCBcontext.getContext().getResources().getString(R.string.pictogram_online));
else
this.builder.setSmallIcon(R.drawable.pictoff)
.setContentTitle("Pictogram offline")
.setContentText(PCBcontext.getContext().getResources().getString(R.string.pictogram_offline));
this.builder.setSmallIcon(R.drawable.logo_pictogram)
.setContentTitle("Pictogram "+ (updated ? "online" : "offline"))
.setContentText(updated ? PCBcontext.getContext().getResources().getString(R.string.pictogram_online)
: PCBcontext.getContext().getResources().getString(R.string.pictogram_offline));
NotificationManager mNotificationManager =
(NotificationManager)PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
......
......@@ -136,7 +136,6 @@ public class Img {
}
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
this.bitmap.setHasAlpha(true);
Log.i(this.getClass().getCanonicalName(), "Img Uploading Picto img" + file_name() + " from " + get_type() + "size:" + get_bitmap(PCBcontext.getContext()).getWidth() + " " + get_bitmap(PCBcontext.getContext()).getHeight());
this.bitmap.compress(Bitmap.CompressFormat.PNG, 100, outstream);
byte[] byteArray = outstream.toByteArray();
os.write(byteArray);
......
......@@ -12,7 +12,7 @@
android:layout_height="120px"
android:contentDescription="@string/app_name"
android:orientation="vertical"
android:src="@drawable/yottalogo72p"
android:src="@drawable/logo"
android:scaleX="0.5"
android:scaleY="0.5"
android:id="@+id/imageView2"
......
......@@ -53,5 +53,5 @@
<string name="notNewCats">Including new categories is not allowed</string>
<!--online/offline status-->
<string name="pictogram_offline">Please check your internet connection. </string>
<string name="pictogram_online">Pictogram server connection established. </string>
<string name="pictogram_online">Server connection established. </string>
</resources>
......@@ -57,5 +57,5 @@
<string name="notNewCats">No puede añadir nuevas categorias</string>
<!--online/offline status-->
<string name="pictogram_offline">Compruebe si tiene conexión a Internet. </string>
<string name="pictogram_online">Conexón con el servidor Pictogram establecida. </string>
<string name="pictogram_online">Conexón con el servidor establecida. </string>
</resources>
......@@ -70,6 +70,6 @@
completions."
<!--online/offline status-->
<string name="pictogram_offline">Compruebe si tiene conexión a Internet. </string>
<string name="pictogram_online">Conexón con el servidor Pictogram establecida. </string>
<string name="pictogram_online">Conexón con el servidor establecida. </string>
</string>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment