use of android.support.annotation.StringRes in project material-dialogs by afollestad.
the class ColorChooserDialog method getTitle.
@StringRes
public int getTitle() {
Builder builder = getBuilder();
int title;
if (isInSub()) {
title = builder.titleSub;
} else {
title = builder.title;
}
if (title == 0) {
title = builder.title;
}
return title;
}
use of android.support.annotation.StringRes in project apps-android-wikipedia by wikimedia.
the class NotificationPresenter method showNotification.
public static void showNotification(@NonNull Context context, Notification n) {
@StringRes int title;
Spanned description;
@DrawableRes int icon;
@ColorInt int color;
Uri historyUri = uriForPath(n, "Special:History/" + (n.isFromWikidata() ? n.title().text() : n.title().full()));
Uri agentUri = uriForPath(n, "User:" + n.agent().name());
Intent pageIntent = PageActivity.newIntent(context, n.title().full());
PendingIntent historyIntent = PendingIntent.getActivity(context, REQUEST_CODE_HISTORY, ShareUtil.createChooserIntent(new Intent(Intent.ACTION_VIEW, historyUri), null, context), PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent agentIntent = PendingIntent.getActivity(context, REQUEST_CODE_AGENT, ShareUtil.createChooserIntent(new Intent(Intent.ACTION_VIEW, agentUri), null, context), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID).setDefaults(NotificationCompat.DEFAULT_ALL).setPriority(NotificationCompat.PRIORITY_HIGH).setAutoCancel(true);
switch(n.type()) {
case Notification.TYPE_EDIT_USER_TALK:
description = StringUtil.fromHtml(context.getString(R.string.notification_talk, n.agent().name(), n.title().full()));
icon = R.drawable.ic_chat_white_24dp;
title = R.string.notification_talk_title;
color = ContextCompat.getColor(context, R.color.accent50);
builder.addAction(0, context.getString(R.string.notification_button_view_user), agentIntent);
break;
case Notification.TYPE_REVERTED:
pageIntent.putExtra(Constants.INTENT_EXTRA_REVERT_QNUMBER, n.title().text());
description = StringUtil.fromHtml(context.getString(R.string.notification_reverted, n.agent().name(), n.title().full()));
icon = R.drawable.ic_rotate_left_white_24dp;
title = R.string.notification_reverted_title;
color = ContextCompat.getColor(context, R.color.red50);
builder.setPriority(NotificationCompat.PRIORITY_MAX);
break;
case Notification.TYPE_EDIT_THANK:
description = StringUtil.fromHtml(context.getString(R.string.notification_thanks, n.agent().name(), n.title().full()));
icon = R.drawable.ic_favorite_white_24dp;
title = R.string.notification_thanks_title;
color = ContextCompat.getColor(context, R.color.green50);
builder.addAction(0, context.getString(R.string.notification_button_view_user), agentIntent);
break;
default:
return;
}
builder.setContentIntent(PendingIntent.getActivity(context, REQUEST_CODE_PAGE, pageIntent, PendingIntent.FLAG_UPDATE_CURRENT)).setStyle(new NotificationCompat.BigTextStyle().bigText(description)).setContentText(description).setSmallIcon(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? icon : R.mipmap.launcher).setColor(color).setContentTitle(context.getString(title));
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(n.id(), builder.build());
}
use of android.support.annotation.StringRes in project openhab-android by openhab.
the class AboutActivity method updateTitle.
private void updateTitle() {
FragmentManager fm = getSupportFragmentManager();
int count = fm.getBackStackEntryCount();
@StringRes int titleResId = count > 0 ? fm.getBackStackEntryAt(count - 1).getBreadCrumbTitleRes() : R.string.about_title;
setTitle(titleResId);
}
use of android.support.annotation.StringRes in project gh4a by slapperwan.
the class PullRequestActivity method updatePullRequestState.
private void updatePullRequestState(boolean open) {
@StringRes int dialogMessageResId = open ? R.string.opening_msg : R.string.closing_msg;
@StringRes int errorMessageResId = open ? R.string.issue_error_reopen : R.string.issue_error_close;
String errorMessage = getString(errorMessageResId, mPullRequest.number());
PullRequestService service = ServiceFactory.get(PullRequestService.class, false);
EditPullRequest request = EditPullRequest.builder().state(open ? ApiHelpers.IssueState.OPEN : ApiHelpers.IssueState.CLOSED).build();
service.editPullRequest(mRepoOwner, mRepoName, mPullRequestNumber, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, dialogMessageResId, errorMessage)).subscribe(result -> {
mPullRequest = result;
handlePullRequestUpdate();
}, error -> handleActionFailure("Updating pull request failed", error));
}
use of android.support.annotation.StringRes in project gh4a by slapperwan.
the class IssueActivity method updateIssueState.
private void updateIssueState(boolean reopen) {
IssueService service = ServiceFactory.get(IssueService.class, false);
IssueRequest request = IssueRequest.builder().state(reopen ? IssueState.Open : IssueState.Closed).build();
@StringRes int dialogResId = reopen ? R.string.opening_msg : R.string.closing_msg;
@StringRes int errorMessageResId = reopen ? R.string.issue_error_reopen : R.string.issue_error_close;
service.editIssue(mRepoOwner, mRepoName, mIssueNumber, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, dialogResId, getString(errorMessageResId, mIssueNumber))).subscribe(result -> {
mIssue = result;
updateHeader();
if (mEditFab != null) {
mEditFab.setState(mIssue.state());
}
if (mFragment != null) {
mFragment.updateState(mIssue);
}
setResult(RESULT_OK);
supportInvalidateOptionsMenu();
}, error -> handleActionFailure("Updating issue state failed", error));
}
Aggregations