1 /*
2  * Copyright (C) 2013 Google Inc.
3  * Licensed to The Android Open Source Project.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.android.mail.browse;
19 
20 import android.app.FragmentTransaction;
21 import android.content.Intent;
22 import android.os.Bundle;
23 
24 import com.android.mail.R;
25 import com.android.mail.analytics.Analytics;
26 import com.android.mail.ui.AccountFeedbackActivity;
27 import com.android.mail.utils.LogTag;
28 import com.android.mail.utils.LogUtils;
29 import com.android.mail.utils.MimeType;
30 
31 public class EmlViewerActivity extends AccountFeedbackActivity {
32     private static final String LOG_TAG = LogTag.getLogTag();
33 
34     private static final String FRAGMENT_TAG = "eml_message_fragment";
35 
36     @Override
onCreate(Bundle savedInstanceState)37     protected void onCreate(Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39 
40         final Intent intent = getIntent();
41         final String action = intent.getAction();
42         final String type = intent.getType();
43 
44         if (savedInstanceState == null) {
45             if (Intent.ACTION_VIEW.equals(action) &&
46                     MimeType.isEmlMimeType(type)) {
47                 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
48                 transaction.add(R.id.root, EmlMessageViewFragment.newInstance(
49                         intent.getData(), mAccountUri), FRAGMENT_TAG);
50                 transaction.commit();
51                 Analytics.getInstance().sendEvent("eml_viewer", null, null, 0);
52             } else {
53                 LogUtils.wtf(LOG_TAG,
54                         "Entered EmlViewerActivity with wrong intent action or type: %s, %s",
55                         action, type);
56                 finish(); // we should not be here. bail out. bail out.
57                 return;
58             }
59         }
60     }
61 }
62