Skip to content
Permalink
Browse files

[Java] pimp android-location-provider

* added text field to enter backend host
* added text field to enter provider domain
* buttons to create joynr runtime and register/unregister provider
* externalized all string used in UI into strings.xml
* JoynrAndroidRuntime is now configurable through joynr config
* created new app icon
* add consumer main to test android provider

Change-Id: Iabfaa6d3ab7f1fd617e8bd300a1a58d71775aff1
  • Loading branch information...
christianhoff committed May 23, 2014
1 parent d17a855 commit 62621101fa013b2a37654f44fa798db630c1533e
Showing with 539 additions and 185 deletions.
  1. +1 −0 .gitignore
  2. +4 −3 examples/android-location-provider/AndroidManifest.xml
  3. +8 −0 examples/android-location-provider/README
  4. BIN examples/android-location-provider/app_icon-web.png
  5. +1 −2 examples/android-location-provider/pom.xml
  6. BIN examples/android-location-provider/res/drawable-hdpi/app_icon.png
  7. BIN examples/android-location-provider/res/drawable-hdpi/icon.png
  8. BIN examples/android-location-provider/res/drawable-ldpi/icon.png
  9. BIN examples/android-location-provider/res/drawable-mdpi/app_icon.png
  10. BIN examples/android-location-provider/res/drawable-mdpi/icon.png
  11. BIN examples/android-location-provider/res/drawable-xhdpi/app_icon.png
  12. BIN examples/android-location-provider/res/drawable-xxhdpi/app_icon.png
  13. +45 −13 examples/android-location-provider/res/layout/main.xml
  14. +7 −2 examples/android-location-provider/res/values/strings.xml
  15. +0 −70 ...ovider/src/main/java/io/joynr/public_examples/android_location_provider/HelloAndroidActivity.java
  16. +0 −78 ...va/io/joynr/public_examples/android_location_provider/JoynAndroidLocationProviderApplication.java
  17. +98 −0 ...a/io/joynr/public_examples/android_location_provider/JoynrAndroidLocationProviderApplication.java
  18. +111 −0 ...er/src/main/java/io/joynr/public_examples/android_location_provider/LocationProviderActivity.java
  19. +1 −0 examples/radio-app/.gitignore
  20. +237 −0 ...-app/src/test/java/io/joynr/public_examples/android_location_provider/GpsConsumerApplication.java
  21. BIN graphics/joynr-location-provider-icon.png
  22. BIN graphics/joynr-location-provider-icon.pptx
  23. +20 −17 java/android/joynr-android-runtime/src/main/java/io/joynr/joynrandroidruntime/InitRuntimeTask.java
  24. +6 −0 ...android/joynr-android-runtime/src/main/java/io/joynr/joynrandroidruntime/JoynrAndroidRuntime.java
@@ -2,6 +2,7 @@ target/
.classpath
.project
.settings/
.externalToolBuilders/
/gen
src/main/generated/
bounceproxy.build-.log
@@ -9,9 +9,10 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application android:icon="@drawable/icon" android:label="@string/app_name"
android:name=".JoynAndroidLocationProviderApplication">
<activity android:name=".HelloAndroidActivity">
<application android:icon="@drawable/app_icon" android:label="@string/app_name"
android:name=".JoynrAndroidLocationProviderApplication">
<activity android:name=".LocationProviderActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -0,0 +1,8 @@
To test the Android Location Provider application there is a consumer application in:

examples/radio-app/src/test/java/io/joynr/public_examples/android_location_provider/GpsConsumerApplication.java

You can start it from the command line in examples/radio-app using maven:

examples/radio-app
mvn exec:java -Dexec.classpathScope="test" -Dexec.mainClass="io.joynr.public_examples.android_location_provider.GpsConsumerApplication" -Dexec.args="<provider-domain>"
Binary file not shown.
@@ -81,7 +81,6 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>
<build>
<plugins>
@@ -165,7 +164,7 @@
<groupId>io.joynr</groupId>
<artifactId>basemodel</artifactId>
<version>${project.version}</version>
</dependency>
</dependency>
</dependencies>
</plugin>
<plugin>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,24 +5,56 @@
android:layout_height="fill_parent"
>

<EditText
android:id="@+id/editTextBackendHost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/hintBackendHost"
android:inputType="textUri"
android:text="@string/textBackendHost" >

<requestFocus />
</EditText>

<Button
android:id="@+id/btnStartJoynrRuntime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="btnOnClickStartJoynrRuntime"
android:text="@string/textStartJoynrRuntime" />

<EditText
android:id="@+id/editTextDomain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/hintDomain"
android:inputType="text"
android:text="@string/textDomain" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:id="@+id/btnRegisterLocationProvider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="onRegisterClick"
android:text="Create &amp; register location provider" />
android:gravity="center_vertical|center_horizontal"
android:onClick="btnOnClickRegisterLocationProvider"
android:text="@string/textRegisterLocationProvider" />

<EditText
android:id="@+id/progressoutput"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10"
android:inputType="textMultiLine"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false">
android:id="@+id/progressoutput"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="top"
android:inputType="textMultiLine" >

</EditText>

</LinearLayout>
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello android-location-provider!</string>
<string name="app_name">android-location-provider</string>
<string name="app_name">joynr Location Provider</string>
<string name="hintDomain">Domain used to register provider.</string>
<string name="textDomain">android-domain</string>
<string name="textRegisterLocationProvider">Register Location Provider</string>
<string name="textStartJoynrRuntime">Start joynr Runtime</string>
<string name="textBackendHost">localhost:8080</string>
<string name="hintBackendHost">Enter host running Bounceproxy and Discovery.</string>
</resources>

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,98 @@
package io.joynr.public_examples.android_location_provider;

/*
* #%L
* %%
* Copyright (C) 2011 - 2013 BMW Car IT GmbH
* %%
* 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.
* #L%
*/

import io.joynr.joynrandroidruntime.JoynrAndroidRuntime;
import io.joynr.messaging.MessagingPropertyKeys;

import java.util.Properties;

import joynr.vehicle.GpsProvider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.app.Application;

public class JoynrAndroidLocationProviderApplication extends Application {
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(JoynrAndroidLocationProviderApplication.class);
private JoynrAndroidRuntime runtime;
private Output output;
private AndroidLocationProvider androidLocationProvider;

@Override
public void onCreate() {
super.onCreate();
}

public void initJoynrRuntime(Properties joynrConfig) {
logToOutput("Creating joynr Runtime.");
logToOutput("Bounceproxy URL: " + joynrConfig.getProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL));
logToOutput("Channel URL Directory: " + joynrConfig.getProperty(MessagingPropertyKeys.CHANNELURLDIRECTORYURL));
logToOutput("Capabilities Directory: "
+ joynrConfig.getProperty(MessagingPropertyKeys.CAPABILITIESDIRECTORYURL));
runtime = new JoynrAndroidRuntime(getApplicationContext(), joynrConfig);
}

public void registerProvider(final String domain) {
if (androidLocationProvider == null) {
logToOutput("Creating new location provider.");
androidLocationProvider = new AndroidLocationProvider("", this.getApplicationContext(), output);
}
if (runtime != null) {
logToOutput("Registering provider on domain \"" + domain + "\".");
// registers the provider at the global capabilities directory
runtime.registerCapability(domain, androidLocationProvider, GpsProvider.class, "android-location-provider");
} else {
logToOutput("Failed to bind service. Can not register provider\n");
}

}

public void unregisterProvider(final String domain) {
if (androidLocationProvider == null) {
return;
}
if (runtime != null) {
logToOutput("Unegistering provider from domain \"" + domain + "\".");
// registers the provider at the global capabilities directory
runtime.unregisterCapability(domain,
androidLocationProvider,
GpsProvider.class,
"android-location-provider");
} else {
logToOutput("Failed to bind service. Can not register provider\n");
}

}

private void logToOutput(String string) {
if (output != null) {
output.append(string);
output.append("\n");
}
}

public void setOutput(Output output) {
this.output = output;
}

}
Oops, something went wrong.

0 comments on commit 6262110

Please sign in to comment.
You can’t perform that action at this time.