Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea5df36a authored by John Hoford's avatar John Hoford
Browse files

layouts, image icons, and layer behavour

bug:7328726
Change-Id: I94300771dd7b6ff5b4196365f13320fbc4bdde92
parent 7d161351
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    android:layout_height="match_parent"
    android:background="@color/background_main_toolbar" >

    <LinearLayout
        android:id="@+id/imageStatePanel"
@@ -170,6 +171,15 @@
                android:visibility="gone" />
        </FrameLayout>

        <com.android.gallery3d.filtershow.CenteredLinearLayout
              xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
              android:id="@+id/mainPanel"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              custom:max_width="600dip"
              android:orientation="vertical">

        <FrameLayout
            android:id="@+id/secondRowPanel"
            android:layout_width="fill_parent"
@@ -235,6 +245,7 @@
                    android:id="@+id/listGeometry"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center"
                    android:orientation="horizontal">

                    <com.android.gallery3d.filtershow.ui.ImageButtonTitle
@@ -349,6 +360,15 @@
            </HorizontalScrollView>
        </FrameLayout>

        <com.android.gallery3d.filtershow.CenteredLinearLayout
              xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
              android:id="@+id/mainPanel"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              custom:max_width="400dip"
              android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="48dip"
@@ -393,6 +413,10 @@
                android:scaleType="centerInside"
                android:src="@drawable/ic_photoeditor_color" />
        </LinearLayout>

        </com.android.gallery3d.filtershow.CenteredLinearLayout>

        </com.android.gallery3d.filtershow.CenteredLinearLayout>
    </LinearLayout>

</FrameLayout>
+3 −0
Original line number Diff line number Diff line
@@ -18,4 +18,7 @@
        <attr name="listPreferredItemHeightSmall" format="dimension" />
        <attr name="switchStyle" format="reference" />
    </declare-styleable>
    <declare-styleable name="CenteredLinearLayout">
        <attr name="max_width" format="dimension" />
    </declare-styleable>
</resources>
+36 −0
Original line number Diff line number Diff line
package com.android.gallery3d.filtershow;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View.MeasureSpec;
import android.widget.LinearLayout;

import com.android.gallery3d.R;

public class CenteredLinearLayout extends LinearLayout {
    private final int mMaxWidth;

    public CenteredLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CenteredLinearLayout);
        mMaxWidth = a.getDimensionPixelSize(R.styleable.CenteredLinearLayout_max_width, 0);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
        int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
        Resources r = getContext().getResources();
        float value = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, parentWidth,
                r.getDisplayMetrics());
        if (mMaxWidth > 0 && parentWidth > mMaxWidth) {
            int measureMode = MeasureSpec.getMode(widthMeasureSpec);
            widthMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxWidth, measureMode);
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

}
+88 −1
Original line number Diff line number Diff line
@@ -36,9 +36,17 @@ import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.filters.ImageFilterBorder;
import com.android.gallery3d.filtershow.filters.ImageFilterContrast;
import com.android.gallery3d.filtershow.filters.ImageFilterExposure;
import com.android.gallery3d.filtershow.filters.ImageFilterFx;
import com.android.gallery3d.filtershow.filters.ImageFilterHue;
import com.android.gallery3d.filtershow.filters.ImageFilterParametricBorder;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.filters.ImageFilterSaturated;
import com.android.gallery3d.filtershow.filters.ImageFilterShadows;
import com.android.gallery3d.filtershow.filters.ImageFilterVibrance;
import com.android.gallery3d.filtershow.filters.ImageFilterVignette;
import com.android.gallery3d.filtershow.filters.ImageFilterWBalance;
import com.android.gallery3d.filtershow.imageshow.ImageBorder;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
import com.android.gallery3d.filtershow.imageshow.ImageFlip;
@@ -47,6 +55,7 @@ import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.ImageSmallBorder;
import com.android.gallery3d.filtershow.imageshow.ImageSmallFilter;
import com.android.gallery3d.filtershow.imageshow.ImageStraighten;
import com.android.gallery3d.filtershow.imageshow.ImageWithIcon;
import com.android.gallery3d.filtershow.imageshow.ImageZoom;
import com.android.gallery3d.filtershow.presets.ImagePreset;
import com.android.gallery3d.filtershow.provider.SharedImageProvider;
@@ -124,6 +133,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,

        LinearLayout listFilters = (LinearLayout) findViewById(R.id.listFilters);
        LinearLayout listBorders = (LinearLayout) findViewById(R.id.listBorders);
        LinearLayout listColors = (LinearLayout) findViewById(R.id.listColorsFx);

        mImageShow = (ImageShow) findViewById(R.id.imageShow);
        mImageCurves = (ImageCurves) findViewById(R.id.imageCurves);
@@ -199,7 +209,84 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
        mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton));

        mPanelController.addPanel(mColorsButton, mListColors, 3);
        mPanelController.addComponent(mColorsButton, findViewById(R.id.vignetteButton));

        int []recastIDs = {
                R.id.vignetteButton,
                R.id.vibranceButton,
                R.id.contrastButton,
                R.id.saturationButton,
                R.id.wbalanceButton,
                R.id.hueButton,
                R.id.exposureButton,
                R.id.shadowRecoveryButton
        };
        ImageFilter []filters = {
                new ImageFilterVignette(),
                new ImageFilterVibrance(),
                new ImageFilterContrast(),
                new ImageFilterSaturated(),
                new ImageFilterWBalance(),
                new ImageFilterHue(),
                new ImageFilterExposure(),
                new ImageFilterShadows()
        };


        for (int i = 0; i < filters.length; i++) {

            ImageSmallFilter fView = new ImageSmallFilter(this);
            View v = listColors.findViewById(recastIDs[i]);
            int pos = listColors.indexOfChild(v);
            listColors.removeView(v);

            filters[i].setParameter(100);
            fView.setImageFilter(filters[i]);
            fView.setController(this);
            fView.setImageLoader(mImageLoader);
            fView.setId(recastIDs[i]);

            mPanelController.addComponent(mColorsButton, fView);
            listColors.addView(fView,pos);
        }

        int []overlayIDs = {
                R.id.sharpenButton,
                R.id.curvesButtonRGB
        };
        int []overlayBitmaps = {
                R.drawable.filtershow_button_colors_sharpen,
                R.drawable.filtershow_button_colors_curve
        };
        int []overlayNames = {
                R.string.sharpen,
                R.string.curvesRGB
        };

        for (int i = 0; i < overlayIDs.length; i++)  {
            ImageWithIcon fView = new ImageWithIcon(this);
            View v = listColors.findViewById(overlayIDs[i]);
            int pos = listColors.indexOfChild(v);
            listColors.removeView(v);
            final int sid =overlayNames[i];
            ImageFilterExposure efilter = new ImageFilterExposure(){
                {
                    mName = getString(sid);
                }
            };
            efilter.setParameter(-300);
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
                    overlayBitmaps[i] );

            fView.setIcon(bitmap);
            fView.setImageFilter(efilter);
            fView.setController(this);
            fView.setImageLoader(mImageLoader);
            fView.setId(overlayIDs[i]);

            mPanelController.addComponent(mColorsButton, fView);
            listColors.addView(fView,pos);
        }

        mPanelController.addComponent(mColorsButton, findViewById(R.id.curvesButtonRGB));
        mPanelController.addComponent(mColorsButton, findViewById(R.id.sharpenButton));
        mPanelController.addComponent(mColorsButton, findViewById(R.id.vibranceButton));
+34 −0
Original line number Diff line number Diff line
package com.android.gallery3d.filtershow.imageshow;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;

/**
 * TODO: Insert description here. (generated by hoford)
 */
public class ImageWithIcon extends ImageSmallFilter {
    /**
     * @param context
     */
    public ImageWithIcon(Context context) {
        super(context);
        // TODO(hoford): Auto-generated constructor stub
    }

    private Bitmap bitmap;

    public void setIcon(Bitmap bitmap){
        this.bitmap = bitmap;
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (bitmap != null) {
            Rect d = new Rect(0, mMargin, getWidth() - mMargin, getWidth());
            drawImage(canvas, bitmap, d);
        }
    }
}