Search in sources :

Example 1 with StringRes

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;
}
Also used : SuppressLint(android.annotation.SuppressLint) StringRes(android.support.annotation.StringRes)

Example 2 with StringRes

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());
}
Also used : ColorInt(android.support.annotation.ColorInt) DrawableRes(android.support.annotation.DrawableRes) NotificationManager(android.app.NotificationManager) StringRes(android.support.annotation.StringRes) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Spanned(android.text.Spanned) Uri(android.net.Uri)

Example 3 with StringRes

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);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) StringRes(android.support.annotation.StringRes)

Example 4 with StringRes

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));
}
Also used : PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) EditPullRequest(com.meisolsson.githubsdk.model.request.pull_request.EditPullRequest) StringRes(android.support.annotation.StringRes) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 5 with StringRes

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));
}
Also used : IssueService(com.meisolsson.githubsdk.service.issues.IssueService) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) StringRes(android.support.annotation.StringRes) ApiHelpers(com.gh4a.utils.ApiHelpers)

Aggregations

StringRes (android.support.annotation.StringRes)22 SuppressLint (android.annotation.SuppressLint)7 View (android.view.View)6 Intent (android.content.Intent)5 ApiHelpers (com.gh4a.utils.ApiHelpers)4 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 Snackbar (android.support.design.widget.Snackbar)3 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2 DrawableRes (android.support.annotation.DrawableRes)2 NonNull (android.support.annotation.NonNull)2 FragmentManager (android.support.v4.app.FragmentManager)2 ActionBar (android.support.v7.app.ActionBar)2 TextView (android.widget.TextView)2 R (com.gh4a.R)2 File (java.io.File)2