Add the ActionBar trash and share icons.
- Adds the share drawable against dark background from ux repos.
- Removes the trash button from the main voicemail ui.
- Adds both trash and share to the ActionBar top right corner of call
details, but only if we are looking at a voicemail.
- Adds placeholder methods for when these buttons get clicked.
- Changes other options menu elements to use the android:onClick
property with a well-named method, rather than using switch by id.
Other changes:
- Tells proguard not to remove android:onClick style methods where those
methods are public void and take a MenuItem or View single argument
(exactly the type specified in xml files).
- Remove android:showAsAction property on the call detail options,
because I don't think we want them to appear on the ActionBar at all,
and if we did these are the wrong properties to use.
- Remove the variable storing the 'has remove from call log', we can
just calculate that in onPrepareOptionsMenu.
- Calls through to super.onCreateOptionsMenu and
super.onPrepareOptionsMenu rather than just returning true, as
requested in the javadoc.
Bug: 5070929
Change-Id: I237bdcbb7b0a5135e940a0f44a64e4a39f741fa6
diff --git a/proguard.flags b/proguard.flags
index 577144b..5a08b9f 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -2,6 +2,13 @@
public <init>(...);
}
+# Xml files containing onClick (menus and layouts) require that proguard not
+# remove their handlers.
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+ public void *(android.view.MenuItem);
+}
+
# TODO: Instead of keeping the following two functions we could as well just remove them completely
# as they are only used in test code
@@ -16,4 +23,4 @@
# Any methods whose name is '*ForTest' are preserved.
-keep class ** {
*** *ForTest(...);
-}
\ No newline at end of file
+}
diff --git a/res/drawable-hdpi/ic_share_holo_dark.png b/res/drawable-hdpi/ic_share_holo_dark.png
new file mode 100644
index 0000000..686da4c
--- /dev/null
+++ b/res/drawable-hdpi/ic_share_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_share_holo_dark.png b/res/drawable-mdpi/ic_share_holo_dark.png
new file mode 100644
index 0000000..5c33eac
--- /dev/null
+++ b/res/drawable-mdpi/ic_share_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_share_holo_dark.png b/res/drawable-xhdpi/ic_share_holo_dark.png
new file mode 100644
index 0000000..b3e2f80
--- /dev/null
+++ b/res/drawable-xhdpi/ic_share_holo_dark.png
Binary files differ
diff --git a/res/layout/playback_layout.xml b/res/layout/playback_layout.xml
index 1fb36be..020c017 100644
--- a/res/layout/playback_layout.xml
+++ b/res/layout/playback_layout.xml
@@ -40,18 +40,6 @@
android:src="@drawable/ic_hold_pause_holo_dark"
android:layout_weight="1"
/>
- <ImageButton
- android:id="@+id/playback_trash"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="5px"
- android:layout_marginTop="4dip"
- android:layout_marginLeft="4dip"
- android:layout_marginRight="4dip"
- android:background="@drawable/dialpad_background"
- android:src="@drawable/ic_trash_holo_dark"
- android:layout_weight="1"
- />
</LinearLayout>
<SeekBar
android:id="@+id/playback_seek"
diff --git a/res/menu/call_details_options.xml b/res/menu/call_details_options.xml
index 68e265c..0db32a4 100644
--- a/res/menu/call_details_options.xml
+++ b/res/menu/call_details_options.xml
@@ -15,15 +15,26 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
- android:id="@+id/remove_from_call_log"
+ android:id="@+id/menu_share_voicemail"
+ android:icon="@drawable/ic_share_holo_dark"
+ android:showAsAction="ifRoom"
+ android:onClick="onMenuShareVoicemail"
+ />
+ <item
+ android:id="@+id/menu_trash"
+ android:icon="@drawable/ic_trash_holo_dark"
+ android:showAsAction="ifRoom"
+ android:onClick="onMenuTrashVoicemail"
+ />
+ <item
+ android:id="@+id/menu_remove_from_call_log"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="@string/recentCalls_removeFromRecentList"
- android:showAsAction="withText"
+ android:onClick="onMenuRemoveFromCallLog"
/>
-
<item
- android:id="@+id/edit_number_before_call"
+ android:id="@+id/menu_edit_number_before_call"
android:title="@string/recentCalls_editNumberBeforeCall"
- android:showAsAction="withText"
+ android:onClick="onMenuEditNumberBeforeCall"
/>
</menu>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6bc5582..9fd4cb0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -58,7 +58,7 @@
<item name="favorites_padding_bottom">?android:attr/actionBarSize</item>
</style>
- <style name="CallDetailActivityTheme" parent="android:Theme.Holo.SplitActionBarWhenNarrow">
+ <style name="CallDetailActivityTheme" parent="android:Theme.Holo">
<item name="android:windowBackground">@android:color/black</item>
<item name="android:gravity">top</item>
<item name="call_detail_transparent_background">#CC000000</item>
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index e9a693e..3fdfe38 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -100,8 +100,6 @@
private TextView mStatusMessageText;
private TextView mStatusMessageAction;
- /** Whether we should show "remove from call log" in the options menu. */
- private boolean mHasRemoveFromCallLog;
/** Whether we should show "edit number before call" in the options menu. */
private boolean mHasEditNumberBeforeCall;
@@ -348,9 +346,6 @@
getString(R.string.menu_sendTextMessage), smsIntent));
}
- // This action deletes all elements in the group from the call log.
- // We don't have this action for voicemails, because you can just use the trash button.
- mHasRemoveFromCallLog = !hasVoicemail();
mHasEditNumberBeforeCall = canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
if (actions.size() != 0) {
@@ -609,58 +604,65 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.call_details_options, menu);
- return true;
+ return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// This action deletes all elements in the group from the call log.
// We don't have this action for voicemails, because you can just use the trash button.
- menu.findItem(R.id.remove_from_call_log).setVisible(mHasRemoveFromCallLog);
- menu.findItem(R.id.edit_number_before_call).setVisible(mHasEditNumberBeforeCall);
- return mHasRemoveFromCallLog || mHasEditNumberBeforeCall;
+ menu.findItem(R.id.menu_remove_from_call_log).setVisible(!hasVoicemail());
+ menu.findItem(R.id.menu_edit_number_before_call).setVisible(mHasEditNumberBeforeCall);
+ menu.findItem(R.id.menu_trash).setVisible(hasVoicemail());
+ menu.findItem(R.id.menu_share_voicemail).setVisible(hasVoicemail());
+ return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
- case R.id.remove_from_call_log: {
- StringBuilder callIds = new StringBuilder();
- for (Uri callUri : getCallLogEntryUris()) {
- if (callIds.length() != 0) {
- callIds.append(",");
- }
- callIds.append(ContentUris.parseId(callUri));
- }
-
- getContentResolver().delete(Calls.CONTENT_URI_WITH_VOICEMAIL,
- Calls._ID + " IN (" + callIds + ")", null);
- // Also close the activity.
- finish();
- return true;
- }
-
- case R.id.edit_number_before_call:
- startActivity(
- new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
- return true;
-
case android.R.id.home: {
onHomeSelected();
return true;
}
+ // All the options menu items are handled by onMenu... methods.
default:
throw new IllegalArgumentException();
}
}
+ public void onMenuRemoveFromCallLog(MenuItem menuItem) {
+ StringBuilder callIds = new StringBuilder();
+ for (Uri callUri : getCallLogEntryUris()) {
+ if (callIds.length() != 0) {
+ callIds.append(",");
+ }
+ callIds.append(ContentUris.parseId(callUri));
+ }
+
+ getContentResolver().delete(Calls.CONTENT_URI_WITH_VOICEMAIL,
+ Calls._ID + " IN (" + callIds + ")", null);
+ // Also close the activity.
+ finish();
+ }
+
+ public void onMenuEditNumberBeforeCall(MenuItem menuItem) {
+ startActivity(new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
+ }
+
+ public void onMenuShareVoicemail(MenuItem menuItem) {
+ Log.w(TAG, "onMenuShareVoicemail not yet implemented");
+ }
+
+ public void onMenuTrashVoicemail(MenuItem menuItem) {
+ Log.w(TAG, "onMenuTrashVoicemail not yet implemented");
+ }
+
private void configureActionBar() {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
- actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME,
- ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE
- | ActionBar.DISPLAY_SHOW_HOME);
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
actionBar.setIcon(R.drawable.ic_ab_dialer_holo_dark);
}
}
diff --git a/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java b/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java
index edc1bb4..d306209 100644
--- a/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java
+++ b/src/com/android/contacts/voicemail/VoicemailPlaybackFragment.java
@@ -66,7 +66,6 @@
private SeekBar mPlaybackSeek;
private ImageButton mStartStopButton;
private ImageButton mPlaybackSpeakerphone;
- private ImageButton mPlaybackTrashButton;
private TextView mPlaybackPositionText;
private ImageButton mRateDecreaseButton;
private ImageButton mRateIncreaseButton;
@@ -80,7 +79,6 @@
mPlaybackSeek = (SeekBar) view.findViewById(R.id.playback_seek);
mStartStopButton = (ImageButton) view.findViewById(R.id.playback_start_stop);
mPlaybackSpeakerphone = (ImageButton) view.findViewById(R.id.playback_speakerphone);
- mPlaybackTrashButton = (ImageButton) view.findViewById(R.id.playback_trash);
mPlaybackPositionText = (TextView) view.findViewById(R.id.playback_position_text);
mRateDecreaseButton = (ImageButton) view.findViewById(R.id.rate_decrease_button);
mRateIncreaseButton = (ImageButton) view.findViewById(R.id.rate_increase_button);
@@ -188,11 +186,6 @@
}
@Override
- public void setDeleteButtonListener(View.OnClickListener listener) {
- mPlaybackTrashButton.setOnClickListener(listener);
- }
-
- @Override
public void setPositionSeekListener(SeekBar.OnSeekBarChangeListener listener) {
mPlaybackSeek.setOnSeekBarChangeListener(listener);
}
diff --git a/src/com/android/contacts/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/contacts/voicemail/VoicemailPlaybackPresenter.java
index 0e7470a..eac502d 100644
--- a/src/com/android/contacts/voicemail/VoicemailPlaybackPresenter.java
+++ b/src/com/android/contacts/voicemail/VoicemailPlaybackPresenter.java
@@ -56,7 +56,6 @@
void setStartStopListener(View.OnClickListener listener);
void setPositionSeekListener(SeekBar.OnSeekBarChangeListener listener);
void setSpeakerphoneListener(View.OnClickListener listener);
- void setDeleteButtonListener(View.OnClickListener listener);
void setClipPosition(int clipPositionInMillis, int clipLengthInMillis);
int getDesiredClipPosition();
void playbackStarted();
@@ -138,7 +137,6 @@
mView.setPositionSeekListener(new PlaybackPositionListener());
mView.setStartStopListener(new StartStopButtonListener());
mView.setSpeakerphoneListener(new SpeakerphoneListener());
- mView.setDeleteButtonListener(new DeleteButtonListener());
mPlayer.setOnErrorListener(new MediaPlayerErrorListener());
mPlayer.setOnCompletionListener(new MediaPlayerCompletionListener());
mView.setSpeakerPhoneOn(mView.isSpeakerPhoneOn());
@@ -303,15 +301,6 @@
}
}
- private class DeleteButtonListener implements View.OnClickListener {
- @Override
- public void onClick(View v) {
- // TODO: Temporarily removed this whilst the team discuss the merits of porting
- // the VoicemailHelper class across vs just hard-coding the delete via cursor.
- mView.finish();
- }
- }
-
private class StartStopButtonListener implements View.OnClickListener {
@Override
public void onClick(View arg0) {
diff --git a/tests/src/com/android/contacts/CallDetailActivityTest.java b/tests/src/com/android/contacts/CallDetailActivityTest.java
index c1efa3f..cdb6e44 100644
--- a/tests/src/com/android/contacts/CallDetailActivityTest.java
+++ b/tests/src/com/android/contacts/CallDetailActivityTest.java
@@ -103,7 +103,7 @@
Menu menu = new ContextMenuBuilder(activity);
activity.onCreateOptionsMenu(menu);
activity.onPrepareOptionsMenu(menu);
- assertFalse(menu.findItem(R.id.remove_from_call_log).isVisible());
+ assertFalse(menu.findItem(R.id.menu_remove_from_call_log).isVisible());
}
/** Test to check that I haven't broken the remove-from-call-log entry from regular calls. */
@@ -113,7 +113,7 @@
Menu menu = new ContextMenuBuilder(activity);
activity.onCreateOptionsMenu(menu);
activity.onPrepareOptionsMenu(menu);
- assertTrue(menu.findItem(R.id.remove_from_call_log).isVisible());
+ assertTrue(menu.findItem(R.id.menu_remove_from_call_log).isVisible());
}
/**