2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 14:15:14 +00:00

Initial Bigscreen remote support

This commit is contained in:
Sylvia van Os
2020-03-27 20:23:02 +01:00
committed by Nicolas Fella
parent cff55ab8dd
commit e3ca5aca57
13 changed files with 325 additions and 2 deletions

View File

@@ -206,6 +206,16 @@
android:scheme="kdeconnect" />
</intent-filter>
</activity>
<activity
android:name="org.kde.kdeconnect.Plugins.BigscreenPlugin.BigscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/pref_plugin_bigscreen"
android:parentActivityName="org.kde.kdeconnect.UserInterface.MainActivity"
android:windowSoftInputMode="stateHidden|adjustResize">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.kde.kdeconnect.UserInterface.MainActivity" />
</activity>
<activity
android:name="org.kde.kdeconnect.Plugins.MousePadPlugin.MousePadActivity"
android:label="@string/pref_plugin_mousepad"

View File

@@ -87,6 +87,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.jakewharton:disklrucache:2.0.2' //For caching album art bitmaps
implementation 'com.jaredrummler:android-device-names:1.1.9' //To get a human-friendly device name
@@ -112,3 +113,7 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'org.skyscreamer:jsonassert:1.3.0'
}
repositories {
google()
}

View File

@@ -1,6 +1,6 @@
#Sun Oct 27 20:27:45 CET 2019
#Fri Mar 27 09:59:30 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z"
android:fillColor="#010101"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,12l1.41,1.41L11,7.83V20h2V7.83l5.58,5.59L20,12l-8,-8 -8,8z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,7v4H5.83l3.58,-3.59L8,6l-6,6 6,6 1.41,-1.41L5.83,13H21V7z"/>
</vector>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.gridlayout.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
grid:useDefaultMargins="true">
<ImageButton
android:id="@+id/home_button"
grid:layout_column="0"
grid:layout_row="0"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:contentDescription="@string/bigscreen_home"
android:src="@drawable/ic_home_black_24dp"
android:theme="@style/DisableableButton" />
<ImageButton
android:id="@+id/up_button"
grid:layout_column="1"
grid:layout_row="0"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:contentDescription="@string/bigscreen_up"
android:src="@drawable/ic_arrow_upward_black_24dp"
android:theme="@style/DisableableButton" />
<ImageButton
android:id="@+id/left_button"
grid:layout_column="0"
grid:layout_row="1"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:contentDescription="@string/bigscreen_left"
android:src="@drawable/ic_arrow_back_black_24dp"
android:theme="@style/DisableableButton" />
<ImageButton
android:id="@+id/select_button"
grid:layout_column="1"
grid:layout_row="1"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:contentDescription="@string/bigscreen_select"
android:src="@drawable/ic_keyboard_return_black_24dp"
android:theme="@style/DisableableButton" />
<ImageButton
android:id="@+id/right_button"
grid:layout_column="2"
grid:layout_row="1"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:contentDescription="@string/bigscreen_right"
android:src="@drawable/ic_arrow_forward_black_24dp"
android:theme="@style/DisableableButton" />
<ImageButton
android:id="@+id/down_button"
grid:layout_column="1"
grid:layout_row="2"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:contentDescription="@string/bigscreen_down"
android:src="@drawable/ic_arrow_downward_black_24dp"
android:theme="@style/DisableableButton" />
</androidx.gridlayout.widget.GridLayout>

View File

@@ -358,4 +358,13 @@
<string name="clipboard_android_x_incompat">Android 10 has removed clipboard access to all apps. This plugin will be disabled.</string>
<string name="mpris_open_url">Continue playing here</string>
<string name="cant_open_url">Can\'t open URL to continue playing</string>
<string name="bigscreen_home">Home</string>
<string name="bigscreen_up">Up</string>
<string name="bigscreen_left">Left</string>
<string name="bigscreen_select">Select</string>
<string name="bigscreen_right">Right</string>
<string name="bigscreen_down">Down</string>
<string name="pref_plugin_bigscreen">Bigscreen remote</string>
<string name="pref_plugin_bigscreen_desc">Use your device as a remote for Plasma Bigscreen</string>
</resources>

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2014 Ahmed I. Khalil <ahmedibrahimkhali@gmail.com>
* Copyright 2020 Sylvia van Os <sylvia@hackerchick.me>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kde.kdeconnect.Plugins.BigscreenPlugin;
import android.os.Bundle;
import org.kde.kdeconnect.BackgroundService;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import org.kde.kdeconnect_tp.R;
import androidx.appcompat.app.AppCompatActivity;
public class BigscreenActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ThemeUtil.setUserPreferredTheme(this);
setContentView(R.layout.activity_bigscreen);
final String deviceId = getIntent().getStringExtra("deviceId");
BackgroundService.RunWithPlugin(this, deviceId, org.kde.kdeconnect.Plugins.BigscreenPlugin.BigscreenPlugin.class, plugin -> runOnUiThread(() -> {
findViewById(R.id.left_button).setOnClickListener(v -> plugin.sendLeft());
findViewById(R.id.right_button).setOnClickListener(v -> plugin.sendRight());
findViewById(R.id.up_button).setOnClickListener(v -> plugin.sendUp());
findViewById(R.id.down_button).setOnClickListener(v -> plugin.sendDown());
findViewById(R.id.select_button).setOnClickListener(v -> plugin.sendSelect());
findViewById(R.id.home_button).setOnClickListener(v -> plugin.sendHome());
}));
}
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright 2014 Ahmed I. Khalil <ahmedibrahimkhali@gmail.com>
* Copyright 2020 Sylvia van Os <sylvia@hackerchick.me>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kde.kdeconnect.Plugins.BigscreenPlugin;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import androidx.core.content.ContextCompat;
import static org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView.SpecialKeysMap;
@PluginFactory.LoadablePlugin
public class BigscreenPlugin extends Plugin {
private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request";
@Override
public String getDisplayName() {
return context.getString(R.string.pref_plugin_bigscreen);
}
@Override
public String getDescription() {
return context.getString(R.string.pref_plugin_bigscreen_desc);
}
@Override
public Drawable getIcon() {
return ContextCompat.getDrawable(context, R.drawable.ic_presenter);
}
@Override
public boolean hasSettings() {
return false;
}
@Override
public boolean hasMainActivity() {
return true;
}
@Override
public void startMainActivity(Activity parentActivity) {
Intent intent = new Intent(parentActivity, BigscreenActivity.class);
intent.putExtra("deviceId", device.getDeviceId());
parentActivity.startActivity(intent);
}
@Override
public String[] getSupportedPacketTypes() { return new String[0]; }
@Override
public String[] getOutgoingPacketTypes() {
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST};
}
@Override
public String getActionName() {
return context.getString(R.string.pref_plugin_bigscreen);
}
public void sendLeft() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_DPAD_LEFT));
device.sendPacket(np);
}
public void sendRight() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_DPAD_RIGHT));
device.sendPacket(np);
}
public void sendUp() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_DPAD_UP));
device.sendPacket(np);
}
public void sendDown() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_DPAD_DOWN));
device.sendPacket(np);
}
public void sendSelect() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_ENTER));
device.sendPacket(np);
}
public void sendHome() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
np.set("alt", true);
np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_F4));
device.sendPacket(np);
}
}