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

Commit c9524f8b authored by Robyn Coultas's avatar Robyn Coultas
Browse files

Preparation for animations if Timer and Stopwatch

Converted CircleButtonsLinearLayout to FrameLayout and renamed
CircleTimerView: always draw circle in view center
CountingTimerView: remeasure text size if view's size changed
StopwatchFragment: some lint cleanup
in the layouts:
remove unneeded layout id and attributes
remove unneeded layout layer in timer_list_item
remove unneeded landscape timer_list_item

Change-Id: Id67e1120c86679c03b55f5b6d714cac233d37842
parent fd263b34
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -13,14 +13,15 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.deskclock.CircleButtonsLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/stopwatch_circle"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:paddingTop="?android:attr/actionBarSize" >
    android:paddingTop="?android:attr/actionBarSize"
    android:baselineAligned="false">

    <FrameLayout
    <com.android.deskclock.CircleButtonsLayout
        android:id="@+id/stopwatch_circle"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_marginLeft="@dimen/circle_margin"
@@ -32,8 +33,7 @@
        <com.android.deskclock.timer.CountingTimerView
            android:id="@+id/stopwatch_time_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center" />
            android:layout_height="match_parent" />

        <com.android.deskclock.CircleTimerView
            android:id="@+id/stopwatch_time"
@@ -77,7 +77,7 @@
            android:layout_gravity="bottom|end"
            android:layout_height="56dip"
            android:contentDescription="@string/sw_share_button" />
    </FrameLayout>
    </com.android.deskclock.CircleButtonsLayout>

    <ListView
        android:id="@+id/laps_list"
@@ -87,4 +87,4 @@
        android:layout_gravity="center"
        android:layout_width="0dip"
        android:layout_height="wrap_content" />
</com.android.deskclock.CircleButtonsLinearLayout>
</LinearLayout>
+0 −117
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 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.
-->

<!-- timer item in the list of active timers -->
<com.android.deskclock.CircleButtonsLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/timer_circle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/timer_frame"
        android:layout_width="@dimen/timer_circle_width"
        android:layout_height="@dimen/timer_circle_diameter"
        android:layout_marginLeft="@dimen/timer_circle_margin"
        android:layout_marginStart="@dimen/timer_circle_margin"
        android:layout_marginRight="@dimen/timer_circle_margin"
        android:layout_marginEnd="@dimen/timer_circle_margin">

        <com.android.deskclock.CircleTimerView
            android:id="@+id/timer_time"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <com.android.deskclock.timer.CountingTimerView
            android:id="@+id/timer_time_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"/>
         <FrameLayout
             android:id="@+id/timer_label"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="0dip"
             android:layout_gravity="top|center_horizontal"
             android:enabled="true"
             android:clickable="true"
             android:contentDescription="@string/label"
             >
             <TextView
                android:id="@+id/timer_label_text"
                android:layout_height="56dip"
                android:layout_width="wrap_content"
                android:background="@null"
                android:layout_gravity="center_horizontal"
                android:gravity="center"
                style="@style/timer_label"
                android:enabled="false"
                android:clickable="false"
                android:singleLine="true"
                android:ellipsize="end"
                android:text="@string/label_unlabeled" />
             <ImageButton
                android:id="@+id/timer_label_icon"
                android:layout_height="56dip"
                android:layout_width="56dip"
                android:background="@null"
                android:layout_gravity="center_horizontal"
                android:enabled="false"
                android:clickable="false"
                style="@style/button"
                android:src="@drawable/ic_label" />
         </FrameLayout>
        <ImageButton
            android:id="@+id/timer_plus_one"
            android:layout_width="56dip"
            android:layout_gravity="bottom|start"
            android:src="@drawable/ic_plusone"
            style="@style/button"
            android:background="@null"
            android:contentDescription="@string/timer_plus_one"
            android:layout_height="56dip" />

        <TextView
            android:id="@+id/timer_stop"
            android:layout_gravity="bottom|center_horizontal"
            android:gravity="center"
            android:layout_marginBottom="0dip"
            android:paddingLeft="10dip"
            android:paddingStart="10dip"
            android:paddingRight="10dip"
            android:paddingEnd="10dip"
            android:paddingBottom="5dip"
            android:paddingTop="5dip"
            android:layout_width="wrap_content"
            android:text="@string/timer_stop"
            style="@style/bold_button"
            android:contentDescription="@string/timer_stop"
            android:layout_height="wrap_content" />

        <ImageButton
            android:id="@+id/timer_delete"
            android:background="@null"
            android:src="@drawable/ic_delete"
            android:layout_gravity="bottom|end"
            android:layout_width="56dip"
            android:contentDescription="@string/timer_delete"
            style="@style/button"
            android:layout_height="56dip" />
    </FrameLayout>

</com.android.deskclock.CircleButtonsLinearLayout>
+6 −7
Original line number Diff line number Diff line
@@ -13,14 +13,14 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.deskclock.CircleButtonsLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/stopwatch_circle"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="?android:attr/actionBarSize" >

    <FrameLayout
    <com.android.deskclock.CircleButtonsLayout
        android:id="@+id/stopwatch_circle"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_marginLeft="@dimen/circle_margin"
@@ -32,8 +32,7 @@
        <com.android.deskclock.timer.CountingTimerView
            android:id="@+id/stopwatch_time_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"/>
            android:layout_height="match_parent" />
        <com.android.deskclock.CircleTimerView
            android:id="@+id/stopwatch_time"
            android:layout_width="match_parent"
@@ -77,11 +76,11 @@
            android:contentDescription="@string/sw_share_button"
            android:background="@null"
            android:src="@drawable/ic_share" />
    </FrameLayout>
    </com.android.deskclock.CircleButtonsLayout>

    <ListView
        android:id="@+id/laps_list"
        android:layout_weight="2"
        android:layout_width="match_parent"
        android:layout_height="0dip" />
</com.android.deskclock.CircleButtonsLinearLayout>
 No newline at end of file
</LinearLayout>
+31 −36
Original line number Diff line number Diff line
@@ -15,17 +15,10 @@
-->

<!-- timer item in the list of active timers -->
<com.android.deskclock.CircleButtonsLinearLayout
<com.android.deskclock.CircleButtonsLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/timer_circle"
        android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/timer_frame"
        android:layout_width="match_parent"
        android:layout_height="@dimen/timer_circle_diameter"
        android:layout_marginLeft="@dimen/timer_circle_margin"
        android:layout_marginStart="@dimen/timer_circle_margin"
@@ -40,8 +33,7 @@
    <com.android.deskclock.timer.CountingTimerView
            android:id="@+id/timer_time_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"/>
            android:layout_height="match_parent"/>

    <FrameLayout
            android:id="@+id/timer_label"
@@ -53,6 +45,7 @@
            android:clickable="true"
            android:contentDescription="@string/label"
            >

        <TextView
                android:id="@+id/timer_label_text"
                android:layout_height="56dip"
@@ -66,6 +59,7 @@
                android:singleLine="true"
                android:ellipsize="end"
                android:text="@string/label_unlabeled"/>

        <ImageButton
                android:id="@+id/timer_label_icon"
                android:layout_height="56dip"
@@ -74,9 +68,11 @@
                android:layout_gravity="center_horizontal"
                android:enabled="false"
                android:clickable="false"
                android:contentDescription="@string/label"
                style="@style/button"
                android:src="@drawable/ic_label"/>
    </FrameLayout>

    <ImageButton
            android:id="@+id/timer_plus_one"
            android:src="@drawable/ic_plusone"
@@ -113,6 +109,5 @@
            android:contentDescription="@string/timer_delete"
            style="@style/button"
            android:layout_height="56dip"/>
    </FrameLayout>
</com.android.deskclock.CircleButtonsLayout>
</com.android.deskclock.CircleButtonsLinearLayout>
+8 −6
Original line number Diff line number Diff line
@@ -4,13 +4,15 @@ import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * TODO: Insert description here. (generated by sblitz)
 * This class adjusts the locations of children buttons and text of this view group by adjusting the
 * margins of each item. The left and right buttons are aligned with the bottom of the circle. The
 * stop button and label text are located within the circle with the stop button near the bottom and
 * the label text near the top. The maximum text size for the label text view is also calculated.
 */
public class CircleButtonsLinearLayout extends LinearLayout {
public class CircleButtonsLayout extends FrameLayout {
    private Context mContext;
    private int mCircleTimerViewId;
    private int mLeftButtonId;
@@ -28,12 +30,12 @@ public class CircleButtonsLinearLayout extends LinearLayout {
    private FrameLayout mLabel;
    private TextView mLabelText;

    public CircleButtonsLinearLayout(Context context) {
    public CircleButtonsLayout(Context context) {
        this(context, null);
        mContext = context;
    }

    public CircleButtonsLinearLayout(Context context, AttributeSet attrs) {
    public CircleButtonsLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
    }
Loading