MessageFileView.java revision b715ea1d768de273cc4bf0d6b052c61ee1245cba
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
17package com.android.email.activity;
18
19import com.android.email.Email;
20import com.android.email.R;
21
22import android.content.Intent;
23import android.net.Uri;
24import android.os.Bundle;
25import android.util.Log;
26
27/**
28 * Activity to show file-based messages.  (i.e. *.eml files, and possibly *.msg files).
29 *
30 * <p>This class has very limited feature set compared to {@link MessageView}, that is:
31 * <ul>
32 *   <li>No action buttons (can't reply, forward or delete)
33 *   <li>No favorite starring.
34 *   <li>No navigating around (no older/newer buttons)
35 * </ul>
36 *
37 * See {@link MessageViewBase} for the class relation diagram.
38 */
39public class MessageFileView extends MessageViewBase {
40    /**
41     * URI to the email (i.e. *.eml files, and possibly *.msg files) file that's being
42     */
43    private Uri mFileEmailUri;
44
45    private MessageFileViewFragment mFragment;
46
47    @Override
48    protected int getLayoutId() {
49        return R.layout.message_file_view;
50    }
51
52    @Override
53    public void onCreate(Bundle icicle) {
54        super.onCreate(icicle);
55
56        mFragment = (MessageFileViewFragment) getFragmentManager().findFragmentById(
57                R.id.message_file_view_fragment);
58        mFragment.setCallback(this);
59
60        Intent intent = getIntent();
61        mFileEmailUri = intent.getData();
62        if (mFileEmailUri == null) {
63            Log.w(Email.LOG_TAG, "Insufficient intent parameter.  Closing...");
64            finish();
65            return;
66        }
67
68        // TODO set title here: "Viewing XXX.eml".
69
70        // Load message.
71        getFragment().openMessage(mFileEmailUri);
72    }
73
74    @Override
75    public void onResume() {
76        super.onResume();
77    }
78
79    /** @return always -1, as no accounts are associated with EML files. */
80    @Override
81    protected long getAccountId() {
82        return -1;
83    }
84
85    // Note the return type is a subclass of that of the super class method.
86    @Override
87    protected MessageFileViewFragment getFragment() {
88        return mFragment;
89    }
90}
91