Commit 15efbd20 authored by Camilo Higuita's avatar Camilo Higuita

initial work on android notifications and more work on playlists play-N-sync: added infobar msg

parent 1033a4bf
kirigami @ 72f49c20
Subproject commit b8ed308c1194be1dc1b52aed28d4efd09bbfa56a
Subproject commit 72f49c2026345579fb5444b930d6fa670fb849f7
......@@ -9,20 +9,20 @@ QT += qml
QT += quickcontrols2
android: QT += androidextras
TARGET = babe
TEMPLATE = app
CONFIG += c++11
unix:linux:!android:
{
include(kde/kde.pri)
}
TARGET = babe
TEMPLATE = app
CONFIG += c++11
include(android-openssl.pri)
android: {
android:
{
QT += androidextras
include(android-openssl.pri)
include(3rdparty/kirigami/kirigami.pri)
}
......@@ -202,7 +202,8 @@ SOURCES += main.cpp \
taglib/tag.cpp \
taglib/tagunion.cpp \
babe.cpp \
settings/BabeSettings.cpp
settings/BabeSettings.cpp \
java/notificationclient.cpp
......@@ -225,7 +226,6 @@ n
DISTFILES += \
db/script.sql \
android-openssl.pri \
# 3rdparty/kirigami/kirigami.pri
kde/kde.pri \
android/AndroidManifest.xml \
android/gradle/wrapper/gradle-wrapper.jar \
......@@ -234,6 +234,7 @@ DISTFILES += \
android/build.gradle \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew.bat \
android/src/org/qtproject/babe/NotificationClient.java
HEADERS += \
......@@ -359,7 +360,7 @@ HEADERS += \
taglib/config.h \
taglib/taglib_config.h \
babe.h \
settings/BabeSettings.h
settings/BabeSettings.h \
java/notificationclient.h
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<manifest package="org.qtproject.babe" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
......
package org.qtproject.babe;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity
{
private static NotificationManager m_notificationManager;
private static Notification.Builder m_builder;
private static NotificationClient m_instance;
public NotificationClient()
{
m_instance = this;
}
public static void notify(String s)
{
if (m_notificationManager == null) {
m_notificationManager = (NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE);
m_builder = new Notification.Builder(m_instance);
// m_builder.setSmallIcon(R.drawable.icon);
m_builder.setContentTitle("A message from Qt!");
}
m_builder.setContentText(s);
m_notificationManager.notify(1, m_builder.build());
}
}
#include "notificationclient.h"
#ifdef Q_OS_ANDROID
#include <QAndroidJniObject>
#endif
NotificationClient::NotificationClient(QObject *parent)
: QObject(parent)
{
connect(this, SIGNAL(notificationChanged()), this, SLOT(updateAndroidNotification()));
}
void NotificationClient::setNotification(const QString &notification)
{
if (m_notification == notification)
return;
m_notification = notification;
emit notificationChanged();
}
QString NotificationClient::notification() const
{
return m_notification;
}
void NotificationClient::updateAndroidNotification()
{
#ifdef Q_OS_ANDROID
QAndroidJniObject javaNotification = QAndroidJniObject::fromString(m_notification);
QAndroidJniObject::callStaticMethod<void>("org/qtproject/babe/NotificationClient",
"notify",
"(Ljava/lang/String;)V",
javaNotification.object<jstring>());
#endif
}
#ifndef NOTIFICATIONCLIENT_H
#define NOTIFICATIONCLIENT_H
#include <QObject>
class NotificationClient : public QObject
{
Q_OBJECT
Q_PROPERTY(QString notification READ notification WRITE setNotification NOTIFY notificationChanged)
public:
explicit NotificationClient(QObject *parent = 0);
void setNotification(const QString &notification);
QString notification() const;
signals:
void notificationChanged();
private slots:
void updateAndroidNotification();
private:
QString m_notification;
};
#endif // NOTIFICATIONCLIENT_H
<RCC>
<qresource prefix="/">
<file alias="icons/application-menu.svg">3rdparty/breeze-icons/icons/actions/32/application-menu.svg</file>
<file alias="icons/document-decrypt.svg">3rdparty/breeze-icons/icons/actions/32/document-decrypt.svg</file>
<file alias="icons/folder-sync.svg">3rdparty/breeze-icons/icons/actions/32/folder-sync.svg</file>
<file alias="icons/go-next.svg">3rdparty/breeze-icons/icons/actions/22/go-next.svg</file>
<file alias="icons/go-previous.svg">3rdparty/breeze-icons/icons/actions/22/go-previous.svg</file>
<file alias="icons/go-up.svg">3rdparty/breeze-icons/icons/actions/22/go-up.svg</file>
<file alias="icons/handle-left.svg">3rdparty/breeze-icons/icons/actions/22/handle-left.svg</file>
<file alias="icons/handle-right.svg">3rdparty/breeze-icons/icons/actions/22/handle-right.svg</file>
<file alias="icons/view-list-icons.svg">3rdparty/breeze-icons/icons/actions/32/view-list-icons.svg</file>
<file alias="icons/applications-graphics.svg">3rdparty/breeze-icons/icons/categories/32/applications-graphics.svg</file>
<file alias="icons/media-record-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/media-record-symbolic.svg</file>
<file alias="org/kde/kirigami/icons/application-menu.svg">3rdparty/breeze-icons/icons/actions/32/application-menu.svg</file>
<file alias="org/kde/kirigami/icons/document-decrypt.svg">3rdparty/breeze-icons/icons/actions/32/document-decrypt.svg</file>
<file alias="org/kde/kirigami/icons/folder-sync.svg">3rdparty/breeze-icons/icons/actions/32/folder-sync.svg</file>
<file alias="org/kde/kirigami/icons/go-next-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/go-next-symbolic.svg</file>
<file alias="org/kde/kirigami/icons/go-previous-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/go-previous-symbolic.svg</file>
<file alias="org/kde/kirigami/icons/go-up.svg">3rdparty/breeze-icons/icons/actions/22/go-up.svg</file>
<file alias="org/kde/kirigami/icons/handle-left.svg">3rdparty/breeze-icons/icons/actions/22/handle-left.svg</file>
<file alias="org/kde/kirigami/icons/overflow-menu.svg">3rdparty/breeze-icons/icons/actions/22/overflow-menu.svg</file>
<file alias="org/kde/kirigami/icons/handle-right.svg">3rdparty/breeze-icons/icons/actions/22/handle-right.svg</file>
<file alias="org/kde/kirigami/icons/view-list-icons.svg">3rdparty/breeze-icons/icons/actions/32/view-list-icons.svg</file>
<file alias="org/kde/kirigami/icons/applications-graphics.svg">3rdparty/breeze-icons/icons/categories/32/applications-graphics.svg</file>
<file alias="org/kde/kirigami/icons/media-record-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/media-record-symbolic.svg</file>
</qresource>
</RCC>
......@@ -10,6 +10,7 @@
#ifdef Q_OS_ANDROID
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
//#include "java/notificationclient.h"
#endif
int main(int argc, char *argv[])
......@@ -21,13 +22,15 @@ int main(int argc, char *argv[])
app.setApplicationVersion(BAE::Version);
app.setWindowIcon(QIcon("qrc:/assets/babe.png"));
QFontDatabase::addApplicationFont(":/utils/materialdesignicons-webfont.ttf");
// QQuickStyle::setStyle("org.kde.desktop");
// QQuickStyle::setStyle("org.kde.desktop");
QQmlApplicationEngine engine;
auto context = engine.rootContext();
#ifdef Q_OS_ANDROID
// NotificationClient *notificationClient = new NotificationClient(&engine);
// context->setContextProperty(QLatin1String("notificationClient"), notificationClient);
KirigamiPlugin::getInstance().registerTypes();
#endif
......
......@@ -33,6 +33,8 @@ Kirigami.ApplicationWindow
property int toolBarHeight : isMobile ? 48 : toolBarIconSize *2
property int contentMargins : 15
property string infoMsg : ""
property string babeColor : bae.babeColor()
property string babeAltColor : bae.babeAltColor()
property string backgroundColor : bae.backgroundColor()
......@@ -70,7 +72,7 @@ Kirigami.ApplicationWindow
signal missingAlert(var track)
/*READONLY PROPS*/
readonly property real opacityLevel : 0.7
readonly property bool isMobile: bae.isMobile()
readonly property int wideSize : bae.screenGeometry("width")*0.5
readonly property int rowHeight: isMobile ? 64 : 52
......@@ -131,6 +133,11 @@ Kirigami.ApplicationWindow
if(isMobile) settingsDrawer.switchColorScheme(bae.loadSetting("THEME", "BABE", "Dark"))
}
BabeNotify
{
id: babeNotify
}
BabeMessage
{
id: missingDialog
......@@ -142,7 +149,6 @@ Kirigami.ApplicationWindow
mainPlaylist.list.model.remove(mainPlaylist.list.currentIndex)
}
}
onMissingAlert:
......@@ -181,6 +187,12 @@ Kirigami.ApplicationWindow
// currentView = 0
}
function infoMsgAnim()
{
animBg.running = true
animTxt.running = true
}
Connections
{
target: player
......@@ -370,7 +382,83 @@ Kirigami.ApplicationWindow
onIconSizeChanged: toolBarIconSize = size
}
Item
{
id: message
visible: infoMsg.length > 0
anchors.bottom: parent.bottom
width: pageStack.wideMode ? columnWidth : parent.width
height: toolBarIconSize
z:999
Rectangle
{
id: infoBg
anchors.fill: parent
z: -999
color: altColor
opacity: opacityLevel
SequentialAnimation
{
id: animBg
PropertyAnimation
{
target: infoBg
property: "color"
easing.type: Easing.InOutQuad
to: babeColor
duration: 250
}
PropertyAnimation
{
target: infoBg
property: "color"
easing.type: Easing.InOutQuad
to: altColor
duration: 500
}
}
}
Label
{
id: infoTxt
anchors.centerIn: parent
anchors.fill: parent
height: parent.height
width: parent.width
font.pointSize: 9
text: infoMsg
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
color: foregroundColor
SequentialAnimation
{
id: animTxt
PropertyAnimation
{
target: infoTxt
property: "color"
easing.type: Easing.InOutQuad
to: "white"
duration: 250
}
PropertyAnimation
{
target: infoTxt
property: "color"
easing.type: Easing.InOutQuad
to: foregroundColor
duration: 500
}
}
}
}
MainPlaylist
{
......@@ -383,7 +471,6 @@ Kirigami.ApplicationWindow
onCoverPressed: Player.appendAll(tracks)
onCoverDoubleClicked: Player.playAll(tracks)
}
}
Page
......@@ -476,6 +563,7 @@ Kirigami.ApplicationWindow
Player.playAll(tracks)
root.sync = true
root.syncPlaylist = playlist
root.infoMsg = "Syncing to "+ playlist
console.log("ALLOW PLAYLIOST SYNC FOR: " ,root.syncPlaylist = playlist)
}
}
......
......@@ -67,5 +67,6 @@
<file>view_models/BabeDelegate.qml</file>
<file>view_models/BabeList.qml</file>
<file>view_models/BabeTable/HeaderMenu.qml</file>
<file>view_models/BabeNotify.qml</file>
</qresource>
</RCC>
......@@ -138,9 +138,10 @@ function appendTrack(track)
if(root.sync === true)
{
console.log("SYNC TRACK")
root.infoMsgAnim()
addToPlaylist([track.url], root.syncPlaylist)
}
}
// if(track)
......@@ -216,6 +217,7 @@ function playAll(tracks)
{
root.sync = false
root.syncPlaylist = ""
root.infoMsg = ""
root.mainPlaylist.list.clearTable()
root.pageStack.currentIndex = 0
......@@ -258,6 +260,9 @@ function addToPlaylist(urls, playlist)
if(!isMobile)
bae.notify(playlist, urls.length + " tracks added to the playlist:\n"+urls.join("\n"))
// else
// babeNotify.notify(urls.length + " tracks added to " +playlist)
}
}
......@@ -12,10 +12,10 @@ Menu
focus: true
parent: ApplicationWindow.overlay
enter: Transition
{
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
// enter: Transition
// {
// NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
// }
Material.accent: babeColor
Material.background: backgroundColor
......
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
Popup
{
property string message : ""
id: notify
width: columnWidth
height: toolBarHeight
padding: 0
x: parent.width / 2 - width / 2
y: parent.height * 0.1
parent: ApplicationWindow.overlay
z: 999
modal: false
focus: false
clip: true
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
background: Rectangle
{
id: notifyBg
color: altColor
opacity: opacityLevel
}
Material.accent: babeColor
Material.background: backgroundColor
Material.primary: backgroundColor
Material.foreground: foregroundColor
Column
{
anchors.fill: parent
Label
{
height: parent.height
width: parent.width
text: message
font.pointSize: 9
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
color: foregroundColor
}
}
function notify(txt)
{
message = txt
open()
}
}
......@@ -5,7 +5,7 @@ import QtQuick.Controls.Material 2.1
Popup
{
width: parent.width *0.8
width: parent.width * 0.8
height: parent.height *0.8
padding: 0
......
......@@ -8,12 +8,11 @@ import ".."
BabeMenu
{
signal saveListClicked();
property alias menuItem: babeMenu.children
Column
{
id: babeMenu
......
......@@ -2,6 +2,7 @@ import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../view_models"
import QtQuick.Controls.Material 2.1
BabePopup
{
......@@ -25,8 +26,8 @@ BabePopup
RowLayout
{
Layout.margins: contentMargins
Layout.fillWidth: true
width:parent.width
height: toolBarHeight
BabeButton
{
......@@ -36,6 +37,12 @@ BabePopup
onClicked: close()
}
Item
{
Layout.fillWidth: true
}
BabeButton
{
id: homeBtn
......@@ -56,6 +63,11 @@ BabePopup
onClicked: {accepted(dirList.currentUrl); close()}
text: "Accept"
Material.accent: babeColor
Material.background: backgroundColor
Material.primary: backgroundColor
Material.foreground: foregroundColor
}
}
......
......@@ -18,12 +18,11 @@ Item
id: mainPlaylistRoot
readonly property real opacityLevel : 0.7
property var currentTrack
property int currentTrackIndex : 0
property int prevTrackIndex : 0
property string currentArtwork
property bool shuffle : false
property alias progressBar : progressBar
......@@ -71,6 +70,7 @@ Item
Layout.maximumHeight: 300
visible: list.count > 0
Rectangle
{
anchors.fill: parent
......@@ -158,8 +158,6 @@ Item
z: -999
}
PlaylistMenu
{
id: playlistMenu
......
......@@ -2,6 +2,7 @@ import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.1
Item
{
......@@ -136,11 +137,15 @@ Item
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
id: loginBtn
text: "Login"
Material.accent: babeColor
Material.background: backgroundColor
Material.primary: backgroundColor
Material.foreground: foregroundColor
}
......
......@@ -74,21 +74,21 @@ ItemDelegate
}
Item
{
visible: !playlistIcon
Layout.fillHeight: true
width: parent.height
BabeButton
{
id: syncBtn
anchors.centerIn: parent
iconName: "amarok_playlist_refresh" //"playlist-generator"
iconColor: textColor
onClicked: playSync(index)
}
}
// Item
// {
// visible: !playlistIcon
// Layout.fillHeight: true
// width: parent.height
// BabeButton
// {
// id: syncBtn
// anchors.centerIn: parent
// iconName: "amarok_playlist_refresh" //"playlist-generator"
// iconColor: textColor
// onClicked: playSync(index)
// }
// }
}
......
......@@ -72,7 +72,6 @@ Kirigami.PageRow
}
}
}
}
......@@ -105,23 +104,25 @@ Kirigami.PageRow
holder.message: "<h2>"+playlistViewModel.model.get(playlistViewModel.currentIndex).playlist+"</h2><p>Your playlist is empty,<br>start adding new music to it</p>"