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

Commit 192943b3 authored by Megha Joshi's avatar Megha Joshi
Browse files

Change to use depressed chiclet when showing diambig resolve list.

Fixes bug # 2093651
parent 4394bddd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@
     limitations under the License.
-->

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
<com.android.contacts.ui.CheckableImageView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="59dip"
    android:layout_height="52dip"
    android:paddingLeft="12dip"
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008 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.contacts.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.ImageView;

/**
 * A special variation of ImageView that can be used as a checkable object.
 * This is used as the background view of fasttrack chiclet, which is in checked state
 * when disambig list is shown. Otherwise, it works identically to a ImageView.
 */
public class CheckableImageView extends ImageView implements Checkable {
    private boolean mChecked;

    private static final int[] CHECKED_STATE_SET = {
        android.R.attr.state_checked
    };

    public CheckableImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public int[] onCreateDrawableState(int extraSpace) {
        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (isChecked()) {
            mergeDrawableStates(drawableState, CHECKED_STATE_SET);
        }
        return drawableState;
    }

    public void toggle() {
        setChecked(!mChecked);
    }
    
    public boolean isChecked() {
        return mChecked;
    }

    public void setChecked(boolean checked) {
        if (mChecked != checked) {
            mChecked = checked;
            refreshDrawableState();
        }
    }
}
+8 −1
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ public class FastTrackWindow implements Window.Callback,
    private View mFooter;
    private View mFooterDisambig;
    private ListView mResolveList;
    private CheckableImageView mLastChiclet;

    /**
     * Set of {@link Action} that are associated with the aggregate currently
@@ -348,6 +349,9 @@ public class FastTrackWindow implements Window.Callback,
            mWindow.closeAllPanels();
        }

        // Release refrence to last chiclet.
        mLastChiclet = null;

        // Completely hide header from current mode
        mHeader.setVisibility(View.GONE);

@@ -931,7 +935,7 @@ public class FastTrackWindow implements Window.Callback,
     * the icon provided by the {@link DataKind}.
     */
    private View inflateAction(String mimeType) {
        ImageView view = (ImageView)mInflater.inflate(R.layout.fasttrack_item, mTrack, false);
        CheckableImageView view = (CheckableImageView)mInflater.inflate(R.layout.fasttrack_item, mTrack, false);

        // Add direct intent if single child, otherwise flag for multiple
        ActionList children = mActions.get(mimeType);
@@ -982,14 +986,17 @@ public class FastTrackWindow implements Window.Callback,
            // If showing list, then hide and save state of down arrow
            mWasDownArrow = mWasDownArrow || (mArrowDown.getVisibility() == View.VISIBLE);
            mArrowDown.setVisibility(View.INVISIBLE);
	    mLastChiclet.setChecked(true);
        } else {
            // If hiding list, restore any down arrow state
            mArrowDown.setVisibility(mWasDownArrow ? View.VISIBLE : View.INVISIBLE);
	    mLastChiclet.setChecked(false);
        }
    }

    /** {@inheritDoc} */
    public void onClick(View v) {
        mLastChiclet = (CheckableImageView)v;
        final Object tag = v.getTag();
        if (tag instanceof Intent) {
            // Hide the resolution list, if present