PeopleAndOptionsActivity.java revision 461a34b466cb4b13dbbc2ec6330b31e217b2ac4e
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.conversationsettings;
18
19import android.app.Fragment;
20import android.os.Bundle;
21import android.view.MenuItem;
22
23import com.android.messaging.R;
24import com.android.messaging.ui.BugleActionBarActivity;
25import com.android.messaging.ui.UIIntents;
26import com.android.messaging.util.Assert;
27
28/**
29 * Shows a list of participants in a conversation.
30 */
31public class PeopleAndOptionsActivity extends BugleActionBarActivity {
32
33    @Override
34    protected void onCreate(final Bundle savedInstanceState) {
35        super.onCreate(savedInstanceState);
36        setContentView(R.layout.people_and_options_activity);
37
38        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
39    }
40
41    @Override
42    public void onAttachFragment(final Fragment fragment) {
43        if (fragment instanceof PeopleAndOptionsFragment) {
44            final String conversationId =
45                    getIntent().getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID);
46            Assert.notNull(conversationId);
47            final PeopleAndOptionsFragment peopleAndOptionsFragment =
48                    (PeopleAndOptionsFragment) fragment;
49            peopleAndOptionsFragment.setConversationId(conversationId);
50        }
51    }
52
53    @Override
54    public boolean onOptionsItemSelected(final MenuItem item) {
55        switch (item.getItemId()) {
56            case android.R.id.home:
57                // Treat the home press as back press so that when we go back to
58                // ConversationActivity, it doesn't lose its original intent (conversation id etc.)
59                onBackPressed();
60                return true;
61
62            default:
63                return super.onOptionsItemSelected(item);
64        }
65    }
66}
67