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));
}
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;
}
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);
}
});
}
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());
}
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();
}
}
}
Aggregations