1 /*
2  * Copyright (C) 2018 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 
17 package com.android.dialer.app;
18 
19 import android.content.ComponentName;
20 import android.content.Context;
21 import android.content.Intent;
22 
23 /**
24  * Main activity intents.
25  *
26  * <p>TODO(calderwoodra): Move this elsewhere.
27  */
28 public class MainComponent {
29 
30   public static final String EXTRA_CLEAR_NEW_VOICEMAILS = "EXTRA_CLEAR_NEW_VOICEMAILS";
31 
32   /**
33    * @param context Context of the application package implementing MainActivity class.
34    * @return intent for MainActivity.class
35    */
getIntent(Context context)36   public static Intent getIntent(Context context) {
37     Intent intent = new Intent();
38     intent.setComponent(new ComponentName(context, getComponentName()));
39     intent.setAction(Intent.ACTION_VIEW);
40     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
41     return intent;
42   }
43 
getShowCallLogIntent(Context context)44   public static Intent getShowCallLogIntent(Context context) {
45     Intent intent = new Intent();
46     intent.setComponent(new ComponentName(context, getComponentName()));
47     intent.setAction("ACTION_SHOW_TAB");
48     intent.putExtra("EXTRA_SHOW_TAB", 1);
49     return intent;
50   }
51 
getShowVoicemailIntent(Context context)52   public static Intent getShowVoicemailIntent(Context context) {
53     Intent intent = new Intent();
54     intent.setComponent(new ComponentName(context, getComponentName()));
55     intent.setAction("ACTION_SHOW_TAB");
56     intent.putExtra("EXTRA_SHOW_TAB", 3);
57     intent.putExtra(EXTRA_CLEAR_NEW_VOICEMAILS, true);
58     return intent;
59   }
60 
getComponentName()61   private static String getComponentName() {
62     return "com.android.dialer.app.DialtactsActivity";
63   }
64 }
65