Skip to content

Commit

Permalink
Set status bar color for lollipop with Qt5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Iktwo committed Feb 5, 2015
1 parent ad81685 commit 868f353
Show file tree
Hide file tree
Showing 31 changed files with 98 additions and 117 deletions.
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="com.iktwo.musicgear" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.9.8" android:versionCode="22" android:installLocation="auto">
<manifest package="com.iktwo.musicgear" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.9.9" android:versionCode="23" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Musicgear" android:icon="@drawable/icon" android:theme="@style/AppTheme">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.iktwo.musicgear.MusicGear" android:label="Musicgear" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
Expand Down
2 changes: 1 addition & 1 deletion android/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">#0066CC</item>
<item name="android:colorPrimary">#005CB8</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#005CB8</item>
</style>
Expand Down
40 changes: 36 additions & 4 deletions android/src/org/qtproject/qt5/android/bindings/QtActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
import android.view.ActionMode.Callback;
//@ANDROID-11

import com.iktwo.musicgear.R;

public class QtActivity extends Activity
{
private final static int MINISTRO_INSTALL_REQUEST_CODE = 0xf3ee; // request code used to know when Ministro instalation is finished
private static final int MINISTRO_API_LEVEL = 4; // Ministro api level (check IMinistro.aidl file)
private static final int MINISTRO_API_LEVEL = 5; // Ministro api level (check IMinistro.aidl file)
private static final int NECESSITAS_API_LEVEL = 2; // Necessitas api level used by platform plugin
private static final int QT_VERSION = 0x050100; // This app requires at least Qt version 5.1.0

Expand All @@ -117,6 +118,7 @@ public class QtActivity extends Activity
private static final String MAIN_LIBRARY_KEY = "main.library";
private static final String STATIC_INIT_CLASSES_KEY = "static.init.classes";
private static final String NECESSITAS_API_LEVEL_KEY = "necessitas.api.level";
private static final String EXTRACT_STYLE_KEY = "extract.android.style";

/// Ministro server parameter keys
private static final String REQUIRED_MODULES_KEY = "required.modules";
Expand Down Expand Up @@ -178,14 +180,15 @@ public class QtActivity extends Activity
// * unstable - unstable repository, DO NOT use this repository in production,
// this repository is used to push Qt snapshots.
private String[] m_qtLibs = null; // required qt libs
private int m_displayDensity = -1;

public QtActivity()
{
if (Build.VERSION.SDK_INT <= 10) {
QT_ANDROID_THEMES = new String[] {"Theme_Light"};
QT_ANDROID_DEFAULT_THEME = "Theme_Light";
}
else if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 13) {
else if ((Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 13) || Build.VERSION.SDK_INT == 21){
QT_ANDROID_THEMES = new String[] {"Theme_Holo_Light"};
QT_ANDROID_DEFAULT_THEME = "Theme_Holo_Light";
} else {
Expand Down Expand Up @@ -630,6 +633,15 @@ private void startApp(final boolean firstStart)
m_activityInfo.metaData.getString("android.app.static_init_classes").split(":"));
}
loaderParams.putStringArrayList(NATIVE_LIBRARIES_KEY, libraryList);


String themePath = getApplicationInfo().dataDir + "/qt-reserved-files/android-style/";
String stylePath = themePath + m_displayDensity + "/";
if (!(new File(stylePath)).exists())
loaderParams.putString(EXTRACT_STYLE_KEY, stylePath);
ENVIRONMENT_VARIABLES += "\tMINISTRO_ANDROID_STYLE_PATH=" + stylePath
+ "\tQT_ANDROID_THEMES_ROOT_PATH=" + themePath;

loaderParams.putString(ENVIRONMENT_VARIABLES_KEY, ENVIRONMENT_VARIABLES
+ "\tQML2_IMPORT_PATH=" + pluginsPrefix + "/qml"
+ "\tQML_IMPORT_PATH=" + pluginsPrefix + "/imports"
Expand Down Expand Up @@ -835,13 +847,24 @@ public void onCreate(Bundle savedInstanceState)

try {
m_activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
setTheme(m_activityInfo.getThemeResource());
for (Field f : Class.forName("android.R$style").getDeclaredFields()) {
if (f.getInt(null) == m_activityInfo.getThemeResource()) {
QT_ANDROID_THEMES = new String[] {f.getName()};
QT_ANDROID_DEFAULT_THEME = f.getName();
}
}
} catch (Exception e) {
e.printStackTrace();
finish();
return;
}

try {
setTheme(R.style.AppTheme);
} catch (Exception e) {
e.printStackTrace();
}

if (Build.VERSION.SDK_INT > 10) {
try {
requestWindowFeature(Window.class.getField("FEATURE_ACTION_BAR").getInt(null));
Expand All @@ -857,15 +880,24 @@ public void onCreate(Bundle savedInstanceState)
return;
}

m_displayDensity = getResources().getDisplayMetrics().densityDpi;

ENVIRONMENT_VARIABLES += "\tQT_ANDROID_THEME=" + QT_ANDROID_DEFAULT_THEME
+ "/\tQT_ANDROID_THEME_DISPLAY_DPI=" + getResources().getDisplayMetrics().densityDpi + "\t";
+ "/\tQT_ANDROID_THEME_DISPLAY_DPI=" + m_displayDensity + "\t";

if (null == getLastNonConfigurationInstance()) {
// if splash screen is defined, then show it
if (m_activityInfo.metaData.containsKey("android.app.splash_screen_drawable"))
getWindow().setBackgroundDrawableResource(m_activityInfo.metaData.getInt("android.app.splash_screen_drawable"));
else
getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));

if (m_activityInfo.metaData.containsKey("android.app.background_running")
&& m_activityInfo.metaData.getBoolean("android.app.background_running")) {
ENVIRONMENT_VARIABLES += "QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED=0\t";
} else {
ENVIRONMENT_VARIABLES += "QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED=1\t";
}
startApp(true);
}
}
Expand Down
5 changes: 5 additions & 0 deletions musicgear.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ TRANSLATIONS += translations/translation_es.ts
lupdate_only{
SOURCES = qml/*.qml
}

DISTFILES += \
android/res/values-v21/styles.xml \
android/res/values/screen_data.xml \
android/src/org/qtproject/qt5/android/bindings/QtActivity.java
2 changes: 1 addition & 1 deletion qml/PlaylistDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Item {

elide: Text.ElideRight
color: Style.TEXT_SECONDARY_COLOR_DARK
text: model.length
text: model.artist + " - " + model.length
width: parent.width
renderType: Text.NativeRendering
}
Expand Down
43 changes: 30 additions & 13 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ ApplicationWindow {
id: applicationWindow

property var resolutions: [
{"height": 480, "width": 320, "name": "HVGA", "ratio": "3:2"},
{"height": 640, "width": 360, "name": "nHD", "ratio": "16:9"},
{"height": 640, "width": 480, "name": "VGA", "ratio": "4:3"},
{"height": 800, "width": 480, "name": "WVGA", "ratio": "5:3"},
{"height": 800, "width": 600, "name": "SVGA", "ratio": "4:3"},
{"height": 960, "width": 540, "name": "qHD", "ratio": "16:9"},
{"height": 1280, "width": 720, "name": "720p", "ratio": "16:9"},
{"height": 1280, "width": 800, "name": "WXGA", "ratio": "16:10"},
{"height": 1920, "width": 1080, "name": "1080p", "ratio": "16:9"}
{"height": 480, "width": 320, "name": "HVGA", "ratio": "3:2" },
{"height": 640, "width": 360, "name": "nHD", "ratio": "16:9" },
{"height": 640, "width": 480, "name": "VGA", "ratio": "4:3" },
{"height": 800, "width": 480, "name": "WVGA", "ratio": "5:3" },
{"height": 800, "width": 600, "name": "SVGA", "ratio": "4:3" },
{"height": 960, "width": 540, "name": "qHD", "ratio": "16:9" },
{"height": 1280, "width": 720, "name": "720p", "ratio": "16:9" },
{"height": 1280, "width": 800, "name": "WXGA", "ratio": "16:10" },
{"height": 1920, "width": 1080, "name": "1080p", "ratio": "16:9" }
]

property int currentResolution: 3
Expand Down Expand Up @@ -49,13 +49,30 @@ ApplicationWindow {
width: resolutions[currentResolution]["width"]
height: resolutions[currentResolution]["height"]

FontLoader { source: "qrc:/fonts/Muli-Italic" }
FontLoader { source: "qrc:/fonts/Muli-Light" }
FontLoader { source: "qrc:/fonts/Muli-Light" }


FontLoader { source: "qrc:/fonts/Roboto-Black" }
FontLoader { source: "qrc:/fonts/Roboto-BlackItalic" }
FontLoader { source: "qrc:/fonts/Roboto-Bold" }
FontLoader { source: "qrc:/fonts/Roboto-BoldItalic" }
FontLoader { source: "qrc:/fonts/RobotoCondensed-Bold" }
FontLoader { source: "qrc:/fonts/RobotoCondensed-BoldItalic" }
FontLoader { source: "qrc:/fonts/RobotoCondensed-Italic" }
FontLoader { source: "qrc:/fonts/RobotoCondensed-Light" }
FontLoader { source: "qrc:/fonts/RobotoCondensed-LightItalic" }
FontLoader { source: "qrc:/fonts/RobotoCondensed-Regular" }
FontLoader { source: "qrc:/fonts/Roboto-Italic" }
FontLoader { source: "qrc:/fonts/Roboto-Light" }
FontLoader { source: "qrc:/fonts/Roboto-LightItalic" }
FontLoader { source: "qrc:/fonts/Roboto-Medium" }
FontLoader { source: "qrc:/fonts/Roboto-MediumItalic" }
FontLoader { source: "qrc:/fonts/Roboto-Thin" }
FontLoader { source: "qrc:/fonts/Roboto-ThinItalic" }

FontLoader {
id: font

source: "qrc:/fonts/Muli-Regular"
source: "qrc:/fonts/Roboto-Regular"
onStatusChanged: {
if (status === FontLoader.Ready)
Theme.fontFamily = font.name
Expand Down
22 changes: 18 additions & 4 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,23 @@
<file alias="add_to_playlist">resources/images/drawable-xxxhdpi/add_to_playlist.png</file>
</qresource>
<qresource prefix="/fonts">
<file alias="Muli-Italic">resources/fonts/Muli-Italic.ttf</file>
<file alias="Muli-Light">resources/fonts/Muli-Light.ttf</file>
<file alias="Muli-LightItalic">resources/fonts/Muli-LightItalic.ttf</file>
<file alias="Muli-Regular">resources/fonts/Muli-Regular.ttf</file>
<file alias="Roboto-Black">resources/fonts/Roboto-Black.ttf</file>
<file alias="Roboto-BlackItalic">resources/fonts/Roboto-BlackItalic.ttf</file>
<file alias="Roboto-Bold">resources/fonts/Roboto-Bold.ttf</file>
<file alias="Roboto-BoldItalic">resources/fonts/Roboto-BoldItalic.ttf</file>
<file alias="RobotoCondensed-Bold">resources/fonts/RobotoCondensed-Bold.ttf</file>
<file alias="RobotoCondensed-BoldItalic">resources/fonts/RobotoCondensed-BoldItalic.ttf</file>
<file alias="RobotoCondensed-Italic">resources/fonts/RobotoCondensed-Italic.ttf</file>
<file alias="RobotoCondensed-Light">resources/fonts/RobotoCondensed-Light.ttf</file>
<file alias="RobotoCondensed-LightItalic">resources/fonts/RobotoCondensed-LightItalic.ttf</file>
<file alias="RobotoCondensed-Regular">resources/fonts/RobotoCondensed-Regular.ttf</file>
<file alias="Roboto-Italic">resources/fonts/Roboto-Italic.ttf</file>
<file alias="Roboto-Light">resources/fonts/Roboto-Light.ttf</file>
<file alias="Roboto-LightItalic">resources/fonts/Roboto-LightItalic.ttf</file>
<file alias="Roboto-Medium">resources/fonts/Roboto-Medium.ttf</file>
<file alias="Roboto-MediumItalic">resources/fonts/Roboto-MediumItalic.ttf</file>
<file alias="Roboto-Regular">resources/fonts/Roboto-Regular.ttf</file>
<file alias="Roboto-Thin">resources/fonts/Roboto-Thin.ttf</file>
<file alias="Roboto-ThinItalic">resources/fonts/Roboto-ThinItalic.ttf</file>
</qresource>
</RCC>
Binary file removed resources/fonts/Muli-Italic.ttf
Binary file not shown.
Binary file removed resources/fonts/Muli-Light.ttf
Binary file not shown.
Binary file removed resources/fonts/Muli-LightItalic.ttf
Binary file not shown.
Binary file removed resources/fonts/Muli-Regular.ttf
Binary file not shown.
93 changes: 0 additions & 93 deletions resources/fonts/OFL.txt

This file was deleted.

Binary file added resources/fonts/Roboto-Black.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-BlackItalic.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-Bold.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-BoldItalic.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-Italic.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-Light.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-LightItalic.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-Medium.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-MediumItalic.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-Regular.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-Thin.ttf
Binary file not shown.
Binary file added resources/fonts/Roboto-ThinItalic.ttf
Binary file not shown.
Binary file added resources/fonts/RobotoCondensed-Bold.ttf
Binary file not shown.
Binary file added resources/fonts/RobotoCondensed-BoldItalic.ttf
Binary file not shown.
Binary file added resources/fonts/RobotoCondensed-Italic.ttf
Binary file not shown.
Binary file added resources/fonts/RobotoCondensed-Light.ttf
Binary file not shown.
Binary file added resources/fonts/RobotoCondensed-LightItalic.ttf
Binary file not shown.
Binary file added resources/fonts/RobotoCondensed-Regular.ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions src/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ void Downloader::downloadFinished(QNetworkReply *reply)
return;
}

if (url.toString() == ("http://www.goear.com/billboard/maintenance")) {
setDownloading(false);
emit searchEnded();
}


qDebug() << reply->url().toString() << " was redirected to:" << url.toString();

if (url.isRelative())
Expand Down

0 comments on commit 868f353

Please sign in to comment.