├── .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 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 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 |