Skip to content

Commit

Permalink
Update to gradle build structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mar-v-in committed Mar 13, 2015
1 parent 4ee1acc commit b2e10a1
Show file tree
Hide file tree
Showing 81 changed files with 228 additions and 145 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "UnifiedNlpApi"]
path = UnifiedNlpApi
[submodule "extern/UnifiedNlpApi"]
path = extern/UnifiedNlpApi
url = https://github.com/microg/android_external_UnifiedNlpApi.git
1 change: 0 additions & 1 deletion UnifiedNlpApi
Submodule UnifiedNlpApi deleted from 06d113
74 changes: 1 addition & 73 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions extern/UnifiedNlpApi
Submodule UnifiedNlpApi added at caa1b9
5 changes: 4 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include ':compat', ':UnifiedNlpApi'
include ':unifiednlp-compat'
include ':unifiednlp-api'
include ':unifiednlp-base'
include ':unifiednlp-app'
30 changes: 0 additions & 30 deletions src/org/microg/nlp/ui/SettingsLauncherActivity.java

This file was deleted.

1 change: 1 addition & 0 deletions unifiednlp-api
52 changes: 52 additions & 0 deletions unifiednlp-app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
41 changes: 41 additions & 0 deletions unifiednlp-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.nlp.app"
android:versionName="1.4"
android:versionCode="10400">

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />

<application
android:icon="@drawable/ic_nlp_app"
android:allowBackup="true"
android:label="@string/nlp_app_name">

<activity
android:name="org.microg.nlp.ui.SettingsLauncherActivity"
android:icon="@drawable/ic_nlp_settings"
android:label="@string/nlp_app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
38 changes: 38 additions & 0 deletions unifiednlp-base/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.nlp"
android:versionName="1.3.1"
android:versionCode="10301">
package="org.microg.nlp">

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<uses-sdk android:minSdkVersion="9" />

<permission
android:permissionGroup="android.permission-group.LOCATION"
Expand All @@ -36,10 +32,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="org.microg.permission.FORCE_COARSE_LOCATION" />

<application
android:icon="@drawable/ic_nlp_app"
android:allowBackup="true"
android:label="@string/nlp_app_name">
<application>
<uses-library android:name="com.android.location.provider" />

<!-- Gingerbread / Ice Cream Sandwich -->
Expand Down Expand Up @@ -110,16 +103,6 @@
android:icon="@drawable/ic_nlp_settings"
android:label="@string/nlp_settings_label" />

<activity
android:name=".ui.SettingsLauncherActivity"
android:icon="@drawable/ic_nlp_settings"
android:label="@string/nlp_app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<receiver android:name="org.microg.nlp.PackageReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_CHANGED" />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}
}
Loading

0 comments on commit b2e10a1

Please sign in to comment.