Преглед изворни кода

Initial import

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic пре 7 година
комит
05d080b95c
100 измењених фајлова са 6531 додато и 0 уклоњено
  1. 56 0
      .gitignore
  2. 8 0
      .idea/compiler.xml
  3. 6 0
      .idea/copyright/GPL3.xml
  4. 7 0
      .idea/copyright/profiles_settings.xml
  5. 6 0
      .idea/encodings.xml
  6. 36 0
      .idea/misc.xml
  7. 9 0
      .idea/modules.xml
  8. 12 0
      .idea/runConfigurations.xml
  9. 6 0
      .idea/vcs.xml
  10. 674 0
      LICENCE
  11. 1 0
      app/.gitignore
  12. 114 0
      app/build.gradle
  13. 21 0
      app/proguard-rules.pro
  14. 26 0
      app/src/androidTest/java/com/nextcloud/talk/ExampleInstrumentedTest.java
  15. 30 0
      app/src/main/AndroidManifest.xml
  16. 93 0
      app/src/main/java/com/nextcloud/talk/activities/MainActivity.java
  17. 180 0
      app/src/main/java/com/nextcloud/talk/adapters/items/RoomItem.java
  18. 145 0
      app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java
  19. 184 0
      app/src/main/java/com/nextcloud/talk/api/NcApi.java
  20. 141 0
      app/src/main/java/com/nextcloud/talk/api/helpers/api/ApiHelper.java
  21. 34 0
      app/src/main/java/com/nextcloud/talk/api/models/RetrofitBucket.java
  22. 40 0
      app/src/main/java/com/nextcloud/talk/api/models/User.java
  23. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/call/Call.java
  24. 31 0
      app/src/main/java/com/nextcloud/talk/api/models/json/call/CallOCS.java
  25. 30 0
      app/src/main/java/com/nextcloud/talk/api/models/json/call/CallOverall.java
  26. 56 0
      app/src/main/java/com/nextcloud/talk/api/models/json/converters/EnumRoomTypeConverter.java
  27. 42 0
      app/src/main/java/com/nextcloud/talk/api/models/json/generic/GenericMeta.java
  28. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/generic/GenericOCS.java
  29. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/generic/GenericOverall.java
  30. 54 0
      app/src/main/java/com/nextcloud/talk/api/models/json/generic/Status.java
  31. 35 0
      app/src/main/java/com/nextcloud/talk/api/models/json/participants/AddParticipantOCS.java
  32. 31 0
      app/src/main/java/com/nextcloud/talk/api/models/json/participants/AddParticipantOverall.java
  33. 42 0
      app/src/main/java/com/nextcloud/talk/api/models/json/participants/Participant.java
  34. 33 0
      app/src/main/java/com/nextcloud/talk/api/models/json/participants/ParticipantsOCS.java
  35. 38 0
      app/src/main/java/com/nextcloud/talk/api/models/json/participants/ParticipantsOverall.java
  36. 69 0
      app/src/main/java/com/nextcloud/talk/api/models/json/rooms/Room.java
  37. 31 0
      app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomOCS.java
  38. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomOverall.java
  39. 39 0
      app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomsOCS.java
  40. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomsOverall.java
  41. 38 0
      app/src/main/java/com/nextcloud/talk/api/models/json/sharees/ExactSharees.java
  42. 39 0
      app/src/main/java/com/nextcloud/talk/api/models/json/sharees/Sharee.java
  43. 37 0
      app/src/main/java/com/nextcloud/talk/api/models/json/sharees/ShareesOCS.java
  44. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/sharees/ShareesOverall.java
  45. 42 0
      app/src/main/java/com/nextcloud/talk/api/models/json/sharees/SharesData.java
  46. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/sharees/Value.java
  47. 42 0
      app/src/main/java/com/nextcloud/talk/api/models/json/userprofile/UserProfileData.java
  48. 37 0
      app/src/main/java/com/nextcloud/talk/api/models/json/userprofile/UserProfileOCS.java
  49. 36 0
      app/src/main/java/com/nextcloud/talk/api/models/json/userprofile/UserProfileOverall.java
  50. 125 0
      app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java
  51. 223 0
      app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java
  52. 218 0
      app/src/main/java/com/nextcloud/talk/controllers/BottomNavigationController.java
  53. 346 0
      app/src/main/java/com/nextcloud/talk/controllers/CallsListController.java
  54. 391 0
      app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java
  55. 165 0
      app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.java
  56. 43 0
      app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java
  57. 222 0
      app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.java
  58. 70 0
      app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java
  59. 64 0
      app/src/main/java/com/nextcloud/talk/controllers/base/ButterKnifeController.java
  60. 57 0
      app/src/main/java/com/nextcloud/talk/controllers/base/RefWatchingController.java
  61. 25 0
      app/src/main/java/com/nextcloud/talk/controllers/base/providers/ActionBarProvider.java
  62. 38 0
      app/src/main/java/com/nextcloud/talk/dagger/modules/BusModule.java
  63. 41 0
      app/src/main/java/com/nextcloud/talk/dagger/modules/ContextModule.java
  64. 64 0
      app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java
  65. 104 0
      app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java
  66. 33 0
      app/src/main/java/com/nextcloud/talk/models/LoginData.java
  67. 43 0
      app/src/main/java/com/nextcloud/talk/persistence/entities/Cache.java
  68. 45 0
      app/src/main/java/com/nextcloud/talk/persistence/entities/User.java
  69. 190 0
      app/src/main/java/com/nextcloud/talk/utils/BundleBuilder.java
  70. 28 0
      app/src/main/java/com/nextcloud/talk/utils/BundleKeys.java
  71. 60 0
      app/src/main/java/com/nextcloud/talk/utils/CachingGlideModule.java
  72. 25 0
      app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java
  73. 47 0
      app/src/main/java/com/nextcloud/talk/utils/database/cache/CacheModule.java
  74. 72 0
      app/src/main/java/com/nextcloud/talk/utils/database/cache/CacheUtils.java
  75. 45 0
      app/src/main/java/com/nextcloud/talk/utils/database/user/UserModule.java
  76. 101 0
      app/src/main/java/com/nextcloud/talk/utils/database/user/UserUtils.java
  77. 31 0
      app/src/main/res/drawable/divider.xml
  78. 29 0
      app/src/main/res/drawable/ic_call_black_24dp.xml
  79. 9 0
      app/src/main/res/drawable/ic_group_black_24dp.xml
  80. 114 0
      app/src/main/res/drawable/ic_launcher_background.xml
  81. 29 0
      app/src/main/res/drawable/ic_person_black_24dp.xml
  82. 9 0
      app/src/main/res/drawable/ic_public_black_24dp.xml
  83. 36 0
      app/src/main/res/drawable/ic_search_white_24dp.xml
  84. 25 0
      app/src/main/res/drawable/ic_settings_black_24dp.xml
  85. 25 0
      app/src/main/res/drawable/ic_voice_chat_black_24dp.xml
  86. 31 0
      app/src/main/res/layout/activity_main.xml
  87. 54 0
      app/src/main/res/layout/controller_account_verification.xml
  88. 25 0
      app/src/main/res/layout/controller_bottom_navigation.xml
  89. 34 0
      app/src/main/res/layout/controller_generic_rv.xml
  90. 50 0
      app/src/main/res/layout/controller_server_selection.xml
  91. 26 0
      app/src/main/res/layout/controller_settings.xml
  92. 34 0
      app/src/main/res/layout/controller_web_view_login.xml
  93. 74 0
      app/src/main/res/layout/rv_item_call.xml
  94. 66 0
      app/src/main/res/layout/rv_item_contact.xml
  95. 33 0
      app/src/main/res/menu/menu_filter.xml
  96. 19 0
      app/src/main/res/menu/menu_navigation.xml
  97. 5 0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  98. 5 0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  99. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  100. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png

+ 56 - 0
.gitignore

@@ -0,0 +1,56 @@
+# Built application files
+*.apk
+*.ap_
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/dictionaries
+.idea/libraries
+
+# Keystore files
+*.jks
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+.DS_Store

+ 8 - 0
.idea/compiler.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="true" />
+    </annotationProcessing>
+  </component>
+</project>

+ 6 - 0
.idea/copyright/GPL3.xml

@@ -0,0 +1,6 @@
+<component name="CopyrightManager">
+  <copyright>
+    <option name="notice" value="Nextcloud Talk application&#10; &#10;@author Mario Danic&#10;Copyright (C) 2017 Mario Danic&#10; &#10;This program is free software: you can redistribute it and/or modify&#10;it under the terms of the GNU General Public License as published by&#10;the Free Software Foundation, either version 3 of the License, or&#10;at your option) any later version.&#10; &#10;This program is distributed in the hope that it will be useful,&#10;but WITHOUT ANY WARRANTY; without even the implied warranty of&#10;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&#10;GNU General Public License for more details.&#10; &#10;You should have received a copy of the GNU General Public License&#10;along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;." />
+    <option name="myName" value="GPL3" />
+  </copyright>
+</component>

+ 7 - 0
.idea/copyright/profiles_settings.xml

@@ -0,0 +1,7 @@
+<component name="CopyrightManager">
+  <settings>
+    <module2copyright>
+      <element module="Project Files" copyright="GPL3" />
+    </module2copyright>
+  </settings>
+</component>

+ 6 - 0
.idea/encodings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="PROJECT" charset="UTF-8" />
+  </component>
+</project>

+ 36 - 0
.idea/misc.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="NullableNotNullManager">
+    <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
+    <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
+    <option name="myNullables">
+      <value>
+        <list size="4">
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
+        </list>
+      </value>
+    </option>
+    <option name="myNotNulls">
+      <value>
+        <list size="4">
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
+        </list>
+      </value>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="ProjectType">
+    <option name="id" value="Android" />
+  </component>
+  <component name="SvnBranchConfigurationManager">
+    <option name="mySupportsUserInfoFilter" value="true" />
+  </component>
+</project>

+ 9 - 0
.idea/modules.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
+      <module fileurl="file://$PROJECT_DIR$/videocalls-android.iml" filepath="$PROJECT_DIR$/videocalls-android.iml" />
+    </modules>
+  </component>
+</project>

+ 12 - 0
.idea/runConfigurations.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="svn" />
+  </component>
+</project>

+ 674 - 0
LICENCE

@@ -0,0 +1,674 @@
+                      GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    {one line to give the program's name and a brief idea of what it does.}
+    Copyright (C) {year}  {name of author}
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    {project}  Copyright (C) {year}  {fullname}
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
+/build

+ 114 - 0
app/build.gradle

@@ -0,0 +1,114 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 26
+    buildToolsVersion '26.0.2'
+    defaultConfig {
+        applicationId "com.nextcloud.talk"
+        minSdkVersion 21
+        targetSdkVersion 26
+        versionCode 1
+        versionName "1.0"
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+        // Enabling multidex support.
+        multiDexEnabled true
+
+        vectorDrawables.useSupportLibrary = true
+
+        lintOptions {
+            disable 'InvalidPackage'
+        }
+
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    packagingOptions {
+        exclude 'META-INF/LICENSE'
+        exclude 'META-INF/NOTICE'
+        exclude 'META-INF/rxjava.properties'
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
+}
+
+ext {
+    supportLibraryVersion = '26.1.0'
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
+    implementation "com.android.support:design:${supportLibraryVersion}"
+    implementation 'com.android.support:multidex:1.0.2'
+
+    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
+    compile "io.reactivex.rxjava2:rxjava:2.1.4"
+
+    implementation 'com.bluelinelabs:conductor:2.1.4'
+    implementation 'com.bluelinelabs:conductor-support:2.1.4'
+
+    implementation 'com.squareup.okhttp3:okhttp:3.8.1'
+    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.6.0'
+    implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
+
+    implementation 'com.bluelinelabs:logansquare:1.3.7'
+    annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.7'
+
+    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
+    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
+    implementation 'com.github.aurae.retrofit2:converter-logansquare:1.4.1'
+
+    implementation 'com.google.dagger:dagger:2.8'
+    annotationProcessor 'com.google.dagger:dagger-compiler:2.8'
+    implementation 'com.github.lukaspili.autodagger2:autodagger2:1.1'
+    annotationProcessor 'com.github.lukaspili.autodagger2:autodagger2-compiler:1.1'
+
+    implementation 'org.greenrobot:eventbus:3.0.0'
+
+    compile 'io.requery:requery:1.4.0'
+    compile 'io.requery:requery-android:1.4.0'
+    compile 'net.zetetic:android-database-sqlcipher:3.5.7'
+    annotationProcessor 'io.requery:requery-processor:1.4.0'
+
+    compile 'org.parceler:parceler-api:1.1.9'
+    annotationProcessor 'org.parceler:parceler:1.1.9'
+
+    compile 'net.orange-box.storebox:storebox-lib:1.4.0'
+
+    compileOnly "org.projectlombok:lombok:1.16.18"
+    annotationProcessor "org.projectlombok:lombok:1.16.18"
+
+    compile 'com.jakewharton:butterknife:8.8.1'
+    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
+
+    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
+    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
+
+    compile "javax.transaction:transaction-api:1.1-rev-1"
+
+    compile 'com.github.HITGIF:TextFieldBoxes:1.3.4'
+
+    compile 'eu.davidea:flexible-adapter:5.0.0-rc2'
+
+    compile 'cn.carbs.android:AvatarImageView:1.0.4'
+
+    compile 'com.github.bumptech.glide:glide:4.2.0'
+    annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
+    compile 'com.github.bumptech.glide:okhttp3-integration:4.2.0@aar'
+
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {
+        exclude group: 'com.android.support', module: 'support-annotations'
+    })
+}

+ 21 - 0
app/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
app/src/androidTest/java/com/nextcloud/talk/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.nextcloud.talk;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() throws Exception {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getTargetContext();
+
+        assertEquals("com.nextcloud.talk", appContext.getPackageName());
+    }
+}

+ 30 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,30 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          xmlns:tools="http://schemas.android.com/tools"
+          package="com.nextcloud.talk">
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+
+    <application
+        android:name=".application.NextcloudTalkApplication"
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/nc_app_name"
+        android:roundIcon="@mipmap/ic_launcher_round"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+
+        <activity
+            android:name=".activities.MainActivity"
+            android:label="@string/nc_app_name"
+            android:launchMode="singleTask"
+            android:windowSoftInputMode="adjustResize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+        </activity>
+
+
+    </application>
+</manifest>

+ 93 - 0
app/src/main/java/com/nextcloud/talk/activities/MainActivity.java

@@ -0,0 +1,93 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.activities;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.ViewGroup;
+
+import com.bluelinelabs.conductor.Conductor;
+import com.bluelinelabs.conductor.Router;
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.bluelinelabs.conductor.changehandler.FadeChangeHandler;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.BottomNavigationController;
+import com.nextcloud.talk.controllers.ServerSelectionController;
+import com.nextcloud.talk.controllers.base.providers.ActionBarProvider;
+import com.nextcloud.talk.utils.database.user.UserUtils;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import io.requery.Persistable;
+import io.requery.reactivex.ReactiveEntityStore;
+
+@AutoInjector(NextcloudTalkApplication.class)
+public final class MainActivity extends AppCompatActivity implements ActionBarProvider {
+
+    @BindView(R.id.toolbar)
+    Toolbar toolbar;
+    @BindView(R.id.controller_container)
+    ViewGroup container;
+
+    @Inject
+    UserUtils userUtils;
+    @Inject
+    ReactiveEntityStore<Persistable> dataStore;
+
+    private Router router;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.activity_main);
+
+        NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
+        ButterKnife.bind(this);
+
+        setSupportActionBar(toolbar);
+
+        router = Conductor.attachRouter(this, container, savedInstanceState);
+
+
+        if (!router.hasRootController() && userUtils.anyUserExists()) {
+            router.setRoot(RouterTransaction.with(new BottomNavigationController(R.menu.menu_navigation))
+                    .pushChangeHandler(new FadeChangeHandler())
+                    .popChangeHandler(new FadeChangeHandler()));
+        } else if (!router.hasRootController()) {
+            router.setRoot(RouterTransaction.with(new ServerSelectionController())
+                    .pushChangeHandler(new FadeChangeHandler())
+                    .popChangeHandler(new FadeChangeHandler()));
+        }
+    }
+
+    @Override
+    public void onBackPressed() {
+        if (!router.handleBack()) {
+            super.onBackPressed();
+        }
+    }
+}

+ 180 - 0
app/src/main/java/com/nextcloud/talk/adapters/items/RoomItem.java

@@ -0,0 +1,180 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.adapters.items;
+
+import android.text.TextUtils;
+import android.text.format.DateUtils;
+import android.view.View;
+import android.widget.TextView;
+
+import com.bumptech.glide.load.model.GlideUrl;
+import com.bumptech.glide.load.model.LazyHeaders;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.api.models.json.rooms.Room;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.persistence.entities.UserEntity;
+import com.nextcloud.talk.utils.ColorUtils;
+import com.nextcloud.talk.utils.GlideApp;
+
+import java.util.List;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import cn.carbs.android.avatarimageview.library.AvatarImageView;
+import eu.davidea.flexibleadapter.FlexibleAdapter;
+import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
+import eu.davidea.flexibleadapter.items.IFilterable;
+import eu.davidea.flexibleadapter.utils.FlexibleUtils;
+import eu.davidea.viewholders.FlexibleViewHolder;
+
+public class RoomItem extends AbstractFlexibleItem<RoomItem.RoomItemViewHolder> implements IFilterable {
+
+    private Room room;
+    private UserEntity userEntity;
+
+    public RoomItem(Room room, UserEntity userEntity) {
+        this.room = room;
+        this.userEntity = userEntity;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof RoomItem) {
+            RoomItem inItem = (RoomItem) o;
+            return room.equals(inItem.getModel());
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return room.hashCode();
+    }
+
+    /**
+     * @return the model object
+     */
+
+    public Room getModel() {
+        return room;
+    }
+
+    /**
+     * Filter is applied to the model fields.
+     */
+
+    @Override
+    public int getLayoutRes() {
+        return R.layout.rv_item_call;
+    }
+
+    @Override
+    public RoomItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
+        return new RoomItemViewHolder(view, adapter);
+    }
+
+    @Override
+    public void bindViewHolder(final FlexibleAdapter adapter, RoomItemViewHolder holder, int position, List payloads) {
+        if (adapter.hasSearchText()) {
+            FlexibleUtils.highlightText(holder.roomDisplayName, room.getDisplayName(), adapter.getSearchText());
+        } else {
+            holder.roomDisplayName.setText(room.getDisplayName());
+        }
+
+        if (room.getLastPing() == 0) {
+            holder.roomLastPing.setText(R.string.nc_invited);
+        } else {
+            holder.roomLastPing.setText(DateUtils.getRelativeTimeSpanString(room.getLastPing() * 1000L,
+                    System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
+        }
+
+
+        switch (room.getType()) {
+            case ROOM_TYPE_ONE_TO_ONE_CALL:
+                holder.avatarImageView.setVisibility(View.VISIBLE);
+
+                holder.avatarImageViewInvisible.setTextAndColorSeed(String.valueOf(room.getDisplayName().
+                        toUpperCase().charAt(0)), ColorUtils.colorSeed);
+
+                if (!TextUtils.isEmpty(room.getName())) {
+                    GlideUrl glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
+                            room.getName()), new LazyHeaders.Builder()
+                            .addHeader("OCS-APIRequest", "true")
+                            .addHeader("User-Agent", ApiHelper.getUserAgent())
+                            .addHeader("Accept", "*/*")
+                            .addHeader("Authorization", () ->
+                                    ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()))
+                            .build());
+
+                    GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
+                            .asBitmap()
+                            .skipMemoryCache(true)
+                            .load(glideUrl)
+                            .placeholder(holder.avatarImageViewInvisible.getDrawable())
+                            .circleCrop()
+                            .centerInside()
+                            .into(holder.avatarImageView);
+                } else {
+                    holder.avatarImageView.setDrawable(holder.avatarImageViewInvisible.getDrawable());
+                }
+                break;
+            case ROOM_GROUP_CALL:
+                holder.avatarImageView.setVisibility(View.VISIBLE);
+                holder.avatarImageView.setImageResource(R.drawable.ic_group_black_24dp);
+                break;
+            case ROOM_PUBLIC_CALL:
+                holder.avatarImageView.setVisibility(View.VISIBLE);
+                holder.avatarImageView.setImageResource(R.drawable.ic_public_black_24dp);
+                break;
+            default:
+                holder.avatarImageView.setVisibility(View.GONE);
+
+        }
+    }
+
+    @Override
+    public boolean filter(String constraint) {
+        return room.getDisplayName() != null && room.getDisplayName().toLowerCase().trim().contains(
+                constraint.toLowerCase());
+
+    }
+
+    static class RoomItemViewHolder extends FlexibleViewHolder {
+
+        @BindView(R.id.name_text)
+        public TextView roomDisplayName;
+        @BindView(R.id.timestamp_text)
+        public TextView roomLastPing;
+        @BindView(R.id.avatar_image)
+        public AvatarImageView avatarImageView;
+        @BindView(R.id.avatar_image_invisible)
+        public AvatarImageView avatarImageViewInvisible;
+
+        /**
+         * Default constructor.
+         */
+        RoomItemViewHolder(View view, FlexibleAdapter adapter) {
+            super(view, adapter);
+            ButterKnife.bind(this, view);
+        }
+    }
+}

+ 145 - 0
app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java

@@ -0,0 +1,145 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.adapters.items;
+
+import android.view.View;
+import android.widget.TextView;
+
+import com.bumptech.glide.load.model.GlideUrl;
+import com.bumptech.glide.load.model.LazyHeaders;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.api.models.User;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.persistence.entities.UserEntity;
+import com.nextcloud.talk.utils.ColorUtils;
+import com.nextcloud.talk.utils.GlideApp;
+
+import java.util.List;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import cn.carbs.android.avatarimageview.library.AvatarImageView;
+import eu.davidea.flexibleadapter.FlexibleAdapter;
+import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
+import eu.davidea.flexibleadapter.items.IFilterable;
+import eu.davidea.flexibleadapter.utils.FlexibleUtils;
+import eu.davidea.viewholders.FlexibleViewHolder;
+
+public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder> implements IFilterable {
+
+    private User user;
+    private UserEntity userEntity;
+
+    public UserItem(User user, UserEntity userEntity) {
+        this.user = user;
+        this.userEntity = userEntity;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof UserItem) {
+            UserItem inItem = (UserItem) o;
+            return user.equals(inItem.getModel());
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return user.hashCode();
+    }
+
+    /**
+     * @return the model object
+     */
+
+    public User getModel() {
+        return user;
+    }
+
+    @Override
+    public int getLayoutRes() {
+        return R.layout.rv_item_contact;
+    }
+
+    @Override
+    public UserItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
+        return new UserItemViewHolder(view, adapter);
+    }
+
+    @Override
+    public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
+        if (adapter.hasSearchText()) {
+            FlexibleUtils.highlightText(holder.contactDisplayName, user.getName(), adapter.getSearchText());
+        } else {
+            holder.contactDisplayName.setText(user.getName());
+        }
+
+        // Awful hack
+        holder.avatarImageViewInvisible.setTextAndColorSeed(String.valueOf(user.getName().
+                toUpperCase().charAt(0)), ColorUtils.colorSeed);
+
+        GlideUrl glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
+                user.getUserId()), new LazyHeaders.Builder()
+                .addHeader("OCS-APIRequest", "true")
+                .addHeader("User-Agent", ApiHelper.getUserAgent())
+                .addHeader("Accept", "*/*")
+                .addHeader("Authorization", () ->
+                        ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()))
+                .build());
+
+        GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
+                .asBitmap()
+                .skipMemoryCache(true)
+                .placeholder(holder.avatarImageViewInvisible.getDrawable())
+                .load(glideUrl)
+                .circleCrop()
+                .centerInside()
+                .into(holder.avatarImageView);
+    }
+
+    @Override
+    public boolean filter(String constraint) {
+        return user.getName() != null && user.getName().toLowerCase().trim().contains(constraint.toLowerCase());
+    }
+
+
+    static class UserItemViewHolder extends FlexibleViewHolder {
+
+        @BindView(R.id.name_text)
+        public TextView contactDisplayName;
+        @BindView(R.id.avatar_image)
+        public AvatarImageView avatarImageView;
+        @BindView(R.id.avatar_image_invisible)
+        public AvatarImageView avatarImageViewInvisible;
+
+        /**
+         * Default constructor.
+         */
+        UserItemViewHolder(View view, FlexibleAdapter adapter) {
+            super(view, adapter);
+            ButterKnife.bind(this, view);
+        }
+    }
+
+
+}

+ 184 - 0
app/src/main/java/com/nextcloud/talk/api/NcApi.java

@@ -0,0 +1,184 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api;
+
+import com.nextcloud.talk.api.models.json.call.CallOverall;
+import com.nextcloud.talk.api.models.json.generic.Status;
+import com.nextcloud.talk.api.models.json.participants.AddParticipantOverall;
+import com.nextcloud.talk.api.models.json.participants.ParticipantsOverall;
+import com.nextcloud.talk.api.models.json.rooms.RoomOverall;
+import com.nextcloud.talk.api.models.json.rooms.RoomsOverall;
+import com.nextcloud.talk.api.models.json.sharees.ShareesOverall;
+import com.nextcloud.talk.api.models.json.userprofile.UserProfileOverall;
+
+import java.util.Map;
+
+import io.reactivex.Observable;
+import retrofit2.http.DELETE;
+import retrofit2.http.GET;
+import retrofit2.http.Header;
+import retrofit2.http.POST;
+import retrofit2.http.PUT;
+import retrofit2.http.QueryMap;
+import retrofit2.http.Url;
+
+public interface NcApi {
+
+    /*
+        QueryMap items are as follows:
+            - "format" : "json"
+            - "search" : ""
+            - "perPage" : "200"
+            - "itemType" : "call"
+
+        Server URL is: baseUrl + ocsApiVersion + /apps/files_sharing/api/v1/sharees
+     */
+    @GET
+    Observable<ShareesOverall> getContactsWithSearchParam(@Header("Authorization") String authorization, @Url String url,
+                                                          @QueryMap Map<String, String> options);
+
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room
+     */
+    @GET
+    Observable<RoomsOverall> getRooms(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken
+    */
+    @GET
+    Observable<RoomOverall> getRoom(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        QueryMap items are as follows:
+            - "roomType" : ""
+            - "invite" : ""
+
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room
+     */
+
+    @POST
+    Observable<RoomOverall> createRoom(@Header("Authorization") String authorization, @Url String url,
+                                       @QueryMap Map<String, String> options);
+
+    /*
+        QueryMap items are as follows:
+            - "roomName" : "newName"
+
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken
+     */
+
+    @PUT
+    Observable<Void> renameRoom(@Header("Authorization") String authorization, @Url String url,
+                                @QueryMap Map<String, String> options);
+
+
+    /*
+        QueryMap items are as follows:
+            - "newParticipant" : "user"
+
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/participants
+    */
+    @POST
+    Observable<AddParticipantOverall> addParticipant(@Header("Authorization") String authorization, @Url String url,
+                                                     @QueryMap Map<String, String> options);
+
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/participants/self
+     */
+
+    @DELETE
+    Observable<Void> removeSelfFromRoom(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/public
+    */
+    @POST
+    Observable<Void> makeRoomPublic(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/public
+    */
+    @DELETE
+    Observable<Void> makeRoomPrivate(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken
+    */
+    @GET
+    Observable<ParticipantsOverall> getPeersForCall(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken
+    */
+    @POST
+    Observable<CallOverall> joinCall(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken/ping
+    */
+    @POST
+    Observable<Void> pingCall(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /call/callToken
+    */
+    @DELETE
+    Observable<Void> leaveCall(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        QueryMap items are as follows:
+            - "messages" : "message"
+
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
+    */
+    @POST
+    Observable<Integer> sendSignalingMessages(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling
+    */
+    @GET
+    Observable<Integer> pullSignalingMessages(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + /index.php/avatar/userId/128
+        Avatar OkHttp
+    */
+
+     /*
+        QueryMap items are as follows:
+            - "format" : "json"
+
+        Server URL is: baseUrl + ocsApiVersion + "/cloud/user"
+    */
+
+    @GET
+    Observable<UserProfileOverall> getUserProfile(@Header("Authorization") String authorization, @Url String url);
+
+    /*
+        Server URL is: baseUrl + /status.php
+     */
+    @GET
+    Observable<Status> getServerStatus(@Url String url);
+}

+ 141 - 0
app/src/main/java/com/nextcloud/talk/api/helpers/api/ApiHelper.java

@@ -0,0 +1,141 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.helpers.api;
+
+import android.net.Uri;
+
+import com.nextcloud.talk.BuildConfig;
+import com.nextcloud.talk.api.models.RetrofitBucket;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import okhttp3.Credentials;
+
+public class ApiHelper {
+    private static String ocsApiVersion = "/ocs/v2.php";
+    private static String spreedApiVersion = "/apps/spreed/api/v1";
+
+    private static String userAgent = "Nextcloud Talk Android/v";
+
+    public static String getUserAgent() {
+        return userAgent + BuildConfig.VERSION_NAME;
+    }
+
+    public static RetrofitBucket getRetrofitBucketForContactsSearch(String baseUrl, String searchQuery) {
+        RetrofitBucket retrofitBucket = new RetrofitBucket();
+        retrofitBucket.setUrl(baseUrl + ocsApiVersion + "/apps/files_sharing/api/v1/sharees");
+
+        Map<String, String> queryMap = new HashMap<>();
+
+        queryMap.put("format", "json");
+        queryMap.put("search", searchQuery);
+        queryMap.put("perPage", "200");
+        queryMap.put("itemType", "call");
+
+        retrofitBucket.setQueryMap(queryMap);
+
+        return retrofitBucket;
+    }
+
+    public static String getUrlForGetRooms(String baseUrl) {
+        return baseUrl + ocsApiVersion + spreedApiVersion + "/room";
+    }
+
+    public static String getRoom(String baseUrl, String token) {
+        return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token;
+    }
+
+    public static RetrofitBucket getRetrofitBucketForCreateRoom(String baseUrl, String roomType, String invite) {
+        RetrofitBucket retrofitBucket = new RetrofitBucket();
+        retrofitBucket.setUrl(baseUrl + ocsApiVersion + spreedApiVersion + "/room");
+        Map<String, String> queryMap = new HashMap<>();
+
+        queryMap.put("roomType", roomType);
+        queryMap.put("invite", invite);
+
+        retrofitBucket.setQueryMap(queryMap);
+
+        return retrofitBucket;
+    }
+
+    public static RetrofitBucket getRetrofitBucketForRenameRoom(String baseUrl, String token, String newRoomName) {
+        RetrofitBucket retrofitBucket = new RetrofitBucket();
+        retrofitBucket.setUrl(baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token);
+
+        Map<String, String> queryMap = new HashMap<>();
+
+        queryMap.put("roomName", newRoomName);
+
+        retrofitBucket.setQueryMap(queryMap);
+
+        return retrofitBucket;
+    }
+
+    public static RetrofitBucket getRetrofitBucketForAddParticipant(String baseUrl, String token, String user) {
+        RetrofitBucket retrofitBucket = new RetrofitBucket();
+        retrofitBucket.setUrl(baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/participants");
+
+        Map<String, String> queryMap = new HashMap<>();
+
+        queryMap.put("newParticipant", user);
+
+        retrofitBucket.setQueryMap(queryMap);
+
+        return retrofitBucket;
+
+    }
+
+    public static String getUrlForRemoveSelfFromRoom(String baseUrl, String token) {
+        return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/participants/self";
+    }
+
+    public static String getUrlForRoomVisibility(String baseUrl, String token) {
+        return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/public";
+    }
+
+    public static String getUrlForCall(String baseUrl, String token) {
+        return baseUrl + ocsApiVersion + spreedApiVersion + "/call/" + token;
+    }
+
+    public static String getUrlForCallPing(String baseUrl, String token) {
+        return getUrlForCall(baseUrl, token) + "/ping";
+    }
+
+    public static String getUrlForSignaling(String baseUrl) {
+        return baseUrl + ocsApiVersion + spreedApiVersion + "/signaling";
+    }
+
+    public static String getUrlForUserProfile(String baseUrl) {
+        return baseUrl + ocsApiVersion + "/cloud/user";
+    }
+
+    public static String getUrlPostfixForStatus() {
+        return "/status.php";
+    }
+
+    public static String getUrlForAvatarWithName(String baseUrl, String name) {
+        return baseUrl + "/index.php/avatar/" + Uri.encode(name) + "/128";
+    }
+
+    public static String getCredentials(String username, String token) {
+        return Credentials.basic(username, token);
+    }
+}

+ 34 - 0
app/src/main/java/com/nextcloud/talk/api/models/RetrofitBucket.java

@@ -0,0 +1,34 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models;
+
+import org.parceler.Parcel;
+
+import java.util.Map;
+
+import lombok.Data;
+
+@Parcel
+@Data
+public class RetrofitBucket {
+    String url;
+    Map<String, String> queryMap;
+}

+ 40 - 0
app/src/main/java/com/nextcloud/talk/api/models/User.java

@@ -0,0 +1,40 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class User {
+    @JsonField(name = "userId")
+    String userId;
+    @JsonField(name = "type")
+    int type;
+    @JsonField(name = "name")
+    String name;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/call/Call.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.call;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class Call {
+    @JsonField(name = "sessionId")
+    String sessionId;
+}

+ 31 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/call/CallOCS.java

@@ -0,0 +1,31 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.call;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+
+@JsonObject
+public class CallOCS extends GenericOCS {
+    @JsonField(name = "data")
+    Call data;
+}

+ 30 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/call/CallOverall.java

@@ -0,0 +1,30 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.call;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+@JsonObject
+public class CallOverall {
+    @JsonField(name = "ocs")
+    CallOCS ocs;
+}

+ 56 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/converters/EnumRoomTypeConverter.java

@@ -0,0 +1,56 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.api.models.json.converters;
+
+import com.bluelinelabs.logansquare.typeconverters.IntBasedTypeConverter;
+import com.nextcloud.talk.api.models.json.rooms.Room;
+
+public class EnumRoomTypeConverter extends IntBasedTypeConverter<Room.RoomType> {
+    @Override
+    public Room.RoomType getFromInt(int i) {
+        switch (i) {
+            case 1:
+                return Room.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL;
+            case 2:
+                return Room.RoomType.ROOM_GROUP_CALL;
+            case 3:
+                return Room.RoomType.ROOM_PUBLIC_CALL;
+            default:
+                return Room.RoomType.DUMMY;
+        }
+    }
+
+    @Override
+    public int convertToInt(Room.RoomType object) {
+        switch (object) {
+            case DUMMY:
+                return 0;
+            case ROOM_TYPE_ONE_TO_ONE_CALL:
+                return 1;
+            case ROOM_GROUP_CALL:
+                return 2;
+            case ROOM_PUBLIC_CALL:
+                return 3;
+            default:
+                return 0;
+        }
+    }
+}

+ 42 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/generic/GenericMeta.java

@@ -0,0 +1,42 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.generic;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class GenericMeta {
+    @JsonField(name = "status")
+    String status;
+
+    @JsonField(name = "statuscode")
+    String statusCode;
+
+    @JsonField(name = "message")
+    String message;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/generic/GenericOCS.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.generic;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class GenericOCS {
+    @JsonField(name = "meta")
+    GenericMeta meta;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/generic/GenericOverall.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.generic;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class GenericOverall {
+    @JsonField(name = "ocs")
+    GenericOCS ocs;
+}

+ 54 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/generic/Status.java

@@ -0,0 +1,54 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.api.models.json.generic;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class Status {
+    @JsonField(name = "installed")
+    boolean installed;
+
+    @JsonField(name = "maintenance")
+    boolean maintenance;
+
+    @JsonField(name = "upgrade")
+    boolean needsUpgrade;
+
+    @JsonField(name = "version")
+    String version;
+
+    @JsonField(name = "versionstring")
+    String versionString;
+
+    @JsonField(name = "edition")
+    String edition;
+
+    @JsonField(name = "productname")
+    String productName;
+}

+ 35 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/participants/AddParticipantOCS.java

@@ -0,0 +1,35 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.participants;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+import com.nextcloud.talk.api.models.json.rooms.Room;
+
+@JsonObject
+public class AddParticipantOCS extends GenericOCS {
+    /*
+        Returned room will have only type set, and sometimes even that will be null
+     */
+    @JsonField(name = "data")
+    Room data;
+}

+ 31 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/participants/AddParticipantOverall.java

@@ -0,0 +1,31 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.participants;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.rooms.RoomsOCS;
+
+@JsonObject
+public class AddParticipantOverall {
+    @JsonField(name = "ocs")
+    RoomsOCS ocs;
+}

+ 42 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/participants/Participant.java

@@ -0,0 +1,42 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.participants;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class Participant {
+    @JsonField(name = "userId")
+    String userId;
+
+    @JsonField(name = "lastPing")
+    long lastPing;
+
+    @JsonField(name = "sessionId")
+    String sessionId;
+}

+ 33 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/participants/ParticipantsOCS.java

@@ -0,0 +1,33 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.participants;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+
+import java.util.List;
+
+@JsonObject
+public class ParticipantsOCS extends GenericOCS {
+    @JsonField(name = "data")
+    List<Participant> data;
+}

+ 38 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/participants/ParticipantsOverall.java

@@ -0,0 +1,38 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.participants;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class ParticipantsOverall {
+    @JsonField(name = "ocs")
+    List<Participant> ocs;
+}

+ 69 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/rooms/Room.java

@@ -0,0 +1,69 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.rooms;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.User;
+import com.nextcloud.talk.api.models.json.converters.EnumRoomTypeConverter;
+
+import org.parceler.Parcel;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class Room {
+    @JsonField(name = "id")
+    String roomId;
+    @JsonField(name = "token")
+    String token;
+    @JsonField(name = "name")
+    String name;
+    @JsonField(name = "displayName")
+    String displayName;
+    @JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
+    RoomType type;
+    @JsonField(name = "count")
+    long count;
+    @JsonField(name = "lastPing")
+    long lastPing;
+    @JsonField(name = "numGuests")
+    long numberOfGuests;
+    @JsonField(name = "guestList")
+    List<User> guestList;
+    @JsonField(name = "participants")
+    List<User> participants;
+    @JsonField(name = "hasPassword")
+    boolean hasPassword;
+    @JsonField(name = "sessionId")
+    String sessionId;
+
+    public enum RoomType {
+        DUMMY,
+        ROOM_TYPE_ONE_TO_ONE_CALL,
+        ROOM_GROUP_CALL,
+        ROOM_PUBLIC_CALL
+    }
+}

+ 31 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomOCS.java

@@ -0,0 +1,31 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.rooms;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+
+@JsonObject
+public class RoomOCS extends GenericOCS {
+    @JsonField(name = "data")
+    Room data;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomOverall.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.rooms;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class RoomOverall {
+    @JsonField(name = "ocs")
+    Room ocs;
+}

+ 39 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomsOCS.java

@@ -0,0 +1,39 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.rooms;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+
+import org.parceler.Parcel;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data
+@Parcel
+@JsonObject
+public class RoomsOCS extends GenericOCS {
+    @JsonField(name = "data")
+    List<Room> data;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/rooms/RoomsOverall.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.rooms;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Data
+@Parcel
+@JsonObject
+public class RoomsOverall {
+    @JsonField(name = "ocs")
+    RoomsOCS ocs;
+}

+ 38 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/sharees/ExactSharees.java

@@ -0,0 +1,38 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.sharees;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class ExactSharees {
+    @JsonField(name = "exact")
+    List<Sharee> exactSharees;
+}

+ 39 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/sharees/Sharee.java

@@ -0,0 +1,39 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.sharees;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class Sharee {
+    @JsonField(name = "value")
+    Value value;
+
+    @JsonField(name = "label")
+    String label;
+}

+ 37 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/sharees/ShareesOCS.java

@@ -0,0 +1,37 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.sharees;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Data
+@Parcel
+@JsonObject
+public class ShareesOCS extends GenericOCS {
+    @JsonField(name = "data")
+    SharesData data;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/sharees/ShareesOverall.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.sharees;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class ShareesOverall {
+    @JsonField(name = "ocs")
+    ShareesOCS ocs;
+}

+ 42 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/sharees/SharesData.java

@@ -0,0 +1,42 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.sharees;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class SharesData {
+    @JsonField(name = "users")
+    List<Sharee> users;
+
+    @JsonField(name = "exact")
+    ExactSharees exactUsers;
+
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/sharees/Value.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.sharees;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class Value {
+    @JsonField(name = "shareWith")
+    String shareWith;
+}

+ 42 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/userprofile/UserProfileData.java

@@ -0,0 +1,42 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.userprofile;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject()
+public class UserProfileData {
+    @JsonField(name = "display-name")
+    String displayName;
+
+    @JsonField(name = "displayname")
+    String displayNameAlt;
+
+    @JsonField(name = "id")
+    String userId;
+}

+ 37 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/userprofile/UserProfileOCS.java

@@ -0,0 +1,37 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.userprofile;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.api.models.json.generic.GenericOCS;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class UserProfileOCS extends GenericOCS {
+    @JsonField(name = "data")
+    UserProfileData data;
+}

+ 36 - 0
app/src/main/java/com/nextcloud/talk/api/models/json/userprofile/UserProfileOverall.java

@@ -0,0 +1,36 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.api.models.json.userprofile;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+@JsonObject
+public class UserProfileOverall {
+    @JsonField(name = "ocs")
+    UserProfileOCS ocs;
+}

+ 125 - 0
app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java

@@ -0,0 +1,125 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.application;
+
+import android.content.Context;
+import android.support.multidex.MultiDex;
+import android.support.multidex.MultiDexApplication;
+
+import com.nextcloud.talk.BuildConfig;
+import com.nextcloud.talk.dagger.modules.BusModule;
+import com.nextcloud.talk.dagger.modules.ContextModule;
+import com.nextcloud.talk.dagger.modules.DatabaseModule;
+import com.nextcloud.talk.dagger.modules.RestModule;
+import com.nextcloud.talk.utils.database.cache.CacheModule;
+import com.nextcloud.talk.utils.database.user.UserModule;
+import com.squareup.leakcanary.LeakCanary;
+import com.squareup.leakcanary.RefWatcher;
+
+import java.security.GeneralSecurityException;
+
+import javax.inject.Singleton;
+
+import autodagger.AutoComponent;
+import autodagger.AutoInjector;
+
+@AutoComponent(
+        modules = {
+                BusModule.class,
+                ContextModule.class,
+                DatabaseModule.class,
+                RestModule.class,
+                UserModule.class,
+                CacheModule.class
+        }
+)
+
+@Singleton
+@AutoInjector(NextcloudTalkApplication.class)
+public class NextcloudTalkApplication extends MultiDexApplication {
+    private static final String TAG = NextcloudTalkApplication.class.getSimpleName();
+
+    //region Public variables
+    public static RefWatcher refWatcher;
+    //endregion
+
+    //region Singleton
+    protected static NextcloudTalkApplication sharedApplication;
+    //region Fields (components)
+    protected NextcloudTalkApplicationComponent componentApplication;
+    //endregion
+
+    public static NextcloudTalkApplication getSharedApplication() {
+        return sharedApplication;
+    }
+    //endregion
+
+    //region Overridden methods
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        sharedApplication = this;
+
+        try {
+            buildComponent();
+        } catch (final GeneralSecurityException exception) {
+            if (BuildConfig.DEBUG) {
+                exception.printStackTrace();
+            }
+        }
+
+        componentApplication.inject(this);
+        refWatcher = LeakCanary.install(this);
+    }
+
+
+    @Override
+    public void onTerminate() {
+        super.onTerminate();
+        sharedApplication = null;
+    }
+    //endregion
+
+    //region Getters
+    public NextcloudTalkApplicationComponent getComponentApplication() {
+        return componentApplication;
+    }
+    //endregion
+
+    //region Protected methods
+    protected void buildComponent() throws GeneralSecurityException {
+        componentApplication = DaggerNextcloudTalkApplicationComponent.builder()
+                .busModule(new BusModule())
+                .contextModule(new ContextModule(getApplicationContext()))
+                .databaseModule(new DatabaseModule())
+                .restModule(new RestModule())
+                .userModule(new UserModule())
+                .cacheModule(new CacheModule())
+                .build();
+    }
+
+    @Override
+    protected void attachBaseContext(Context base) {
+        super.attachBaseContext(base);
+        MultiDex.install(this);
+    }
+    //endregion
+}

+ 223 - 0
app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java

@@ -0,0 +1,223 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.controllers;
+
+import android.content.pm.ActivityInfo;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.api.NcApi;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.utils.BundleKeys;
+import com.nextcloud.talk.utils.database.user.UserUtils;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import butterknife.BindView;
+import io.reactivex.CompletableObserver;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+
+
+@AutoInjector(NextcloudTalkApplication.class)
+public class AccountVerificationController extends BaseController {
+
+    public static final String TAG = "AccountVerificationController";
+
+    @Inject
+    NcApi ncApi;
+
+    @Inject
+    UserUtils userUtils;
+
+    @BindView(R.id.progress_text)
+    TextView progressText;
+
+    private Disposable roomsQueryDisposable;
+    private Disposable profileQueryDisposable;
+    private Disposable dbQueryDisposable;
+
+    private String baseUrl;
+    private String username;
+    private String token;
+
+    public AccountVerificationController(Bundle args) {
+        super(args);
+        if (args != null) {
+            baseUrl = args.getString(BundleKeys.KEY_BASE_URL);
+            username = args.getString(BundleKeys.KEY_USERNAME);
+            token = args.getString(BundleKeys.KEY_TOKEN);
+        }
+    }
+
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_account_verification, container, false);
+    }
+
+    @Override
+    protected void onViewBound(@NonNull View view) {
+        super.onViewBound(view);
+        NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
+
+        if (getActivity() != null) {
+            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+        }
+
+        dispose(null);
+
+        String credentials = ApiHelper.getCredentials(username, token);
+
+        roomsQueryDisposable = ncApi.getRooms(credentials, ApiHelper.getUrlForGetRooms(baseUrl))
+                .subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(roomsOverall -> {
+                    progressText.setText(String.format(getResources().getString(
+                            R.string.nc_nextcloud_talk_app_installed), getResources().getString(R.string.nc_app_name)));
+
+                    profileQueryDisposable = ncApi.getUserProfile(credentials,
+                            ApiHelper.getUrlForUserProfile(baseUrl))
+                            .subscribeOn(Schedulers.newThread())
+                            .observeOn(AndroidSchedulers.mainThread())
+                            .subscribe(userProfileOverall -> {
+                                progressText.setText(progressText.getText().toString() + "\n" +
+                                        getResources().getString(R.string.nc_display_name_fetched));
+
+                                String displayName = null;
+                                if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
+                                        .getDisplayName())) {
+                                    displayName = userProfileOverall.getOcs().getData()
+                                            .getDisplayName();
+                                } else if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
+                                        .getDisplayNameAlt())) {
+                                    displayName = userProfileOverall.getOcs().getData()
+                                            .getDisplayNameAlt();
+                                }
+
+                                if (!TextUtils.isEmpty(displayName)) {
+                                    dbQueryDisposable = userUtils.createOrUpdateUser(username, token,
+                                            baseUrl, displayName)
+                                            .subscribeOn(Schedulers.newThread())
+                                            .observeOn(AndroidSchedulers.mainThread())
+                                            .subscribe(userEntity -> {
+                                                        progressText.setText(progressText.getText().toString()
+                                                                + "\n" +
+                                                                getResources().getString(
+                                                                        R.string.nc_display_name_stored));
+                                                        getRouter().setRoot(RouterTransaction.with(new
+                                                                BottomNavigationController(R.menu.menu_navigation)));
+                                                    },
+                                                    throwable -> {
+                                                        progressText.setText(progressText.getText().toString() +
+                                                                "\n" +
+                                                                getResources().getString(
+                                                                        R.string.nc_display_name_not_stored));
+                                                        abortVerification();
+                                                    }, () -> dispose(dbQueryDisposable));
+
+                                } else {
+                                    progressText.setText(progressText.getText().toString() + "\n" +
+                                            getResources().getString(R.string.nc_display_name_not_fetched));
+                                    abortVerification();
+                                }
+                            }, throwable -> {
+                                progressText.setText(progressText.getText().toString()
+                                        + "\n" + getResources().getString(
+                                        R.string.nc_display_name_not_fetched));
+                                abortVerification();
+                            }, () -> dispose(profileQueryDisposable));
+
+                }, throwable -> {
+                    progressText.setText(String.format(getResources().getString(
+                            R.string.nc_nextcloud_talk_app_not_installed), getResources().getString(R.string.nc_app_name)));
+                    abortVerification();
+                }, () -> dispose(roomsQueryDisposable));
+
+
+    }
+
+    private void dispose(@Nullable Disposable disposable) {
+        if (disposable != null && !disposable.isDisposed()) {
+            disposable.dispose();
+        } else if (disposable == null) {
+            if (roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed()) {
+                roomsQueryDisposable.dispose();
+                roomsQueryDisposable = null;
+            }
+
+            if (profileQueryDisposable != null && !profileQueryDisposable.isDisposed()) {
+                profileQueryDisposable.dispose();
+                profileQueryDisposable = null;
+            }
+
+            if (dbQueryDisposable != null && !dbQueryDisposable.isDisposed()) {
+                dbQueryDisposable.dispose();
+                dbQueryDisposable = null;
+            }
+
+        }
+
+        disposable = null;
+    }
+
+    @Override
+    protected void onDestroyView(@NonNull View view) {
+        super.onDestroyView(view);
+        if (getActivity() != null) {
+            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
+        }
+    }
+
+    private void abortVerification() {
+        dispose(null);
+
+        userUtils.deleteUser(username, baseUrl).subscribe(new CompletableObserver() {
+            @Override
+            public void onSubscribe(Disposable d) {
+
+            }
+
+            @Override
+            public void onComplete() {
+                new Handler().postDelayed(() -> getRouter().popToRoot(), 5000);
+            }
+
+            @Override
+            public void onError(Throwable e) {
+
+            }
+        });
+    }
+
+}

+ 218 - 0
app/src/main/java/com/nextcloud/talk/controllers/BottomNavigationController.java

@@ -0,0 +1,218 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The bottom navigation was taken from a PR to Conductor by Chris6647@gmail.com
+ * https://github.com/bluelinelabs/Conductor/pull/316
+ * and of course modified by yours truly.      v v      xzcs     an
+ */
+
+package com.nextcloud.talk.controllers;
+
+import android.os.Bundle;
+import android.support.annotation.MenuRes;
+import android.support.annotation.NonNull;
+import android.support.design.widget.BottomNavigationView;
+import android.util.SparseArray;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import com.bluelinelabs.conductor.ChangeHandlerFrameLayout;
+import com.bluelinelabs.conductor.Controller;
+import com.bluelinelabs.conductor.Router;
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.utils.BundleBuilder;
+
+import butterknife.BindView;
+
+/**
+ * Backstack per menu item goes against Google Design Guidelines.
+ * https://material.io/guidelines/components/bottom-navigation.html#bottom-navigation-behavior
+ */
+public class BottomNavigationController extends BaseController {
+
+    public static final String TAG = "BottomNavigationController";
+
+    private static final String KEY_MENU_RESOURCE = "key_menu_resource";
+    private static final String KEY_STATE_ROUTER_BUNDLES = "key_state_router_bundles";
+    private static final String KEY_STATE_CURRENTLY_SELECTED_ID = "key_state_currently_selected_id";
+
+    @BindView(R.id.bottom_navigation_root)
+    LinearLayout bottomNavigationRoot;
+
+    @BindView(R.id.navigation)
+    BottomNavigationView bottomNavigationView;
+
+    @BindView(R.id.bottom_navigation_controller_container)
+    ChangeHandlerFrameLayout controllerContainer;
+
+    private int currentlySelectedItemId;
+
+    private SparseArray<Bundle> routerBundles;
+
+    private Router childRouter;
+
+    public BottomNavigationController(@MenuRes int menu) {
+        this(new BundleBuilder(new Bundle()).putInt(KEY_MENU_RESOURCE, menu).build());
+    }
+
+    public BottomNavigationController(Bundle args) {
+        super(args);
+    }
+
+    private static Controller getControllerFor(int menuItemId) {
+        Controller controller;
+        switch (menuItemId) {
+            case R.id.navigation_calls:
+                controller = new CallsListController();
+                break;
+            case R.id.navigation_contacts:
+                controller = new ContactsController();
+                break;
+            case R.id.navigation_settings:
+                controller = new SettingsController();
+                break;
+            default:
+                throw new IllegalStateException(
+                        "Unknown bottomNavigationView item selected.");
+        }
+        return controller;
+    }
+
+    @NonNull
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_bottom_navigation, container, false);
+    }
+
+    @Override
+    protected void onViewBound(@NonNull View view) {
+        super.onViewBound(view);
+
+        /* Setup the BottomNavigationView with the constructor supplied Menu resource */
+        bottomNavigationView.inflateMenu(getMenuResource());
+
+        Menu menu = bottomNavigationView.getMenu();
+        int menuSize = menu.size();
+
+        childRouter = getChildRouter(controllerContainer);
+
+        /*
+         * Not having access to Backstack or RouterTransaction constructors,
+         * we have to save/restore the entire routers for each backstack.
+         */
+        if (routerBundles == null) {
+            routerBundles = new SparseArray<>(menuSize);
+            for (int i = 0; i < menuSize; i++) {
+                MenuItem menuItem = menu.getItem(i);
+                int itemId = menuItem.getItemId();
+                /* Ensure the first checked item is shown */
+                if (menuItem.isChecked()) {
+                    childRouter.setRoot(RouterTransaction.with(BottomNavigationController.getControllerFor(
+                            itemId)));
+                    bottomNavigationView.setSelectedItemId(itemId);
+                    currentlySelectedItemId = bottomNavigationView.getSelectedItemId();
+                    break;
+                }
+            }
+        } else {
+            /*
+             * Since we are restoring our state,
+             * and onRestoreInstanceState is called before onViewBound,
+             * all we need to do is rebind.
+             */
+            childRouter.rebindIfNeeded();
+        }
+
+        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
+            @Override
+            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+                if (currentlySelectedItemId != item.getItemId()) {
+                    saveChildRouter(currentlySelectedItemId);
+                    clearChildRouter();
+
+                    currentlySelectedItemId = item.getItemId();
+                    Bundle routerBundle = routerBundles.get(currentlySelectedItemId);
+                    if (routerBundle != null && !routerBundle.isEmpty()) {
+                        childRouter.restoreInstanceState(routerBundle);
+                        childRouter.rebindIfNeeded();
+                    } else {
+                        childRouter.setRoot(RouterTransaction.with(BottomNavigationController.getControllerFor(
+                                currentlySelectedItemId)));
+                    }
+                    return true;
+                } else {
+                    return false;
+                }
+            }
+        });
+    }
+
+    private void saveChildRouter(int itemId) {
+        Bundle routerBundle = new Bundle();
+        childRouter.saveInstanceState(routerBundle);
+        routerBundles.put(itemId, routerBundle);
+    }
+
+    /**
+     * Removes ALL {@link Controller}'s in the child{@link Router}'s backstack
+     */
+    private void clearChildRouter() {
+        childRouter.setPopsLastView(true); /* Ensure the last view can be removed while we do this */
+        childRouter.popToRoot();
+        childRouter.popCurrentController();
+        childRouter.setPopsLastView(false);
+    }
+
+    private int getMenuResource() {
+        return getArgs().getInt(KEY_MENU_RESOURCE);
+    }
+
+    @Override
+    protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
+        routerBundles = savedInstanceState.getSparseParcelableArray(KEY_STATE_ROUTER_BUNDLES);
+        currentlySelectedItemId = savedInstanceState.getInt(KEY_STATE_CURRENTLY_SELECTED_ID);
+    }
+
+    @Override
+    protected void onSaveInstanceState(@NonNull Bundle outState) {
+        saveChildRouter(currentlySelectedItemId);
+        outState.putSparseParcelableArray(KEY_STATE_ROUTER_BUNDLES, routerBundles);
+        /*
+         * For some reason the BottomNavigationView does not seem to correctly restore its
+         * selectedId, even though the view appears with the correct state.
+         * So we keep track of it manually
+         */
+        outState.putInt(KEY_STATE_CURRENTLY_SELECTED_ID, currentlySelectedItemId);
+    }
+
+    @Override
+    public boolean handleBack() {
+        /*
+         * The childRouter should handleBack,
+         * as this BottomNavigationController doesn't have a back step sensible to the user.
+         */
+        return childRouter.handleBack();
+    }
+}

+ 346 - 0
app/src/main/java/com/nextcloud/talk/controllers/CallsListController.java

@@ -0,0 +1,346 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.controllers;
+
+import android.app.SearchManager;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.design.widget.BottomNavigationView;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.SearchView;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.inputmethod.EditorInfo;
+
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.bluelinelabs.conductor.changehandler.FadeChangeHandler;
+import com.bluelinelabs.logansquare.LoganSquare;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.adapters.items.RoomItem;
+import com.nextcloud.talk.api.NcApi;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.api.models.json.rooms.Room;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.persistence.entities.UserEntity;
+import com.nextcloud.talk.utils.database.cache.CacheUtils;
+import com.nextcloud.talk.utils.database.user.UserUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import butterknife.BindView;
+import eu.davidea.flexibleadapter.FlexibleAdapter;
+import eu.davidea.flexibleadapter.common.FlexibleItemDecoration;
+import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+
+@AutoInjector(NextcloudTalkApplication.class)
+public class CallsListController extends BaseController implements SearchView.OnQueryTextListener {
+
+    public static final String TAG = "CallsListController";
+
+    private static final String KEY_FROM_RESTORE_VIEW = "CallsListController.fromRestoreView";
+    private static final String KEY_SEARCH_QUERY = "ContactsController.searchQuery";
+
+    @Inject
+    UserUtils userUtils;
+
+    @Inject
+    CacheUtils cacheUtils;
+
+    @Inject
+    NcApi ncApi;
+    @BindView(R.id.recycler_view)
+    RecyclerView recyclerView;
+
+    @BindView(R.id.swipe_refresh_layout)
+    SwipeRefreshLayout swipeRefreshLayout;
+
+    private UserEntity userEntity;
+    private Disposable roomsQueryDisposable;
+    private Disposable cacheQueryDisposable;
+    private FlexibleAdapter<RoomItem> adapter;
+    private List<RoomItem> roomItems = new ArrayList<>();
+
+    private boolean isFromRestore;
+    private String searchQuery;
+
+    private MenuItem searchItem;
+    private SearchView searchView;
+
+    public CallsListController() {
+        super();
+        setHasOptionsMenu(true);
+    }
+
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_generic_rv, container, false);
+    }
+
+    @Override
+    protected void onViewBound(@NonNull View view) {
+        super.onViewBound(view);
+        NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
+
+        adapter = new FlexibleAdapter<>(roomItems, getActivity(), false);
+        prepareRecyclerView();
+
+        swipeRefreshLayout.setOnRefreshListener(() -> fetchData(true));
+        swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getResources().getColor(R.color.colorPrimary));
+    }
+
+    @Override
+    protected void onAttach(@NonNull View view) {
+        super.onAttach(view);
+
+        if ((userEntity = userUtils.getCurrentUser()) != null) {
+            if (!cacheUtils.cacheExistsForContext(TAG) || !isFromRestore) {
+                fetchData(true);
+            } else {
+                fetchData(false);
+            }
+        } else {
+            // Fallback to login if we have no users
+            if (getParentController().getRouter() != null) {
+                getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
+                        .pushChangeHandler(new FadeChangeHandler())
+                        .popChangeHandler(new FadeChangeHandler())));
+            }
+        }
+    }
+
+    private void initSearchView() {
+        if (getActivity() != null) {
+            SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
+            if (searchItem != null) {
+                searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
+                searchView.setMaxWidth(Integer.MAX_VALUE);
+                searchView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
+                searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN);
+                searchView.setQueryHint(getResources().getString(R.string.nc_search));
+                if (searchManager != null) {
+                    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
+                }
+                searchView.setOnQueryTextListener(this);
+            }
+        }
+
+        final View mSearchEditFrame = searchView
+                .findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
+
+        BottomNavigationView bottomNavigationView = getParentController().getView().findViewById(R.id.navigation);
+
+        Handler handler = new Handler();
+        ViewTreeObserver vto = mSearchEditFrame.getViewTreeObserver();
+        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+            int oldVisibility = -1;
+
+            @Override
+            public void onGlobalLayout() {
+
+                int currentVisibility = mSearchEditFrame.getVisibility();
+
+                if (currentVisibility != oldVisibility) {
+                    if (currentVisibility == View.VISIBLE) {
+                        handler.postDelayed(() -> bottomNavigationView.setVisibility(View.GONE), 100);
+                    } else {
+                        handler.postDelayed(() -> {
+                            bottomNavigationView.setVisibility(View.VISIBLE);
+                            searchItem.setVisible(roomItems.size() > 0);
+                        }, 500);
+                    }
+
+                    oldVisibility = currentVisibility;
+                }
+
+            }
+        });
+
+    }
+
+    @Override
+    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        super.onCreateOptionsMenu(menu, inflater);
+        inflater.inflate(R.menu.menu_filter, menu);
+        searchItem = menu.findItem(R.id.action_search);
+        initSearchView();
+    }
+
+    @Override
+    public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        searchItem.setVisible(roomItems.size() > 0);
+    }
+
+    private void fetchData(boolean forceNew) {
+        dispose(null);
+
+        roomItems = new ArrayList<>();
+
+        if (forceNew) {
+            roomsQueryDisposable = ncApi.getRooms(ApiHelper.getCredentials(userEntity.getUsername(),
+                    userEntity.getToken()), ApiHelper.getUrlForGetRooms(userEntity.getBaseUrl()))
+                    .subscribeOn(Schedulers.newThread())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(roomsOverall -> {
+
+                                if (roomsOverall != null) {
+                                    for (int i = 0; i < roomsOverall.getOcs().getData().size(); i++) {
+                                        roomItems.add(new RoomItem(roomsOverall.getOcs().getData().get(i), userEntity));
+                                    }
+
+                                    adapter.updateDataSet(roomItems, true);
+                                    if (searchItem != null) {
+                                        searchItem.setVisible(roomItems.size() > 0);
+                                    }
+
+                                    cacheQueryDisposable = cacheUtils.createOrUpdateViewCache(
+                                            LoganSquare.serialize(roomsOverall.getOcs().getData()),
+                                            userEntity.getId(), TAG).subscribe(cacheEntity -> {
+                                                // do nothing
+                                            }, throwable -> dispose(cacheQueryDisposable),
+                                            () -> dispose(cacheQueryDisposable));
+                                }
+                            }, throwable -> {
+                                if (searchItem != null) {
+                                    searchItem.setVisible(false);
+                                 }
+                                dispose(roomsQueryDisposable);
+                            }
+                            , () -> {
+                                dispose(roomsQueryDisposable);
+                                swipeRefreshLayout.setRefreshing(false);
+                            });
+        } else {
+            cacheQueryDisposable = cacheUtils.getViewCache(userEntity.getId(), TAG)
+                    .subscribe(o -> {
+                                if (o != null) {
+                                    List<Room> rooms = LoganSquare.parseList(o.getValue(), Room.class);
+                                    for (Room room : rooms) {
+                                        roomItems.add(new RoomItem(room, userEntity));
+                                    }
+
+                                    if (!TextUtils.isEmpty(searchQuery) && searchItem != null && searchView != null) {
+                                        searchItem.expandActionView();
+                                        searchView.setQuery(searchQuery, false);
+                                        recyclerView.setAdapter(null);
+                                        adapter.updateDataSet(roomItems, false);
+                                        onQueryTextSubmit(searchQuery);
+                                        recyclerView.setAdapter(adapter);
+                                    } else {
+                                        adapter.updateDataSet(roomItems, true);
+                                        if (searchItem != null) {
+                                            searchItem.setVisible(roomItems.size() > 0);
+                                        }
+                                    }
+                                }
+                            }, throwable -> {
+                                if (searchItem != null) {
+                                    searchItem.setVisible(false);
+                                }
+                                dispose(cacheQueryDisposable);
+                            },
+                            () -> dispose(cacheQueryDisposable));
+        }
+    }
+
+    private void prepareRecyclerView() {
+        recyclerView.setLayoutManager(new SmoothScrollLinearLayoutManager(getActivity()));
+        recyclerView.setHasFixedSize(true);
+        recyclerView.setAdapter(adapter);
+
+        recyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity())
+                .withDivider(R.drawable.divider));
+    }
+
+    private void dispose(@Nullable Disposable disposable) {
+        if (disposable != null && !disposable.isDisposed()) {
+            disposable.dispose();
+        } else if (disposable == null) {
+
+            if (roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed()) {
+                roomsQueryDisposable.dispose();
+                roomsQueryDisposable = null;
+            }
+
+            if (cacheQueryDisposable != null && !cacheQueryDisposable.isDisposed()) {
+                cacheQueryDisposable.dispose();
+                cacheQueryDisposable = null;
+            }
+        }
+    }
+
+
+    @Override
+    public void onSaveViewState(@NonNull View view, @NonNull Bundle outState) {
+        super.onSaveViewState(view, outState);
+        outState.putBoolean(KEY_FROM_RESTORE_VIEW, true);
+        if (searchView != null && !TextUtils.isEmpty(searchView.getQuery())) {
+            outState.putString(KEY_SEARCH_QUERY, searchView.getQuery().toString());
+        }
+    }
+
+    @Override
+    public void onRestoreViewState(@NonNull View view, @NonNull Bundle savedViewState) {
+        super.onRestoreViewState(view, savedViewState);
+        isFromRestore = savedViewState.getBoolean(KEY_FROM_RESTORE_VIEW, false);
+        searchQuery = savedViewState.getString(KEY_SEARCH_QUERY, "");
+    }
+
+    @Override
+    public boolean onQueryTextChange(String newText) {
+        if (adapter.hasNewSearchText(newText)) {
+            adapter.setSearchText(newText);
+
+            adapter.filterItems(300);
+        }
+
+        if (swipeRefreshLayout != null) {
+            swipeRefreshLayout.setEnabled(!adapter.hasSearchText());
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean onQueryTextSubmit(String query) {
+        return onQueryTextChange(query);
+    }
+}

+ 391 - 0
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java

@@ -0,0 +1,391 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.controllers;
+
+import android.app.SearchManager;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.design.widget.BottomNavigationView;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.SearchView;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.inputmethod.EditorInfo;
+
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.bluelinelabs.conductor.changehandler.FadeChangeHandler;
+import com.bluelinelabs.logansquare.LoganSquare;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.adapters.items.UserItem;
+import com.nextcloud.talk.api.NcApi;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.api.models.RetrofitBucket;
+import com.nextcloud.talk.api.models.User;
+import com.nextcloud.talk.api.models.json.sharees.Sharee;
+import com.nextcloud.talk.api.models.json.sharees.SharesData;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.persistence.entities.UserEntity;
+import com.nextcloud.talk.utils.database.cache.CacheUtils;
+import com.nextcloud.talk.utils.database.user.UserUtils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import butterknife.BindView;
+import eu.davidea.flexibleadapter.FlexibleAdapter;
+import eu.davidea.flexibleadapter.common.FlexibleItemDecoration;
+import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+
+@AutoInjector(NextcloudTalkApplication.class)
+public class ContactsController extends BaseController implements SearchView.OnQueryTextListener {
+
+    public static final String TAG = "ContactsController";
+
+    private static final String KEY_FROM_RESTORE_VIEW = "ContactsController.fromRestoreView";
+    private static final String KEY_SEARCH_QUERY = "ContactsController.searchQuery";
+
+    @Inject
+    UserUtils userUtils;
+
+    @Inject
+    CacheUtils cacheUtils;
+
+    @Inject
+    NcApi ncApi;
+    @BindView(R.id.recycler_view)
+    RecyclerView recyclerView;
+
+    @BindView(R.id.swipe_refresh_layout)
+    SwipeRefreshLayout swipeRefreshLayout;
+
+    private UserEntity userEntity;
+    private Disposable contactsQueryDisposable;
+    private Disposable cacheQueryDisposable;
+    private FlexibleAdapter<UserItem> adapter;
+    private List<UserItem> contactItems = new ArrayList<>();
+
+    private boolean isFromRestore;
+    private String searchQuery;
+
+    private MenuItem searchItem;
+    private SearchView searchView;
+
+    public ContactsController() {
+        super();
+        setHasOptionsMenu(true);
+    }
+
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_generic_rv, container, false);
+    }
+
+    @Override
+    protected void onViewBound(@NonNull View view) {
+        super.onViewBound(view);
+        NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
+
+        adapter = new FlexibleAdapter<>(contactItems, getActivity(), false);
+        prepareRecyclerView();
+
+        swipeRefreshLayout.setOnRefreshListener(() -> fetchData(true));
+        swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getResources().getColor(R.color.colorPrimary));
+    }
+
+    @Override
+    protected void onAttach(@NonNull View view) {
+        super.onAttach(view);
+
+        if ((userEntity = userUtils.getCurrentUser()) != null) {
+            if (!cacheUtils.cacheExistsForContext(TAG) || !isFromRestore) {
+                fetchData(true);
+            } else {
+                fetchData(false);
+            }
+        } else {
+            // Fallback to login if we have no users
+            if (getParentController().getRouter() != null) {
+                getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
+                        .pushChangeHandler(new FadeChangeHandler())
+                        .popChangeHandler(new FadeChangeHandler())));
+            }
+        }
+    }
+
+    private void initSearchView() {
+        if (getActivity() != null) {
+            SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
+            if (searchItem != null) {
+                searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
+                searchView.setMaxWidth(Integer.MAX_VALUE);
+                searchView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
+                searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN);
+                searchView.setQueryHint(getResources().getString(R.string.nc_search));
+                if (searchManager != null) {
+                    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
+                }
+                searchView.setOnQueryTextListener(this);
+            }
+        }
+
+        final View mSearchEditFrame = searchView
+                .findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
+
+        BottomNavigationView bottomNavigationView = getParentController().getView().findViewById(R.id.navigation);
+
+        Handler handler = new Handler();
+        ViewTreeObserver vto = mSearchEditFrame.getViewTreeObserver();
+        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+            int oldVisibility = -1;
+
+            @Override
+            public void onGlobalLayout() {
+
+                int currentVisibility = mSearchEditFrame.getVisibility();
+
+                if (currentVisibility != oldVisibility) {
+                    if (currentVisibility == View.VISIBLE) {
+                        handler.postDelayed(() -> bottomNavigationView.setVisibility(View.GONE), 100);
+                    } else {
+                        handler.postDelayed(() -> {
+                            bottomNavigationView.setVisibility(View.VISIBLE);
+                            searchItem.setVisible(contactItems.size() > 0);
+                        }, 500);
+                    }
+
+                    oldVisibility = currentVisibility;
+                }
+
+            }
+        });
+
+    }
+
+    @Override
+    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        super.onCreateOptionsMenu(menu, inflater);
+        inflater.inflate(R.menu.menu_filter, menu);
+        searchItem = menu.findItem(R.id.action_search);
+        initSearchView();
+    }
+
+    @Override
+    public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        searchItem.setVisible(contactItems.size() > 0);
+    }
+
+    private void fetchData(boolean forceNew) {
+        dispose(null);
+
+        Set<Sharee> shareeHashSet = new HashSet<>();
+
+        contactItems = new ArrayList<>();
+
+        if (forceNew) {
+            RetrofitBucket retrofitBucket = ApiHelper.getRetrofitBucketForContactsSearch(userEntity.getBaseUrl(),
+                    "");
+            contactsQueryDisposable = ncApi.getContactsWithSearchParam(
+                    ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()),
+                    retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
+                    .subscribeOn(Schedulers.newThread())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(shareesOverall -> {
+                                if (shareesOverall != null) {
+
+                                    if (shareesOverall.getOcs().getData().getUsers() != null) {
+                                        shareeHashSet.addAll(shareesOverall.getOcs().getData().getUsers());
+                                    }
+
+                                    if (shareesOverall.getOcs().getData().getExactUsers() != null &&
+                                            shareesOverall.getOcs().getData().getExactUsers().getExactSharees() != null) {
+                                        shareeHashSet.addAll(shareesOverall.getOcs().getData().
+                                                getExactUsers().getExactSharees());
+                                    }
+
+                                    User user;
+                                    for (Sharee sharee : shareeHashSet) {
+                                        if (!sharee.getValue().getShareWith().equals(userEntity.getUsername())) {
+                                            user = new User();
+                                            user.setName(sharee.getLabel());
+                                            user.setUserId(sharee.getValue().getShareWith());
+                                            contactItems.add(new UserItem(user, userEntity));
+                                        }
+
+                                    }
+
+                                    adapter.updateDataSet(contactItems, true);
+                                    searchItem.setVisible(contactItems.size() > 0);
+
+                                    cacheQueryDisposable = cacheUtils.createOrUpdateViewCache(
+                                            LoganSquare.serialize(shareesOverall.getOcs().getData()),
+                                            userEntity.getId(), TAG).subscribe(cacheEntity -> {
+                                                // do nothing
+                                            }, throwable -> dispose(cacheQueryDisposable),
+                                            () -> dispose(cacheQueryDisposable));
+                                }
+
+                            }, throwable -> {
+                                if (searchItem != null) {
+                                    searchItem.setVisible(false);
+                                }
+                                dispose(contactsQueryDisposable);
+                            }
+                            , () -> {
+                                swipeRefreshLayout.setRefreshing(false);
+                                dispose(contactsQueryDisposable);
+                            });
+        } else {
+            cacheQueryDisposable = cacheUtils.getViewCache(userEntity.getId(), TAG)
+                    .subscribeOn(Schedulers.newThread())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(o -> {
+                                if (o != null) {
+                                    SharesData sharesData = LoganSquare.parse(o.getValue(), SharesData.class);
+
+                                    if (sharesData.getUsers() != null) {
+                                        shareeHashSet.addAll(sharesData.getUsers());
+                                    }
+
+                                    if (sharesData.getExactUsers() != null && sharesData.getExactUsers()
+                                            .getExactSharees() != null) {
+                                        shareeHashSet.addAll(sharesData.getExactUsers().getExactSharees());
+                                    }
+
+                                    User user;
+                                    for (Sharee sharee : shareeHashSet) {
+                                        if (!sharee.getValue().getShareWith().equals(userEntity.getUsername())) {
+                                            user = new User();
+                                            user.setName(sharee.getLabel());
+                                            user.setUserId(sharee.getValue().getShareWith());
+                                            contactItems.add(new UserItem(user, userEntity));
+                                        }
+
+                                    }
+
+                                    if (!TextUtils.isEmpty(searchQuery) && searchItem != null && searchView != null) {
+                                        searchItem.expandActionView();
+                                        searchView.setQuery(searchQuery, false);
+                                        recyclerView.setAdapter(null);
+                                        adapter.updateDataSet(contactItems, false);
+                                        onQueryTextSubmit(searchQuery);
+                                        recyclerView.setAdapter(adapter);
+                                    } else {
+                                        adapter.updateDataSet(contactItems, true);
+                                        searchItem.setVisible(contactItems.size() > 0);
+                                    }
+
+                                }
+                            }, throwable -> {
+                                dispose(cacheQueryDisposable);
+                                if (searchItem != null) {
+                                    searchItem.setVisible(false);
+                                }
+                            },
+                            () -> {
+                                dispose(cacheQueryDisposable);
+                            });
+        }
+    }
+
+    private void prepareRecyclerView() {
+        recyclerView.setLayoutManager(new SmoothScrollLinearLayoutManager(getActivity()));
+        recyclerView.setHasFixedSize(true);
+        recyclerView.setAdapter(adapter);
+
+        recyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity())
+                .withDivider(R.drawable.divider));
+    }
+
+    private void dispose(@Nullable Disposable disposable) {
+        if (disposable != null && !disposable.isDisposed()) {
+            disposable.dispose();
+        } else if (disposable == null) {
+
+            if (contactsQueryDisposable != null && !contactsQueryDisposable.isDisposed()) {
+                contactsQueryDisposable.dispose();
+                contactsQueryDisposable = null;
+            }
+
+            if (cacheQueryDisposable != null && !cacheQueryDisposable.isDisposed()) {
+                cacheQueryDisposable.dispose();
+                cacheQueryDisposable = null;
+            }
+        }
+    }
+
+    @Override
+    public void onSaveViewState(@NonNull View view, @NonNull Bundle outState) {
+        super.onSaveViewState(view, outState);
+        outState.putBoolean(KEY_FROM_RESTORE_VIEW, true);
+        if (searchView != null && !TextUtils.isEmpty(searchView.getQuery())) {
+            outState.putString(KEY_SEARCH_QUERY, searchView.getQuery().toString());
+        }
+    }
+
+    @Override
+    public void onRestoreViewState(@NonNull View view, @NonNull Bundle savedViewState) {
+        super.onRestoreViewState(view, savedViewState);
+        isFromRestore = savedViewState.getBoolean(KEY_FROM_RESTORE_VIEW, false);
+        searchQuery = savedViewState.getString(KEY_SEARCH_QUERY, "");
+    }
+
+    @Override
+    public boolean onQueryTextChange(String newText) {
+        if (adapter.hasNewSearchText(newText)) {
+            adapter.setSearchText(newText);
+
+            adapter.filterItems(300);
+        }
+
+        if (swipeRefreshLayout != null) {
+            swipeRefreshLayout.setEnabled(!adapter.hasSearchText());
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean onQueryTextSubmit(String query) {
+        return onQueryTextChange(query);
+    }
+}

+ 165 - 0
app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.java

@@ -0,0 +1,165 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.controllers;
+
+import android.content.pm.ActivityInfo;
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.api.NcApi;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.base.BaseController;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import butterknife.BindView;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.schedulers.Schedulers;
+import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
+import studio.carbonylgroup.textfieldboxes.TextFieldBoxes;
+
+@AutoInjector(NextcloudTalkApplication.class)
+public class ServerSelectionController extends BaseController {
+
+    public static final String TAG = "ServerSelectionController";
+
+    @BindView(R.id.extended_edit_text)
+    ExtendedEditText serverEntry;
+    @BindView(R.id.text_field_boxes)
+    TextFieldBoxes textFieldBoxes;
+
+    @Inject
+    NcApi ncApi;
+
+    private Disposable statusQueryDisposable;
+
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_server_selection, container, false);
+    }
+
+    @Override
+    protected void onViewBound(@NonNull View view) {
+        super.onViewBound(view);
+        NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
+
+        if (getActivity() != null) {
+            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+        }
+
+        textFieldBoxes.setLabelText(getResources().getString(R.string.nc_app_name) + " " + getResources().getString(R.string.nc_appended_server_url));
+
+        serverEntry.requestFocus();
+
+        serverEntry.setOnEditorActionListener((textView, i, keyEvent) -> {
+            if (i == EditorInfo.IME_ACTION_DONE) {
+                dispose();
+
+                String url = serverEntry.getText().toString().trim();
+
+                if (url.startsWith("http://") || url.startsWith("https://")) {
+                    serverEntry.setEnabled(false);
+
+                    if (url.endsWith("/")) {
+                        url = url.substring(0, url.length() - 1);
+                    }
+
+                    String queryUrl = url + ApiHelper.getUrlPostfixForStatus();
+                    final String finalServerUrl = url;
+
+                    statusQueryDisposable = ncApi.getServerStatus(queryUrl)
+                            .subscribeOn(Schedulers.newThread())
+                            .observeOn(AndroidSchedulers.mainThread())
+                            .subscribe(status -> {
+                                String productName = getResources().getString(R.string.nc_server_product_name);
+
+                                if (status.isInstalled() && !status.isMaintenance() &&
+                                        !status.isNeedsUpgrade() &&
+                                        status.getProductName().equals(
+                                                getResources().getString(R.string.nc_server_product_name))) {
+
+                                    getRouter().pushController(RouterTransaction.with(
+                                            new WebViewLoginController(finalServerUrl)));
+                                } else if (!status.isInstalled()) {
+                                    textFieldBoxes.setError(String.format(
+                                            getResources().getString(R.string.nc_server_not_installed), productName),
+                                            true);
+                                } else if (status.isNeedsUpgrade()) {
+                                    textFieldBoxes.setError(String.format(getResources().
+                                            getString(R.string.nc_server_db_upgrade_needed), productName), true);
+                                } else if (status.isMaintenance()) {
+                                    textFieldBoxes.setError(String.format(getResources().
+                                                    getString(R.string.nc_server_maintenance), productName),
+                                            true);
+                                } else if (!status.getProductName().equals(
+                                        getResources().getString(R.string.nc_server_product_name))) {
+                                    textFieldBoxes.setError(String.format(getResources().
+                                                    getString(R.string.nc_server_not_nc),
+                                            getResources().getString(R.string.nc_app_name)
+                                            , productName), true);
+                                }
+
+                            }, throwable -> {
+                                textFieldBoxes.setError(throwable.getLocalizedMessage(), true);
+                                if (serverEntry != null) {
+                                    serverEntry.setEnabled(true);
+                                }
+                                dispose();
+
+                            }, this::dispose);
+                } else {
+                    textFieldBoxes.setError(getResources().getString(R.string.nc_server_url_prefix), true);
+                    serverEntry.setEnabled(true);
+                    return true;
+                }
+
+            }
+
+            return false;
+        });
+    }
+
+    @Override
+    protected void onDestroyView(@NonNull View view) {
+        super.onDestroyView(view);
+        if (getActivity() != null) {
+            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
+        }
+    }
+
+    private void dispose() {
+        if (statusQueryDisposable != null && !statusQueryDisposable.isDisposed()) {
+            statusQueryDisposable.dispose();
+        }
+
+        statusQueryDisposable = null;
+    }
+
+
+}

+ 43 - 0
app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java

@@ -0,0 +1,43 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.controllers;
+
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.base.BaseController;
+
+import autodagger.AutoInjector;
+
+@AutoInjector(NextcloudTalkApplication.class)
+public class SettingsController extends BaseController {
+
+    public static final String TAG = "SettingsController";
+
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_settings, container, false);
+    }
+}

+ 222 - 0
app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.java

@@ -0,0 +1,222 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.controllers;
+
+import android.content.pm.ActivityInfo;
+import android.net.http.SslError;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.SslErrorHandler;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+import com.bluelinelabs.conductor.RouterTransaction;
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.models.LoginData;
+import com.nextcloud.talk.utils.BundleBuilder;
+import com.nextcloud.talk.utils.BundleKeys;
+import com.nextcloud.talk.utils.database.user.UserUtils;
+
+import java.net.URLDecoder;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import butterknife.BindView;
+import io.reactivex.disposables.Disposable;
+import io.requery.Persistable;
+import io.requery.reactivex.ReactiveEntityStore;
+
+@AutoInjector(NextcloudTalkApplication.class)
+public class WebViewLoginController extends BaseController {
+
+    public static final String TAG = "WebViewLoginController";
+
+    private final String PROTOCOL_SUFFIX = "://";
+    private final String LOGIN_URL_DATA_KEY_VALUE_SEPARATOR = ":";
+
+    @Inject
+    UserUtils userUtils;
+    @Inject
+    ReactiveEntityStore<Persistable> dataStore;
+
+    @BindView(R.id.webview)
+    WebView webView;
+
+    private String assembledPrefix;
+
+    private Disposable userQueryDisposable;
+
+    private String baseUrl;
+
+    public WebViewLoginController(String baseUrl) {
+        this.baseUrl = baseUrl;
+    }
+
+    public WebViewLoginController(Bundle args) {
+        super(args);
+    }
+
+    @Override
+    protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        return inflater.inflate(R.layout.controller_web_view_login, container, false);
+    }
+
+    @Override
+    protected void onViewBound(@NonNull View view) {
+        super.onViewBound(view);
+        NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
+
+        if (getActivity() != null) {
+            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+        }
+
+        assembledPrefix = getResources().getString(R.string.nc_talk_login_scheme) + PROTOCOL_SUFFIX + "login/";
+
+        webView.getSettings().setAllowFileAccess(false);
+        webView.getSettings().setAllowFileAccessFromFileURLs(false);
+        webView.getSettings().setJavaScriptEnabled(true);
+        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
+        webView.getSettings().setDomStorageEnabled(true);
+        webView.getSettings().setUserAgentString(ApiHelper.getUserAgent());
+        webView.getSettings().setSaveFormData(false);
+        webView.getSettings().setSavePassword(false);
+        webView.clearCache(true);
+        webView.clearFormData();
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("OCS-APIRequest", "true");
+
+        webView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+                if (url.startsWith(assembledPrefix)) {
+                    parseAndLoginFromWebView(url);
+                    return true;
+                }
+                return false;
+            }
+
+            @Override
+            public void onPageFinished(WebView view, String url) {
+                super.onPageFinished(view, url);
+
+            }
+
+            @Override
+            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
+                super.onReceivedSslError(view, handler, error);
+            }
+
+            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
+                super.onReceivedError(view, errorCode, description, failingUrl);
+            }
+        });
+
+        webView.loadUrl(baseUrl + "/index.php/login/flow", headers);
+    }
+
+
+    private void dispose() {
+        if (userQueryDisposable != null && !userQueryDisposable.isDisposed()) {
+            userQueryDisposable.dispose();
+        }
+
+        userQueryDisposable = null;
+    }
+
+    private void parseAndLoginFromWebView(String dataString) {
+        LoginData loginData = parseLoginData(assembledPrefix, dataString);
+
+        if (loginData != null) {
+            dispose();
+
+            // We use the URL user entered because one provided by the server is NOT reliable
+            userQueryDisposable = userUtils.createOrUpdateUser(loginData.getUsername(), loginData.getToken(),
+                    baseUrl, null).subscribe(userEntity -> {
+                        BundleBuilder bundleBuilder = new BundleBuilder(new Bundle());
+                        bundleBuilder.putString(BundleKeys.KEY_USERNAME, userEntity.getUsername());
+                        bundleBuilder.putString(BundleKeys.KEY_TOKEN, userEntity.getToken());
+                        bundleBuilder.putString(BundleKeys.KEY_BASE_URL, userEntity.getBaseUrl());
+                        getRouter().pushController(RouterTransaction.with(new AccountVerificationController
+                                (bundleBuilder.build())));
+                    }, throwable -> dispose(),
+                    this::dispose);
+        }
+    }
+
+    private LoginData parseLoginData(String prefix, String dataString) {
+        if (dataString.length() < prefix.length()) {
+            return null;
+        }
+
+        LoginData loginData = new LoginData();
+
+        // format is xxx://login/server:xxx&user:xxx&password:xxx
+        String data = dataString.substring(prefix.length());
+
+        String[] values = data.split("&");
+
+        if (values.length != 3) {
+            return null;
+        }
+
+        for (String value : values) {
+            if (value.startsWith("user" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR)) {
+                loginData.setUsername(URLDecoder.decode(
+                        value.substring(("user" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR).length())));
+            } else if (value.startsWith("password" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR)) {
+                loginData.setToken(URLDecoder.decode(
+                        value.substring(("password" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR).length())));
+            } else if (value.startsWith("server" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR)) {
+                loginData.setServerUrl(URLDecoder.decode(
+                        value.substring(("server" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR).length())));
+            } else {
+                return null;
+            }
+        }
+
+        if (!TextUtils.isEmpty(loginData.getServerUrl()) && !TextUtils.isEmpty(loginData.getUsername()) &&
+                !TextUtils.isEmpty(loginData.getToken())) {
+            return loginData;
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    protected void onDestroyView(@NonNull View view) {
+        super.onDestroyView(view);
+        if (getActivity() != null) {
+            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
+        }
+    }
+
+}

+ 70 - 0
app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java

@@ -0,0 +1,70 @@
+/**
+ * Nextcloud Talk application
+ *
+ * @author BlueLine Labs, Inc.
+ * Copyright (C) 2016 BlueLine Labs, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.nextcloud.talk.controllers.base;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v7.app.ActionBar;
+import android.view.View;
+
+import com.bluelinelabs.conductor.Controller;
+import com.nextcloud.talk.controllers.base.providers.ActionBarProvider;
+
+public abstract class BaseController extends RefWatchingController {
+
+    protected BaseController() {
+    }
+
+    protected BaseController(Bundle args) {
+        super(args);
+    }
+
+    // Note: This is just a quick demo of how an ActionBar *can* be accessed, not necessarily how it *should*
+    // be accessed. In a production app, this would use Dagger instead.
+    protected ActionBar getActionBar() {
+        ActionBarProvider actionBarProvider = ((ActionBarProvider) getActivity());
+        return actionBarProvider != null ? actionBarProvider.getSupportActionBar() : null;
+    }
+
+    @Override
+    protected void onAttach(@NonNull View view) {
+        setTitle();
+        super.onAttach(view);
+    }
+
+    protected void setTitle() {
+        Controller parentController = getParentController();
+        while (parentController != null) {
+            if (parentController instanceof BaseController && ((BaseController) parentController).getTitle() != null) {
+                return;
+            }
+            parentController = parentController.getParentController();
+        }
+
+        String title = getTitle();
+        ActionBar actionBar = getActionBar();
+        if (title != null && actionBar != null) {
+            actionBar.setTitle(title);
+        }
+    }
+
+    protected String getTitle() {
+        return null;
+    }
+}

+ 64 - 0
app/src/main/java/com/nextcloud/talk/controllers/base/ButterKnifeController.java

@@ -0,0 +1,64 @@
+/**
+ * Nextcloud Talk application
+ *
+ * @author BlueLine Labs, Inc.
+ * Copyright (C) 2016 BlueLine Labs, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.nextcloud.talk.controllers.base;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.bluelinelabs.conductor.Controller;
+
+import butterknife.ButterKnife;
+import butterknife.Unbinder;
+
+public abstract class ButterKnifeController extends Controller {
+
+    private Unbinder unbinder;
+
+    protected ButterKnifeController() {
+    }
+
+    protected ButterKnifeController(Bundle args) {
+        super(args);
+    }
+
+    protected abstract View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container);
+
+    @NonNull
+    @Override
+    protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
+        View view = inflateView(inflater, container);
+        unbinder = ButterKnife.bind(this, view);
+        onViewBound(view);
+        return view;
+    }
+
+    protected void onViewBound(@NonNull View view) {
+    }
+
+    @Override
+    protected void onDestroyView(@NonNull View view) {
+        super.onDestroyView(view);
+        unbinder.unbind();
+        unbinder = null;
+    }
+
+}

+ 57 - 0
app/src/main/java/com/nextcloud/talk/controllers/base/RefWatchingController.java

@@ -0,0 +1,57 @@
+/**
+ * Nextcloud Talk application
+ *
+ * @author BlueLine Labs, Inc.
+ * Copyright (C) 2016 BlueLine Labs, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.nextcloud.talk.controllers.base;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+
+import com.bluelinelabs.conductor.ControllerChangeHandler;
+import com.bluelinelabs.conductor.ControllerChangeType;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+
+public abstract class RefWatchingController extends ButterKnifeController {
+
+    private boolean hasExited;
+
+    protected RefWatchingController() {
+    }
+
+    protected RefWatchingController(Bundle args) {
+        super(args);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+
+        if (hasExited) {
+            NextcloudTalkApplication.refWatcher.watch(this);
+        }
+    }
+
+    @Override
+    protected void onChangeEnded(@NonNull ControllerChangeHandler changeHandler, @NonNull ControllerChangeType changeType) {
+        super.onChangeEnded(changeHandler, changeType);
+
+        hasExited = !changeType.isEnter;
+        if (isDestroyed()) {
+            NextcloudTalkApplication.refWatcher.watch(this);
+        }
+    }
+}

+ 25 - 0
app/src/main/java/com/nextcloud/talk/controllers/base/providers/ActionBarProvider.java

@@ -0,0 +1,25 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author BlueLine Labs, Inc.
+ * Copyright (C) 2016 BlueLine Labs, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.nextcloud.talk.controllers.base.providers;
+
+import android.support.v7.app.ActionBar;
+
+public interface ActionBarProvider {
+    ActionBar getSupportActionBar();
+}

+ 38 - 0
app/src/main/java/com/nextcloud/talk/dagger/modules/BusModule.java

@@ -0,0 +1,38 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.dagger.modules;
+
+import org.greenrobot.eventbus.EventBus;
+
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class BusModule {
+
+    @Provides
+    @Singleton
+    public EventBus provideEventBus() {
+        return EventBus.getDefault();
+    }
+}

+ 41 - 0
app/src/main/java/com/nextcloud/talk/dagger/modules/ContextModule.java

@@ -0,0 +1,41 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.dagger.modules;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class ContextModule {
+    private final Context context;
+
+    public ContextModule(@NonNull final Context context) {
+        this.context = context;
+    }
+
+    @Provides
+    public Context provideContext() {
+        return context;
+    }
+}

+ 64 - 0
app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java

@@ -0,0 +1,64 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.dagger.modules;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+
+import com.nextcloud.talk.R;
+import com.nextcloud.talk.persistence.entities.Models;
+
+import net.orange_box.storebox.StoreBox;
+
+import java.util.prefs.Preferences;
+
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+import io.requery.Persistable;
+import io.requery.android.sqlcipher.SqlCipherDatabaseSource;
+import io.requery.reactivex.ReactiveEntityStore;
+import io.requery.reactivex.ReactiveSupport;
+import io.requery.sql.Configuration;
+import io.requery.sql.EntityDataStore;
+
+@Module
+public class DatabaseModule {
+
+    @Provides
+    @Singleton
+    public ReactiveEntityStore<Persistable> provideDataStore(@NonNull final Context context) {
+
+        final SqlCipherDatabaseSource source = new SqlCipherDatabaseSource(context, Models.DEFAULT,
+                context.getResources().getString(R.string.nc_app_name).toLowerCase()
+                        .replace(" ", "_").trim() + ".sqlite",
+                context.getString(R.string.nc_talk_database_encryption_key), 1);
+        final Configuration configuration = source.getConfiguration();
+        return ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
+    }
+
+    @Provides
+    @Singleton
+    public Preferences providePreferences(@NonNull final Context poContext) {
+        return StoreBox.create(poContext, Preferences.class);
+    }
+}

+ 104 - 0
app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java

@@ -0,0 +1,104 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.dagger.modules;
+
+import android.support.annotation.NonNull;
+
+import com.github.aurae.retrofit2.LoganSquareConverterFactory;
+import com.nextcloud.talk.BuildConfig;
+import com.nextcloud.talk.api.NcApi;
+import com.nextcloud.talk.api.helpers.api.ApiHelper;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+
+import java.io.IOException;
+
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.Cache;
+import okhttp3.Interceptor;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.logging.HttpLoggingInterceptor;
+import retrofit2.Retrofit;
+import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
+
+@Module
+public class RestModule {
+
+    @Provides
+    @Singleton
+    NcApi provideNcApi(Retrofit retrofit) {
+        return retrofit.create(NcApi.class);
+    }
+
+    @Provides
+    @Singleton
+    Retrofit provideRetrofit(OkHttpClient httpClient) {
+        Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
+                .client(httpClient)
+                .baseUrl("https://nextcloud.com")
+                .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io()))
+                .addConverterFactory(LoganSquareConverterFactory.create());
+
+        return retrofitBuilder.build();
+    }
+
+    @Provides
+    @Singleton
+    OkHttpClient provideHttpClient() {
+        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
+
+        int cacheSize = 128 * 1024 * 1024; // 128 MB
+
+        httpClient.cache(new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(), cacheSize));
+
+        if (BuildConfig.DEBUG) {
+            HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
+            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
+
+            httpClient.addInterceptor(loggingInterceptor);
+        }
+        httpClient.addInterceptor(new HeadersInterceptor());
+
+        return httpClient.build();
+    }
+
+    private class HeadersInterceptor implements Interceptor {
+
+        @Override
+        public Response intercept(@NonNull Chain chain) throws IOException {
+            Request original = chain.request();
+
+            Request request = original.newBuilder()
+                    .header("User-Agent", ApiHelper.getUserAgent())
+                    .header("Accept", "application/json")
+                    .header("OCS-APIRequest", "true")
+                    .method(original.method(), original.body())
+                    .build();
+
+            return chain.proceed(request);
+        }
+    }
+}

+ 33 - 0
app/src/main/java/com/nextcloud/talk/models/LoginData.java

@@ -0,0 +1,33 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.models;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Parcel
+@Data
+public class LoginData {
+    String serverUrl;
+    String username;
+    String token;
+}

+ 43 - 0
app/src/main/java/com/nextcloud/talk/persistence/entities/Cache.java

@@ -0,0 +1,43 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.persistence.entities;
+
+import android.os.Parcelable;
+
+import java.io.Serializable;
+
+import io.requery.Entity;
+import io.requery.Generated;
+import io.requery.Key;
+import io.requery.Persistable;
+
+@Entity
+public interface Cache extends Parcelable, Persistable, Serializable {
+    @Key
+    @Generated
+    long getId();
+
+    String getKey();
+
+    String getValue();
+
+    Long getUserId();
+}

+ 45 - 0
app/src/main/java/com/nextcloud/talk/persistence/entities/User.java

@@ -0,0 +1,45 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.persistence.entities;
+
+import android.os.Parcelable;
+
+import java.io.Serializable;
+
+import io.requery.Entity;
+import io.requery.Generated;
+import io.requery.Key;
+import io.requery.Persistable;
+
+@Entity
+public interface User extends Parcelable, Persistable, Serializable {
+    @Key
+    @Generated
+    long getId();
+
+    String getUsername();
+
+    String getBaseUrl();
+
+    String getToken();
+
+    String getDisplayName();
+}

+ 190 - 0
app/src/main/java/com/nextcloud/talk/utils/BundleBuilder.java

@@ -0,0 +1,190 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author BlueLine Labs, Inc.
+ * Copyright (C) 2016 BlueLine Labs, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.nextcloud.talk.utils;
+
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.util.SparseArray;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class BundleBuilder {
+
+    private final Bundle bundle;
+
+    public BundleBuilder(Bundle bundle) {
+        this.bundle = bundle;
+    }
+
+    public BundleBuilder putAll(Bundle bundle) {
+        this.bundle.putAll(bundle);
+        return this;
+    }
+
+    public BundleBuilder putBoolean(String key, boolean value) {
+        bundle.putBoolean(key, value);
+        return this;
+    }
+
+    public BundleBuilder putBooleanArray(String key, boolean[] value) {
+        bundle.putBooleanArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putDouble(String key, double value) {
+        bundle.putDouble(key, value);
+        return this;
+    }
+
+    public BundleBuilder putDoubleArray(String key, double[] value) {
+        bundle.putDoubleArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putLong(String key, long value) {
+        bundle.putLong(key, value);
+        return this;
+    }
+
+    public BundleBuilder putLongArray(String key, long[] value) {
+        bundle.putLongArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putString(String key, String value) {
+        bundle.putString(key, value);
+        return this;
+    }
+
+    public BundleBuilder putStringArray(String key, String[] value) {
+        bundle.putStringArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putBundle(String key, Bundle value) {
+        bundle.putBundle(key, value);
+        return this;
+    }
+
+    public BundleBuilder putByte(String key, byte value) {
+        bundle.putByte(key, value);
+        return this;
+    }
+
+    public BundleBuilder putByteArray(String key, byte[] value) {
+        bundle.putByteArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putChar(String key, char value) {
+        bundle.putChar(key, value);
+        return this;
+    }
+
+    public BundleBuilder putCharArray(String key, char[] value) {
+        bundle.putCharArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putCharSequence(String key, CharSequence value) {
+        bundle.putCharSequence(key, value);
+        return this;
+    }
+
+    public BundleBuilder putCharSequenceArray(String key, CharSequence[] value) {
+        bundle.putCharSequenceArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putCharSequenceArrayList(String key, ArrayList<CharSequence> value) {
+        bundle.putCharSequenceArrayList(key, value);
+        return this;
+    }
+
+    public BundleBuilder putInt(String key, int value) {
+        bundle.putInt(key, value);
+        return this;
+    }
+
+    public BundleBuilder putIntArray(String key, int[] value) {
+        bundle.putIntArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putFloat(String key, float value) {
+        bundle.putFloat(key, value);
+        return this;
+    }
+
+    public BundleBuilder putFloatArray(String key, float[] value) {
+        bundle.putFloatArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putIntegerArrayList(String key, ArrayList<Integer> value) {
+        bundle.putIntegerArrayList(key, value);
+        return this;
+    }
+
+    public BundleBuilder putParcelable(String key, Parcelable value) {
+        bundle.putParcelable(key, value);
+        return this;
+    }
+
+    public BundleBuilder putParcelableArray(String key, Parcelable[] value) {
+        bundle.putParcelableArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putParcelableArrayList(String key, ArrayList<? extends Parcelable> value) {
+        bundle.putParcelableArrayList(key, value);
+        return this;
+    }
+
+    public BundleBuilder putSerializable(String key, Serializable value) {
+        bundle.putSerializable(key, value);
+        return this;
+    }
+
+    public BundleBuilder putShort(String key, short value) {
+        bundle.putShort(key, value);
+        return this;
+    }
+
+    public BundleBuilder putShortArray(String key, short[] value) {
+        bundle.putShortArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putSparseParcelableArray(String key, SparseArray<? extends Parcelable> value) {
+        bundle.putSparseParcelableArray(key, value);
+        return this;
+    }
+
+    public BundleBuilder putStringArrayList(String key, ArrayList<String> value) {
+        bundle.putStringArrayList(key, value);
+        return this;
+    }
+
+    public Bundle build() {
+        return bundle;
+    }
+
+}

+ 28 - 0
app/src/main/java/com/nextcloud/talk/utils/BundleKeys.java

@@ -0,0 +1,28 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.utils;
+
+public class BundleKeys {
+    public static final String KEY_USERNAME = "KEY_USERNAME";
+    public static final String KEY_TOKEN = "KEY_TOKEN";
+    public static final String KEY_BASE_URL = "KEY_BASE_URL";
+
+}

+ 60 - 0
app/src/main/java/com/nextcloud/talk/utils/CachingGlideModule.java

@@ -0,0 +1,60 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.utils;
+
+
+import android.content.Context;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.GlideBuilder;
+import com.bumptech.glide.Registry;
+import com.bumptech.glide.annotation.GlideModule;
+import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
+import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
+import com.bumptech.glide.load.model.GlideUrl;
+import com.bumptech.glide.module.AppGlideModule;
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+
+import java.io.InputStream;
+
+import okhttp3.Cache;
+import okhttp3.OkHttpClient;
+
+@GlideModule
+public class CachingGlideModule extends AppGlideModule {
+    // 128 MB
+    private static final int OK_HTTP_CLIENT_CACHE = 128 * 1024 * 1024;
+    // 256 MB
+    private static final int IMAGE_CACHE_SIZE =  256 * 1024 * 1024;
+
+    @Override
+    public void registerComponents(Context context, Glide glide, Registry registry) {
+        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
+        httpClient.cache(new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(),
+                OK_HTTP_CLIENT_CACHE));
+        registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(httpClient.build()));
+    }
+
+    @Override
+    public void applyOptions(Context context, GlideBuilder builder) {
+        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, IMAGE_CACHE_SIZE));
+    }
+}

+ 25 - 0
app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java

@@ -0,0 +1,25 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.utils;
+
+public class ColorUtils {
+    public static String colorSeed = "ballast butte permute doxy graham rummage grateful songbook pledge escapade";
+}

+ 47 - 0
app/src/main/java/com/nextcloud/talk/utils/database/cache/CacheModule.java

@@ -0,0 +1,47 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.utils.database.cache;
+
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.dagger.modules.DatabaseModule;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import dagger.Module;
+import dagger.Provides;
+import io.requery.Persistable;
+import io.requery.reactivex.ReactiveEntityStore;
+
+@Module(includes = DatabaseModule.class)
+@AutoInjector(NextcloudTalkApplication.class)
+public class CacheModule {
+
+    @Inject
+    public CacheModule() {
+    }
+
+    @Provides
+    public CacheUtils provideCacheUtils(ReactiveEntityStore<Persistable> dataStore) {
+        return new CacheUtils(dataStore);
+    }
+
+}

+ 72 - 0
app/src/main/java/com/nextcloud/talk/utils/database/cache/CacheUtils.java

@@ -0,0 +1,72 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.utils.database.cache;
+
+import com.nextcloud.talk.persistence.entities.Cache;
+import com.nextcloud.talk.persistence.entities.CacheEntity;
+
+import io.reactivex.Observable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import io.requery.Persistable;
+import io.requery.query.Result;
+import io.requery.reactivex.ReactiveEntityStore;
+
+public class CacheUtils {
+    private ReactiveEntityStore<Persistable> dataStore;
+
+    CacheUtils(ReactiveEntityStore<Persistable> dataStore) {
+        this.dataStore = dataStore;
+
+    }
+
+    public boolean cacheExistsForContext(String context) {
+        return (dataStore.count(Cache.class).where(CacheEntity.KEY.eq(context)).limit(1).get().value() > 0);
+    }
+
+    public Observable<CacheEntity> getViewCache(Long userId, String context) {
+        return dataStore.select(CacheEntity.class).where(CacheEntity.KEY.eq(context).
+                and(CacheEntity.USER_ID.eq(userId))).limit(1).get().observable()
+                .subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread());
+    }
+
+    public Observable<CacheEntity> createOrUpdateViewCache(String cache, Long userId, String context) {
+        Result findUserQueryResult = dataStore.select(CacheEntity.class).where(CacheEntity.KEY.eq(context).
+                and(CacheEntity.USER_ID.eq(userId))).limit(1).get();
+
+        CacheEntity cacheEntity = (CacheEntity) findUserQueryResult.firstOrNull();
+
+        if (cacheEntity == null) {
+            cacheEntity = new CacheEntity();
+            cacheEntity.setKey(context);
+            cacheEntity.setUserId(userId);
+            cacheEntity.setValue(cache);
+        } else {
+            cacheEntity.setValue(cache);
+        }
+
+        return dataStore.upsert(cacheEntity)
+                .toObservable()
+                .subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread());
+    }
+
+}

+ 45 - 0
app/src/main/java/com/nextcloud/talk/utils/database/user/UserModule.java

@@ -0,0 +1,45 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017 Mario Danic
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.utils.database.user;
+
+import com.nextcloud.talk.application.NextcloudTalkApplication;
+import com.nextcloud.talk.dagger.modules.DatabaseModule;
+
+import javax.inject.Inject;
+
+import autodagger.AutoInjector;
+import dagger.Module;
+import dagger.Provides;
+import io.requery.Persistable;
+import io.requery.reactivex.ReactiveEntityStore;
+
+@Module(includes = DatabaseModule.class)
+@AutoInjector(NextcloudTalkApplication.class)
+public class UserModule {
+
+    @Inject
+    public UserModule() {
+    }
+
+    @Provides
+    public UserUtils provideUserUtils(ReactiveEntityStore<Persistable> dataStore) {
+        return new UserUtils(dataStore);
+    }
+}

+ 101 - 0
app/src/main/java/com/nextcloud/talk/utils/database/user/UserUtils.java

@@ -0,0 +1,101 @@
+/*
+ *
+ *   Nextcloud Talk application
+ *
+ *   @author Mario Danic
+ *   Copyright (C) 2017 Mario Danic
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.talk.utils.database.user;
+
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+
+import com.nextcloud.talk.persistence.entities.User;
+import com.nextcloud.talk.persistence.entities.UserEntity;
+
+import io.reactivex.Completable;
+import io.reactivex.Observable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import io.requery.Persistable;
+import io.requery.query.Result;
+import io.requery.reactivex.ReactiveEntityStore;
+
+public class UserUtils {
+    private ReactiveEntityStore<Persistable> dataStore;
+
+    UserUtils(ReactiveEntityStore<Persistable> dataStore) {
+        this.dataStore = dataStore;
+
+    }
+
+    public boolean anyUserExists() {
+        return (dataStore.count(User.class).limit(1).get().value() > 0);
+    }
+
+    // temporary method while we only support 1 user
+    public UserEntity getCurrentUser() {
+        Result findUserQueryResult = dataStore.select(User.class).limit(1).get();
+
+        return (UserEntity) findUserQueryResult.firstOrNull();
+    }
+
+    public Completable deleteUser(String username, String serverUrl) {
+        Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.USERNAME.eq(username).
+                and(UserEntity.BASE_URL.eq(serverUrl.toLowerCase()))).limit(1).get();
+
+        UserEntity user = (UserEntity) findUserQueryResult.firstOrNull();
+
+        return dataStore.delete(user)
+                .subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread());
+
+    }
+
+    public Observable<UserEntity> createOrUpdateUser(String username, String token, String serverUrl,
+                                                     @Nullable String displayName) {
+        Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.USERNAME.eq(username).
+                and(UserEntity.BASE_URL.eq(serverUrl.toLowerCase()))).limit(1).get();
+
+        UserEntity user = (UserEntity) findUserQueryResult.firstOrNull();
+
+        if (user == null) {
+            user = new UserEntity();
+            user.setBaseUrl(serverUrl);
+            user.setUsername(username);
+            user.setToken(token);
+
+            if (!TextUtils.isEmpty(displayName)) {
+                user.setDisplayName(displayName);
+            }
+
+        } else {
+            if (!token.equals(user.getToken())) {
+                user.setToken(token);
+            }
+
+            if (!TextUtils.isEmpty(displayName) && !displayName.equals(user.getDisplayName())) {
+                user.setDisplayName(displayName);
+            }
+        }
+
+        return dataStore.upsert(user)
+                .toObservable()
+                .subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread());
+    }
+
+}

+ 31 - 0
app/src/main/res/drawable/divider.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+       android:shape="rectangle">
+
+	<size
+		android:width="1dp"
+		android:height="1dp"/>
+
+	<solid android:color="@color/colorPrimary"/>
+
+</shape>

+ 29 - 0
app/src/main/res/drawable/ic_call_black_24dp.xml

@@ -0,0 +1,29 @@
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"/>
+</vector>

+ 9 - 0
app/src/main/res/drawable/ic_group_black_24dp.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M16,11c1.66,0 2.99,-1.34 2.99,-3S17.66,5 16,5c-1.66,0 -3,1.34 -3,3s1.34,3 3,3zM8,11c1.66,0 2.99,-1.34 2.99,-3S9.66,5 8,5C6.34,5 5,6.34 5,8s1.34,3 3,3zM8,13c-2.33,0 -7,1.17 -7,3.5L1,19h14v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5zM16,13c-0.29,0 -0.62,0.02 -0.97,0.05 1.16,0.84 1.97,1.97 1.97,3.45L17,19h6v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5z"/>
+</vector>

+ 114 - 0
app/src/main/res/drawable/ic_launcher_background.xml

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportHeight="108.0"
+    android:viewportWidth="108.0">
+    <path
+        android:fillColor="#26A69A"
+        android:pathData="M0,0h108v108h-108z"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,0L19,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M9,0L9,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,0L39,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,0L29,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,0L59,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,0L49,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,0L79,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,0L69,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M89,0L89,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M99,0L99,108"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,89L108,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,99L108,99"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,69L108,69"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,79L108,79"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,49L108,49"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,59L108,59"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,29L108,29"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,39L108,39"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,19L108,19"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8"/>
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,9L108,9"
+        android:strokeColor="#66FFFFFF"
+        android:strokeWidth="0.8"/>
+</vector>
+

+ 29 - 0
app/src/main/res/drawable/ic_person_black_24dp.xml

@@ -0,0 +1,29 @@
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
+</vector>

+ 9 - 0
app/src/main/res/drawable/ic_public_black_24dp.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,19.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L9,15v1c0,1.1 0.9,2 2,2v1.93zM17.9,17.39c-0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L8,12v-2h2c0.55,0 1,-0.45 1,-1L11,7h2c1.1,0 2,-0.9 2,-2v-0.41c2.93,1.19 5,4.06 5,7.41 0,2.08 -0.8,3.97 -2.1,5.39z"/>
+</vector>

+ 36 - 0
app/src/main/res/drawable/ic_search_white_24dp.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91
+3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27 .28 v.79l5 4.99L20.49
+19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5
+14z" />
+    <path
+        android:pathData="M0 0h24v24H0z" />
+</vector>

+ 25 - 0
app/src/main/res/drawable/ic_settings_black_24dp.xml

@@ -0,0 +1,25 @@
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<vector android:autoMirrored="true" android:height="24dp"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
+</vector>

+ 25 - 0
app/src/main/res/drawable/ic_voice_chat_black_24dp.xml

@@ -0,0 +1,25 @@
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<vector android:autoMirrored="true" android:height="24dp"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM18,14l-4,-3.2L14,14L6,14L6,6h8v3.2L18,6v8z"/>
+</vector>

+ 31 - 0
app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:fitsSystemWindows="true"
+    tools:context=".activities.MainActivity">
+
+    <android.support.design.widget.AppBarLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <android.support.v7.widget.Toolbar
+            android:id="@+id/toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
+            />
+
+    </android.support.design.widget.AppBarLayout>
+
+    <com.bluelinelabs.conductor.ChangeHandlerFrameLayout
+        android:id="@+id/controller_container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior"
+        />
+
+</android.support.design.widget.CoordinatorLayout>

+ 54 - 0
app/src/main/res/layout/controller_account_verification.xml

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@color/background_color">
+
+    <ProgressBar
+        android:id="@+id/progress_bar"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:layout_marginLeft="@dimen/activity_horizontal_margin"
+        android:layout_marginRight="@dimen/activity_horizontal_margin"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:indeterminate="true"
+        android:progressTint="@color/colorPrimary"/>
+
+    <TextView
+        android:id="@+id/progress_text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/progress_bar"
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:layout_marginLeft="@dimen/activity_horizontal_margin"
+        android:layout_marginRight="@dimen/activity_horizontal_margin"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:layout_marginTop="@dimen/padding_between_elements"
+        />
+
+
+</RelativeLayout>

+ 25 - 0
app/src/main/res/layout/controller_bottom_navigation.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/bottom_navigation_root"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <com.bluelinelabs.conductor.ChangeHandlerFrameLayout
+        android:id="@+id/bottom_navigation_controller_container"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_gravity="top"
+        android:layout_weight="1"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
+
+    <android.support.design.widget.BottomNavigationView
+        android:id="@+id/navigation"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom"
+        android:animateLayoutChanges="true"
+        android:background="?android:attr/windowBackground"/>
+</LinearLayout>

+ 34 - 0
app/src/main/res/layout/controller_generic_rv.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                                              android:id="@+id/swipe_refresh_layout"
+                                              android:layout_width="match_parent"
+                                              android:layout_height="match_parent"
+                                              android:background="@color/background_color">
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/recycler_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+    </android.support.v7.widget.RecyclerView>
+
+</android.support.v4.widget.SwipeRefreshLayout>

+ 50 - 0
app/src/main/res/layout/controller_server_selection.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                xmlns:app="http://schemas.android.com/apk/res-auto"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@color/background_color">
+
+    <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
+        android:id="@+id/text_field_boxes"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:layout_marginLeft="@dimen/activity_horizontal_margin"
+        android:layout_marginRight="@dimen/activity_horizontal_margin"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        app:errorColor="@color/A400red"
+        app:helperText=" "
+        app:primaryColor="@color/colorPrimary">
+
+        <studio.carbonylgroup.textfieldboxes.ExtendedEditText
+            android:id="@+id/extended_edit_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:imeOptions="actionDone"
+            android:singleLine="true"/>
+
+    </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
+
+</RelativeLayout>

+ 26 - 0
app/src/main/res/layout/controller_settings.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+</RelativeLayout>

+ 34 - 0
app/src/main/res/layout/controller_web_view_login.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical">
+
+    <WebView
+        android:id="@+id/webview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+    </WebView>
+
+</LinearLayout>

+ 74 - 0
app/src/main/res/layout/rv_item_call.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                xmlns:app="http://schemas.android.com/apk/res-auto"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <cn.carbs.android.avatarimageview.library.AvatarImageView
+        android:id="@+id/avatar_image_invisible"
+        android:visibility="invisible"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/padding_between_elements"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:layout_marginTop="@dimen/activity_vertical_margin"
+        android:scaleType="centerInside"
+        app:aiv_CornerRadius="20dp"
+        app:aiv_ShowBoarder="false"
+        app:aiv_TextSizeRatio="0.5"/>
+
+    <cn.carbs.android.avatarimageview.library.AvatarImageView
+        android:id="@+id/avatar_image"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/padding_between_elements"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:scaleType="centerInside"
+        app:aiv_CornerRadius="20dp"
+        app:aiv_ShowBoarder="false"
+        app:aiv_TextSizeRatio="0.5"/>
+
+    <TextView
+        android:id="@+id/name_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignTop="@id/avatar_image"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:layout_marginStart="@dimen/padding_between_elements"
+        android:layout_marginTop="@dimen/activity_vertical_margin"
+        android:layout_toEndOf="@id/avatar_image"/>
+
+    <TextView
+        android:id="@+id/timestamp_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/name_text"
+        android:layout_toEndOf="@id/avatar_image"
+        android:layout_marginBottom="@dimen/activity_vertical_margin"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:layout_marginStart="@dimen/padding_between_elements"
+        android:layout_marginTop="@dimen/padding_between_elements"/>
+
+</RelativeLayout>

+ 66 - 0
app/src/main/res/layout/rv_item_contact.xml

@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                xmlns:app="http://schemas.android.com/apk/res-auto"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <cn.carbs.android.avatarimageview.library.AvatarImageView
+        android:id="@+id/avatar_image_invisible"
+        android:visibility="invisible"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/padding_between_elements"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:layout_marginTop="@dimen/activity_vertical_margin"
+        android:scaleType="centerInside"
+        app:aiv_CornerRadius="20dp"
+        app:aiv_ShowBoarder="false"
+        app:aiv_TextSizeRatio="0.5"/>
+
+    <cn.carbs.android.avatarimageview.library.AvatarImageView
+        android:id="@+id/avatar_image"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/padding_between_elements"
+        android:layout_marginStart="@dimen/activity_horizontal_margin"
+        android:layout_marginTop="@dimen/activity_vertical_margin"
+        android:scaleType="centerInside"
+        app:aiv_CornerRadius="20dp"
+        app:aiv_ShowBoarder="false"
+        app:aiv_TextSizeRatio="0.5"/>
+
+    <TextView
+        android:id="@+id/name_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_marginBottom="@dimen/activity_vertical_margin"
+        android:layout_marginEnd="@dimen/activity_horizontal_margin"
+        android:layout_marginStart="@dimen/padding_between_elements"
+        android:layout_toEndOf="@id/avatar_image"/>
+
+
+</RelativeLayout>

+ 33 - 0
app/src/main/res/menu/menu_filter.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017 Mario Danic
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
+
+	<!-- Search, should appear as action button -->
+	<item android:id="@+id/action_search"
+	      android:title="@string/nc_search"
+	      android:icon="@drawable/ic_search_white_24dp"
+	      app:showAsAction="collapseActionView|always"
+	      android:animateLayoutChanges="true"
+	      app:actionViewClass="android.support.v7.widget.SearchView"/>
+
+</menu>

+ 19 - 0
app/src/main/res/menu/menu_navigation.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:id="@+id/navigation_calls"
+        android:checked="true"
+        android:icon="@drawable/ic_call_black_24dp"
+        android:title="@string/nc_bottom_navigation_title_calls"/>
+
+    <item
+        android:id="@+id/navigation_contacts"
+        android:icon="@drawable/ic_person_black_24dp"
+        android:title="@string/nc_bottom_navigation_title_contacts"/>
+
+    <item
+        android:id="@+id/navigation_settings"
+        android:icon="@drawable/ic_settings_black_24dp"
+        android:title="@string/nc_bottom_navigation_title_settings"/>
+</menu>

+ 5 - 0
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_background"/>
+    <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
+</adaptive-icon>

+ 5 - 0
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_background"/>
+    <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
+</adaptive-icon>

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png


Неке датотеке нису приказане због велике количине промена