Merged Files
This commit is contained in:
14
Android/BewoMitarbeiterApp/.idea/gradle.xml
generated
14
Android/BewoMitarbeiterApp/.idea/gradle.xml
generated
@@ -5,6 +5,20 @@
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/volley" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="myModules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/volley" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
6
Android/BewoMitarbeiterApp/.idea/vcs.xml
generated
Normal file
6
Android/BewoMitarbeiterApp/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/volley" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -7,23 +7,13 @@
|
||||
<option name="BUILDABLE" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -82,17 +82,42 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="ksoap2-android-assembly-3.6.0-jar-with-dependencies" level="project" />
|
||||
<orderEntry type="library" exported="" name="gson-2.6.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
|
||||
<orderEntry type="module" module-name="volley" exported="" />
|
||||
<orderEntry type="library" exported="" name="android-android-21" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -22,8 +22,11 @@ android {
|
||||
dependencies {
|
||||
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:21.0.3'
|
||||
compile files('libs/gson-2.6.2.jar')
|
||||
compile files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
|
||||
// compile files('libs/gson-2.6.2.jar')
|
||||
// compile files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
|
||||
compile 'com.octo.android.robospice:robospice:1.4.14'
|
||||
compile project(":volley")
|
||||
compile project(':volley')
|
||||
compile files('src/libs/gson-2.6.2.jar')
|
||||
compile files('src/libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
|
||||
// compile files('src/libs/robospice-1.4.14.jar')
|
||||
}
|
||||
|
||||
BIN
Android/BewoMitarbeiterApp/app/src/libs/gson-2.6.2.jar
Normal file
BIN
Android/BewoMitarbeiterApp/app/src/libs/gson-2.6.2.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
Android/BewoMitarbeiterApp/app/src/libs/robospice-1.4.14.jar
Normal file
BIN
Android/BewoMitarbeiterApp/app/src/libs/robospice-1.4.14.jar
Normal file
Binary file not shown.
@@ -1,11 +1,8 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@@ -16,20 +13,11 @@ import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.content.IntentCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.Html;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -39,43 +27,30 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
|
||||
/**
|
||||
* Created by bib on 03.05.2016.
|
||||
*/
|
||||
public class ChatActiviti extends ActionBarActivity{
|
||||
public class ChatActivity extends ActionBarActivity{
|
||||
|
||||
//View Variablen
|
||||
protected TextView chat;
|
||||
@@ -84,11 +59,11 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
|
||||
//Server Variablen
|
||||
public static Socket socket;
|
||||
protected static final String dstAddress = "192.168.1.115"; //10.0.2.2"
|
||||
protected static final String dstAddress = "192.168.1.103"; //10.0.2.2"
|
||||
protected static final int dstPort = 5000;
|
||||
DataOutputStream st;
|
||||
|
||||
String SaveCompletteMS;
|
||||
String SaveCompleteMS;
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
@@ -107,7 +82,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
File Unsendfile = null;
|
||||
//Chat Name
|
||||
protected String name;
|
||||
|
||||
protected int personOid;
|
||||
|
||||
//Für Notification
|
||||
private static boolean isOnStop = false;
|
||||
@@ -117,7 +92,6 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.chat);
|
||||
|
||||
//########### Custom Action Bar ##################################
|
||||
ActionBar action = getSupportActionBar();
|
||||
|
||||
action.setDisplayShowHomeEnabled(false);
|
||||
@@ -134,6 +108,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
//get Daten aus vorheriger Activity
|
||||
Bundle zielkorb = getIntent().getExtras();
|
||||
name = zielkorb.getString("Name");
|
||||
personOid = zielkorb.getInt("RecipientOid");
|
||||
|
||||
byte[] bildArray = zielkorb.getByteArray("Bild");
|
||||
Bitmap customerImage;
|
||||
@@ -148,24 +123,19 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
/* ImageView img = (ImageView) mCustomView.findViewById(R.id.status);
|
||||
img.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
ChatActiviti.this.openOptionsMenu(); // activity's onCreateOptionsMenu gets called
|
||||
ChatActivity.this.openOptionsMenu(); // activity's onCreateOptionsMenu gets called
|
||||
//optionsMenu.performIdentifierAction(R.id., 0);
|
||||
}
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
|
||||
titlename.setText(name);
|
||||
|
||||
action.setCustomView(mCustomView);
|
||||
action.setDisplayShowCustomEnabled(true);
|
||||
//###########################################################################################
|
||||
|
||||
senden = (Button)findViewById(R.id.Sendebutton);
|
||||
//chat = (TextView)findViewById(R.id.ChatText);
|
||||
|
||||
//################### Initial Design Variabeln Message Adapter #############################################
|
||||
chatMessages = new ArrayList<>();
|
||||
|
||||
listView = (ListView)findViewById(R.id.list_msg);
|
||||
@@ -173,11 +143,8 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
adapter = new MessageAdapter(this, R.layout.item_chat_left,chatMessages);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
//############################ Initial Design Variablen ende ###############################
|
||||
|
||||
//########################### Initial Socket ###############################################
|
||||
try {
|
||||
MainActivityMitarbeiter.isThreadPause = true;
|
||||
|
||||
|
||||
socket = MainActivityMitarbeiter.socket;
|
||||
|
||||
@@ -187,23 +154,16 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
}catch(Exception e){/*Fail*/}
|
||||
|
||||
|
||||
// MainActivityMitarbeiter.listen.interrupt();
|
||||
// MainActivityMitarbeiter.listen = null;
|
||||
// MainActivityMitarbeiter.listen.interrupt();
|
||||
// MainActivityMitarbeiter.listen = null;
|
||||
|
||||
|
||||
|
||||
//##########################################################################################
|
||||
|
||||
//############## Safe / Write gedöns #########################################################
|
||||
CreateFile();
|
||||
|
||||
ReadMessageToStorage();
|
||||
|
||||
//##########################################################################################
|
||||
|
||||
|
||||
//Öffnet eine Verbindung zum Server
|
||||
// new Thread(new OpenConnection()).start();
|
||||
// new Thread(new OpenConnection()).start();
|
||||
|
||||
|
||||
text = (EditText)findViewById(R.id.editText);
|
||||
@@ -217,28 +177,22 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
|
||||
if(text.getText().toString().equals("exit")){
|
||||
//eine möglich keit die connection zu schließen
|
||||
// new Thread(new ConnectionClose()).start();
|
||||
// new Thread(new ConnectionClose()).start();
|
||||
}else if(!text.getText().toString().equals("")){
|
||||
new Thread(new SendMS()).start();
|
||||
new Thread(new MessageSender()).start();
|
||||
}else{
|
||||
Toast.makeText(ChatActiviti.this, "Sie müssen schon Text eingeben ", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(ChatActivity.this, "Sie müssen schon Text eingeben ", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Erstelle einen immer horchenden Listener
|
||||
Thread t = new Thread(new SocketListener());
|
||||
t.start();
|
||||
|
||||
|
||||
|
||||
//MainActivityMitarbeiter.listen.sus
|
||||
}
|
||||
|
||||
|
||||
//######################### Server/ Client gedöns ##################################################
|
||||
/*public class OpenConnection implements Runnable{
|
||||
public void run(){
|
||||
try {
|
||||
@@ -246,11 +200,11 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
// Log.v("Status: ","Vorhanden 3");
|
||||
|
||||
//nachricht an server senden welcher name jetz aktiv connected ist
|
||||
st = new DataOutputStream(socket.getOutputStream());
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
name=name+"/1";
|
||||
byte[] ts = name.getBytes();
|
||||
st.write(ts);
|
||||
st.flush();
|
||||
dataOutputStream.write(ts);
|
||||
dataOutputStream.flush();
|
||||
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
@@ -262,25 +216,30 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
}
|
||||
}*/
|
||||
|
||||
public class SendMS implements Runnable{
|
||||
public class MessageSender implements Runnable{
|
||||
public void run(){
|
||||
String al = text.getText().toString();
|
||||
|
||||
|
||||
|
||||
byte[] ts = al.getBytes();
|
||||
|
||||
|
||||
//TODO: Packet erstellen
|
||||
//ChatActivity.
|
||||
|
||||
try{
|
||||
if(socket!= null ) {
|
||||
Packet p = new Packet();
|
||||
p.ChatMessage = text.getText().toString();
|
||||
p.SenderPersonOid = SoapConnectionManager.User.getPersonOid().intValue();
|
||||
p.ChatDataIdentifier = DataIdentifier.MESSAGE;
|
||||
p.ChatName = SoapConnectionManager.User.getFullName();
|
||||
p.RecipientPersonOid = personOid;
|
||||
|
||||
//try catch bei catch SaveAfterLoseConnection();
|
||||
|
||||
|
||||
|
||||
st.write(ts);
|
||||
st.write(p.GetDataStream());
|
||||
st.flush();
|
||||
}
|
||||
|
||||
|
||||
// Update der GUI
|
||||
listView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -288,24 +247,22 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
String formattedDate = df.format(c.getTime());
|
||||
|
||||
SaveCompletteMS = text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n";
|
||||
SaveCompleteMS = text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n";
|
||||
|
||||
WriteMessagesfromStorage(text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n");
|
||||
WriteMessagesfromStorage(text.getText().toString()+"/"+isMe+"%"+formattedDate+"\n");
|
||||
|
||||
chatMessage = new ChatMessageFormat(text.getText().toString(), isMe, formattedDate);
|
||||
chatMessages.add(chatMessage);
|
||||
adapter.notifyDataSetChanged();
|
||||
chatMessage = new ChatMessageFormat(text.getText().toString(), isMe, formattedDate);
|
||||
chatMessages.add(chatMessage);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
text.setText("");
|
||||
text.setText("");
|
||||
|
||||
}
|
||||
});
|
||||
}catch(IOException s){
|
||||
Log.v("Status: ","Senden einer Nachricht konnte nicht ausgeführt werden. Save wird ausgeführt");
|
||||
//Log.v("hallo",);
|
||||
|
||||
|
||||
SaveAfterLoseConnection(SaveCompletteMS);
|
||||
SaveAfterLoseConnection(SaveCompleteMS);
|
||||
s.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -315,9 +272,9 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
public void run(){
|
||||
try {
|
||||
// Log.v("Bin ich Überhaupt", "Hier drinne");
|
||||
if (st != null) {
|
||||
st.flush();
|
||||
st.close();
|
||||
if (dataOutputStream != null) {
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
}
|
||||
if (socket != null)
|
||||
socket = null;
|
||||
@@ -332,8 +289,6 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
|
||||
// Erhalte Messages all the time
|
||||
public class SocketListener implements Runnable{
|
||||
|
||||
|
||||
String str;
|
||||
long i = 1;
|
||||
//BufferedReader in = null;
|
||||
@@ -343,77 +298,75 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
Log.v("Komme","ICh den Rein");
|
||||
while(true){
|
||||
|
||||
if (socket != null) {
|
||||
Log.v("Komme","So wie es aussieht nicht ");
|
||||
if(socket.isConnected()) {
|
||||
Log.v("Connection Steht ", "Connection Steht");
|
||||
Log.v("Komme","So wie es aussieht nicht2 ");
|
||||
//final TextView text = (TextView)findViewById(R.id.ChatText);
|
||||
if (socket != null) {
|
||||
Log.v("Komme","So wie es aussieht nicht ");
|
||||
if(socket.isConnected()) {
|
||||
Log.v("Connection Steht ", "Connection Steht");
|
||||
Log.v("Komme","So wie es aussieht nicht2 ");
|
||||
//final TextView text = (TextView)findViewById(R.id.ChatText);
|
||||
|
||||
final ListView listV = (ListView) findViewById(R.id.list_msg);
|
||||
final ListView listV = (ListView) findViewById(R.id.list_msg);
|
||||
|
||||
Log.v("Komme","So wie es aussieht nicht 3");
|
||||
// in = new BufferedReader(new InputStreamReader(MainActivityMitarbeiter.socket.getInputStream()));
|
||||
Log.v("Komme","So wie es aussieht nicht 3");
|
||||
// in = new BufferedReader(new InputStreamReader(MainActivityMitarbeiter.socket.getInputStream()));
|
||||
|
||||
/*---> da wird das pendant ausgeführt und nicht dieses */ String s = in.readLine();
|
||||
Log.v("Komme","So wie es aussieht nicht 4");
|
||||
CharSequence cs = text.getText();
|
||||
Log.v("Komme","So wie es aussieht nicht 4");
|
||||
CharSequence cs = text.getText();
|
||||
|
||||
// wir nehmen mal cs raus
|
||||
//str = cs + "\r\n" + s;
|
||||
str = s;
|
||||
// wir nehmen mal cs raus
|
||||
//str = cs + "\r\n" + s;
|
||||
str = s;
|
||||
|
||||
if (s == null)
|
||||
break;
|
||||
if (s == null)
|
||||
break;
|
||||
|
||||
//Design Spezifisch
|
||||
listV.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//Design Spezifisch
|
||||
listV.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
String formattedDate = df.format(c.getTime());
|
||||
Calendar c = Calendar.getInstance();
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
String formattedDate = df.format(c.getTime());
|
||||
|
||||
boolean determind = false;
|
||||
boolean determind = false;
|
||||
|
||||
WriteMessagesfromStorage(str+"/"+determind+"%"+formattedDate+"\n");
|
||||
WriteMessagesfromStorage(str+"/"+determind+"%"+formattedDate+"\n");
|
||||
|
||||
chatMessage = new ChatMessageFormat(str, determind, formattedDate); //<---------- rausnehmen am besten alles
|
||||
chatMessages.add(chatMessage);
|
||||
adapter.notifyDataSetChanged(); //<----------
|
||||
chatMessage = new ChatMessageFormat(str, determind, formattedDate);
|
||||
chatMessages.add(chatMessage);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
Log.v("","");
|
||||
|
||||
if(isOnStop == true){
|
||||
SetNotifi("Bärtiger Hanz",str);
|
||||
}
|
||||
Log.v("","");
|
||||
|
||||
if(isOnStop == true){
|
||||
SetNotify("Bärtiger Hanz",str);
|
||||
}
|
||||
});
|
||||
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
});
|
||||
|
||||
if (in != null)
|
||||
in.close();
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
|
||||
// else Log.v("Connection","nicht aufgebaut"); nach tausend versuchen break und fehler ausgabe
|
||||
if (in != null)
|
||||
in.close();
|
||||
}
|
||||
|
||||
// else Log.v("Connection","nicht aufgebaut"); nach tausend versuchen break und fehler ausgabe
|
||||
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
Log.v("Status ","Verbindung zum Server wurde seitens dem Server getrennt ");
|
||||
// Log.e(getClass().getName(),e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// Log.e(getClass().getName(),e.getMessage());
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//#################################### Server Client Ende ##########################################
|
||||
|
||||
//########################### Speichere Message für Server bei unsend #####################################
|
||||
public void SaveAfterLoseConnection(String UnsendMessage){
|
||||
CreateCustomFileForUnSendMessage();
|
||||
try{
|
||||
@@ -430,36 +383,35 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
}
|
||||
|
||||
public void SendAfterGetConnection(){
|
||||
|
||||
//ist eine UnsendMessage File vorhanden
|
||||
if(Unsendfile != null && socket.isConnected()){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(Unsendfile);
|
||||
InputStreamReader in = new InputStreamReader(stream);
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
FileInputStream stream = new FileInputStream(Unsendfile);
|
||||
InputStreamReader in = new InputStreamReader(stream);
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
|
||||
String line = readLn.readLine();
|
||||
String allLines="";
|
||||
String line = readLn.readLine();
|
||||
String allLines="";
|
||||
|
||||
while (line != null) {
|
||||
allLines += line;
|
||||
while (line != null) {
|
||||
allLines += line;
|
||||
|
||||
String[] splitt = line.split("/");
|
||||
String[] splitt = line.split("/");
|
||||
|
||||
if(splitt.length >1 ) {
|
||||
String[] ArtDate = splitt[1].split("%");
|
||||
if(splitt.length >1 ) {
|
||||
String[] ArtDate = splitt[1].split("%");
|
||||
|
||||
final String message = splitt[0];
|
||||
final boolean art = Boolean.valueOf(ArtDate[0]);
|
||||
final String datetime = ArtDate[1];
|
||||
final String message = splitt[0];
|
||||
final boolean art = Boolean.valueOf(ArtDate[0]);
|
||||
final String datetime = ArtDate[1];
|
||||
|
||||
//für jede Gelesene Line Sende Nachricht
|
||||
new Thread(new SendUnsendMS(message)).start();
|
||||
}
|
||||
line = readLn.readLine();
|
||||
//für jede Gelesene Line Sende Nachricht
|
||||
new Thread(new SendUnsendMS(message)).start();
|
||||
}
|
||||
stream.close();
|
||||
in.close();
|
||||
line = readLn.readLine();
|
||||
}
|
||||
stream.close();
|
||||
in.close();
|
||||
Unsendfile.delete();
|
||||
}catch(Exception fe){
|
||||
Log.v("Status","Ein problem ist im BEreich Unsend Ms Aufgetreten");
|
||||
@@ -508,12 +460,6 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
}
|
||||
}
|
||||
|
||||
//####################### Ende Unsend Message Gedöns ###########################################
|
||||
|
||||
|
||||
|
||||
//############### Menue Bereich ################################################################
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menue_chat, menu);
|
||||
@@ -532,12 +478,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
}
|
||||
}
|
||||
|
||||
//################################################################################################
|
||||
|
||||
|
||||
//############## Setze Notification ############################################################
|
||||
|
||||
public void SetNotifi(String Username,String message){
|
||||
public void SetNotify(String Username, String message){
|
||||
|
||||
//Convertiert in Pic Resource in ein Bitmap
|
||||
//BitmapFactory.decodeResource(getResources(), R.drawable.bslogo)
|
||||
@@ -553,9 +494,9 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }) //Notification.Default_Vibrate
|
||||
.setLights(Color.YELLOW, 3000, 3000) //Notification.Default_Lights
|
||||
.setOngoing(true);
|
||||
//neuland ende
|
||||
//neuland ende
|
||||
|
||||
Intent resultIntent = new Intent(this, ChatActiviti.class);
|
||||
Intent resultIntent = new Intent(this, ChatActivity.class);
|
||||
//versuch ab hier neuland
|
||||
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
//neuland ende
|
||||
@@ -576,88 +517,52 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
mNotifyMgr.notify(001, mBuilder.build());
|
||||
}
|
||||
|
||||
//##############################################################################################
|
||||
|
||||
|
||||
//################ Activit abfragen ############################################################
|
||||
public void onStart(){
|
||||
SharedPreferences sp = getSharedPreferences("OURINFO", MODE_PRIVATE);
|
||||
Editor ed = sp.edit();
|
||||
ed.putBoolean("active", true);
|
||||
ed.commit();
|
||||
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
// Log.v("Stuss","Hier nochmals on creat aufrufen");
|
||||
// isOnStop = false;
|
||||
isOnStop = false;
|
||||
|
||||
// MainActivityMitarbeiter.isThreadPause = true;
|
||||
|
||||
SharedPreferences sp = getSharedPreferences("OURINFO", MODE_PRIVATE);
|
||||
Editor ed = sp.edit();
|
||||
ed.putBoolean("active", true);
|
||||
ed.commit();
|
||||
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void onStop(){
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
|
||||
// MainActivityMitarbeiter.isThreadPause = false;
|
||||
|
||||
//isOnStop = true;
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
|
||||
|
||||
SharedPreferences sp = getSharedPreferences("OURINFO", MODE_PRIVATE);
|
||||
Editor ed = sp.edit();
|
||||
ed.putBoolean("active", false);
|
||||
ed.commit();
|
||||
|
||||
isOnStop = true;
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public void onDestroy(){
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
// currentlisten = null;
|
||||
// MainActivityMitarbeiter.isThreadPause = false;
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
// currentlisten = null;
|
||||
|
||||
SharedPreferences sp = getSharedPreferences("OURINFO", MODE_PRIVATE);
|
||||
Editor ed = sp.edit();
|
||||
ed.putBoolean("active", false);
|
||||
ed.commit();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
//##############################################################################################
|
||||
|
||||
//################# Lade/Speichere Die Messages ################################################
|
||||
//create a File
|
||||
public void CreateFile(){
|
||||
|
||||
try{
|
||||
try{
|
||||
|
||||
File pfad = getBaseContext().getFilesDir();
|
||||
File pfad = getBaseContext().getFilesDir();
|
||||
|
||||
//Für external Save
|
||||
//File pfad = getBaseContext().getExternalFilesDir(null);
|
||||
//Für external Save
|
||||
//File pfad = getBaseContext().getExternalFilesDir(null);
|
||||
|
||||
//Erstelle das File Objekt
|
||||
//file = new File(pfad,name+".txt");
|
||||
//Erstelle das File Objekt
|
||||
//file = new File(pfad,name+".txt");
|
||||
|
||||
//vorläufig ##### für debug zwecke
|
||||
file = new File(pfad,"demo"+".txt");
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler"," Das erstellen/öffnen einer Datei ist Derzeit nicht möglich");
|
||||
}
|
||||
//vorläufig ##### für debug zwecke
|
||||
file = new File(pfad,"demo"+".txt");
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler"," Das erstellen/öffnen einer Datei ist Derzeit nicht möglich");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Internal Storage
|
||||
public void WriteMessagesfromStorage(String message){
|
||||
try{
|
||||
@@ -669,7 +574,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
stream.close();
|
||||
}
|
||||
|
||||
// Log.v("Status","Text: "+message+" wurde gespeichert." );
|
||||
// Log.v("Status","Text: "+message+" wurde gespeichert." );
|
||||
|
||||
}catch (Exception e){
|
||||
Log.v("Fehler 1 ",e.getMessage());
|
||||
@@ -680,7 +585,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
public void ReadMessageToStorage(){
|
||||
try{
|
||||
|
||||
// Log.v("Status","Verbindung steht 1");
|
||||
// Log.v("Status","Verbindung steht 1");
|
||||
int lenght = (int) file.length();
|
||||
|
||||
byte[] bytes = new byte[lenght];
|
||||
@@ -688,7 +593,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
|
||||
// Log.v("Status","Verbindung steht 2");
|
||||
// Log.v("Status","Verbindung steht 2");
|
||||
InputStreamReader in = new InputStreamReader(stream);
|
||||
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
@@ -703,7 +608,7 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
//---> <---//
|
||||
//String[] splitt = line.split("/");
|
||||
|
||||
// Log.v("Status",line);
|
||||
// Log.v("Status",line);
|
||||
|
||||
String[] splitt = line.split("/");
|
||||
|
||||
@@ -727,36 +632,29 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
}
|
||||
|
||||
line = readLn.readLine();
|
||||
|
||||
|
||||
}
|
||||
|
||||
stream.close();
|
||||
in.close();
|
||||
|
||||
// Log.v("Local Storage",allLines);
|
||||
// Log.v("Local Storage",allLines);
|
||||
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler 2 ",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//##############################################################################################
|
||||
|
||||
//################# Convert Bitmap for a circled bitmap ########################################
|
||||
private Bitmap GetCircleBitmap(Bitmap bitmap) {
|
||||
|
||||
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(output);
|
||||
|
||||
int color = Color.RED;
|
||||
Paint paint = new Paint();
|
||||
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
RectF rectF = new RectF(rect);
|
||||
int color = Color.RED;
|
||||
Paint paint = new Paint();
|
||||
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
RectF rectF = new RectF(rect);
|
||||
|
||||
//bis hierhin war alles final
|
||||
paint.setAntiAlias(true);
|
||||
@@ -771,7 +669,4 @@ public class ChatActiviti extends ActionBarActivity{
|
||||
|
||||
return output;
|
||||
}
|
||||
//##############################################################################################
|
||||
|
||||
|
||||
}
|
||||
@@ -5,13 +5,26 @@ package beyondsoft.bewomitarbeiterapp;
|
||||
*/
|
||||
public class ChatMessageFormat {
|
||||
|
||||
// sender, recipient
|
||||
private int senderPersonOid;
|
||||
|
||||
public int getRecipientPersonOid() {
|
||||
return recipientPersonOid;
|
||||
}
|
||||
|
||||
public int getSenderPersonOid() {
|
||||
return senderPersonOid;
|
||||
}
|
||||
|
||||
private int recipientPersonOid;
|
||||
|
||||
private boolean isMe;
|
||||
private String message;
|
||||
private String datum;
|
||||
|
||||
//villeicht eine issend variable einbauen
|
||||
//villeicht eine isSent-Variable einbauen
|
||||
|
||||
ChatMessageFormat(String message, boolean isMe,String datum){
|
||||
ChatMessageFormat(String message, boolean isMe, String datum){
|
||||
this.message = message;
|
||||
this.isMe = isMe;
|
||||
this.datum = datum;
|
||||
|
||||
@@ -4,8 +4,6 @@ package beyondsoft.bewomitarbeiterapp;
|
||||
* Created by bib on 07.06.2016.
|
||||
*/
|
||||
public class ContactList {
|
||||
|
||||
|
||||
private int _id;
|
||||
private String _kontaktname;
|
||||
private String _art;
|
||||
@@ -80,5 +78,4 @@ public class ContactList {
|
||||
public void setPicture(byte[] d){
|
||||
this._picture = d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class ContactListItem {
|
||||
private int _id;
|
||||
private String _kontaktname;
|
||||
private byte[] _picture;
|
||||
private int _personOid;
|
||||
|
||||
//default Construkt
|
||||
public ContactListItem(){}
|
||||
|
||||
//Construkt 1
|
||||
public ContactListItem(int id, String kontaktname, int personOid, byte[] picture){
|
||||
this._id = id;
|
||||
this._kontaktname = kontaktname;
|
||||
this._personOid = personOid;
|
||||
this._picture = picture;
|
||||
}
|
||||
|
||||
//Construkt 2
|
||||
public ContactListItem(String kontaktname, int personOid, byte[] picture){
|
||||
this._kontaktname = kontaktname;
|
||||
this._personOid = personOid;
|
||||
this._picture = picture;
|
||||
}
|
||||
|
||||
//Construkt 3
|
||||
public ContactListItem(String kontaktname, int personOid){
|
||||
this._kontaktname = kontaktname;
|
||||
this._personOid = personOid;
|
||||
this._picture = null;
|
||||
}
|
||||
|
||||
//Construkt4
|
||||
public ContactListItem(int id, String kontaktname, int personOid){
|
||||
this._id = id;
|
||||
this._kontaktname = kontaktname;
|
||||
this._personOid = personOid;
|
||||
this._picture = null;
|
||||
}
|
||||
|
||||
//ID
|
||||
public int getID(){
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public void setID(int id){
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
|
||||
// KONTAKT
|
||||
public String getKontaktName(){
|
||||
return this._kontaktname;
|
||||
}
|
||||
|
||||
public void setKontaktName(String k){
|
||||
this._kontaktname = k;
|
||||
}
|
||||
|
||||
//Picture
|
||||
public byte[] getPicture(){
|
||||
return this._picture;
|
||||
}
|
||||
|
||||
public void setPicture(byte[] d){
|
||||
this._picture = d;
|
||||
}
|
||||
|
||||
public int get_personOid() {
|
||||
return _personOid;
|
||||
}
|
||||
|
||||
public void set_personOid(int _personOid) {
|
||||
this._personOid = _personOid;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
//Table Columns name
|
||||
private static final String KEY_ID ="id";
|
||||
private static final String KEY_KontaktName = "kontaktname";
|
||||
private static final String KEY_ART = "art";
|
||||
private static final String KEY_PERSONOID = "personoid";
|
||||
private static final String KEY_Picture_BLOB = "bild";
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// Erstelle Tabelle | Tabellen construct
|
||||
public void onCreate(SQLiteDatabase db){
|
||||
String CREATE_CONTACTS_TABLE ="CREATE TABLE "+TABLE_CONTACTS +"("+
|
||||
KEY_ID +" INTEGER PRIMARY KEY,"+KEY_KontaktName+ " TEXT,"+
|
||||
KEY_ART +" TEXT," + KEY_Picture_BLOB+ " BLOB"+")";
|
||||
KEY_ID +" INTEGER PRIMARY KEY,"+KEY_KontaktName+ " TEXT,"+
|
||||
KEY_PERSONOID +" INTEGER," + KEY_Picture_BLOB+ " BLOB"+")";
|
||||
|
||||
db.execSQL(CREATE_CONTACTS_TABLE);
|
||||
}
|
||||
@@ -52,13 +52,13 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
//Add Neuen Contact
|
||||
void addContact(ContactList contact) {
|
||||
void addContact(ContactListItem contact) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
//Values übergabe
|
||||
values.put(KEY_KontaktName,contact.getKontaktName());
|
||||
values.put(KEY_ART,contact.getArt());
|
||||
values.put(KEY_PERSONOID,contact.get_personOid());
|
||||
values.put(KEY_Picture_BLOB,contact.getPicture());
|
||||
|
||||
db.insert(TABLE_CONTACTS,null,values);
|
||||
@@ -66,25 +66,25 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
//Hole ein Bestimten Contact
|
||||
ContactList getContact(int id) {
|
||||
ContactListItem getContact(int id) {
|
||||
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
|
||||
Cursor cursor = db.query(TABLE_CONTACTS, new String[]{KEY_ID,KEY_KontaktName,
|
||||
KEY_ART,KEY_Picture_BLOB},KEY_ID +"=?",new String[]{String.valueOf(id)}
|
||||
,null,null,null,null);
|
||||
KEY_PERSONOID,KEY_Picture_BLOB},KEY_ID +"=?",new String[]{String.valueOf(id)}
|
||||
,null,null,null,null);
|
||||
|
||||
if(cursor !=null)
|
||||
if(cursor !=null) {
|
||||
cursor.moveToFirst();
|
||||
}
|
||||
|
||||
ContactList clist = new ContactList(Integer.parseInt(cursor.getString(0)),cursor.getString(1),
|
||||
cursor.getString(2),cursor.getBlob(3));
|
||||
ContactListItem clist = new ContactListItem(Integer.parseInt(cursor.getString(0)),cursor.getString(1), Integer.parseInt(cursor.getString(2)),cursor.getBlob(3));
|
||||
return clist;
|
||||
}
|
||||
|
||||
//Holle alle Contacts
|
||||
public List<ContactList> getAllContacts(){
|
||||
List<ContactList> contactList = new ArrayList<ContactList>();
|
||||
public List<ContactListItem> getAllContacts(){
|
||||
List<ContactListItem> contactList = new ArrayList<ContactListItem>();
|
||||
// Select All Query
|
||||
String selectQuery = "SELECT * FROM " + TABLE_CONTACTS;
|
||||
|
||||
@@ -94,10 +94,10 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// looping through all rows and adding to list
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
ContactList contact = new ContactList();
|
||||
ContactListItem contact = new ContactListItem();
|
||||
contact.setID(Integer.parseInt(cursor.getString(0)));
|
||||
contact.setKontaktName(cursor.getString(1));
|
||||
contact.setArt(cursor.getString(2));
|
||||
contact.set_personOid(Integer.parseInt(cursor.getString(2)));
|
||||
contact.setPicture(cursor.getBlob(3));
|
||||
|
||||
// Adding contact to list
|
||||
@@ -109,12 +109,12 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
//updating single Contact
|
||||
public int updateContact(ContactList contact) {
|
||||
public int updateContact(ContactListItem contact) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_KontaktName, contact.getKontaktName());
|
||||
values.put(KEY_ART, contact.getArt());
|
||||
values.put(KEY_PERSONOID, contact.get_personOid());
|
||||
values.put(KEY_Picture_BLOB, contact.getPicture());
|
||||
|
||||
// updating row
|
||||
@@ -123,10 +123,9 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
//Delet single Contact
|
||||
public void deletContacts(ContactList contact){
|
||||
public void deletContacts(ContactListItem contact){
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
|
||||
new String[] { String.valueOf(contact.getID()) });
|
||||
db.delete(TABLE_CONTACTS, KEY_ID + " = ?", new String[] { String.valueOf(contact.getID()) });
|
||||
db.close();
|
||||
}
|
||||
|
||||
@@ -140,5 +139,13 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
return cursor.getCount();
|
||||
}
|
||||
|
||||
public byte[] getUserImage(Integer personOid) {
|
||||
|
||||
SQLiteDatabase database = this.getReadableDatabase();
|
||||
|
||||
Cursor cursor = database.query(TABLE_CONTACTS, new String[] {KEY_PERSONOID}, " = " + personOid, null, null, null, null);
|
||||
cursor.close();
|
||||
|
||||
return cursor.getBlob(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
@@ -10,15 +11,11 @@ import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.media.Image;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -26,16 +23,15 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by bib on 03.05.2016.
|
||||
*/
|
||||
public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
|
||||
|
||||
private final Context context;
|
||||
private final ContactList[] values;
|
||||
// private final List<ContactList> contactlist;
|
||||
private final ContactListItem[] values;
|
||||
// private final List<ContactListItem> contactlist;
|
||||
|
||||
private Bitmap bitmaping;
|
||||
ImageView imageView;
|
||||
@@ -46,31 +42,26 @@ public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
Thread getM;
|
||||
Thread getPic;
|
||||
|
||||
|
||||
public KontaktAdapter(Context context, ContactList[] values) {
|
||||
super(context, R.layout.kontakt_list_chat,values);
|
||||
public KontaktAdapter(Context context, ContactListItem[] values) {
|
||||
super(context, R.layout.kontakt_list_chat, values);
|
||||
this.context = context;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
View rowView = inflater.inflate(R.layout.kontakt_list_chat, parent, false);
|
||||
TextView textView = (TextView) rowView.findViewById(R.id.label);
|
||||
minitext = (TextView) rowView.findViewById(R.id.subtitle);
|
||||
// TextView lasttime = (TextView) rowView.findViewById(R.id.lasttime);
|
||||
|
||||
ImageView onlinestats = (ImageView)rowView.findViewById(R.id.status);
|
||||
imageView = (ImageView) rowView.findViewById(R.id.logo);
|
||||
|
||||
// ImageView Bau die Kontakt View auf
|
||||
textView.setText(values[position].getKontaktName());
|
||||
|
||||
|
||||
//Textzuweisung auf die methode verlagern
|
||||
if(values[position].getKontaktName().equals("Demo")) {
|
||||
getM = new Thread(new ReadLastMessage(values[position].getKontaktName(), inflater));
|
||||
getM.start();
|
||||
@@ -78,12 +69,6 @@ public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
minitext.setText("Hier könnte auch ihre Nachricht stehen");
|
||||
|
||||
|
||||
Log.v("Bis hierhin","Alles correct");
|
||||
|
||||
//get last Message from File
|
||||
//filedaten = ReadLastMessage(values[position].getKontaktName(),inflater);
|
||||
|
||||
//abfrage mit demo ist provisorium weil zurzeit alle auf demo zugreifen würden
|
||||
/*if(values[position].getKontaktName().equals("Demo") && filedaten != null)
|
||||
minitext.setText(filedaten[0]);
|
||||
else
|
||||
@@ -98,49 +83,52 @@ public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
//Konvert byte[] to Image
|
||||
Bitmap i = BitmapFactory.decodeByteArray(values[position].getPicture(),0,values[position].getPicture().length);
|
||||
|
||||
getPic = new Thread(new GetCircleBitmap(i));
|
||||
|
||||
|
||||
getPic = new Thread(new CircleBitmapCreator(i));
|
||||
getPic.start();
|
||||
|
||||
// t.interrupt();
|
||||
// t.interrupt();
|
||||
|
||||
//imageView.setImageBitmap(bitmaping);
|
||||
}else {
|
||||
// imageView.setImageBitmap(CircleBitmapCreator(i));
|
||||
} else {
|
||||
//wenn der kontakt kein bild besitzt dann nimm Default bild
|
||||
//Bitmap customerImage =((BitmapDrawable).getDrawable(R.drawable.katze3)).getBitmap();
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(inflater.getContext().getResources(), R.drawable.katze3);
|
||||
// imageView.setImageResource(R.drawable.katze3);
|
||||
Bitmap bitmap = decodeSampledBitmapFromResource(inflater.getContext().getResources(), R.drawable.katze3, 100, 100);//BitmapFactory.decodeResource(inflater.getContext().getResources(), R.drawable.katze3);
|
||||
|
||||
getPic = new Thread(new GetCircleBitmap(bitmap));
|
||||
|
||||
|
||||
// imageView.setImageResource(CircleBitmapCreator(bitmap));
|
||||
|
||||
getPic = new Thread(new CircleBitmapCreator(bitmap));
|
||||
getPic.start();
|
||||
|
||||
|
||||
|
||||
// imageView.setImageBitmap(bitmaping);
|
||||
// imageView.setImageBitmap(CircleBitmapCreator(bitmap));
|
||||
}
|
||||
|
||||
//if statement ob kontakt online oder net
|
||||
if(values[position].getArt().equals("1"))
|
||||
onlinestats.setImageResource(R.drawable.online);
|
||||
else if(values[position].getArt().equals("2"))
|
||||
onlinestats.setImageResource(R.drawable.beschaftigt);
|
||||
else if(values[position].getArt().equals("3"))
|
||||
onlinestats.setImageResource(R.drawable.offline);
|
||||
// if(values[position].getArt().equals("1"))
|
||||
// onlinestats.setImageResource(R.drawable.online);
|
||||
// else if(values[position].getArt().equals("2"))
|
||||
// onlinestats.setImageResource(R.drawable.beschaftigt);
|
||||
// else if(values[position].getArt().equals("3"))
|
||||
// onlinestats.setImageResource(R.drawable.offline);
|
||||
|
||||
|
||||
return rowView;
|
||||
}
|
||||
|
||||
|
||||
public class GetCircleBitmap implements Runnable{
|
||||
public class CircleBitmapCreator implements Runnable{
|
||||
|
||||
Bitmap bitmap;
|
||||
GetCircleBitmap(Bitmap _bitmap){
|
||||
CircleBitmapCreator(Bitmap _bitmap){
|
||||
this.bitmap = _bitmap;
|
||||
}
|
||||
|
||||
public void run(){
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(output);
|
||||
|
||||
final int color = Color.RED;
|
||||
@@ -160,29 +148,46 @@ public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
|
||||
bitmaping = output;
|
||||
|
||||
Log.v("GET Circled"," Picture");
|
||||
|
||||
//if(imageView != null)
|
||||
// imageView.setImageBitmap(output);
|
||||
|
||||
|
||||
imageView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
imageView.setImageBitmap(bitmaping);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) {
|
||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeResource(res, resId, options);
|
||||
|
||||
//Convert Bitmap for a circled bitmap
|
||||
/*private Bitmap GetCircleBitmap(Bitmap bitmap ) {
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
|
||||
|
||||
options.inJustDecodeBounds = false;
|
||||
return BitmapFactory.decodeResource(res, resId, options);
|
||||
}
|
||||
|
||||
public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
||||
final int height = options.outHeight;
|
||||
final int width = options.outWidth;
|
||||
|
||||
int inSampleSize = 1;
|
||||
|
||||
if(height > reqHeight || width > reqWidth) {
|
||||
if(width > height) {
|
||||
inSampleSize = Math.round((float) height / (float) reqHeight);
|
||||
}
|
||||
else {
|
||||
inSampleSize = Math.round((float) width / (float) reqWidth);
|
||||
}
|
||||
}
|
||||
|
||||
return inSampleSize;
|
||||
}
|
||||
|
||||
/* private Bitmap CircleBitmapCreator(Bitmap bitmap ) {
|
||||
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(output);
|
||||
|
||||
final int color = Color.RED;
|
||||
@@ -203,8 +208,6 @@ public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
return output;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
public class ReadLastMessage implements Runnable{
|
||||
|
||||
LayoutInflater inflater;
|
||||
@@ -258,28 +261,21 @@ public class KontaktAdapter extends ArrayAdapter<ContactList> {
|
||||
stream.close();
|
||||
in.close();
|
||||
|
||||
// filedaten =ret;
|
||||
|
||||
// filedaten =ret;
|
||||
|
||||
|
||||
if(minitext != null)
|
||||
if(minitext != null) {
|
||||
minitext.setText(ret[0]);
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
Log.v("Fehler 2 ",e.getMessage());
|
||||
e.printStackTrace();
|
||||
// return null;
|
||||
// return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String[] ReadLastMessage(String filename,LayoutInflater inflater){
|
||||
public String[] ReadLastMessage(String filename, LayoutInflater inflater){
|
||||
try{
|
||||
File filesDir = inflater.getContext().getFilesDir();
|
||||
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.StackView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class KontaktChatActiviti extends ListActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//erstelle für Demo ein pic einmalig
|
||||
/* ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
Bitmap a =((BitmapDrawable)getResources().getDrawable(R.drawable.bslogo)).getBitmap();
|
||||
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
|
||||
byte[] x = stream.toByteArray();
|
||||
*/
|
||||
DatabaseHandler db = new DatabaseHandler(this);
|
||||
|
||||
//Clear Database from Data
|
||||
/* db.onUpgrade(db.getReadableDatabase(),1,2);
|
||||
//Add New ContactList
|
||||
db.addContact(new ContactList("Demo","1",x));
|
||||
db.addContact(new ContactList("Peter Fritz","2"));
|
||||
db.addContact(new ContactList("mattis Schlitz","3"));
|
||||
db.addContact(new ContactList("jan Detlef","2"));
|
||||
*/
|
||||
|
||||
|
||||
List<ContactList> lc = db.getAllContacts();
|
||||
|
||||
ContactList[] Klientel = lc.toArray(new ContactList[lc.size()]);
|
||||
|
||||
setListAdapter(new KontaktAdapter(this,Klientel));
|
||||
db.close();
|
||||
}
|
||||
|
||||
//############### Menue bereiche ##########################
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main_activity_mitarbeiter, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
|
||||
if (id == R.id.action_Logout) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
//########################################################
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
//get selected items
|
||||
ContactList selectedValue = (ContactList) getListAdapter().getItem(position);
|
||||
Toast.makeText(this, selectedValue.getKontaktName(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
//
|
||||
|
||||
Bundle korb = new Bundle();
|
||||
|
||||
korb.putString("Name",selectedValue.getKontaktName());
|
||||
|
||||
Intent in = new Intent(getBaseContext(), ChatActiviti.class);
|
||||
in.putExtras(korb);
|
||||
|
||||
//gebe bild mit für den Cat
|
||||
if(selectedValue.getPicture() == null){
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.katze3);
|
||||
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
|
||||
byte[] x = stream.toByteArray();
|
||||
in.putExtra("Bild",x);
|
||||
}else
|
||||
in.putExtra("Bild",selectedValue.getPicture());
|
||||
|
||||
|
||||
|
||||
startActivity(in);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.octo.android.robospice.SpiceManager;
|
||||
import com.octo.android.robospice.UncachedSpiceService;
|
||||
import com.octo.android.robospice.persistence.exception.SpiceException;
|
||||
import com.octo.android.robospice.request.listener.RequestListener;
|
||||
|
||||
import org.ksoap2.serialization.PropertyInfo;
|
||||
import org.ksoap2.serialization.SoapPrimitive;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import entities.ChatPerson;
|
||||
import soapConnection.JsonSoapPrimitiveRequest;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class KontaktChatActivity extends ListActivity {
|
||||
|
||||
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
|
||||
private DatabaseHandler databaseHandler;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//erstelle für Demo ein pic einmalig
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
Bitmap a =((BitmapDrawable)getResources().getDrawable(R.drawable.bslogo)).getBitmap();
|
||||
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
|
||||
byte[] x = stream.toByteArray();
|
||||
|
||||
databaseHandler = new DatabaseHandler(this);
|
||||
|
||||
//Clear Database from Data
|
||||
//TODO: nicht löschen, sondern updaten
|
||||
databaseHandler.onUpgrade(databaseHandler.getReadableDatabase(),1,2);
|
||||
|
||||
ArrayList<PropertyInfo> propertyInfos = new ArrayList<>();
|
||||
propertyInfos.add(SoapConnectionManager.BuildProperty("pPersonOid", SoapConnectionManager.User.getPersonOid(), Long.class));
|
||||
|
||||
JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.GET_CONTACTS_FOR_PERSON, propertyInfos);
|
||||
spiceManager.execute(request, new JsonSoapPrimitiveRequestListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main_activity_mitarbeiter, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
|
||||
if (id == R.id.action_Logout) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
//get selected items
|
||||
ContactListItem selectedValue = (ContactListItem) getListAdapter().getItem(position);
|
||||
|
||||
Bundle korb = new Bundle();
|
||||
|
||||
korb.putString("Name", selectedValue.getKontaktName());
|
||||
korb.putInt("RecipientOid", selectedValue.get_personOid());
|
||||
Log.i("KontaktChatActivity", "EmpfängerOid: " + selectedValue.get_personOid());
|
||||
|
||||
Intent in = new Intent(getBaseContext(), ChatActivity.class);
|
||||
in.putExtras(korb);
|
||||
|
||||
//Gib Bild für den Chat mit
|
||||
if(selectedValue.getPicture() == null){
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.katze3);
|
||||
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
|
||||
byte[] x = stream.toByteArray();
|
||||
in.putExtra("Bild", x);
|
||||
}else
|
||||
in.putExtra("Bild", selectedValue.getPicture());
|
||||
|
||||
startActivity(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(){
|
||||
spiceManager.shouldStop();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
spiceManager.start(this);
|
||||
}
|
||||
|
||||
private final class JsonSoapPrimitiveRequestListener implements RequestListener<SoapPrimitive> {
|
||||
|
||||
@Override
|
||||
public void onRequestFailure(SpiceException spiceException) {
|
||||
Toast.makeText(KontaktChatActivity.this, "An error occured while loading the contact list", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(SoapPrimitive soapPrimitive) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
Type listType = new TypeToken<ArrayList<ChatPerson>>(){}.getType();
|
||||
|
||||
ArrayList<ChatPerson> result = gson.fromJson(soapPrimitive.toString(), listType);
|
||||
|
||||
for(ChatPerson cp : result) {
|
||||
databaseHandler.addContact(new ContactListItem(cp.Name, cp.Oid));
|
||||
}
|
||||
|
||||
List<ContactListItem> lc = databaseHandler.getAllContacts();
|
||||
|
||||
ContactListItem[] Klientel = lc.toArray(new ContactListItem[lc.size()]);
|
||||
|
||||
// TODO: neuen Adapter schreiben
|
||||
setListAdapter(new KontaktAdapter(KontaktChatActivity.this, Klientel));
|
||||
databaseHandler.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class LoginActiviti extends ActionBarActivity {
|
||||
//##################### Variablen ####################
|
||||
protected Button loginbutton;
|
||||
protected Button beendenbutton;
|
||||
|
||||
protected EditText kunnr;
|
||||
protected EditText user;
|
||||
protected EditText paswd;
|
||||
protected String[] MitarbeiterloginString = new String[3];
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.login);
|
||||
|
||||
setzeButtonListener();
|
||||
setzeEditText();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//########################## Action events der Jeweiligen Buttons
|
||||
public void LoginApp(){
|
||||
|
||||
//Server Überprüfung mit den werten
|
||||
|
||||
//Hier mus Serveraufruf mit rückgabe wert als string array
|
||||
|
||||
MitarbeiterloginString[0]="placeholder";
|
||||
MitarbeiterloginString[1]="placeholder";
|
||||
MitarbeiterloginString[2]="placeholder";
|
||||
|
||||
|
||||
if(kunnr.getText().toString().equals(MitarbeiterloginString[0]) && user.getText().toString().equals(MitarbeiterloginString[1]) && paswd.getText().toString().equals(MitarbeiterloginString[2])) {
|
||||
|
||||
startActivity(new Intent(getBaseContext(), MainActivityMitarbeiter.class));
|
||||
|
||||
}else if(user.getText().toString().equals("demo")){
|
||||
|
||||
startActivity(new Intent(getBaseContext(), MainActivityMitarbeiter.class));
|
||||
|
||||
}else{
|
||||
|
||||
new AlertDialog.Builder(this).setTitle("Fehler").setMessage("Benutzername oder Passwort falsch!").setNeutralButton("Schließen", null).show();
|
||||
|
||||
kunnr.setText("");
|
||||
user.setText("");
|
||||
paswd.setText("");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LogoutApp(){
|
||||
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setzeButtonListener(){
|
||||
|
||||
//################## Kalender Button ######################
|
||||
loginbutton = (Button) findViewById(R.id.Loginbutton);
|
||||
loginbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
LoginApp();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//################# Kassen Button #########################
|
||||
beendenbutton = (Button) findViewById(R.id.Beendenbutton);
|
||||
beendenbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
LogoutApp();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setzeEditText(){
|
||||
kunnr = (EditText) findViewById(R.id.KundennrText);
|
||||
|
||||
user = (EditText) findViewById(R.id.UsernameText);
|
||||
|
||||
paswd = (EditText) findViewById(R.id.PWText);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.octo.android.robospice.SpiceManager;
|
||||
import com.octo.android.robospice.UncachedSpiceService;
|
||||
import com.octo.android.robospice.persistence.exception.SpiceException;
|
||||
import com.octo.android.robospice.request.listener.RequestListener;
|
||||
|
||||
import org.ksoap2.serialization.PropertyInfo;
|
||||
import org.ksoap2.serialization.SoapPrimitive;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import soapConnection.ApplicationUser;
|
||||
import soapConnection.JsonSoapPrimitiveRequest;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
import util.SecurityUtils;
|
||||
import util.Util;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class LoginActivity extends ActionBarActivity {
|
||||
private CheckBox mRememberMeCheckBoxView;
|
||||
private EditText mChatCodeView;
|
||||
private EditText mTenantView;
|
||||
private EditText mUsernameView;
|
||||
private EditText mPasswordView;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
mChatCodeView = (EditText) findViewById(R.id.token);
|
||||
mTenantView = (EditText) findViewById(R.id.tenant);
|
||||
mUsernameView = (EditText) findViewById(R.id.username);
|
||||
mPasswordView = (EditText) findViewById(R.id.password);
|
||||
mRememberMeCheckBoxView = (CheckBox) findViewById(R.id.remember_me_checkbox);
|
||||
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
|
||||
if (id == R.id.login || id == EditorInfo.IME_NULL) {
|
||||
attemptLogin();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Button mSignInButton = (Button) findViewById(R.id.sign_in_button);
|
||||
mSignInButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
attemptLogin();
|
||||
}
|
||||
});
|
||||
|
||||
mLoginFormView = findViewById(R.id.login_form);
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
String savedToken = settings.getString(Util.PREFS_TOKEN_KEY, null);
|
||||
String savedTenant = settings.getString(Util.PREFS_TENANT_KEY, null);
|
||||
String savedUsername = settings.getString(Util.PREFS_USERNAME_KEY, null);
|
||||
String savedPassword = settings.getString(Util.PREFS_PASSWORD, null);
|
||||
|
||||
if(savedTenant != null && savedToken != null && savedUsername != null && savedPassword != null) {
|
||||
mRememberMeCheckBoxView.setChecked(true);
|
||||
|
||||
byte[] tokenByteArray = Base64.decode(savedToken, Base64.DEFAULT);
|
||||
ByteArrayInputStream tokenStream = new ByteArrayInputStream(tokenByteArray);
|
||||
|
||||
byte[] tenantByteArray = Base64.decode(savedTenant, Base64.DEFAULT);
|
||||
ByteArrayInputStream tenantStream = new ByteArrayInputStream(tenantByteArray);
|
||||
|
||||
byte[] usernameByteArray = Base64.decode(savedUsername, Base64.DEFAULT);
|
||||
ByteArrayInputStream usernameStream = new ByteArrayInputStream(usernameByteArray);
|
||||
|
||||
byte[] passwordByteArray = Base64.decode(savedPassword, Base64.DEFAULT);
|
||||
ByteArrayInputStream passwordStream = new ByteArrayInputStream(passwordByteArray);
|
||||
|
||||
try {
|
||||
mChatCodeView.setText(SecurityUtils.decrypt(tokenStream).toString());
|
||||
mTenantView.setText(SecurityUtils.decrypt(tenantStream).toString());
|
||||
mUsernameView.setText(SecurityUtils.decrypt(usernameStream).toString());
|
||||
mPasswordView.setText(SecurityUtils.decrypt(passwordStream).toString());
|
||||
} catch (IOException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
|
||||
super.onStart();
|
||||
spiceManager.start(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
|
||||
spiceManager.shouldStop();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void attemptLogin() {
|
||||
|
||||
mTenantView.setError(null);
|
||||
mChatCodeView.setError(null);
|
||||
mUsernameView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
|
||||
final String username = mUsernameView.getText().toString();
|
||||
final String password = mPasswordView.getText().toString();
|
||||
final String tenant = mTenantView.getText().toString();
|
||||
String token = mChatCodeView.getText().toString();
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
mPasswordView.setError(getString(R.string.error_invalid_input));
|
||||
focusView = mPasswordView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(username)) {
|
||||
mUsernameView.setError(getString(R.string.error_invalid_input));
|
||||
focusView = mUsernameView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(TextUtils.isEmpty(tenant)) {
|
||||
mTenantView.setError(getString(R.string.error_invalid_input));
|
||||
focusView = mTenantView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(TextUtils.isEmpty(token)) {
|
||||
mChatCodeView.setError(getString(R.string.error_invalid_input));
|
||||
focusView = mChatCodeView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
focusView.requestFocus();
|
||||
}
|
||||
else {
|
||||
showProgress(true);
|
||||
|
||||
RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
|
||||
String url = SoapCalls.TOKEN_CHECK_URL + token;
|
||||
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
if(response == null || TextUtils.isEmpty(response)) {
|
||||
showProgress(false);
|
||||
|
||||
clearSharedPreferences();
|
||||
|
||||
mPasswordView.setError(getString(R.string.error_invalid_input));
|
||||
mUsernameView.setError(getString(R.string.error_invalid_input));
|
||||
mChatCodeView.setError(getString(R.string.error_invalid_input));
|
||||
mTenantView.setError(getString(R.string.error_invalid_input));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<PropertyInfo> propertyInfos = new ArrayList<>();
|
||||
propertyInfos.add(SoapConnectionManager.BuildProperty("pTenant", tenant, String.class));
|
||||
propertyInfos.add(SoapConnectionManager.BuildProperty("pUsername", username, String.class));
|
||||
propertyInfos.add(SoapConnectionManager.BuildProperty("pPassword", password, String.class));
|
||||
|
||||
JsonSoapPrimitiveRequest request = new JsonSoapPrimitiveRequest(SoapCalls.LOGIN_CALL, propertyInfos);
|
||||
spiceManager.execute(request, new JsonSoapPrimitiveRequestListener());
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
showProgress(false);
|
||||
Log.e("Error sending request", (error == null ? "error is null" : error.getMessage()));
|
||||
}
|
||||
});
|
||||
|
||||
queue.add(stringRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public void rememberMeOnClick(View view) {
|
||||
CheckBox rememberMeCheckBox = (CheckBox) view;
|
||||
|
||||
if(!rememberMeCheckBox.isChecked()) {
|
||||
clearSharedPreferences();
|
||||
}
|
||||
}
|
||||
|
||||
private final class JsonSoapPrimitiveRequestListener implements RequestListener<SoapPrimitive> {
|
||||
|
||||
@Override
|
||||
public void onRequestFailure(SpiceException spiceException) {
|
||||
|
||||
showProgress(false);
|
||||
Log.e("Error", spiceException.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestSuccess(SoapPrimitive soapPrimitive) {
|
||||
//TODO: UserDC statt bool zurückgeben. Null bei fehlgeschlagenem Login
|
||||
|
||||
if(soapPrimitive == null) {
|
||||
showProgress(false);
|
||||
showLoginUIErrors(true, true, true, true);
|
||||
|
||||
Toast.makeText(LoginActivity.this, "Login returned null", Toast.LENGTH_SHORT).show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
//boolean loginResult = Boolean.valueOf(soapPrimitive.toString());
|
||||
//Employee loggedInUser = gson.fromJson(soapPrimitive.toString(), Employee.class);
|
||||
String abc = soapPrimitive.toString();
|
||||
|
||||
if(abc != null) {
|
||||
String[] blubb = abc.split(";");
|
||||
SoapConnectionManager.User = new ApplicationUser(blubb[1], blubb[2], Long.valueOf(blubb[0]), Long.valueOf(blubb[3]));
|
||||
|
||||
if(mRememberMeCheckBoxView.isChecked()) {
|
||||
ByteArrayOutputStream tokenOutputStream = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream tenantOutputStream = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream usernameOutputStream = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream passwordOutputStream = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
SecurityUtils.encrypt(mChatCodeView.getText().toString(), tokenOutputStream);
|
||||
SecurityUtils.encrypt(mTenantView.getText().toString(), tenantOutputStream);
|
||||
SecurityUtils.encrypt(mUsernameView.getText().toString(), usernameOutputStream);
|
||||
SecurityUtils.encrypt(mPasswordView.getText().toString(), passwordOutputStream);
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
|
||||
editor.putString(Util.PREFS_TOKEN_KEY, Base64.encodeToString(tokenOutputStream.toByteArray(), Base64.DEFAULT));
|
||||
editor.putString(Util.PREFS_TENANT_KEY, Base64.encodeToString(tenantOutputStream.toByteArray(), Base64.DEFAULT));
|
||||
editor.putString(Util.PREFS_USERNAME_KEY, Base64.encodeToString(usernameOutputStream.toByteArray(), Base64.DEFAULT));
|
||||
editor.putString(Util.PREFS_PASSWORD, Base64.encodeToString(passwordOutputStream.toByteArray(), Base64.DEFAULT));
|
||||
|
||||
editor.apply();
|
||||
|
||||
} catch (IOException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Intent mainActivityMitarbeiter = new Intent(LoginActivity.this, MainActivityMitarbeiter.class);
|
||||
LoginActivity.this.startActivity(mainActivityMitarbeiter);
|
||||
}
|
||||
else {
|
||||
showProgress(false);
|
||||
showLoginUIErrors(true, true, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoginUIErrors(boolean token, boolean tenant, boolean username, boolean password) {
|
||||
|
||||
mChatCodeView.setError(token ? getString(R.string.error_invalid_input) : null);
|
||||
|
||||
mTenantView.setError(tenant ? getString(R.string.error_invalid_input) : null);
|
||||
|
||||
mUsernameView.setError(username ? getString(R.string.error_invalid_input) : null);
|
||||
|
||||
mPasswordView.setError(password ? getString(R.string.error_invalid_input) : null);
|
||||
}
|
||||
|
||||
private void clearSharedPreferences() {
|
||||
|
||||
SharedPreferences settings = getSharedPreferences(Util.PREFS_NAME, 0);
|
||||
settings.edit().clear().commit();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
private void showProgress(final boolean show) {
|
||||
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
||||
// for very easy animations. If available, use these APIs to fade-in
|
||||
// the progress spinner.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
// The ViewPropertyAnimator APIs are not available, so simply show
|
||||
// and hide the relevant UI components.
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import android.widget.Button;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -27,6 +26,11 @@ import java.util.Calendar;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import soapConnection.DataIdentifier;
|
||||
import soapConnection.Packet;
|
||||
import soapConnection.SoapCalls;
|
||||
import soapConnection.SoapConnectionManager;
|
||||
|
||||
|
||||
public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
@@ -34,17 +38,16 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
protected Button chatbutton;
|
||||
protected Button logoutbutton;
|
||||
|
||||
|
||||
//########### Server Relevante Variablen #######################################################
|
||||
public static Socket socket;
|
||||
protected static final String dstAddress = "192.168.1.117"; //10.0.2.2"
|
||||
protected static final String dstAddress = SoapCalls.DESTINATION_ADDRESS;
|
||||
protected static final int dstPort = 5000;
|
||||
DataOutputStream st;
|
||||
public static BufferedReader in = null;
|
||||
//Name der Zum Server Gesndet wird
|
||||
DataOutputStream dataOutputStream;
|
||||
public static BufferedReader in = null;
|
||||
|
||||
//Name, der Zum Server gesendet wird
|
||||
protected String name;
|
||||
|
||||
//Name der vom Server Erhalten wird
|
||||
//Name, der vom Server erhalten wird
|
||||
//protected String recname;
|
||||
|
||||
File file;
|
||||
@@ -53,16 +56,12 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
public static Thread listen;
|
||||
|
||||
public static boolean isThreadPause = false;
|
||||
|
||||
//Für Notification
|
||||
private static boolean isOnStop = false;
|
||||
private static boolean ankommenderName = false;
|
||||
|
||||
//Testweise
|
||||
// protected Map<String,String> MapMessage = new HashMap<>();
|
||||
|
||||
String personoid;
|
||||
//##############################################################################################
|
||||
int personOid;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -71,17 +70,11 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
setzeButtonListener();
|
||||
|
||||
// Das ist der Name des Grade benutzen devices
|
||||
name= "Franz";
|
||||
name = SoapConnectionManager.User.getFullName();
|
||||
|
||||
personoid="1";
|
||||
//Erstelle für jedes SQLite DatenSatz ein File
|
||||
// CreateFile();
|
||||
personOid = SoapConnectionManager.User.getPersonOid() <= Integer.MAX_VALUE ? SoapConnectionManager.User.getPersonOid().intValue() : 0;
|
||||
|
||||
|
||||
//Starte hier die Server Connection + Daten receive und speichere daten local in den Datensatz
|
||||
StartServerConnection();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +103,6 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
public void setzeButtonListener() {
|
||||
|
||||
//################## Kalender Button ######################
|
||||
dokubutton = (Button) findViewById(R.id.Dokubutton);
|
||||
dokubutton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
@@ -125,7 +117,7 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivity(new Intent(getBaseContext(),KontaktChatActivity.class));
|
||||
|
||||
//SendAfterGetConnection();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -133,63 +125,55 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
logoutbutton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
||||
System.exit(0);
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//################ Server Gedöns Was im Hintergrund der Gesamten app laufen soll ###################
|
||||
public void StartServerConnection(){
|
||||
|
||||
Log.v("Status","Bin in start server connection");
|
||||
new Thread(new OpenConnection()).start();
|
||||
|
||||
//Starte hier die Server Connection + Daten receive und speichere daten local in den Datensatz
|
||||
|
||||
}
|
||||
//##################################################################################################
|
||||
|
||||
public class OpenConnection implements Runnable{
|
||||
public void run(){
|
||||
try {
|
||||
socket = new Socket(dstAddress,dstPort);
|
||||
// Log.v("Status: ","Verbindung wurde aufgebaut");
|
||||
socket = new Socket(dstAddress, dstPort);
|
||||
|
||||
//Prüfe und Sende die nicht Gesendeten Nachrichten
|
||||
Log.d("OpenConnection","Verbindung hergestellt");
|
||||
SendAfterGetConnection();
|
||||
|
||||
//nachricht an server senden welcher name jetz aktiv connected ist
|
||||
st = new DataOutputStream(socket.getOutputStream());
|
||||
name=name+"/1"+"?"+personoid;
|
||||
byte[] ts = name.getBytes();
|
||||
st.write(ts);
|
||||
st.flush();
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
// name = name + "/1" + "?" + personOid;
|
||||
// byte[] ts = name.getBytes();
|
||||
// dataOutputStream.write(ts);
|
||||
// dataOutputStream.flush();
|
||||
|
||||
// Starte SocketListener
|
||||
listen = new Thread(new SocketListener());
|
||||
listen.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.v("Connection: ","Konnte nicht Aufgebaut werden. Es wird erneut versucht");
|
||||
Log.e("Connection: ","Konnte nicht aufgebaut werden. Es wird erneut versucht. Nachricht: " + e.getMessage());
|
||||
socket = null;
|
||||
try {
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.v("Status", "Starte jetzt den Neu versuch");
|
||||
Log.i("Status", "Starte jetzt den Neu versuch");
|
||||
StartServerConnection();
|
||||
}
|
||||
}, 120000); //----> Versuche beim Scheitern nach 2 Minuten eine Neue Verbindung aufzubauen
|
||||
}catch(Exception s){
|
||||
Log.v("Fehler",s.getMessage());
|
||||
Log.e("Fehler", s.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SocketListener implements Runnable {
|
||||
|
||||
String str;
|
||||
@@ -197,88 +181,73 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
if (socket != null) {
|
||||
if (socket.isConnected()) { //----------> isThreadPausabfrage dass könnte das problem mit dem Socketlistener vorort beheben
|
||||
if(!isThreadPause){
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
Log.v("Connection Steht ", "Message Erhalten");
|
||||
String s = in.readLine();
|
||||
if (socket != null) {
|
||||
if (socket.isConnected()) { //----------> isThreadPausabfrage das könnte das Problem mit dem SocketListener vorort beheben
|
||||
|
||||
String[] splitt = s.split(":");
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
Log.v("Connection Steht ", "Message Erhalten");
|
||||
String s = in.readLine();
|
||||
|
||||
str = s;
|
||||
String[] splitt = s.split(":");
|
||||
|
||||
if (s == null)
|
||||
break;
|
||||
str = s;
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
String formattedDate = df.format(c.getTime());
|
||||
if (s == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
boolean determind = false;
|
||||
Calendar c = Calendar.getInstance();
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
|
||||
String formattedDate = df.format(c.getTime());
|
||||
|
||||
Log.v("MESSAGE",splitt[0]);
|
||||
CreateFile(splitt[0]);
|
||||
boolean determind = false;
|
||||
|
||||
//##############----------------- Abfrage im welche view man sich befindet
|
||||
Log.v("MESSAGE", "Komme ich den in den Save Bereich Hinein");
|
||||
Log.v("MESSAGE",splitt[0]);
|
||||
CreateFile(splitt[0]);
|
||||
|
||||
WriteMessagesfromStorage(splitt[1] + "/" + determind + "%" + formattedDate + "\n");
|
||||
Log.v("MESSAGE", "Komme ich in den Save-Bereich hinein");
|
||||
|
||||
SetNotifi(splitt[0], splitt[1]);
|
||||
// adapter.notifyDataSetChanged();
|
||||
//#############------------------
|
||||
WriteMessagesfromStorage(splitt[1] + "/" + determind + "%" + formattedDate + "\n");
|
||||
|
||||
SetNotify(splitt[0], splitt[1]);
|
||||
|
||||
/* Shared preferenz abfragen wenn ja dann -->*
|
||||
if(){
|
||||
SharedPreferences sp = getSharedPreferences("OURINFO", MODE_PRIVATE);
|
||||
Editor ed = sp.edit();
|
||||
ed.putBoolean("active", true);
|
||||
ed.commit();
|
||||
|
||||
-->*
|
||||
chatMessage = new ChatMessageFormat(str, determind, formattedDate); //<----------
|
||||
chatMessages.add(chatMessage);
|
||||
adapter.notifyDataSetChanged(); //<----------
|
||||
|
||||
}*/
|
||||
}
|
||||
} else {
|
||||
if (in != null)
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
Log.v("Status ","Verbindung zum Server wurde seitens dem Server getrennt ");
|
||||
} catch(Exception e) {
|
||||
Log.v("Status ","Verbindung zum Server wurde serverseitig getrennt ");
|
||||
// Log.e(getClass().getName(),e.getMessage());
|
||||
in = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//##################### Close Connection #######################
|
||||
public class ConnectionClose implements Runnable{
|
||||
public void run(){
|
||||
try {
|
||||
if (st != null) {
|
||||
st.flush();
|
||||
st.close();
|
||||
if (dataOutputStream != null) {
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
}
|
||||
if (socket != null)
|
||||
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
|
||||
if(in != null)
|
||||
if(in != null) {
|
||||
in = null;
|
||||
}
|
||||
|
||||
Log.v("Status","Socket succesfull closed");
|
||||
Log.v("Status","Socket succesfully closed");
|
||||
}catch(IOException se){
|
||||
Log.v("Fehler Aufgetreten",se.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
//##############################################################
|
||||
|
||||
public void CreateFile(String filename){
|
||||
|
||||
@@ -299,47 +268,63 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
} //---> Zu sortieren der message zum Jeweiligen kontakt
|
||||
|
||||
public void SendAfterGetConnection(){
|
||||
CreateCustomFileForUnSendMessage();
|
||||
|
||||
if(Unsendfile.canRead() && socket.isConnected()){
|
||||
try{
|
||||
Log.v("Info","Eine ungesendete Nachricht wurde gefunden");
|
||||
if(socket.isConnected()) {
|
||||
try {
|
||||
Packet p = new Packet();
|
||||
p.ChatName = SoapConnectionManager.User.getFullName();
|
||||
p.ChatDataIdentifier = DataIdentifier.LOGIN;
|
||||
p.SenderPersonOid = SoapConnectionManager.User.getPersonOid().intValue();
|
||||
//p.RecipientPersonOid = 3;
|
||||
p.ChatMessage = "Chromosomenfasching";
|
||||
|
||||
FileInputStream stream = new FileInputStream(Unsendfile);
|
||||
InputStreamReader in = new InputStreamReader(stream);
|
||||
BufferedReader readLn = new BufferedReader(in);
|
||||
|
||||
String line = readLn.readLine();
|
||||
String allLines="";
|
||||
|
||||
while (line != null) {
|
||||
allLines += line;
|
||||
|
||||
Log.v("Info","Eine ungesendete NAchricht 4");
|
||||
String[] splitt = line.split("/");
|
||||
|
||||
if(splitt.length >1 ) {
|
||||
String[] ArtDate = splitt[1].split("%");
|
||||
|
||||
final String message = splitt[0];
|
||||
final boolean art = Boolean.valueOf(ArtDate[0]);
|
||||
final String datetime = ArtDate[1];
|
||||
|
||||
Log.v("Info","Eine ungesendete NAchricht 5");
|
||||
//für jede Gelesene Line Sende Nachricht
|
||||
new Thread(new SendUnsendMS(message)).start();
|
||||
Log.v("Info","Eine ungesendete NAchricht 6");
|
||||
}
|
||||
line = readLn.readLine();
|
||||
}
|
||||
stream.close();
|
||||
in.close();
|
||||
Unsendfile.delete();
|
||||
}catch(Exception fe){
|
||||
Log.v("Status","Ein problem ist im BEreich Unsend Ms Aufgetreten");
|
||||
new Thread(new TestMessageSender(p.GetDataStream())).start();
|
||||
} catch(Exception e) {
|
||||
Log.e("SendAfterGetConnection", "Fehler beim Senden einer Nachricht an den Server: " + e.getMessage());
|
||||
}
|
||||
//recreate();
|
||||
}
|
||||
|
||||
// CreateCustomFileForUnSendMessage();
|
||||
//
|
||||
// if(Unsendfile.canRead() && socket.isConnected()){
|
||||
// try{
|
||||
// Log.v("Info","Eine ungesendete NAchricht wurde gefunden");
|
||||
//
|
||||
// FileInputStream stream = new FileInputStream(Unsendfile);
|
||||
// InputStreamReader in = new InputStreamReader(stream);
|
||||
// BufferedReader readLn = new BufferedReader(in);
|
||||
//
|
||||
// String line = readLn.readLine();
|
||||
// String allLines="";
|
||||
//
|
||||
// while (line != null) {
|
||||
// allLines += line;
|
||||
//
|
||||
// Log.v("Info","Eine ungesendete NAchricht 4");
|
||||
// String[] splitt = line.split("/");
|
||||
//
|
||||
// if(splitt.length >1 ) {
|
||||
// String[] ArtDate = splitt[1].split("%");
|
||||
//
|
||||
// final String message = splitt[0];
|
||||
// final boolean art = Boolean.valueOf(ArtDate[0]);
|
||||
// final String datetime = ArtDate[1];
|
||||
//
|
||||
// Log.v("Info","Eine ungesendete NAchricht 5");
|
||||
// //für jede Gelesene Line Sende Nachricht
|
||||
// new Thread(new SendUnsentMessages(message)).start();
|
||||
// Log.v("Info","Eine ungesendete NAchricht 6");
|
||||
// }
|
||||
// line = readLn.readLine();
|
||||
// }
|
||||
// stream.close();
|
||||
// in.close();
|
||||
// Unsendfile.delete();
|
||||
// }catch(Exception fe){
|
||||
// Log.v("Status","Ein problem ist im BEreich Unsend Ms Aufgetreten");
|
||||
// }
|
||||
// //recreate();
|
||||
// }
|
||||
}
|
||||
|
||||
public void CreateCustomFileForUnSendMessage(){
|
||||
@@ -357,9 +342,36 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public class SendUnsendMS implements Runnable{
|
||||
public class TestMessageSender implements Runnable {
|
||||
|
||||
byte[] packetToSend;
|
||||
|
||||
public TestMessageSender(byte[] packet2Send) {
|
||||
packetToSend = packet2Send;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if(socket != null && dataOutputStream != null) {
|
||||
|
||||
Log.d("TestMessageSender", "Sende Packet... (" + packetToSend.length + ")");
|
||||
|
||||
dataOutputStream.write(packetToSend);
|
||||
dataOutputStream.flush();
|
||||
}
|
||||
else {
|
||||
Log.d("TestMessageSender", "Socket und/oder Stream ist null");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.e("TestMessageSender", "Fehler beim Senden der TestMessage " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SendUnsentMessages implements Runnable{
|
||||
String al;
|
||||
SendUnsendMS(String unMS){
|
||||
SendUnsentMessages(String unMS){
|
||||
this.al = unMS;
|
||||
}
|
||||
public void run() {
|
||||
@@ -367,11 +379,11 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
byte[] ts = al.getBytes();
|
||||
try {
|
||||
if (socket != null && st != null) {
|
||||
if (socket != null && dataOutputStream != null) {
|
||||
|
||||
//try catch bei catch SaveAfterLoseConnection();
|
||||
st.write(ts);
|
||||
st.flush();
|
||||
dataOutputStream.write(ts);
|
||||
dataOutputStream.flush();
|
||||
}
|
||||
}catch(Exception xs){
|
||||
}
|
||||
@@ -397,7 +409,7 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
}
|
||||
|
||||
//setze Notification
|
||||
public void SetNotifi(String Username,String message){
|
||||
public void SetNotify(String Username, String message){
|
||||
|
||||
//Convertiert in Pic Resource in ein Bitmap
|
||||
//BitmapFactory.decodeResource(getResources(), R.drawable.bslogo)
|
||||
@@ -436,14 +448,14 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
mNotifyMgr.notify(001, mBuilder.build());
|
||||
}
|
||||
|
||||
//###### Activiti abfragen ##################
|
||||
@Override
|
||||
public void onResume() {
|
||||
// Log.v("Stuss","Hier nochmals on creat aufrufen");
|
||||
isOnStop = false;
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(){
|
||||
// Thread t = new Thread(new ConnectionClose());
|
||||
// t.start();
|
||||
@@ -458,5 +470,4 @@ public class MainActivityMitarbeiter extends Activity {
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,16 +2,12 @@ package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -61,9 +57,9 @@ public class MessageAdapter extends ArrayAdapter<ChatMessageFormat> {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
Log.v("Status","Bin ich hier ?? ");
|
||||
} else {*/
|
||||
convertView = inflater.inflate(layoutResource, parent, false);
|
||||
holder = new ViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
convertView = inflater.inflate(layoutResource, parent, false);
|
||||
holder = new ViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
//}
|
||||
|
||||
//set message content
|
||||
@@ -113,6 +109,4 @@ public class MessageAdapter extends ArrayAdapter<ChatMessageFormat> {
|
||||
send_tick = (TextView)v.findViewById(R.id.txt_msg_tick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,52 +1,45 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class SplashScreenActiviti extends Activity {
|
||||
|
||||
|
||||
private static final int SPLASH_DURATION = 4000;
|
||||
private Handler startMain;
|
||||
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.splashscreen);
|
||||
|
||||
Thread logoTimer = new Thread() {
|
||||
public void run(){
|
||||
try{
|
||||
int logoTimer = 0;
|
||||
while(logoTimer < 2125){
|
||||
sleep(75);
|
||||
logoTimer = logoTimer +100;
|
||||
};
|
||||
startActivity(new Intent(getBaseContext(),LoginActiviti.class));
|
||||
}
|
||||
|
||||
catch (InterruptedException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
finally{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
logoTimer.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class SplashScreenActivity extends Activity {
|
||||
|
||||
private static final int SPLASH_DURATION = 4000;
|
||||
private Handler startMain;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.splashscreen);
|
||||
|
||||
Thread logoTimer = new Thread() {
|
||||
public void run(){
|
||||
try{
|
||||
int logoTimer = 0;
|
||||
while(logoTimer < 2125){
|
||||
sleep(75);
|
||||
logoTimer = logoTimer + 100;
|
||||
}
|
||||
|
||||
startActivity(new Intent(getBaseContext(), LoginActivity.class));
|
||||
}
|
||||
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
finally{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
logoTimer.start();
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class WebdokuActiviti extends ActionBarActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.webdoku);
|
||||
|
||||
// Uri uri = Uri.parse("http://www.google.com");
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
// startActivity(intent);
|
||||
|
||||
|
||||
String URL = "http://192.168.1.115/BewoPlanerMobil/login/demo";
|
||||
WebView view = (WebView) this.findViewById(R.id.webView1);
|
||||
|
||||
view.getSettings().setJavaScriptEnabled(true);
|
||||
view.loadUrl(URL);
|
||||
view.setWebViewClient(new WebViewClient());
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
view.setWebViewClient(new WebViewClient(){
|
||||
|
||||
public void onPageFinished(WebView view,String url){
|
||||
String username = "franz";
|
||||
String passwort = "walter";
|
||||
|
||||
view.loadUrl("javascript:document.getElementbyId('tb_login').value='"+username+"; " +
|
||||
"document.getElementsbyName('tb_password').value='"+passwort+";");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package beyondsoft.bewomitarbeiterapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import soapConnection.SoapCalls;
|
||||
|
||||
/**
|
||||
* Created by bib on 02.05.2016.
|
||||
*/
|
||||
public class WebdokuActivity extends ActionBarActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.webdoku);
|
||||
|
||||
WebView view = (WebView) this.findViewById(R.id.webView1);
|
||||
|
||||
view.getSettings().setJavaScriptEnabled(true);
|
||||
|
||||
//TODO: Url anhand des überprüften Tokens bestimmen (Welcher Server)
|
||||
view.loadUrl(SoapCalls.WEB_DOKU_URL);
|
||||
view.setWebViewClient(new WebViewClient());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package entities;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class ChatPerson {
|
||||
public int Oid;
|
||||
public String Name;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package soapConnection;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class ApplicationUser {
|
||||
private String fullName;
|
||||
private String username;
|
||||
private Long employeeOid;
|
||||
private Long personOid;
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Long getEmployeeOid() {
|
||||
return employeeOid;
|
||||
}
|
||||
|
||||
public void setEmployeeOid(Long employeeOid) {
|
||||
this.employeeOid = employeeOid;
|
||||
}
|
||||
|
||||
public Long getPersonOid() {
|
||||
return personOid;
|
||||
}
|
||||
|
||||
public void setPersonOid(Long personOid) {
|
||||
this.personOid = personOid;
|
||||
}
|
||||
|
||||
public ApplicationUser(String fullName, String username, Long employeeOid, Long personOid) {
|
||||
this.fullName = fullName;
|
||||
this.username = username;
|
||||
this.employeeOid = employeeOid;
|
||||
this.personOid = personOid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package soapConnection;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public enum DataIdentifier {
|
||||
MESSAGE(0),
|
||||
LOGIN(1),
|
||||
LOGOUT(2),
|
||||
NULL(3);
|
||||
|
||||
private final int value;
|
||||
DataIdentifier(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package soapConnection;
|
||||
|
||||
import com.octo.android.robospice.request.SpiceRequest;
|
||||
|
||||
import org.ksoap2.serialization.PropertyInfo;
|
||||
import org.ksoap2.serialization.SoapPrimitive;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class JsonSoapPrimitiveRequest extends SpiceRequest<SoapPrimitive> {
|
||||
private String soapOperation;
|
||||
private ArrayList<PropertyInfo> soapPropertyInfos;
|
||||
|
||||
public JsonSoapPrimitiveRequest(String operation, ArrayList<PropertyInfo> propertyInfos) {
|
||||
super(SoapPrimitive.class);
|
||||
this.soapOperation = operation;
|
||||
this.soapPropertyInfos = propertyInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoapPrimitive loadDataFromNetwork() throws Exception {
|
||||
return SoapConnectionManager.MakeCall(soapOperation, soapPropertyInfos);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package soapConnection;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class Packet {
|
||||
public DataIdentifier ChatDataIdentifier;
|
||||
public String ChatName;
|
||||
public int SenderPersonOid;
|
||||
public int RecipientPersonOid;
|
||||
public String ChatMessage;
|
||||
|
||||
public Packet() {
|
||||
ChatDataIdentifier = DataIdentifier.NULL;
|
||||
ChatMessage = null;
|
||||
ChatName = null;
|
||||
SenderPersonOid = 0;
|
||||
RecipientPersonOid = 0;
|
||||
}
|
||||
|
||||
|
||||
public Packet(byte[] dataStream) {
|
||||
ChatDataIdentifier = DataIdentifier.values()[ByteBuffer.allocate(4).getInt()];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public byte[] GetDataStream() {
|
||||
|
||||
String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length() + ";";
|
||||
|
||||
dataStreamAsString += ChatName + ChatMessage;
|
||||
|
||||
byte[] blaaah = new byte[1024];
|
||||
|
||||
try {
|
||||
blaaah = dataStreamAsString.getBytes("UTF8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e("Packet.GetDataStream", e.getMessage());
|
||||
}
|
||||
|
||||
return blaaah;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package soapConnection;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class SoapCalls {
|
||||
public static String GET_SERVER_ADDRESS_BY_TOKEN_CALL = "GetServerAddressByToken";
|
||||
public static String LOGIN_CALL = "Login";
|
||||
public static String GET_CONTACTS_FOR_PERSON = "GetContactsForPerson";
|
||||
|
||||
public static String DESTINATION_ADDRESS = "192.168.1.103";
|
||||
|
||||
public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token=";
|
||||
|
||||
public static String WEB_DOKU_URL = "http://192.168.1.103/BewoPlanerMobil/login/demo";
|
||||
|
||||
public static String WSDL_TARGET_NAME = "bliblablubb.org/";
|
||||
public static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package soapConnection;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.PropertyInfo;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapPrimitive;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class SoapConnectionManager {
|
||||
public static ApplicationUser User;
|
||||
|
||||
private static final String LOGTAG = "SoapConnectionManager";
|
||||
|
||||
private static final HttpTransportSE androidHttpTransport = new HttpTransportSE(SoapCalls.SOAP_ADDRESS);
|
||||
|
||||
public static SoapPrimitive MakeCall(String operation, ArrayList<PropertyInfo> propertyInfos) {
|
||||
|
||||
try {
|
||||
SoapObject request = new SoapObject(SoapCalls.WSDL_TARGET_NAME, operation);
|
||||
|
||||
if(propertyInfos != null) {
|
||||
for (PropertyInfo info : propertyInfos) {
|
||||
request.addProperty(info);
|
||||
}
|
||||
}
|
||||
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport.call(SoapCalls.WSDL_TARGET_NAME + operation, envelope);
|
||||
|
||||
return (SoapPrimitive) envelope.getResponse();
|
||||
}
|
||||
catch(IOException |XmlPullParserException exception) {
|
||||
Log.e(LOGTAG, exception.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PropertyInfo BuildProperty(String name, Object value, Class type) {
|
||||
|
||||
PropertyInfo propertyInfo = new PropertyInfo();
|
||||
|
||||
propertyInfo.setName(name);
|
||||
propertyInfo.setValue(value);
|
||||
propertyInfo.setType(type);
|
||||
|
||||
return propertyInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 06.07.2016.
|
||||
*/
|
||||
public class ArrayHandle {
|
||||
public static Object[] reverse(Object[] array) {
|
||||
List<Object> list = Arrays.asList(array);
|
||||
Collections.reverse(list);
|
||||
|
||||
return list.toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.CipherInputStream;
|
||||
import javax.crypto.CipherOutputStream;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SealedObject;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
private static final byte[] iV16 = { (byte)35, (byte)138, (byte)177, (byte)253, (byte)227, (byte)63, (byte)2, (byte)27, (byte)9, (byte)17, (byte)192, (byte)230, (byte)1, (byte)24, (byte)165, (byte)99 };
|
||||
|
||||
public static final byte[] key = { (byte)174, (byte)130, (byte)219, (byte)185, (byte)185, (byte)221, (byte)96, (byte)50, (byte)37, (byte)212, (byte)81, (byte)121, (byte)71, (byte)206, (byte)130, (byte)153};
|
||||
|
||||
private static final IvParameterSpec ivSpec16 = new IvParameterSpec(iV16);
|
||||
private static final String transformation = "AES/CBC/PKCS5Padding";
|
||||
|
||||
public static void encrypt(Serializable object, OutputStream ostream) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
|
||||
try {
|
||||
SecretKeySpec sks = new SecretKeySpec(key, transformation);
|
||||
|
||||
Cipher cipher = Cipher.getInstance(transformation);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, sks, ivSpec16);
|
||||
SealedObject sealedObject = new SealedObject(object, cipher);
|
||||
|
||||
CipherOutputStream cos = new CipherOutputStream(ostream, cipher);
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(cos);
|
||||
outputStream.writeObject(sealedObject);
|
||||
outputStream.close();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
Log.e("Encryption error", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static Object decrypt(InputStream istream) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
|
||||
SecretKeySpec sks = new SecretKeySpec(key, transformation);
|
||||
Cipher cipher = Cipher.getInstance(transformation);
|
||||
cipher.init(Cipher.DECRYPT_MODE, sks, ivSpec16);
|
||||
|
||||
CipherInputStream cipherInputStream = new CipherInputStream(istream, cipher);
|
||||
ObjectInputStream inputStream = new ObjectInputStream(cipherInputStream);
|
||||
SealedObject sealedObject;
|
||||
try {
|
||||
sealedObject = (SealedObject) inputStream.readObject();
|
||||
return sealedObject.getObject(cipher);
|
||||
} catch (ClassNotFoundException | IllegalBlockSizeException | BadPaddingException e) {
|
||||
Log.e("Encryption error", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Android/BewoMitarbeiterApp/app/src/main/java/util/Util.java
Normal file
15
Android/BewoMitarbeiterApp/app/src/main/java/util/Util.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package util;
|
||||
|
||||
/**
|
||||
* Created by JettenM on 05.07.2016.
|
||||
*/
|
||||
public class Util {
|
||||
public static final String PREFS_NAME = "BeWoMitarbeiterPrefsFile";
|
||||
|
||||
public static final String PREFS_SERVERADDRESS_KEY = "serverAddress";
|
||||
|
||||
public static final String PREFS_TOKEN_KEY = "serverAddress";
|
||||
public static final String PREFS_TENANT_KEY = "tenant";
|
||||
public static final String PREFS_USERNAME_KEY = "username";
|
||||
public static final String PREFS_PASSWORD = "password";
|
||||
}
|
||||
@@ -15,4 +15,4 @@ allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user