Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-06-10 15:33:13 +02:00
commit 3293760d7e
2 changed files with 35 additions and 15 deletions

View file

@ -22,6 +22,8 @@ import android.os.IBinder;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.PowerManager.WakeLock; import android.os.PowerManager.WakeLock;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v7.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
@ -181,10 +183,9 @@ public class NavigationService extends Service implements LocationListener {
}; };
registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION)); registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION));
Intent notificationIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); Intent notificationIntent = new Intent(OSMAND_STOP_SERVICE_ACTION);
Notification notification = new Notification(R.drawable.bgs_icon, "", //$NON-NLS-1$
System.currentTimeMillis());
notification.flags = Notification.FLAG_NO_CLEAR;
//Show currently active wake-up interval //Show currently active wake-up interval
int soi = settings.SERVICE_OFF_INTERVAL.get(); int soi = settings.SERVICE_OFF_INTERVAL.get();
@ -196,11 +197,21 @@ public class NavigationService extends Service implements LocationListener {
} else { } else {
nt = nt + Integer.toString(soi/1000/60) + " " + getString(R.string.int_min); nt = nt + Integer.toString(soi/1000/60) + " " + getString(R.string.int_min);
} }
PendingIntent broadcast = PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// Notification notification = new Notification(R.drawable.bgs_icon, "", //$NON-NLS-1$
// System.currentTimeMillis());
//
// notification.setLatestEventInfo(this, Version.getAppName(cl) + " " + getString(R.string.osmand_service), nt,
// broadcast);
// notification.flags = Notification.FLAG_NO_CLEAR;
// startForeground(NOTIFICATION_SERVICE_ID, notification);
notification.setLatestEventInfo(this, Version.getAppName(cl) + " " + getString(R.string.osmand_service), nt, final Builder noti = new NotificationCompat.Builder(
PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)); this).setContentTitle(Version.getAppName(cl))
.setContentText(getString(R.string.osmand_service)).setSmallIcon(R.drawable.bgs_icon)
startForeground(NOTIFICATION_SERVICE_ID, notification); // .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext()))
.setContentIntent(broadcast).setOngoing(true);
startForeground(NOTIFICATION_SERVICE_ID, noti.build());
} }
@Override @Override

View file

@ -40,7 +40,6 @@ import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.helpers.GpxImportHelper; import net.osmand.plus.helpers.GpxImportHelper;
import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
@ -68,6 +67,8 @@ import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v7.app.NotificationCompat;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -119,12 +120,20 @@ public class MapActivity extends AccessibleActivity {
private Notification getNotification() { private Notification getNotification() {
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Notification notification = new Notification(R.drawable.bgs_icon_drive, "", //$NON-NLS-1$ PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIndent, PendingIntent.FLAG_UPDATE_CURRENT);
System.currentTimeMillis()); // Notification notification = new Notification(R.drawable.bgs_icon_drive, "", //$NON-NLS-1$
notification.flags |= Notification.FLAG_AUTO_CANCEL; // System.currentTimeMillis());
notification.setLatestEventInfo(this, Version.getAppName(app), getString(R.string.go_back_to_osmand), // notification.flags |= Notification.FLAG_AUTO_CANCEL;
PendingIntent.getActivity(this, 0, notificationIndent, PendingIntent.FLAG_UPDATE_CURRENT)); // notification.setLatestEventInfo(this, Version.getAppName(app), getString(R.string.go_back_to_osmand),
return notification; // pi);
int smallIcon = app.getSettings().getApplicationMode().getSmallIconDark();
final Builder noti = new NotificationCompat.Builder(
this).setContentTitle(Version.getAppName(app))
.setContentText(getString(R.string.go_back_to_osmand))
.setSmallIcon(smallIcon )
// .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext()))
.setContentIntent(pi).setOngoing(true);
return noti.build();
} }
@Override @Override