Commit fcdd0d6f authored by Camilo Higuita's avatar Camilo Higuita

more work on android external sdcard support and check missing files, and more ui fixes

parent 5335d4a3
......@@ -14,6 +14,7 @@
#ifdef Q_OS_ANDROID
#include <QAndroidJniObject>
#include <QAndroidJniEnvironment>
#endif
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
......@@ -202,6 +203,11 @@ QStringList Babe::getPlaylists()
return this->con->getPlaylists();
}
bool Babe::removeTrack(const QString &url)
{
return this->con->removeTrack(url);
}
void Babe::notify(const QString &title, const QString &body)
{
......@@ -266,6 +272,11 @@ int Babe::lastPlaylistPos()
return BAE::loadSettings("PLAYLIST_POS","MAINWINDOW",QVariant(0)).toInt();
}
bool Babe::fileExists(const QString &url)
{
return BAE::fileExists(url);
}
QString Babe::baseColor()
{
#if defined(Q_OS_ANDROID)
......@@ -440,14 +451,20 @@ QString Babe::moodColor(const int &pos)
QString Babe::homeDir()
{
#ifdef Q_OS_ANDROID
#if defined(Q_OS_ANDROID)
QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
return mediaPath.toString();
qDebug()<<"HOMEDIR FROM ADNROID"<< mediaPath.toString();
// QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android.content.Context", "getExternalFilesDir", "()Ljava/io/File;");
// QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
// return mediaPath.toString();
if(BAE::fileExists("/mnt/extSdCard"))
return "/mnt/sdcard";
else
return mediaPath.toString();
// QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android.content.Context", "getExternalFilesDir", "()Ljava/io/File;");
// QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
// return mediaPath.toString();
#else
return BAE::HomePath;
#endif
......@@ -460,10 +477,21 @@ QString Babe::musicDir()
QString Babe::sdDir()
{
#ifdef Q_OS_ANDROID
QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
return mediaPath.toString();
#if defined(Q_OS_ANDROID)
// QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
// QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
// QString dataAbsPath = mediaPath.toString()+"/Download/";
// QAndroidJniEnvironment env;
// if (env->ExceptionCheck()) {
// // Handle exception here.
// env->ExceptionClear();
// }
// qDebug()<<"TESTED SDPATH"<<QProcessEnvironment::systemEnvironment().value("EXTERNAL_SDCARD_STORAGE",dataAbsPath);
if(BAE::fileExists("/mnt/extSdCard"))
return "/mnt/extSdCard";
else
return "/mnt/";
#else
return homeDir();
#endif
......
......@@ -49,6 +49,9 @@ public:
Q_INVOKABLE bool addPlaylist(const QString &playlist);
Q_INVOKABLE QStringList getPlaylists();
Q_INVOKABLE bool removeTrack(const QString &url);
Q_INVOKABLE void notify(const QString &title, const QString &body);
......@@ -69,6 +72,8 @@ public:
Q_INVOKABLE static void savePlaylistPos(const int &pos);
Q_INVOKABLE static int lastPlaylistPos();
Q_INVOKABLE static bool fileExists(const QString &url);
/*COLORS*/
Q_INVOKABLE static QString baseColor();
Q_INVOKABLE static QString darkColor();
......
......@@ -30,19 +30,16 @@ Kirigami.ApplicationWindow
Material.primary: bae.backgroundColor()
Material.foreground: bae.foregroundColor()
// property int columnWidth: Kirigami.Units.gridUnit * 13
signal missingAlert(var track)
readonly property bool isMobile: bae.isMobile()
readonly property int wideSize : bae.screenGeometry("width")*0.45
readonly property int toolBarIconSize: isMobile ? 24 : 22
property int columnWidth: Kirigami.Units.gridUnit * 20
property int coverSize: isMobile ? Math.sqrt(root.width*root.height)*0.4 : columnWidth * 0.65
// property int columnWidth: Math.sqrt(root.width*root.height)*0.4
property int currentView : 0
readonly property int toolBarIconSize: isMobile ? 24 : 22
property alias mainPlaylist : mainPlaylist
// minimumWidth: columnWidth
pageStack.defaultColumnWidth: columnWidth
pageStack.initialPage: [mainPlaylist, views]
......@@ -68,6 +65,27 @@ Kirigami.ApplicationWindow
onClosing: Player.savePlaylist()
BabeDialog
{
id: missingDialog
title: "Missing file"
onAccepted:
{
bae.removeTrack(mainPlaylist.currentTrack.url)
mainPlaylist.list.model.remove(mainPlaylist.list.currentIndex)
}
}
onMissingAlert:
{
missingDialog.message = track.title +" by "+track.artist+" is missing"
missingDialog.messageBody = "Do you want to remove it from your collection?"
missingDialog.open()
}
function runSearch()
{
if(searchInput.text)
......@@ -145,8 +163,8 @@ Kirigami.ApplicationWindow
pageStack.currentIndex = 0
}
onTracksViewClicked:
{
if(!isMobile && !pageStack.wideMode)
......@@ -155,6 +173,7 @@ Kirigami.ApplicationWindow
pageStack.currentIndex = 1
currentView = 0
}
onAlbumsViewClicked:
{
if(!isMobile && !pageStack.wideMode)
......@@ -163,6 +182,7 @@ Kirigami.ApplicationWindow
pageStack.currentIndex = 1
currentView = 1
}
onArtistsViewClicked:
{
if(!isMobile && !pageStack.wideMode)
......@@ -171,6 +191,7 @@ Kirigami.ApplicationWindow
pageStack.currentIndex = 1
currentView = 2
}
onPlaylistsViewClicked:
{
if(!isMobile && !pageStack.wideMode)
......@@ -179,6 +200,7 @@ Kirigami.ApplicationWindow
pageStack.currentIndex = 1
currentView = 3
}
onSettingsViewClicked: settingsDrawer.visible ? settingsDrawer.close() : settingsDrawer.open()
}
......@@ -233,7 +255,6 @@ Kirigami.ApplicationWindow
}
}
BabeButton
{
anchors.right: parent.right
......@@ -241,11 +262,7 @@ Kirigami.ApplicationWindow
iconName: "edit-clear"
onClicked: clearSearch()
}
}
}
background: Rectangle
......@@ -266,6 +283,8 @@ Kirigami.ApplicationWindow
MainPlaylist
{
id: mainPlaylist
anchors.fill: parent
clip: true
Connections
{
target: mainPlaylist
......@@ -281,14 +300,9 @@ Kirigami.ApplicationWindow
anchors.fill: parent
clip: true
// transform: Translate {
// x: (settingsDrawer.position * views.width * 0.33)*-1
// }
Column
{
width: parent.width
height: parent.height
anchors.fill: parent
SwipeView
{
......
......@@ -1726,5 +1726,7 @@ var Babe = {
/*others*/
"gohome" : Icon.home
"gohome" : Icon.home,
"sd" : Icon.sd,
"disks": Icon.disk
}
......@@ -3,41 +3,47 @@ Qt.include("Icons.js")
function playTrack(track)
{
root.mainPlaylist.currentTrack = track
player.source(root.mainPlaylist.currentTrack.url);
player.play()
root.mainPlaylist.playIcon.iconName = "media-playback-pause"
if(track)
{
root.mainPlaylist.currentTrack = track
if(bae.fileExists(root.mainPlaylist.currentTrack.url))
{
player.source(root.mainPlaylist.currentTrack.url);
player.play()
root.mainPlaylist.playIcon.iconName = "media-playback-pause"
var artwork = root.mainPlaylist.currentTrack.artwork
// root.mainPlaylist.list.currentItem.playingIndicator = true
root.mainPlaylist.currentArtwork = artwork && artwork.length>0 && artwork !== "NONE" ? artwork : bae.loadCover(root.mainPlaylist.currentTrack.url)
if(!root.isMobile)
{
root.title = root.mainPlaylist.currentTrack.title + " - " +root.mainPlaylist.currentTrack.artist
var artwork = root.mainPlaylist.currentTrack.artwork
// root.mainPlaylist.list.currentItem.playingIndicator = true
root.mainPlaylist.currentArtwork = artwork && artwork.length>0 && artwork !== "NONE" ? artwork : bae.loadCover(root.mainPlaylist.currentTrack.url)
if(!root.active)
bae.notifySong(root.mainPlaylist.currentTrack.url)
}
if(!root.isMobile)
{
root.title = root.mainPlaylist.currentTrack.title + " - " +root.mainPlaylist.currentTrack.artist
if(!root.active)
bae.notifySong(root.mainPlaylist.currentTrack.url)
}
if(bae.trackBabe(root.mainPlaylist.currentTrack.url))
root.mainPlaylist.babeBtnIcon.iconColor = bae.babeColor()
else
root.mainPlaylist.babeBtnIcon.iconColor = root.mainPlaylist.babeBtnIcon.defaultColor
var lyrics = root.mainPlaylist.currentTrack.lyrics
if(bae.trackBabe(root.mainPlaylist.currentTrack.url))
root.mainPlaylist.babeBtnIcon.iconColor = bae.babeColor()
else
root.mainPlaylist.babeBtnIcon.iconColor = root.mainPlaylist.babeBtnIcon.defaultColor
if(!lyrics || lyrics.length === 0 || lyrics === "NONE" )
bae.trackLyrics(root.mainPlaylist.currentTrack.url)
else
root.mainPlaylist.infoView.lyrics = lyrics
var lyrics = root.mainPlaylist.currentTrack.lyrics
// root.mainPlaylist.infoView.wikiAlbum = bae.albumWiki(root.mainPlaylist.currentTrack.album,root.mainPlaylist.currentTrack.artist)
// root.mainPlaylist.infoView.wikiArtist = bae.artistWiki(root.mainPlaylist.currentTrack.artist)
// // root.mainPlaylist.infoView.artistHead = bae.artistArt(root.mainPlaylist.currentTrack.artist)
// if(!lyrics || lyrics.length === 0 || lyrics === "NONE" )
// bae.trackLyrics(root.mainPlaylist.currentTrack.url)
// else
root.mainPlaylist.infoView.lyrics = lyrics
// root.mainPlaylist.infoView.wikiAlbum = bae.albumWiki(root.mainPlaylist.currentTrack.album,root.mainPlaylist.currentTrack.artist)
// root.mainPlaylist.infoView.wikiArtist = bae.artistWiki(root.mainPlaylist.currentTrack.artist)
// // root.mainPlaylist.infoView.artistHead = bae.artistArt(root.mainPlaylist.currentTrack.artist)
}else root.missingAlert(root.mainPlaylist.currentTrack)
}
}
......@@ -64,21 +70,27 @@ function resumeTrack()
function nextTrack()
{
var next = 0
if(root.mainPlaylist.shuffle)
next = shuffle()
else
next = root.mainPlaylist.list.currentIndex+1 >= root.mainPlaylist.list.count? 0 : root.mainPlaylist.list.currentIndex+1
root.mainPlaylist.prevTrackIndex = root.mainPlaylist.list.currentIndex
playAt(next)
if(root.mainPlaylist.list.count>0)
{
var next = 0
if(root.mainPlaylist.shuffle)
next = shuffle()
else
next = root.mainPlaylist.list.currentIndex+1 >= root.mainPlaylist.list.count? 0 : root.mainPlaylist.list.currentIndex+1
root.mainPlaylist.prevTrackIndex = root.mainPlaylist.list.currentIndex
playAt(next)
}
}
function previousTrack()
{
var previous = previous = root.mainPlaylist.list.currentIndex-1 >= 0 ? root.mainPlaylist.list.currentIndex-1 : root.mainPlaylist.list.count-1
root.mainPlaylist.prevTrackIndex = root.mainPlaylist.list.currentIndex
playAt(previous)
if(root.mainPlaylist.list.count>0)
{
var previous = previous = root.mainPlaylist.list.currentIndex-1 >= 0 ? root.mainPlaylist.list.currentIndex-1 : root.mainPlaylist.list.count-1
root.mainPlaylist.prevTrackIndex = root.mainPlaylist.list.currentIndex
playAt(previous)
}
}
function shuffle()
......
......@@ -5,13 +5,14 @@ Dialog
{
id: dialog
property string message
property string messageBody
width: parent.width
x: (parent.width - width) / 2
y: (parent.height - height) / 2
parent: ApplicationWindow.overlay
modal: true
title: "Confirmation"
standardButtons: Dialog.Yes | Dialog.No
Column
......@@ -21,9 +22,18 @@ Dialog
Label
{
text: message ? message : ""
width: parent.width
elide: Text.ElideRight
color: bae.foregroundColor()
}
}
onAccepted: console.log("accepted join medos")
Label
{
text: messageBody ? messageBody : ""
width: parent.width
elide: Text.ElideRight
color: bae.foregroundColor()
}
}
}
......@@ -5,13 +5,12 @@ import "../../view_models"
Popup
{
// width: parent.width *0.7
// height: parent.height *0.7
id: folderPickerRoot
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
width: parent.width
height: parent.height
id: folderPickerRoot
modal: true
focus: true
clip: true
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
......@@ -28,7 +27,6 @@ Popup
anchors.fill: parent
color: bae.altColor()
z: -999
radius: 4
}
Column
......@@ -42,17 +40,23 @@ Popup
BabeButton
{
Layout.alignment: Qt.AlignLeft
id: closeBtn
iconName: "window-close"
onClicked: close()
}
BabeButton
{
id: homeBtn
iconName: "gohome"
onClicked:
{
// var dir = bae.getParentDir(dirList.currentUrl)
// dirList.currentUrl = dir.url
// dirList.currentName = dir.name
// goBack(dirList.currentUrl)
load(bae.homeDir())
}
onClicked: load(bae.homeDir())
}
BabeButton
{
id: sdBtn
iconName: "disks"
onClicked: load(bae.sdDir())
}
Button
......@@ -70,6 +74,7 @@ Popup
radius: 2
}
}
}
FolderPickerList
......@@ -89,7 +94,7 @@ Popup
}
}
function load(folderUrl)
{
{
dirList.clearTable()
var dirs = bae.getDirs(folderUrl)
for(var path in dirs)
......
......@@ -88,6 +88,7 @@ Item
Image
{
id: artwork
visible: cover.visible
width: parent.height < 300 ? parent.height : 300
height: parent.height
anchors.centerIn: parent
......@@ -170,7 +171,9 @@ Item
Layout.column: 1
Layout.fillWidth: true
width: parent.width
height: 48
Layout.preferredHeight: 48
// height: 48
// anchors.top: cover.bottom
visible: list.count > 0
......@@ -240,20 +243,20 @@ Item
Layout.alignment: Qt.AlignLeft
iconName: stackView.currentItem === list ? "documentinfo" : "arrow-left"
iconSize: playbackIconSize
onClicked:
{
if(stackView.currentItem !== list)
{
stackView.pop(list)
cover.visible = true
}
else
if( stackView.currentItem !== list)
{
cover.visible = false
cover.visible = true
stackView.pop(list) }
else {
cover.visible = false
stackView.push(infoView)
}
}
}
......@@ -266,8 +269,6 @@ Item
id: babeBtnIcon
iconName: "love" //"love-amarok"
iconColor: defaultColor
iconSize: playbackIconSize
onClicked: Player.babeTrack()
}
......@@ -275,8 +276,6 @@ Item
{
id: previousBtn
iconName: "media-skip-backward"
iconSize: playbackIconSize
onClicked: Player.previousTrack()
onPressAndHold: Player.playAt(prevTrackIndex)
......@@ -286,8 +285,6 @@ Item
{
id: playIcon
iconName: "media-playback-start"
iconSize: playbackIconSize
onClicked:
{
if(player.isPaused()) Player.resumeTrack()
......@@ -299,8 +296,6 @@ Item
{
id: nextBtn
iconName: "media-skip-forward"
iconSize: playbackIconSize
onClicked: Player.nextTrack()
onPressAndHold: Player.playAt(Player.shuffle())
}
......@@ -309,8 +304,6 @@ Item
{
id: shuffleBtn
iconName: shuffle ? "media-playlist-shuffle" : "media-playlist-repeat"
iconSize: playbackIconSize
onClicked: shuffle = !shuffle
}
}
......@@ -323,8 +316,6 @@ Item
Layout.alignment: Qt.AlignRight
iconName: /*"application-menu"*/ "overflow-menu"
iconSize: playbackIconSize
onClicked: root.isMobile ? playlistMenu.open() : playlistMenu.popup()
}
......@@ -337,7 +328,9 @@ Item
Layout.row: 3
Layout.column: 1
Layout.fillWidth: true
height: 48
Layout.preferredHeight: 48
// height: 48
anchors.top: playbackControls.bottom
visible: list.count > 0
......
......@@ -11,7 +11,7 @@ Drawer
id: settingsView
y: header.height
height: parent.height - header.height - footer.height
width: root.isMobile ? parent.width* 0.7 : parent.width* 0.5
width: root.pageStack.wideMode ? parent.width* 0.7 : parent.width
edge: Qt.RightEdge
interactive: true
focus: true
......
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