Search in sources :

Example 46 with ImageButton

use of android.widget.ImageButton in project android_frameworks_base by ResurrectionRemix.

the class FloatingToolbar method createMenuItemButton.

/**
     * Creates and returns a menu button for the specified menu item.
     */
private static View createMenuItemButton(Context context, MenuItem menuItem) {
    if (isIconOnlyMenuItem(menuItem)) {
        View imageMenuItemButton = LayoutInflater.from(context).inflate(R.layout.floating_popup_menu_image_button, null);
        ((ImageButton) imageMenuItemButton.findViewById(R.id.floating_toolbar_menu_item_image_button)).setImageDrawable(menuItem.getIcon());
        return imageMenuItemButton;
    }
    Button menuItemButton = (Button) LayoutInflater.from(context).inflate(R.layout.floating_popup_menu_button, null);
    menuItemButton.setText(menuItem.getTitle());
    menuItemButton.setContentDescription(menuItem.getTitle());
    return menuItemButton;
}
Also used : ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 47 with ImageButton

use of android.widget.ImageButton in project Rocket.Chat.Android by RocketChat.

the class RoomToolbar method onLayout.

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    if (badgeImageView != null && badgeImageView.getVisibility() != View.GONE) {
        try {
            Field field = Toolbar.class.getDeclaredField("mNavButtonView");
            field.setAccessible(true);
            ImageButton navButtonView = (ImageButton) field.get(this);
            int iconLeft = navButtonView.getLeft();
            int iconTop = navButtonView.getTop();
            int iconRight = navButtonView.getRight();
            int iconBottom = navButtonView.getBottom();
            // put badge image at right-top side on the NavButtonView,
            // with 1/8 margin and 1/4 scale.
            int badgeLeft = iconLeft + (iconRight - iconLeft) * 5 / 8;
            int badgeRight = iconLeft + (iconRight - iconLeft) * 7 / 8;
            int badgeTop = iconTop + (iconBottom - iconTop) / 8;
            int badgeBottom = iconTop + (iconBottom - iconTop) * 3 / 8;
            badgeImageView.layout(badgeLeft, badgeTop, badgeRight, badgeBottom);
        } catch (Exception exception) {
            return;
        }
    }
}
Also used : Field(java.lang.reflect.Field) ImageButton(android.widget.ImageButton)

Example 48 with ImageButton

use of android.widget.ImageButton in project android_frameworks_base by ResurrectionRemix.

the class ScreenshotEditor method initButtons.

private void initButtons() {
    mainLayout.setSystemUiVisibility(getUiOptions());
    cropView = (CropImageView) mainLayout.findViewById(R.id.image);
    cropView.setFrameColor(getResources().getColor(R.color.crop_frame));
    cropView.setHandleColor(getResources().getColor(R.color.crop_handle));
    cropView.setGuideColor(getResources().getColor(R.color.crop_guide));
    cropView.setHandleSizeInDp(15);
    cropView.setTouchPaddingInDp(10);
    cropView.setGuideShowMode(CropImageView.ShowMode.SHOW_ON_TOUCH);
    cropModeButton = (ImageButton) mainLayout.findViewById(R.id.cropMode);
    final ListPopupWindow listPopupWindowCropMode = new ListPopupWindow(mContext);
    nCropMode = preferences.getInt(KEY_WORK_MODE, 0);
    ImageArrayAdapter cropModeAdapter = new ImageArrayAdapter(mContext, new Integer[] { R.drawable.ic_image_crop_free, R.drawable.ic_image_crop_square, R.drawable.ic_image_crop_circle });
    listPopupWindowCropMode.setAdapter(cropModeAdapter);
    listPopupWindowCropMode.setAnchorView(cropModeButton);
    listPopupWindowCropMode.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            nCropMode = position;
            setCropMode();
            preferences.edit().putInt(KEY_CROP_MODE, nCropMode).apply();
            setCropMode();
            listPopupWindowCropMode.dismiss();
        }
    });
    listPopupWindowCropMode.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpCropModeShowing = false;
        }
    });
    cropModeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpCropModeShowing) {
                listPopupWindowCropMode.show();
                isPopUpCropModeShowing = true;
            } else
                listPopupWindowCropMode.dismiss();
        }
    });
    cropModeButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    cropButton = (ImageButton) mainLayout.findViewById(R.id.doneCrop);
    cropButton.setOnClickListener(this);
    cropButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton recoverButton = (ImageButton) mainLayout.findViewById(R.id.recover);
    recoverButton.setOnClickListener(this);
    recoverButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton deleteButton = (ImageButton) mainLayout.findViewById(R.id.delete);
    deleteButton.setOnClickListener(this);
    deleteButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton shareButton = (ImageButton) mainLayout.findViewById(R.id.share);
    shareButton.setOnClickListener(this);
    shareButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton saveButton = (ImageButton) mainLayout.findViewById(R.id.save);
    saveButton.setOnClickListener(this);
    saveButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final Integer[] colors = new Integer[] { getResources().getColor(R.color.crop_draw_color_1), getResources().getColor(R.color.crop_draw_color_2), getResources().getColor(R.color.crop_draw_color_3), getResources().getColor(R.color.crop_draw_color_4), getResources().getColor(R.color.crop_draw_color_5), getResources().getColor(R.color.crop_draw_color_6), getResources().getColor(R.color.crop_draw_color_7), getResources().getColor(R.color.crop_draw_color_8) };
    final BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_image_edit, opt);
    float scale = getResources().getDisplayMetrics().density;
    final ListPopupWindow listPopupWindowColorPicker = new ListPopupWindow(mContext);
    listPopupWindowColorPicker.setAdapter(new ColorArrayAdapter(mContext, colors));
    int width = mContext.getResources().getDimensionPixelSize(R.dimen.crop_buttons);
    final ImageButton drawColorButton = (ImageButton) mainLayout.findViewById(R.id.drawColor);
    listPopupWindowColorPicker.setAnchorView(drawColorButton);
    drawColor = preferences.getInt(KEY_DRAW_COLOR, getResources().getColor(R.color.crop_draw_color_1));
    cropView.setDrawColor(drawColor);
    drawColorButton.setImageDrawable(createColorImage(drawColor));
    listPopupWindowColorPicker.setDropDownGravity(Gravity.CENTER);
    drawColorButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpColorShowing) {
                listPopupWindowColorPicker.show();
                isPopUpColorShowing = true;
            }
        }
    });
    listPopupWindowColorPicker.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpColorShowing = false;
        }
    });
    listPopupWindowColorPicker.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            drawColor = colors[position];
            drawColorButton.setImageDrawable(createColorImage(drawColor));
            preferences.edit().putInt(KEY_DRAW_COLOR, drawColor).apply();
            cropView.setDrawColor(drawColor);
            listPopupWindowColorPicker.dismiss();
        }
    });
    final String[] penSizeValues = getResources().getStringArray(R.array.crop_pen_size_entries);
    final ListPopupWindow listPopupPenSizerPicker = new ListPopupWindow(mContext);
    listPopupPenSizerPicker.setAdapter(new PenSizeArrayAdapter(this, android.R.layout.simple_list_item_1, penSizeValues));
    final ImageButton penSizeButton = (ImageButton) mainLayout.findViewById(R.id.penSize);
    listPopupPenSizerPicker.setAnchorView(penSizeButton);
    final int penSizeValue = preferences.getInt(KEY_PEN_SIZE, 5);
    penSize = Math.round(penSizeValue * mDensity);
    cropView.setPenSize(penSize);
    penSizeButton.setImageDrawable(createPenSizeImage(penSize));
    listPopupPenSizerPicker.setDropDownGravity(Gravity.CENTER);
    penSizeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpColorShowing) {
                listPopupPenSizerPicker.show();
                isPopUpPenSizeShowing = true;
            }
        }
    });
    listPopupPenSizerPicker.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpPenSizeShowing = false;
        }
    });
    listPopupPenSizerPicker.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final int penSizeValue = Integer.valueOf(penSizeValues[position]);
            preferences.edit().putInt(KEY_PEN_SIZE, penSizeValue).apply();
            penSize = Math.round(penSizeValue * mDensity);
            penSizeButton.setImageDrawable(createPenSizeImage(penSize));
            cropView.setPenSize(penSize);
            listPopupPenSizerPicker.dismiss();
        }
    });
    layoutWorkModeCrop = (LinearLayout) mainLayout.findViewById(R.id.layout_work_mode_crop);
    layoutWorkModeDraw = (LinearLayout) mainLayout.findViewById(R.id.layout_work_mode_draw);
    final ListPopupWindow listPopupWindow = new ListPopupWindow(mContext);
    workModeButton = (ImageButton) mainLayout.findViewById(R.id.workMode);
    workMode = preferences.getInt(KEY_WORK_MODE, WORK_MODE_CROP);
    ImageArrayAdapter adapter = new ImageArrayAdapter(mContext, new Integer[] { R.drawable.ic_image_crop, R.drawable.ic_image_edit, R.drawable.ic_action_visibility });
    listPopupWindow.setAdapter(adapter);
    listPopupWindow.setAnchorView(workModeButton);
    listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            preferences.edit().putInt(KEY_WORK_MODE, position).apply();
            workMode = position;
            setWorkMode();
            listPopupWindow.dismiss();
        }
    });
    listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpWorkModeShowing = false;
        }
    });
    workModeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpWorkModeShowing) {
                listPopupWindow.show();
                isPopUpWorkModeShowing = true;
            } else
                listPopupWindow.dismiss();
        }
    });
    setWorkMode();
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) PopupWindow(android.widget.PopupWindow) ColorArrayAdapter(com.android.systemui.screenshot.ColorArrayAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CropImageView(com.android.systemui.screenshot.CropImageView) Paint(android.graphics.Paint) Point(android.graphics.Point) ImageButton(android.widget.ImageButton) ListPopupWindow(android.widget.ListPopupWindow) ImageArrayAdapter(com.android.systemui.screenshot.ImageArrayAdapter) AdapterView(android.widget.AdapterView) BitmapFactory(android.graphics.BitmapFactory)

Example 49 with ImageButton

use of android.widget.ImageButton in project android_frameworks_base by ResurrectionRemix.

the class ManualActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.manual_layout);
    onCreateCommon(mRunnable);
    mSoftwareView = (MainView) findViewById(R.id.software_view);
    mSoftwareView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    mSoftwareView.setBackgroundColor(Color.WHITE);
    mSoftwareView.addDrawCallback(mDrawCallback);
    mCompareImageView = (ImageView) findViewById(R.id.compare_image_view);
    int width = getResources().getDimensionPixelSize(R.dimen.layer_width);
    int height = getResources().getDimensionPixelSize(R.dimen.layer_height);
    mCompareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    mErrorTextView = (TextView) findViewById(R.id.current_error);
    ((ImageButton) findViewById(R.id.next)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DisplayModifier.step();
            updateSpinners();
            redrawViews();
        }
    });
    ((ImageButton) findViewById(R.id.previous)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DisplayModifier.stepBack();
            updateSpinners();
            redrawViews();
        }
    });
    ((Button) findViewById(R.id.show_hardware_version)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCompareImageViewState = COMPARE_VIEW_HARDWARE;
            mHandler.post(mRunnable);
        }
    });
    ((Button) findViewById(R.id.show_software_version)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCompareImageViewState = COMPARE_VIEW_SOFTWARE;
            mHandler.post(mRunnable);
        }
    });
    ((Button) findViewById(R.id.show_error_heatmap)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCompareImageViewState = COMPARE_VIEW_HEATMAP;
            mHandler.post(mRunnable);
        }
    });
    buildSpinnerLayout();
}
Also used : ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 50 with ImageButton

use of android.widget.ImageButton in project newsrob by marianokamp.

the class AbstractNewsRobListActivity method setupButtons.

private void setupButtons() {
    if (shouldActionBarBeHidden())
        return;
    // In Progress Cancel Sync Button
    Button cancelSyncButton = (Button) findViewById(R.id.cancel_sync);
    if (cancelSyncButton != null) {
        cancelSyncButton.setBackgroundResource(R.drawable.custom_button);
        cancelSyncButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                entryManager.cancel();
            }
        });
    }
    refreshButton = (ImageButton) findViewById(R.id.refresh);
    if (refreshButton == null)
        return;
    refreshButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if ("Refresh".equals(v.getTag())) {
                requestRefresh();
                Toast.makeText(AbstractNewsRobListActivity.this, "Refresh", Toast.LENGTH_SHORT).show();
            }
        }
    });
    showHideButton = (ImageButton) findViewById(R.id.show_hide_button);
    showHideButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            requestToggleHideItems();
            String toastText = getDbQuery().shouldHideReadItems() ? "Unread Articles only" : "All Articles";
            Toast.makeText(AbstractNewsRobListActivity.this, toastText, Toast.LENGTH_SHORT).show();
        }
    });
    markAllReadButton = (ImageButton) findViewById(R.id.mark_all_read_button);
    markAllReadButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AbstractNewsRobListActivity.this.instantiateMarkAllReadDialog();
        }
    });
    toggleOrderButton = (ImageButton) findViewById(R.id.toggle_order_button);
    toggleOrderButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            requestToggleSortOrder();
            String toastText = getDbQuery().isSortOrderAscending() ? "Oldest first" : "Newest first";
            Toast.makeText(AbstractNewsRobListActivity.this, toastText, Toast.LENGTH_SHORT).show();
        }
    });
    updateButtons();
}
Also used : ImageButton(android.widget.ImageButton) Button(android.widget.Button) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView)

Aggregations

ImageButton (android.widget.ImageButton)158 View (android.view.View)112 TextView (android.widget.TextView)87 ImageView (android.widget.ImageView)55 Button (android.widget.Button)27 ListView (android.widget.ListView)25 AdapterView (android.widget.AdapterView)24 OnClickListener (android.view.View.OnClickListener)21 LinearLayout (android.widget.LinearLayout)21 Intent (android.content.Intent)19 RelativeLayout (android.widget.RelativeLayout)13 DialogInterface (android.content.DialogInterface)12 Bundle (android.os.Bundle)11 LayoutInflater (android.view.LayoutInflater)11 EditText (android.widget.EditText)11 ViewGroup (android.view.ViewGroup)10 ArrayList (java.util.ArrayList)10 Builder (android.app.AlertDialog.Builder)7 Drawable (android.graphics.drawable.Drawable)7 RecyclerView (android.support.v7.widget.RecyclerView)7