Commit 6b091a0e authored by Nicolas Fella's avatar Nicolas Fella

Add Android brightness backend

Test Plan: Double-tap barcode : Screen gets brighter

Reviewers: vkrause

Reviewed By: vkrause

Subscribers: kde-pim

Tags: #kde_pim, #kde_itinerary

Differential Revision: https://phabricator.kde.org/D17827
parent 5f8544bc
......@@ -48,7 +48,9 @@ set(itinerary_app_srcs
brightnessmanager.cpp
livedatamanager.cpp
)
if (NOT ANDROID)
if (ANDROID)
list(APPEND itinerary_app_srcs androidbrightnessbackend.cpp)
else()
list(APPEND itinerary_app_srcs solidbrightnessbackend.cpp)
qt5_add_dbus_interface(itinerary_app_srcs org.kde.Solid.PowerManagement.Actions.BrightnessControl.xml brightnesscontroldbusinterface)
endif()
......
/*
Copyright (C) 2018 Nicolas Fella <nicolas.fella@gmx.de>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
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 Library 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 <https://www.gnu.org/licenses/>.
*/
#include "androidbrightnessbackend.h"
#include <QDebug>
#include <QtAndroid>
#include <QAndroidJniObject>
AndroidBrightnessBackend::AndroidBrightnessBackend(QObject *parent)
: BrightnessBackend(parent)
{
}
AndroidBrightnessBackend::~AndroidBrightnessBackend()
{
}
void AndroidBrightnessBackend::maxBrightness()
{
const auto activity = QtAndroid::androidActivity();
if (activity.isValid()) {
activity.callMethod<void>("maxBrightness");
}
}
/*
Copyright (C) 2018 Nicolas Fella <nicolas.fella@gmx.de>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
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 Library 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 <https://www.gnu.org/licenses/>.
*/
#ifndef ANDROIDBRIGHTNESSBACKEND_H
#define ANDROIDBRIGHTNESSBACKEND_H
#include <QObject>
#include "brightnessmanager.h"
class AndroidBrightnessBackend : public BrightnessBackend
{
public:
explicit AndroidBrightnessBackend(QObject *parent = nullptr);
virtual ~AndroidBrightnessBackend();
virtual void maxBrightness();
};
#endif // ANDROIDBRIGHTNESSBACKEND_H
......@@ -19,14 +19,18 @@
#include <QDebug>
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
#if defined(Q_OS_ANDROID)
#include "androidbrightnessbackend.h"
#elif defined(Q_OS_LINUX)
#include "solidbrightnessbackend.h"
#endif
BrightnessManager::BrightnessManager(QObject *parent)
: QObject(parent)
{
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
#if defined(Q_OS_ANDROID)
m_backend = new AndroidBrightnessBackend(this);
#elif defined(Q_OS_LINUX)
m_backend = new SolidBrightnessBackend(this);
#endif
}
......
......@@ -27,6 +27,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.CalendarContract;
import android.util.Log;
import android.view.WindowManager;
import java.io.*;
import java.util.*;
......@@ -116,4 +117,15 @@ public class Activity extends QtActivity
}
}
}
public void maxBrightness() {
runOnUiThread(new Runnable() {
@Override
public void run() {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = 1F;
getWindow().setAttributes(layout);
}
});
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment