diff --git a/Android/BewoMitarbeiterApp/app/app.iml b/Android/BewoMitarbeiterApp/app/app.iml index c0810e81b..775fb29fa 100644 --- a/Android/BewoMitarbeiterApp/app/app.iml +++ b/Android/BewoMitarbeiterApp/app/app.iml @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java b/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java index 350f83797..7a28e5d75 100644 --- a/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java +++ b/Android/BewoMitarbeiterApp/app/src/main/java/Database/DatabaseHandler.java @@ -38,7 +38,7 @@ public class DatabaseHandler extends SQLiteOpenHelper { private static final String LOGTAG = "DATABASE_HANDLER"; //DataBase version - private static final int DATABASE_VERSION = 9; + private static final int DATABASE_VERSION = 10; //Database name private static final String DATABASE_NAME = "Contacts_Manager"; diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java index d30b8feda..8998ae55e 100644 --- a/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java +++ b/Android/BewoMitarbeiterApp/app/src/main/java/beyondsoft/bewomitarbeiterapp/ChatActivity.java @@ -100,8 +100,6 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei private final static String LOGTAG = "CHAT_ACTIVITY"; - private int mLastFirstVisibleItem = 0; - @Override public void onNetworkConnectionChanged(boolean isConnected) { BeWoLog.writeToLogFile("onNetworkConnectionChanged in ChatActivity aufgerufen. Bin "+ (isConnected ? "online" : "offline")); @@ -142,7 +140,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei int cc = view.getChildCount(); int lvp = view.getLastVisiblePosition(); - ChatMessage oldest = chatMessages.get(view.getLastVisiblePosition()); + ChatMessage oldest = chatMessages.get(fvp); String scrollStateName = ""; switch (scrollState) { @@ -163,17 +161,18 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei String lvpStr = String.format(Locale.GERMAN, "%1$3d", lvp); String ccStr = String.format(Locale.GERMAN, "%1$3d", cc); - Log.i("ON_SCROLL_STATE_CHANGED", "ScrollState: " + scrollStateName + "; FirstVisiblePosition: " + fvpStr + " LastVisiblePosition: " + lvpStr + "; ChildCount: " + ccStr + "; Id der ältesten Nachricht: " + oldest.MessageId); - - if(fvp == 0) { + if(fvp == 0 && scrollState == SCROLL_STATE_IDLE) { //TODO: Nachichten nachladen +// Log.i("ON_SCROLL_STATE_CHANGED", "ScrollState: " + scrollStateName + "; FirstVisiblePosition: " + fvpStr + " LastVisiblePosition: " + lvpStr + "; ChildCount: " + ccStr + "; Id der ältesten Nachricht: " + oldest.MessageId + "; " + oldest.ChatText); + Log.i("ON_SCROLL_STATE_CHANGED", "Lade Nachrichten nach..."); + + // TODO: die MessageId der ältesten Nachricht übergeben! + loadMessages(oldest.MessageId, false); } } @Override - public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { -// Log.i("ON_SCROLL", "Scrolle... firstVisibleItem: " + firstVisibleItem + "; visibleItemCount: " + visibleItemCount + "; totalItemCount" + totalItemCount); - } + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); Bundle zielkorb = getIntent().getExtras(); @@ -372,46 +371,21 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei } }); - ArrayList test = isTeam ? databaseHandler.getExistingTeamChatMessageUUIDs() : databaseHandler.getExistingChatMessageUUIDs(); + loadMessages(null, true); - String pExceptions = ""; - for(int i = 0; i < test.size(); i++) { - pExceptions += test.get(i); + NotificationManager mNotifyMgr = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); - if(i < test.size() - 1) { - pExceptions += ";"; - } + ChatEntity entity = new ChatEntity(recipientOid, isTeam, isEmployee); + + if(SocketManager.notificationEntities.get(entity) != null) { + mNotifyMgr.cancel(SocketManager.notificationEntities.get(entity).getNotificationId()); + Util.removeMessagesCount(entity); + } else { + Log.i("CHAT_ACTIVITY", "Keine Notification für diesen Chat vorhanden."); } + } - // TODO: Anfang Test ---------------------------------------------------------------------------------------------------------------------------------------------------- - String newestMessageId = ""; - - if(test.size() > 0) { - newestMessageId = test.get(test.size() - 1); - } - - Log.i("CHUNKS", "MessageId der Nachricht, die nicht geladen wird: " + newestMessageId); - - ArrayList propertyInfos2 = new ArrayList<>(); - propertyInfos2.add(SoapConnectionManager.BuildProperty("messageId", newestMessageId, String.class)); - propertyInfos2.add(SoapConnectionManager.BuildProperty("pRecipientPersonOid", recipientPersonOid, Long.class)); - propertyInfos2.add(SoapConnectionManager.BuildProperty("pSenderPersonOid", SoapConnectionManager.getUser().getPersonOid(), Long.class)); - propertyInfos2.add(SoapConnectionManager.BuildProperty("pIsForTeam", isTeam, Boolean.class)); - propertyInfos2.add(SoapConnectionManager.BuildProperty("pExceptions", pExceptions, String.class)); - - final JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.LOAD_CHATMESSAGES_CHUNKWISE, propertyInfos2); -// spiceManager.execute(request, new JsonSoapChunkRequestListener()); - - // TODO: Ende Test ------------------------------------------------------------------------------------------------------------------------------------------------------ - -// ArrayList propertyInfos = new ArrayList<>(); -// propertyInfos.add(SoapConnectionManager.BuildProperty("pSenderPersonOid", SoapConnectionManager.getUser().getPersonOid(), Long.class)); -// propertyInfos.add(SoapConnectionManager.BuildProperty("pRecipientPersonOid", recipientPersonOid, Long.class)); -// propertyInfos.add(SoapConnectionManager.BuildProperty("pExceptions", pExceptions, String.class)); -// propertyInfos.add(SoapConnectionManager.BuildProperty("pIsForTeam", isTeam, Boolean.class)); -// -// final JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.GET_ALL_CHAT_MESSAGES, propertyInfos); - + private void loadMessages(String pNewestMessage, final Boolean isInitialCall) { final Callback corruptedSpiceCallback = new Callback() { @Override public void doCallback() { @@ -440,16 +414,48 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei } }; + ArrayList test = isTeam ? databaseHandler.getExistingTeamChatMessageUUIDs() : databaseHandler.getExistingChatMessageUUIDs(); + + String pExceptions = ""; + for(int i = 0; i < test.size(); i++) { + pExceptions += test.get(i); + + if(i < test.size() - 1) { + pExceptions += ";"; + } + } + + String newestMessageId = ""; + + if(pNewestMessage == null) { + if (test.size() > 0) { + newestMessageId = test.get(test.size() - 1); + } + } else { + newestMessageId = pNewestMessage; + } + + Log.i("CHUNKS", "MessageId der ältesten, bereits heruntergeladenen Nachricht: " + newestMessageId); + + ArrayList propertyInfos2 = new ArrayList<>(); + propertyInfos2.add(SoapConnectionManager.BuildProperty("messageId", newestMessageId, String.class)); + propertyInfos2.add(SoapConnectionManager.BuildProperty("pRecipientPersonOid", recipientPersonOid, Long.class)); + propertyInfos2.add(SoapConnectionManager.BuildProperty("pSenderPersonOid", SoapConnectionManager.getUser().getPersonOid(), Long.class)); + propertyInfos2.add(SoapConnectionManager.BuildProperty("pIsForTeam", isTeam, Boolean.class)); + propertyInfos2.add(SoapConnectionManager.BuildProperty("pExceptions", pExceptions, String.class)); + + final JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.LOAD_CHATMESSAGES_CHUNKWISE, propertyInfos2); + if(ConnectivityReceiver.isConnected()) { if((Calendar.getInstance().getTime().getTime() - BeWoChatApplication.lastOnlineTS.getTime()) < BeWoChatApplication.getRefreshIntervalInMilliseconds()) { BeWoLog.writeToLogFile("Lade alle Nachrichten für diesen Chat herunter. (ChatActivity)"); - spiceManager.execute(request, new JsonSoapPrimitiveRequestListener(corruptedSpiceCallback)); + spiceManager.execute(request, new JsonSoapPrimitiveRequestListener(corruptedSpiceCallback, isInitialCall)); } else { SocketManager.loginCallbackAfterConnectionLost = new Callback() { @Override public void doCallback() { BeWoLog.writeToLogFile("Lade alle Nachrichten für diesen Chat nach fehlgeschlagenem ersten Versuch herunter. (ChatActivity)"); - spiceManager.execute(request, new JsonSoapPrimitiveRequestListener(corruptedSpiceCallback)); + spiceManager.execute(request, new JsonSoapPrimitiveRequestListener(corruptedSpiceCallback, isInitialCall)); } }; SocketManager.connectToServer("ChatActivity -> Letzter Serverkontakt ist länger als " + BeWoChatApplication.getRefreshIntervalInMinutes() + " Minuten her"); @@ -458,17 +464,6 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei BeWoLog.writeToLogFile("App ist offline. (ChatActivity)"); Toast.makeText(getApplicationContext(), "Offline. Keine Aktion möglich.", Toast.LENGTH_LONG).show(); } - - NotificationManager mNotifyMgr = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); - - ChatEntity entity = new ChatEntity(recipientOid, isTeam, isEmployee); - - if(SocketManager.notificationEntities.get(entity) != null) { - mNotifyMgr.cancel(SocketManager.notificationEntities.get(entity).getNotificationId()); - Util.removeMessagesCount(entity); - } else { - Log.i("CHAT_ACTIVITY", "Keine Notification für diesen Chat vorhanden."); - } } @Override @@ -592,9 +587,11 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei private final class JsonSoapPrimitiveRequestListener implements RequestListener { Callback corruptedRequestCallback; + Boolean isInitialCall; - JsonSoapPrimitiveRequestListener(Callback corruptedRequestCallback) { + JsonSoapPrimitiveRequestListener(Callback corruptedRequestCallback, Boolean isInitialCall) { this.corruptedRequestCallback = corruptedRequestCallback; + this.isInitialCall = isInitialCall; } @Override @@ -671,6 +668,13 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei public void run() { chatMessages.addAll(result); adapter.sort(DATE_COMPARATOR); + if(!isInitialCall) { + try { + listView.setSelection(0); + } catch(Exception e) { + Util.buildAlert(ChatActivity.this, "adapter.getCount() hat nicht funktioniert!"); + } + } adapter.notifyDataSetChanged(); } }); diff --git a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java index 5efba1dcd..17c3a5c4e 100644 --- a/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java +++ b/Android/BewoMitarbeiterApp/app/src/main/java/soapConnection/SoapCalls.java @@ -16,24 +16,24 @@ public class SoapCalls { public static String LOAD_CHATMESSAGES_CHUNKWISE = "LoadChatMessagesChunkwise"; //TODO: "app4.bewoplaner.de";// -// public static String DESTINATION_ADDRESS = "app4.bewoplaner.de"; -// public static int DESTINATION_PORT = 5000; -// -// public static String TOKEN_CHECK_URL = "https://" + DESTINATION_ADDRESS + "/mobil/main/checktoken?token="; -// -// public static String WEB_DOKU_URL = "https://app1.bewoplaner.de/mobil/login/1234567890"; -// -// public static String WSDL_TARGET_NAME = "bliblablubb.org/"; -// public static String SOAP_ADDRESS = "https://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx"; - - - public static String DESTINATION_ADDRESS = "192.168.1.103"; + public static String DESTINATION_ADDRESS = "app4.bewoplaner.de"; public static int DESTINATION_PORT = 5000; - public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token="; + public static String TOKEN_CHECK_URL = "https://" + DESTINATION_ADDRESS + "/mobil/main/checktoken?token="; - public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/login/demo"; + public static String WEB_DOKU_URL = "https://app1.bewoplaner.de/mobil/login/1234567890"; - static String WSDL_TARGET_NAME = "bliblablubb.org/"; - static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx"; + public static String WSDL_TARGET_NAME = "bliblablubb.org/"; + public static String SOAP_ADDRESS = "https://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx"; + + +// public static String DESTINATION_ADDRESS = "192.168.1.103"; +// public static int DESTINATION_PORT = 5000; +// +// public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token="; +// +// public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/login/demo"; +// +// static String WSDL_TARGET_NAME = "bliblablubb.org/"; +// static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx"; } diff --git a/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml b/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml index b7759bfa8..8e0fc57a2 100644 --- a/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml +++ b/Android/BewoMitarbeiterApp/app/src/main/res/layout/chat.xml @@ -18,7 +18,7 @@ android:listSelector="@android:color/transparent" android:stackFromBottom="true" android:background="@color/white" - android:transcriptMode="alwaysScroll" + android:transcriptMode="disabled" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" /> diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index e851a916c..e6361bf1f 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -1716,15 +1716,16 @@ namespace BeWo.Data.Access if (!string.IsNullOrEmpty(pMessageId)) { var c1 = CreateCriteriaIsActive() - .Add(Restrictions.Eq(ChatMessage.PropertyName_MessageId, pMessageId)); - var lastLoadedChatMessage = c1.UniqueResult(); + .Add(Restrictions.Eq(ChatMessage.PropertyName_MessageId, pMessageId)) + .AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs)); + var lastLoadedChatMessage = c1.List().First(); c.Add(Restrictions.Not(Restrictions.In(ChatMessage.PropertyName_MessageId, pExceptions))); - c.Add(Restrictions.Gt(BeWoEntityBase.PropertyName_InsTs, lastLoadedChatMessage.InsTs)); + c.Add(Restrictions.Lt(BeWoEntityBase.PropertyName_InsTs, lastLoadedChatMessage.InsTs)); } c.AddOrder(Order.Desc(BeWoEntityBase.PropertyName_InsTs)); - c.SetMaxResults(15); + c.SetMaxResults(50); return c.List(); } diff --git a/Model/Changes_03_11_2016.txt b/Model/Changes_03_11_2016.txt index 98a2a3440..c01957499 100644 --- a/Model/Changes_03_11_2016.txt +++ b/Model/Changes_03_11_2016.txt @@ -1,4 +1,4 @@ -ALTER TABLE `1234567890`.`chatmessages` +ALTER TABLE `chatmessages` DROP COLUMN `BildDatei`, @@ -7,6 +7,6 @@ DROP COLUMN `DokuDatei`, CHANGE COLUMN `SoundDatei` `MediaDatei` LONGBLOB NULL DEFAULT NULL COMMENT '' ; -ALTER TABLE `1234567890`.`chatmessages` +ALTER TABLE `chatmessages` ADD COLUMN `MediaTyp` INT(10) NULL DEFAULT NULL COMMENT '' AFTER `MessageId`; diff --git a/Model/Changes_04_11_2016.txt b/Model/Changes_04_11_2016.txt index 21826509c..18cd1e48b 100644 --- a/Model/Changes_04_11_2016.txt +++ b/Model/Changes_04_11_2016.txt @@ -1,3 +1,3 @@ -ALTER TABLE `1234567890`.`supportconceptapprovalperiod2employee` +ALTER TABLE `supportconceptapprovalperiod2employee` ADD COLUMN `IsAbsolut` INT(10) NULL DEFAULT 0 COMMENT '' AFTER `Betreuungsschluessel`;