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

Commit 7b0effea authored by Christian Mehlmauer's avatar Christian Mehlmauer Committed by Steve Kondik
Browse files

ContactsBadge: When there is no data to display, show it to the user

instead of showing an empty badge

To test:
Create an empty Contact (only with a name), and click the Android symbol
on the Contact.
old Version: Empty Badge
new Version: TextView showing "No data"

Change-Id: I28e65b6de689af69d0b6a327c5bea9ab711d0691
parent 3ad0dd57
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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.
-->

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="12dip"
    android:paddingRight="12dip"
    android:scaleType="centerInside"
    android:focusable="false"
    android:clickable="false"
    android:gravity="center_vertical"
    android:background="@drawable/quickcontact_slider_btn_normal"
    android:textColor="@android:color/black"
    android:text="@string/quickcontact_no_data" />
+16 −13
Original line number Diff line number Diff line
@@ -839,6 +839,9 @@
    <!-- Shown as the header name for a person when the name is missing or unknown. -->
    <string name="quickcontact_missing_name">Unknown</string>

    <!-- Text that is shown in the Badge, when there is no data to display -->
    <string name="quickcontact_no_data">No data</string>

    <!-- The menu item to open the list of accounts -->
    <string name="menu_accounts">Accounts</string>

@@ -1123,8 +1126,8 @@

    <!-- Text shown in the contacts app if the background process updating contacts fails because of memory shortage -->
    <string name="upgrade_out_of_memory">Contacts are in the process of being upgraded.
    \n\nThe upgrade process requires approximately <xliff:g id="size_in_megabytes">%d</xliff:g>Mb of 
    internal phone storage.\n\nChoose one of the following options:</string>
    \n\nThe upgrade process requires approximately <xliff:g id="size_in_megabytes">%d</xliff:g>
    Mb of internal phone storage.\n\nChoose one of the following options:</string>

    <!-- Button shown in the contacts app if the background process updating contacts fails because of memory shortage -->
    <string name="upgrade_out_of_memory_uninstall">Uninstall some applications</string>
+18 −5
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ public class QuickContactWindow implements Window.Callback,
    private int mRequestedY;

    private boolean mHasValidSocial = false;
    private boolean mHasData = false;
    private boolean mMakePrimary = false;

    private ImageView mArrowUp;
@@ -599,7 +598,7 @@ public class QuickContactWindow implements Window.Callback,
     * {@link #showInternal()} when all data items are present.
     */
    private void considerShowing() {
        if (mHasData && !mShowing && !mDismissed) {
        if (!mShowing && !mDismissed) {
            if (mMode == QuickContact.MODE_MEDIUM && !mHasValidSocial) {
                // Missing valid social, swap medium for small header
                mHeader.setVisibility(View.GONE);
@@ -624,7 +623,6 @@ public class QuickContactWindow implements Window.Callback,
        }

        handleData(cursor);
        mHasData = true;

        if (!cursor.isClosed()) {
            cursor.close();
@@ -1258,9 +1256,12 @@ public class QuickContactWindow implements Window.Callback,
        // All the mime-types to add.
        final Set<String> containedTypes = new HashSet<String>(mActions.keySet());

        boolean hasData = false;

        // First, add PRECEDING_MIMETYPES, which are most common.
        for (String mimeType : PRECEDING_MIMETYPES) {
            if (containedTypes.contains(mimeType)) {
                hasData = true;
                mTrack.addView(inflateAction(mimeType), index++);
                containedTypes.remove(mimeType);
            }
@@ -1272,6 +1273,7 @@ public class QuickContactWindow implements Window.Callback,
        // Then, add FOLLOWING_MIMETYPES, which are least common.
        for (String mimeType : FOLLOWING_MIMETYPES) {
            if (containedTypes.contains(mimeType)) {
                hasData = true;
                mTrack.addView(inflateAction(mimeType), index++);
                containedTypes.remove(mimeType);
            }
@@ -1280,10 +1282,17 @@ public class QuickContactWindow implements Window.Callback,
        // Go back to just after PRECEDING_MIMETYPES, and append the rest.
        index = indexAfterPreceding;
        final String[] remainingTypes = containedTypes.toArray(new String[containedTypes.size()]);
        if (remainingTypes.length > 0) hasData = true;
        Arrays.sort(remainingTypes);
        for (String mimeType : remainingTypes) {
            mTrack.addView(inflateAction(mimeType), index++);
        }

        // When there is no data to display, add a TextView to show the user there's no data
        if (!hasData) {
            View view = mInflater.inflate(R.layout.quickcontact_item_nodata, mTrack, false);
            mTrack.addView(view, index++);
        }
    }

    /**
@@ -1316,6 +1325,10 @@ public class QuickContactWindow implements Window.Callback,
     * possible recycling during another pass.
     */
    private synchronized void releaseView(View view) {
        // Only add CheckableImageViews
        if (!(view instanceof CheckableImageView)) {
            return;
        }
        mActionPool.offer(view);
        mActionRecycled++;
    }