2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-22 01:51:47 +00:00

initial work on new bigscreen remote ui

This commit is contained in:
Manuel de la Fuente 2022-06-22 13:42:03 +02:00 committed by Manuel Jesús de la Fuente
parent 7c1d62f60c
commit 3b1f9d92ff
12 changed files with 270 additions and 110 deletions

View File

@ -0,0 +1,12 @@
<vector
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z" />
</vector>

View File

@ -0,0 +1,12 @@
<vector
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M15.41,16.59L10.83,12l4.58,-4.59L14,6l-6,6 6,6 1.41,-1.41z" />
</vector>

View File

@ -0,0 +1,12 @@
<vector
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M8.59,16.59L13.17,12 8.59,7.41 10,6l6,6 -6,6 -1.41,-1.41z" />
</vector>

View File

@ -0,0 +1,12 @@
<vector
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z" />
</vector>

View File

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

View File

@ -1,9 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
<vector
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="#FF000000"
android:pathData="M 16.766667,8.7612589 v 2.5197071 c 0,2.182796 -2.138935,3.959544 -4.766667,3.959544 -2.6277329,0 -4.7666673,-1.776748 -4.7666673,-3.959544 V 8.7612589 H 5.4999999 v 2.5197071 c 0,2.732804 2.4587328,4.991913 5.6333321,5.345392 v 2.933663 H 8.0999999 v 1.439831 H 15.9 V 19.560021 H 12.866667 V 16.626358 C 16.041267,16.272879 18.5,14.01377 18.5,11.280966 V 8.7612589 Z M 12,13.800679 A 3.0333332,2.5197106 0 0 1 8.9666671,11.280966 V 5.5216304 a 3.0333332,2.5197106 0 1 1 6.0666649,0 V 11.280966 A 3.0333332,2.5197106 0 0 1 12,13.800679 Z"/>
android:pathData="M 16.766667,8.7612589 v 2.5197071 c 0,2.182796 -2.138935,3.959544 -4.766667,3.959544 -2.6277329,0 -4.7666673,-1.776748 -4.7666673,-3.959544 V 8.7612589 H 5.4999999 v 2.5197071 c 0,2.732804 2.4587328,4.991913 5.6333321,5.345392 v 2.933663 H 8.0999999 v 1.439831 H 15.9 V 19.560021 H 12.866667 V 16.626358 C 16.041267,16.272879 18.5,14.01377 18.5,11.280966 V 8.7612589 Z M 12,13.800679 A 3.0333332,2.5197106 0 0 1 8.9666671,11.280966 V 5.5216304 a 3.0333332,2.5197106 0 1 1 6.0666649,0 V 11.280966 A 3.0333332,2.5197106 0 0 1 12,13.800679 Z" />
</vector>

View File

@ -1,89 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.kde.kdeconnect.Plugins.BigscreenPlugin.BigscreenActivity">
<include layout="@layout/toolbar" android:id="@+id/toolbar_layout" />
<include
android:id="@+id/toolbar_layout"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.kde.kdeconnect.UserInterface.Utils.RoundedConstraintLayout
android:id="@+id/rConstraintLayout"
<androidx.gridlayout.widget.GridLayout
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
grid:useDefaultMargins="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
android:layout_height="0dp"
android:layout_margin="24dp"
app:layout_constraintBottom_toTopOf="@+id/rLinearLayout"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_layout">
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/disabled_grey"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/up_button"
android:contentDescription="@string/bigscreen_up"
android:src="@drawable/ic_baseline_keyboard_arrow_up_24"
android:theme="@style/TransparentButton"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_row="0"
app:layout_rowWeight="1" />
<ImageButton
android:id="@+id/left_button"
android:contentDescription="@string/bigscreen_left"
android:src="@drawable/ic_baseline_keyboard_arrow_left_24"
android:theme="@style/TransparentButton"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_row="1"
app:layout_rowWeight="1" />
<ImageButton
android:id="@+id/select_button"
style="@style/CircleButton"
android:contentDescription="@string/bigscreen_select"
app:layout_column="1"
app:layout_columnWeight="2"
app:layout_row="1"
app:layout_rowWeight="2" />
<ImageButton
android:id="@+id/right_button"
android:contentDescription="@string/bigscreen_right"
android:src="@drawable/ic_baseline_keyboard_arrow_right_24"
android:theme="@style/TransparentButton"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="1"
app:layout_rowWeight="1" />
<ImageButton
android:id="@+id/down_button"
android:contentDescription="@string/bigscreen_down"
android:src="@drawable/ic_baseline_keyboard_arrow_down_24"
android:theme="@style/TransparentButton"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_row="2"
app:layout_rowWeight="1" />
</androidx.gridlayout.widget.GridLayout>
</org.kde.kdeconnect.UserInterface.Utils.RoundedConstraintLayout>
<LinearLayout
android:id="@+id/rLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rConstraintLayout">
<ImageButton
android:id="@+id/home_button"
grid:layout_column="0"
grid:layout_row="0"
grid:layout_columnWeight="1"
grid:layout_rowWeight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="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" />
android:theme="@style/DisableableButton"/>
<ImageButton
android:id="@+id/mic_button"
grid:layout_column="2"
grid:layout_columnWeight="1"
grid:layout_row="0"
grid:layout_rowWeight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:contentDescription="@string/bigscreen_mic"
android:src="@drawable/ic_mic_black"
android:theme="@style/DisableableButton" />
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" />
</LinearLayout>
<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>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -2,6 +2,7 @@
<resources>
<color name="primaryDark">@android:color/black</color>
<color name="darkGrey">#555555</color>
<color name="disabled_grey">@color/darkGrey</color>
<color name="darkToolbarBackground">#222222</color>
<color name="darkStatusBarBackground">#333333</color>
<color name="on_secondary">@android:color/black</color>

View File

@ -52,6 +52,19 @@
<item name="colorButtonNormal">@drawable/disableable_button</item>
</style>
<style name="TransparentButton" parent="android:Widget.ActionButton">
<!-- <item name="android:padding">0dp</item>-->
<!-- <item name="android:layout_margin">0dp</item>-->
<item name="background">@android:color/transparent</item>
<item name="backgroundTint">@android:color/transparent</item>
<item name="android:layout_width">48dp</item>
<item name="android:layout_height">48dp</item>
</style>
<style name="CircleButton" parent="android:Widget.ActionButton">
<item name="android:background">@drawable/button_circle</item>
</style>
<style name="ActionModeStyle" parent="Widget.AppCompat.ActionMode">
<item name="background">@color/primaryDark</item>
</style>

View File

@ -43,35 +43,36 @@ public class BigscreenActivity extends AppCompatActivity {
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
final String deviceId = getIntent().getStringExtra("deviceId");
if (!SpeechRecognizer.isRecognitionAvailable(this)) {
binding.micButton.setEnabled(false);
binding.micButton.setVisibility(View.INVISIBLE);
}
BackgroundService.RunWithPlugin(this, deviceId, BigscreenPlugin.class, plugin -> runOnUiThread(() -> {
binding.leftButton.setOnClickListener(v -> plugin.sendLeft());
binding.rightButton.setOnClickListener(v -> plugin.sendRight());
binding.upButton.setOnClickListener(v -> plugin.sendUp());
binding.downButton.setOnClickListener(v -> plugin.sendDown());
binding.selectButton.setOnClickListener(v -> plugin.sendSelect());
binding.homeButton.setOnClickListener(v -> plugin.sendHome());
binding.micButton.setOnClickListener(v -> {
if (plugin.hasMicPermission()) {
activateSTT();
} else {
new PermissionsAlertDialogFragment.Builder()
.setTitle(plugin.getDisplayName())
.setMessage(R.string.bigscreen_optional_permission_explanation)
.setPositiveButton(R.string.ok)
.setNegativeButton(R.string.cancel)
.setPermissions(new String[]{Manifest.permission.RECORD_AUDIO})
.setRequestCode(MainActivity.RESULT_NEEDS_RELOAD)
.create().show(getSupportFragmentManager(), null);
}
});
}));
// TODO uncomment before merging
// final String deviceId = getIntent().getStringExtra("deviceId");
//
// if (!SpeechRecognizer.isRecognitionAvailable(this)) {
// binding.micButton.setEnabled(false);
// binding.micButton.setVisibility(View.INVISIBLE);
// }
//
// BackgroundService.RunWithPlugin(this, deviceId, BigscreenPlugin.class, plugin -> runOnUiThread(() -> {
// binding.leftButton.setOnClickListener(v -> plugin.sendLeft());
// binding.rightButton.setOnClickListener(v -> plugin.sendRight());
// binding.upButton.setOnClickListener(v -> plugin.sendUp());
// binding.downButton.setOnClickListener(v -> plugin.sendDown());
// binding.selectButton.setOnClickListener(v -> plugin.sendSelect());
// binding.homeButton.setOnClickListener(v -> plugin.sendHome());
// binding.micButton.setOnClickListener(v -> {
// if (plugin.hasMicPermission()) {
// activateSTT();
// } else {
// new PermissionsAlertDialogFragment.Builder()
// .setTitle(plugin.getDisplayName())
// .setMessage(R.string.bigscreen_optional_permission_explanation)
// .setPositiveButton(R.string.ok)
// .setNegativeButton(R.string.cancel)
// .setPermissions(new String[]{Manifest.permission.RECORD_AUDIO})
// .setRequestCode(MainActivity.RESULT_NEEDS_RELOAD)
// .create().show(getSupportFragmentManager(), null);
// }
// });
// }));
}
public void activateSTT() {

View File

@ -16,6 +16,7 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import org.kde.kdeconnect.Plugins.BigscreenPlugin.BigscreenActivity
import org.kde.kdeconnect.UserInterface.List.ListAdapter
import org.kde.kdeconnect.UserInterface.MainActivity
import org.kde.kdeconnect_tp.R
@ -89,8 +90,9 @@ class AboutFragment : Fragment() {
startActivity(Intent(context, LicensesActivity::class.java))
}
// TODO change back go AboutKDEActivity::class.java before merging
binding!!.aboutKdeButton.setOnClickListener {
startActivity(Intent(context, AboutKDEActivity::class.java))
startActivity(Intent(context, BigscreenActivity::class.java))
}
setupInfoButton(aboutData.websiteURL, binding!!.websiteButton)

View File

@ -0,0 +1,52 @@
/*
* SPDX-FileCopyrightText: 2022 Manuel Jesús de la Fuente <m@nueljl.in>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
package org.kde.kdeconnect.UserInterface.Utils
import android.annotation.TargetApi
import android.content.Context
import android.graphics.Canvas
import android.graphics.Path
import android.graphics.RectF
import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
class RoundedConstraintLayout : ConstraintLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
: super(context, attrs, defStyleAttr)
@TargetApi(21)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int)
: super(context, attrs, defStyleAttr, defStyleRes)
var path: Path = Path()
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
val width = w.toFloat()
val height = h.toFloat()
// Set the corner radius here. You could change this to i.e. 28.0F to match Material 3 but
// since this is only used in the Bigscreen activity for the circle pad it's just taking
// the runtime width as the radius to make it fully rounded
val radius = width
with (this.path) {
addRoundRect(
RectF(0.0F, 0.0F, width, height), radius, radius, Path.Direction.CW
)
}
}
override fun dispatchDraw(canvas: Canvas?) {
canvas?.clipPath(this.path)
super.dispatchDraw(canvas)
}
}