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

Commit c1678c2f authored by James Kung's avatar James Kung
Browse files

UI adjustments to mini calendar items for tablets.

Change-Id: Ie84eb6720ce11d21895c7ac2143fb38c065e8580
parent 14d76a20
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@

    <com.android.calendar.selectcalendars.CalendarColorSquare
        android:id="@+id/color"
        android:layout_height="48dip"
        android:layout_width="48dip"
        android:layout_marginLeft="13dip"
        android:layout_height="20dip"
        android:layout_width="20dip"
        android:layout_marginLeft="16dip"
        android:layout_gravity="center_vertical"
        style="?android:attr/quickContactBadgeStyleWindowMedium"
        android:cropToPadding="true"
@@ -38,8 +38,8 @@
    <TextView android:id="@+id/calendar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"        
        android:layout_marginLeft="44dip"
        android:layout_marginTop="3dip"
        android:layout_toRightOf="@id/color"
        android:layout_marginLeft="8dip"
        android:singleLine="true"
        android:ellipsize="marquee"
        style="@style/TextAppearance.SelectCalendar_Name"
+12 −38
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.provider.CalendarContract.Calendars;
import android.text.TextUtils;
@@ -34,9 +33,7 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.calendar.CalendarColorPickerDialog;
@@ -45,11 +42,7 @@ import com.android.calendar.Utils;

public class SelectCalendarsSimpleAdapter extends BaseAdapter implements ListAdapter {
    private static final String TAG = "SelectCalendarsAdapter";
    private static int SELECTED_COLOR_CHIP_SIZE = 16;
    private static int UNSELECTED_COLOR_CHIP_SIZE = 10;
    private static int COLOR_CHIP_LEFT_MARGIN = 20;
    private static int COLOR_CHIP_RIGHT_MARGIN = 8;
    private static int COLOR_CHIP_TOP_OFFSET = 5;

    private static int BOTTOM_ITEM_HEIGHT = 64;
    private static int NORMAL_ITEM_HEIGHT = 48;

@@ -105,11 +98,6 @@ public class SelectCalendarsSimpleAdapter extends BaseAdapter implements ListAda

        if (mScale == 0) {
            mScale = mRes.getDisplayMetrics().density;
            SELECTED_COLOR_CHIP_SIZE *= mScale;
            UNSELECTED_COLOR_CHIP_SIZE *= mScale;
            COLOR_CHIP_LEFT_MARGIN *= mScale;
            COLOR_CHIP_RIGHT_MARGIN *= mScale;
            COLOR_CHIP_TOP_OFFSET *= mScale;
            BOTTOM_ITEM_HEIGHT *= mScale;
            NORMAL_ITEM_HEIGHT *= mScale;
        }
@@ -208,6 +196,7 @@ public class SelectCalendarsSimpleAdapter extends BaseAdapter implements ListAda
        notifyDataSetChanged();
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (position >= mRowCount) {
            return null;
@@ -257,11 +246,6 @@ public class SelectCalendarsSimpleAdapter extends BaseAdapter implements ListAda
            }
        });

        CheckBox syncCheckBox = (CheckBox) view.findViewById(R.id.sync);
        if (syncCheckBox != null) {
            // Full screen layout
            syncCheckBox.setChecked(selected);

        int textColor;
        if (selected) {
            textColor = mColorCalendarVisible;
@@ -269,8 +253,13 @@ public class SelectCalendarsSimpleAdapter extends BaseAdapter implements ListAda
            textColor = mColorCalendarHidden;
        }
        calendarName.setTextColor(textColor);
            LayoutParams layoutParam = calendarName.getLayoutParams();

        CheckBox syncCheckBox = (CheckBox) view.findViewById(R.id.sync);
        if (syncCheckBox != null) {
            // Full screen layout
            syncCheckBox.setChecked(selected);

            LayoutParams layoutParam = calendarName.getLayoutParams();
            TextView secondaryText = (TextView) view.findViewById(R.id.status);
            if (!TextUtils.isEmpty(mData[position].ownerAccount)
                    && !mData[position].ownerAccount.equals(name)
@@ -294,23 +283,8 @@ public class SelectCalendarsSimpleAdapter extends BaseAdapter implements ListAda

        } else {
            // Tablet layout
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                    SELECTED_COLOR_CHIP_SIZE, SELECTED_COLOR_CHIP_SIZE);
            params.leftMargin = COLOR_CHIP_LEFT_MARGIN;
            params.rightMargin = COLOR_CHIP_RIGHT_MARGIN;
            // This offset is needed because the assets include the bottom of the
            // previous item
            params.topMargin = COLOR_CHIP_TOP_OFFSET;
            if (!selected) {
                params.height = UNSELECTED_COLOR_CHIP_SIZE;
                params.width = UNSELECTED_COLOR_CHIP_SIZE;
                params.leftMargin += (SELECTED_COLOR_CHIP_SIZE - UNSELECTED_COLOR_CHIP_SIZE) / 2;
                params.topMargin += (SELECTED_COLOR_CHIP_SIZE - UNSELECTED_COLOR_CHIP_SIZE) / 2;
            }
            colorView.setLayoutParams(params);

            Drawable bg = getBackground(position, selected);
            view.setBackgroundDrawable(bg);
            view.findViewById(R.id.color).setEnabled(selected);
            view.setBackgroundDrawable(getBackground(position, selected));
            ViewGroup.LayoutParams newParams = view.getLayoutParams();
            if (position == mData.length - 1) {
                newParams.height = BOTTOM_ITEM_HEIGHT;