blob: 056912a1a0bb96cf465759f5163e061770ead3d4 [file] [log] [blame]
Priyank Singhab37e372019-03-25 13:35:16 -07001/*
2 * Copyright (C) 2019 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.car.frameworkpackagestubs;
18
19import android.app.Activity;
20import android.os.Bundle;
21import android.widget.Toast;
22
23/**
24 * Contains different stub classes.
25 *
26 * <p>These are broken out so that the intent filters are easier to track and so that
27 * individual ones can create more specific messages if desired.
28 */
29public final class Stubs {
30
31 /**
32 * Base class for stubs.
33 *
34 * <p>Shows a toast and finishes.
35 *
36 * <p>Subclasses can override {@link #getMessage()} to customize the message.
37 */
38 private static class BaseActivity extends Activity {
39
40 private Toast mToast;
41
42 @Override
43 protected void onCreate(Bundle savedInstanceState) {
44 super.onCreate(savedInstanceState);
45 showToast();
46 finish();
47 }
48
49 protected CharSequence getMessage() {
50 return getResources().getString(R.string.message_not_supported);
51 }
52
53 private void showToast() {
54 cancelToast();
55 mToast = Toast.makeText(this, getMessage(), Toast.LENGTH_LONG);
56 mToast.show();
57 }
58
59 private void cancelToast() {
60 if (mToast != null) {
61 mToast.cancel();
62 }
63 }
64 }
65
66 /**
Hayden Gomes019912d2019-05-21 16:19:29 -070067 * Stub activity for Browser events.
68 */
69 public static class BrowserStub extends BaseActivity { }
70
71 /**
72 * Stub activity for Calendar events.
73 */
74 public static class CalendarStub extends BaseActivity { }
75
76 /**
77 * Stub activity for Desk Clock events.
78 */
79 public static class DeskClockStub extends BaseActivity { }
80
81 /**
82 * Stub activity for Dialer events.
83 */
84 public static class DialerStub extends BaseActivity { }
85
86 /**
Priyank Singhab37e372019-03-25 13:35:16 -070087 * Stub activity for media events.
88 */
89 public static class MediaStub extends BaseActivity { }
90
91 /**
92 * Stub activity for setting events.
93 */
94 public static class SettingsStub extends BaseActivity { }
95}