Make Welcome launch MessageListXL

Also added the "1 pane" activity to test the phone UI.

Change-Id: I1c86d2088a2298ada5028b7a266bd090b593593c
This commit is contained in:
Makoto Onuki 2010-08-04 15:38:25 -07:00
parent 6333e15108
commit 191448b430
5 changed files with 95 additions and 47 deletions

View File

@ -59,24 +59,12 @@
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:name="Email">
<activity
android:name=".activity.Welcome">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--
We show this on the home for the development purpose.
STOPSHIP: Remove label, and MAIN/LAUNCHER intent filter.
-->
<activity
android:name=".activity.MessageListXL"
android:label="@string/activity_label_2pane"
android:theme="@android:style/Theme.WithActionBar"
android:name=".activity.Welcome"
android:theme="@android:style/Theme.WithActionBar" >
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@ -180,10 +168,11 @@
<activity
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" />
</intent-filter>
</activity>
<activity
android:name=".activity.MessageListXL"
android:theme="@android:style/Theme.WithActionBar"
>
</activity>
<!--
@ -420,5 +409,29 @@
</provider>
<!--EXCHANGE-REMOVE-SECTION-END-->
<!--
STOPSHIP: These aliases are only for development. Remove them.
-->
<activity-alias
android:name="dev_one_pane"
android:label="@string/activity_label_1pane"
android:targetActivity=".activity.AccountFolderList"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="dev_two_pane"
android:label="@string/activity_label_2pane"
android:targetActivity=".activity.MessageListXL"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
</application>
</manifest>

View File

@ -717,5 +717,7 @@
<!-- Do Not Translate. STOPSHIP: Dev version only. Remove this. -->
<string name="activity_label_2pane">Email 2 Pane</string>
<!-- Do Not Translate. STOPSHIP: Dev version only. Remove this. -->
<string name="activity_label_1pane">Email 1 Pane</string>
</resources>

View File

@ -24,6 +24,7 @@ import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.Intent;
import android.content.Loader;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
@ -62,6 +63,10 @@ MessageListXLFragmentManager.TargetActivity {
private final MessageOrderManagerCallback mMessageOrderManagerCallback
= new MessageOrderManagerCallback();
public static void actionStart(Activity fromActivity) {
fromActivity.startActivity(new Intent(fromActivity, MessageListXL.class));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onCreate");

View File

@ -29,7 +29,9 @@ import android.accounts.AccountManager;
import android.accounts.OnAccountsUpdateListener;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@ -94,34 +96,7 @@ public class Welcome extends Activity {
// Run reconciliation to make sure we're up-to-date on account status
mAccountsUpdatedListener.onAccountsUpdated(null);
// Find out how many accounts we have, and if there's just one, go directly to it
Cursor c = null;
try {
c = getContentResolver().query(
EmailContent.Account.CONTENT_URI,
EmailContent.Account.ID_PROJECTION,
null, null, null);
switch (c.getCount()) {
case 0:
AccountSetupBasics.actionNewAccount(this);
break;
case 1:
c.moveToFirst();
long accountId = c.getLong(EmailContent.Account.CONTENT_ID_COLUMN);
MessageList.actionHandleAccount(this, accountId, Mailbox.TYPE_INBOX);
break;
default:
AccountFolderList.actionShowAccounts(this);
break;
}
} finally {
if (c != null) {
c.close();
}
}
// In all cases, do not return to this activity
finish();
new MainActivityLauncher(this).execute();
}
@Override
@ -144,4 +119,49 @@ public class Welcome extends Activity {
});
}
}
/**
* Open the Activity appropriate to the current configuration.
*
* - If there's 0 accounts, open AccountSetupBasics.
* - If it has XL screen, open MessageListXL.
* - If there's 1 account, open MessageList.
* - Otherwise open AccountFolderList.
*/
private static class MainActivityLauncher extends AsyncTask<Void, Void, Void> {
private final Activity mFromActivity;
public MainActivityLauncher(Activity fromActivity) {
mFromActivity = fromActivity;
}
@Override
protected Void doInBackground(Void... params) {
final int numAccount =
EmailContent.count(mFromActivity, EmailContent.Account.CONTENT_URI);
if (numAccount == 0) {
AccountSetupBasics.actionNewAccount(mFromActivity);
} else {
final int screenLayout = mFromActivity.getResources().getConfiguration()
.screenLayout;
if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_XLARGE) != 0) {
MessageListXL.actionStart(mFromActivity);
} else {
if (numAccount == 1) {
long accountId = EmailContent.Account.getDefaultAccountId(mFromActivity);
MessageList.actionHandleAccount(mFromActivity, accountId,
Mailbox.TYPE_INBOX);
} else {
AccountFolderList.actionShowAccounts(mFromActivity);
}
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
mFromActivity.finish();
}
}
}

View File

@ -145,6 +145,7 @@ public abstract class EmailContent {
/**
* Generic count method that can be used for any ContentProvider
*
* @param context the calling Context
* @param uri the Uri for the provider query
* @param selection as with a query call
@ -156,6 +157,13 @@ public abstract class EmailContent {
uri, COUNT_COLUMNS, selection, selectionArgs, null, 0, Long.valueOf(0)).intValue();
}
/**
* Same as {@link #count(Context, Uri, String, String[])} without selection.
*/
static public int count(Context context, Uri uri) {
return count(context, uri, null, null);
}
/**
* no public constructor since this is a utility class
*/