Email: husky title for MessageList & MailboxList.
Bug: 2419716
This commit is contained in:
parent
842ac04828
commit
b052885ea3
|
@ -148,11 +148,13 @@
|
|||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.MailboxList">
|
||||
android:name=".activity.MailboxList"
|
||||
android:theme="@style/ThemeNoTitleBar">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.MessageList">
|
||||
android:name=".activity.MessageList"
|
||||
android:theme="@style/ThemeNoTitleBar">
|
||||
<intent-filter>
|
||||
<!-- This action is only to allow an entry point for launcher shortcuts -->
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 752 B |
Binary file not shown.
After Width: | Height: | Size: 775 B |
Binary file not shown.
After Width: | Height: | Size: 775 B |
Binary file not shown.
After Width: | Height: | Size: 725 B |
Binary file not shown.
After Width: | Height: | Size: 749 B |
Binary file not shown.
After Width: | Height: | Size: 749 B |
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_window_focused="false" android:state_enabled="true"
|
||||
android:drawable="@drawable/one_pixel_border" />
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/one_pixel_border_pressed" />
|
||||
<item android:state_focused="true" android:state_enabled="true"
|
||||
android:drawable="@drawable/one_pixel_border_selected" />
|
||||
<item android:state_enabled="true"
|
||||
android:drawable="@drawable/one_pixel_border" />
|
||||
</selector>
|
|
@ -19,8 +19,9 @@
|
|||
android:id="@+id/screen"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical">
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@android:drawable/title_bar">
|
||||
|
||||
<TextView android:id="@+id/title_left_text"
|
||||
android:gravity="center_vertical|left"
|
||||
|
@ -43,6 +44,19 @@
|
|||
android:shadowColor="#ff000000"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button android:id="@+id/account_title_button"
|
||||
android:gravity="center_vertical|right"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="26dip"
|
||||
android:textColor="#ffffffff"
|
||||
android:layout_margin="3dip"
|
||||
android:paddingTop="0dip"
|
||||
android:paddingBottom="0dip"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="10dip"
|
||||
android:background="@drawable/one_pixel_border_button" />
|
||||
|
||||
<ProgressBar android:id="@+id/title_progress_icon"
|
||||
style="?android:attr/progressBarStyleSmallTitle"
|
||||
android:visibility="gone"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/list_title" />
|
||||
<include layout="@layout/connection_error_banner" />
|
||||
|
||||
<ListView
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/list_title" />
|
||||
<include layout="@layout/connection_error_banner" />
|
||||
|
||||
<ListView
|
||||
|
|
|
@ -28,4 +28,9 @@
|
|||
<item name="android:maxWidth">48dip</item>
|
||||
<item name="android:gravity">center_horizontal|center_vertical</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeNoTitleBar" parent="android:Theme.NoTitleBar">
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.android.email.provider.EmailContent.MailboxColumns;
|
|||
import com.android.email.provider.EmailContent.Message;
|
||||
import com.android.email.provider.EmailContent.MessageColumns;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListActivity;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
|
@ -47,11 +48,13 @@ import android.view.LayoutInflater;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CursorAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
|
@ -59,7 +62,7 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
public class MailboxList extends ListActivity implements OnItemClickListener {
|
||||
public class MailboxList extends ListActivity implements OnItemClickListener, OnClickListener {
|
||||
|
||||
// Intent extras (internal to this activity)
|
||||
private static final String EXTRA_ACCOUNT_ID = "com.android.email.activity._ACCOUNT_ID";
|
||||
|
@ -82,7 +85,7 @@ public class MailboxList extends ListActivity implements OnItemClickListener {
|
|||
// DB access
|
||||
private long mAccountId;
|
||||
private LoadMailboxesTask mLoadMailboxesTask;
|
||||
private AsyncTask<Void, Void, String> mLoadAccountNameTask;
|
||||
private AsyncTask<Void, Void, Object[]> mLoadAccountNameTask;
|
||||
private MessageCountTask mMessageCountTask;
|
||||
|
||||
private long mDraftMailboxKey = -1;
|
||||
|
@ -106,11 +109,7 @@ public class MailboxList extends ListActivity implements OnItemClickListener {
|
|||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
|
||||
setContentView(R.layout.mailbox_list);
|
||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
|
||||
R.layout.list_title);
|
||||
|
||||
mListView = getListView();
|
||||
mProgressIcon = (ProgressBar) findViewById(R.id.title_progress_icon);
|
||||
|
@ -123,6 +122,8 @@ public class MailboxList extends ListActivity implements OnItemClickListener {
|
|||
mListAdapter = new MailboxListAdapter(this);
|
||||
setListAdapter(mListAdapter);
|
||||
|
||||
((Button) findViewById(R.id.account_title_button)).setOnClickListener(this);
|
||||
|
||||
mAccountId = getIntent().getLongExtra(EXTRA_ACCOUNT_ID, -1);
|
||||
if (mAccountId != -1) {
|
||||
mLoadMailboxesTask = new LoadMailboxesTask(mAccountId);
|
||||
|
@ -134,37 +135,38 @@ public class MailboxList extends ListActivity implements OnItemClickListener {
|
|||
((TextView)findViewById(R.id.title_left_text)).setText(R.string.mailbox_list_title);
|
||||
|
||||
// Go to the database for the account name
|
||||
mLoadAccountNameTask = new AsyncTask<Void, Void, String>() {
|
||||
mLoadAccountNameTask = new AsyncTask<Void, Void, Object[]>() {
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
String result = null;
|
||||
protected Object[] doInBackground(Void... params) {
|
||||
String accountName = null;
|
||||
Uri uri = ContentUris.withAppendedId(Account.CONTENT_URI, mAccountId);
|
||||
Cursor c = MailboxList.this.getContentResolver().query(
|
||||
uri, new String[] { AccountColumns.DISPLAY_NAME }, null, null, null);
|
||||
try {
|
||||
if (c.moveToFirst()) {
|
||||
result = c.getString(0);
|
||||
accountName = c.getString(0);
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
return result;
|
||||
int nAccounts = EmailContent.count(MailboxList.this, Account.CONTENT_URI, null, null);
|
||||
return new Object[] {accountName, nAccounts};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
/* doInBackground() returns null if the account name can't be retrieved from DB.
|
||||
* so we can't use null test for cancellation, instead use isCancelled().
|
||||
*/
|
||||
if (isCancelled()) {
|
||||
protected void onPostExecute(Object[] result) {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
// result is null if account name can't be retrieved or query exception
|
||||
if (result == null) {
|
||||
final String accountName = (String) result[0];
|
||||
// accountName is null if account name can't be retrieved or query exception
|
||||
if (accountName == null) {
|
||||
// something is wrong with this account
|
||||
finish();
|
||||
}
|
||||
((TextView)findViewById(R.id.title_right_text)).setText(result);
|
||||
|
||||
final int nAccounts = (Integer) result[1];
|
||||
setTitleAccountName(accountName, nAccounts > 1);
|
||||
}
|
||||
|
||||
}.execute();
|
||||
|
@ -206,6 +208,14 @@ public class MailboxList extends ListActivity implements OnItemClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.account_title_button:
|
||||
onAccounts();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
onOpenMailbox(id);
|
||||
}
|
||||
|
@ -299,6 +309,20 @@ public class MailboxList extends ListActivity implements OnItemClickListener {
|
|||
MessageCompose.actionCompose(this, mAccountId);
|
||||
}
|
||||
|
||||
private void setTitleAccountName(String accountName, boolean showAccountsButton) {
|
||||
TextView accountsButton = (TextView) findViewById(R.id.account_title_button);
|
||||
TextView textPlain = (TextView) findViewById(R.id.title_right_text);
|
||||
if (showAccountsButton) {
|
||||
accountsButton.setVisibility(View.VISIBLE);
|
||||
textPlain.setVisibility(View.GONE);
|
||||
accountsButton.setText(accountName);
|
||||
} else {
|
||||
accountsButton.setVisibility(View.GONE);
|
||||
textPlain.setVisibility(View.VISIBLE);
|
||||
textPlain.setText(accountName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Async task for loading the mailboxes for a given account
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.android.email.provider.EmailContent.MailboxColumns;
|
|||
import com.android.email.provider.EmailContent.MessageColumns;
|
||||
import com.android.email.service.MailService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListActivity;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ContentResolver;
|
||||
|
@ -111,7 +112,6 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
private Controller mController = Controller.getInstance(getApplication());
|
||||
private ControllerResults mControllerCallback = new ControllerResults();
|
||||
private TextView mLeftTitle;
|
||||
private TextView mRightTitle;
|
||||
private ProgressBar mProgressIcon;
|
||||
|
||||
// DB access
|
||||
|
@ -220,11 +220,7 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
|
||||
setContentView(R.layout.message_list);
|
||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
|
||||
R.layout.list_title);
|
||||
|
||||
mCanAutoRefresh = true;
|
||||
mListView = getListView();
|
||||
|
@ -233,13 +229,13 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
mFavoriteButton = (Button) findViewById(R.id.btn_multi_favorite);
|
||||
mDeleteButton = (Button) findViewById(R.id.btn_multi_delete);
|
||||
mLeftTitle = (TextView) findViewById(R.id.title_left_text);
|
||||
mRightTitle = (TextView) findViewById(R.id.title_right_text);
|
||||
mProgressIcon = (ProgressBar) findViewById(R.id.title_progress_icon);
|
||||
mErrorBanner = (TextView) findViewById(R.id.connection_error_text);
|
||||
|
||||
mReadUnreadButton.setOnClickListener(this);
|
||||
mFavoriteButton.setOnClickListener(this);
|
||||
mDeleteButton.setOnClickListener(this);
|
||||
((Button) findViewById(R.id.account_title_button)).setOnClickListener(this);
|
||||
|
||||
mListView.setOnItemClickListener(this);
|
||||
mListView.setItemsCanFocus(false);
|
||||
|
@ -403,6 +399,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
case R.id.btn_multi_delete:
|
||||
onMultiDelete(mListAdapter.getSelectedSet());
|
||||
break;
|
||||
case R.id.account_title_button:
|
||||
onAccounts();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1113,7 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
}
|
||||
}
|
||||
|
||||
private class SetTitleTask extends AsyncTask<Void, Void, String[]> {
|
||||
private class SetTitleTask extends AsyncTask<Void, Void, Object[]> {
|
||||
|
||||
private long mMailboxKey;
|
||||
|
||||
|
@ -1123,21 +1122,22 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String[] doInBackground(Void... params) {
|
||||
protected Object[] doInBackground(Void... params) {
|
||||
// Check special Mailboxes
|
||||
int resIdSpecialMailbox = 0;
|
||||
if (mMailboxKey == Mailbox.QUERY_ALL_INBOXES) {
|
||||
return new String[] {null,
|
||||
getString(R.string.account_folder_list_summary_inbox)};
|
||||
resIdSpecialMailbox = R.string.account_folder_list_summary_inbox;
|
||||
} else if (mMailboxKey == Mailbox.QUERY_ALL_FAVORITES) {
|
||||
return new String[] {null,
|
||||
getString(R.string.account_folder_list_summary_starred)};
|
||||
resIdSpecialMailbox = R.string.account_folder_list_summary_starred;
|
||||
} else if (mMailboxKey == Mailbox.QUERY_ALL_DRAFTS) {
|
||||
return new String[] {null,
|
||||
getString(R.string.account_folder_list_summary_drafts)};
|
||||
resIdSpecialMailbox = R.string.account_folder_list_summary_drafts;
|
||||
} else if (mMailboxKey == Mailbox.QUERY_ALL_OUTBOX) {
|
||||
return new String[] {null,
|
||||
getString(R.string.account_folder_list_summary_outbox)};
|
||||
resIdSpecialMailbox = R.string.account_folder_list_summary_outbox;
|
||||
}
|
||||
if (resIdSpecialMailbox != 0) {
|
||||
return new Object[] {null, getString(resIdSpecialMailbox), 0};
|
||||
}
|
||||
|
||||
String accountName = null;
|
||||
String mailboxName = null;
|
||||
String accountKey = null;
|
||||
|
@ -1168,23 +1168,41 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
|
|||
c.close();
|
||||
}
|
||||
}
|
||||
return new String[] {accountName, mailboxName};
|
||||
int nAccounts = EmailContent.count(MessageList.this, Account.CONTENT_URI, null, null);
|
||||
return new Object[] {accountName, mailboxName, nAccounts};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String[] names) {
|
||||
if (names == null) {
|
||||
protected void onPostExecute(Object[] result) {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
if (names[0] != null) {
|
||||
mRightTitle.setText(names[0]);
|
||||
|
||||
final int nAccounts = (Integer) result[2];
|
||||
if (result[0] != null) {
|
||||
setTitleAccountName((String) result[0], nAccounts > 1);
|
||||
}
|
||||
if (names[1] != null) {
|
||||
mLeftTitle.setText(names[1]);
|
||||
|
||||
if (result[1] != null) {
|
||||
mLeftTitle.setText((String) result[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setTitleAccountName(String accountName, boolean showAccountsButton) {
|
||||
TextView accountsButton = (TextView) findViewById(R.id.account_title_button);
|
||||
TextView textPlain = (TextView) findViewById(R.id.title_right_text);
|
||||
if (showAccountsButton) {
|
||||
accountsButton.setVisibility(View.VISIBLE);
|
||||
textPlain.setVisibility(View.GONE);
|
||||
accountsButton.setText(accountName);
|
||||
} else {
|
||||
accountsButton.setVisibility(View.GONE);
|
||||
textPlain.setVisibility(View.VISIBLE);
|
||||
textPlain.setText(accountName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for UI-thread operations (when called from callbacks or any other threads)
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue