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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimSelectNotification method createNotification.
private void createNotification(Context context) {
final Resources resources = context.getResources();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp).setColor(context.getColor(R.color.sim_noitification)).setContentTitle(resources.getString(R.string.sim_notification_title)).setContentText(resources.getString(R.string.sim_notification_summary));
Intent resultIntent = new Intent(context, SimSettingsActivity.class);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
use of android.support.v4.app.NotificationCompat.Builder in project Weather by Sparker0i.
the class WeatherFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_weather, container, false);
ButterKnife.bind(this, rootView);
MaterialDialog.Builder builder = new MaterialDialog.Builder(this.getActivity()).title(getString(R.string.please_wait)).content(getString(R.string.loading)).cancelable(false).progress(true, 0);
pd = builder.build();
setHasOptionsMenu(true);
preferences = new Prefs(getContext());
weatherFont = Typeface.createFromAsset(getActivity().getAssets(), "fonts/weather.ttf");
Bundle bundle = getArguments();
int mode;
if (bundle != null)
mode = bundle.getInt(Constants.MODE, 0);
else
mode = 0;
if (mode == 0)
updateWeatherData(preferences.getCity(), null, null);
else
updateWeatherData(null, Float.toString(preferences.getLatitude()), Float.toString(preferences.getLongitude()));
gps = new GPSTracker(getContext());
cityField.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
updatedField.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
humidityView.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
sunriseIcon.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
sunriseIcon.setTypeface(weatherFont);
sunriseIcon.setText(getActivity().getString(R.string.sunrise_icon));
sunsetIcon.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
sunsetIcon.setTypeface(weatherFont);
sunsetIcon.setText(getActivity().getString(R.string.sunset_icon));
windIcon.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
windIcon.setTypeface(weatherFont);
windIcon.setText(getActivity().getString(R.string.speed_icon));
humidityIcon.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
humidityIcon.setTypeface(weatherFont);
humidityIcon.setText(getActivity().getString(R.string.humidity_icon));
windView.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
swipeView.setColorSchemeResources(R.color.red, R.color.green, R.color.blue, R.color.yellow, R.color.orange);
swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeView.setRefreshing(true);
handler.post(new Runnable() {
@Override
public void run() {
changeCity(preferences.getCity());
}
});
handler.postDelayed(new Runnable() {
@Override
public void run() {
swipeView.setRefreshing(false);
}
}, 10000);
}
});
directionView.setTypeface(weatherFont);
directionView.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
dailyView.setText(getString(R.string.daily));
dailyView.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
sunriseView.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
sunsetView.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
button.setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
pd.show();
for (int i = 0; i < 11; ++i) {
String f = "details_view" + (i + 1), g = "weather_icon" + (i + 1);
if (i != 10) {
int resID = getResources().getIdentifier(f, "id", getContext().getPackageName());
detailsField[i] = (TextView) rootView.findViewById(resID);
detailsField[i].setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
}
int resIDI = getResources().getIdentifier(g, "id", getContext().getPackageName());
weatherIcon[i] = (TextView) rootView.findViewById(resIDI);
weatherIcon[i].setTypeface(weatherFont);
weatherIcon[i].setTextColor(ContextCompat.getColor(getContext(), R.color.textColor));
}
return rootView;
}
use of android.support.v4.app.NotificationCompat.Builder in project Tusky by Vavassor.
the class NotificationMaker method make.
public static void make(final Context context, final int notifyId, Notification body) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
final SharedPreferences notificationPreferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
if (!filterNotification(preferences, body)) {
return;
}
String rawCurrentNotifications = notificationPreferences.getString("current", "[]");
JSONArray currentNotifications;
try {
currentNotifications = new JSONArray(rawCurrentNotifications);
} catch (JSONException e) {
currentNotifications = new JSONArray();
}
boolean alreadyContains = false;
for (int i = 0; i < currentNotifications.length(); i++) {
try {
if (currentNotifications.getString(i).equals(body.account.getDisplayName())) {
alreadyContains = true;
}
} catch (JSONException e) {
Log.d(TAG, Log.getStackTraceString(e));
}
}
if (!alreadyContains) {
currentNotifications.put(body.account.getDisplayName());
}
notificationPreferences.edit().putString("current", currentNotifications.toString()).commit();
Intent resultIntent = new Intent(context, MainActivity.class);
resultIntent.putExtra("tab_position", 1);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
Intent deleteIntent = new Intent(context, NotificationClearBroadcastReceiver.class);
PendingIntent deletePendingIntent = PendingIntent.getBroadcast(context, 0, deleteIntent, PendingIntent.FLAG_CANCEL_CURRENT);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_notify).setContentIntent(resultPendingIntent).setDeleteIntent(deletePendingIntent).setDefaults(// So it doesn't ring twice, notify only in Target callback
0);
if (currentNotifications.length() == 1) {
builder.setContentTitle(titleForType(context, body)).setContentText(truncateWithEllipses(bodyForType(body), 40));
Target mTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
builder.setLargeIcon(bitmap);
setupPreferences(preferences, builder);
((NotificationManager) (context.getSystemService(Context.NOTIFICATION_SERVICE))).notify(notifyId, builder.build());
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(context).load(body.account.avatar).placeholder(R.drawable.avatar_default).transform(new RoundedTransformation(7, 0)).into(mTarget);
} else {
setupPreferences(preferences, builder);
try {
builder.setContentTitle(String.format(context.getString(R.string.notification_title_summary), currentNotifications.length())).setContentText(truncateWithEllipses(joinNames(context, currentNotifications), 40));
} catch (JSONException e) {
Log.d(TAG, Log.getStackTraceString(e));
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setVisibility(android.app.Notification.VISIBILITY_PRIVATE);
builder.setCategory(android.app.Notification.CATEGORY_SOCIAL);
}
((NotificationManager) (context.getSystemService(Context.NOTIFICATION_SERVICE))).notify(notifyId, builder.build());
}
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