Improve theming under Android

This commit is contained in:
Martchus 2018-09-09 00:57:02 +02:00
parent a5ffe32861
commit 829c7e63dc
17 changed files with 293 additions and 18 deletions

View File

@ -101,6 +101,7 @@ set(REQUIRED_ICONS
dialog-ok-apply
dialog-password
document-close
document-encrypt
document-export
document-new
document-open
@ -118,6 +119,7 @@ set(REQUIRED_ICONS
flag-black
flag-blue
folder
folder-add
folder-symbolic
go-next
help-about
@ -127,17 +129,37 @@ set(REQUIRED_ICONS
password-generate
password-show-off
password-show-on
passwordmanager
preferences-desktop-icons
preferences-desktop-locale
qtcreator
sheet
story-editor
system-file-manager
system-run
system-search
window-close
)
set(REQUIRED_ICONS_FOR_KIRIGAMI
application-menu
arrow-down
dialog-close
document-decrypt
edit
folder-sync
go-next-symbolic
go-next-symbolic-rtl
go-previous-symbolic
go-previous-symbolic-rtl
go-up
handle-sort
overflow-menu
view-left-close
view-left-new
view-list-icons
view-right-close
view-right-new
window-close
window-close-symbolic
)
# find c++utilities
find_package(c++utilities 4.10.0 REQUIRED)
@ -157,6 +179,12 @@ endif()
find_package(passwordfile 3.1.0 REQUIRED)
use_password_file()
# require additional icons when using Kirigami
if(QUICK_QUI)
list(APPEND REQUIRED_ICONS ${REQUIRED_ICONS_FOR_KIRIGAMI})
list(REMOVE_DUPLICATES REQUIRED_ICONS)
endif()
# require Qt AndroidExtras
if(ANDROID AND QUICK_GUI)
list(APPEND ADDITIONAL_QT_MODULES AndroidExtras)

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<manifest package="org.martchus.passwordmanager" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.5" android:versionCode="2" android:installLocation="auto">
<application android:icon="@drawable/icon" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name">
<application android:icon="@drawable/passwordmanager_circle" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name">
<activity
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
android:name="org.martchus.passwordmanager.Activity"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -6,7 +6,6 @@
</shape>
</item>
<item>
<bitmap android:src="@drawable/icon"
android:gravity="center"/>
<bitmap android:src="@drawable/passwordmanager_black" android:gravity="center"/>
</item>
</layer-list>

View File

@ -3,7 +3,10 @@ package org.martchus.passwordmanager;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.support.v4.provider.DocumentFile;
import java.io.FileNotFoundException;
import org.qtproject.qt5.android.bindings.QtActivity;
@ -45,6 +48,14 @@ public class Activity extends QtActivity {
}
}
public void applyTheming() {
Window window = getWindow();
window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(0x000000FF);
window.setNavigationBarColor(0x000000FF);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {

View File

@ -9,22 +9,24 @@ Kirigami.ApplicationWindow {
property alias showPasswordsOnFocus: showPasswordsOnFocusSwitch.checked
header: Kirigami.ApplicationHeader {
backButtonEnabled: true
backButtonEnabled: false
minimumHeight: 0
preferredHeight: Kirigami.Units.gridUnit * 2.3
maximumHeight: Kirigami.Units.gridUnit * 3
/*
Controls.TextField {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
placeholderText: qsTr("Filter")
width: Kirigami.Units.gridUnit * 8
}
*/
}
globalDrawer: Kirigami.GlobalDrawer {
id: leftMenu
title: qsTr("Password Manager")
titleIcon: "qrc://icons/hicolor/scalable/apps/passwordmanager.svg"
titleIcon: "qrc://icons/hicolor/scalable/apps/passwordmanager-black.svg"
visible: !nativeInterface.fileOpen
topContent: ColumnLayout {
Layout.fillWidth: true
@ -87,7 +89,7 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
text: "Change password"
enabled: nativeInterface.fileOpen
iconName: "dialog-password"
iconName: "document-encrypt"
onTriggered: enterPasswordDialog.askForNewPassword(
"Change password for " + nativeInterface.filePath)
},

View File

@ -21,6 +21,11 @@ namespace QtGui {
static Controller *controllerForAndroid = nullptr;
void applyThemingForAndroid()
{
QtAndroid::androidActivity().callObjectMethod("applyTheming", "()");
}
void registerControllerForAndroid(Controller *controller)
{
controllerForAndroid = controller;

View File

@ -11,6 +11,8 @@ QT_END_NAMESPACE
namespace QtGui {
class Controller;
void applyThemingForAndroid();
void registerControllerForAndroid(Controller *controller);
bool showAndroidFileDialog(bool existing);
int openFileDescriptorFromAndroidContentUrl(const QString &url, const QString &mode);

View File

@ -98,13 +98,7 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
#ifdef Q_OS_ANDROID
QtAndroid::runOnAndroidThread([=]() {
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
window.callMethod<void>("addFlags", "(I)V", Android::WindowManager::LayoutParams::DrawsSystemBarBackgrounds);
window.callMethod<void>("clearFlags", "(I)V", Android::WindowManager::LayoutParams::TranslucentStatus);
window.callMethod<void>("setStatusBarColor", "(I)V", QColor("#2196f3").rgba());
window.callMethod<void>("setNavigationBarColor", "(I)V", QColor("#2196f3").rgba());
});
applyThemingForAndroid();
#endif
// run event loop

View File

@ -2,5 +2,6 @@
<qresource prefix="/">
<file>icons/hicolor/128x128/apps/passwordmanager.png</file>
<file>icons/hicolor/scalable/apps/passwordmanager.svg</file>
<file>icons/hicolor/scalable/apps/passwordmanager-black.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
version="1.1"
width="24"
id="svg28"
sodipodi:docname="passwordmanager-monochrome.svg"
inkscape:version="0.92.2 2405546, 2018-03-11">
<metadata
id="metadata34">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs32" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1039"
id="namedview30"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="5.5950835"
inkscape:cy="13.311248"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="1"
inkscape:current-layer="svg28" />
<path
style="fill:#000000;fill-opacity:1"
inkscape:connector-curvature="0"
id="path2"
d="M 12,3 C 9.2386,3 7,5.6 7,9 v 1 c 0,0.5 0.3731,1 0.8333,1 0.4603,0 0.8334,-0.5 0.8334,-1 V 9 c 0,-2.4 1.4923,-4.3 3.3333,-4.3 1.841,0 3.333,1.9 3.333,4.3 v 1 c 0,0.5 0.373,1 0.834,1 C 16.627,11 17,10.5 17,10 V 9 C 17,5.6 14.761,3 12,3 Z" />
<path
style="fill:#000000;fill-opacity:1"
inkscape:connector-curvature="0"
id="path4"
d="M 6,9 C 4.8954,9 4,9.9 4,11 v 7 c 0,1.1 0.8954,2 2,2 h 12 c 1.105,0 2,-0.9 2,-2 V 11 C 20,9.9 19.105,9 18,9 Z" />
<path
style="fill:#090909;fill-opacity:1"
inkscape:connector-curvature="0"
id="path6"
d="m 12,1.5 c -3.3137,0 -6,2.7 -6,6 v 1 c 0,0.6 0.4477,1 1,1 0.5523,0 1,-0.4 1,-1 v -1 c 0,-2.3 1.7909,-4.2 4,-4.2 2.209,0 4,1.9 4,4.2 v 1 c 0,0.6 0.448,1 1,1 0.552,0 1,-0.4 1,-1 v -1 c 0,-3.3 -2.686,-6 -6,-6 z" />
<path
style="fill:#0e0901;fill-opacity:1"
inkscape:connector-curvature="0"
id="path8"
d="m 6,11 c -1.1046,0 -2,0.9 -2,2 v 7 c 0,1.1 0.8954,2 2,2 h 12 c 1.105,0 2,-0.9 2,-2 v -7 c 0,-1.1 -0.895,-2 -2,-2 z" />
<path
style="fill:#000000;fill-opacity:1"
inkscape:connector-curvature="0"
id="path14"
d="M 12,2 C 8.6863,2 6,4.6 6,8 v 1 c 0,0.5 0.4477,1 1,1 0.5523,0 1,-0.5 1,-1 V 8 c 0,-2.4 1.7909,-4.3 4,-4.3 2.209,0 4,1.9 4,4.3 v 1 c 0,0.5 0.448,1 1,1 0.552,0 1,-0.5 1,-1 V 8 C 18,4.6 15.314,2 12,2 Z" />
<g
style="fill:#090909;fill-opacity:1"
id="g24"
transform="translate(0,-1028.4)">
<rect
id="rect16"
y="1041.4"
x="6"
width="12"
height="1"
style="fill:#090909;fill-opacity:1" />
<rect
id="rect18"
y="1043.4"
x="6"
width="12"
height="1"
style="fill:#090909;fill-opacity:1" />
<rect
id="rect20"
y="1045.4"
x="6"
width="12"
height="1"
style="fill:#090909;fill-opacity:1" />
<rect
id="rect22"
y="1047.4"
x="6"
width="12"
height="1"
style="fill:#090909;fill-opacity:1" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
version="1.1"
width="24"
id="svg28"
sodipodi:docname="passwordmanager-circle.svg"
inkscape:version="0.92.2 2405546, 2018-03-11"
inkscape:export-filename="/run/media/martchus/files/programming/projects/c++/cmake/passwordmanager/android/res/drawable-xhdpi/passwordmanager.png"
inkscape:export-xdpi="2048"
inkscape:export-ydpi="2048">
<metadata
id="metadata34">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs32" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1039"
id="namedview30"
showgrid="false"
inkscape:zoom="19.666667"
inkscape:cx="2.4467278"
inkscape:cy="6.3485545"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="1"
inkscape:current-layer="svg28" />
<circle
style="opacity:1;fill:#f4eed7;fill-opacity:0.98581561;fill-rule:nonzero;stroke:none;stroke-width:2.08891916;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.99954295;stroke-opacity:1;paint-order:normal"
id="path4545"
cx="12"
cy="12"
r="12" />
<path
style="fill:#7f8c8d;stroke-width:0.84084862"
inkscape:connector-curvature="0"
id="path2"
d="m 12,4.2435477 c -2.416225,0 -4.375,2.1008784 -4.375,4.848181 v 0.8080302 c 0,0.4040151 0.3264625,0.8080301 0.7291375,0.8080301 0.4027625,0 0.729225,-0.404015 0.729225,-0.8080301 V 9.0917287 C 9.0833625,7.1524563 10.389125,5.617199 12,5.617199 c 1.610875,0 2.916375,1.5352573 2.916375,3.4745297 v 0.8080302 c 0,0.4040151 0.326375,0.8080301 0.72975,0.8080301 0.4025,0 0.728875,-0.404015 0.728875,-0.8080301 V 9.0917287 c 0,-2.7473026 -1.959125,-4.848181 -4.375,-4.848181 z" />
<path
style="fill:#f9e48e;stroke-width:0.84084862;fill-opacity:1"
inkscape:connector-curvature="0"
id="path4"
d="M 6.75,9.0917287 C 5.783475,9.0917287 5,9.8189559 5,10.707789 V 16.364 c 0,0.888834 0.783475,1.616061 1.75,1.616061 h 10.5 c 0.966875,0 1.75,-0.727227 1.75,-1.616061 V 10.707789 C 19,9.8189559 18.216875,9.0917287 17.25,9.0917287 Z" />
<path
style="fill:#bdc3c7;stroke-width:0.84084862"
inkscape:connector-curvature="0"
id="path6"
d="m 12,3.0315024 c -2.8994875,0 -5.25,2.1816815 -5.25,4.8481811 v 0.8080301 c 0,0.4848182 0.3917375,0.8080302 0.875,0.8080302 0.4832625,0 0.875,-0.323212 0.875,-0.8080302 V 7.8796835 c 0,-1.8584695 1.567038,-3.3937268 3.5,-3.3937268 1.932875,0 3.5,1.5352573 3.5,3.3937268 v 0.8080301 c 0,0.4848182 0.392,0.8080302 0.875,0.8080302 0.483,0 0.875,-0.323212 0.875,-0.8080302 V 7.8796835 C 17.25,5.2131839 14.89975,3.0315024 12,3.0315024 Z" />
<path
style="fill:#f7be62;stroke-width:0.84084862;fill-opacity:1"
inkscape:connector-curvature="0"
id="path8"
d="m 6.75,10.707789 c -0.966525,0 -1.75,0.727227 -1.75,1.61606 v 5.656212 c 0,0.888833 0.783475,1.61606 1.75,1.61606 h 10.5 c 0.966875,0 1.75,-0.727227 1.75,-1.61606 v -5.656212 c 0,-0.888833 -0.783125,-1.61606 -1.75,-1.61606 z" />
<path
style="fill:#7f8c8d;stroke-width:0.84084862"
inkscape:connector-curvature="0"
id="path10"
d="m 7.036125,9.0917287 c -0.2977625,0 -0.5747875,0.080803 -0.8203125,0.1616061 0.19425,0.7272271 0.8799,1.2120452 1.6953125,1.2120452 0.8918875,0 1.614375,-0.6464241 1.7227,-1.3736513 z" />
<path
style="fill:#7f8c8d;stroke-width:0.84084862"
inkscape:connector-curvature="0"
id="path12"
d="m 17.068,9.0109257 c 0.2975,0 0.574875,0.080803 0.819875,0.2424091 C 17.693625,9.8997589 17.0085,10.46538 16.193,10.46538 c -0.8925,0 -1.614375,-0.6464241 -1.722875,-1.4544543 z" />
<path
style="fill:#95a5a6;stroke-width:0.84084862"
inkscape:connector-curvature="0"
id="path14"
d="m 12,3.4355175 c -2.8994875,0 -5.25,2.1008784 -5.25,4.8481811 v 0.8080301 c 0,0.4040151 0.3917375,0.8080302 0.875,0.8080302 0.4832625,0 0.875,-0.4040151 0.875,-0.8080302 V 8.2836986 c 0,-1.9392725 1.567038,-3.4745298 3.5,-3.4745298 1.932875,0 3.5,1.5352573 3.5,3.4745298 v 0.8080301 c 0,0.4040151 0.392,0.8080302 0.875,0.8080302 0.483,0 0.875,-0.4040151 0.875,-0.8080302 V 8.2836986 C 17.25,5.5363959 14.89975,3.4355175 12,3.4355175 Z" />
<g
style="fill:#7e430f;fill-opacity:1"
id="g24"
transform="matrix(0.875,0,0,0.80803018,1.5,-829.15878)">
<rect
id="rect16"
y="1041.4"
x="6"
width="12"
height="1"
style="fill:#7e430f;fill-opacity:1" />
<rect
id="rect18"
y="1043.4"
x="6"
width="12"
height="1"
style="fill:#7e430f;fill-opacity:1" />
<rect
id="rect20"
y="1045.4"
x="6"
width="12"
height="1"
style="fill:#7e430f;fill-opacity:1" />
<rect
id="rect22"
y="1047.4"
x="6"
width="12"
height="1"
style="fill:#7e430f;fill-opacity:1" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -1,8 +1,8 @@
[Material]
Primary=#2196F3
Accent=#2196F3
Primary=#000000
Accent=#000000
Theme=System
[Universal]
Accent=#2196F3
Accent=#000000
Theme=System