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 package com.android.messaging.ui.conversationlist;
17 
18 import android.graphics.drawable.ColorDrawable;
19 import android.os.Bundle;
20 import androidx.appcompat.app.ActionBar;
21 import android.view.Menu;
22 import android.view.MenuItem;
23 
24 import com.android.messaging.R;
25 import com.android.messaging.util.DebugUtils;
26 
27 public class ArchivedConversationListActivity extends AbstractConversationListActivity {
28 
29     @Override
onCreate(final Bundle savedInstanceState)30     protected void onCreate(final Bundle savedInstanceState) {
31         super.onCreate(savedInstanceState);
32 
33         final ConversationListFragment fragment =
34                 ConversationListFragment.createArchivedConversationListFragment();
35         getFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
36         invalidateActionBar();
37     }
38 
updateActionBar(ActionBar actionBar)39     protected void updateActionBar(ActionBar actionBar) {
40         actionBar.setTitle(getString(R.string.archived_activity_title));
41         actionBar.setDisplayShowTitleEnabled(true);
42         actionBar.setDisplayHomeAsUpEnabled(true);
43         actionBar.setBackgroundDrawable(new ColorDrawable(
44                 getResources().getColor(
45                         R.color.archived_conversation_action_bar_background_color_dark)));
46         actionBar.show();
47         super.updateActionBar(actionBar);
48     }
49 
50     @Override
onBackPressed()51     public void onBackPressed() {
52         if (isInConversationListSelectMode()) {
53             exitMultiSelectState();
54         } else {
55             super.onBackPressed();
56         }
57     }
58 
59     @Override
onCreateOptionsMenu(Menu menu)60     public boolean onCreateOptionsMenu(Menu menu) {
61         if (super.onCreateOptionsMenu(menu)) {
62             return true;
63         }
64         getMenuInflater().inflate(R.menu.archived_conversation_list_menu, menu);
65         final MenuItem item = menu.findItem(R.id.action_debug_options);
66         if (item != null) {
67             final boolean enableDebugItems = DebugUtils.isDebugEnabled();
68             item.setVisible(enableDebugItems).setEnabled(enableDebugItems);
69         }
70         return true;
71     }
72 
73     @Override
onOptionsItemSelected(MenuItem menuItem)74     public boolean onOptionsItemSelected(MenuItem menuItem) {
75         switch(menuItem.getItemId()) {
76             case R.id.action_debug_options:
77                 onActionBarDebug();
78                 return true;
79             case android.R.id.home:
80                 onActionBarHome();
81                 return true;
82             default:
83                 return super.onOptionsItemSelected(menuItem);
84         }
85     }
86 
87     @Override
onActionBarHome()88     public void onActionBarHome() {
89         onBackPressed();
90     }
91 
92     @Override
isSwipeAnimatable()93     public boolean isSwipeAnimatable() {
94         return false;
95     }
96 }
97