1/*
2 * Copyright (C) 2015 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.messaging.ui.attachmentchooser;
18
19import android.app.Fragment;
20import android.os.Bundle;
21
22import com.android.messaging.R;
23import com.android.messaging.ui.BugleActionBarActivity;
24import com.android.messaging.ui.UIIntents;
25import com.android.messaging.ui.attachmentchooser.AttachmentChooserFragment.AttachmentChooserFragmentHost;
26import com.android.messaging.util.Assert;
27
28public class AttachmentChooserActivity extends BugleActionBarActivity implements
29        AttachmentChooserFragmentHost {
30
31    @Override
32    protected void onCreate(final Bundle savedInstanceState) {
33        super.onCreate(savedInstanceState);
34        setContentView(R.layout.attachment_chooser_activity);
35        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
36    }
37
38    @Override
39    public void onAttachFragment(final Fragment fragment) {
40        if (fragment instanceof AttachmentChooserFragment) {
41            final String conversationId =
42                    getIntent().getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID);
43            Assert.notNull(conversationId);
44            final AttachmentChooserFragment chooserFragment =
45                    (AttachmentChooserFragment) fragment;
46            chooserFragment.setConversationId(conversationId);
47            chooserFragment.setHost(this);
48        }
49    }
50
51    @Override
52    public void onConfirmSelection() {
53        setResult(RESULT_OK);
54        finish();
55    }
56}
57