Further UI tweak of photo picker
- When photo picker is shown, the action bar title will be "Choose photo".
- Modified column width of GridView in photo picker to use entire screen
width.
- Changed the folder of all photos button to "all photos"
Bug: 24988706
Change-Id: Ia3e3ddf515c308e1cf6cdabc4c99fd7f9d983bc0
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 45ba4fa..7a51cb5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -815,10 +815,13 @@
<!-- Title of profile photos that are from your various accounts -->
<string name="from_your_accounts">From your accounts</string>
- <!-- Button used in photo picker to open camera -->
+ <!-- Button used in photo picker to open camera [CHAR LIMIT=30]-->
<string name="take_a_photo_button">Take a photo</string>
- <!-- Button used in photo picker to open photo/gallery -->
+ <!-- Button used in photo picker to open photo/gallery [CHAR LIMIT=20]-->
<string name="all_photos_button">All photos</string>
+ <!-- Title of photo picker [CHAR LIMIT=30]-->
+ <string name="photo_picker_title">Choose photo</string>
+
</resources>
diff --git a/src/com/android/contacts/activities/CompactContactEditorActivity.java b/src/com/android/contacts/activities/CompactContactEditorActivity.java
index 5e2fbff..0de20e7 100644
--- a/src/com/android/contacts/activities/CompactContactEditorActivity.java
+++ b/src/com/android/contacts/activities/CompactContactEditorActivity.java
@@ -43,6 +43,7 @@
private static final String STATE_PHOTO_MODE = "photo_mode";
private static final String STATE_IS_PHOTO_SELECTION = "is_photo_selection";
+ private static final String STATE_ACTION_BAR_TITLE = "action_bar_title";
/**
* Displays a PopupWindow with photo edit options.
@@ -145,6 +146,7 @@
// Restore state
mPhotoMode = savedState.getInt(STATE_PHOTO_MODE);
mIsPhotoSelection = savedState.getBoolean(STATE_IS_PHOTO_SELECTION);
+ mActionBarTitleResId = savedState.getInt(STATE_ACTION_BAR_TITLE);
// Show/hide the editor and photo selection fragments (w/o animations)
mFragment = (CompactContactEditorFragment) getFragmentManager()
@@ -154,8 +156,10 @@
final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
if (mIsPhotoSelection) {
fragmentTransaction.hide(getEditorFragment()).show(mPhotoSelectionFragment);
+ getActionBar().setTitle(getResources().getString(R.string.photo_picker_title));
} else {
fragmentTransaction.show(getEditorFragment()).hide(mPhotoSelectionFragment);
+ getActionBar().setTitle(getResources().getString(mActionBarTitleResId));
}
fragmentTransaction.commit();
}
@@ -172,8 +176,9 @@
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putInt(STATE_PHOTO_MODE, mPhotoMode);
+ outState.putInt(STATE_PHOTO_MODE, mPhotoMode);
outState.putBoolean(STATE_IS_PHOTO_SELECTION, mIsPhotoSelection);
+ outState.putInt(STATE_ACTION_BAR_TITLE, mActionBarTitleResId);
}
@Override
@@ -221,6 +226,7 @@
.hide(getEditorFragment())
.show(mPhotoSelectionFragment)
.commit();
+ getActionBar().setTitle(getResources().getString(R.string.photo_picker_title));
}
private void showEditorFragment() {
@@ -229,7 +235,7 @@
.hide(mPhotoSelectionFragment)
.show((CompactContactEditorFragment) mFragment)
.commit();
-
+ getActionBar().setTitle(getResources().getString(mActionBarTitleResId));
mIsPhotoSelection = false;
}
diff --git a/src/com/android/contacts/activities/ContactEditorBaseActivity.java b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
index a86196b..aaa04a4 100644
--- a/src/com/android/contacts/activities/ContactEditorBaseActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
@@ -67,6 +67,8 @@
public static final String ACTION_JOIN_COMPLETED = "joinCompleted";
public static final String ACTION_SAVE_COMPLETED = "saveCompleted";
+ protected int mActionBarTitleResId;
+
/**
* Contract for contact editors Fragments that are managed by this Activity.
*/
@@ -218,12 +220,11 @@
ActionBar actionBar = getActionBar();
if (actionBar != null) {
if (Intent.ACTION_EDIT.equals(action) || ACTION_EDIT.equals(action)) {
- actionBar.setTitle(getResources().getString(
- R.string.contact_editor_title_existing_contact));
+ mActionBarTitleResId = R.string.contact_editor_title_existing_contact;
} else {
- actionBar.setTitle(getResources().getString(
- R.string.contact_editor_title_new_contact));
+ mActionBarTitleResId = R.string.contact_editor_title_new_contact;
}
+ actionBar.setTitle(getResources().getString(mActionBarTitleResId));
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
diff --git a/src/com/android/contacts/detail/PhotoSelectionHandler.java b/src/com/android/contacts/detail/PhotoSelectionHandler.java
index 405bbfc..d2e5763 100644
--- a/src/com/android/contacts/detail/PhotoSelectionHandler.java
+++ b/src/com/android/contacts/detail/PhotoSelectionHandler.java
@@ -315,7 +315,7 @@
* Constructs an intent for picking a photo from Gallery, and returning the bitmap.
*/
private Intent getPhotoPickIntent(Uri outputUri) {
- final Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
+ final Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setType("image/*");
ContactPhotoUtils.addPhotoPickerExtras(intent, outputUri);
return intent;
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index 6c0ff85..0ca8d35 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -233,7 +233,7 @@
final ArrayList<CompactPhotoSelectionFragment.Photo> photos = getContent().getPhotos();
if (photos.size() > 1) {
// For aggregate contacts, the user may select a new super primary photo from among
- // the (non-default) raw contact photos, or source a new photo from the ActionBar
+ // the (non-default) raw contact photos, or source a new photo.
getEditorActivity().selectPhoto(photos, getPhotoMode());
return;
}
diff --git a/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java b/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java
index bd4016e..060d64d 100644
--- a/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java
+++ b/src/com/android/contacts/editor/CompactPhotoSelectionFragment.java
@@ -312,9 +312,8 @@
final int paddingWidth = (int) getResources().getDimension(R.dimen
.photo_picker_column_padding_width);
float density = getResources().getDisplayMetrics().density;
- float dpScreenWidth = outMetrics.widthPixels / density;
- float dpColumnWidth = (dpScreenWidth - paddingWidth * mNumberOfColumns) * density /
- mNumberOfColumns;
+ float dpColumnWidth = (outMetrics.widthPixels - paddingWidth * (mNumberOfColumns - 1) *
+ density) / mNumberOfColumns;
gridView.setColumnWidth((int) dpColumnWidth);
return view;