use of android.support.v4.app.NotificationCompat.Builder in project RSAndroidApp by RailwayStations.
the class NearbyBahnhofNotificationManager method getBasicNotificationBuilder.
/**
* Helper method that configures a NotificationBuilder wtih the elements common to both
* notification types.
*
* @return
*/
protected NotificationCompat.Builder getBasicNotificationBuilder() {
// Build an intent for an action to see station details
PendingIntent detailPendingIntent = getDetailPendingIntent();
// Build an intent to see the station on a map
PendingIntent mapPendingIntent = getMapPendingIntent();
// Build an intent to view the station's timetable
PendingIntent timetablePendingIntent = getTimetablePendingIntent();
// Build an intent to launch the DB Bahnhöfe Live app
PendingIntent stationPendingIntent = getStationPendingIntent();
// Texts and bigStyle
TextCreator textCreator = new TextCreator().invoke();
String shortText = textCreator.getShortText();
NotificationCompat.BigTextStyle bigStyle = textCreator.getBigStyle();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_logotrain_found).setContentTitle(context.getString(R.string.station_is_near)).setContentText(shortText).setContentIntent(detailPendingIntent).addAction(R.drawable.ic_directions_white_24dp, context.getString(de.bahnhoefe.deutschlands.bahnhofsfotos.R.string.label_map), mapPendingIntent).setStyle(bigStyle).setPriority(NotificationCompat.PRIORITY_HIGH).setOnlyAlertOnce(true).setVisibility(Notification.VISIBILITY_PUBLIC);
if (timetablePendingIntent != null) {
builder.addAction(R.drawable.ic_timetable, context.getString(de.bahnhoefe.deutschlands.bahnhofsfotos.R.string.label_timetable), timetablePendingIntent);
}
return new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_logotrain_found).setContentTitle(context.getString(R.string.station_is_near)).setContentText(shortText).setContentIntent(detailPendingIntent).addAction(R.drawable.ic_directions_white_24dp, context.getString(de.bahnhoefe.deutschlands.bahnhofsfotos.R.string.label_map), mapPendingIntent).addAction(R.drawable.ic_timetable, context.getString(de.bahnhoefe.deutschlands.bahnhofsfotos.R.string.label_timetable), timetablePendingIntent).setStyle(bigStyle).setPriority(NotificationCompat.PRIORITY_HIGH).setOnlyAlertOnce(true).setVisibility(Notification.VISIBILITY_PUBLIC);
}
use of android.support.v4.app.NotificationCompat.Builder in project cw-omnibus by commonsguy.
the class Downloader method onHandleIntent.
@Override
public void onHandleIntent(Intent i) {
mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
try {
String filename = i.getData().getLastPathSegment();
NotificationCompat.Builder builder = buildForeground(filename);
final Notification notif = builder.build();
startForeground(FOREGROUND_ID, notif);
File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
root.mkdirs();
File output = new File(root, filename);
if (output.exists()) {
output.delete();
}
final ProgressResponseBody.Listener progressListener = new ProgressResponseBody.Listener() {
long lastUpdateTime = 0L;
@Override
public void onProgressChange(long bytesRead, long contentLength, boolean done) {
long now = SystemClock.uptimeMillis();
if (now - lastUpdateTime > 1000) {
notif.contentView.setProgressBar(android.R.id.progress, (int) contentLength, (int) bytesRead, false);
mgr.notify(FOREGROUND_ID, notif);
lastUpdateTime = now;
}
}
};
Interceptor nightTrain = new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Response original = chain.proceed(chain.request());
Response.Builder b = original.newBuilder().body(new ProgressResponseBody(original.body(), progressListener));
return (b.build());
}
};
OkHttpClient client = new OkHttpClient.Builder().addNetworkInterceptor(nightTrain).build();
Request request = new Request.Builder().url(i.getData().toString()).build();
Response response = client.newCall(request).execute();
String contentType = response.header("Content-type");
BufferedSink sink = Okio.buffer(Okio.sink(new File(output.getPath())));
sink.writeAll(response.body().source());
sink.close();
stopForeground(true);
raiseNotification(contentType, output, null);
} catch (IOException e2) {
stopForeground(true);
raiseNotification(null, null, e2);
}
}
use of android.support.v4.app.NotificationCompat.Builder in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class Helpers method getOpenCellData.
public static void getOpenCellData(InjectionAppCompatActivity injectionActivity, Cell cell, char type, final AimsicdService service) {
if (Helpers.isNetAvailable(injectionActivity)) {
if (!"NA".equals(CellTracker.OCID_API_KEY)) {
// [Km]
double earthRadius = 6371.01;
// Use a 2 Km radius with center at GPS location.
int radius = 2;
if (Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0) {
//New GeoLocation object to find bounding Coordinates
GeoLocation currentLoc = GeoLocation.fromDegrees(cell.getLat(), cell.getLon());
//Calculate the Bounding Box Coordinates using an N Km "radius" //0=min, 1=max
GeoLocation[] boundingCoords = currentLoc.boundingCoordinates(radius, earthRadius);
String boundParameter;
//Request OpenCellID data for Bounding Coordinates (0 = min, 1 = max)
boundParameter = String.valueOf(boundingCoords[0].getLatitudeInDegrees()) + "," + String.valueOf(boundingCoords[0].getLongitudeInDegrees()) + "," + String.valueOf(boundingCoords[1].getLatitudeInDegrees()) + "," + String.valueOf(boundingCoords[1].getLongitudeInDegrees());
log.info("OCID BBOX is set to: " + boundParameter + " with radius " + radius + " Km.");
StringBuilder sb = new StringBuilder();
sb.append("http://www.opencellid.org/cell/getInArea?key=").append(CellTracker.OCID_API_KEY).append("&BBOX=").append(boundParameter);
log.info("OCID MCC is set to: " + cell.getMobileCountryCode());
if (cell.getMobileCountryCode() != Integer.MAX_VALUE) {
sb.append("&mcc=").append(cell.getMobileCountryCode());
}
log.info("OCID MNC is set to: " + cell.getMobileNetworkCode());
if (cell.getMobileNetworkCode() != Integer.MAX_VALUE) {
sb.append("&mnc=").append(cell.getMobileNetworkCode());
}
sb.append("&format=csv");
new RequestTask(injectionActivity, type, new RequestTask.AsyncTaskCompleteListener() {
@Override
public void onAsyncTaskSucceeded() {
log.verbose("RequestTask's OCID download was successful. Callback rechecking connected cell against database");
service.getCellTracker().compareLacAndOpenDb();
}
@Override
public void onAsyncTaskFailed(String result) {
}
}).execute(sb.toString());
}
} else {
Fragment myFragment = injectionActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
if (myFragment instanceof MapFragment) {
((MapFragment) myFragment).setRefreshActionButtonState(false);
}
Helpers.sendMsg(injectionActivity, injectionActivity.getString(R.string.no_opencellid_key_detected));
}
} else {
Fragment myFragment = injectionActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
if (myFragment instanceof MapFragment) {
((MapFragment) myFragment).setRefreshActionButtonState(false);
}
final AlertDialog.Builder builder = new AlertDialog.Builder(injectionActivity);
builder.setTitle(R.string.no_network_connection_title).setMessage(R.string.no_network_connection_message);
builder.create().show();
}
}
use of android.support.v4.app.NotificationCompat.Builder in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class Helpers method importCellTowersData.
/**
* Description: Imports cell data from the specified file
*
* Used:
* @param celltowersPath path to the cell_towers.csv / cell_towers.csv.gz
* @param cell Current Cell Information
* @param importFile
*
*/
public static void importCellTowersData(InjectionAppCompatActivity injectionActivity, Cell cell, Uri importFile, final AimsicdService service) {
if (Helpers.isNetAvailable(injectionActivity)) {
// Use a 2 Km radius with center at GPS location.
int radius = 2;
if (Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0) {
GeoLocation currentLoc = GeoLocation.fromDegrees(cell.getLat(), cell.getLon());
log.info("OCID location: " + currentLoc.toString() + " with radius " + radius + " Km.");
log.info("OCID MCC is set to: " + cell.getMobileCountryCode());
log.info("OCID MNC is set to: " + cell.getMobileNetworkCode());
new ImportTask(injectionActivity, importFile, cell.getMobileCountryCode(), cell.getMobileNetworkCode(), currentLoc, radius, new ImportTask.AsyncTaskCompleteListener() {
@Override
public void onAsyncTaskSucceeded() {
log.verbose("ImportTask's OCID import was successful. Callback rechecking connected cell against database");
service.getCellTracker().compareLacAndOpenDb();
}
@Override
public void onAsyncTaskFailed(String result) {
}
}).execute();
}
} else {
Fragment myFragment = injectionActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
if (myFragment instanceof MapFragment) {
((MapFragment) myFragment).setRefreshActionButtonState(false);
}
final AlertDialog.Builder builder = new AlertDialog.Builder(injectionActivity);
builder.setTitle(R.string.no_network_connection_title).setMessage(R.string.no_network_connection_message);
builder.create().show();
}
}
use of android.support.v4.app.NotificationCompat.Builder in project Douya by DreaminginCodeZH.
the class AppBarWrapperLayout method show.
public void show() {
if (mShowing) {
return;
}
mShowing = true;
cancelAnimator();
mAnimator = new AnimatorSet().setDuration(mAnimationDuration);
mAnimator.setInterpolator(new FastOutSlowInInterpolator());
AnimatorSet.Builder builder = mAnimator.play(ObjectAnimator.ofFloat(this, TRANSLATION_Y, getTranslationY(), 0));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
builder.with(ObjectAnimator.ofFloat(mShadowCompatView, ALPHA, mShadowCompatView.getAlpha(), 1));
} else {
builder.with(ObjectAnimator.ofFloat(mAppbarView, TRANSLATION_Z, mAppbarView.getTranslationZ(), 0));
}
mAnimator.start();
}
Aggregations