├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── tmp_icon-web.png
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── tmp_icon.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── tmp_icon.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── tmp_icon.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── tmp_icon.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── tmp_icon.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── layout
│ │ │ │ ├── dialog_add_command.xml
│ │ │ │ ├── drawer_header.xml
│ │ │ │ ├── fragment_account.xml
│ │ │ │ ├── box_command_item.xml
│ │ │ │ ├── fragment_settingsitem_list.xml
│ │ │ │ ├── activity_chat.xml
│ │ │ │ ├── fragment_settingsitem.xml
│ │ │ │ ├── fragment_command.xml
│ │ │ │ ├── activity_start.xml
│ │ │ │ ├── fragment_single_contact.xml
│ │ │ │ ├── single_contact_cmd_item.xml
│ │ │ │ ├── fragment_about.xml
│ │ │ │ ├── contact_item.xml
│ │ │ │ └── fragment_home.xml
│ │ │ └── values-w820dp
│ │ │ │ └── dimens.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── pddstudio
│ │ │ │ └── brbox
│ │ │ │ ├── views
│ │ │ │ ├── dialogs
│ │ │ │ │ ├── CallbackDialog.java
│ │ │ │ │ ├── AddCommandDialog.java
│ │ │ │ │ ├── ConnectionDialog.java
│ │ │ │ │ ├── DebugDialog.java
│ │ │ │ │ ├── DialogUtil.java
│ │ │ │ │ ├── ExitDialog.java
│ │ │ │ │ ├── ContactListDialog.java
│ │ │ │ │ ├── BaseDialog.java
│ │ │ │ │ └── NewConnectionDialog.java
│ │ │ │ └── NavigationDrawer.java
│ │ │ │ ├── managers
│ │ │ │ ├── ConnectionManager.java
│ │ │ │ ├── Preferences.java
│ │ │ │ ├── ContactCommandManager.java
│ │ │ │ └── Navigate.java
│ │ │ │ ├── enums
│ │ │ │ └── Page.java
│ │ │ │ ├── objects
│ │ │ │ └── CommandHistoryObject.java
│ │ │ │ ├── fragments
│ │ │ │ ├── AccountFragment.java
│ │ │ │ ├── AboutFragment.java
│ │ │ │ ├── CommandFragment.java
│ │ │ │ ├── SettingsItemAdapter.java
│ │ │ │ ├── SingleContactFragment.java
│ │ │ │ ├── SettingsFragment.java
│ │ │ │ └── HomeFragment.java
│ │ │ │ ├── StartActivity.java
│ │ │ │ ├── adapters
│ │ │ │ ├── CommandAdapter.java
│ │ │ │ ├── ContactsAdapter.java
│ │ │ │ └── CommandRecyclerAdapter.java
│ │ │ │ └── ChatActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── pddstudio
│ │ │ └── brbox
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── pddstudio
│ │ └── brbox
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── brtalk
├── .gitignore
├── libs
│ ├── jxmpp-jid-0.4.2.jar
│ ├── smack-im-4.1.4.jar
│ ├── smack-tcp-4.1.4.jar
│ ├── jxmpp-core-0.4.2.jar
│ ├── smack-bosh-4.1.4.jar
│ ├── smack-core-4.1.4.jar
│ ├── smack-android-4.1.4.jar
│ ├── jxmpp-util-cache-0.4.2.jar
│ ├── smack-extensions-4.1.4.jar
│ ├── smack-sasl-provided-4.1.4.jar
│ ├── jxmpp-stringprep-libidn-0.4.2.jar
│ ├── smack-android-extensions-4.1.4.jar
│ └── smack-compression-jzlib-4.1.4.jar
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── pddstudio
│ │ │ │ └── brtalk
│ │ │ │ ├── callbacks
│ │ │ │ ├── SendMessageCallback.java
│ │ │ │ ├── xmpp
│ │ │ │ │ ├── XmppLogoutCallback.java
│ │ │ │ │ ├── XmppLoginCallback.java
│ │ │ │ │ └── XmppMessageCallback.java
│ │ │ │ ├── ConnectionInterface.java
│ │ │ │ ├── ServerConnectionCallback.java
│ │ │ │ ├── BrRequestInterface.java
│ │ │ │ ├── SendCommandCallback.java
│ │ │ │ └── PostActionCallback.java
│ │ │ │ ├── objects
│ │ │ │ ├── ClientSettings.java
│ │ │ │ ├── RequestObject.java
│ │ │ │ ├── ServerSettings.java
│ │ │ │ ├── ResponseObject.java
│ │ │ │ ├── SingleContact.java
│ │ │ │ ├── RequestFailure.java
│ │ │ │ ├── BoxCommand.java
│ │ │ │ └── ConnectionObject.java
│ │ │ │ ├── managers
│ │ │ │ ├── CommandGroupManager.java
│ │ │ │ ├── RequestManager.java
│ │ │ │ └── ContactsManager.java
│ │ │ │ ├── services
│ │ │ │ └── ReceiverService.java
│ │ │ │ ├── async
│ │ │ │ └── OpenConnectionTask.java
│ │ │ │ └── BrTalk.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── pddstudio
│ │ │ └── brtalk
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── pddstudio
│ │ └── brtalk
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── brtalk.iml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── Brbox.iml
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Brbox
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/brtalk/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':brtalk'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/tmp_icon-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/tmp_icon-web.png
--------------------------------------------------------------------------------
/brtalk/libs/jxmpp-jid-0.4.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/jxmpp-jid-0.4.2.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-im-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-im-4.1.4.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-tcp-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-tcp-4.1.4.jar
--------------------------------------------------------------------------------
/brtalk/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BrTalk
3 |
4 |
--------------------------------------------------------------------------------
/brtalk/libs/jxmpp-core-0.4.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/jxmpp-core-0.4.2.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-bosh-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-bosh-4.1.4.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-core-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-core-4.1.4.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-android-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-android-4.1.4.jar
--------------------------------------------------------------------------------
/brtalk/libs/jxmpp-util-cache-0.4.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/jxmpp-util-cache-0.4.2.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-extensions-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-extensions-4.1.4.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/tmp_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-hdpi/tmp_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/tmp_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-mdpi/tmp_icon.png
--------------------------------------------------------------------------------
/brtalk/libs/smack-sasl-provided-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-sasl-provided-4.1.4.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tmp_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-xhdpi/tmp_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/tmp_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-xxhdpi/tmp_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/tmp_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-xxxhdpi/tmp_icon.png
--------------------------------------------------------------------------------
/brtalk/libs/jxmpp-stringprep-libidn-0.4.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/jxmpp-stringprep-libidn-0.4.2.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-android-extensions-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-android-extensions-4.1.4.jar
--------------------------------------------------------------------------------
/brtalk/libs/smack-compression-jzlib-4.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/brtalk/libs/smack-compression-jzlib-4.1.4.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PDDStudio/brbox-android/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 | /app/src/main/java/com/pddstudio/brbox/TestClass.java
9 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Nov 24 10:24:16 CET 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_add_command.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/drawer_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/SendMessageCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks;
2 |
3 | /**
4 | * This Class was created by Patrick J
5 | * on 23.11.15. For more Details and Licensing
6 | * have a look at the README.md
7 | */
8 | public interface SendMessageCallback {
9 | void onMessageReceived();
10 | }
11 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/xmpp/XmppLogoutCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks.xmpp;
2 |
3 | /**
4 | * This Class was created by Patrick J
5 | * on 24.11.15. For more Details and Licensing
6 | * have a look at the README.md
7 | */
8 | public interface XmppLogoutCallback {
9 | void onLogout(boolean logoutSuccess);
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/brtalk/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/ConnectionInterface.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks;
2 |
3 | import com.pddstudio.brtalk.objects.ConnectionObject;
4 |
5 | /**
6 | * This Class was created by Patrick J
7 | * on 23.11.15. For more Details and Licensing
8 | * have a look at the README.md
9 | */
10 | public interface ConnectionInterface {
11 | ConnectionObject getConnection();
12 | }
13 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/ServerConnectionCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks;
2 |
3 | /**
4 | * This Class was created by Patrick J
5 | * on 21.11.15. For more Details and Licensing
6 | * have a look at the README.md
7 | */
8 | public interface ServerConnectionCallback {
9 | void onPreparingConnection();
10 | void onConnectionResultReceived(boolean status);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/pddstudio/brbox/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/brtalk/src/test/java/com/pddstudio/brtalk/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/pddstudio/brbox/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/brtalk/src/androidTest/java/com/pddstudio/brtalk/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/xmpp/XmppLoginCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks.xmpp;
2 |
3 | /**
4 | * This Class was created by Patrick J
5 | * on 23.11.15. For more Details and Licensing
6 | * have a look at the README.md
7 | */
8 | public interface XmppLoginCallback {
9 | //called before the connection
10 | void onPreparingXmppLogin();
11 | //called when tried to connect
12 | void onXmppLoginResult(boolean loginSuccessful);
13 | }
14 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/BrRequestInterface.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks;
2 |
3 | import com.pddstudio.brtalk.objects.RequestObject;
4 | import com.pddstudio.brtalk.objects.ResponseObject;
5 |
6 | /**
7 | * This Class was created by Patrick J
8 | * on 23.11.15. For more Details and Licensing
9 | * have a look at the README.md
10 | */
11 | public interface BrRequestInterface {
12 | RequestObject onRequestInit();
13 | void onRequestResponseReceived(ResponseObject responseObject);
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_account.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/CallbackDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import com.afollestad.materialdialogs.MaterialDialog;
4 |
5 | /**
6 | * This Class was created by Patrick J
7 | * on 23.11.15. For more Details and Licensing
8 | * have a look at the README.md
9 | */
10 | //dialog which is showing while waiting for the callback of an action
11 | public final class CallbackDialog {
12 |
13 | private static CallbackDialog callbackDialog;
14 |
15 | private MaterialDialog dialog;
16 |
17 | private CallbackDialog() {}
18 | }
19 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/box_command_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/xmpp/XmppMessageCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks.xmpp;
2 |
3 | import com.pddstudio.brtalk.objects.RequestFailure;
4 | import com.pddstudio.brtalk.objects.RequestObject;
5 | import com.pddstudio.brtalk.objects.ResponseObject;
6 |
7 | /**
8 | * This Class was created by Patrick J
9 | * on 23.11.15. For more Details and Licensing
10 | * have a look at the README.md
11 | */
12 | public interface XmppMessageCallback {
13 | void onPrepareRequest(RequestObject requestObject);
14 | void onServeResponse(ResponseObject responseObject);
15 | void onRequestFailure(RequestFailure requestFailure);
16 | }
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/pddstudio/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/brtalk/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/pddstudio/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #3F51B5
5 | #303F9F
6 | #FF4081
7 |
8 |
9 | #FFFFFF
10 | @color/colorPrimary
11 | #DE000000
12 | @color/colorAccent
13 | @color/colorAccent
14 | @color/colorAccent
15 |
16 |
17 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/SendCommandCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks;
2 |
3 | import com.afollestad.materialdialogs.MaterialDialog;
4 |
5 | import org.jivesoftware.smack.chat.Chat;
6 | import org.jivesoftware.smack.packet.Message;
7 |
8 | /**
9 | * This Class was created by Patrick J
10 | * on 21.11.15. For more Details and Licensing
11 | * have a look at the README.md
12 | */
13 | public interface SendCommandCallback {
14 | MaterialDialog onPrepare();
15 | void onReplyReceived(boolean sendSuccess, Chat chat, Message message, MaterialDialog dialog);
16 | void onConnectionFailure(MaterialDialog dialog);
17 | void onExceptionOccurred(Exception exception, MaterialDialog dialog);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_settingsitem_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/callbacks/PostActionCallback.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.callbacks;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import org.jivesoftware.smack.chat.Chat;
6 | import org.jivesoftware.smack.chat.ChatMessageListener;
7 | import org.jivesoftware.smack.packet.Message;
8 |
9 | /**
10 | * This Class was created by Patrick J
11 | * on 23.11.15. For more Details and Licensing
12 | * have a look at the README.md
13 | */
14 | //used to send commands to the target
15 | public interface PostActionCallback {
16 | @Nullable ChatMessageListener getCustomMessageListenerCallback();
17 | void onPostAction();
18 | void onPostActionFailed(@Nullable Exception exception);
19 | void onAnswerReceived(Chat chat, Message message);
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_settingsitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_command.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/ClientSettings.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | /**
4 | * This Class was created by Patrick J
5 | * on 20.11.15. For more Details and Licensing
6 | * have a look at the README.md
7 | */
8 | public class ClientSettings {
9 |
10 | private String userName;
11 | private String userPassword;
12 |
13 | public ClientSettings(String userName, String userPassword) {
14 | this.userName = userName;
15 | this.userPassword = userPassword;
16 | }
17 |
18 | public String getUserName() {
19 | return userName;
20 | }
21 |
22 | public void setUserName(String userName) {
23 | this.userName = userName;
24 | }
25 |
26 | public String getUserPassword() {
27 | return userPassword;
28 | }
29 |
30 | public void setUserPassword(String userPassword) {
31 | this.userPassword = userPassword;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_start.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/AddCommandDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import com.afollestad.materialdialogs.MaterialDialog;
4 | import com.pddstudio.brbox.R;
5 |
6 | /**
7 | * This Class was created by Patrick J
8 | * on 21.11.15. For more Details and Licensing
9 | * have a look at the README.md
10 | */
11 | public final class AddCommandDialog {
12 |
13 | private static AddCommandDialog addCommandDialog;
14 |
15 | private MaterialDialog dialog;
16 |
17 | private AddCommandDialog() {
18 | dialog = new MaterialDialog.Builder(DialogUtil.getContext())
19 | .title("")
20 | .customView(R.layout.dialog_add_command, true)
21 | .positiveText("")
22 | .build();
23 | }
24 |
25 | public static void show() {
26 | addCommandDialog = new AddCommandDialog();
27 | addCommandDialog.dialog.show();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/ConnectionDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import com.afollestad.materialdialogs.MaterialDialog;
4 | import com.pddstudio.brbox.R;
5 |
6 | /**
7 | * This Class was created by Patrick J
8 | * on 24.11.15. For more Details and Licensing
9 | * have a look at the README.md
10 | */
11 | public final class ConnectionDialog {
12 |
13 | private MaterialDialog dialog;
14 |
15 | private ConnectionDialog() {
16 | dialog = DialogUtil.getDefaultBuilderColors()
17 | .title(R.string.connection_disconnected_title)
18 | .content(R.string.connection_disconnected_content)
19 | .positiveText(R.string.ok)
20 | .build();
21 | }
22 |
23 | public static void showDisconnected() {
24 | ConnectionDialog connectionDialog = new ConnectionDialog();
25 | connectionDialog.dialog.show();
26 | }
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_single_contact.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/single_contact_cmd_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
22 |
23 |
27 |
28 |
--------------------------------------------------------------------------------
/Brbox.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/RequestObject.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | import java.util.Date;
4 | import java.util.GregorianCalendar;
5 | import java.util.Locale;
6 |
7 | /**
8 | * This Class was created by Patrick J
9 | * on 23.11.15. For more Details and Licensing
10 | * have a look at the README.md
11 | */
12 | public class RequestObject {
13 |
14 | private final SingleContact singleContact;
15 | private final BoxCommand boxCommand;
16 | private final Date requestDate;
17 |
18 | public RequestObject(SingleContact contact, BoxCommand boxCommand) {
19 | this.singleContact = contact;
20 | this.boxCommand = boxCommand;
21 | this.requestDate = GregorianCalendar.getInstance(Locale.getDefault()).getTime();
22 | }
23 |
24 | public SingleContact getSingleContact() {
25 | return singleContact;
26 | }
27 |
28 | public BoxCommand getBoxCommand() {
29 | return boxCommand;
30 | }
31 |
32 | public Date getRequestDate() {
33 | return requestDate;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/DebugDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.afollestad.materialdialogs.MaterialDialog;
6 | import com.pddstudio.brbox.R;
7 |
8 | /**
9 | * This Class was created by Patrick J
10 | * on 23.11.15. For more Details and Licensing
11 | * have a look at the README.md
12 | */
13 | public class DebugDialog {
14 |
15 | private static MaterialDialog.Builder builder = DialogUtil.getDefaultBuilderColors();
16 |
17 | public static MaterialDialog getLoadingDialog(@Nullable String title, @Nullable String content) {
18 | MaterialDialog dialog;
19 | builder.progress(true, 0);
20 | if(title != null) builder.title(title);
21 | if(content != null) builder.content(content);
22 | dialog = builder.build();
23 | return dialog;
24 | }
25 |
26 | public static MaterialDialog getInfoDialog(String title, String content) {
27 | MaterialDialog dialog;
28 | builder.title(title).content(content).positiveText(R.string.ok);
29 | dialog = builder.build();
30 | return dialog;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/ServerSettings.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | /**
4 | * This Class was created by Patrick J
5 | * on 20.11.15. For more Details and Licensing
6 | * have a look at the README.md
7 | */
8 | public class ServerSettings {
9 |
10 | private String serverDomain;
11 | private int serverPort;
12 | private String serverName;
13 |
14 | public ServerSettings(String serverDomain, int serverPort) {
15 | this.serverDomain = serverDomain;
16 | this.serverPort = serverPort;
17 | }
18 |
19 | public String getServerDomain() {
20 | return serverDomain;
21 | }
22 |
23 | public void setServerDomain(String serverDomain) {
24 | this.serverDomain = serverDomain;
25 | }
26 |
27 | public int getServerPort() {
28 | return serverPort;
29 | }
30 |
31 | public void setServerPort(int serverPort) {
32 | this.serverPort = serverPort;
33 | }
34 |
35 | public String getServerName() {
36 | return serverName;
37 | }
38 |
39 | public void setServerName(String serverName) {
40 | this.serverName = serverName;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/managers/ConnectionManager.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.managers;
2 |
3 | import com.pddstudio.brtalk.BrTalk;
4 |
5 | import java.util.HashMap;
6 |
7 | /**
8 | * This Class was created by Patrick J
9 | * on 20.11.15. For more Details and Licensing
10 | * have a look at the README.md
11 | */
12 | public class ConnectionManager {
13 |
14 | private static ConnectionManager connectionManager;
15 |
16 | private HashMap connections;
17 |
18 |
19 | private ConnectionManager() {
20 | this.connections = new HashMap<>();
21 | }
22 |
23 | public static ConnectionManager getInstance() {
24 | if(connectionManager == null) connectionManager = new ConnectionManager();
25 | return connectionManager;
26 | }
27 |
28 | private void loadSavedConnections() {
29 |
30 | }
31 |
32 | private void saveConnections() {
33 |
34 | }
35 |
36 | public void addConnection(String identifier, BrTalk brTalk) {
37 | connections.put(identifier, brTalk);
38 | }
39 |
40 | public BrTalk getConnection(String identifier) {
41 | return connections.get(identifier);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_about.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
13 |
14 |
20 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | repositories {
4 | jcenter()
5 | maven { url "https://jitpack.io" }
6 | }
7 |
8 | android {
9 | compileSdkVersion 23
10 | buildToolsVersion '23.0.2'
11 |
12 | defaultConfig {
13 | applicationId "com.pddstudio.brbox"
14 | minSdkVersion 17
15 | targetSdkVersion 23
16 | versionCode 1
17 | versionName "1.0"
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(include: ['*.jar'], dir: 'libs')
29 | testCompile 'junit:junit:4.12'
30 | compile('com.github.afollestad.material-dialogs:core:0.8.5.0@aar') {
31 | transitive = true
32 | }
33 | compile('com.mikepenz:materialdrawer:4.4.4@aar') {
34 | transitive = true
35 | }
36 | compile project(':brtalk')
37 |
38 | compile 'com.android.support:appcompat-v7:23.1.1'
39 | compile 'com.android.support:design:23.1.1'
40 | compile 'com.android.support:cardview-v7:23.1.1'
41 | compile 'com.android.support:recyclerview-v7:23.1.1'
42 | compile 'com.android.support:support-v4:23.1.1'
43 | compile 'io.paperdb:paperdb:1.0'
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/DialogUtil.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import android.content.Context;
4 |
5 | import com.afollestad.materialdialogs.MaterialDialog;
6 | import com.pddstudio.brbox.R;
7 | import com.pddstudio.brbox.managers.Preferences;
8 |
9 | /**
10 | * This Class was created by Patrick J
11 | * on 20.11.15. For more Details and Licensing
12 | * have a look at the README.md
13 | */
14 | public class DialogUtil {
15 |
16 | private static Context appContext;
17 |
18 | public static void setAppContext(Context context) {
19 | appContext = context;
20 | }
21 |
22 | protected static Context getContext() {
23 | return appContext;
24 | }
25 |
26 | public static MaterialDialog.Builder getDefaultBuilderColors() {
27 | MaterialDialog.Builder baseBuilder = new MaterialDialog.Builder(appContext);
28 | baseBuilder.backgroundColorRes(R.color.dialogBackgroundColor)
29 | .titleColorRes(R.color.dialogTitleColor)
30 | .contentColorRes(R.color.dialogContentColor)
31 | .positiveColorRes(R.color.dialogPositiveTextColor)
32 | .neutralColorRes(R.color.dialogNeutralTextColor)
33 | .negativeColorRes(R.color.dialogNegativeTextColor);
34 | return baseBuilder;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/ResponseObject.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import org.jivesoftware.smack.chat.Chat;
6 | import org.jivesoftware.smack.packet.Message;
7 |
8 | import java.util.Date;
9 | import java.util.GregorianCalendar;
10 | import java.util.Locale;
11 |
12 | /**
13 | * This Class was created by Patrick J
14 | * on 23.11.15. For more Details and Licensing
15 | * have a look at the README.md
16 | */
17 | public class ResponseObject {
18 |
19 | private final Chat chat;
20 | private final Message message;
21 | private final String identifier;
22 | private final Date responseDate;
23 |
24 | public ResponseObject(@Nullable String identifier, Chat chat, Message message) {
25 | this.chat = chat;
26 | this.message = message;
27 | this.identifier = identifier;
28 | this.responseDate = GregorianCalendar.getInstance(Locale.getDefault()).getTime();
29 | }
30 |
31 | public Chat getChat() {
32 | return chat;
33 | }
34 |
35 | public Message getMessage() {
36 | return message;
37 | }
38 |
39 | public String getIdentifier() {
40 | return identifier;
41 | }
42 |
43 | public Date getResponseDate() {
44 | return responseDate;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/managers/CommandGroupManager.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.managers;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import com.pddstudio.brtalk.BrTalk;
7 |
8 | import java.util.HashSet;
9 | import java.util.Set;
10 |
11 | /**
12 | * This Class was created by Patrick J
13 | * on 23.11.15. For more Details and Licensing
14 | * have a look at the README.md
15 | */
16 | public class CommandGroupManager {
17 |
18 | private static final String BRTALK_MNGR = "brtalk.commandgroup.manager";
19 | private static CommandGroupManager commandGroupManager;
20 |
21 | private SharedPreferences sharedPreferences;
22 | private Set commandCategories;
23 |
24 | private CommandGroupManager(BrTalk brTalk) {
25 | this.commandCategories = new HashSet<>();
26 | if(brTalk.getAppContext() == null) {
27 | //todo handle action when no context is given
28 | } else {
29 | this.sharedPreferences = brTalk.getAppContext().getSharedPreferences(BRTALK_MNGR, Context.MODE_PRIVATE);
30 | }
31 | }
32 |
33 | public static CommandGroupManager getInstanceFor(BrTalk brTalk) {
34 | if(commandGroupManager == null) commandGroupManager = new CommandGroupManager(brTalk);
35 | return commandGroupManager;
36 | }
37 |
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/SingleContact.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | import android.os.Parcelable;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * This Class was created by Patrick J
9 | * on 21.11.15. For more Details and Licensing
10 | * have a look at the README.md
11 | */
12 | public class SingleContact implements Serializable {
13 |
14 | //the 'real' name
15 | private String conName;
16 | //the jabber id
17 | private String conId;
18 | //the status, if set
19 | private String conStat;
20 | //internal id to handle requests
21 | private int uid;
22 |
23 | public SingleContact() {}
24 |
25 | public String getName() {
26 | return conName;
27 | }
28 |
29 | public void setName(String name) {
30 | this.conName = name;
31 | }
32 |
33 | public String getConnectionId() {
34 | return conId;
35 | }
36 |
37 | public void setConnectionId(String connectionId) {
38 | this.conId = connectionId;
39 | }
40 |
41 | public String getStatus() {
42 | return conStat;
43 | }
44 |
45 | public void setStatus(String status) {
46 | this.conStat = status;
47 | }
48 |
49 | public int getUniqueId() {
50 | return uid;
51 | }
52 |
53 | public void setUID(int uid) {
54 | this.uid = uid;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/ExitDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import android.content.Context;
4 |
5 | import com.afollestad.materialdialogs.DialogAction;
6 | import com.afollestad.materialdialogs.MaterialDialog;
7 | import com.pddstudio.brbox.R;
8 |
9 | /**
10 | * This Class was created by Patrick J
11 | * on 20.11.15. For more Details and Licensing
12 | * have a look at the README.md
13 | */
14 | public final class ExitDialog {
15 |
16 | private static ExitDialog exitDialog;
17 |
18 | private MaterialDialog dialog;
19 |
20 | private ExitDialog(Context context) {
21 | dialog = new MaterialDialog.Builder(context)
22 | .title(R.string.exit_dialog_title)
23 | .content(R.string.exit_dialog_content)
24 | .positiveText(R.string.yes)
25 | .negativeText(R.string.no)
26 | .onPositive(new MaterialDialog.SingleButtonCallback() {
27 | @Override
28 | public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
29 | System.exit(0);
30 | }
31 | })
32 | .build();
33 | }
34 |
35 | public static void show(Context context) {
36 | exitDialog = new ExitDialog(context);
37 | exitDialog.dialog.show();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/brtalk/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | repositories {
4 | jcenter()
5 | maven { url "https://jitpack.io" }
6 | }
7 |
8 | android {
9 | compileSdkVersion 23
10 | buildToolsVersion '23.0.2'
11 |
12 | defaultConfig {
13 | minSdkVersion 17
14 | targetSdkVersion 23
15 | versionCode 1
16 | versionName "1.0"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | packagingOptions {
26 | exclude 'META-INF/DEPENDENCIES.txt'
27 | exclude 'META-INF/LICENSE.txt'
28 | exclude 'META-INF/NOTICE.txt'
29 | exclude 'META-INF/NOTICE'
30 | exclude 'META-INF/LICENSE'
31 | exclude 'META-INF/DEPENDENCIES'
32 | exclude 'META-INF/notice.txt'
33 | exclude 'META-INF/license.txt'
34 | exclude 'META-INF/dependencies.txt'
35 | exclude 'META-INF/LGPL2.1'
36 | }
37 | }
38 |
39 | repositories {
40 | mavenCentral()
41 | }
42 |
43 | dependencies {
44 | compile fileTree(dir: 'libs', include: ['*.jar'])
45 | testCompile 'junit:junit:4.12'
46 | compile 'com.android.support:appcompat-v7:23.1.1'
47 | compile('com.github.afollestad.material-dialogs:core:0.8.5.0@aar') {
48 | transitive = true
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/contact_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/services/ReceiverService.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.services;
2 |
3 | import android.util.Log;
4 |
5 | import org.jivesoftware.smack.chat.Chat;
6 | import org.jivesoftware.smack.chat.ChatManager;
7 | import org.jivesoftware.smack.chat.ChatManagerListener;
8 | import org.jivesoftware.smack.chat.ChatMessageListener;
9 | import org.jivesoftware.smack.packet.Message;
10 |
11 | /**
12 | * This Class was created by Patrick J
13 | * on 21.11.15. For more Details and Licensing
14 | * have a look at the README.md
15 | */
16 | public class ReceiverService implements ChatManagerListener, ChatMessageListener {
17 |
18 | private final ChatManager chatManager;
19 |
20 | private ReceiverService(ChatManager chatManager) {
21 | this.chatManager = chatManager;
22 | this.chatManager.addChatListener(this);
23 | Log.d("ReceiverService", "created instance with given chat manager");
24 | }
25 |
26 | public static ReceiverService register(ChatManager chatManager) {
27 | return new ReceiverService(chatManager);
28 | }
29 |
30 | @Override
31 | public void chatCreated(Chat chat, boolean createdLocally) {
32 | if(!createdLocally) {
33 | chat.addMessageListener(this);
34 | }
35 | }
36 |
37 | @Override
38 | public void processMessage(Chat chat, Message message) {
39 | Log.d("ReceiverService", "Message from: " + chat.getParticipant() + " : '" + message.getBody() + "'");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/ContactListDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import android.view.View;
4 |
5 | import com.afollestad.materialdialogs.MaterialDialog;
6 | import com.pddstudio.brbox.R;
7 | import com.pddstudio.brbox.TestClass;
8 | import com.pddstudio.brtalk.objects.SingleContact;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * This Class was created by Patrick J
14 | * on 21.11.15. For more Details and Licensing
15 | * have a look at the README.md
16 | */
17 | public final class ContactListDialog {
18 |
19 | private static ContactListDialog contactListDialog;
20 |
21 | private MaterialDialog dialog;
22 | private CharSequence[] contactNames;
23 |
24 | private ContactListDialog() {
25 | this.load();
26 | dialog = DialogUtil.getDefaultBuilderColors()
27 | .title("Your Contacts:")
28 | .items(contactNames)
29 | .positiveText(R.string.ok)
30 | .build();
31 | }
32 |
33 | private void load() {
34 | contactNames = new CharSequence[TestClass.getInstance().getContactsArray().length];
35 | for(int i = 0; i < TestClass.getInstance().getContactsArray().length; i++) {
36 | contactNames[i] = TestClass.getInstance().getContactsArray()[i].getName();
37 | }
38 | }
39 |
40 | public static void show() {
41 | contactListDialog = new ContactListDialog();
42 | contactListDialog.dialog.show();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/enums/Page.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.enums;
2 |
3 | import com.pddstudio.brbox.managers.Navigate;
4 |
5 | /**
6 | * This Class was created by Patrick J
7 | * on 20.11.15. For more Details and Licensing
8 | * have a look at the README.md
9 | */
10 | public enum Page {
11 | HOME(Navigate.PAGE_HOME, Navigate.PAGE_HOME_TAG),
12 | ABOUT(Navigate.PAGE_ABOUT, Navigate.PAGE_ABOUT_TAG),
13 | COMMANDS(Navigate.PAGE_COMMANDS, Navigate.PAGE_COMMANDS_TAG),
14 | ACCOUNTS(Navigate.PAGE_ACCOUNTS, Navigate.PAGE_ACCOUNTS_TAG);
15 |
16 | private final int fragmentID;
17 | private final String fragmentTag;
18 |
19 | Page(int fragmentID, String fragmentTag) {
20 | this.fragmentID = fragmentID;
21 | this.fragmentTag = fragmentTag;
22 | }
23 |
24 | public int getFragmentID() {
25 | return fragmentID;
26 | }
27 |
28 | public String getFragmentTag() {
29 | return fragmentTag;
30 | }
31 |
32 | public static int getFragmentID(Page page) {
33 | return page.getFragmentID();
34 | }
35 |
36 | public static String getFragmentTag(Page page) {
37 | return page.getFragmentTag();
38 | }
39 |
40 | public static Page getPageForId(int id) {
41 | switch (id) {
42 | case Navigate.PAGE_HOME:
43 | return HOME;
44 | case Navigate.PAGE_ABOUT:
45 | return ABOUT;
46 | case Navigate.PAGE_COMMANDS:
47 | return COMMANDS;
48 | case Navigate.PAGE_ACCOUNTS:
49 | return ACCOUNTS;
50 | }
51 | return null;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/managers/RequestManager.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.managers;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.pddstudio.brtalk.BrTalk;
6 | import com.pddstudio.brtalk.callbacks.BrRequestInterface;
7 | import com.pddstudio.brtalk.callbacks.ConnectionInterface;
8 | import com.pddstudio.brtalk.objects.BoxCommand;
9 | import com.pddstudio.brtalk.objects.ConnectionObject;
10 | import com.pddstudio.brtalk.objects.RequestObject;
11 | import com.pddstudio.brtalk.objects.ResponseObject;
12 | import com.pddstudio.brtalk.objects.SingleContact;
13 |
14 | /**
15 | * This Class was created by Patrick J
16 | * on 23.11.15. For more Details and Licensing
17 | * have a look at the README.md
18 | */
19 | public abstract class RequestManager implements ConnectionInterface, BrRequestInterface {
20 |
21 | private final BrTalk brTalk;
22 |
23 | private SingleContact targetContact;
24 | private BoxCommand targetCommand;
25 |
26 | public RequestManager(BrTalk brTalk) {
27 | this.brTalk = brTalk;
28 | }
29 |
30 | public abstract RequestObject onRequestInit();
31 | public abstract void onRequestResponseReceived(ResponseObject responseObject);
32 | public abstract void onRequestFailed(@Nullable Exception exception);
33 | public abstract ConnectionObject getConnection();
34 |
35 | public void executeRequest() {
36 | RequestObject requestObject = this.onRequestInit();
37 | this.targetContact = requestObject.getSingleContact();
38 | this.targetCommand = requestObject.getBoxCommand();
39 | }
40 |
41 | private void connectionSetup() {
42 |
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/RequestFailure.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import java.util.Date;
6 | import java.util.GregorianCalendar;
7 | import java.util.Locale;
8 |
9 | /**
10 | * This Class was created by Patrick J
11 | * on 24.11.15. For more Details and Licensing
12 | * have a look at the README.md
13 | */
14 | public class RequestFailure {
15 |
16 | private final String failDescriptionTitle;
17 | private final String failDescriptionContentShort;
18 | private final String failDescriptionContentLong;
19 | private final Date failDate;
20 |
21 | public RequestFailure(@Nullable String title, @Nullable String contentShort, @Nullable String contentLong) {
22 | if(title == null) this.failDescriptionTitle = "";
23 | else this.failDescriptionTitle = title;
24 | if(contentShort == null) this.failDescriptionContentShort = "";
25 | else this.failDescriptionContentShort = contentShort;
26 | if(contentLong == null) this.failDescriptionContentLong = "";
27 | else this.failDescriptionContentLong = contentLong;
28 | this.failDate = GregorianCalendar.getInstance(Locale.getDefault()).getTime();
29 | }
30 |
31 | public String getFailDescriptionTitle() {
32 | return failDescriptionTitle;
33 | }
34 |
35 | public String getFailDescriptionContentShort() {
36 | return failDescriptionContentShort;
37 | }
38 |
39 | public String getFailDescriptionContentLong() {
40 | return failDescriptionContentLong;
41 | }
42 |
43 | public Date getFailDate() {
44 | return failDate;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/BoxCommand.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | /**
6 | * This Class was created by Patrick J
7 | * on 21.11.15. For more Details and Licensing
8 | * have a look at the README.md
9 | */
10 | public class BoxCommand {
11 |
12 | //visible name for the command
13 | private String commandName;
14 |
15 | //command send to the target
16 | private String commandTarget;
17 |
18 | //description for the command
19 | private String commandDesc;
20 |
21 | //the group where the command is sort in
22 | private String commandGroup;
23 |
24 | //represents a collection of information for a command
25 | public BoxCommand() {}
26 |
27 | public BoxCommand(String commandName, String commandTarget, String commandDesc, @Nullable String commandGrp) {
28 | this.commandName = commandName;
29 | this.commandTarget = commandTarget;
30 | this.commandDesc = commandDesc;
31 | this.commandGroup = commandGrp;
32 | }
33 |
34 | public String getCommandName() {
35 | return commandName;
36 | }
37 |
38 | public void setCommandName(String commandName) {
39 | this.commandName = commandName;
40 | }
41 |
42 | public String getCommandTarget() {
43 | return commandTarget;
44 | }
45 |
46 | public void setCommandTarget(String commandTarget) {
47 | this.commandTarget = commandTarget;
48 | }
49 |
50 | public String getCommandDesc() {
51 | return commandDesc;
52 | }
53 |
54 | public void setCommandDesc(String commandDesc) {
55 | this.commandDesc = commandDesc;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/objects/CommandHistoryObject.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.objects;
2 |
3 | import com.pddstudio.brtalk.objects.RequestFailure;
4 | import com.pddstudio.brtalk.objects.RequestObject;
5 | import com.pddstudio.brtalk.objects.ResponseObject;
6 | import com.pddstudio.brtalk.objects.SingleContact;
7 |
8 | /**
9 | * This Class was created by Patrick J
10 | * on 25.11.15. For more Details and Licensing
11 | * have a look at the README.md
12 | */
13 | public class CommandHistoryObject {
14 |
15 | private SingleContact contactTarget;
16 | private RequestObject requestObject;
17 | private ResponseObject responseObject;
18 | private RequestFailure requestFailure;
19 | private boolean requestFailed = false;
20 |
21 | public CommandHistoryObject() {
22 |
23 | }
24 |
25 | public SingleContact getContactTarget() {
26 | return contactTarget;
27 | }
28 |
29 | public void setContactTarget(SingleContact contactTarget) {
30 | this.contactTarget = contactTarget;
31 | }
32 |
33 | public RequestObject getRequestObject() {
34 | return requestObject;
35 | }
36 |
37 | public void setRequestObject(RequestObject requestObject) {
38 | this.requestObject = requestObject;
39 | }
40 |
41 | public ResponseObject getResponseObject() {
42 | return responseObject;
43 | }
44 |
45 | public void setResponseObject(ResponseObject responseObject) {
46 | this.responseObject = responseObject;
47 | }
48 |
49 | public boolean isRequestFailed() {
50 | return requestFailed;
51 | }
52 |
53 | public void setRequestFailed(boolean requestFailed) {
54 | this.requestFailed = requestFailed;
55 | }
56 |
57 | public RequestFailure getRequestFailure() {
58 | return requestFailure;
59 | }
60 |
61 | public void setRequestFailure(RequestFailure requestFailure) {
62 | this.requestFailure = requestFailure;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/AccountFragment.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.pddstudio.brbox.R;
11 | import com.pddstudio.brbox.managers.Navigate;
12 |
13 | /**
14 | * A simple {@link Fragment} subclass.
15 | */
16 | public class AccountFragment extends Fragment {
17 |
18 | private static final String FRAGMENT_ID_IDENTIFIER = "FragmentID";
19 | private static final String FRAGMENT_TAG_IDENTIFIER = "FragmentTAG";
20 |
21 | private int fragmentID;
22 | private String fragmentTag;
23 |
24 | private View root;
25 |
26 | public AccountFragment() {
27 | // Required empty public constructor
28 | }
29 |
30 | public static AccountFragment newInstance(int id, String tag) {
31 | AccountFragment accountFragment = new AccountFragment();
32 | Bundle bundle = new Bundle();
33 | bundle.putInt(FRAGMENT_ID_IDENTIFIER, id);
34 | bundle.putString(FRAGMENT_TAG_IDENTIFIER, tag);
35 | accountFragment.setArguments(bundle);
36 | return accountFragment;
37 | }
38 |
39 | @Override
40 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
41 | Bundle savedInstanceState) {
42 | // Inflate the layout for this fragment (and restoring saved information, if any)
43 | if(savedInstanceState == null) {
44 | this.fragmentTag = Navigate.PAGE_HOME_TAG;
45 | this.fragmentID = Navigate.PAGE_HOME;
46 | } else {
47 | this.fragmentTag = savedInstanceState.getString(FRAGMENT_TAG_IDENTIFIER);
48 | this.fragmentID = savedInstanceState.getInt(FRAGMENT_ID_IDENTIFIER);
49 | }
50 |
51 | root = inflater.inflate(R.layout.fragment_home, container, false);
52 | return root;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/AboutFragment.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.pddstudio.brbox.R;
11 | import com.pddstudio.brbox.managers.Navigate;
12 |
13 | /**
14 | * A simple {@link Fragment} subclass.
15 | */
16 | public class AboutFragment extends Fragment {
17 |
18 | private static final String FRAGMENT_ID_IDENTIFIER = "FragmentID";
19 | private static final String FRAGMENT_TAG_IDENTIFIER = "FragmentTAG";
20 |
21 | private int fragmentID;
22 | private String fragmentTag;
23 |
24 | public AboutFragment() {
25 | // Required empty public constructor
26 | }
27 |
28 | public static AboutFragment newInstance(int pageId, String pageTag) {
29 | AboutFragment aboutFragment = new AboutFragment();
30 | Bundle bundle = new Bundle();
31 | bundle.putInt(FRAGMENT_ID_IDENTIFIER, pageId);
32 | bundle.putString(FRAGMENT_TAG_IDENTIFIER, pageTag);
33 | aboutFragment.setArguments(bundle);
34 | return aboutFragment;
35 | }
36 |
37 |
38 | @Override
39 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
40 | Bundle savedInstanceState) {
41 | // Check whether the bundle contains any states to be restored
42 | if(savedInstanceState == null) {
43 | this.fragmentTag = Navigate.PAGE_HOME_TAG;
44 | this.fragmentID = Navigate.PAGE_HOME;
45 | } else {
46 | this.fragmentTag = savedInstanceState.getString(FRAGMENT_TAG_IDENTIFIER);
47 | this.fragmentID = savedInstanceState.getInt(FRAGMENT_ID_IDENTIFIER);
48 | }
49 | // Inflate the layout for this fragment
50 | View root = inflater.inflate(R.layout.fragment_about, container, false);
51 | return root;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BrBox
3 | Hello blank fragment
4 |
5 |
6 | Ok
7 | Yes
8 | No
9 | Login
10 | Logout
11 |
12 |
13 | Overview
14 | Account Management
15 | Manage Commands
16 | Settings
17 | About
18 |
19 |
20 | Username
21 | Password
22 |
23 |
24 | Exit Application?
25 | Are you sure you want to leave the application? This will close all open connections!
26 |
27 | Connecting to Server!
28 | Please be patient!"
29 | Connected!
30 | Successfully connected to the server.
31 | Connection Failed!
32 | Unable to connect! Please check your configuration and try again.
33 |
34 | Disconnected!
35 | Your account has disconnected from the server.
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/BaseDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.StringRes;
5 |
6 | import com.afollestad.materialdialogs.MaterialDialog;
7 | import com.pddstudio.brbox.managers.Preferences;
8 |
9 | /**
10 | * This Class was created by Patrick J
11 | * on 20.11.15. For more Details and Licensing
12 | * have a look at the README.md
13 | */
14 | public abstract class BaseDialog {
15 |
16 | private MaterialDialog dialog;
17 | private MaterialDialog.Builder dialogBuilder;
18 |
19 | @StringRes private int dialogTitle;
20 | @StringRes private int dialogContent;
21 | @StringRes private int positiveText;
22 | @StringRes private int negativeText;
23 | @StringRes private int neutralText;
24 |
25 | private MaterialDialog.SingleButtonCallback positiveCallback;
26 | private MaterialDialog.SingleButtonCallback negativeCallback;
27 | private MaterialDialog.SingleButtonCallback neutralCallback;
28 |
29 | private boolean cancelable;
30 | private Context context;
31 |
32 | public BaseDialog() {
33 | }
34 |
35 | public void setDialogTitle(@StringRes int dialogTitle) {
36 | this.dialogTitle = dialogTitle;
37 | }
38 |
39 | public void setDialogContent(@StringRes int dialogContent) {
40 | this.dialogContent = dialogContent;
41 | }
42 |
43 | public void setPositiveText(@StringRes int positiveText) {
44 |
45 | }
46 |
47 | public void setPositiveText(@StringRes int positiveText, MaterialDialog.SingleButtonCallback positiveCallback) {
48 |
49 | }
50 |
51 | public void setNegativeText(@StringRes int negativeText) {
52 |
53 | }
54 |
55 | public void setNegativeText(@StringRes int negativeText, MaterialDialog.SingleButtonCallback negativeCallback) {
56 |
57 | }
58 |
59 | public void setNeutralText(@StringRes int neutralText) {
60 |
61 | }
62 |
63 | public void setNeutralText(@StringRes int neutralText, MaterialDialog.SingleButtonCallback neutralCallback) {
64 |
65 | }
66 |
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/managers/Preferences.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.managers;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 |
7 | import com.pddstudio.brbox.objects.CommandHistoryObject;
8 | import com.pddstudio.brbox.views.dialogs.DialogUtil;
9 | import com.pddstudio.brtalk.objects.SingleContact;
10 |
11 | import java.util.LinkedList;
12 | import java.util.List;
13 |
14 | import io.paperdb.Paper;
15 |
16 | /**
17 | * This Class was created by Patrick J
18 | * on 20.11.15. For more Details and Licensing
19 | * have a look at the README.md
20 | */
21 | public class Preferences {
22 |
23 | private static final String PREFERENCES_NAME = "brbox.preferences";
24 | private static Preferences preferences;
25 |
26 | private static final String CONTACT_COMMAND_HISTORY = "contact_cmd_history";
27 |
28 | private final SharedPreferences sharedPreferences;
29 |
30 | private Preferences(Activity activity) {
31 | this.sharedPreferences = activity.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
32 |
33 | //initializing paper for pojo de/serialization
34 | Paper.init(activity);
35 |
36 | DialogUtil.setAppContext(activity);
37 | }
38 |
39 | public static Preferences initialize(Activity activity) {
40 | preferences = new Preferences(activity);
41 | return preferences;
42 | }
43 |
44 | public static Preferences getInstance() {
45 | return preferences;
46 | }
47 |
48 | //save the given command history for the given contact
49 | public void saveCommandHistory(SingleContact contact, List commandHistoryObjectList) {
50 | Paper.book(contact.getConnectionId()).write(CONTACT_COMMAND_HISTORY, commandHistoryObjectList);
51 | }
52 |
53 | //load the command history for the given contact
54 | public List getSavedCommandHistory(SingleContact contact) {
55 | return Paper.book(contact.getConnectionId()).read(CONTACT_COMMAND_HISTORY, new LinkedList());
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/StartActivity.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox;
2 |
3 | import android.os.Build;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.Toolbar;
7 |
8 | import com.mikepenz.materialdrawer.Drawer;
9 | import com.pddstudio.brbox.enums.Page;
10 | import com.pddstudio.brbox.managers.Navigate;
11 | import com.pddstudio.brbox.managers.Preferences;
12 | import com.pddstudio.brbox.views.NavigationDrawer;
13 | import com.pddstudio.brbox.views.dialogs.ExitDialog;
14 |
15 | public class StartActivity extends AppCompatActivity {
16 |
17 | //ui components
18 | private Toolbar toolbar;
19 | private Drawer drawer;
20 |
21 | //misc props
22 | private Navigate navigate;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_start);
28 |
29 | //navbar color support for Android 5.0 > devices
30 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
31 | getWindow().setNavigationBarColor(getResources().getColor(R.color.primary_dark, getTheme()));
32 | }
33 |
34 | //initializing the application's preferences
35 | Preferences.initialize(this);
36 |
37 | //initializing ui components
38 | toolbar = (Toolbar) findViewById(R.id.toolbar);
39 | setSupportActionBar(toolbar);
40 | drawer = new NavigationDrawer(this).addToolbar(toolbar).create();
41 |
42 | //initializing the nav handler
43 | navigate = Navigate.init(this, this, getSupportFragmentManager());
44 |
45 | //check whether the Bundle contains information or not
46 | if(savedInstanceState == null) {
47 | navigate.to(Page.HOME);
48 | } else {
49 | navigate.toBundleInfo(savedInstanceState);
50 | }
51 |
52 | }
53 |
54 | public void closeDrawerIfOpen() {
55 | if(drawer.isDrawerOpen()) drawer.closeDrawer();
56 | }
57 |
58 | @Override
59 | public void onBackPressed() {
60 | if(drawer.isDrawerOpen()) {
61 | drawer.closeDrawer();
62 | } else {
63 | ExitDialog.show(this);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/CommandFragment.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ListView;
11 |
12 | import com.pddstudio.brbox.R;
13 | import com.pddstudio.brbox.managers.Navigate;
14 |
15 | /**
16 | * A simple {@link Fragment} subclass.
17 | */
18 | public class CommandFragment extends Fragment {
19 |
20 | private static final String FRAGMENT_ID_IDENTIFIER = "FragmentID";
21 | private static final String FRAGMENT_TAG_IDENTIFIER = "FragmentTAG";
22 |
23 | private int fragmentID;
24 | private String fragmentTag;
25 |
26 | private View root;
27 | private ListView commandList;
28 | private FloatingActionButton fab;
29 |
30 | public CommandFragment() {
31 | // Required empty public constructor
32 | }
33 |
34 | public static CommandFragment newInstance(int id, String tag) {
35 | CommandFragment commandFragment = new CommandFragment();
36 | Bundle bundle = new Bundle();
37 | bundle.putInt(FRAGMENT_ID_IDENTIFIER, id);
38 | bundle.putString(FRAGMENT_TAG_IDENTIFIER, tag);
39 | commandFragment.setArguments(bundle);
40 | return commandFragment;
41 | }
42 |
43 |
44 | @Override
45 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
46 | Bundle savedInstanceState) {
47 | // Check the Bundle
48 | if(savedInstanceState == null) {
49 | this.fragmentTag = Navigate.PAGE_HOME_TAG;
50 | this.fragmentID = Navigate.PAGE_HOME;
51 | } else {
52 | this.fragmentTag = savedInstanceState.getString(FRAGMENT_TAG_IDENTIFIER);
53 | this.fragmentID = savedInstanceState.getInt(FRAGMENT_ID_IDENTIFIER);
54 | }
55 | // Inflate the layout for this fragment
56 | root = inflater.inflate(R.layout.fragment_command, container, false);
57 | commandList = (ListView) root.findViewById(R.id.command_list);
58 | fab = (FloatingActionButton) root.findViewById(R.id.add_command_fab);
59 | //todo add parsing for bundle and loading
60 | return root;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/adapters/CommandAdapter.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.adapters;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.BaseAdapter;
7 | import android.widget.TextView;
8 |
9 | import com.pddstudio.brbox.R;
10 | import com.pddstudio.brtalk.objects.BoxCommand;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * This Class was created by Patrick J
16 | * on 21.11.15. For more Details and Licensing
17 | * have a look at the README.md
18 | */
19 | public class CommandAdapter extends BaseAdapter {
20 |
21 | private List commandList;
22 |
23 | public CommandAdapter(List commands) {
24 | this.commandList = commands;
25 | }
26 |
27 | @Override
28 | public int getCount() {
29 | return commandList.size();
30 | }
31 |
32 | @Override
33 | public BoxCommand getItem(int position) {
34 | if(position >= 0 && position < commandList.size()) {
35 | return commandList.get(position);
36 | }
37 | return null;
38 | }
39 |
40 | @Override
41 | public long getItemId(int position) {
42 | return 0;
43 | }
44 |
45 | @Override
46 | public View getView(int position, View convertView, ViewGroup parent) {
47 | SingleCommandView singleCommandView;
48 | BoxCommand boxCommand = commandList.get(position);
49 | if(convertView == null) {
50 | LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
51 | convertView = layoutInflater.inflate(R.layout.box_command_item, parent, false);
52 | singleCommandView = new SingleCommandView();
53 | singleCommandView.commandTitle = (TextView) convertView.findViewById(R.id.command_title);
54 | singleCommandView.commandDescription = (TextView) convertView.findViewById(R.id.command_desc);
55 | convertView.setTag(singleCommandView);
56 | } else {
57 | singleCommandView = (SingleCommandView) convertView.getTag();
58 | }
59 |
60 | singleCommandView.commandTitle.setText(boxCommand.getCommandName());
61 | singleCommandView.commandDescription.setText(boxCommand.getCommandDesc());
62 | return convertView;
63 | }
64 |
65 | private class SingleCommandView {
66 | public TextView commandTitle;
67 | public TextView commandDescription;
68 | //todo maybe add delete button, too?
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/ChatActivity.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentTransaction;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.os.Bundle;
10 | import android.support.v7.widget.Toolbar;
11 | import android.util.Log;
12 |
13 | import com.pddstudio.brbox.fragments.SingleContactFragment;
14 | import com.pddstudio.brtalk.objects.SingleContact;
15 |
16 | public class ChatActivity extends AppCompatActivity {
17 |
18 | public static final String CONTACT = "com.pddstudio.brbox.ChatActivity.CONTACT";
19 |
20 | //non ui components
21 | private SingleContact contact;
22 | private FragmentManager fragmentManager;
23 |
24 | //ui stuff
25 | private Toolbar toolbar;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | Intent data = getIntent();
31 | this.contact = (SingleContact) data.getExtras().getSerializable(CONTACT);
32 | setContentView(R.layout.activity_chat);
33 |
34 | //navbar color for +5.0 devices
35 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
36 | getWindow().setNavigationBarColor(getResources().getColor(R.color.primary_dark, getTheme()));
37 | }
38 |
39 | //leaving the activity if the contact wasn't found
40 | if(contact == null) {
41 | Log.e("ChatActivity", "Contact is null. Leaving activity!");
42 | this.finish();
43 | } else {
44 | Log.i("ChatActivity", "Contact successfully re-serialized.");
45 | }
46 |
47 | //setting the toolbar
48 | toolbar = (Toolbar) findViewById(R.id.chat_toolbar);
49 | toolbar.setTitle(contact.getName());
50 | toolbar.setTitleTextColor(Color.WHITE);
51 | setSupportActionBar(toolbar);
52 |
53 | //setting the fragment
54 | SingleContactFragment fragment = new SingleContactFragment().withContact(contact);
55 | fragmentManager = this.getSupportFragmentManager();
56 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
57 | fragmentTransaction.replace(R.id.chat_fragment_placeholder, fragment);
58 | fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
59 | fragmentTransaction.commit();
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/SettingsItemAdapter.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.pddstudio.brbox.R;
10 |
11 | /*public class SettingsItemAdapter extends RecyclerView.Adapter {
12 |
13 | private final List mValues;
14 | private final SettingsFragment.OnListFragmentInteractionListener mListener;
15 |
16 | public SettingsItemAdapter(List items, SettingsFragment.OnListFragmentInteractionListener listener) {
17 | mValues = items;
18 | mListener = listener;
19 | }
20 |
21 | @Override
22 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
23 | View view = LayoutInflater.from(parent.getContext())
24 | .inflate(R.layout.fragment_settingsitem, parent, false);
25 | return new ViewHolder(view);
26 | }
27 |
28 | @Override
29 | public void onBindViewHolder(final ViewHolder holder, int position) {
30 | holder.mItem = mValues.get(position);
31 | holder.mIdView.setText(mValues.get(position).id);
32 | holder.mContentView.setText(mValues.get(position).content);
33 |
34 | holder.mView.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | if (null != mListener) {
38 | // Notify the active callbacks interface (the activity, if the
39 | // fragment is attached to one) that an item has been selected.
40 | mListener.onListFragmentInteraction(holder.mItem);
41 | }
42 | }
43 | });
44 | }
45 |
46 | @Override
47 | public int getItemCount() {
48 | return mValues.size();
49 | }
50 |
51 | public class ViewHolder extends RecyclerView.ViewHolder {
52 | public final View mView;
53 | public final TextView mIdView;
54 | public final TextView mContentView;
55 | public DummyItem mItem;
56 |
57 | public ViewHolder(View view) {
58 | super(view);
59 | mView = view;
60 | mIdView = (TextView) view.findViewById(R.id.id);
61 | mContentView = (TextView) view.findViewById(R.id.content);
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return super.toString() + " '" + mContentView.getText() + "'";
67 | }
68 | }
69 | }*/
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/adapters/ContactsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.adapters;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.BaseAdapter;
7 | import android.widget.TextView;
8 |
9 | import com.pddstudio.brbox.R;
10 | import com.pddstudio.brtalk.BrTalk;
11 | import com.pddstudio.brtalk.objects.SingleContact;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * This Class was created by Patrick J
17 | * on 24.11.15. For more Details and Licensing
18 | * have a look at the README.md
19 | */
20 | public class ContactsAdapter extends BaseAdapter {
21 |
22 | private List contactList;
23 | private final BrTalk brTalk;
24 |
25 | public ContactsAdapter(BrTalk brTalk) {
26 | this.brTalk = brTalk;
27 | this.contactList = brTalk.getContacts();
28 | }
29 |
30 | public void reloadContacts() {
31 | this.contactList = brTalk.getContacts();
32 | this.notifyDataSetChanged();
33 | }
34 |
35 | @Override
36 | public int getCount() {
37 | return contactList.size();
38 | }
39 |
40 | @Override
41 | public SingleContact getItem(int position) {
42 | if(position >= 0 && position < contactList.size()) {
43 | return contactList.get(position);
44 | }
45 | return null;
46 | }
47 |
48 | @Override
49 | public long getItemId(int position) {
50 | return 0;
51 | }
52 |
53 | @Override
54 | public View getView(int position, View convertView, ViewGroup parent) {
55 | ContactItemView contactItemView;
56 | SingleContact singleContact = contactList.get(position);
57 | if(convertView == null) {
58 | LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
59 | convertView = layoutInflater.inflate(R.layout.contact_item, parent, false);
60 | contactItemView = new ContactItemView();
61 | contactItemView.contactName = (TextView) convertView.findViewById(R.id.contact_title);
62 | contactItemView.contactAddress = (TextView) convertView.findViewById(R.id.contact_address);
63 | convertView.setTag(contactItemView);
64 | } else {
65 | contactItemView = (ContactItemView) convertView.getTag();
66 | }
67 |
68 | contactItemView.contactName.setText(singleContact.getName());
69 | contactItemView.contactAddress.setText(singleContact.getConnectionId());
70 | return convertView;
71 | }
72 |
73 | private class ContactItemView {
74 | TextView contactName;
75 | TextView contactAddress;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/dialogs/NewConnectionDialog.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views.dialogs;
2 |
3 | import android.util.Log;
4 |
5 | import com.afollestad.materialdialogs.DialogAction;
6 | import com.afollestad.materialdialogs.MaterialDialog;
7 | import com.pddstudio.brbox.R;
8 | import com.pddstudio.brbox.TestClass;
9 |
10 | import org.jivesoftware.smack.AbstractXMPPConnection;
11 |
12 | /**
13 | * This Class was created by Patrick J
14 | * on 21.11.15. For more Details and Licensing
15 | * have a look at the README.md
16 | */
17 | public final class NewConnectionDialog {
18 |
19 | private static NewConnectionDialog newConnectionDialog;
20 |
21 | private MaterialDialog dialog;
22 |
23 | private NewConnectionDialog() {
24 | dialog = DialogUtil.getDefaultBuilderColors()
25 | .title(R.string.new_connection_title)
26 | .content(R.string.new_connection_content)
27 | .progress(true, 0)
28 | .cancelable(false)
29 | .build();
30 | }
31 |
32 | public static void show() {
33 | newConnectionDialog = new NewConnectionDialog();
34 | newConnectionDialog.dialog.show();
35 | }
36 |
37 | public static void showResult(boolean result) {
38 | if(newConnectionDialog != null && newConnectionDialog.dialog.isShowing()) newConnectionDialog.dialog.hide();
39 | MaterialDialog.Builder dialogBuilder = DialogUtil.getDefaultBuilderColors();
40 | if(result) {
41 | dialogBuilder.title(R.string.new_connection_result_positive_title);
42 | dialogBuilder.content(R.string.new_connection_result_positive_content);
43 | dialogBuilder.onPositive(new MaterialDialog.SingleButtonCallback() {
44 | @Override
45 | public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
46 | AbstractXMPPConnection xmppConnection = TestClass.getInstance().currentConnection();
47 | Log.d("ConnectionInfo", "Hostname: " + xmppConnection.getHost() + " User: " + xmppConnection.getUser());
48 | Log.d("ConnectionInfo", "Connected: " + xmppConnection.isConnected() + " Authenticated: " + xmppConnection.isAuthenticated());
49 | Log.d("ConnectionInfo", "Anonymous: " + xmppConnection.isAnonymous() + " Secured Connection: " + xmppConnection.isSecureConnection());
50 | }
51 | });
52 | } else {
53 | dialogBuilder.title(R.string.new_connection_result_negative_title);
54 | dialogBuilder.content(R.string.new_connection_result_negative_content);
55 | }
56 | dialogBuilder.positiveText(R.string.ok);
57 | dialogBuilder.show();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/SingleContactFragment.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | import com.pddstudio.brbox.R;
14 | import com.pddstudio.brbox.TestClass;
15 | import com.pddstudio.brbox.adapters.CommandRecyclerAdapter;
16 | import com.pddstudio.brbox.managers.ContactCommandManager;
17 | import com.pddstudio.brtalk.objects.SingleContact;
18 |
19 | /**
20 | * A simple {@link Fragment} subclass.
21 | */
22 | public class SingleContactFragment extends Fragment {
23 |
24 | private static final String FRAGMENT_ID_IDENTIFIER = "FragmentID";
25 | private static final String FRAGMENT_TAG_IDENTIFIER = "FragmentTAG";
26 |
27 | private int fragmentID;
28 | private String fragmentTag;
29 |
30 | private SingleContact singleContact;
31 | private ContactCommandManager contactCommandManager;
32 |
33 | private View root;
34 | private FloatingActionButton fab;
35 | private RecyclerView recyclerView;
36 | private CommandRecyclerAdapter commandRecyclerAdapter;
37 |
38 | public SingleContactFragment() {
39 | // Required empty public constructor
40 | }
41 |
42 | public SingleContactFragment withContact(SingleContact singleContact) {
43 | this.singleContact = singleContact;
44 | return this;
45 | }
46 |
47 | @Override
48 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
49 | Bundle savedInstanceState) {
50 | // Inflate the layout for this fragment
51 | root = inflater.inflate(R.layout.fragment_single_contact, container, false);
52 | //todo: inflate layout (parse history and add actions)
53 | recyclerView = (RecyclerView) root.findViewById(R.id.contact_command_recycler_view);
54 |
55 | fab = (FloatingActionButton) root.findViewById(R.id.contact_command_fab);
56 | fab.setOnClickListener(new View.OnClickListener() {
57 | @Override
58 | public void onClick(View v) {
59 | TestClass.getInstance().sendHelpCommand(contactCommandManager);
60 | }
61 | });
62 |
63 | if(singleContact != null) {
64 | contactCommandManager = ContactCommandManager.getHistory(singleContact);
65 | if(!contactCommandManager.hasHistory()) Log.d("SCFragment", "no history found int contactCommandManager!");
66 | commandRecyclerAdapter = new CommandRecyclerAdapter(contactCommandManager);
67 | recyclerView.setAdapter(commandRecyclerAdapter);
68 | }
69 |
70 | return root;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/managers/ContactsManager.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.managers;
2 |
3 | import android.util.Log;
4 |
5 | import com.pddstudio.brtalk.objects.SingleContact;
6 |
7 | import org.jivesoftware.smack.AbstractXMPPConnection;
8 | import org.jivesoftware.smack.chat.ChatManager;
9 | import org.jivesoftware.smack.roster.Roster;
10 | import org.jivesoftware.smack.roster.RosterEntry;
11 | import org.jivesoftware.smack.roster.RosterGroup;
12 |
13 | import java.util.ArrayList;
14 | import java.util.Collection;
15 | import java.util.List;
16 |
17 | /**
18 | * This Class was created by Patrick J
19 | * on 21.11.15. For more Details and Licensing
20 | * have a look at the README.md
21 | */
22 | public class ContactsManager {
23 |
24 | private final AbstractXMPPConnection abstractXMPPConnection;
25 | private List contactList;
26 |
27 | private ContactsManager(AbstractXMPPConnection abstractXMPPConnection) {
28 | this.abstractXMPPConnection = abstractXMPPConnection;
29 | //this.loadRoster();
30 | this.loadContacts();
31 | }
32 |
33 | public static ContactsManager forConnection(AbstractXMPPConnection abstractXMPPConnection) {
34 | return new ContactsManager(abstractXMPPConnection);
35 | }
36 |
37 | public List getContactList() {
38 | return contactList;
39 | }
40 |
41 | private void loadRoster() {
42 | Roster roster = Roster.getInstanceFor(abstractXMPPConnection);
43 | Collection entries = roster.getEntries();
44 | for(RosterEntry entry : entries) {
45 | Log.d("Roster", "User: " + entry.getUser() + " Name: " + entry.getName() + " Status: " + entry.getStatus());
46 | }
47 | Collection groups = roster.getGroups();
48 | for(RosterGroup group : groups) {
49 | Log.d("RosterGroup", "Name: " + group.getName() + " Entries: " + group.getEntryCount());
50 | }
51 | }
52 |
53 | private void loadContacts() {
54 | contactList = new ArrayList<>();
55 | Roster roster = Roster.getInstanceFor(abstractXMPPConnection);
56 | Collection rosterEntries = roster.getEntries();
57 | int id = 0;
58 | for(RosterEntry entry : rosterEntries) {
59 | SingleContact singleContact = new SingleContact();
60 | singleContact.setUID(id);
61 | singleContact.setName(entry.getName());
62 | singleContact.setConnectionId(entry.getUser());
63 | if(entry.getStatus() != null) singleContact.setStatus(entry.getStatus().name());
64 | contactList.add(singleContact);
65 | id++;
66 | }
67 | }
68 |
69 | public SingleContact getContact(int UID) {
70 | return contactList.get(UID);
71 | }
72 |
73 | public SingleContact getContact(String contactID) {
74 | for(SingleContact contact : contactList) {
75 | if(contact.getConnectionId().toLowerCase().equals(contactID.toLowerCase())) return contact;
76 | }
77 | return null;
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/views/NavigationDrawer.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.views;
2 |
3 | import android.app.Activity;
4 | import android.support.v7.widget.Toolbar;
5 | import android.util.Log;
6 | import android.view.View;
7 |
8 | import com.mikepenz.materialdrawer.Drawer;
9 | import com.mikepenz.materialdrawer.DrawerBuilder;
10 | import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
11 | import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
12 | import com.pddstudio.brbox.R;
13 | import com.pddstudio.brbox.StartActivity;
14 | import com.pddstudio.brbox.enums.Page;
15 | import com.pddstudio.brbox.managers.Navigate;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | /**
21 | * This Class was created by Patrick J
22 | * on 20.11.15. For more Details and Licensing
23 | * have a look at the README.md
24 | */
25 | public class NavigationDrawer implements Drawer.OnDrawerItemClickListener {
26 |
27 | private DrawerBuilder drawerBuilder;
28 | private final Activity activity;
29 |
30 | public NavigationDrawer(Activity activity) {
31 | this.activity = activity;
32 | drawerBuilder = new DrawerBuilder(activity);
33 | }
34 |
35 | public NavigationDrawer addToolbar(Toolbar toolbar) {
36 | drawerBuilder.withToolbar(toolbar);
37 | return this;
38 | }
39 |
40 | public Drawer create() {
41 | drawerBuilder
42 | .withDrawerItems(getDrawerItems())
43 | .withOnDrawerItemClickListener(this)
44 | .withHeader(R.layout.drawer_header)
45 | .withDisplayBelowStatusBar(true)
46 | .withActionBarDrawerToggle(true)
47 | .withActionBarDrawerToggleAnimated(true);
48 | return drawerBuilder.build();
49 | }
50 |
51 | private ArrayList getDrawerItems() {
52 | ArrayList drawerItems = new ArrayList<>();
53 |
54 | //TODO: Add icons to the items
55 |
56 | //Home-Item
57 | PrimaryDrawerItem homeItem = new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIdentifier(Navigate.PAGE_HOME);
58 | drawerItems.add(homeItem);
59 |
60 | //Accounts-Item
61 | PrimaryDrawerItem accountsItem = new PrimaryDrawerItem().withName(R.string.drawer_item_accounts).withIdentifier(Navigate.PAGE_ACCOUNTS);
62 | drawerItems.add(accountsItem);
63 |
64 | //Commands-Item
65 | PrimaryDrawerItem commandsItem = new PrimaryDrawerItem().withName(R.string.drawer_item_commands).withIdentifier(Navigate.PAGE_COMMANDS);
66 | drawerItems.add(commandsItem);
67 |
68 | //About-Item
69 | PrimaryDrawerItem aboutItem = new PrimaryDrawerItem().withName(R.string.drawer_item_about).withIdentifier(Navigate.PAGE_ABOUT);
70 | drawerItems.add(aboutItem);
71 |
72 | return drawerItems;
73 | }
74 |
75 | @Override
76 | public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
77 | if(drawerItem != null) {
78 | Page p = Page.getPageForId(drawerItem.getIdentifier());
79 | if(p != null) Navigate.getInstance().to(p);
80 | else Log.e("NavigationDrawer", "Unable to change Page! ID not found...");
81 | }
82 | return true;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/async/OpenConnectionTask.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.async;
2 |
3 | import android.os.AsyncTask;
4 | import android.util.Log;
5 |
6 | import com.pddstudio.brtalk.BrTalk;
7 | import com.pddstudio.brtalk.callbacks.ServerConnectionCallback;
8 | import com.pddstudio.brtalk.objects.ClientSettings;
9 | import com.pddstudio.brtalk.objects.ConnectionObject;
10 | import com.pddstudio.brtalk.objects.ServerSettings;
11 | import org.jivesoftware.smack.AbstractXMPPConnection;
12 | import org.jivesoftware.smack.ConnectionConfiguration;
13 | import org.jivesoftware.smack.SASLAuthentication;
14 | import org.jivesoftware.smack.sasl.SASLMechanism;
15 | import org.jivesoftware.smack.sasl.provided.SASLDigestMD5Mechanism;
16 | import org.jivesoftware.smack.tcp.XMPPTCPConnection;
17 | import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
18 |
19 |
20 | /**
21 | * This Class was created by Patrick J
22 | * on 21.11.15. For more Details and Licensing
23 | * have a look at the README.md
24 | */
25 | public class OpenConnectionTask extends AsyncTask {
26 |
27 | private final ServerSettings serverSettings;
28 | private final ClientSettings clientSettings;
29 | private final ConnectionObject connectionObject;
30 |
31 | private AbstractXMPPConnection xmppConnection;
32 |
33 | public OpenConnectionTask(ConnectionObject connectionObject) {
34 | this.connectionObject = connectionObject;
35 | this.serverSettings = connectionObject.getServerSettings();
36 | this.clientSettings = connectionObject.getClientSettings();
37 | }
38 |
39 | @Override
40 | public void onPreExecute() {
41 | connectionObject.onPreparingXmppLogin();
42 | }
43 |
44 | @Override
45 | protected Boolean doInBackground(Void... params) {
46 | XMPPTCPConnectionConfiguration configuration = XMPPTCPConnectionConfiguration.builder()
47 | .setUsernameAndPassword(clientSettings.getUserName(), clientSettings.getUserPassword())
48 | .setHost(serverSettings.getServerDomain())
49 | .setServiceName(serverSettings.getServerDomain())
50 | .setPort(serverSettings.getServerPort())
51 | .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
52 | .setDebuggerEnabled(true)
53 | .build();
54 |
55 | xmppConnection = new XMPPTCPConnection(configuration);
56 | SASLMechanism saslMechanism = new SASLDigestMD5Mechanism();
57 | SASLAuthentication.registerSASLMechanism(saslMechanism);
58 | SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
59 | SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
60 |
61 |
62 | try {
63 | xmppConnection.connect();
64 | xmppConnection.login();
65 | Log.d("BrTalk", "Connection successful!");
66 | return true;
67 | } catch (Exception e) {
68 | Log.d("BrTalk", "Connection failed!");
69 | e.printStackTrace();
70 | return false;
71 | }
72 | }
73 |
74 | @Override
75 | public void onPostExecute(Boolean result) {
76 | if(result) connectionObject.setXmppConnection(xmppConnection);
77 | connectionObject.onXmppLoginResult(result);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | import com.pddstudio.brbox.R;
14 |
15 | /**
16 | * A fragment representing a list of Items.
17 | *
18 | * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener}
19 | * interface.
20 | */
21 | public class SettingsFragment extends Fragment {
22 |
23 | // TODO: Customize parameters
24 | private int mColumnCount = 1;
25 |
26 | private OnListFragmentInteractionListener mListener;
27 |
28 | /**
29 | * Mandatory empty constructor for the fragment manager to instantiate the
30 | * fragment (e.g. upon screen orientation changes).
31 | */
32 | public SettingsFragment() {
33 | }
34 |
35 | @Override
36 | public void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 |
39 | }
40 |
41 | @Override
42 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
43 | Bundle savedInstanceState) {
44 | View view = inflater.inflate(R.layout.fragment_settingsitem_list, container, false);
45 |
46 | // Set the adapter
47 | if (view instanceof RecyclerView) {
48 | Context context = view.getContext();
49 | RecyclerView recyclerView = (RecyclerView) view;
50 | if (mColumnCount <= 1) {
51 | recyclerView.setLayoutManager(new LinearLayoutManager(context));
52 | } else {
53 | recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
54 | }
55 | //recyclerView.setAdapter(new SettingsItemAdapter(DummyContent.ITEMS, mListener));
56 | }
57 | return view;
58 | }
59 |
60 |
61 | @Override
62 | public void onAttach(Context context) {
63 | super.onAttach(context);
64 | if (context instanceof OnListFragmentInteractionListener) {
65 | mListener = (OnListFragmentInteractionListener) context;
66 | } else {
67 | throw new RuntimeException(context.toString()
68 | + " must implement OnListFragmentInteractionListener");
69 | }
70 | }
71 |
72 | @Override
73 | public void onDetach() {
74 | super.onDetach();
75 | mListener = null;
76 | }
77 |
78 | /**
79 | * This interface must be implemented by activities that contain this
80 | * fragment to allow an interaction in this fragment to be communicated
81 | * to the activity and potentially other fragments contained in that
82 | * activity.
83 | *
84 | * See the Android Training lesson Communicating with Other Fragments for more information.
87 | */
88 | public interface OnListFragmentInteractionListener {
89 | // TODO: Update argument type and name
90 | void onListFragmentInteraction(String item);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
20 |
21 |
26 |
27 |
31 |
32 |
37 |
38 |
42 |
43 |
50 |
51 |
52 |
53 |
54 |
55 |
59 |
60 |
65 |
66 |
72 |
73 |
79 |
80 |
81 |
82 |
83 |
84 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/BrTalk.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 |
6 | import com.pddstudio.brtalk.async.OpenConnectionTask;
7 | import com.pddstudio.brtalk.callbacks.ServerConnectionCallback;
8 | import com.pddstudio.brtalk.callbacks.xmpp.XmppLoginCallback;
9 | import com.pddstudio.brtalk.managers.CommandGroupManager;
10 | import com.pddstudio.brtalk.managers.ContactsManager;
11 | import com.pddstudio.brtalk.objects.BoxCommand;
12 | import com.pddstudio.brtalk.objects.ClientSettings;
13 | import com.pddstudio.brtalk.objects.ConnectionObject;
14 | import com.pddstudio.brtalk.objects.ServerSettings;
15 | import com.pddstudio.brtalk.objects.SingleContact;
16 | import com.pddstudio.brtalk.services.ReceiverService;
17 |
18 | import org.jivesoftware.smack.AbstractXMPPConnection;
19 | import org.jivesoftware.smack.chat.Chat;
20 | import org.jivesoftware.smack.chat.ChatManager;
21 | import org.jivesoftware.smack.packet.Message;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * This Class was created by Patrick J
27 | * on 20.11.15. For more Details and Licensing
28 | * have a look at the README.md
29 | */
30 | public class BrTalk {
31 |
32 | //variables received from the ConnectionBuilder
33 | private final ConnectionObject connectionObject;
34 | private Context appContext;
35 |
36 | //optional identifier for the connection
37 | private final String connectionId;
38 |
39 | //for managing the contacts
40 | private ContactsManager contactsManager;
41 |
42 | private BrTalk(ConnectionBuilder connectionBuilder) {
43 | if(connectionBuilder.connectionId != null) this.connectionId = connectionBuilder.connectionId;
44 | else this.connectionId = "NONE";
45 | if(connectionBuilder.context != null) this.appContext = connectionBuilder.context;
46 | this.connectionObject = new ConnectionObject(connectionBuilder.serverSettings, connectionBuilder.clientSettings);
47 | }
48 |
49 | public void connect() {
50 | new OpenConnectionTask(connectionObject).execute();
51 | }
52 |
53 | public ConnectionObject getConnectionObject() {
54 | return connectionObject;
55 | }
56 |
57 | public Context getAppContext() {
58 | return appContext;
59 | }
60 |
61 | public List getContacts() {
62 | if(contactsManager == null) {
63 | this.contactsManager = connectionObject.getContactsManager();
64 | }
65 | return contactsManager.getContactList();
66 | }
67 |
68 | public List getCommands() {
69 | return null;
70 | //TODO: add command list
71 | }
72 |
73 | public static class ConnectionBuilder {
74 |
75 | private final ServerSettings serverSettings;
76 | private final ClientSettings clientSettings;
77 | private String connectionId;
78 | private Context context;
79 |
80 | public ConnectionBuilder(@NonNull ServerSettings serverSettings, @NonNull ClientSettings clientSettings) {
81 | this.serverSettings = serverSettings;
82 | this.clientSettings = clientSettings;
83 | }
84 |
85 | public ConnectionBuilder withConnectionID(String connectionId) {
86 | this.connectionId = connectionId;
87 | return this;
88 | }
89 |
90 | public ConnectionBuilder withContext(Context appContext) {
91 | this.context = appContext;
92 | return this;
93 | }
94 |
95 | public BrTalk build() {
96 | return new BrTalk(this);
97 | }
98 |
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/adapters/CommandRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.adapters;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.pddstudio.brbox.R;
10 | import com.pddstudio.brbox.managers.ContactCommandManager;
11 | import com.pddstudio.brbox.objects.CommandHistoryObject;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * This Class was created by Patrick J
17 | * on 24.11.15. For more Details and Licensing
18 | * have a look at the README.md
19 | */
20 | public class CommandRecyclerAdapter extends RecyclerView.Adapter implements ContactCommandManager.NotificationInterface {
21 |
22 | private List itemList;
23 | private ContactCommandManager contactCommandManager;
24 |
25 | public CommandRecyclerAdapter(ContactCommandManager commandHistoryObjects) {
26 | this.contactCommandManager = commandHistoryObjects;
27 | this.itemList = commandHistoryObjects.getHistoryObjectList();
28 | contactCommandManager.registerNotificationInterface(this);
29 | }
30 |
31 | @Override
32 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
33 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_contact_cmd_item, parent, false);
34 | //todo: align items layout and paddings
35 | return new ViewHolder(view);
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(ViewHolder holder, int position) {
40 | //todo: set the data for the viewholder items
41 | //getting the history object
42 | CommandHistoryObject historyObject = itemList.get(position);
43 | //request info
44 | holder.sendText.setText("Send Text: " + historyObject.getRequestObject().getBoxCommand().getCommandDesc());
45 | holder.sendDate.setText("Date: " + historyObject.getRequestObject().getRequestDate());
46 | //response info
47 | if(!historyObject.isRequestFailed()) {
48 | //on success
49 | holder.responseText.setText("ResponseText: " + historyObject.getResponseObject().getMessage().getBody());
50 | holder.responseDate.setText("Date: " + historyObject.getResponseObject().getResponseDate());
51 | } else {
52 | //on failed
53 | holder.responseText.setText("Request failed! " + historyObject.getRequestFailure().getFailDescriptionContentShort());
54 | holder.responseDate.setText("Date: " + historyObject.getRequestFailure().getFailDate());
55 | }
56 | }
57 |
58 | @Override
59 | public int getItemCount() {
60 | return itemList.size();
61 | }
62 |
63 | @Override
64 | public void onItemAdded(CommandHistoryObject commandHistoryObject) {
65 | if(itemList != null) itemList.add(commandHistoryObject);
66 | this.notifyDataSetChanged();
67 | }
68 |
69 | @Override
70 | public void onListReplaced() {
71 | if(itemList != null) itemList = contactCommandManager.getHistoryObjectList();
72 | this.notifyDataSetChanged();
73 | }
74 |
75 | public static class ViewHolder extends RecyclerView.ViewHolder {
76 | public TextView sendText;
77 | public TextView sendDate;
78 | public TextView responseText;
79 | public TextView responseDate;
80 |
81 | public ViewHolder(View itemView) {
82 | super(itemView);
83 | sendDate = (TextView) itemView.findViewById(R.id.request_date);
84 | sendText = (TextView) itemView.findViewById(R.id.request_text);
85 | responseDate = (TextView) itemView.findViewById(R.id.response_date);
86 | responseText = (TextView) itemView.findViewById(R.id.response_text);
87 | }
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/fragments/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.fragments;
2 |
3 |
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v7.widget.CardView;
10 | import android.util.Log;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.AdapterView;
15 | import android.widget.Button;
16 | import android.widget.EditText;
17 | import android.widget.ListView;
18 |
19 | import com.pddstudio.brbox.ChatActivity;
20 | import com.pddstudio.brbox.R;
21 | import com.pddstudio.brbox.TestClass;
22 | import com.pddstudio.brbox.adapters.ContactsAdapter;
23 | import com.pddstudio.brbox.managers.Navigate;
24 | import com.pddstudio.brbox.views.dialogs.ContactListDialog;
25 | import com.pddstudio.brbox.views.dialogs.NewConnectionDialog;
26 | import com.pddstudio.brtalk.callbacks.ServerConnectionCallback;
27 | import com.pddstudio.brtalk.objects.SingleContact;
28 |
29 |
30 | /**
31 | * A simple {@link Fragment} subclass.
32 | */
33 | public class HomeFragment extends Fragment {
34 |
35 | private static final String FRAGMENT_ID_IDENTIFIER = "FragmentID";
36 | private static final String FRAGMENT_TAG_IDENTIFIER = "FragmentTAG";
37 |
38 | private int fragmentID;
39 | private String fragmentTag;
40 |
41 | private CardView loginCard;
42 | private ListView contactListView;
43 | private ContactsAdapter contactsAdapter;
44 |
45 | public HomeFragment() {
46 | // Required empty public constructor
47 | }
48 |
49 | public static HomeFragment newInstance(int pageId, String pageIdent) {
50 | HomeFragment homeFragment = new HomeFragment();
51 | Bundle bundle = new Bundle();
52 | bundle.putInt(FRAGMENT_ID_IDENTIFIER, pageId);
53 | bundle.putString(FRAGMENT_TAG_IDENTIFIER, pageIdent);
54 | homeFragment.setArguments(bundle);
55 | return homeFragment;
56 | }
57 |
58 | @Override
59 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
60 | Bundle savedInstanceState) {
61 | // Inflate the layout for this fragment (and restoring saved information, if any)
62 | if(savedInstanceState == null) {
63 | this.fragmentTag = Navigate.PAGE_HOME_TAG;
64 | this.fragmentID = Navigate.PAGE_HOME;
65 | } else {
66 | this.fragmentTag = savedInstanceState.getString(FRAGMENT_TAG_IDENTIFIER);
67 | this.fragmentID = savedInstanceState.getInt(FRAGMENT_ID_IDENTIFIER);
68 | }
69 |
70 | final View root = inflater.inflate(R.layout.fragment_home, container, false);
71 |
72 | loginCard = (CardView) root.findViewById(R.id.home_login_card);
73 | loginCard.setVisibility(View.VISIBLE);
74 |
75 | final EditText userName = (EditText) root.findViewById(R.id.login_username_field);
76 | final EditText userPassword = (EditText) root.findViewById(R.id.login_password_field);
77 | Button loginButton = (Button) root.findViewById(R.id.login_button);
78 | loginButton.setOnClickListener(new View.OnClickListener() {
79 | @Override
80 | public void onClick(View v) {
81 | Log.d("LoginButton", "Username: " + userName.getText().toString() + " Password: " + userPassword.getText().toString());
82 | //Testing the connection via Test-Class
83 | TestClass.getInstance().openTestConnection(getContext());
84 | }
85 | });
86 |
87 | Button logoutButton = (Button) root.findViewById(R.id.logout_btn);
88 | logoutButton.setOnClickListener(new View.OnClickListener() {
89 | @Override
90 | public void onClick(View v) {
91 | TestClass.getInstance().logout();
92 | }
93 | });
94 |
95 | final Button contactList = (Button) root.findViewById(R.id.show_contacts_btn);
96 | contactList.setOnClickListener(new View.OnClickListener() {
97 | @Override
98 | public void onClick(View v) {
99 | ContactListDialog.show();
100 | if(TestClass.getInstance().hasContacts()) {
101 | contactsAdapter = new ContactsAdapter(TestClass.getInstance().getBrTalk());
102 | contactListView.setAdapter(contactsAdapter);
103 | contactsAdapter.reloadContacts();
104 | contactListView.setVisibility(View.VISIBLE);
105 | if(loginCard != null) loginCard.setVisibility(View.GONE);
106 | }
107 | }
108 | });
109 |
110 | contactListView = (ListView) root.findViewById(R.id.contact_list);
111 | contactListView.setVisibility(View.GONE);
112 |
113 | contactListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
114 | @Override
115 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
116 | //todo
117 | SingleContact contact = contactsAdapter.getItem(position);
118 | Snackbar.make(root, "Clicked on: " + contact.getName(), Snackbar.LENGTH_LONG).show();
119 | Intent details = new Intent(HomeFragment.this.getContext(), ChatActivity.class);
120 | details.putExtra(ChatActivity.CONTACT, contact);
121 | HomeFragment.this.startActivity(details);
122 | }
123 | });
124 |
125 | return root;
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/managers/ContactCommandManager.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.managers;
2 |
3 | import android.util.Log;
4 |
5 | import com.pddstudio.brbox.TestClass;
6 | import com.pddstudio.brbox.objects.CommandHistoryObject;
7 | import com.pddstudio.brtalk.BrTalk;
8 | import com.pddstudio.brtalk.callbacks.xmpp.XmppMessageCallback;
9 | import com.pddstudio.brtalk.objects.BoxCommand;
10 | import com.pddstudio.brtalk.objects.RequestFailure;
11 | import com.pddstudio.brtalk.objects.RequestObject;
12 | import com.pddstudio.brtalk.objects.ResponseObject;
13 | import com.pddstudio.brtalk.objects.SingleContact;
14 |
15 | import java.util.List;
16 |
17 | /**
18 | * This Class was created by Patrick J
19 | * on 25.11.15. For more Details and Licensing
20 | * have a look at the README.md
21 | */
22 | public class ContactCommandManager {
23 |
24 | public interface NotificationInterface {
25 | void onItemAdded(CommandHistoryObject commandHistoryObject);
26 | void onListReplaced();
27 | }
28 |
29 | private final SingleContact targetContact;
30 | private final BrTalk brTalk;
31 |
32 | private List historyObjectList;
33 |
34 | private NotificationInterface notificationInterface;
35 |
36 | private CommandHistoryObject commandHistoryObject;
37 |
38 | private ContactCommandManager(SingleContact contact) {
39 | this.targetContact = contact;
40 | this.historyObjectList = Preferences.getInstance().getSavedCommandHistory(contact);
41 | this.brTalk = TestClass.getInstance().getBrTalk();
42 | this.brTalk.getConnectionObject().addMessageCallback(messageCallback);
43 | }
44 |
45 | public static ContactCommandManager getHistory(SingleContact contact) {
46 | return new ContactCommandManager(contact);
47 | }
48 |
49 | //returns the List of saved commands for the given contact
50 | public List getHistoryObjectList() {
51 | return historyObjectList;
52 | }
53 |
54 | //adds a new entry to the list and saves it to the device's storage
55 | public void addHistoryObject(CommandHistoryObject commandHistoryObject) {
56 | historyObjectList.add(commandHistoryObject);
57 | Preferences.getInstance().saveCommandHistory(targetContact, historyObjectList);
58 | if(notificationInterface != null) notificationInterface.onItemAdded(commandHistoryObject);
59 | //todo: notifyDatasetChagned() call required on adapter to see changes
60 | }
61 |
62 | //clears the list of history entries for the given contact and deletes the data saved on the storage
63 | public void clearHistory() {
64 | historyObjectList.clear();
65 | Preferences.getInstance().saveCommandHistory(targetContact, historyObjectList);
66 | if(notificationInterface != null) notificationInterface.onListReplaced();
67 | //todo: notifyDatasetChanged() call required on adapter to see changes
68 | }
69 |
70 | //resets the current list and pulls a fresh 'checkout' from the backend
71 | public void reset() {
72 | historyObjectList.clear();
73 | historyObjectList = Preferences.getInstance().getSavedCommandHistory(targetContact);
74 | if(notificationInterface != null) notificationInterface.onListReplaced();
75 | }
76 |
77 | //returns whether the contact has a history or not
78 | public boolean hasHistory() {
79 | return !historyObjectList.isEmpty();
80 | }
81 |
82 | //sends a new command
83 | public void sendCommand(BoxCommand command) {
84 | commandHistoryObject = new CommandHistoryObject();
85 | RequestObject requestObject = new RequestObject(targetContact, command);
86 | brTalk.getConnectionObject().sendRequest(requestObject);
87 | }
88 |
89 | //register the notification interface
90 | public void registerNotificationInterface(NotificationInterface notificationInterface) {
91 | this.notificationInterface = notificationInterface;
92 | }
93 |
94 | private XmppMessageCallback messageCallback = new XmppMessageCallback() {
95 | @Override
96 | public void onPrepareRequest(RequestObject requestObject) {
97 | if(commandHistoryObject != null) {
98 | commandHistoryObject.setContactTarget(requestObject.getSingleContact());
99 | commandHistoryObject.setRequestObject(requestObject);
100 | Log.d("ContactCMD", "added target and request object to history object!");
101 | } else {
102 | Log.d("ContactCMD", "unable to add target and request object to history object!");
103 | }
104 | }
105 |
106 | @Override
107 | public void onServeResponse(ResponseObject responseObject) {
108 | if(commandHistoryObject != null) {
109 | commandHistoryObject.setResponseObject(responseObject);
110 | Log.d("ContactCMD", "added response object to history object!");
111 | ContactCommandManager.this.addHistoryObject(commandHistoryObject);
112 | commandHistoryObject = null;
113 | } else {
114 | Log.d("ContactCMD", "unable to add response object to history object!");
115 | }
116 | }
117 |
118 | @Override
119 | public void onRequestFailure(RequestFailure requestFailure) {
120 | if(commandHistoryObject != null) {
121 | commandHistoryObject.setRequestFailure(requestFailure);
122 | commandHistoryObject.setRequestFailed(true);
123 | Log.d("ContactCMD", "added request failure object to history object!");
124 | ContactCommandManager.this.addHistoryObject(commandHistoryObject);
125 | commandHistoryObject = null;
126 | } else {
127 | Log.d("ContactCMD", "unable to add failure object to history object!");
128 | }
129 | }
130 | };
131 |
132 | }
133 |
--------------------------------------------------------------------------------
/app/src/main/java/com/pddstudio/brbox/managers/Navigate.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brbox.managers;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentTransaction;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.util.Log;
10 |
11 | import com.pddstudio.brbox.R;
12 | import com.pddstudio.brbox.StartActivity;
13 | import com.pddstudio.brbox.enums.Page;
14 | import com.pddstudio.brbox.fragments.AboutFragment;
15 | import com.pddstudio.brbox.fragments.AccountFragment;
16 | import com.pddstudio.brbox.fragments.CommandFragment;
17 | import com.pddstudio.brbox.fragments.HomeFragment;
18 | import com.pddstudio.brbox.fragments.SingleContactFragment;
19 | import com.pddstudio.brtalk.objects.SingleContact;
20 |
21 | /**
22 | * This Class was created by Patrick J
23 | * on 20.11.15. For more Details and Licensing
24 | * have a look at the README.md
25 | */
26 | public class Navigate {
27 |
28 | //public identifiers
29 | public static final int PAGE_HOME = 0;
30 | public static final String PAGE_HOME_TAG = "FRAGMENT_HOME";
31 | public static final int PAGE_ABOUT = 1;
32 | public static final String PAGE_ABOUT_TAG = "FRAGMENT_ABOUT";
33 | public static final int PAGE_COMMANDS = 2;
34 | public static final String PAGE_COMMANDS_TAG = "FRAGMENT_CMD";
35 | public static final int PAGE_ACCOUNTS = 3;
36 | public static final String PAGE_ACCOUNTS_TAG = "FRAGMENT_ACC";
37 |
38 | //bundle identifier
39 | private static final String LAST_PAGE_ID = "FRAGMENT_ID";
40 | private static final String LAST_PAGE_TAG = "FRAGMENT_TAG";
41 |
42 | //singleton instance
43 | private static Navigate navigateInstance;
44 |
45 | private final StartActivity activity;
46 | private final Context context;
47 | private final FragmentManager fragmentManager;
48 |
49 | private Navigate(StartActivity appCompatActivity, Context context, FragmentManager fragmentManager) {
50 | this.activity = appCompatActivity;
51 | this.context = context;
52 | this.fragmentManager = fragmentManager;
53 | }
54 |
55 | public static Navigate init(StartActivity startActivity, Context context, FragmentManager fragmentManager) {
56 | navigateInstance = new Navigate(startActivity, context, fragmentManager);
57 | return navigateInstance;
58 | }
59 |
60 | public static Navigate getInstance() {
61 | return navigateInstance;
62 | }
63 |
64 | private String getFragmentTagForID(int fragmentID) {
65 | switch (fragmentID) {
66 | default:
67 | case PAGE_HOME:
68 | return PAGE_HOME_TAG;
69 | case PAGE_ABOUT:
70 | return PAGE_ABOUT_TAG;
71 | case PAGE_COMMANDS:
72 | return PAGE_COMMANDS_TAG;
73 | case PAGE_ACCOUNTS:
74 | return PAGE_ACCOUNTS_TAG;
75 | }
76 | }
77 |
78 | private void setFragment(int id, String tag) {
79 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
80 | switch (id) {
81 | case PAGE_HOME:
82 | HomeFragment homeFragment = (HomeFragment) fragmentManager.findFragmentByTag(PAGE_HOME_TAG);
83 | if(homeFragment == null) {
84 | Log.d("setFragment()", "HomeFragment was null. Creating new instance!");
85 | homeFragment = HomeFragment.newInstance(id, tag);
86 | }
87 | fragmentTransaction.replace(R.id.fragment_placeholder, homeFragment);
88 | break;
89 | case PAGE_ABOUT:
90 | AboutFragment aboutFragment = (AboutFragment) fragmentManager.findFragmentByTag(PAGE_ABOUT_TAG);
91 | if(aboutFragment == null) {
92 | Log.d("setFragment()", "AboutFragment was null. Creating new instance!");
93 | aboutFragment = AboutFragment.newInstance(id, tag);
94 | }
95 | fragmentTransaction.replace(R.id.fragment_placeholder, aboutFragment);
96 | break;
97 | case PAGE_COMMANDS:
98 | CommandFragment commandFragment = (CommandFragment) fragmentManager.findFragmentByTag(PAGE_COMMANDS_TAG);
99 | if(commandFragment == null) {
100 | Log.d("setFragment()", "CommandFragment was null. Creating new instance!");
101 | commandFragment = CommandFragment.newInstance(id, tag);
102 | }
103 | fragmentTransaction.replace(R.id.fragment_placeholder, commandFragment);
104 | break;
105 | case PAGE_ACCOUNTS:
106 | AccountFragment accountFragment = (AccountFragment) fragmentManager.findFragmentByTag(PAGE_ACCOUNTS_TAG);
107 | if(accountFragment == null) {
108 | Log.d("setFragment()", "AccountFragment was null. Creating new instance");
109 | accountFragment = AccountFragment.newInstance(id, tag);
110 | }
111 | fragmentTransaction.replace(R.id.fragment_placeholder, accountFragment);
112 | break;
113 | }
114 | fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
115 | fragmentTransaction.commit();
116 | Log.d("Navigate", "Commited FragmentTransaction! Target TAG: " + tag);
117 | if(activity != null) activity.closeDrawerIfOpen();
118 | }
119 |
120 | public void to(final int pageIdentifier) {
121 |
122 | }
123 |
124 | public void to(final String pageIdentifier) {
125 |
126 | }
127 |
128 | public void to(final Page page) {
129 | setFragment(page.getFragmentID(), page.getFragmentTag());
130 | }
131 |
132 | public void toBundleInfo(Bundle bundle) {
133 | //no default value required, as because getInt() will return 0 if the value wasn't found
134 | int pageID = bundle.getInt(LAST_PAGE_ID);
135 | String pageTag = bundle.getString(LAST_PAGE_TAG, getFragmentTagForID(pageID));
136 | setFragment(pageID, pageTag);
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/brtalk/src/main/java/com/pddstudio/brtalk/objects/ConnectionObject.java:
--------------------------------------------------------------------------------
1 | package com.pddstudio.brtalk.objects;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.util.Log;
5 |
6 | import com.pddstudio.brtalk.callbacks.xmpp.XmppLoginCallback;
7 | import com.pddstudio.brtalk.callbacks.xmpp.XmppLogoutCallback;
8 | import com.pddstudio.brtalk.callbacks.xmpp.XmppMessageCallback;
9 | import com.pddstudio.brtalk.managers.ContactsManager;
10 |
11 | import org.jivesoftware.smack.AbstractXMPPConnection;
12 | import org.jivesoftware.smack.chat.Chat;
13 | import org.jivesoftware.smack.chat.ChatManager;
14 | import org.jivesoftware.smack.chat.ChatMessageListener;
15 | import org.jivesoftware.smack.packet.Message;
16 |
17 | import java.util.ArrayList;
18 | import java.util.LinkedList;
19 | import java.util.List;
20 | import java.util.Queue;
21 |
22 | /**
23 | * This Class was created by Patrick J
24 | * on 23.11.15. For more Details and Licensing
25 | * have a look at the README.md
26 | */
27 | public class ConnectionObject implements XmppLoginCallback, XmppMessageCallback, XmppLogoutCallback {
28 |
29 | //connection information
30 | private final ClientSettings clientSettings;
31 | private final ServerSettings serverSettings;
32 | private AbstractXMPPConnection xmppConnection;
33 |
34 | //managers
35 | private ContactsManager contactsManager;
36 |
37 | //lists for the listeners
38 | private final List messageCallbackList = new ArrayList<>();
39 | private final List loginCallbackList = new ArrayList<>();
40 | private final List logoutCallbackList = new ArrayList<>();
41 |
42 | public ConnectionObject(ServerSettings serverSettings, ClientSettings clientSettings) {
43 | this.serverSettings = serverSettings;
44 | this.clientSettings = clientSettings;
45 | }
46 |
47 | //returns the server settings
48 | public ServerSettings getServerSettings() {
49 | return serverSettings;
50 | }
51 |
52 | //returns the client settings
53 | public ClientSettings getClientSettings() {
54 | return clientSettings;
55 | }
56 |
57 | //get the ContactsManager
58 | public ContactsManager getContactsManager() {
59 | return ContactsManager.forConnection(xmppConnection);
60 | }
61 |
62 | //the connection object - this is only used by the OpenConnectionTask after a successful login
63 | public void setXmppConnection(AbstractXMPPConnection xmppConnection) {
64 | this.xmppConnection = xmppConnection;
65 | }
66 |
67 | //this function needs to be replaced later - once everything is working TODO
68 | public AbstractXMPPConnection getXmppConnection() {
69 | return xmppConnection;
70 | }
71 |
72 | //method the check whether the connection is open or not
73 | public boolean isConnected() {
74 | if(xmppConnection == null) return false;
75 | return xmppConnection.isConnected();
76 | }
77 |
78 | //method to disconnect the current connection (if open)
79 | public void disconnect() {
80 | if(xmppConnection != null && xmppConnection.isConnected()) xmppConnection.disconnect();
81 | this.onLogout(!isConnected());
82 | }
83 |
84 | //for adding multiple XmppMessageCallback interfaces
85 | public void addMessageCallback(XmppMessageCallback messageCallbacks) {
86 | Log.d("Connection/O", "addMessageCallback() - a new listener has been added.");
87 | messageCallbackList.add(messageCallbacks);
88 | }
89 |
90 | //for adding multiple XmppLoginCallback interfaces
91 | public void addLoginCallback(XmppLoginCallback xmppLoginCallback) {
92 | Log.d("Connection/O", "addLoginCallback() - a new listener has been added.");
93 | loginCallbackList.add(xmppLoginCallback);
94 | }
95 |
96 | //for adding multiple XmppLogoutCallback interfaces
97 | public void addLogoutCallback(XmppLogoutCallback xmppLogoutCallback) {
98 | Log.d("Connection/O", "addLogoutCallback() - a new listener has been added.");
99 | logoutCallbackList.add(xmppLogoutCallback);
100 | }
101 |
102 | public void sendRequest(@NonNull RequestObject requestObject) {
103 | if(xmppConnection != null && xmppConnection.isConnected()) {
104 | this.onPrepareRequest(requestObject);
105 | try {
106 | ChatManager chatManager = ChatManager.getInstanceFor(xmppConnection);
107 | Chat chat = chatManager.createChat(requestObject.getSingleContact().getConnectionId());
108 | chat.addMessageListener(chatMessageListener);
109 | Message message = new Message();
110 | message.setBody(requestObject.getBoxCommand().getCommandTarget());
111 | message.setType(Message.Type.chat);
112 | chat.sendMessage(message);
113 | } catch (Exception e) {
114 | RequestFailure requestFailure = new RequestFailure(e.toString(), null, e.getLocalizedMessage());
115 | e.printStackTrace();
116 | this.onRequestFailure(requestFailure);
117 | }
118 | } else {
119 | RequestFailure requestFailure = new RequestFailure("XMPPConnectionFailure", "Unable to find connection.", null);
120 | this.onRequestFailure(requestFailure);
121 | }
122 | }
123 |
124 | private final ChatMessageListener chatMessageListener = new ChatMessageListener() {
125 | @Override
126 | public void processMessage(Chat chat, Message message) {
127 | ResponseObject responseObject = new ResponseObject(null, chat, message);
128 | ConnectionObject.this.onServeResponse(responseObject);
129 | }
130 | };
131 |
132 | @Override
133 | public void onPreparingXmppLogin() {
134 | Log.d("Connection/O", "onPreparingXmppLogin() - calling listeners.");
135 | for(XmppLoginCallback callback : loginCallbackList) {
136 | callback.onPreparingXmppLogin();
137 | }
138 | }
139 |
140 | @Override
141 | public void onXmppLoginResult(boolean loginSuccessful) {
142 | Log.d("Connection/O", "onXmppLoginResult() - calling listeners.");
143 | for(XmppLoginCallback callback : loginCallbackList) {
144 | callback.onXmppLoginResult(loginSuccessful);
145 | }
146 | }
147 |
148 | @Override
149 | public void onPrepareRequest(RequestObject requestObject) {
150 | Log.d("Connection/O", "onPrepareRequest() - calling listeners.");
151 | for(XmppMessageCallback callback : messageCallbackList) {
152 | callback.onPrepareRequest(requestObject);
153 | }
154 | }
155 |
156 | @Override
157 | public void onServeResponse(ResponseObject responseObject) {
158 | Log.d("Connection/O", "onServeResponse() - calling listeners.");
159 | for(XmppMessageCallback callback : messageCallbackList) {
160 | callback.onServeResponse(responseObject);
161 | }
162 | }
163 |
164 | @Override
165 | public void onRequestFailure(RequestFailure requestFailure) {
166 | Log.d("Connection/O", "onRequestFailure() - calling listeners.");
167 | for (XmppMessageCallback callback : messageCallbackList) {
168 | callback.onRequestFailure(requestFailure);
169 | }
170 | }
171 |
172 | @Override
173 | public void onLogout(boolean logoutSuccess) {
174 | Log.d("Connection/O", "onLogout() - calling listeners.");
175 | for (XmppLogoutCallback callback : logoutCallbackList) {
176 | callback.onLogout(logoutSuccess);
177 | }
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/brtalk/brtalk.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------