Uses a floating action button for adding new contact
Change-Id: I47cc26e857f7b3da8537bc52c8cb08b969af44b7
diff --git a/res/drawable-hdpi/ic_person_add_24dp.png b/res/drawable-hdpi/ic_person_add_24dp.png
new file mode 100644
index 0000000..1b71ff1
--- /dev/null
+++ b/res/drawable-hdpi/ic_person_add_24dp.png
Binary files differ
diff --git a/res/drawable-hdpi/profile_ic_fab_yellow.png b/res/drawable-hdpi/profile_ic_fab_yellow.png
new file mode 100644
index 0000000..9287aa5
--- /dev/null
+++ b/res/drawable-hdpi/profile_ic_fab_yellow.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_person_add_24dp.png b/res/drawable-mdpi/ic_person_add_24dp.png
new file mode 100644
index 0000000..b6cf02d
--- /dev/null
+++ b/res/drawable-mdpi/ic_person_add_24dp.png
Binary files differ
diff --git a/res/drawable-mdpi/profile_ic_fab_yellow.png b/res/drawable-mdpi/profile_ic_fab_yellow.png
new file mode 100644
index 0000000..257be13
--- /dev/null
+++ b/res/drawable-mdpi/profile_ic_fab_yellow.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_person_add_24dp.png b/res/drawable-xhdpi/ic_person_add_24dp.png
new file mode 100644
index 0000000..2d265e1
--- /dev/null
+++ b/res/drawable-xhdpi/ic_person_add_24dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/profile_ic_fab_yellow.png b/res/drawable-xhdpi/profile_ic_fab_yellow.png
new file mode 100644
index 0000000..a6e183b
--- /dev/null
+++ b/res/drawable-xhdpi/profile_ic_fab_yellow.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_person_add_24dp.png b/res/drawable-xxhdpi/ic_person_add_24dp.png
new file mode 100644
index 0000000..6091312
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_person_add_24dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/profile_ic_fab_yellow.png b/res/drawable-xxhdpi/profile_ic_fab_yellow.png
new file mode 100644
index 0000000..3e4b898
--- /dev/null
+++ b/res/drawable-xxhdpi/profile_ic_fab_yellow.png
Binary files differ
diff --git a/res/drawable/floating_action_button.xml b/res/drawable/floating_action_button.xml
new file mode 100644
index 0000000..96748e6
--- /dev/null
+++ b/res/drawable/floating_action_button.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 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.
+-->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:tint="@color/contacts_accent_color"
+ android:pinned="true">
+ <item android:drawable="@drawable/profile_ic_fab_yellow" />
+</ripple>
diff --git a/res/layout/people_activity.xml b/res/layout/people_activity.xml
index 589e4a9..bcdf08f 100644
--- a/res/layout/people_activity.xml
+++ b/res/layout/people_activity.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -42,4 +42,22 @@
android:layout_height="match_parent"
android:layout_width="match_parent" />
</FrameLayout>
-</FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/floating_action_button_container"
+ android:layout_width="@dimen/floating_action_button_width"
+ android:layout_height="@dimen/floating_action_button_height"
+ android:layout_marginRight="@dimen/floating_action_button_margin_right"
+ android:layout_marginBottom="@dimen/floating_action_button_margin_bottom"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentBottom="true">
+
+ <ImageButton
+ android:id="@+id/floating_action_button"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/floating_action_button"
+ android:contentDescription="@string/action_menu_add_new_contact_button"
+ android:src="@drawable/ic_person_add_24dp"/>
+ </FrameLayout>
+</RelativeLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 51dbd71..d1ea3b0 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -41,4 +41,6 @@
<!-- Color of the selected tab underline (overriding value in ContactsCommon) -->
<color name="tab_selected_color">#ffeeff41</color>
+ <color name="contacts_accent_color">#00acc1</color>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 305a648..f40dbb0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -644,4 +644,8 @@
<!-- Description when picture in the contact detail view is selected. [CHAR LIMIT=NONE] -->
<string name="contact_detail_picture_description">Picture. Select to change</string>
+
+ <!-- Content description for the button that adds a new contact
+ [CHAR LIMIT=NONE] -->
+ <string name="action_menu_add_new_contact_button">add new contact</string>
</resources>
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 0a49f4c..8a22b98 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -47,6 +47,7 @@
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageButton;
import android.widget.Toast;
import com.android.contacts.ContactSaveService;
@@ -82,6 +83,7 @@
import com.android.contacts.preference.ContactsPreferenceActivity;
import com.android.contacts.preference.DisplayOptionsPreferenceFragment;
import com.android.contacts.common.util.AccountFilterUtil;
+import com.android.contacts.common.util.ViewUtil;
import com.android.contacts.util.AccountPromptUtils;
import com.android.contacts.common.util.Constants;
import com.android.contacts.util.DialogManager;
@@ -98,10 +100,13 @@
* Displays a list to browse contacts. For xlarge screens, this also displays a detail-pane on
* the right.
*/
-public class PeopleActivity extends ContactsActivity
- implements View.OnCreateContextMenuListener, ActionBarAdapter.Listener,
+public class PeopleActivity extends ContactsActivity implements
+ View.OnCreateContextMenuListener,
+ View.OnClickListener,
+ ActionBarAdapter.Listener,
DialogManager.DialogShowingViewActivity,
- ContactListFilterController.ContactListFilterListener, ProviderStatusListener {
+ ContactListFilterController.ContactListFilterListener,
+ ProviderStatusListener {
private static final String TAG = "PeopleActivity";
@@ -150,6 +155,9 @@
private TransitionAnimationView mPeopleActivityView;
private TransitionAnimationView mContactDetailsView;
+ private View mFloatingActionButtonContainer;
+ private ImageButton mFloatingActionButton;
+
/** ViewPager for swipe, used only on the phone (i.e. one-pane mode) */
private ViewPager mTabPager;
private TabPagerAdapter mTabPagerAdapter;
@@ -422,6 +430,12 @@
mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar(), isUsingTwoPanes);
mActionBarAdapter.initialize(savedState, mRequest);
+ // Configure action button
+ mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
+ ViewUtil.setupFloatingActionButton(mFloatingActionButtonContainer, getResources());
+ mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
+ mFloatingActionButton.setOnClickListener(this);
+
invalidateOptionsMenuIfNeeded();
}
@@ -1582,4 +1596,20 @@
public ContactDetailFragment getDetailFragment() {
return mContactDetailFragment;
}
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.floating_action_button:
+ Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ intent.putExtras(extras);
+ }
+ startActivity(intent);
+ break;
+ default:
+ Log.wtf(TAG, "Unexpected onClick event from " + view);
+ }
+ }
}