Home | History | Annotate | Download | only in editors
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.gallery3d.filtershow.editors;
     18 
     19 import android.content.Context;
     20 import android.view.View;
     21 import android.view.View.OnClickListener;
     22 import android.widget.Button;
     23 import android.widget.FrameLayout;
     24 import android.widget.LinearLayout;
     25 
     26 import com.android.gallery3d.R;
     27 import com.android.gallery3d.filtershow.imageshow.ImageRotate;
     28 import com.android.gallery3d.filtershow.imageshow.MasterImage;
     29 
     30 public class EditorRotate extends Editor implements EditorInfo {
     31     public static final String LOGTAG = "EditorRotate";
     32     public static final int ID = R.id.editorRotate;
     33     ImageRotate mImageRotate;
     34 
     35     public EditorRotate() {
     36         super(ID);
     37     }
     38 
     39     @Override
     40     public void createEditor(Context context, FrameLayout frameLayout) {
     41         super.createEditor(context, frameLayout);
     42         if (mImageRotate == null) {
     43             mImageRotate = new ImageRotate(context);
     44         }
     45         mView = mImageShow = mImageRotate;
     46         mImageRotate.setImageLoader(MasterImage.getImage().getImageLoader());
     47         mImageRotate.setEditor(this);
     48         mImageRotate.syncLocalToMasterGeometry();
     49     }
     50 
     51     @Override
     52     public void openUtilityPanel(final LinearLayout accessoryViewList) {
     53         final Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
     54         button.setOnClickListener(new OnClickListener() {
     55             @Override
     56             public void onClick(View arg0) {
     57                 mImageRotate.rotate();
     58                 button.setText(mContext.getString(getTextId()) + " " + mImageRotate.getLocalValue());
     59                 mImageRotate.saveAndSetPreset();
     60             }
     61         });
     62     }
     63 
     64     @Override
     65     public int getTextId() {
     66         return R.string.rotate;
     67     }
     68 
     69     @Override
     70     public int getOverlayId() {
     71         return R.drawable.filtershow_button_geometry_rotate;
     72     }
     73 
     74     @Override
     75     public boolean getOverlayOnly() {
     76         return true;
     77     }
     78 
     79     @Override
     80     public boolean showsSeekBar() {
     81         return false;
     82     }
     83 
     84     @Override
     85     public boolean showsPopupIndicator() {
     86         return false;
     87     }
     88 }
     89