1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.loaderapp;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.content.res.Configuration;
22 import android.os.Bundle;
23 
24 public final class FrontDoor extends Activity {
25     @Override
onCreate(Bundle savedState)26     public void onCreate(Bundle savedState) {
27         super.onCreate(savedState);
28 
29         Intent intent = getIntent();
30 
31         String componentName = intent.getComponent().getClassName();
32         if ("com.android.loaderapp.FrontDoorNormal".equals(componentName)) {
33             // The user clicked on the normal front door
34             startActivity(new Intent(this, HomeNormal.class));
35         } else if ("com.android.loaderapp.FrontDoorXLarge".equals(componentName)) {
36             // The user clicked on the large front door
37             startActivity(new Intent(this, HomeXLarge.class));
38         } else if ("com.android.loaderapp.FrontDoorGroupsXLarge".equals(componentName)) {
39             // The user clicked on the groups large front door
40             startActivity(new Intent(this, HomeGroupsXLarge.class));
41         } else {
42             // The user clicked on the config based front door
43             Configuration config = getResources().getConfiguration();
44             int screenLayoutSize = config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
45             if (screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
46                 startActivity(new Intent(this, HomeXLarge.class));
47             } else {
48                 // Default to the normal layout
49                 startActivity(new Intent(this, HomeNormal.class));
50             }
51         }
52 
53         finish();
54     }
55 }