calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 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 | |
calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 19 | import android.content.ComponentName; |
| 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 22 | |
zachh | d74e72e | 2018-03-23 11:43:18 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Main activity intents. |
| 25 | * |
| 26 | * <p>TODO(calderwoodra): Move this elsewhere. |
| 27 | */ |
calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 28 | public class MainComponent { |
| 29 | |
calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 30 | /** |
| 31 | * @param context Context of the application package implementing MainActivity class. |
| 32 | * @return intent for MainActivity.class |
| 33 | */ |
| 34 | public static Intent getIntent(Context context) { |
| 35 | Intent intent = new Intent(); |
calderwoodra | 014ffe1 | 2018-02-05 15:59:47 -0800 | [diff] [blame] | 36 | intent.setComponent(new ComponentName(context, getComponentName())); |
calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 37 | intent.setAction(Intent.ACTION_VIEW); |
| 38 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 39 | return intent; |
| 40 | } |
calderwoodra | 014ffe1 | 2018-02-05 15:59:47 -0800 | [diff] [blame] | 41 | |
| 42 | public static Intent getShowCallLogIntent(Context context) { |
| 43 | Intent intent = new Intent(); |
| 44 | intent.setComponent(new ComponentName(context, getComponentName())); |
| 45 | intent.setAction("ACTION_SHOW_TAB"); |
| 46 | intent.putExtra("EXTRA_SHOW_TAB", 1); |
| 47 | return intent; |
| 48 | } |
| 49 | |
calderwoodra | 0c06057 | 2018-02-05 19:24:02 -0800 | [diff] [blame] | 50 | public static Intent getShowVoicemailIntent(Context context) { |
| 51 | Intent intent = new Intent(); |
| 52 | intent.setComponent(new ComponentName(context, getComponentName())); |
| 53 | intent.setAction("ACTION_SHOW_TAB"); |
| 54 | intent.putExtra("EXTRA_SHOW_TAB", 3); |
| 55 | return intent; |
| 56 | } |
| 57 | |
calderwoodra | 014ffe1 | 2018-02-05 15:59:47 -0800 | [diff] [blame] | 58 | private static String getComponentName() { |
| 59 | return "com.android.dialer.main.impl.MainActivity"; |
| 60 | } |
calderwoodra | 9f16e17 | 2018-01-29 19:18:14 -0800 | [diff] [blame] | 61 | } |