Merge "Fix crash editing newly saved directory contact" into lmp-dev
diff --git a/res/layout/custom_action_bar.xml b/res/layout/custom_action_bar.xml
index af104fe..5b930ea 100644
--- a/res/layout/custom_action_bar.xml
+++ b/res/layout/custom_action_bar.xml
@@ -33,6 +33,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:iconifiedByDefault="false"
- android:inputType="textFilter" />
+ android:inputType="textFilter"
+ android:theme="@style/ContactPickerSearchTheme" />
</FrameLayout>
diff --git a/res/layout/expanding_entry_card_item.xml b/res/layout/expanding_entry_card_item.xml
index 138a3a5..4710df2 100644
--- a/res/layout/expanding_entry_card_item.xml
+++ b/res/layout/expanding_entry_card_item.xml
@@ -90,8 +90,8 @@
android:layout_alignParentTop="true"
android:visibility="gone"
android:background="?android:attr/selectableItemBackgroundBorderless"
- android:layout_marginEnd="@dimen/expanding_entry_card_item_alternate_icon_margin_end"
- android:layout_marginTop="@dimen/expanding_entry_card_item_icon_margin_top"
- android:layout_marginBottom="@dimen/expanding_entry_card_item_alternate_icon_margin_bottom" />
+ android:paddingTop="@dimen/expanding_entry_card_item_icon_margin_top"
+ android:paddingBottom="@dimen/expanding_entry_card_item_alternate_icon_margin_bottom"
+ android:layout_marginStart="@dimen/expanding_entry_card_item_alternate_icon_start_margin" />
</view>
diff --git a/res/layout/quickcontact_content.xml b/res/layout/quickcontact_content.xml
index 5ead702..494b93b 100644
--- a/res/layout/quickcontact_content.xml
+++ b/res/layout/quickcontact_content.xml
@@ -23,7 +23,7 @@
android:background="@color/card_margin_color">
<!-- All the cards should be inserted into this LinearLayout -->
- <view class="com.android.contacts.common.widget.ActivityTouchLinearLayout"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -54,6 +54,6 @@
android:visibility="gone"
cardview:cardCornerRadius="@dimen/expanding_entry_card_card_corner_radius" />
- </view>
+ </LinearLayout>
</com.android.contacts.widget.TouchlessScrollView>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 52918d5..d422627 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -173,7 +173,7 @@
<dimen name="expanding_entry_card_item_icon_margin_top">7dp</dimen>
<dimen name="expanding_entry_card_item_header_only_margin_top">6dp</dimen>
- <dimen name="expanding_entry_card_item_alternate_icon_margin_end">0dp</dimen>
+ <dimen name="expanding_entry_card_item_alternate_icon_start_margin">16dp</dimen>
<dimen name="expanding_entry_card_item_alternate_icon_margin_bottom">10dp</dimen>
<dimen name="expanding_entry_card_badge_separator_margin">8dp</dimen>
@@ -181,6 +181,7 @@
<dimen name="expanding_entry_card_header_margin_bottom">2dp</dimen>
<!-- The top margin when the sub header and text views are both gone -->
<dimen name="expanding_entry_card_item_header_only_margin_bottom">2dp</dimen>
+ <dimen name="expanding_entry_card_item_no_icon_margin_top">6dp</dimen>
<dimen name="people_activity_card_elevation">2dp</dimen>
<!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8ff6469..511f686 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -66,6 +66,7 @@
<item name="android:windowBackground">@color/background_primary</item>
<item name="android:colorPrimaryDark">@color/primary_color_dark</item>
<item name="android:colorPrimary">@color/primary_color</item>
+ <item name="android:colorAccent">@color/primary_color</item>
<item name="list_item_height">?android:attr/listPreferredItemHeight</item>
<item name="activated_background">@drawable/list_item_activated_background</item>
<item name="section_header_background">@drawable/list_title_holo</item>
@@ -128,6 +129,13 @@
<item name="android:displayOptions"></item>
</style>
+ <style name="ContactPickerSearchTheme" parent="@style/PeopleTheme">
+ <item name="android:textColorPrimary">@android:color/white</item>
+ <item name="android:textColorHint">?android:textColorHintInverse</item>
+ <item name="android:colorControlActivated">?android:textColorHintInverse</item>
+ <item name="android:colorControlNormal">@android:color/white</item>
+ </style>
+
<!-- Text in the action bar at the top of the screen -->
<style name="ContactsActionBarTitleText"
parent="@android:style/TextAppearance.Material.Widget.ActionBar.Title">
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index b4ec7f9..f112847 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -131,6 +131,9 @@
private static final String KEY_NEW_CONTACT_READY = "newContactDataReady";
private static final String KEY_EXISTING_CONTACT_READY = "existingContactDataReady";
private static final String KEY_RAW_CONTACTS = "rawContacts";
+ private static final String KEY_SEND_TO_VOICE_MAIL_STATE = "sendToVoicemailState";
+ private static final String KEY_CUSTOM_RINGTONE = "customRingtone";
+ private static final String KEY_ARE_PHONE_OPTIONS_CHANGEABLE = "arePhoneOptionsChangable";
public static final String SAVE_MODE_EXTRA_KEY = "saveMode";
@@ -509,7 +512,9 @@
mExistingContactDataReady = savedState.getBoolean(KEY_EXISTING_CONTACT_READY);
mRawContacts = ImmutableList.copyOf(savedState.<RawContact>getParcelableArrayList(
KEY_RAW_CONTACTS));
-
+ mSendToVoicemailState = savedState.getBoolean(KEY_SEND_TO_VOICE_MAIL_STATE);
+ mCustomRingtone = savedState.getString(KEY_CUSTOM_RINGTONE);
+ mArePhoneOptionsChangable = savedState.getBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE);
}
// mState can still be null because it may not have have finished loading before
@@ -1772,6 +1777,9 @@
outState.putParcelableArrayList(KEY_RAW_CONTACTS,
mRawContacts == null ?
Lists.<RawContact> newArrayList() : Lists.newArrayList(mRawContacts));
+ outState.putBoolean(KEY_SEND_TO_VOICE_MAIL_STATE, mSendToVoicemailState);
+ outState.putString(KEY_CUSTOM_RINGTONE, mCustomRingtone);
+ outState.putBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE, mArePhoneOptionsChangable);
super.onSaveInstanceState(outState);
}
diff --git a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
index e54fe31..9369cbe 100644
--- a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
+++ b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
@@ -357,7 +357,9 @@
if (TextUtils.isEmpty(mTitleTextView.getText()) &&
mEntriesViewGroup.getChildCount() == 0) {
entry.setPadding(entry.getPaddingLeft(),
- entry.getPaddingTop() + getResources().getDimensionPixelSize(
+ getResources().getDimensionPixelSize(
+ R.dimen.expanding_entry_card_item_padding_top) +
+ getResources().getDimensionPixelSize(
R.dimen.expanding_entry_card_null_title_top_extra_padding),
entry.getPaddingRight(),
entry.getPaddingBottom());
@@ -577,6 +579,11 @@
view.setTag(new EntryTag(entry.getId(), entry.getIntent()));
}
+ if (entry.getIntent() == null && entry.getEntryContextMenuInfo() == null) {
+ // Remove the click effect
+ view.setBackground(null);
+ }
+
// If only the header is visible, add a top margin to match icon's top margin.
// Also increase the space below the header for visual comfort.
if (header.getVisibility() == View.VISIBLE && subHeader.getVisibility() == View.GONE &&
@@ -620,13 +627,21 @@
});
}
- // Decrease margin for entries that have an invisible icon
- if (iconVisibility == View.INVISIBLE) {
+ // Adjust the top padding size for entries with an invisible icon. The padding depends on
+ // if there is a sub header or text section
+ if (iconVisibility == View.INVISIBLE &&
+ (!TextUtils.isEmpty(entry.getSubHeader()) || !TextUtils.isEmpty(entry.getText()))) {
+ view.setPaddingRelative(view.getPaddingStart(),
+ getResources().getDimensionPixelSize(
+ R.dimen.expanding_entry_card_item_no_icon_margin_top),
+ view.getPaddingEnd(),
+ view.getPaddingBottom());
+ } else if (iconVisibility == View.INVISIBLE && TextUtils.isEmpty(entry.getSubHeader())
+ && TextUtils.isEmpty(entry.getText())) {
view.setPaddingRelative(view.getPaddingStart(), 0, view.getPaddingEnd(),
view.getPaddingBottom());
}
-
view.setOnCreateContextMenuListener(mOnCreateContextMenuListener);
return view;
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index b61985f..6240c37 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -74,6 +74,7 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
@@ -169,7 +170,7 @@
private static final int ANIMATION_STATUS_BAR_COLOR_CHANGE_DURATION = 150;
private static final int REQUEST_CODE_CONTACT_EDITOR_ACTIVITY = 1;
- private static final int SCRIM_COLOR = Color.argb(0xB2, 0, 0, 0);
+ private static final int SCRIM_COLOR = Color.argb(0xC8, 0, 0, 0);
private static final String MIMETYPE_SMS = "vnd.android-dir/mms-sms";
/** This is the Intent action to install a shortcut in the launcher. */
@@ -228,6 +229,12 @@
private boolean mIsExitAnimationInProgress;
private boolean mHasComputedThemeColor;
+ /**
+ * Used to stop the ExpandingEntry cards from adjusting between an entry click and the intent
+ * being launched.
+ */
+ private boolean mHasIntentLaunched;
+
private Contact mContactData;
private ContactLoader mContactLoader;
private PorterDuffColorFilter mColorFilter;
@@ -339,15 +346,15 @@
// Pass the touch point through the intent for use in the InCallUI
if (Intent.ACTION_CALL.equals(intent.getAction())) {
- final Point touchPoint = TouchPointManager.getInstance().getPoint();
-
- if (touchPoint.x != 0 || touchPoint.y != 0) {
+ if (TouchPointManager.getInstance().hasValidPoint()) {
Bundle extras = new Bundle();
- extras.putParcelable(TouchPointManager.TOUCH_POINT, touchPoint);
+ extras.putParcelable(TouchPointManager.TOUCH_POINT,
+ TouchPointManager.getInstance().getPoint());
intent.putExtra(TelecommManager.EXTRA_OUTGOING_CALL_EXTRAS, extras);
}
}
+ mHasIntentLaunched = true;
startActivity(intent);
}
};
@@ -538,6 +545,14 @@
};
@Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ TouchPointManager.getInstance().setPoint((int) ev.getRawX(), (int) ev.getRawY());
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
+ @Override
protected void onCreate(Bundle savedInstanceState) {
Trace.beginSection("onCreate()");
super.onCreate(savedInstanceState);
@@ -881,7 +896,20 @@
return aboutCardEntries;
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ // If returning from a launched activity, repopulate the contact and about card
+ if (mHasIntentLaunched) {
+ mHasIntentLaunched = false;
+ populateContactAndAboutCard();
+ }
+ }
+
private void populateContactAndAboutCard() {
+ if (mHasIntentLaunched) {
+ return;
+ }
Trace.beginSection("bind contact card");
final List<List<Entry>> contactCardEntries = new ArrayList<>();
@@ -1710,6 +1738,7 @@
}
private void editContact() {
+ mHasIntentLaunched = true;
startActivityForResult(getEditContactIntent(), REQUEST_CODE_CONTACT_EDITOR_ACTIVITY);
}
@@ -1778,6 +1807,7 @@
final Intent chooseIntent = Intent.createChooser(intent, chooseTitle);
try {
+ mHasIntentLaunched = true;
this.startActivity(chooseIntent);
} catch (final ActivityNotFoundException ex) {
Toast.makeText(this, R.string.share_error, Toast.LENGTH_SHORT).show();
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index 82b3970..26b032b 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -54,6 +54,13 @@
* MultiShrinkScroller's code is heavily influenced by ScrollView. Nonetheless, several ScrollView
* features are missing. For example: handling of KEYCODES, OverScroll bounce and saving
* scroll state in savedInstanceState bundles.
+ *
+ * Before copying this approach to nested scrolling, consider whether something simpler & less
+ * customized will work for you. For example, see the re-usable StickyHeaderListView used by
+ * WifiSetupActivity (very nice). Alternatively, check out Google+'s cover photo scrolling or
+ * Android L's built in nested scrolling support. I thought I needed a more custom ViewGroup in
+ * order to track velocity, modify EdgeEffect color & perform specific animations such as the ones
+ * inside snapToBottom(). As a result this ViewGroup has non-standard talkback and keyboard support.
*/
public class MultiShrinkScroller extends FrameLayout {