{"action":"created","issue":{"url":"https://api.github.com/repos/papyros/qml-material/issues/279","labels_url":"https://api.github.com/repos/papyros/qml-material/issues/279/labels{/name}","comments_url":"https://api.github.com/repos/papyros/qml-material/issues/279/comments","events_url":"https://api.github.com/repos/papyros/qml-material/issues/279/events","html_url":"https://github.com/papyros/qml-material/issues/279","id":106670378,"number":279,"title":"android woes","user":{"login":"glenfordwilliams","id":1114368,"avatar_url":"https://avatars.githubusercontent.com/u/1114368?v=3","gravatar_id":"","url":"https://api.github.com/users/glenfordwilliams","html_url":"https://github.com/glenfordwilliams","followers_url":"https://api.github.com/users/glenfordwilliams/followers","following_url":"https://api.github.com/users/glenfordwilliams/following{/other_user}","gists_url":"https://api.github.com/users/glenfordwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/glenfordwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glenfordwilliams/subscriptions","organizations_url":"https://api.github.com/users/glenfordwilliams/orgs","repos_url":"https://api.github.com/users/glenfordwilliams/repos","events_url":"https://api.github.com/users/glenfordwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/glenfordwilliams/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/papyros/qml-material/labels/bug","name":"bug","color":"F44336"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/papyros/qml-material/milestones/3","html_url":"https://github.com/papyros/qml-material/milestones/Version%200.1.1","labels_url":"https://api.github.com/repos/papyros/qml-material/milestones/3/labels","id":1232167,"number":3,"title":"Version 0.1.1","description":"Bug fix update before the next major release","creator":{"login":"iBeliever","id":3230912,"avatar_url":"https://avatars.githubusercontent.com/u/3230912?v=3","gravatar_id":"","url":"https://api.github.com/users/iBeliever","html_url":"https://github.com/iBeliever","followers_url":"https://api.github.com/users/iBeliever/followers","following_url":"https://api.github.com/users/iBeliever/following{/other_user}","gists_url":"https://api.github.com/users/iBeliever/gists{/gist_id}","starred_url":"https://api.github.com/users/iBeliever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iBeliever/subscriptions","organizations_url":"https://api.github.com/users/iBeliever/orgs","repos_url":"https://api.github.com/users/iBeliever/repos","events_url":"https://api.github.com/users/iBeliever/events{/privacy}","received_events_url":"https://api.github.com/users/iBeliever/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":1,"state":"open","created_at":"2015-07-29T18:39:57Z","updated_at":"2015-09-15T23:49:58Z","due_on":"2015-10-01T05:00:00Z","closed_at":null},"comments":3,"created_at":"2015-09-15T23:48:54Z","updated_at":"2015-09-16T00:17:52Z","closed_at":null,"body":"so ive been testing out some code on the android side and the first thing that popped out to me was the fact that both the actionbar and Navigationdrawer were too small as well as missing icons\r\n\r\nbefore this project started i was able to solve the scaling issues using the following code \r\n`\r\n#include <QScreen>\r\n#ifdef Q_OS_ANDROID\r\n#include <QtAndroidExtras>\r\n#endif\r\n\r\n    QScreen *screen = qApp->primaryScreen();\r\n    int dpi = screen->physicalDotsPerInch() * screen->devicePixelRatio();\r\n    bool isMobile = false;\r\n\r\n#if defined(Q_OS_IOS)\r\n    // iOS integration of scaling (retina, non-retina, 4K) does itself.\r\n    dpi = screen->physicalDotsPerInch();\r\n    isMobile = true;\r\n#elif defined(Q_OS_ANDROID)\r\n    // https://bugreports.qt-project.org/browse/QTBUG-35701\r\n    // recalculate dpi for Android\r\n\r\n    QAndroidJniEnvironment env;\r\n    QAndroidJniObject activity = QtAndroid::androidActivity();\r\n    QAndroidJniObject resources = activity.callObjectMethod(\"getResources\", \"()Landroid/content/res/Resources;\");\r\n    if (env->ExceptionCheck()) {\r\n        env->ExceptionDescribe();\r\n        env->ExceptionClear();\r\n\r\n        return EXIT_FAILURE;\r\n    }\r\n\r\n    QAndroidJniObject displayMetrics = resources.callObjectMethod(\"getDisplayMetrics\", \"()Landroid/util/DisplayMetrics;\");\r\n    if (env->ExceptionCheck()) {\r\n        env->ExceptionDescribe();\r\n        env->ExceptionClear();\r\n\r\n        return EXIT_FAILURE;\r\n    }\r\n    dpi = displayMetrics.getField<int>(\"densityDpi\");\r\n    isMobile = true;\r\n#else\r\n    // standard dpi\r\n    dpi = screen->logicalDotsPerInch() * screen->devicePixelRatio();\r\n#endif\r\n\r\n    // now calculate the dp ratio\r\n    qreal dp = dpi / 160.f;\r\n\r\n    QQmlApplicationEngine engine;\r\n    QQmlContext *context = engine.rootContext();\r\n    context->setContextProperty(QStringLiteral(\"utils\"), new Utils(&engine));\r\n    context->setContextProperty(QStringLiteral(\"initialUrl\"),\r\n                                Utils::fromUserInput(initialUrl));\r\n    \r\n    QRect geometry = QGuiApplication::primaryScreen()->availableGeometry();\r\n    if (!QGuiApplication::styleHints()->showIsFullScreen()) {\r\n        const QSize size = geometry.size() * 4 / 5;\r\n        const QSize offset = (geometry.size() - size) / 2;\r\n        const QPoint pos = geometry.topLeft() + QPoint(offset.width(), offset.height());\r\n        geometry = QRect(pos, size);\r\n    }\r\n\r\n    context->setContextProperty(\"dp\", dp);\r\n        context->setContextProperty(\"isMobile\", isMobile);\r\n    context->setContextProperty(QStringLiteral(\"initialX\"), geometry.x());\r\n    context->setContextProperty(QStringLiteral(\"initialY\"), geometry.y());\r\n    context->setContextProperty(QStringLiteral(\"initialWidth\"), geometry.width());\r\n    context->setContextProperty(QStringLiteral(\"initialHeight\"), geometry.height());\r\n`\r\n\r\n![screenshot_2015-09-15-17-28-02](https://cloud.githubusercontent.com/assets/1114368/9892834/3970f6e4-5bd8-11e5-80b5-8ebee1163566.png)\r\n![screenshot_2015-09-15-17-28-13](https://cloud.githubusercontent.com/assets/1114368/9892833/39704366-5bd8-11e5-86dc-189775560b54.png)\r\n![screenshot_2015-09-15-17-28-16](https://cloud.githubusercontent.com/assets/1114368/9892835/3974a08c-5bd8-11e5-9518-6488c0bc484a.png)\r\n![screenshot_2015-09-15-18-01-35](https://cloud.githubusercontent.com/assets/1114368/9892836/39768fc8-5bd8-11e5-9a30-a67c77476fea.png)\r\n![screenshot_2015-09-15-17-27-52](https://cloud.githubusercontent.com/assets/1114368/9892837/3978365c-5bd8-11e5-9f8c-b5a7f19fd7d3.png)\r\n\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26715901-android-woes?utm_campaign=plugin&utm_content=tracker%2F7838182&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F7838182&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/papyros/qml-material/issues/comments/140585841","html_url":"https://github.com/papyros/qml-material/issues/279#issuecomment-140585841","issue_url":"https://api.github.com/repos/papyros/qml-material/issues/279","id":140585841,"user":{"login":"glenfordwilliams","id":1114368,"avatar_url":"https://avatars.githubusercontent.com/u/1114368?v=3","gravatar_id":"","url":"https://api.github.com/users/glenfordwilliams","html_url":"https://github.com/glenfordwilliams","followers_url":"https://api.github.com/users/glenfordwilliams/followers","following_url":"https://api.github.com/users/glenfordwilliams/following{/other_user}","gists_url":"https://api.github.com/users/glenfordwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/glenfordwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glenfordwilliams/subscriptions","organizations_url":"https://api.github.com/users/glenfordwilliams/orgs","repos_url":"https://api.github.com/users/glenfordwilliams/repos","events_url":"https://api.github.com/users/glenfordwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/glenfordwilliams/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T00:17:52Z","updated_at":"2015-09-16T00:17:52Z","body":"This screen looked way smaller mine\n"}}