Search in sources :

Example 11 with StringRes

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

the class ChooseContactActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    Intent intent = getIntent();
    @StringRes int res = intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID, R.string.title_activity_choose_contact) : R.string.title_activity_choose_contact;
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        try {
            bar.setTitle(res);
        } catch (Exception e) {
            bar.setTitle(R.string.title_activity_choose_contact);
        }
    }
}
Also used : StringRes(android.support.annotation.StringRes) Intent(android.content.Intent) ActionBar(android.support.v7.app.ActionBar)

Example 12 with StringRes

use of android.support.annotation.StringRes in project edx-app-android by edx.

the class CourseDiscussionResponsesAdapter method bindViewHolderToResponseRow.

private void bindViewHolderToResponseRow(DiscussionResponseViewHolder holder, final int position) {
    // Subtract 1 for the discussion thread row at position 0
    final DiscussionComment comment = discussionResponses.get(position - 1);
    holder.authorLayoutViewHolder.populateViewHolder(config, comment, comment, initialTimeStampMs, new Runnable() {

        @Override
        public void run() {
            listener.onClickAuthor(comment.getAuthor());
        }
    });
    if (comment.isEndorsed()) {
        holder.authorLayoutViewHolder.answerTextView.setVisibility(View.VISIBLE);
        holder.responseAnswerAuthorTextView.setVisibility(View.VISIBLE);
        DiscussionThread.ThreadType threadType = discussionThread.getType();
        DiscussionTextUtils.AuthorAttributionLabel authorAttributionLabel;
        @StringRes int endorsementTypeStringRes;
        switch(threadType) {
            case QUESTION:
                authorAttributionLabel = DiscussionTextUtils.AuthorAttributionLabel.ANSWER;
                endorsementTypeStringRes = R.string.discussion_responses_answer;
                break;
            case DISCUSSION:
            default:
                authorAttributionLabel = DiscussionTextUtils.AuthorAttributionLabel.ENDORSEMENT;
                endorsementTypeStringRes = R.string.discussion_responses_endorsed;
                break;
        }
        holder.authorLayoutViewHolder.answerTextView.setText(endorsementTypeStringRes);
        DiscussionTextUtils.setAuthorAttributionText(holder.responseAnswerAuthorTextView, authorAttributionLabel, comment.getEndorserData(), initialTimeStampMs, new Runnable() {

            @Override
            public void run() {
                listener.onClickAuthor(comment.getEndorsedBy());
            }
        });
    } else {
        holder.authorLayoutViewHolder.answerTextView.setVisibility(View.GONE);
        holder.responseAnswerAuthorTextView.setVisibility(View.GONE);
    }
    DiscussionTextUtils.renderHtml(holder.responseCommentBodyTextView, comment.getRenderedBody());
    if (discussionThread.isClosed() && comment.getChildCount() == 0) {
        holder.addCommentLayout.setEnabled(false);
    } else if (courseData.isDiscussionBlackedOut() && comment.getChildCount() == 0) {
        holder.addCommentLayout.setEnabled(false);
    } else {
        holder.addCommentLayout.setEnabled(true);
        holder.addCommentLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (comment.getChildCount() > 0) {
                    listener.onClickViewComments(comment);
                } else {
                    listener.onClickAddComment(comment);
                }
            }
        });
    }
    bindNumberCommentsView(holder.numberResponsesViewHolder, comment);
    if (TextUtils.equals(loginPrefs.getUsername(), comment.getAuthor())) {
        holder.actionsBar.setVisibility(View.GONE);
    } else {
        holder.actionsBar.setVisibility(View.VISIBLE);
        bindSocialView(holder.socialLayoutViewHolder, position, comment);
        holder.discussionReportViewHolder.reportLayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(final View v) {
                discussionService.setCommentFlagged(comment.getIdentifier(), new FlagBody(!comment.isAbuseFlagged())).enqueue(new ErrorHandlingCallback<DiscussionComment>(context, null, new DialogErrorNotification(baseFragment)) {

                    @Override
                    protected void onResponse(@NonNull final DiscussionComment comment) {
                        discussionResponses.get(position - 1).patchObject(comment);
                        discussionResponses.set(position - 1, comment);
                        notifyItemChanged(position);
                    }
                });
            }
        });
        holder.discussionReportViewHolder.setReported(comment.isAbuseFlagged());
        holder.socialLayoutViewHolder.threadFollowContainer.setVisibility(View.INVISIBLE);
    }
}
Also used : StringRes(android.support.annotation.StringRes) DiscussionComment(org.edx.mobile.discussion.DiscussionComment) DiscussionTextUtils(org.edx.mobile.discussion.DiscussionTextUtils) FlagBody(org.edx.mobile.discussion.DiscussionService.FlagBody) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DiscussionThread(org.edx.mobile.discussion.DiscussionThread) ErrorHandlingCallback(org.edx.mobile.http.callback.ErrorHandlingCallback) NonNull(android.support.annotation.NonNull) DialogErrorNotification(org.edx.mobile.http.notifications.DialogErrorNotification)

Example 13 with StringRes

use of android.support.annotation.StringRes in project Osmand by osmandapp.

the class RasterMapMenu method createLayersItems.

private static void createLayersItems(final ContextMenuAdapter contextMenuAdapter, final MapActivity mapActivity, final RasterMapType type) {
    final OsmandApplication app = mapActivity.getMyApplication();
    final OsmandSettings settings = app.getSettings();
    final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
    assert plugin != null;
    final OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
    final OsmandSettings.CommonPreference<String> mapTypePreference;
    final OsmandSettings.CommonPreference<String> exMapTypePreference;
    final LayerTransparencySeekbarMode currentMapTypeSeekbarMode = type == RasterMapType.OVERLAY ? LayerTransparencySeekbarMode.OVERLAY : LayerTransparencySeekbarMode.UNDERLAY;
    @StringRes final int mapTypeString;
    @StringRes final int mapTypeStringTransparency;
    if (type == RasterMapType.OVERLAY) {
        mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY;
        mapTypePreference = settings.MAP_OVERLAY;
        exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
        mapTypeString = R.string.map_overlay;
        mapTypeStringTransparency = R.string.overlay_transparency;
    } else if (type == RasterMapType.UNDERLAY) {
        mapTransparencyPreference = settings.MAP_TRANSPARENCY;
        mapTypePreference = settings.MAP_UNDERLAY;
        exMapTypePreference = settings.MAP_UNDERLAY_PREVIOUS;
        mapTypeString = R.string.map_underlay;
        mapTypeStringTransparency = R.string.map_transparency;
    } else {
        throw new RuntimeException("Unexpected raster map type");
    }
    final OsmandSettings.CommonPreference<Boolean> hidePolygonsPref = mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
    String mapTypeDescr = mapTypePreference.get();
    final boolean selected = mapTypeDescr != null;
    final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
    final OnMapSelectedCallback onMapSelectedCallback = new OnMapSelectedCallback() {

        @Override
        public void onMapSelected(boolean canceled) {
            if (type == RasterMapType.UNDERLAY && !canceled && !selected) {
                hidePolygonsPref.set(true);
                refreshMapComplete(mapActivity);
            } else if (type == RasterMapType.UNDERLAY && !canceled && mapTypePreference.get() == null) {
                hidePolygonsPref.set(false);
                refreshMapComplete(mapActivity);
            }
            mapActivity.getDashboard().refreshContent(true);
        }
    };
    final MapActivityLayers mapLayers = mapActivity.getMapLayers();
    ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {

        @Override
        public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int pos) {
            if (itemId == mapTypeString) {
                if (selected) {
                    plugin.selectMapOverlayLayer(mapActivity.getMapView(), mapTypePreference, exMapTypePreference, true, mapActivity, onMapSelectedCallback);
                }
                return false;
            }
            return super.onRowItemClick(adapter, view, itemId, pos);
        }

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, final int itemId, final int pos, final boolean isChecked, int[] viewCoordinates) {
            if (itemId == toggleActionStringId) {
                app.runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback);
                        refreshMapComplete(mapActivity);
                    }
                });
            } else if (itemId == R.string.show_polygons) {
                hidePolygonsPref.set(!isChecked);
                refreshMapComplete(mapActivity);
            } else if (itemId == R.string.show_transparency_seekbar) {
                settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(isChecked ? currentMapTypeSeekbarMode : LayerTransparencySeekbarMode.OFF);
                if (isChecked) {
                    mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
                } else {
                    mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
                }
                mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked);
            }
            return false;
        }
    };
    mapTypeDescr = selected ? mapTypeDescr : mapActivity.getString(R.string.shared_string_none);
    contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(toggleActionStringId, mapActivity).hideDivider(true).setListener(l).setSelected(selected).createItem());
    if (selected) {
        contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(mapTypeString, mapActivity).hideDivider(true).setListener(l).setLayout(R.layout.list_item_icon_and_menu_wide).setDescription(mapTypeDescr).createItem());
        ContextMenuAdapter.OnIntegerValueChangedListener integerListener = new ContextMenuAdapter.OnIntegerValueChangedListener() {

            @Override
            public boolean onIntegerValueChangedListener(int newValue) {
                mapTransparencyPreference.set(newValue);
                mapActivity.getMapView().refreshMap();
                return false;
            }
        };
        // android:max="255" in layout is expected
        contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(mapTypeStringTransparency, mapActivity).hideDivider(true).setLayout(R.layout.list_item_progress).setIcon(R.drawable.ic_action_opacity).setProgress(mapTransparencyPreference.get()).setListener(l).setIntegerListener(integerListener).createItem());
        if (type == RasterMapType.UNDERLAY) {
            contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_polygons, mapActivity).hideDivider(true).setListener(l).setSelected(!hidePolygonsPref.get()).createItem());
        }
        Boolean transparencySwitchState = isSeekbarVisible(app, type);
        contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_transparency_seekbar, mapActivity).hideDivider(true).setListener(l).setSelected(transparencySwitchState).createItem());
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) StringRes(android.support.annotation.StringRes) OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin) MapActivityLayers(net.osmand.plus.activities.MapActivityLayers) ContextMenuItem(net.osmand.plus.ContextMenuItem) LayerTransparencySeekbarMode(net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) OnMapSelectedCallback(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.OnMapSelectedCallback) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 14 with StringRes

use of android.support.annotation.StringRes in project Remindy by abicelis.

the class PlaceActivity method handleDeletePlace.

private void handleDeletePlace() {
    mDao = new RemindyDAO(getApplicationContext());
    final BaseTransientBottomBar.BaseCallback<Snackbar> callback = new BaseTransientBottomBar.BaseCallback<Snackbar>() {

        @Override
        public void onDismissed(Snackbar transientBottomBar, int event) {
            super.onDismissed(transientBottomBar, event);
            setResult(RESULT_OK);
            finish();
        }
    };
    // Check if Place is associated with at least one location-based reminder
    List<Task> locationBasedTasks = new ArrayList<>();
    try {
        locationBasedTasks = mDao.getLocationBasedTasksAssociatedWithPlace(mPlace.getId(), -1);
    } catch (CouldNotGetDataException e) {
        SnackbarUtil.showSnackbar(mMapContainer, SnackbarUtil.SnackbarType.ERROR, R.string.activity_place_snackbar_error_deleting, SnackbarUtil.SnackbarDuration.LONG, null);
    }
    // if there are tasks that use this place, warn user
    @StringRes int title = (locationBasedTasks.size() > 0 ? R.string.activity_place_dialog_delete_with_associated_tasks_title : R.string.activity_place_dialog_delete_title);
    @StringRes int message = (locationBasedTasks.size() > 0 ? R.string.activity_place_dialog_delete_with_associated_tasks_message : R.string.activity_place_dialog_delete_message);
    @StringRes int positive = (locationBasedTasks.size() > 0 ? R.string.activity_place_dialog_delete_with_associated_tasks_positive : R.string.activity_place_dialog_delete_positive);
    @StringRes int negative = (locationBasedTasks.size() > 0 ? R.string.activity_place_dialog_delete_negative : R.string.activity_place_dialog_delete_negative);
    AlertDialog dialog = new AlertDialog.Builder(this).setTitle(getResources().getString(title)).setMessage(getResources().getString(message)).setPositiveButton(getResources().getString(positive), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                mDao.deletePlace(mPlace.getId());
                SnackbarUtil.showSnackbar(mMapContainer, SnackbarUtil.SnackbarType.SUCCESS, R.string.activity_place_snackbar_delete_succesful, SnackbarUtil.SnackbarDuration.SHORT, callback);
                dialog.dismiss();
            } catch (CouldNotDeleteDataException e) {
                SnackbarUtil.showSnackbar(mMapContainer, SnackbarUtil.SnackbarType.ERROR, R.string.activity_place_snackbar_error_deleting, SnackbarUtil.SnackbarDuration.LONG, callback);
            }
        }
    }).setNegativeButton(getResources().getString(negative), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).create();
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) Task(ve.com.abicelis.remindy.model.Task) CouldNotGetDataException(ve.com.abicelis.remindy.exception.CouldNotGetDataException) DialogInterface(android.content.DialogInterface) StringRes(android.support.annotation.StringRes) BaseTransientBottomBar(android.support.design.widget.BaseTransientBottomBar) ArrayList(java.util.ArrayList) CouldNotDeleteDataException(ve.com.abicelis.remindy.exception.CouldNotDeleteDataException) RemindyDAO(ve.com.abicelis.remindy.database.RemindyDAO) Snackbar(android.support.design.widget.Snackbar)

Example 15 with StringRes

use of android.support.annotation.StringRes in project buglife-android by Buglife.

the class ScreenshotAnnotatorActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screenshot_annotator);
    mAnnotationView = (AnnotationView) findViewById(R.id.annotation_view);
    Intent intent = getIntent();
    intent.setExtrasClassLoader(FileAttachment.class.getClassLoader());
    mAttachment = intent.getParcelableExtra(INTENT_KEY_ATTACHMENT);
    intent.setExtrasClassLoader(BugContext.class.getClassLoader());
    mBugContext = intent.getParcelableExtra(INTENT_KEY_BUG_CONTEXT);
    File file = mAttachment.getFile();
    Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
    mAnnotationView.setImage(bitmap);
    mColorPalette = new ColorPalette.Builder(this).build();
    // Annotation tools
    mAnnotationToolbar = findViewById(R.id.annotation_toolbar);
    mAnnotationToolbar.setBackgroundColor(mColorPalette.getColorPrimary());
    mArrowTool = (ImageButton) findViewById(R.id.arrow_tool);
    mLoupeTool = (ImageButton) findViewById(R.id.loupe_tool);
    mBlurTool = (ImageButton) findViewById(R.id.blur_tool);
    mArrowTool.setColorFilter(getToolColorFilter());
    mLoupeTool.setColorFilter(getToolColorFilter());
    mBlurTool.setColorFilter(getToolColorFilter());
    mArrowTool.setOnClickListener(mToolClickListener);
    mLoupeTool.setOnClickListener(mToolClickListener);
    mBlurTool.setOnClickListener(mToolClickListener);
    setSelectedTool(Annotation.Type.ARROW);
    mAnnotationView.setAnnotation(Annotation.newArrowInstance());
    mAnnotationView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getActionMasked()) {
                case MotionEvent.ACTION_DOWN:
                    setToolbarsHidden(true);
                    break;
                case MotionEvent.ACTION_UP:
                    setToolbarsHidden(false);
                    break;
            }
            // Must return false in order for event to propagate down
            return false;
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        int colorPrimary = mColorPalette.getColorPrimary();
        int titleTextColor = mColorPalette.getTextColorPrimary();
        @DrawableRes final int homeAsUpIndicatorDrawableId;
        @StringRes final int titleStringId;
        if (isInitialScreenshotAnnotationActivity()) {
            // If this is the initial screenshot activity, show a different title
            // along with close + next buttons
            homeAsUpIndicatorDrawableId = android.R.drawable.ic_menu_close_clear_cancel;
            titleStringId = R.string.report_a_bug;
        } else {
            // Otherwise, this is a child activity of ReportActivity
            homeAsUpIndicatorDrawableId = R.drawable.buglife_abc_ic_ab_back_mtrl_am_alpha;
            titleStringId = R.string.screenshot_annotator_activity_label;
        }
        Drawable homeAsUpIndicator = ActivityUtils.getTintedDrawable(this, homeAsUpIndicatorDrawableId, mColorPalette.getTextColorPrimary());
        CharSequence title = ActivityUtils.getTextWithColor(this, titleTextColor, titleStringId);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(homeAsUpIndicator);
        actionBar.setBackgroundDrawable(new ColorDrawable(colorPrimary));
        actionBar.setTitle(title);
    }
    ActivityUtils.setStatusBarColor(this, mColorPalette.getColorPrimaryDark());
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
        // ClientEventReporter.getInstance(Buglife.getContext()).reportClientEvent("presented_reporter", mBugContext.getApiIdentity());
        }
    }, 2000);
}
Also used : DrawableRes(android.support.annotation.DrawableRes) StringRes(android.support.annotation.StringRes) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) Intent(android.content.Intent) View(android.view.View) MotionEvent(android.view.MotionEvent) Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) File(java.io.File) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

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