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

Commit 353efcf3 authored by Adam Powell's avatar Adam Powell
Browse files

Convert calculator to use ViewPager for multi-page layouts.

Change-Id: Icb6b136e72cfac98119b639259818f5363be7176
parent 6547c777
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_STATIC_JAVA_LIBRARIES := libarity
LOCAL_STATIC_JAVA_LIBRARIES := libarity android-support-v4

LOCAL_SRC_FILES := $(call all-java-files-under, src)

@@ -32,6 +32,7 @@ include $(BUILD_PACKAGE)
include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libarity:arity-2.1.2.jar

include $(BUILD_MULTI_PREBUILT)

# Use the folloing include to make our test apk.
+93 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
/*
* Copyright (C) 2011, 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.
*/
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/advancedPad"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:orientation="vertical"
              android:layout_gravity="center"
              >

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/sin"
            android:text="@string/sin"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/cos"
            android:text="@string/cos"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/tan"
            android:text="@string/tan"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/pi"
            android:text="@string/pi"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/factorial"
            android:text="@string/factorial"
            style="@style/button_style"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/ln"
            android:text="@string/ln"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/lg"
            android:text="@string/lg"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/e"
            android:text="@string/e"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/power"
            android:text="@string/power"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/sqrt"
            android:text="@string/sqrt"
            style="@style/button_style"
            />
    </LinearLayout>
</LinearLayout>
+3 −198
Original line number Diff line number Diff line
@@ -76,206 +76,11 @@
        </FrameLayout>
    </LinearLayout>

    <com.android.calculator2.PanelSwitcher
    <android.support.v4.view.ViewPager
         android:id="@+id/panelswitch"
         android:layout_width="match_parent"
         android:layout_height="0dp"
         android:layout_weight="5"
         >

    <LinearLayout 
         android:id="@+id/simplePad"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
         android:layout_gravity="center"
         > 
        <LinearLayout 
             android:layout_weight="1"
             android:layout_width="match_parent"
             android:layout_height="0dp"
             >    
            <com.android.calculator2.ColorButton
                android:id="@+id/digit7"
                android:text="@string/digit7"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/digit8"
                android:text="@string/digit8"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/digit9"
                android:text="@string/digit9"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/leftParen"
                android:text="@string/leftParen"
                style="@style/button_style"
         android:layout_weight="4"
         />
            <com.android.calculator2.ColorButton
                android:id="@+id/rightParen"
                android:text="@string/rightParen"
                style="@style/button_style"
                />
            <com.android.calculator2.ColorButton 
                android:id="@+id/mul"
                android:text="@string/mul"
                style="@style/button_style"
                />
        </LinearLayout>

        <LinearLayout 
             android:layout_weight="1"
             android:layout_width="match_parent"
             android:layout_height="0dp"
             >    
            <com.android.calculator2.ColorButton
                android:id="@+id/digit4"
                android:text="@string/digit4"
                style="@style/digit_button_style"
                />        
            <com.android.calculator2.ColorButton 
                android:id="@+id/digit5"
                android:text="@string/digit5"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton 
                android:id="@+id/digit6"
                android:text="@string/digit6"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton 
                android:id="@+id/dot"
                android:text="@string/dot"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/div"
                android:text="@string/div"
                style="@style/button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/minus"
                android:text="@string/minus"
                style="@style/button_style"
                />
        </LinearLayout>
        
        <LinearLayout 
             android:layout_weight="1"
             android:layout_width="match_parent"
             android:layout_height="0dp"
             >            
            <com.android.calculator2.ColorButton
                android:id="@+id/digit1"
                android:text="@string/digit1"
                style="@style/digit_button_style"
                />        
            <com.android.calculator2.ColorButton
                android:id="@+id/digit2"
                android:text="@string/digit2"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton 
                android:id="@+id/digit3"
                android:text="@string/digit3"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/digit0"
                android:text="@string/digit0"
                style="@style/digit_button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/equal"
                android:text="@string/equal"
                style="@style/button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/plus"
                android:text="@string/plus"
                style="@style/button_style"
                />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout 
         android:id="@+id/advancedPad"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_weight="1"
         android:orientation="vertical"
         android:layout_gravity="center"
         android:layout_marginTop="5dp"
         android:layout_marginBottom="0dp"
         > 
        
        <LinearLayout 
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            >            
            <com.android.calculator2.ColorButton 
                android:id="@+id/sin"
                android:text="@string/sin"
                style="@style/button_small_style"
                />
            <com.android.calculator2.ColorButton 
                android:id="@+id/cos"
                android:text="@string/cos"
                style="@style/button_small_style"
                />
            <com.android.calculator2.ColorButton 
                android:id="@+id/tan"
                android:text="@string/tan"
                style="@style/button_small_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/pi"
                android:text="@string/pi"
                style="@style/button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/factorial"
                android:text="@string/factorial"
                style="@style/button_style"
                />
        </LinearLayout>
        
        <LinearLayout 
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            >            
            <com.android.calculator2.ColorButton
                android:id="@+id/ln"
                android:text="@string/ln"
                style="@style/button_small_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/lg"
                android:text="@string/lg"
                style="@style/button_small_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/e"
                android:text="@string/e"
                style="@style/button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/power"
                android:text="@string/power"
                style="@style/button_style"
                />
            <com.android.calculator2.ColorButton
                android:id="@+id/sqrt"
                android:text="@string/sqrt"
                style="@style/button_style"
                />
        </LinearLayout>
    </LinearLayout>
    </com.android.calculator2.PanelSwitcher>
</LinearLayout>
+138 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
/*
* Copyright (C) 2011, 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.
*/
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/simplePad"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              android:layout_gravity="center"
              >
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/digit7"
            android:text="@string/digit7"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit8"
            android:text="@string/digit8"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit9"
            android:text="@string/digit9"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/leftParen"
            android:text="@string/leftParen"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/rightParen"
            android:text="@string/rightParen"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/mul"
            android:text="@string/mul"
            style="@style/button_style"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/digit4"
            android:text="@string/digit4"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit5"
            android:text="@string/digit5"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit6"
            android:text="@string/digit6"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/dot"
            android:text="@string/dot"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/div"
            android:text="@string/div"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/minus"
            android:text="@string/minus"
            style="@style/button_style"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/digit1"
            android:text="@string/digit1"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit2"
            android:text="@string/digit2"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit3"
            android:text="@string/digit3"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/digit0"
            android:text="@string/digit0"
            style="@style/digit_button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/equal"
            android:text="@string/equal"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/plus"
            android:text="@string/plus"
            style="@style/button_style"
            />
    </LinearLayout>
</LinearLayout>
+116 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
/*
* Copyright (C) 2011, 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.
*/
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/advancedPad"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              android:layout_gravity="center"
              >

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/sin"
            android:text="@string/sin"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/cos"
            android:text="@string/cos"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/tan"
            android:text="@string/tan"
            style="@style/button_small_style"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/ln"
            android:text="@string/ln"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/lg"
            android:text="@string/lg"
            style="@style/button_small_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/factorial"
            android:text="@string/factorial"
            style="@style/button_style"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/pi"
            android:text="@string/pi"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/e"
            android:text="@string/e"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/power"
            android:text="@string/power"
            style="@style/button_style"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        >
        <com.android.calculator2.ColorButton
            android:id="@+id/leftParen"
            android:text="@string/leftParen"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/rightParen"
            android:text="@string/rightParen"
            style="@style/button_style"
            />
        <com.android.calculator2.ColorButton
            android:id="@+id/sqrt"
            android:text="@string/sqrt"
            style="@style/button_style"
            />
    </LinearLayout>
</LinearLayout>
Loading