OSDN Git Service

Merge "Import translations. DO NOT MERGE" into jb-mr2-dev
authorBaligh Uddin <baligh@google.com>
Wed, 3 Apr 2013 22:00:41 +0000 (22:00 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Wed, 3 Apr 2013 22:00:42 +0000 (22:00 +0000)
res/layout-land/camera_controls.xml
res/layout-port/camera_controls.xml
res/layout/camera_main.xml
res/values-ko/strings.xml
res/values-ru/strings.xml
src/com/android/camera/CameraActivity.java
src/com/android/camera/PhotoUI.java
src/com/android/camera/ui/CameraControls.java [moved from src/com/android/camera/ui/SwitcherBackgroundView.java with 50% similarity]
src/com/android/camera/ui/CameraRootView.java [new file with mode: 0644]
src/com/android/camera/ui/RotatableLayout.java
src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java

index f090e3d..59a83e0 100644 (file)
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<com.android.camera.ui.RotatableLayout
+<com.android.camera.ui.CameraControls
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/camera_controls"
     style="@style/CameraControls"
     android:layout_gravity="center" >
 
-        <com.android.camera.ui.SwitcherBackgroundView
+        <View
             android:id="@+id/blocker"
             android:layout_height="match_parent"
             android:layout_width="@dimen/switcher_size"
@@ -58,4 +58,4 @@
             android:focusable="true"
             android:scaleType="center"
             android:src="@drawable/btn_new_shutter" />
-</com.android.camera.ui.RotatableLayout>
+</com.android.camera.ui.CameraControls>
index 7a12217..e3fdce8 100644 (file)
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<com.android.camera.ui.RotatableLayout
+<com.android.camera.ui.CameraControls
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/camera_controls"
     style="@style/CameraControls"
     android:layout_gravity="center" >
 
-        <com.android.camera.ui.SwitcherBackgroundView
+        <View
             android:id="@+id/blocker"
             android:layout_width="match_parent"
             android:layout_height="@dimen/switcher_size"
@@ -59,4 +59,4 @@
             android:scaleType="center"
             android:src="@drawable/btn_new_shutter" />
 
-</com.android.camera.ui.RotatableLayout>
\ No newline at end of file
+</com.android.camera.ui.CameraControls>
\ No newline at end of file
index 710e69d..fe59134 100644 (file)
@@ -13,7 +13,8 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.camera.ui.CameraRootView
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/content"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >
@@ -29,4 +30,4 @@
         style="@style/CameraControls"
         android:layout_centerInParent="true" />
 
-</RelativeLayout>
\ No newline at end of file
+</com.android.camera.ui.CameraRootView>
\ No newline at end of file
index 267add3..a6d4a5d 100644 (file)
     <!-- no translation found for pref_camera_timer_sound_default (7066624532144402253) -->
     <skip />
     <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"카운트다운하는 동안 신호음 울리기"</string>
-    <string name="setting_off" msgid="4480039384202951946">"사용 안함"</string>
-    <string name="setting_on" msgid="8602246224465348901">"사용"</string>
+    <string name="setting_off" msgid="4480039384202951946">"OFF"</string>
+    <string name="setting_on" msgid="8602246224465348901">"ON"</string>
     <string name="pref_video_quality_title" msgid="8245379279801096922">"동영상 화질"</string>
     <string name="pref_video_quality_entry_high" msgid="8664038216234805914">"고화질"</string>
     <string name="pref_video_quality_entry_low" msgid="7258507152393173784">"저화질"</string>
     <string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"매크로"</string>
     <string name="pref_camera_flashmode_title" msgid="2287362477238791017">"플래시 모드"</string>
     <string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"자동"</string>
-    <string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"사용"</string>
-    <string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"사용 안함"</string>
+    <string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"ON"</string>
+    <string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"OFF"</string>
     <string name="pref_camera_whitebalance_title" msgid="677420930596673340">"화이트 밸런스"</string>
     <string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"자동"</string>
     <string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"백열"</string>
     <string name="accessibility_review_cancel" msgid="9070531914908644686">"리뷰 취소"</string>
     <string name="accessibility_review_ok" msgid="7793302834271343168">"리뷰 완료"</string>
     <string name="accessibility_review_retake" msgid="659300290054705484">"다시 찍기 검토"</string>
-    <string name="capital_on" msgid="5491353494964003567">"사용"</string>
-    <string name="capital_off" msgid="7231052688467970897">"사용 안함"</string>
+    <string name="capital_on" msgid="5491353494964003567">"ON"</string>
+    <string name="capital_off" msgid="7231052688467970897">"OFF"</string>
     <string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"사용 안함"</string>
     <string name="pref_video_time_lapse_frame_interval_500" msgid="2949719376111679816">"0.5초"</string>
     <string name="pref_video_time_lapse_frame_interval_1000" msgid="1672458758823855874">"1초"</string>
index 13efe23..7bb107f 100644 (file)
     <string name="accessibility_review_cancel" msgid="9070531914908644686">"Отмена"</string>
     <string name="accessibility_review_ok" msgid="7793302834271343168">"Готово"</string>
     <string name="accessibility_review_retake" msgid="659300290054705484">"Ещё раз"</string>
-    <string name="capital_on" msgid="5491353494964003567">"Вкл"</string>
-    <string name="capital_off" msgid="7231052688467970897">"Выкл"</string>
+    <string name="capital_on" msgid="5491353494964003567">"I"</string>
+    <string name="capital_off" msgid="7231052688467970897">"O"</string>
     <string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Выкл."</string>
     <string name="pref_video_time_lapse_frame_interval_500" msgid="2949719376111679816">"0,5 сек."</string>
     <string name="pref_video_time_lapse_frame_interval_1000" msgid="1672458758823855874">"1 сек."</string>
index 3813cce..1215cec 100644 (file)
@@ -118,7 +118,6 @@ public class CameraActivity extends ActivityBase
 
     public void init() {
         boolean landscape = Util.getDisplayRotation(this) % 180 == 90;
-        setMargins(landscape);
         mControlsBackground = findViewById(R.id.blocker);
         mCameraControls = findViewById(R.id.camera_controls);
         mShutter = (ShutterButton) findViewById(R.id.shutter_button);
@@ -318,24 +317,9 @@ public class CameraActivity extends ActivityBase
     @Override
     public void onConfigurationChanged(Configuration config) {
         super.onConfigurationChanged(config);
-        boolean landscape = (config.orientation == Configuration.ORIENTATION_LANDSCAPE);
-        setMargins(landscape);
         mCurrentModule.onConfigurationChanged(config);
     }
 
-    private void setMargins(boolean landscape) {
-        ViewGroup appRoot = (ViewGroup) findViewById(R.id.content);
-        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) appRoot.getLayoutParams();
-        int navBarWidth = getResources().getDimensionPixelSize(R.dimen.navigation_bar_width);
-        int navBarHeight = getResources().getDimensionPixelSize(R.dimen.navigation_bar_height);
-        if (landscape) {
-            lp.setMargins(navBarHeight, 0, navBarHeight - navBarWidth, 0);
-        } else {
-            lp.setMargins(0, navBarHeight, 0, 0);
-        }
-        appRoot.setLayoutParams(lp);
-    }
-
     @Override
     public void onPause() {
         mPaused = true;
index 1af870a..29ebd6a 100644 (file)
@@ -115,6 +115,8 @@ public class PhotoUI implements PieListener,
                 h = width;
             }
             if (mPreviewWidth != w || mPreviewHeight != h) {
+                mPreviewWidth = w;
+                mPreviewHeight = h;
                 mController.onScreenSizeChanged(width, height, w, h);
             }
         }
@@ -27,38 +27,57 @@ import android.widget.FrameLayout.LayoutParams;
 import com.android.camera.Util;
 import com.android.gallery3d.R;
 
-/*
- * This is a simple view that has a gradient background. The background
- * needs to rotate when orientation changes, so that the side of the drawable
- * that is dark is always aligned to the side of the screen, and the side that is
- * closer to the center of the screen is transparent.
- * */
-public class SwitcherBackgroundView extends View
+public class CameraControls extends RotatableLayout
 {
-    public SwitcherBackgroundView(Context context, AttributeSet attrs) {
+    private View mBackgroundView;
+    public CameraControls(Context context, AttributeSet attrs) {
         super(context, attrs);
-        setBackgroundResource(R.drawable.switcher_bg);
     }
 
-    public SwitcherBackgroundView(Context context) {
+    public CameraControls(Context context) {
         super(context);
-        setBackgroundResource(R.drawable.switcher_bg);
     }
+
     @Override
     public void onConfigurationChanged(Configuration config) {
         super.onConfigurationChanged(config);
+        adjustBackground();
+    }
+
+    @Override
+    public void onFinishInflate() {
+        super.onFinishInflate();
+        mBackgroundView = findViewById(R.id.blocker);
+    }
+
+    // In reverse landscape and reverse portrait, camera controls will be laid out
+    // on the wrong side of the screen. We need to make adjustment to move the controls
+    // to the USB side
+    public void adjustControlsToRightPosition() {
+        Configuration config = getResources().getConfiguration();
+        int orientation = Util.getDisplayRotation((Activity) getContext());
+        if (orientation == 270 && config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+            flipChildren();
+        }
+        if (orientation == 180 && config.orientation == Configuration.ORIENTATION_PORTRAIT) {
+            flipChildren();
+        }
+        adjustBackground();
+    }
+
+    private void adjustBackground() {
         // remove current drawable and reset rotation
-        setBackgroundDrawable(null);
-        setRotationX(0);
-        setRotationY(0);
+        mBackgroundView.setBackgroundDrawable(null);
+        mBackgroundView.setRotationX(0);
+        mBackgroundView.setRotationY(0);
         // if the switcher background is top aligned we need to flip the background
         // drawable vertically; if left aligned, flip horizontally
-        int gravity = ((LayoutParams) getLayoutParams()).gravity;
+        int gravity = ((LayoutParams) mBackgroundView.getLayoutParams()).gravity;
         if ((gravity & Gravity.TOP) == Gravity.TOP) {
-            setRotationX(180);
+            mBackgroundView.setRotationX(180);
         } else if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
-            setRotationY(180);
+            mBackgroundView.setRotationY(180);
         }
-        setBackgroundResource(R.drawable.switcher_bg);
+        mBackgroundView.setBackgroundResource(R.drawable.switcher_bg);
     }
 }
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java
new file mode 100644 (file)
index 0000000..cce6495
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.ui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.RelativeLayout;
+
+import com.android.camera.Util;
+import com.android.gallery3d.R;
+
+public class CameraRootView extends RelativeLayout
+    implements RotatableLayout.RotationListener {
+
+    private int mOffset = 0;
+    public CameraRootView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        // Layout the window as if we did not need navigation bar
+        setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+    }
+
+    @Override
+    protected boolean fitSystemWindows(Rect insets) {
+        super.fitSystemWindows(insets);
+        // insets include status bar, navigation bar, etc
+        // In this case, we are only concerned with the size of nav bar
+        if (mOffset > 0) return true;
+        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
+        if (insets.bottom > 0) {
+            mOffset = insets.bottom;
+        } else if (insets.right > 0) {
+            mOffset = insets.right;
+        }
+        Configuration config = getResources().getConfiguration();
+        if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
+            lp.setMargins(0, 0, 0, mOffset);
+        } else if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+            lp.setMargins(0, 0, mOffset, 0);
+        }
+        CameraControls controls = (CameraControls) findViewById(R.id.camera_controls);
+        if (controls != null) {
+            controls.setRotationListener(this);
+            controls.adjustControlsToRightPosition();
+        }
+        return true;
+    }
+
+    @Override
+    public void onRotation(int rotation) {
+        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
+        int b = lp.bottomMargin;
+        int t = lp.topMargin;
+        int l = lp.leftMargin;
+        int r = lp.rightMargin;
+        rotation = (rotation + 360) % 360;
+        if (rotation == 90) {
+            lp.setMargins(b, l, t, r);
+        } else if (rotation == 270) {
+            lp.setMargins(t, r, b, l);
+        } else if (rotation == 180) {
+            lp.setMargins(r, b, l, t);
+        }
+    }
+}
index 4edec5d..6836b39 100644 (file)
@@ -39,6 +39,10 @@ public class RotatableLayout extends FrameLayout {
 
     private static final String TAG = "RotatableLayout";
     private int mPrevRotation;
+    private RotationListener mListener = null;
+    public interface RotationListener {
+        public void onRotation(int rotation);
+    }
     public RotatableLayout(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
     }
@@ -53,12 +57,15 @@ public class RotatableLayout extends FrameLayout {
 
     @Override
     public void onFinishInflate() { // get initial orientation
+        super.onFinishInflate();
         mPrevRotation = Util.getDisplayRotation((Activity) getContext());
     }
 
     @Override
     public void onConfigurationChanged(Configuration config) {
         super.onConfigurationChanged(config);
+        int rotation = Util.getDisplayRotation((Activity) getContext());
+        boolean clockwise = isClockWiseRotation(mPrevRotation, rotation);
         // Change the size of the layout
         ViewGroup.LayoutParams lp = getLayoutParams();
         int width = lp.width;
@@ -66,15 +73,33 @@ public class RotatableLayout extends FrameLayout {
         lp.height = width;
         lp.width = height;
         setLayoutParams(lp);
+
         // rotate all the children
-        int rotation = Util.getDisplayRotation((Activity) getContext());
-        boolean clockwise = isClockWiseRotation(mPrevRotation, rotation);
         mPrevRotation = rotation;
+        rotateChildren(clockwise);
+    }
+
+    protected void rotateChildren(boolean clockwise) {
         int childCount = getChildCount();
         for (int i = 0; i < childCount; i++) {
             View child = getChildAt(i);
             rotate(child, clockwise);
         }
+        if (mListener != null) mListener.onRotation(clockwise ? 90 : 270);
+    }
+
+    protected void flipChildren() {
+        mPrevRotation = Util.getDisplayRotation((Activity) getContext());
+        int childCount = getChildCount();
+        for (int i = 0; i < childCount; i++) {
+            View child = getChildAt(i);
+            flip(child);
+        }
+        if (mListener != null) mListener.onRotation(180);
+    }
+
+    public void setRotationListener(RotationListener listener) {
+        mListener = listener;
     }
 
     public static boolean isClockWiseRotation(int prevRotation, int currentRotation) {
@@ -181,4 +206,10 @@ public class RotatableLayout extends FrameLayout {
         lp.height = width;
         view.setLayoutParams(lp);
     }
+
+    // Rotate a given view 180 degrees
+    public static void flip(View view) {
+        rotateClockwise(view);
+        rotateClockwise(view);
+    }
 }
\ No newline at end of file
index 6c3417a..8fcc028 100644 (file)
@@ -83,8 +83,8 @@ public class ImageDraw extends ImageShow {
     float[] mTmpPoint = new float[2]; // so we do not malloc
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        boolean ret = super.onTouchEvent(event);
         if (event.getPointerCount() > 1) {
+            boolean ret = super.onTouchEvent(event);
             if (mFRep.getCurrentDrawing() != null) {
                 mFRep.clearCurrentSection();
                 mEditorDraw.commitLocalRepresentation();
@@ -93,7 +93,7 @@ public class ImageDraw extends ImageShow {
         }
         if (event.getAction() != MotionEvent.ACTION_DOWN) {
             if (mFRep.getCurrentDrawing() == null) {
-                return ret;
+                return super.onTouchEvent(event);
             }
         }