diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d26868204..98ccf2a70 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -68,6 +68,7 @@ android:name="com.fsck.k9.activity.Accounts" android:launchMode="singleTask" android:configChanges="locale" + android:uiOptions="splitActionBarWhenNarrow" android:label="@string/app_name"> diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 5851e0e02..88ca74093 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -29,6 +29,8 @@ import android.util.Log; import android.util.SparseBooleanArray; import android.util.TypedValue; import android.view.ContextMenu; + +import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; import android.view.View; @@ -129,6 +131,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { private FontSizes mFontSizes = K9.getFontSizes(); private MenuItem mRefreshMenuItem; + private ActionBar mActionBar; + + private TextView mActionBarTitle; + private TextView mActionBarSubTitle; + private TextView mActionBarUnread; + /** * Contains information about objects that need to be retained on configuration changes. * @@ -141,9 +149,17 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { class AccountsHandler extends Handler { private void setViewTitle() { - String dispString = mListener.formatHeader(Accounts.this, getString(R.string.accounts_title), mUnreadMessageCount, getTimeFormat()); + mActionBarTitle.setText(" "+getString(R.string.accounts_title)); + mActionBarUnread.setText(String.valueOf(mUnreadMessageCount)); - setTitle(dispString); + String operation = mListener.getOperation(Accounts.this, getTimeFormat()); + operation.trim(); + if (operation.length() < 1) { + mActionBarSubTitle.setVisibility(View.GONE); + } else { + mActionBarSubTitle.setVisibility(View.VISIBLE); + mActionBarSubTitle.setText(operation); + } } public void refreshTitle() { runOnUiThread(new Runnable() { @@ -373,7 +389,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { } requestWindowFeature(Window.FEATURE_PROGRESS); - getSupportActionBar().setHomeButtonEnabled(false); + mActionBar = getSupportActionBar(); + initializeActionBar(); setContentView(R.layout.accounts); ListView listView = getListView(); listView.setOnItemClickListener(this); @@ -395,6 +412,18 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { } } + private void initializeActionBar() { + mActionBar.setDisplayShowCustomEnabled(true); + mActionBar.setCustomView(R.layout.actionbar_custom); + + View customView = mActionBar.getCustomView(); + mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first); + mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub); + mActionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count); + + mActionBar.setDisplayHomeAsUpEnabled(true); + } + /** * Creates and initializes the special accounts ('Unified Inbox' and 'All Messages') */ diff --git a/src/com/fsck/k9/activity/ActivityListener.java b/src/com/fsck/k9/activity/ActivityListener.java index 803158fc0..329a64677 100644 --- a/src/com/fsck/k9/activity/ActivityListener.java +++ b/src/com/fsck/k9/activity/ActivityListener.java @@ -23,6 +23,13 @@ public class ActivityListener extends MessagingListener { public String formatHeader(Context context, String activityPrefix, int unreadMessageCount, DateFormat timeFormat) { + String operation = getOperation(context, timeFormat); + return context.getString(R.string.activity_header_format, activityPrefix, + (unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""), + operation); + } + + public String getOperation(Context context, DateFormat timeFormat){ String operation = null; String progress = null; if (mLoadingAccountDescription != null @@ -66,11 +73,7 @@ public class ActivityListener extends MessagingListener { } } - return context.getString(R.string.activity_header_format, activityPrefix, - (unreadMessageCount > 0 ? context.getString(R.string.activity_unread_count, unreadMessageCount) : ""), - operation); - - + return operation; } public void informUserOfStatus() {