Search in sources :

Example 16 with StringRes

use of android.support.annotation.StringRes in project gh4a by slapperwan.

the class IssueMilestoneEditActivity method setMilestoneState.

private void setMilestoneState(boolean open) {
    @StringRes int dialogMessageResId = open ? R.string.opening_msg : R.string.closing_msg;
    String errorMessage = getString(open ? R.string.issue_milestone_reopen_error : R.string.issue_milestone_close_error, mMilestone.title());
    IssueMilestoneService service = ServiceFactory.get(IssueMilestoneService.class, false);
    CreateMilestone request = CreateMilestone.builder().state(open ? IssueState.Open : IssueState.Closed).build();
    service.editMilestone(mRepoOwner, mRepoName, mMilestone.id(), request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, dialogMessageResId, errorMessage)).subscribe(result -> {
        mMilestone = result;
        updateHighlightColor();
        supportInvalidateOptionsMenu();
        setResult(RESULT_OK);
    }, error -> handleActionFailure("Updating milestone failed", error));
}
Also used : IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) StringRes(android.support.annotation.StringRes) CreateMilestone(com.meisolsson.githubsdk.model.request.issue.CreateMilestone) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 17 with StringRes

use of android.support.annotation.StringRes in project MagiskManager by topjohnwu.

the class Utils method getAvailableLocale.

public static List<Locale> getAvailableLocale() {
    List<Locale> locales = new ArrayList<>();
    HashSet<String> set = new HashSet<>();
    Locale locale;
    @StringRes int compareId = R.string.download_file_error;
    // Add default locale
    locales.add(Locale.ENGLISH);
    set.add(getLocaleString(Locale.ENGLISH, compareId));
    // Add some special locales
    locales.add(Locale.TAIWAN);
    set.add(getLocaleString(Locale.TAIWAN, compareId));
    locale = new Locale("pt", "BR");
    locales.add(locale);
    set.add(getLocaleString(locale, compareId));
    // Other locales
    for (String s : MagiskManager.get().getAssets().getLocales()) {
        locale = Locale.forLanguageTag(s);
        if (set.add(getLocaleString(locale, compareId))) {
            locales.add(locale);
        }
    }
    Collections.sort(locales, (l1, l2) -> l1.getDisplayName(l1).compareTo(l2.getDisplayName(l2)));
    return locales;
}
Also used : Locale(java.util.Locale) StringRes(android.support.annotation.StringRes) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 18 with StringRes

use of android.support.annotation.StringRes in project AndroidChromium by JackyAndroid.

the class ContextMenuManager method createContextMenu.

/**
 * Populates the context menu.
 * @param menu The menu to populate.
 * @param associatedView The view that requested a context menu.
 * @param delegate Delegate that defines the configuration of the menu and what to do when items
 *                 are tapped.
 */
public void createContextMenu(ContextMenu menu, View associatedView, Delegate delegate) {
    OnMenuItemClickListener listener = new ItemClickListener(delegate, associatedView);
    boolean hasItems = false;
    for (@ContextMenuItemId int itemId : MenuItemLabelMatcher.STRING_MAP.keySet()) {
        if (!shouldShowItem(itemId, delegate))
            continue;
        @StringRes int itemString = MenuItemLabelMatcher.STRING_MAP.get(itemId);
        menu.add(Menu.NONE, itemId, Menu.NONE, itemString).setOnMenuItemClickListener(listener);
        hasItems = true;
    }
    // No item added. We won't show the menu, so we can skip the rest.
    if (!hasItems)
        return;
    associatedView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {

        @Override
        public void onViewAttachedToWindow(View view) {
        }

        @Override
        public void onViewDetachedFromWindow(View view) {
            closeContextMenu();
            view.removeOnAttachStateChangeListener(this);
        }
    });
    // Disable touch events on the outer view while the context menu is open. This is to
    // prevent the user long pressing to get the context menu then on the same press scrolling
    // or swiping to dismiss an item (eg. https://crbug.com/638854, https://crbug.com/638555,
    // https://crbug.com/636296)
    mOuterView.setTouchEnabled(false);
    mActivity.addContextMenuCloseCallback(new Callback<Menu>() {

        @Override
        public void onResult(Menu result) {
            mOuterView.setTouchEnabled(true);
            mActivity.removeContextMenuCloseCallback(this);
        }
    });
}
Also used : OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) StringRes(android.support.annotation.StringRes) OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) ContextMenu(android.view.ContextMenu) Menu(android.view.Menu) View(android.view.View)

Example 19 with StringRes

use of android.support.annotation.StringRes in project AndroidChromium by JackyAndroid.

the class StripLayoutHelper method setAccessibilityDescription.

/**
 * Set the accessibility description of a {@link StripLayoutTab}.
 *
 * @param stripTab  The StripLayoutTab to set the accessibility description.
 * @param title     The title of the tab.
 * @param isHidden  Current visibility state of the Tab.
 */
private void setAccessibilityDescription(StripLayoutTab stripTab, String title, boolean isHidden) {
    if (stripTab == null)
        return;
    // Separator used to separate the different parts of the content description.
    // Not for sentence construction and hence not localized.
    final String contentDescriptionSeparator = ", ";
    final StringBuilder builder = new StringBuilder();
    if (!TextUtils.isEmpty(title)) {
        builder.append(title);
        builder.append(contentDescriptionSeparator);
    }
    @StringRes int resId;
    if (mIncognito) {
        resId = isHidden ? R.string.accessibility_tabstrip_incognito_identifier : R.string.accessibility_tabstrip_incognito_identifier_selected;
    } else {
        resId = isHidden ? R.string.accessibility_tabstrip_identifier : R.string.accessibility_tabstrip_identifier_selected;
    }
    builder.append(mContext.getResources().getString(resId));
    stripTab.setAccessibilityDescription(builder.toString());
}
Also used : StringRes(android.support.annotation.StringRes) SuppressLint(android.annotation.SuppressLint)

Example 20 with StringRes

use of android.support.annotation.StringRes in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (grantResults.length > 0) {
        if (allGranted(grantResults)) {
            if (requestCode == REQUEST_START_DOWNLOAD) {
                if (this.mPendingDownloadableMessage != null) {
                    startDownloadable(this.mPendingDownloadableMessage);
                }
            } else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) {
                if (this.mPendingEditorContent != null) {
                    attachImageToConversation(this.mPendingEditorContent);
                }
            } else {
                attachFile(requestCode);
            }
        } else {
            @StringRes int res;
            if (Manifest.permission.CAMERA.equals(getFirstDenied(grantResults, permissions))) {
                res = R.string.no_camera_permission;
            } else {
                res = R.string.no_storage_permission;
            }
            Toast.makeText(getActivity(), res, Toast.LENGTH_SHORT).show();
        }
    }
}
Also used : StringRes(android.support.annotation.StringRes) SuppressLint(android.annotation.SuppressLint)

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