Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2014 Ahmed I. Khalil <ahmedibrahimkhali@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | package org.kde.kdeconnect.Plugins.PresenterPlugin; | ||||
22 | | ||||
23 | | ||||
24 | import android.app.Activity; | ||||
25 | import android.content.Intent; | ||||
26 | import android.graphics.drawable.Drawable; | ||||
27 | import android.support.v4.content.ContextCompat; | ||||
28 | import android.view.KeyEvent; | ||||
29 | | ||||
30 | import org.kde.kdeconnect.NetworkPacket; | ||||
31 | import org.kde.kdeconnect.Plugins.Plugin; | ||||
32 | import org.kde.kdeconnect_tp.R; | ||||
33 | | ||||
34 | import static org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView.SpecialKeysMap; | ||||
35 | | ||||
36 | public class PresenterPlugin extends Plugin { | ||||
37 | | ||||
38 | public final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request"; | ||||
39 | | ||||
40 | @Override | ||||
41 | public String getDisplayName() { | ||||
42 | return context.getString(R.string.pref_plugin_presenter); | ||||
43 | } | ||||
44 | | ||||
45 | @Override | ||||
46 | public String getDescription() { | ||||
47 | return context.getString(R.string.pref_plugin_presenter_desc); | ||||
48 | } | ||||
49 | | ||||
50 | @Override | ||||
51 | public Drawable getIcon() { | ||||
52 | return ContextCompat.getDrawable(context, R.drawable.ic_presenter); | ||||
53 | } | ||||
54 | | ||||
55 | @Override | ||||
56 | public boolean hasSettings() { | ||||
57 | return false; | ||||
58 | } | ||||
59 | | ||||
60 | @Override | ||||
61 | public boolean hasMainActivity() { | ||||
62 | return true; | ||||
63 | } | ||||
64 | | ||||
65 | @Override | ||||
66 | public void startMainActivity(Activity parentActivity) { | ||||
67 | Intent intent = new Intent(parentActivity, PresenterActivity.class); | ||||
68 | intent.putExtra("deviceId", device.getDeviceId()); | ||||
69 | parentActivity.startActivity(intent); | ||||
70 | } | ||||
71 | | ||||
72 | @Override | ||||
73 | public String[] getSupportedPacketTypes() { | ||||
74 | return new String[0]; | ||||
75 | } | ||||
76 | | ||||
77 | @Override | ||||
78 | public String[] getOutgoingPacketTypes() { | ||||
79 | return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST}; | ||||
80 | } | ||||
81 | | ||||
82 | @Override | ||||
83 | public String getActionName() { | ||||
84 | return context.getString(R.string.pref_plugin_presenter); | ||||
85 | } | ||||
86 | | ||||
87 | public void sendNext() { | ||||
88 | NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST); | ||||
89 | np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_PAGE_DOWN)); | ||||
90 | device.sendPacket(np); | ||||
91 | } | ||||
92 | public void sendPrevious() { | ||||
93 | NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST); | ||||
94 | np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_PAGE_UP)); | ||||
95 | device.sendPacket(np); | ||||
96 | } | ||||
97 | public void sendFullscreen() { | ||||
98 | NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST); | ||||
99 | np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_F5)); | ||||
100 | device.sendPacket(np); | ||||
101 | } | ||||
102 | | ||||
103 | } |