From b2e10a10e47f4540fad1e609469dd5fff87002c5 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Fri, 13 Mar 2015 16:19:59 +0100 Subject: [PATCH] Update to gradle build structure --- .gitmodules | 4 +- UnifiedNlpApi | 1 - build.gradle | 74 +----------------- extern/UnifiedNlpApi | 1 + settings.gradle | 5 +- .../nlp/ui/SettingsLauncherActivity.java | 30 ------- unifiednlp-api | 1 + unifiednlp-app/build.gradle | 52 ++++++++++++ unifiednlp-app/src/main/AndroidManifest.xml | 41 ++++++++++ .../nlp/ui/SettingsLauncherActivity.java | 55 +++++++++++++ unifiednlp-base/build.gradle | 38 +++++++++ .../src/main/AndroidManifest.xml | 23 +----- .../v4/preference/PreferenceFragment.java | 0 .../org/microg/nlp/AbstractBackendHelper.java | 0 .../microg/nlp/AbstractProviderService.java | 0 .../java}/org/microg/nlp/PackageReceiver.java | 0 .../java}/org/microg/nlp/Preferences.java | 0 .../main/java}/org/microg/nlp/Provider.java | 0 .../nlp/geocode/AbstractGeocodeService.java | 0 .../org/microg/nlp/geocode/BackendFuser.java | 0 .../org/microg/nlp/geocode/BackendHelper.java | 0 .../microg/nlp/geocode/GeocodeProvider.java | 0 .../microg/nlp/geocode/GeocodeProviderV1.java | 0 .../microg/nlp/geocode/GeocodeServiceV1.java | 0 .../nlp/location/AbstractLocationService.java | 14 ++-- .../org/microg/nlp/location/BackendFuser.java | 0 .../microg/nlp/location/BackendHelper.java | 0 .../microg/nlp/location/LocationProvider.java | 0 .../nlp/location/LocationProviderV1.java | 0 .../nlp/location/LocationProviderV2.java | 0 .../nlp/location/LocationServiceV1.java | 0 .../nlp/location/LocationServiceV2.java | 0 .../org/microg/nlp/location/ThreadHelper.java | 0 .../nlp/ui/AbstractBackendPreference.java | 0 .../nlp/ui/GeocoderBackendPreference.java | 0 .../nlp/ui/LocationBackendPreference.java | 0 .../microg/nlp/ui/SettingInjectorService.java | 30 ++++--- .../org/microg/nlp/ui/SettingsActivity.java | 0 .../main/res}/drawable-hdpi/ic_nlp_app.png | Bin .../res}/drawable-hdpi/ic_nlp_settings.png | Bin .../src/main/res}/drawable-hdpi/info.png | Bin .../src/main/res}/drawable-hdpi/settings.png | Bin .../main/res}/drawable-mdpi/ic_nlp_app.png | Bin .../res}/drawable-mdpi/ic_nlp_settings.png | Bin .../src/main/res}/drawable-mdpi/info.png | Bin .../src/main/res}/drawable-mdpi/settings.png | Bin .../main/res}/drawable-xhdpi/ic_nlp_app.png | Bin .../res}/drawable-xhdpi/ic_nlp_settings.png | Bin .../src/main/res}/drawable-xhdpi/info.png | Bin .../src/main/res}/drawable-xhdpi/settings.png | Bin .../main/res}/drawable-xxhdpi/ic_nlp_app.png | Bin .../res}/drawable-xxhdpi/ic_nlp_settings.png | Bin .../src/main/res}/drawable-xxhdpi/info.png | Bin .../main/res}/drawable-xxhdpi/settings.png | Bin .../main/res}/drawable-xxxhdpi/ic_nlp_app.png | Bin .../res}/drawable-xxxhdpi/ic_nlp_settings.png | Bin .../src/main/res}/drawable-xxxhdpi/info.png | Bin .../main/res}/drawable-xxxhdpi/settings.png | Bin .../main/res}/layout/backend_list_entry.xml | 0 .../main/res}/layout/settings_activity.xml | 0 .../src/main/res}/values-v21/themes.xml | 0 .../src/main/res}/values/colors.xml | 0 .../src/main/res}/values/strings.xml | 0 .../src/main/res}/values/themes.xml | 0 .../main/res}/xml/nlp_injected_setting.xml | 0 .../src/main/res}/xml/nlp_preferences.xml | 0 {compat => unifiednlp-compat}/build.gradle | 4 +- .../android/location/GeocoderParams.java | 0 .../current}/android/location/Geofence.java | 0 .../current}/android/location/Location.java | 0 .../android/location/LocationManager.java | 0 .../android/location/LocationRequest.java | 0 .../internal/location/ProviderProperties.java | 0 .../internal/location/ProviderRequest.java | 0 .../location/provider/GeocodeProvider.java | 0 .../provider/LocationProviderBase.java | 0 .../provider/LocationRequestUnbundled.java | 0 .../provider/ProviderPropertiesUnbundled.java | 0 .../provider/ProviderRequestUnbundled.java | 0 .../src}/v9/Android.mk | 0 .../location/provider/LocationProvider.java | 0 81 files changed, 228 insertions(+), 145 deletions(-) delete mode 160000 UnifiedNlpApi create mode 160000 extern/UnifiedNlpApi delete mode 100644 src/org/microg/nlp/ui/SettingsLauncherActivity.java create mode 120000 unifiednlp-api create mode 100644 unifiednlp-app/build.gradle create mode 100644 unifiednlp-app/src/main/AndroidManifest.xml create mode 100644 unifiednlp-app/src/main/java/org/microg/nlp/ui/SettingsLauncherActivity.java create mode 100644 unifiednlp-base/build.gradle rename AndroidManifest.xml => unifiednlp-base/src/main/AndroidManifest.xml (87%) rename {src => unifiednlp-base/src/main/java}/android/support/v4/preference/PreferenceFragment.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/AbstractBackendHelper.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/AbstractProviderService.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/PackageReceiver.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/Preferences.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/Provider.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/geocode/AbstractGeocodeService.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/geocode/BackendFuser.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/geocode/BackendHelper.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/geocode/GeocodeProvider.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/geocode/GeocodeProviderV1.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/geocode/GeocodeServiceV1.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/AbstractLocationService.java (88%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/BackendFuser.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/BackendHelper.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/LocationProvider.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/LocationProviderV1.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/LocationProviderV2.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/LocationServiceV1.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/LocationServiceV2.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/location/ThreadHelper.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/ui/AbstractBackendPreference.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/ui/GeocoderBackendPreference.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/ui/LocationBackendPreference.java (100%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/ui/SettingInjectorService.java (74%) rename {src => unifiednlp-base/src/main/java}/org/microg/nlp/ui/SettingsActivity.java (100%) rename {res => unifiednlp-base/src/main/res}/drawable-hdpi/ic_nlp_app.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-hdpi/ic_nlp_settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-hdpi/info.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-hdpi/settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-mdpi/ic_nlp_app.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-mdpi/ic_nlp_settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-mdpi/info.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-mdpi/settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xhdpi/ic_nlp_app.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xhdpi/ic_nlp_settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xhdpi/info.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xhdpi/settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxhdpi/ic_nlp_app.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxhdpi/ic_nlp_settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxhdpi/info.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxhdpi/settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxxhdpi/ic_nlp_app.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxxhdpi/ic_nlp_settings.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxxhdpi/info.png (100%) rename {res => unifiednlp-base/src/main/res}/drawable-xxxhdpi/settings.png (100%) rename {res => unifiednlp-base/src/main/res}/layout/backend_list_entry.xml (100%) rename {res => unifiednlp-base/src/main/res}/layout/settings_activity.xml (100%) rename {res => unifiednlp-base/src/main/res}/values-v21/themes.xml (100%) rename {res => unifiednlp-base/src/main/res}/values/colors.xml (100%) rename {res => unifiednlp-base/src/main/res}/values/strings.xml (100%) rename {res => unifiednlp-base/src/main/res}/values/themes.xml (100%) rename {res => unifiednlp-base/src/main/res}/xml/nlp_injected_setting.xml (100%) rename {res => unifiednlp-base/src/main/res}/xml/nlp_preferences.xml (100%) rename {compat => unifiednlp-compat}/build.gradle (91%) rename {compat/current/src => unifiednlp-compat/src/current}/android/location/GeocoderParams.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/android/location/Geofence.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/android/location/Location.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/android/location/LocationManager.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/android/location/LocationRequest.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/internal/location/ProviderProperties.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/internal/location/ProviderRequest.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/location/provider/GeocodeProvider.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/location/provider/LocationProviderBase.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/location/provider/LocationRequestUnbundled.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/location/provider/ProviderPropertiesUnbundled.java (100%) rename {compat/current/src => unifiednlp-compat/src/current}/com/android/location/provider/ProviderRequestUnbundled.java (100%) rename {compat => unifiednlp-compat/src}/v9/Android.mk (100%) rename {compat/v9/src => unifiednlp-compat/src/v9}/com/android/location/provider/LocationProvider.java (100%) diff --git a/.gitmodules b/.gitmodules index 96a48ae..c4c91f7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "UnifiedNlpApi"] - path = UnifiedNlpApi +[submodule "extern/UnifiedNlpApi"] + path = extern/UnifiedNlpApi url = https://github.com/microg/android_external_UnifiedNlpApi.git diff --git a/UnifiedNlpApi b/UnifiedNlpApi deleted file mode 160000 index 06d1132..0000000 --- a/UnifiedNlpApi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 06d1132344b4600ae00bda63d4da0acff7de42f0 diff --git a/build.gradle b/build.gradle index c08eb1b..495c503 100644 --- a/build.gradle +++ b/build.gradle @@ -1,73 +1 @@ -/* - Copyright 2013-2015 µg Project Team - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.0.0' - } -} - -final boolean buildNlpAsLib = name.equals('UnifiedNlpLib') - -if (buildNlpAsLib) { - apply plugin: 'com.android.library' -} else { - apply plugin: 'com.android.application' -} - -dependencies { - compile 'com.android.support:support-v4:21.0.3' - compile 'com.android.support:appcompat-v7:21.0.3' - compile project(':UnifiedNlpApi') - provided project('compat') -} - -android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" - lintOptions.abortOnError false - - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src'] - aidl.srcDirs = ['src'] - res.srcDirs = ['res'] - } - } - - if (!buildNlpAsLib) { - productFlavors { - NetworkLocation { - applicationId = 'com.google.android.gms' - minSdkVersion 19 - } - LegacyNetworkLocation { - applicationId = 'com.google.android.location' - } - UnifiedNlp { - applicationId = 'org.microg.nlp' - } - } - } -} - -if (file('user.gradle').exists()) { - apply from: 'user.gradle' -} +// Top-level build file where you can add configuration options common to all sub-projects/modules. diff --git a/extern/UnifiedNlpApi b/extern/UnifiedNlpApi new file mode 160000 index 0000000..caa1b95 --- /dev/null +++ b/extern/UnifiedNlpApi @@ -0,0 +1 @@ +Subproject commit caa1b952b320c21e34357a1442c858ac775a1e15 diff --git a/settings.gradle b/settings.gradle index 77bd5ab..cc79756 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,4 @@ -include ':compat', ':UnifiedNlpApi' +include ':unifiednlp-compat' +include ':unifiednlp-api' +include ':unifiednlp-base' +include ':unifiednlp-app' diff --git a/src/org/microg/nlp/ui/SettingsLauncherActivity.java b/src/org/microg/nlp/ui/SettingsLauncherActivity.java deleted file mode 100644 index 56381a4..0000000 --- a/src/org/microg/nlp/ui/SettingsLauncherActivity.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013-2015 µg Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.microg.nlp.ui; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; - -public class SettingsLauncherActivity extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - startActivity(new Intent(this, SettingsActivity.class)); - finish(); - } -} diff --git a/unifiednlp-api b/unifiednlp-api new file mode 120000 index 0000000..c6bf4ca --- /dev/null +++ b/unifiednlp-api @@ -0,0 +1 @@ +extern/UnifiedNlpApi/unifiednlp-api \ No newline at end of file diff --git a/unifiednlp-app/build.gradle b/unifiednlp-app/build.gradle new file mode 100644 index 0000000..e84cd45 --- /dev/null +++ b/unifiednlp-app/build.gradle @@ -0,0 +1,52 @@ +/* + Copyright 2013-2015 µg Project Team + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.1.3' + } +} + +apply plugin: 'com.android.application' + +dependencies { + compile project(':unifiednlp-base') +} + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.0" + + productFlavors { + NetworkLocation { + applicationId = 'com.google.android.gms' + minSdkVersion 19 + } + LegacyNetworkLocation { + applicationId = 'com.google.android.location' + } + UnifiedNlp { + applicationId = 'org.microg.nlp' + } + } +} + +if (file('user.gradle').exists()) { + apply from: 'user.gradle' +} diff --git a/unifiednlp-app/src/main/AndroidManifest.xml b/unifiednlp-app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..998329a --- /dev/null +++ b/unifiednlp-app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/unifiednlp-app/src/main/java/org/microg/nlp/ui/SettingsLauncherActivity.java b/unifiednlp-app/src/main/java/org/microg/nlp/ui/SettingsLauncherActivity.java new file mode 100644 index 0000000..f5a8dd8 --- /dev/null +++ b/unifiednlp-app/src/main/java/org/microg/nlp/ui/SettingsLauncherActivity.java @@ -0,0 +1,55 @@ +/* + * Copyright 2013-2015 µg Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.microg.nlp.ui; + +import android.app.Activity; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.Bundle; + +import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED; +import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; +import static android.content.pm.PackageManager.DONT_KILL_APP; + +public class SettingsLauncherActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + startActivity(new Intent(this, SettingsActivity.class)); + finish(); + } + + public static void setLauncherIconEnabled(Context context, boolean enabled) { + PackageManager pm = context.getPackageManager(); + pm.setComponentEnabledSetting(new ComponentName(context, SettingsLauncherActivity.class), + enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED, + DONT_KILL_APP); + } + + public static void updateLauncherIcon(Context context) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (SettingInjectorService.settingsInjectionPossible(context)) { + setLauncherIconEnabled(context, false); + } else { + setLauncherIconEnabled(context, true); + } + } + } +} diff --git a/unifiednlp-base/build.gradle b/unifiednlp-base/build.gradle new file mode 100644 index 0000000..315130f --- /dev/null +++ b/unifiednlp-base/build.gradle @@ -0,0 +1,38 @@ +/* + Copyright 2013-2015 µg Project Team + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.1.3' + } +} + +apply plugin: 'com.android.library' + +dependencies { + compile 'com.android.support:support-v4:22.0.0' + compile 'com.android.support:appcompat-v7:22.0.0' + compile project(':unifiednlp-api') + provided project(':unifiednlp-compat') +} + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.0" +} diff --git a/AndroidManifest.xml b/unifiednlp-base/src/main/AndroidManifest.xml similarity index 87% rename from AndroidManifest.xml rename to unifiednlp-base/src/main/AndroidManifest.xml index a24c996..4fee19b 100644 --- a/AndroidManifest.xml +++ b/unifiednlp-base/src/main/AndroidManifest.xml @@ -15,13 +15,9 @@ --> + package="org.microg.nlp"> - + - + @@ -110,16 +103,6 @@ android:icon="@drawable/ic_nlp_settings" android:label="@string/nlp_settings_label" /> - - - - - - - diff --git a/src/android/support/v4/preference/PreferenceFragment.java b/unifiednlp-base/src/main/java/android/support/v4/preference/PreferenceFragment.java similarity index 100% rename from src/android/support/v4/preference/PreferenceFragment.java rename to unifiednlp-base/src/main/java/android/support/v4/preference/PreferenceFragment.java diff --git a/src/org/microg/nlp/AbstractBackendHelper.java b/unifiednlp-base/src/main/java/org/microg/nlp/AbstractBackendHelper.java similarity index 100% rename from src/org/microg/nlp/AbstractBackendHelper.java rename to unifiednlp-base/src/main/java/org/microg/nlp/AbstractBackendHelper.java diff --git a/src/org/microg/nlp/AbstractProviderService.java b/unifiednlp-base/src/main/java/org/microg/nlp/AbstractProviderService.java similarity index 100% rename from src/org/microg/nlp/AbstractProviderService.java rename to unifiednlp-base/src/main/java/org/microg/nlp/AbstractProviderService.java diff --git a/src/org/microg/nlp/PackageReceiver.java b/unifiednlp-base/src/main/java/org/microg/nlp/PackageReceiver.java similarity index 100% rename from src/org/microg/nlp/PackageReceiver.java rename to unifiednlp-base/src/main/java/org/microg/nlp/PackageReceiver.java diff --git a/src/org/microg/nlp/Preferences.java b/unifiednlp-base/src/main/java/org/microg/nlp/Preferences.java similarity index 100% rename from src/org/microg/nlp/Preferences.java rename to unifiednlp-base/src/main/java/org/microg/nlp/Preferences.java diff --git a/src/org/microg/nlp/Provider.java b/unifiednlp-base/src/main/java/org/microg/nlp/Provider.java similarity index 100% rename from src/org/microg/nlp/Provider.java rename to unifiednlp-base/src/main/java/org/microg/nlp/Provider.java diff --git a/src/org/microg/nlp/geocode/AbstractGeocodeService.java b/unifiednlp-base/src/main/java/org/microg/nlp/geocode/AbstractGeocodeService.java similarity index 100% rename from src/org/microg/nlp/geocode/AbstractGeocodeService.java rename to unifiednlp-base/src/main/java/org/microg/nlp/geocode/AbstractGeocodeService.java diff --git a/src/org/microg/nlp/geocode/BackendFuser.java b/unifiednlp-base/src/main/java/org/microg/nlp/geocode/BackendFuser.java similarity index 100% rename from src/org/microg/nlp/geocode/BackendFuser.java rename to unifiednlp-base/src/main/java/org/microg/nlp/geocode/BackendFuser.java diff --git a/src/org/microg/nlp/geocode/BackendHelper.java b/unifiednlp-base/src/main/java/org/microg/nlp/geocode/BackendHelper.java similarity index 100% rename from src/org/microg/nlp/geocode/BackendHelper.java rename to unifiednlp-base/src/main/java/org/microg/nlp/geocode/BackendHelper.java diff --git a/src/org/microg/nlp/geocode/GeocodeProvider.java b/unifiednlp-base/src/main/java/org/microg/nlp/geocode/GeocodeProvider.java similarity index 100% rename from src/org/microg/nlp/geocode/GeocodeProvider.java rename to unifiednlp-base/src/main/java/org/microg/nlp/geocode/GeocodeProvider.java diff --git a/src/org/microg/nlp/geocode/GeocodeProviderV1.java b/unifiednlp-base/src/main/java/org/microg/nlp/geocode/GeocodeProviderV1.java similarity index 100% rename from src/org/microg/nlp/geocode/GeocodeProviderV1.java rename to unifiednlp-base/src/main/java/org/microg/nlp/geocode/GeocodeProviderV1.java diff --git a/src/org/microg/nlp/geocode/GeocodeServiceV1.java b/unifiednlp-base/src/main/java/org/microg/nlp/geocode/GeocodeServiceV1.java similarity index 100% rename from src/org/microg/nlp/geocode/GeocodeServiceV1.java rename to unifiednlp-base/src/main/java/org/microg/nlp/geocode/GeocodeServiceV1.java diff --git a/src/org/microg/nlp/location/AbstractLocationService.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/AbstractLocationService.java similarity index 88% rename from src/org/microg/nlp/location/AbstractLocationService.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/AbstractLocationService.java index cee630e..965e467 100644 --- a/src/org/microg/nlp/location/AbstractLocationService.java +++ b/unifiednlp-base/src/main/java/org/microg/nlp/location/AbstractLocationService.java @@ -26,6 +26,8 @@ import org.microg.nlp.AbstractProviderService; import org.microg.nlp.ui.SettingInjectorService; +import java.lang.reflect.Method; + import static org.microg.nlp.api.Constants.ACTION_FORCE_LOCATION; import static org.microg.nlp.api.Constants.ACTION_RELOAD_SETTINGS; import static org.microg.nlp.api.Constants.INTENT_EXTRA_LOCATION; @@ -91,12 +93,12 @@ public boolean onUnbind(Intent intent) { } private void updateLauncherIcon() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - if (SettingInjectorService.settingsInjectionPossible(this)) { - SettingInjectorService.setLauncherIconEnabled(this, false); - } else { - SettingInjectorService.setLauncherIconEnabled(this, true); - } + try { + Class cls = Class.forName("org.microg.nlp.ui.SettingsLauncherActivity"); + Method updateLauncherIcon = cls.getDeclaredMethod("updateLauncherIcon", Context.class); + updateLauncherIcon.invoke(null, this); + } catch (Exception ignored) { + // This package does not come with a settings launcher icon } } } diff --git a/src/org/microg/nlp/location/BackendFuser.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/BackendFuser.java similarity index 100% rename from src/org/microg/nlp/location/BackendFuser.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/BackendFuser.java diff --git a/src/org/microg/nlp/location/BackendHelper.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/BackendHelper.java similarity index 100% rename from src/org/microg/nlp/location/BackendHelper.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/BackendHelper.java diff --git a/src/org/microg/nlp/location/LocationProvider.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/LocationProvider.java similarity index 100% rename from src/org/microg/nlp/location/LocationProvider.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/LocationProvider.java diff --git a/src/org/microg/nlp/location/LocationProviderV1.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/LocationProviderV1.java similarity index 100% rename from src/org/microg/nlp/location/LocationProviderV1.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/LocationProviderV1.java diff --git a/src/org/microg/nlp/location/LocationProviderV2.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/LocationProviderV2.java similarity index 100% rename from src/org/microg/nlp/location/LocationProviderV2.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/LocationProviderV2.java diff --git a/src/org/microg/nlp/location/LocationServiceV1.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/LocationServiceV1.java similarity index 100% rename from src/org/microg/nlp/location/LocationServiceV1.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/LocationServiceV1.java diff --git a/src/org/microg/nlp/location/LocationServiceV2.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/LocationServiceV2.java similarity index 100% rename from src/org/microg/nlp/location/LocationServiceV2.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/LocationServiceV2.java diff --git a/src/org/microg/nlp/location/ThreadHelper.java b/unifiednlp-base/src/main/java/org/microg/nlp/location/ThreadHelper.java similarity index 100% rename from src/org/microg/nlp/location/ThreadHelper.java rename to unifiednlp-base/src/main/java/org/microg/nlp/location/ThreadHelper.java diff --git a/src/org/microg/nlp/ui/AbstractBackendPreference.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/AbstractBackendPreference.java similarity index 100% rename from src/org/microg/nlp/ui/AbstractBackendPreference.java rename to unifiednlp-base/src/main/java/org/microg/nlp/ui/AbstractBackendPreference.java diff --git a/src/org/microg/nlp/ui/GeocoderBackendPreference.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/GeocoderBackendPreference.java similarity index 100% rename from src/org/microg/nlp/ui/GeocoderBackendPreference.java rename to unifiednlp-base/src/main/java/org/microg/nlp/ui/GeocoderBackendPreference.java diff --git a/src/org/microg/nlp/ui/LocationBackendPreference.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/LocationBackendPreference.java similarity index 100% rename from src/org/microg/nlp/ui/LocationBackendPreference.java rename to unifiednlp-base/src/main/java/org/microg/nlp/ui/LocationBackendPreference.java diff --git a/src/org/microg/nlp/ui/SettingInjectorService.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingInjectorService.java similarity index 74% rename from src/org/microg/nlp/ui/SettingInjectorService.java rename to unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingInjectorService.java index a2a425e..e89149e 100644 --- a/src/org/microg/nlp/ui/SettingInjectorService.java +++ b/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingInjectorService.java @@ -23,6 +23,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Build; +import android.os.UserHandle; import android.util.Log; import java.lang.reflect.InvocationTargetException; @@ -52,25 +53,34 @@ protected boolean onGetEnabled() { return true; } - public static void setLauncherIconEnabled(Context context, boolean enabled) { - PackageManager pm = context.getPackageManager(); - pm.setComponentEnabledSetting(new ComponentName(context, SettingsLauncherActivity.class), - enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED, - DONT_KILL_APP); - } - + /** + * Dirty method to check whether settings injection is possible on the currently used system + */ public static boolean settingsInjectionPossible(Context context) { try { Context settingsContext = context.createPackageContext("com.android.settings", CONTEXT_INCLUDE_CODE); ClassLoader cl = settingsContext.getClassLoader(); Class cls = cl.loadClass("com.android.settings.location.SettingsInjector"); - Method pSi = cls.getDeclaredMethod("parseServiceInfo", ResolveInfo.class, PackageManager.class); + int pSiVersion; + Method pSi; + try { + pSi = cls.getDeclaredMethod("parseServiceInfo", ResolveInfo.class, PackageManager.class); + pSiVersion = 1; + } catch (NoSuchMethodException e) { + pSi = cls.getDeclaredMethod("parseServiceInfo", ResolveInfo.class, UserHandle.class, PackageManager.class); + pSiVersion = 2; + } pSi.setAccessible(true); PackageManager pm = context.getPackageManager(); Intent intent = new Intent(context, SettingInjectorService.class); List ris = pm.queryIntentServices(intent, GET_META_DATA); ResolveInfo ri = ris.get(0); - Object result = pSi.invoke(null, ri, pm); + Object result = null; + if (pSiVersion == 1) { + result = pSi.invoke(null, ri, pm); + } else if (pSiVersion == 2) { + result = pSi.invoke(null, ri, android.os.Process.myUserHandle(), pm); + } if (result != null) { Log.d(TAG, "Setting injection possible!"); return true; @@ -78,7 +88,7 @@ public static boolean settingsInjectionPossible(Context context) { } catch (InvocationTargetException e) { Log.d(TAG, "settings injection not possible: " + e.getMessage()); } catch (Exception e) { - Log.d(TAG, "Can't determine if settings injection is possible"); + Log.w(TAG, "Can't determine if settings injection is possible", e); } return false; } diff --git a/src/org/microg/nlp/ui/SettingsActivity.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingsActivity.java similarity index 100% rename from src/org/microg/nlp/ui/SettingsActivity.java rename to unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingsActivity.java diff --git a/res/drawable-hdpi/ic_nlp_app.png b/unifiednlp-base/src/main/res/drawable-hdpi/ic_nlp_app.png similarity index 100% rename from res/drawable-hdpi/ic_nlp_app.png rename to unifiednlp-base/src/main/res/drawable-hdpi/ic_nlp_app.png diff --git a/res/drawable-hdpi/ic_nlp_settings.png b/unifiednlp-base/src/main/res/drawable-hdpi/ic_nlp_settings.png similarity index 100% rename from res/drawable-hdpi/ic_nlp_settings.png rename to unifiednlp-base/src/main/res/drawable-hdpi/ic_nlp_settings.png diff --git a/res/drawable-hdpi/info.png b/unifiednlp-base/src/main/res/drawable-hdpi/info.png similarity index 100% rename from res/drawable-hdpi/info.png rename to unifiednlp-base/src/main/res/drawable-hdpi/info.png diff --git a/res/drawable-hdpi/settings.png b/unifiednlp-base/src/main/res/drawable-hdpi/settings.png similarity index 100% rename from res/drawable-hdpi/settings.png rename to unifiednlp-base/src/main/res/drawable-hdpi/settings.png diff --git a/res/drawable-mdpi/ic_nlp_app.png b/unifiednlp-base/src/main/res/drawable-mdpi/ic_nlp_app.png similarity index 100% rename from res/drawable-mdpi/ic_nlp_app.png rename to unifiednlp-base/src/main/res/drawable-mdpi/ic_nlp_app.png diff --git a/res/drawable-mdpi/ic_nlp_settings.png b/unifiednlp-base/src/main/res/drawable-mdpi/ic_nlp_settings.png similarity index 100% rename from res/drawable-mdpi/ic_nlp_settings.png rename to unifiednlp-base/src/main/res/drawable-mdpi/ic_nlp_settings.png diff --git a/res/drawable-mdpi/info.png b/unifiednlp-base/src/main/res/drawable-mdpi/info.png similarity index 100% rename from res/drawable-mdpi/info.png rename to unifiednlp-base/src/main/res/drawable-mdpi/info.png diff --git a/res/drawable-mdpi/settings.png b/unifiednlp-base/src/main/res/drawable-mdpi/settings.png similarity index 100% rename from res/drawable-mdpi/settings.png rename to unifiednlp-base/src/main/res/drawable-mdpi/settings.png diff --git a/res/drawable-xhdpi/ic_nlp_app.png b/unifiednlp-base/src/main/res/drawable-xhdpi/ic_nlp_app.png similarity index 100% rename from res/drawable-xhdpi/ic_nlp_app.png rename to unifiednlp-base/src/main/res/drawable-xhdpi/ic_nlp_app.png diff --git a/res/drawable-xhdpi/ic_nlp_settings.png b/unifiednlp-base/src/main/res/drawable-xhdpi/ic_nlp_settings.png similarity index 100% rename from res/drawable-xhdpi/ic_nlp_settings.png rename to unifiednlp-base/src/main/res/drawable-xhdpi/ic_nlp_settings.png diff --git a/res/drawable-xhdpi/info.png b/unifiednlp-base/src/main/res/drawable-xhdpi/info.png similarity index 100% rename from res/drawable-xhdpi/info.png rename to unifiednlp-base/src/main/res/drawable-xhdpi/info.png diff --git a/res/drawable-xhdpi/settings.png b/unifiednlp-base/src/main/res/drawable-xhdpi/settings.png similarity index 100% rename from res/drawable-xhdpi/settings.png rename to unifiednlp-base/src/main/res/drawable-xhdpi/settings.png diff --git a/res/drawable-xxhdpi/ic_nlp_app.png b/unifiednlp-base/src/main/res/drawable-xxhdpi/ic_nlp_app.png similarity index 100% rename from res/drawable-xxhdpi/ic_nlp_app.png rename to unifiednlp-base/src/main/res/drawable-xxhdpi/ic_nlp_app.png diff --git a/res/drawable-xxhdpi/ic_nlp_settings.png b/unifiednlp-base/src/main/res/drawable-xxhdpi/ic_nlp_settings.png similarity index 100% rename from res/drawable-xxhdpi/ic_nlp_settings.png rename to unifiednlp-base/src/main/res/drawable-xxhdpi/ic_nlp_settings.png diff --git a/res/drawable-xxhdpi/info.png b/unifiednlp-base/src/main/res/drawable-xxhdpi/info.png similarity index 100% rename from res/drawable-xxhdpi/info.png rename to unifiednlp-base/src/main/res/drawable-xxhdpi/info.png diff --git a/res/drawable-xxhdpi/settings.png b/unifiednlp-base/src/main/res/drawable-xxhdpi/settings.png similarity index 100% rename from res/drawable-xxhdpi/settings.png rename to unifiednlp-base/src/main/res/drawable-xxhdpi/settings.png diff --git a/res/drawable-xxxhdpi/ic_nlp_app.png b/unifiednlp-base/src/main/res/drawable-xxxhdpi/ic_nlp_app.png similarity index 100% rename from res/drawable-xxxhdpi/ic_nlp_app.png rename to unifiednlp-base/src/main/res/drawable-xxxhdpi/ic_nlp_app.png diff --git a/res/drawable-xxxhdpi/ic_nlp_settings.png b/unifiednlp-base/src/main/res/drawable-xxxhdpi/ic_nlp_settings.png similarity index 100% rename from res/drawable-xxxhdpi/ic_nlp_settings.png rename to unifiednlp-base/src/main/res/drawable-xxxhdpi/ic_nlp_settings.png diff --git a/res/drawable-xxxhdpi/info.png b/unifiednlp-base/src/main/res/drawable-xxxhdpi/info.png similarity index 100% rename from res/drawable-xxxhdpi/info.png rename to unifiednlp-base/src/main/res/drawable-xxxhdpi/info.png diff --git a/res/drawable-xxxhdpi/settings.png b/unifiednlp-base/src/main/res/drawable-xxxhdpi/settings.png similarity index 100% rename from res/drawable-xxxhdpi/settings.png rename to unifiednlp-base/src/main/res/drawable-xxxhdpi/settings.png diff --git a/res/layout/backend_list_entry.xml b/unifiednlp-base/src/main/res/layout/backend_list_entry.xml similarity index 100% rename from res/layout/backend_list_entry.xml rename to unifiednlp-base/src/main/res/layout/backend_list_entry.xml diff --git a/res/layout/settings_activity.xml b/unifiednlp-base/src/main/res/layout/settings_activity.xml similarity index 100% rename from res/layout/settings_activity.xml rename to unifiednlp-base/src/main/res/layout/settings_activity.xml diff --git a/res/values-v21/themes.xml b/unifiednlp-base/src/main/res/values-v21/themes.xml similarity index 100% rename from res/values-v21/themes.xml rename to unifiednlp-base/src/main/res/values-v21/themes.xml diff --git a/res/values/colors.xml b/unifiednlp-base/src/main/res/values/colors.xml similarity index 100% rename from res/values/colors.xml rename to unifiednlp-base/src/main/res/values/colors.xml diff --git a/res/values/strings.xml b/unifiednlp-base/src/main/res/values/strings.xml similarity index 100% rename from res/values/strings.xml rename to unifiednlp-base/src/main/res/values/strings.xml diff --git a/res/values/themes.xml b/unifiednlp-base/src/main/res/values/themes.xml similarity index 100% rename from res/values/themes.xml rename to unifiednlp-base/src/main/res/values/themes.xml diff --git a/res/xml/nlp_injected_setting.xml b/unifiednlp-base/src/main/res/xml/nlp_injected_setting.xml similarity index 100% rename from res/xml/nlp_injected_setting.xml rename to unifiednlp-base/src/main/res/xml/nlp_injected_setting.xml diff --git a/res/xml/nlp_preferences.xml b/unifiednlp-base/src/main/res/xml/nlp_preferences.xml similarity index 100% rename from res/xml/nlp_preferences.xml rename to unifiednlp-base/src/main/res/xml/nlp_preferences.xml diff --git a/compat/build.gradle b/unifiednlp-compat/build.gradle similarity index 91% rename from compat/build.gradle rename to unifiednlp-compat/build.gradle index 4442c05..f82f1d6 100644 --- a/compat/build.gradle +++ b/unifiednlp-compat/build.gradle @@ -21,6 +21,6 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream( def sdkDir = properties.getProperty('sdk.dir') sourceSets.main { - java.srcDirs = ['current/src', 'v9/src'] - compileClasspath += project.rootProject.files("$sdkDir/platforms/android-21/android.jar") + java.srcDirs = ['src/current', 'src/v9'] + compileClasspath += project.rootProject.files("$sdkDir/platforms/android-22/android.jar") } diff --git a/compat/current/src/android/location/GeocoderParams.java b/unifiednlp-compat/src/current/android/location/GeocoderParams.java similarity index 100% rename from compat/current/src/android/location/GeocoderParams.java rename to unifiednlp-compat/src/current/android/location/GeocoderParams.java diff --git a/compat/current/src/android/location/Geofence.java b/unifiednlp-compat/src/current/android/location/Geofence.java similarity index 100% rename from compat/current/src/android/location/Geofence.java rename to unifiednlp-compat/src/current/android/location/Geofence.java diff --git a/compat/current/src/android/location/Location.java b/unifiednlp-compat/src/current/android/location/Location.java similarity index 100% rename from compat/current/src/android/location/Location.java rename to unifiednlp-compat/src/current/android/location/Location.java diff --git a/compat/current/src/android/location/LocationManager.java b/unifiednlp-compat/src/current/android/location/LocationManager.java similarity index 100% rename from compat/current/src/android/location/LocationManager.java rename to unifiednlp-compat/src/current/android/location/LocationManager.java diff --git a/compat/current/src/android/location/LocationRequest.java b/unifiednlp-compat/src/current/android/location/LocationRequest.java similarity index 100% rename from compat/current/src/android/location/LocationRequest.java rename to unifiednlp-compat/src/current/android/location/LocationRequest.java diff --git a/compat/current/src/com/android/internal/location/ProviderProperties.java b/unifiednlp-compat/src/current/com/android/internal/location/ProviderProperties.java similarity index 100% rename from compat/current/src/com/android/internal/location/ProviderProperties.java rename to unifiednlp-compat/src/current/com/android/internal/location/ProviderProperties.java diff --git a/compat/current/src/com/android/internal/location/ProviderRequest.java b/unifiednlp-compat/src/current/com/android/internal/location/ProviderRequest.java similarity index 100% rename from compat/current/src/com/android/internal/location/ProviderRequest.java rename to unifiednlp-compat/src/current/com/android/internal/location/ProviderRequest.java diff --git a/compat/current/src/com/android/location/provider/GeocodeProvider.java b/unifiednlp-compat/src/current/com/android/location/provider/GeocodeProvider.java similarity index 100% rename from compat/current/src/com/android/location/provider/GeocodeProvider.java rename to unifiednlp-compat/src/current/com/android/location/provider/GeocodeProvider.java diff --git a/compat/current/src/com/android/location/provider/LocationProviderBase.java b/unifiednlp-compat/src/current/com/android/location/provider/LocationProviderBase.java similarity index 100% rename from compat/current/src/com/android/location/provider/LocationProviderBase.java rename to unifiednlp-compat/src/current/com/android/location/provider/LocationProviderBase.java diff --git a/compat/current/src/com/android/location/provider/LocationRequestUnbundled.java b/unifiednlp-compat/src/current/com/android/location/provider/LocationRequestUnbundled.java similarity index 100% rename from compat/current/src/com/android/location/provider/LocationRequestUnbundled.java rename to unifiednlp-compat/src/current/com/android/location/provider/LocationRequestUnbundled.java diff --git a/compat/current/src/com/android/location/provider/ProviderPropertiesUnbundled.java b/unifiednlp-compat/src/current/com/android/location/provider/ProviderPropertiesUnbundled.java similarity index 100% rename from compat/current/src/com/android/location/provider/ProviderPropertiesUnbundled.java rename to unifiednlp-compat/src/current/com/android/location/provider/ProviderPropertiesUnbundled.java diff --git a/compat/current/src/com/android/location/provider/ProviderRequestUnbundled.java b/unifiednlp-compat/src/current/com/android/location/provider/ProviderRequestUnbundled.java similarity index 100% rename from compat/current/src/com/android/location/provider/ProviderRequestUnbundled.java rename to unifiednlp-compat/src/current/com/android/location/provider/ProviderRequestUnbundled.java diff --git a/compat/v9/Android.mk b/unifiednlp-compat/src/v9/Android.mk similarity index 100% rename from compat/v9/Android.mk rename to unifiednlp-compat/src/v9/Android.mk diff --git a/compat/v9/src/com/android/location/provider/LocationProvider.java b/unifiednlp-compat/src/v9/com/android/location/provider/LocationProvider.java similarity index 100% rename from compat/v9/src/com/android/location/provider/LocationProvider.java rename to unifiednlp-compat/src/v9/com/android/location/provider/LocationProvider.java