From 350e665cef5dfde75de391c5c21ace196b48004b Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 12 Feb 2018 02:08:56 +0100 Subject: [PATCH] Add more MVP classes --- .idea/misc.xml | 2 +- mobile/src/main/AndroidManifest.xml | 3 +- .../slam/AbstractTextWatcher.java | 17 ++ .../slam/EditorActionDoneListener.java | 17 ++ .../de/vanitasvitae/slam/SlamApplication.java | 31 ++++ .../slam/mvp/DummyPresenterFactory.java | 77 +++++++++ .../de/vanitasvitae/slam/mvp/DummyStore.java | 71 +++++++++ .../slam/mvp/PresenterFactory.java | 70 +++++++++ .../mvp/contracts/ContactDetailContract.java | 48 ++++++ .../mvp/contracts/ContactListContract.java | 20 +++ .../mvp/contracts/ConversationContract.java | 23 ++- .../contracts/ConversationListContract.java | 24 ++- .../slam/mvp/contracts/LoginContract.java | 17 ++ .../slam/mvp/contracts/SearchContract.java | 17 ++ .../mvp/presenter/ContactDetailPresenter.java | 77 +++++++++ .../mvp/presenter/ContactListPresenter.java | 49 ++++++ .../presenter/ConversationListPresenter.java | 44 ++++++ .../mvp/presenter/ConversationPresenter.java | 61 ++++++++ .../slam/mvp/presenter/LoginPresenter.java | 20 ++- .../slam/mvp/presenter/SearchPresenter.java | 44 ++++++ .../dummy/DummyContactDetailPresenter.java | 77 +++++++++ .../dummy/DummyContactListPresenter.java | 49 ++++++ .../dummy/DummyConversationListPresenter.java | 60 +++++++ .../dummy/DummyConversationPresenter.java | 100 ++++++++++++ .../presenter/dummy/DummyLoginPresenter.java | 17 ++ .../presenter/dummy/DummySearchPresenter.java | 44 ++++++ .../slam/mvp/view/ContactDetailFragment.java | 76 +++++++++ .../slam/mvp/view/ContactListFragment.java | 63 ++++++++ .../slam/mvp/view/ConversationFragment.java | 147 ++++++++++++++---- .../mvp/view/ConversationListFragment.java | 121 ++++++++++---- .../slam/mvp/view/LoginActivity.java | 26 +++- .../slam/mvp/view/MainActivity.java | 25 ++- .../slam/mvp/view/SearchFragment.java | 24 +++ .../view/abstr/ThemedAppCompatActivity.java | 17 ++ .../slam/receiver/MessageReadReceiver.java | 23 +-- .../slam/receiver/MessageReplyReceiver.java | 23 +-- .../slam/service/MyMessagingService.java | 23 +-- .../slam/ui/ChatMessageEntry.java | 17 ++ .../slam/ui/ConversationEntry.java | 17 ++ .../de/vanitasvitae/slam/xmpp/Contact.java | 29 ++++ .../vanitasvitae/slam/xmpp/Conversation.java | 33 ++++ .../res/layout/fragment_contact_detail.xml | 57 +++++++ 42 files changed, 1690 insertions(+), 110 deletions(-) create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/SlamApplication.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyPresenterFactory.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyStore.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/PresenterFactory.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactDetailContract.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactDetailPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactListPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationListPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/SearchPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactDetailPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactListPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationListPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummySearchPresenter.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactDetailFragment.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactListFragment.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/xmpp/Contact.java create mode 100644 mobile/src/main/java/de/vanitasvitae/slam/xmpp/Conversation.java create mode 100644 mobile/src/main/res/layout/fragment_contact_detail.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 635999d..ba7052b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/mobile/src/main/AndroidManifest.xml b/mobile/src/main/AndroidManifest.xml index 4381476..bb76a3c 100644 --- a/mobile/src/main/AndroidManifest.xml +++ b/mobile/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ - + diff --git a/mobile/src/main/java/de/vanitasvitae/slam/AbstractTextWatcher.java b/mobile/src/main/java/de/vanitasvitae/slam/AbstractTextWatcher.java index 9902444..5c461d3 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/AbstractTextWatcher.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/AbstractTextWatcher.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam; import android.text.Editable; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/EditorActionDoneListener.java b/mobile/src/main/java/de/vanitasvitae/slam/EditorActionDoneListener.java index d09a827..f4ed6ed 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/EditorActionDoneListener.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/EditorActionDoneListener.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam; import android.view.KeyEvent; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/SlamApplication.java b/mobile/src/main/java/de/vanitasvitae/slam/SlamApplication.java new file mode 100644 index 0000000..d2626c8 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/SlamApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam; + +import android.app.Application; + +import de.vanitasvitae.slam.mvp.DummyPresenterFactory; +import de.vanitasvitae.slam.mvp.PresenterFactory; + +public class SlamApplication extends Application { + + public SlamApplication() { + super(); + PresenterFactory.setInstance(new DummyPresenterFactory()); + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyPresenterFactory.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyPresenterFactory.java new file mode 100644 index 0000000..28f4f40 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyPresenterFactory.java @@ -0,0 +1,77 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp; + +import org.jxmpp.stringprep.XmppStringprepException; + +import de.vanitasvitae.slam.mvp.contracts.ContactDetailContract; +import de.vanitasvitae.slam.mvp.contracts.ContactListContract; +import de.vanitasvitae.slam.mvp.contracts.ConversationContract; +import de.vanitasvitae.slam.mvp.contracts.ConversationListContract; +import de.vanitasvitae.slam.mvp.contracts.LoginContract; +import de.vanitasvitae.slam.mvp.contracts.SearchContract; +import de.vanitasvitae.slam.mvp.presenter.dummy.DummyContactDetailPresenter; +import de.vanitasvitae.slam.mvp.presenter.dummy.DummyContactListPresenter; +import de.vanitasvitae.slam.mvp.presenter.dummy.DummyConversationListPresenter; +import de.vanitasvitae.slam.mvp.presenter.dummy.DummyConversationPresenter; +import de.vanitasvitae.slam.mvp.presenter.dummy.DummyLoginPresenter; +import de.vanitasvitae.slam.mvp.presenter.dummy.DummySearchPresenter; + +public class DummyPresenterFactory extends PresenterFactory { + + public static DummyStore STORE; + + public DummyPresenterFactory() { + super(); + try { + STORE = new DummyStore(); + } catch (XmppStringprepException e) { + e.printStackTrace(); + } + } + + @Override + public ContactDetailContract.Presenter createContactDetailPresenter(ContactDetailContract.View view) { + return new DummyContactDetailPresenter(view); + } + + @Override + public ContactListContract.Presenter createContactListPresenter(ContactListContract.View view) { + return new DummyContactListPresenter(view); + } + + @Override + public ConversationListContract.Presenter createConversationListPresenter(ConversationListContract.View view) { + return new DummyConversationListPresenter(view); + } + + @Override + public ConversationContract.Presenter createConversationPresenter(ConversationContract.View view) { + return new DummyConversationPresenter(view); + } + + @Override + public LoginContract.Presenter createLoginPresenter(LoginContract.View view) { + return new DummyLoginPresenter(view); + } + + @Override + public SearchContract.Presenter createSearchPresenter(SearchContract.View view) { + return new DummySearchPresenter(view); + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyStore.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyStore.java new file mode 100644 index 0000000..3726f60 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/DummyStore.java @@ -0,0 +1,71 @@ +package de.vanitasvitae.slam.mvp; + +import org.jivesoftware.smack.packet.Message; +import org.jxmpp.jid.BareJid; +import org.jxmpp.jid.impl.JidCreate; +import org.jxmpp.stringprep.XmppStringprepException; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.vanitasvitae.slam.xmpp.Contact; + +/** + * Created by Paul Schaub on 11.02.18. + */ +public class DummyStore { + + public final Map> conversations = new HashMap<>(); + public final List contacts = new ArrayList<>(); + + public DummyStore() throws XmppStringprepException { + contacts.addAll(contacts()); + conversations.put(contacts.get(0).getJid(), aliceMessages()); + conversations.put(contacts.get(1).getJid(), bobMessages()); + } + + private List contacts() throws XmppStringprepException { + List l = new ArrayList<>(); + l.add(new Contact(JidCreate.entityBareFrom("alice@wonderland.lit"), "Alice")); + l.add(new Contact(JidCreate.entityBareFrom("bob@builder.tv"))); + l.add(new Contact(JidCreate.entityBareFrom("juliet@capulet.lit"), "Juliet")); + l.add(new Contact(JidCreate.entityBareFrom("romeo@montague.lit"), "Romeo <3")); + return l; + } + + private List aliceMessages() throws XmppStringprepException { + BareJid jid = JidCreate.entityBareFrom("alice@wonderland.lit"); + List m = new ArrayList<>(); + + Message m1 = new Message(); + m1.setFrom(jid); + m1.setBody("Hi!"); + m.add(m1); + + return m; + } + + private List bobMessages() throws XmppStringprepException { + BareJid jid = JidCreate.entityBareFrom("bob@builder.tv"); + List m = new ArrayList<>(); + + Message m1 = new Message(); + m1.setFrom(jid); + m1.setBody("Hello, I'm Bob!"); + m.add(m1); + + Message m2 = new Message(); + m2.setFrom(jid); + m2.setBody("Do you think we can do it?"); + m.add(m2); + + Message m3 = new Message(); + m3.setFrom(jid); + m3.setBody("YES WE CAN!!!"); + m.add(m3); + + return m; + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/PresenterFactory.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/PresenterFactory.java new file mode 100644 index 0000000..d245d39 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/PresenterFactory.java @@ -0,0 +1,70 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp; + +import org.jxmpp.jid.BareJid; + +import de.vanitasvitae.slam.mvp.contracts.ContactDetailContract; +import de.vanitasvitae.slam.mvp.contracts.ContactListContract; +import de.vanitasvitae.slam.mvp.contracts.ConversationContract; +import de.vanitasvitae.slam.mvp.contracts.ConversationListContract; +import de.vanitasvitae.slam.mvp.contracts.LoginContract; +import de.vanitasvitae.slam.mvp.contracts.SearchContract; +import de.vanitasvitae.slam.mvp.presenter.ContactDetailPresenter; +import de.vanitasvitae.slam.mvp.presenter.ContactListPresenter; +import de.vanitasvitae.slam.mvp.presenter.ConversationListPresenter; +import de.vanitasvitae.slam.mvp.presenter.ConversationPresenter; +import de.vanitasvitae.slam.mvp.presenter.LoginPresenter; +import de.vanitasvitae.slam.mvp.presenter.SearchPresenter; + +public class PresenterFactory { + + private static PresenterFactory INSTANCE; + + public static PresenterFactory getInstance() { + return INSTANCE; + } + + public static void setInstance(PresenterFactory instance) { + INSTANCE = instance; + } + + public ContactDetailContract.Presenter createContactDetailPresenter(ContactDetailContract.View view) { + return new ContactDetailPresenter(view); + } + + public ContactListContract.Presenter createContactListPresenter(ContactListContract.View view) { + return new ContactListPresenter(view); + } + + public ConversationListContract.Presenter createConversationListPresenter(ConversationListContract.View view) { + return new ConversationListPresenter(view); + } + + public ConversationContract.Presenter createConversationPresenter(ConversationContract.View view) { + return new ConversationPresenter(view); + } + + public LoginContract.Presenter createLoginPresenter(LoginContract.View view) { + return new LoginPresenter(view); + } + + public SearchContract.Presenter createSearchPresenter(SearchContract.View view) { + return new SearchPresenter(view); + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactDetailContract.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactDetailContract.java new file mode 100644 index 0000000..9b83c08 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactDetailContract.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.contracts; + +import org.jivesoftware.smack.packet.Presence; + +import java.util.List; + +/** + * Model-View-Presenter contract for the {@link de.vanitasvitae.slam.mvp.view.ContactDetailFragment}. + */ +public interface ContactDetailContract { + + interface View { + void setContactAvatar(); + void setNickname(String nickname); + void setPresence(Presence presence); + void clearFingerprints(); + void addFingerprints(List fingerprints); + } + + interface Presenter { + void onAvatarClick(); + void onSharedMediaClick(); + void onAudioCallClick(); + void onVideoCallClick(); + void onShareContactClick(); + void onBlockContactClick(); + void onEditClick(); + void onDeleteClick(); + void onFingerprintTrustChanged(); + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactListContract.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactListContract.java index 5812b99..8537c85 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactListContract.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ContactListContract.java @@ -1,5 +1,24 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.contracts; +import org.jxmpp.jid.BareJid; + import java.util.List; import de.vanitasvitae.slam.mvp.view.ConversationListFragment; @@ -17,6 +36,7 @@ public interface ContactListContract { void onUpdateContactPresence(); void showContactListLoadingIndicator(); void hideContactListLoadingIndicator(); + void navigateToConversation(BareJid contact); } interface Presenter { diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationContract.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationContract.java index 3c7223f..bde2f7d 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationContract.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationContract.java @@ -1,5 +1,25 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.contracts; +import org.jivesoftware.smack.packet.Message; +import org.jxmpp.jid.EntityBareJid; + import java.util.List; import de.vanitasvitae.slam.mvp.view.ConversationFragment; @@ -11,13 +31,14 @@ import de.vanitasvitae.slam.mvp.view.ConversationFragment; public interface ConversationContract { interface View { - void addMessageItems(List messages, boolean end); + void addMessageItems(List messages, boolean end); void highlightMessageItem(); void correctMessageItem(); void navigateToContactProfile(); } interface Presenter { + void setPeersJid(EntityBareJid jid); void onConversationScrolledToTop(); void onComposingMessageChanged(String composingMessage); void onMessageItemClick(); diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationListContract.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationListContract.java index 35218b1..f108449 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationListContract.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/ConversationListContract.java @@ -1,7 +1,28 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.contracts; +import org.jxmpp.jid.BareJid; + import java.util.List; +import de.vanitasvitae.slam.xmpp.Conversation; + /** * Model-View-Presenter contract of the conversation list fragment. * Created by Paul Schaub on 01.02.18. @@ -9,7 +30,8 @@ import java.util.List; public interface ConversationListContract { interface View { - void populateConversationList(List conversations); + void populateConversationList(List conversations); + void navigateToConversation(BareJid contact); } interface Presenter { diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/LoginContract.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/LoginContract.java index 8d73e1d..afa439b 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/LoginContract.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/LoginContract.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.contracts; /** diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/SearchContract.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/SearchContract.java index 6ef285b..9d05788 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/SearchContract.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/contracts/SearchContract.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.contracts; import java.util.List; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactDetailPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactDetailPresenter.java new file mode 100644 index 0000000..153c71c --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactDetailPresenter.java @@ -0,0 +1,77 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter; + +import org.jxmpp.jid.BareJid; + +import de.vanitasvitae.slam.mvp.contracts.ContactDetailContract; + +public class ContactDetailPresenter implements ContactDetailContract.Presenter { + + private final ContactDetailContract.View view; + private BareJid contact; + + public ContactDetailPresenter(ContactDetailContract.View view) { + this.view = view; + } + + @Override + public void onAvatarClick() { + + } + + @Override + public void onSharedMediaClick() { + + } + + @Override + public void onAudioCallClick() { + + } + + @Override + public void onVideoCallClick() { + + } + + @Override + public void onShareContactClick() { + + } + + @Override + public void onBlockContactClick() { + + } + + @Override + public void onEditClick() { + + } + + @Override + public void onDeleteClick() { + + } + + @Override + public void onFingerprintTrustChanged() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactListPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactListPresenter.java new file mode 100644 index 0000000..a60f79c --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ContactListPresenter.java @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter; + +import de.vanitasvitae.slam.mvp.contracts.ContactListContract; + +public class ContactListPresenter implements ContactListContract.Presenter { + + private final ContactListContract.View view; + + public ContactListPresenter(ContactListContract.View view) { + this.view = view; + } + + @Override + public void onContactListItemClick() { + + } + + @Override + public void onContactListItemLongClick() { + + } + + @Override + public void addNewContact() { + + } + + @Override + public void deleteContact() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationListPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationListPresenter.java new file mode 100644 index 0000000..38d7776 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationListPresenter.java @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter; + +import de.vanitasvitae.slam.mvp.contracts.ConversationListContract; + +public class ConversationListPresenter implements ConversationListContract.Presenter { + + private final ConversationListContract.View view; + + public ConversationListPresenter(ConversationListContract.View view) { + this.view = view; + } + + @Override + public void onConversationClick() { + + } + + @Override + public void onConversationLongClick() { + + } + + @Override + public void load() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationPresenter.java new file mode 100644 index 0000000..f77402f --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/ConversationPresenter.java @@ -0,0 +1,61 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter; + +import org.jxmpp.jid.EntityBareJid; + +import de.vanitasvitae.slam.mvp.contracts.ConversationContract; + +public class ConversationPresenter implements ConversationContract.Presenter { + + private final ConversationContract.View view; + + public ConversationPresenter(ConversationContract.View view) { + this.view = view; + } + + @Override + public void setPeersJid(EntityBareJid jid) { + + } + + @Override + public void onConversationScrolledToTop() { + + } + + @Override + public void onComposingMessageChanged(String composingMessage) { + + } + + @Override + public void onMessageItemClick() { + + } + + @Override + public void onMessageItemLongClick() { + + } + + @Override + public void onMessageItemSenderClick() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/LoginPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/LoginPresenter.java index a2f7510..34e4770 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/LoginPresenter.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/LoginPresenter.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.presenter; import org.jxmpp.jid.BareJid; @@ -6,9 +23,6 @@ import org.jxmpp.stringprep.XmppStringprepException; import de.vanitasvitae.slam.mvp.contracts.LoginContract; -/** - * Created by Paul Schaub on 01.02.18. - */ public class LoginPresenter implements LoginContract.Presenter { private final LoginContract.View view; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/SearchPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/SearchPresenter.java new file mode 100644 index 0000000..a39b6ad --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/SearchPresenter.java @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter; + +import de.vanitasvitae.slam.mvp.contracts.SearchContract; + +public class SearchPresenter implements SearchContract.Presenter { + + private final SearchContract.View view; + + public SearchPresenter(SearchContract.View view) { + this.view = view; + } + + @Override + public void onSearchQueryChanged(String query) { + + } + + @Override + public void onSearchResultClick() { + + } + + @Override + public void onSearchScrolledToBottom() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactDetailPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactDetailPresenter.java new file mode 100644 index 0000000..be0da86 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactDetailPresenter.java @@ -0,0 +1,77 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter.dummy; + +import org.jxmpp.jid.BareJid; + +import de.vanitasvitae.slam.mvp.contracts.ContactDetailContract; + +public class DummyContactDetailPresenter implements ContactDetailContract.Presenter { + + private final ContactDetailContract.View view; + private BareJid contact; + + public DummyContactDetailPresenter(ContactDetailContract.View view) { + this.view = view; + } + + @Override + public void onAvatarClick() { + + } + + @Override + public void onSharedMediaClick() { + + } + + @Override + public void onAudioCallClick() { + + } + + @Override + public void onVideoCallClick() { + + } + + @Override + public void onShareContactClick() { + + } + + @Override + public void onBlockContactClick() { + + } + + @Override + public void onEditClick() { + + } + + @Override + public void onDeleteClick() { + + } + + @Override + public void onFingerprintTrustChanged() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactListPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactListPresenter.java new file mode 100644 index 0000000..e3a3d1d --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyContactListPresenter.java @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter.dummy; + +import de.vanitasvitae.slam.mvp.contracts.ContactListContract; + +public class DummyContactListPresenter implements ContactListContract.Presenter { + + private final ContactListContract.View view; + + public DummyContactListPresenter(ContactListContract.View view) { + this.view = view; + } + + @Override + public void onContactListItemClick() { + view.navigateToConversation(null); + } + + @Override + public void onContactListItemLongClick() { + + } + + @Override + public void addNewContact() { + + } + + @Override + public void deleteContact() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationListPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationListPresenter.java new file mode 100644 index 0000000..af4002c --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationListPresenter.java @@ -0,0 +1,60 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter.dummy; + +import org.jivesoftware.smack.packet.Message; + +import java.util.ArrayList; +import java.util.List; + +import de.vanitasvitae.slam.mvp.DummyPresenterFactory; +import de.vanitasvitae.slam.mvp.contracts.ConversationListContract; +import de.vanitasvitae.slam.xmpp.Contact; +import de.vanitasvitae.slam.xmpp.Conversation; + +public class DummyConversationListPresenter implements ConversationListContract.Presenter { + + private final ConversationListContract.View view; + + public DummyConversationListPresenter(ConversationListContract.View view) { + this.view = view; + List conversationList = new ArrayList<>(); + for (Contact contact : DummyPresenterFactory.STORE.contacts) { + List m = DummyPresenterFactory.STORE.conversations.get(contact.getJid()); + if (m != null) { + conversationList.add(new Conversation(contact, m.get(m.size() - 1).getBody(), "now")); + } + } + view.populateConversationList(conversationList); + } + + @Override + public void onConversationClick() { + + } + + @Override + public void onConversationLongClick() { + + } + + @Override + public void load() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationPresenter.java new file mode 100644 index 0000000..8fc5da3 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyConversationPresenter.java @@ -0,0 +1,100 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter.dummy; + +import org.jivesoftware.smack.packet.Message; +import org.jxmpp.jid.BareJid; +import org.jxmpp.jid.EntityBareJid; +import org.jxmpp.jid.impl.JidCreate; +import org.jxmpp.stringprep.XmppStringprepException; + +import java.util.ArrayList; +import java.util.List; + +import de.vanitasvitae.slam.mvp.contracts.ConversationContract; + +public class DummyConversationPresenter implements ConversationContract.Presenter { + + private final ConversationContract.View view; + + private final List dummyMessages = new ArrayList<>(); + + public DummyConversationPresenter(ConversationContract.View view) { + this.view = view; + populateDummyMessages(); + this.view.addMessageItems(dummyMessages, true); + } + + private void populateDummyMessages() { + try { + BareJid alice = JidCreate.bareFrom("alice@wonderland.lit"); + + Message m1 = new Message(); + m1.setFrom(alice); + m1.setBody("Hello World!"); + dummyMessages.add(m1); + + Message m2 = new Message(); + m2.setFrom(alice); + m2.setBody("This is a demonstration of a SLAM! conversation."); + dummyMessages.add(m2); + + Message m3 = new Message(); + m3.setFrom(alice); + m3.setBody("As you can see, long messages are displayed just as nice as short messages."); + dummyMessages.add(m3); + + Message m4 = new Message(); + m4.setFrom(alice); + m4.setBody("Easy usability is one of SLAM!s main focus points. I hope, that SLAM! will develop further to become one very easy and intuitive messenger."); + dummyMessages.add(m4); + } catch (XmppStringprepException e) { + e.printStackTrace(); + } + } + + @Override + public void setPeersJid(EntityBareJid jid) { + + } + + @Override + public void onConversationScrolledToTop() { + + } + + @Override + public void onComposingMessageChanged(String composingMessage) { + + } + + @Override + public void onMessageItemClick() { + + } + + @Override + public void onMessageItemLongClick() { + + } + + @Override + public void onMessageItemSenderClick() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyLoginPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyLoginPresenter.java index 35dff61..7881a7a 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyLoginPresenter.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummyLoginPresenter.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.presenter.dummy; import android.os.Handler; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummySearchPresenter.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummySearchPresenter.java new file mode 100644 index 0000000..d71baf6 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/presenter/dummy/DummySearchPresenter.java @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.presenter.dummy; + +import de.vanitasvitae.slam.mvp.contracts.SearchContract; + +public class DummySearchPresenter implements SearchContract.Presenter { + + private final SearchContract.View view; + + public DummySearchPresenter(SearchContract.View view) { + this.view = view; + } + + @Override + public void onSearchQueryChanged(String query) { + + } + + @Override + public void onSearchResultClick() { + + } + + @Override + public void onSearchScrolledToBottom() { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactDetailFragment.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactDetailFragment.java new file mode 100644 index 0000000..6ee2b7b --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactDetailFragment.java @@ -0,0 +1,76 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package de.vanitasvitae.slam.mvp.view; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import org.jivesoftware.smack.packet.Presence; +import org.jxmpp.jid.BareJid; + +import java.util.List; + +import butterknife.ButterKnife; +import de.vanitasvitae.slam.R; +import de.vanitasvitae.slam.mvp.PresenterFactory; +import de.vanitasvitae.slam.mvp.contracts.ContactDetailContract; + +public class ContactDetailFragment extends Fragment implements ContactDetailContract.View { + + private final ContactDetailContract.Presenter presenter; + + public ContactDetailFragment() { + this.presenter = PresenterFactory.getInstance().createContactDetailPresenter(this); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_contact_detail, container, false); + ButterKnife.bind(this, view); + return view; + } + + @Override + public void setContactAvatar() { + + } + + @Override + public void setNickname(String nickname) { + + } + + @Override + public void setPresence(Presence presence) { + + } + + @Override + public void clearFingerprints() { + + } + + @Override + public void addFingerprints(List fingerprints) { + + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactListFragment.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactListFragment.java new file mode 100644 index 0000000..2c33760 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ContactListFragment.java @@ -0,0 +1,63 @@ +package de.vanitasvitae.slam.mvp.view; + +import android.app.Fragment; +import android.os.Bundle; + +import org.jxmpp.jid.BareJid; + +import java.util.List; + +import de.vanitasvitae.slam.R; +import de.vanitasvitae.slam.mvp.PresenterFactory; +import de.vanitasvitae.slam.mvp.contracts.ContactListContract; + +/** + * Created by Paul Schaub on 11.02.18. + */ +public class ContactListFragment extends Fragment implements ContactListContract.View { + + private final ContactListContract.Presenter presenter; + + public ContactListFragment() { + super(); + this.presenter = PresenterFactory.getInstance().createContactListPresenter(this); + } + + @Override + public void addContactListItems(List contacts) { + + } + + @Override + public void clearContactListItems() { + + } + + @Override + public void onUpdateContactPresence() { + + } + + @Override + public void showContactListLoadingIndicator() { + + } + + @Override + public void hideContactListLoadingIndicator() { + + } + + @Override + public void navigateToConversation(BareJid contact) { + ConversationFragment fragment = new ConversationFragment(); + Bundle bundle = new Bundle(); + bundle.putString(ConversationFragment.KEY_JID, contact.toString()); + fragment.setArguments(bundle); + + getFragmentManager().beginTransaction() + .add(R.id.fragment_container, fragment) + .addToBackStack("conversation") + .commit(); + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationFragment.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationFragment.java index 1cbdb52..e1e6420 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationFragment.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationFragment.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.view; import android.app.Fragment; @@ -7,63 +24,131 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.TextView; +import org.jivesoftware.smack.packet.Message; +import org.jxmpp.jid.EntityBareJid; +import org.jxmpp.jid.impl.JidCreate; +import org.jxmpp.stringprep.XmppStringprepException; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import butterknife.BindView; import butterknife.ButterKnife; import de.vanitasvitae.slam.R; +import de.vanitasvitae.slam.mvp.PresenterFactory; +import de.vanitasvitae.slam.mvp.contracts.ConversationContract; import de.vanitasvitae.slam.ui.ChatMessageEntry; /** * Fragment that shows the conversation with a user. - * - * Created by Paul Schaub on 30.01.18. */ -public class ConversationFragment extends Fragment { +public class ConversationFragment extends Fragment implements ConversationContract.View { + + public static final String KEY_JID = "conversationfragment_jid"; @BindView(R.id.recycler_chat) RecyclerView recyclerView; + private final ConversationContract.Presenter presenter; + + Map messageIdIndizes = new HashMap<>(); + List messages = new ArrayList<>(); + + private final RecyclerView.Adapter chatMessageAdapter = new RecyclerView.Adapter() { + @Override + public ChatMessageEntry onCreateViewHolder(ViewGroup parent, int viewType) { + View messageView = LayoutInflater.from(getActivity()).inflate(R.layout.item_chatmessage, parent, false); + messageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getFragmentManager().beginTransaction() + .replace(R.id.fragment_container, new ContactDetailFragment()) + .commit(); + } + }); + return new ChatMessageEntry(messageView); + } + + @Override + public void onBindViewHolder(ChatMessageEntry holder, int position) { + Message message = messages.get(position); + String sender = message.getFrom().toString(); + String role = "Member"; + View content; + content = new TextView(getActivity()); + ((TextView)content).setText(message.getBody()); + + holder.bind(sender, role, content, "now"); + } + + @Override + public int getItemCount() { + return messages.size(); + } + }; + + public ConversationFragment() { + super(); + this.presenter = PresenterFactory.getInstance().createConversationPresenter(this); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_chat, container, false); ButterKnife.bind(this, view); + + Bundle arguments = getArguments(); + String jidString = arguments.getString(KEY_JID); + if (jidString != null) { + try { + EntityBareJid jid = JidCreate.entityBareFrom(jidString); + presenter.setPeersJid(jid); + } catch (XmppStringprepException e) { + e.printStackTrace(); + } + } + return view; } @Override public void onViewCreated(final View view, Bundle savedInstanceState) { - final String[] messages = new String[] {"This is an example message.", "null","This is a very long message. Its purpose is to demonstrate Slam!s ability to render longer messages in a sane way without looking too crowded."}; recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); - recyclerView.setAdapter(new RecyclerView.Adapter() { - @Override - public ChatMessageEntry onCreateViewHolder(ViewGroup parent, int viewType) { - View view1 = LayoutInflater.from(getActivity()).inflate(R.layout.item_chatmessage, parent, false); - return new ChatMessageEntry(view1); - } - - @Override - public void onBindViewHolder(ChatMessageEntry holder, int position) { - View content; - if (position != 1) { - content = new TextView(getActivity()); - ((TextView)content).setText(messages[position]); - } else { - content = new ImageView(getActivity()); - ((ImageView)content).setImageResource(R.drawable.ic_add_a_photo_black_48dp); - } - holder.bind("alice@wonderland.lit", - "Member", content, "just now"); - } - - @Override - public int getItemCount() { - return messages.length; - } - }); + recyclerView.setAdapter(chatMessageAdapter); recyclerView.getAdapter().notifyDataSetChanged(); } + @Override + public void addMessageItems(List messages, boolean end) { + if (end) { + this.messages.addAll(messages); + } else { + this.messages.addAll(0, messages); + } + chatMessageAdapter.notifyDataSetChanged(); + } + + @Override + public void highlightMessageItem() { + + } + + @Override + public void correctMessageItem() { + + } + + @Override + public void navigateToContactProfile() { + getFragmentManager().beginTransaction() + .setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out) + .add(R.id.fragment_container, new ContactDetailFragment()) + .addToBackStack("detail") + .commit(); + } } diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationListFragment.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationListFragment.java index 1062beb..01534a1 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationListFragment.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/ConversationListFragment.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.view; import android.app.Fragment; @@ -8,21 +25,70 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import org.jxmpp.jid.BareJid; + +import java.util.ArrayList; +import java.util.List; + import butterknife.BindView; import butterknife.ButterKnife; import de.vanitasvitae.slam.R; +import de.vanitasvitae.slam.mvp.PresenterFactory; +import de.vanitasvitae.slam.mvp.contracts.ConversationListContract; import de.vanitasvitae.slam.ui.ConversationEntry; +import de.vanitasvitae.slam.xmpp.Conversation; /** * Fragment that lists conversations the user takes part in. * * Created by Paul Schaub on 30.01.18. */ -public class ConversationListFragment extends Fragment { +public class ConversationListFragment extends Fragment implements ConversationListContract.View { @BindView(R.id.recycler_chatlist) RecyclerView recyclerView; + private final ConversationListContract.Presenter presenter; + private final List conversations = new ArrayList<>(); + + private final RecyclerView.Adapter conversationEntryAdapter = new RecyclerView.Adapter() { + @Override + public ConversationEntry onCreateViewHolder(ViewGroup parent, int viewType) { + View conversationView = LayoutInflater.from(getActivity()).inflate(R.layout.chatlist_singlechat, parent, false); + return new ConversationEntry(conversationView); + } + + @Override + public void onBindViewHolder(final ConversationEntry holder, final int position) { + Conversation conversation = conversations.get(holder.getAdapterPosition()); + String name = conversation.getContact().getNickname(); + + holder.bind( + name != null ? name : conversation.getContact().getJid().toString(), + conversation.getLastMessage(), + conversation.getDate(), + true); + + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int pos = holder.getAdapterPosition(); + navigateToConversation(conversations.get(pos).getContact().getJid()); + } + }); + } + + @Override + public int getItemCount() { + return conversations.size(); + } + }; + + public ConversationListFragment() { + super(); + this.presenter = PresenterFactory.getInstance().createConversationListPresenter(this); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -33,40 +99,29 @@ public class ConversationListFragment extends Fragment { @Override public void onViewCreated(final View view, Bundle savedInstanceState) { - final String[] usernames = {"alice@wonderland.lit", "Bob the Builder", "Marvin"}; - final String[] messages = {"But I don’t want to go among mad people", "Yes we can!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "My name is Marvin!"}; - final String[] dates = {"13:37", "yesterday", "24.12.2018"}; - final boolean[] reads = {true, false, true}; - recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); - recyclerView.setAdapter(new RecyclerView.Adapter() { - @Override - public ConversationEntry onCreateViewHolder(ViewGroup parent, int viewType) { - View view1 = LayoutInflater.from(getActivity()).inflate(R.layout.chatlist_singlechat, parent, false); - view1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.fragment_container, new ConversationFragment()).commit(); - } - }); - return new ConversationEntry(view1); - } - - @Override - public void onBindViewHolder(ConversationEntry holder, int position) { - holder.bind( - usernames[position], - messages[position], - dates[position], - reads[position]); - } - - @Override - public int getItemCount() { - return usernames.length; - } - }); + recyclerView.setAdapter(conversationEntryAdapter); recyclerView.getAdapter().notifyDataSetChanged(); } + @Override + public void populateConversationList(List conversations) { + this.conversations.clear(); + this.conversations.addAll(conversations); + conversationEntryAdapter.notifyDataSetChanged(); + } + + @Override + public void navigateToConversation(BareJid contact) { + Bundle bundle = new Bundle(); + bundle.putString(ConversationFragment.KEY_JID, contact.toString()); + + ConversationFragment fragment = new ConversationFragment(); + fragment.setArguments(bundle); + + getFragmentManager().beginTransaction() + .add(R.id.fragment_container, fragment) + .addToBackStack("conversation") + .commit(); + } } diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/LoginActivity.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/LoginActivity.java index 3707146..81912f6 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/LoginActivity.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/LoginActivity.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.view; import android.content.Intent; @@ -20,6 +37,8 @@ import butterknife.OnClick; import de.vanitasvitae.slam.AbstractTextWatcher; import de.vanitasvitae.slam.EditorActionDoneListener; import de.vanitasvitae.slam.R; +import de.vanitasvitae.slam.mvp.DummyPresenterFactory; +import de.vanitasvitae.slam.mvp.PresenterFactory; import de.vanitasvitae.slam.mvp.view.abstr.ThemedAppCompatActivity; import de.vanitasvitae.slam.mvp.presenter.dummy.DummyLoginPresenter; import de.vanitasvitae.slam.mvp.contracts.LoginContract; @@ -50,6 +69,11 @@ public class LoginActivity extends ThemedAppCompatActivity implements LoginContr @BindView(R.id.button_login) Button buttonLogin; + public LoginActivity() { + super(); + this.presenter = PresenterFactory.getInstance().createLoginPresenter(this); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -58,8 +82,6 @@ public class LoginActivity extends ThemedAppCompatActivity implements LoginContr setSupportActionBar(toolbar); - this.presenter = new DummyLoginPresenter(this); - // attempt login on editor action done inputPassword.setOnEditorActionListener(new EditorActionDoneListener() { @Override diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/MainActivity.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/MainActivity.java index 72f37cf..a89fa86 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/MainActivity.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/MainActivity.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.view; import android.app.Fragment; @@ -17,8 +34,6 @@ import de.vanitasvitae.slam.mvp.view.abstr.ThemedAppCompatActivity; /** * Main activity that hosts some fragments. - * - * Created by vanitas on 22.01.18. */ public class MainActivity extends ThemedAppCompatActivity { @@ -51,8 +66,10 @@ public class MainActivity extends ThemedAppCompatActivity { drawerLayout.addDrawerListener(drawerToggle); Fragment chatListFragment = new ConversationListFragment(); - Log.d(TAG, "Begin Transaction"); - getFragmentManager().beginTransaction().add(R.id.fragment_container, chatListFragment).commit(); + getFragmentManager().beginTransaction() + .add(R.id.fragment_container, chatListFragment) + .addToBackStack("conversation_list") + .commit(); } @Override diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/SearchFragment.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/SearchFragment.java index 23a138f..fe62168 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/SearchFragment.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/SearchFragment.java @@ -1,9 +1,27 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.view; import android.app.Fragment; import java.util.List; +import de.vanitasvitae.slam.mvp.PresenterFactory; import de.vanitasvitae.slam.mvp.contracts.SearchContract; /** @@ -13,6 +31,12 @@ import de.vanitasvitae.slam.mvp.contracts.SearchContract; */ public class SearchFragment extends Fragment implements SearchContract.View { + private final SearchContract.Presenter presenter; + + public SearchFragment() { + this.presenter = PresenterFactory.getInstance().createSearchPresenter(this); + } + @Override public void addSearchResults(List results) { diff --git a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/abstr/ThemedAppCompatActivity.java b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/abstr/ThemedAppCompatActivity.java index f30fd22..047965c 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/abstr/ThemedAppCompatActivity.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/mvp/view/abstr/ThemedAppCompatActivity.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.mvp.view.abstr; import android.annotation.SuppressLint; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReadReceiver.java b/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReadReceiver.java index 680ce6c..466cf24 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReadReceiver.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReadReceiver.java @@ -1,19 +1,20 @@ /* - * Copyright (C) 2014 The Android Open Source Project + * Copyright 2018 Paul Schaub * - * 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 + * This code 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. * - * 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. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package de.vanitasvitae.slam.receiver; import android.content.BroadcastReceiver; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReplyReceiver.java b/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReplyReceiver.java index 51bd583..d0ddd9c 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReplyReceiver.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReplyReceiver.java @@ -1,19 +1,20 @@ /* - * Copyright (C) 2014 The Android Open Source Project + * Copyright 2018 Paul Schaub * - * 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 + * This code 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. * - * 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. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package de.vanitasvitae.slam.receiver; import android.content.BroadcastReceiver; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/service/MyMessagingService.java b/mobile/src/main/java/de/vanitasvitae/slam/service/MyMessagingService.java index 44aa98a..d4798c7 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/service/MyMessagingService.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/service/MyMessagingService.java @@ -1,19 +1,20 @@ /* - * Copyright (C) 2014 The Android Open Source Project + * Copyright 2018 Paul Schaub * - * 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 + * This code 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. * - * 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. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package de.vanitasvitae.slam.service; import android.app.PendingIntent; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/ui/ChatMessageEntry.java b/mobile/src/main/java/de/vanitasvitae/slam/ui/ChatMessageEntry.java index e8b16fb..300c548 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/ui/ChatMessageEntry.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/ui/ChatMessageEntry.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.ui; import android.support.v7.widget.RecyclerView; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/ui/ConversationEntry.java b/mobile/src/main/java/de/vanitasvitae/slam/ui/ConversationEntry.java index 9150eb7..6f29456 100644 --- a/mobile/src/main/java/de/vanitasvitae/slam/ui/ConversationEntry.java +++ b/mobile/src/main/java/de/vanitasvitae/slam/ui/ConversationEntry.java @@ -1,3 +1,20 @@ +/* + * Copyright 2018 Paul Schaub + * + * This code 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ package de.vanitasvitae.slam.ui; import android.support.v7.widget.RecyclerView; diff --git a/mobile/src/main/java/de/vanitasvitae/slam/xmpp/Contact.java b/mobile/src/main/java/de/vanitasvitae/slam/xmpp/Contact.java new file mode 100644 index 0000000..e9fb661 --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/xmpp/Contact.java @@ -0,0 +1,29 @@ +package de.vanitasvitae.slam.xmpp; + +import org.jxmpp.jid.BareJid; + +/** + * Created by Paul Schaub on 11.02.18. + */ +public class Contact { + + private final BareJid jid; + private String nickname; + + public Contact(BareJid jid) { + this(jid, null); + } + + public Contact(BareJid jid, String nickname) { + this.jid = jid; + this.nickname = nickname; + } + + public BareJid getJid() { + return jid; + } + + public String getNickname() { + return nickname; + } +} diff --git a/mobile/src/main/java/de/vanitasvitae/slam/xmpp/Conversation.java b/mobile/src/main/java/de/vanitasvitae/slam/xmpp/Conversation.java new file mode 100644 index 0000000..8fb66be --- /dev/null +++ b/mobile/src/main/java/de/vanitasvitae/slam/xmpp/Conversation.java @@ -0,0 +1,33 @@ +package de.vanitasvitae.slam.xmpp; + +/** + * Created by Paul Schaub on 11.02.18. + */ +public class Conversation { + + private final Contact contact; + private final String lastMessage; + private final String date; + + public Conversation(Contact contact) { + this(contact, null, null); + } + + public Conversation(Contact contact, String lastMessage, String date) { + this.contact = contact; + this.lastMessage = lastMessage; + this.date = date; + } + + public Contact getContact() { + return contact; + } + + public String getLastMessage() { + return lastMessage; + } + + public String getDate() { + return date; + } +} diff --git a/mobile/src/main/res/layout/fragment_contact_detail.xml b/mobile/src/main/res/layout/fragment_contact_detail.xml new file mode 100644 index 0000000..549c71e --- /dev/null +++ b/mobile/src/main/res/layout/fragment_contact_detail.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file