Use ActionBar in call log details activity.
This replaces the temporary mock that I added earlier on.
It also gives the action bar home button the correct semantics: it now
always goes to the call log, no matter from which context it had been
opened.
Bug: 5071264
Change-Id: I0324bb91bbd003b46574ec4e422eaed66fa176b3
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index d732d66..813ebb1 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -24,6 +24,7 @@
import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
+import android.app.ActionBar;
import android.app.FragmentManager;
import android.app.ListActivity;
import android.content.ContentResolver;
@@ -81,7 +82,6 @@
private CallTypeHelper mCallTypeHelper;
private PhoneNumberHelper mPhoneNumberHelper;
private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
- private View mHomeActionView;
private ImageView mMainActionView;
private ImageView mContactBackgroundView;
@@ -156,20 +156,12 @@
mStatusMessageView = findViewById(R.id.voicemail_status);
mStatusMessageText = (TextView) findViewById(R.id.voicemail_status_message);
mStatusMessageAction = (TextView) findViewById(R.id.voicemail_status_action);
- mHomeActionView = findViewById(R.id.action_bar_home);
mMainActionView = (ImageView) findViewById(R.id.main_action);
mContactBackgroundView = (ImageView) findViewById(R.id.contact_background);
mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this);
mContactPhotoManager = ContactPhotoManager.getInstance(this);
getListView().setOnItemClickListener(this);
- mHomeActionView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // We want this to start the call log if this activity was not started from the
- // call log itself.
- CallDetailActivity.this.finish();
- }
- });
+ configureActionBar();
}
@Override
@@ -654,8 +646,32 @@
new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
return true;
+ case android.R.id.home: {
+ onHomeSelected();
+ return true;
+ }
+
default:
throw new IllegalArgumentException();
}
}
+
+ 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.setIcon(R.drawable.ic_ab_dialer_holo_dark);
+ }
+ }
+
+ /** Invoked when the user presses the home button in the action bar. */
+ private void onHomeSelected() {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Calls.CONTENT_URI);
+ // This will open the call log even if the detail view has been opened directly.
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ finish();
+ }
}