Skip to content

Commit

Permalink
apply code formatter to all files
Browse files Browse the repository at this point in the history
Signed-off-by: Hannes Achleitner <[email protected]>
  • Loading branch information
hannesa2 committed Dec 2, 2017
1 parent 301bcb0 commit a34695f
Show file tree
Hide file tree
Showing 86 changed files with 5,495 additions and 6,157 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

ext{
ext {
compileSdkVersion = 26
buildToolsVersion = '26.0.2'
supportLibVersion = '27.0.0'
Expand Down
4 changes: 0 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
18 changes: 9 additions & 9 deletions org.eclipse.paho.android.sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.eclipse.paho.android.sample">
<manifest package="org.eclipse.paho.android.sample"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">


<!-- Permissions the Application Requires -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MaterialTheme"
android:supportsRtl="false"
android:theme="@style/MaterialTheme"
tools:ignore="GoogleAppIndexingWarning">

<activity
android:name=".activity.MainActivity"
android:label="@string/app_name" >
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

</activity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import org.eclipse.paho.android.sample.R;
import org.eclipse.paho.android.sample.internal.Connections;
import org.eclipse.paho.android.sample.model.Subscription;
import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.android.service.MqttAndroidClient;

import java.util.ArrayList;

Expand All @@ -25,30 +24,6 @@ public class ActionListener implements IMqttActionListener {

private static final String TAG = "ActionListener";
private static final String activityClass = "org.eclipse.paho.android.sample.activity.MainActivity";

/**
* Actions that can be performed Asynchronously <strong>and</strong> associated with a
* {@link ActionListener} object
*/
enum Action {
/**
* Connect Action
**/
CONNECT,
/**
* Disconnect Action
**/
DISCONNECT,
/**
* Subscribe Action
**/
SUBSCRIBE,
/**
* Publish Action
**/
PUBLISH
}

/**
* The {@link Action} that is associated with this instance of
* <code>ActionListener</code>
Expand All @@ -58,7 +33,6 @@ enum Action {
* The arguments passed to be used for formatting strings
**/
private final String[] additionalArgs;

private final Connection connection;
/**
* Handle of the {@link Connection} this action was being executed on
Expand All @@ -77,8 +51,7 @@ enum Action {
* @param connection The connection
* @param additionalArgs Used for as arguments for string formating
*/
public ActionListener(Context context, Action action,
Connection connection, String... additionalArgs) {
public ActionListener(Context context, Action action, Connection connection, String... additionalArgs) {
this.context = context;
this.action = action;
this.connection = connection;
Expand Down Expand Up @@ -107,7 +80,6 @@ public void onSuccess(IMqttToken asyncActionToken) {
publish();
break;
}

}

/**
Expand All @@ -116,14 +88,12 @@ public void onSuccess(IMqttToken asyncActionToken) {
* user of success
*/
private void publish() {

Connection c = Connections.getInstance(context).getConnection(clientHandle);
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
@SuppressLint("StringFormatMatches") String actionTaken = context.getString(R.string.toast_pub_success,
(Object[]) additionalArgs);
c.addAction(actionTaken);
(Object[]) additionalArgs);
connection.addAction(actionTaken);
Notify.toast(context, actionTaken, Toast.LENGTH_SHORT);
System.out.print("Published");

}

/**
Expand All @@ -132,13 +102,12 @@ private void publish() {
* the user of success
*/
private void subscribe() {
Connection c = Connections.getInstance(context).getConnection(clientHandle);
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
String actionTaken = context.getString(R.string.toast_sub_success,
(Object[]) additionalArgs);
c.addAction(actionTaken);
connection.addAction(actionTaken);
Notify.toast(context, actionTaken, Toast.LENGTH_SHORT);
System.out.print(actionTaken);

}

/**
Expand All @@ -147,16 +116,15 @@ private void subscribe() {
* then notify the user of success.
*/
private void disconnect() {
Connection c = Connections.getInstance(context).getConnection(clientHandle);
c.changeConnectionStatus(Connection.ConnectionStatus.DISCONNECTED);
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
connection.changeConnectionStatus(Connection.ConnectionStatus.DISCONNECTED);
String actionTaken = context.getString(R.string.toast_disconnected);
c.addAction(actionTaken);
Log.i(TAG, c.handle() + " disconnected.");
connection.addAction(actionTaken);
Log.i(TAG, connection.handle() + " disconnected.");
//build intent
Intent intent = new Intent();
intent.setClassName(context, activityClass);
intent.putExtra("handle", clientHandle);

}

/**
Expand All @@ -165,16 +133,15 @@ private void disconnect() {
* then notify the user of success.
*/
private void connect() {
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
connection.changeConnectionStatus(Connection.ConnectionStatus.CONNECTED);
connection.addAction("Client Connected");
Log.i(TAG, connection.handle() + " connected.");

Connection c = Connections.getInstance(context).getConnection(clientHandle);
c.changeConnectionStatus(Connection.ConnectionStatus.CONNECTED);
c.addAction("Client Connected");
Log.i(TAG, c.handle() + " connected.");

ArrayList<Subscription> subscriptions = connection.getSubscriptions();
ArrayList<Subscription> subscriptions = this.connection.getSubscriptions();
for (Subscription sub : subscriptions) {
Log.i(TAG, "Auto-subscribing to: " + sub.getTopic() + "@ QoS: " + sub.getQos());
connection.getClient().subscribe(sub.getTopic(), sub.getQos());
this.connection.getClient().subscribe(sub.getTopic(), sub.getQos());
}
}

Expand All @@ -200,7 +167,6 @@ public void onFailure(IMqttToken token, Throwable exception) {
publish(exception);
break;
}

}

/**
Expand All @@ -209,13 +175,13 @@ public void onFailure(IMqttToken token, Throwable exception) {
* @param exception This argument is not used
*/
private void publish(Throwable exception) {
Connection c = Connections.getInstance(context).getConnection(clientHandle);
@SuppressLint("StringFormatMatches") String action = context.getString(R.string.toast_pub_failed,
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
@SuppressLint("StringFormatMatches")
String action = context.getString(R.string.toast_pub_failed,
(Object[]) additionalArgs);
c.addAction(action);
connection.addAction(action);
Notify.toast(context, action, Toast.LENGTH_SHORT);
System.out.print("Publish failed");

}

/**
Expand All @@ -224,13 +190,12 @@ private void publish(Throwable exception) {
* @param exception This argument is not used
*/
private void subscribe(Throwable exception) {
Connection c = Connections.getInstance(context).getConnection(clientHandle);
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
String action = context.getString(R.string.toast_sub_failed,
(Object[]) additionalArgs);
c.addAction(action);
connection.addAction(action);
Notify.toast(context, action, Toast.LENGTH_SHORT);
System.out.print(action);

}

/**
Expand All @@ -239,10 +204,9 @@ private void subscribe(Throwable exception) {
* @param exception This argument is not used
*/
private void disconnect(Throwable exception) {
Connection c = Connections.getInstance(context).getConnection(clientHandle);
c.changeConnectionStatus(Connection.ConnectionStatus.DISCONNECTED);
c.addAction("Disconnect Failed - an error occured");

Connection connection = Connections.getInstance(context).getConnection(clientHandle);
connection.changeConnectionStatus(Connection.ConnectionStatus.DISCONNECTED);
connection.addAction("Disconnect Failed - an error occured");
}

/**
Expand All @@ -251,11 +215,33 @@ private void disconnect(Throwable exception) {
* @param exception This argument is not used
*/
private void connect(Throwable exception) {
Connection c = Connections.getInstance(context).getConnection(clientHandle);
c.changeConnectionStatus(Connection.ConnectionStatus.ERROR);
c.addAction("Client failed to connect");
Connection connection = Connections.getInstance(context).getConnection(clientHandle);
connection.changeConnectionStatus(Connection.ConnectionStatus.ERROR);
connection.addAction("Client failed to connect");
System.out.println("Client failed to connect");
}

/**
* Actions that can be performed Asynchronously <strong>and</strong> associated with a
* {@link ActionListener} object
*/
enum Action {
/**
* Connect Action
**/
CONNECT,
/**
* Disconnect Action
**/
DISCONNECT,
/**
* Subscribe Action
**/
SUBSCRIBE,
/**
* Publish Action
**/
PUBLISH
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

class ActivityConstants {

/** Bundle key for passing a connection around by it's name **/
/**
* Bundle key for passing a connection around by it's name
**/
public static final String CONNECTION_KEY = "CONNECTION_KEY";

public static final String AUTO_CONNECT = "AUTO_CONNECT";
public static final String CONNECTED = "CONNECTEd";

public static final String LOGGING_KEY = "LOGGING_ENABLED";


/** Property name for the history field in {@link Connection} object for use with {@link java.beans.PropertyChangeEvent} **/
/**
* Property name for the history field in {@link Connection} object for use with {@link java.beans.PropertyChangeEvent}
**/
public static final String historyProperty = "history";

/** Property name for the connection status field in {@link Connection} object for use with {@link java.beans.PropertyChangeEvent} **/
/**
* Property name for the connection status field in {@link Connection} object for use with {@link java.beans.PropertyChangeEvent}
**/
public static final String ConnectionStatusProperty = "connectionStatus";



/** Empty String for comparisons **/
/**
* Empty String for comparisons
**/
static final String empty = "";
}
Loading

0 comments on commit a34695f

Please sign in to comment.