Skip to content

Commit

Permalink
Update to Android 10 and Qt 5.15
Browse files Browse the repository at this point in the history
Bug fix: load ssystem_1000comets.ini

New functionality: user-defined solar system objects
  • Loading branch information
chengxinlun committed Jun 23, 2020
1 parent e7a9955 commit d0aa53e
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 92 deletions.
91 changes: 64 additions & 27 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,54 +1,91 @@
<?xml version="1.0"?>
<manifest package="com.noctuasoftware.stellarium" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.29.6_m" android:versionCode="24" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name" android:launchMode="singleTop">
<manifest package="com.noctuasoftware.stellarium" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.29.6_m_1" android:versionCode="25" android:installLocation="auto">
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->

<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->

<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name" android:extractNativeLibs="true" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->

<meta-data android:name="android.app.lib_name" android:value="stellarium"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>

<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so:plugins/bearer/libqandroidbearer.so:plugins/sensors/libqtsensors_android.so:plugins/position/libqtposition_android.so"/>
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidAccessibility.jar:jar/QtAndroid-bundled.jar:jar/QtAndroidAccessibility-bundled.jar:jar/QtAndroidBearer.jar:jar/QtAndroidBearer-bundled.jar:jar/QtSensors.jar:jar/QtSensors-bundled.jar:jar/QtPositioning.jar:jar/QtPositioning-bundled.jar"/>
<meta-data android:name="android.app.static_init_classes" android:value="org.qtproject.qt5.android.sensors.QtSensors:org.qtproject.qt5.android.sensors.QtSensors:org.qtproject.qt5.android.positioning.QtPositioning:org.qtproject.qt5.android.positioning.QtPositioning"/>
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->

<!-- Splash screen -->
<!--
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
-->
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
are done populating your window with content. -->
<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
</activity>

<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->

<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->

<!-- extract android style -->
<!-- available android:values :
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>

<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->

</application>
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<uses-feature android:glEsVersion="0x00020000"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/>
<uses-feature android:name="android.hardware.location" android:required="false"/>
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>
<uses-feature android:name="android.hardware.location.network" android:required="false"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="29"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:required="false"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>



</manifest>
27 changes: 19 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.6.0'
}
}

allprojects {
repositories {
jcenter()
}
repositories {
google()
jcenter()
}

apply plugin: 'com.android.application'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}

android {
Expand All @@ -36,15 +36,15 @@ android {

compileSdkVersion androidCompileSdkVersion.toInteger()

buildToolsVersion androidBuildToolsVersion
buildToolsVersion '28.0.3'

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
Expand All @@ -54,4 +54,15 @@ android {
lintOptions {
abortOnError false
}

// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}

defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
}
9 changes: 0 additions & 9 deletions android/gradle.properties

This file was deleted.

9 changes: 0 additions & 9 deletions android/gradle.properties~

This file was deleted.

Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Feb 20 10:43:22 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-bin.zip
8 changes: 4 additions & 4 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="-Xmx1024m -Dfile.encoding=UTF-8"
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Xmx1024m -Dfile.encoding=UTF-8
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
6 changes: 0 additions & 6 deletions android/local.properties

This file was deleted.

6 changes: 0 additions & 6 deletions android/local.properties~

This file was deleted.

15 changes: 6 additions & 9 deletions android/res/values/libs.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.10</item>
<item>https://download.qt.io/ministro/android/qt5/qt-5.14</item>
</array>

<!-- The following is handled automatically by the deployment tool. It should
Expand All @@ -11,15 +11,12 @@
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>

<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>

<array name="bundled_in_lib">
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="bundled_in_assets">
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->

<array name="load_local_libs">
<!-- %%INSERT_LOCAL_LIBS%% -->
</array>

</resources>
1 change: 0 additions & 1 deletion android/src/com/noctuasoftware/stellarium/Stellarium.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ public int getRotation() {
return display.getRotation();
}
};

76 changes: 70 additions & 6 deletions src/core/modules/SolarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ void SolarSystem::loadPlanets()
qWarning() << "ERROR while loading ssystem_minor.ini (unable to find data/ssystem_minor.ini): " << endl;
return;
}

foreach (const QString& solarSystemFile, solarSystemFiles)
{
if (loadPlanets(solarSystemFile))
Expand Down Expand Up @@ -284,11 +283,76 @@ void SolarSystem::loadPlanets()
}
}

shadowPlanetCount = 0;

foreach (const PlanetP& planet, systemPlanets)
if(planet->parent != sun || !planet->satellites.isEmpty())
shadowPlanetCount++;
// Modified: load 1000 comets file (Cheng Xinlun, Jun 23 2020)
qDebug() << "Loading Solar System data (3: 1000 comets)";
QStringList solarSystemCometFiles = StelFileMgr::findFileInAllPaths("data/ssystem_1000comets.ini");
if (solarSystemCometFiles.isEmpty())
{
qWarning() << "ERROR while loading ssystem_1000comets.ini (unable to find data/ssystem_1000comets.ini):" << Qt::endl;
return;
}
foreach (const QString& solarSystemFile, solarSystemCometFiles)
{
if (loadPlanets(solarSystemFile))
{
qDebug() << "File ssystem_1000comets.ini is loaded successfully...";
break;
}
else
{
qDebug() << "Removing comets";
foreach (PlanetP p, systemPlanets)
{
p->satellites.clear();
p.clear();
}
systemPlanets.clear();
if (solarSystemFile.contains(StelFileMgr::getUserDir()))
{
QString newName = QString("%1/data/ssystem-%2.ini").arg(StelFileMgr::getUserDir()).arg(QDateTime::currentDateTime().toString("yyyyMMddThhmmss"));
if (QFile::rename(solarSystemFile, newName))
qWarning() << "Invalid Solar System file" << QDir::toNativeSeparators(solarSystemFile) << "has been renamed to" << QDir::toNativeSeparators(newName);
else
{
qWarning() << "Invalid Solar System file" << QDir::toNativeSeparators(solarSystemFile) << "cannot be removed!";
qWarning() << "Please either delete it, rename it or move it elsewhere.";
}
}
}
}

// Modified: load user solar system object file (Cheng Xinlun, Jun 23 2020)
qDebug() << "Loading Solar System data (4: user-defined solar system objects)";
QStringList solarSystemUserFiles = StelFileMgr::findFileInAllPaths("data/ssystem_user.ini", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::File));
if (solarSystemUserFiles.isEmpty())
{
qWarning() << "ERROR while loading ssystem_user.ini (unable to find data/ssystem_user.ini):" << Qt::endl;
return;
}
foreach (const QString& solarSystemFile, solarSystemUserFiles)
{
if (loadPlanets(solarSystemFile))
{
qDebug() << "File ssystem_user.ini is loaded successfully...";
break;
}
else
{
qDebug() << "Removing user-defined bodies";
foreach (PlanetP p, systemPlanets)
{
p->satellites.clear();
p.clear();
}
systemPlanets.clear();
}
}

shadowPlanetCount = 0;

foreach (const PlanetP& planet, systemPlanets)
if(planet->parent != sun || !planet->satellites.isEmpty())
shadowPlanetCount++;
}

bool SolarSystem::loadPlanets(const QString& filePath)
Expand Down
Loading

0 comments on commit d0aa53e

Please sign in to comment.