App: neue Chat-Bubbles, neue Avatare, neuer ImageConverter zum rundmachen der Avatare. Neuer Style

This commit is contained in:
staccatomamba
2016-10-07 12:40:16 +02:00
parent bbd26cca9c
commit c504e994cb
40 changed files with 383 additions and 292 deletions

View File

@@ -84,7 +84,6 @@
<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/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" />

View File

@@ -16,7 +16,8 @@
android:name=".SplashScreenActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:configChanges="orientation"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

View File

@@ -51,7 +51,19 @@ public class DatabaseHandler extends SQLiteOpenHelper {
private static final String KEY_TEAM_MEMBER_OIDS = "teammemberoids";
private static final String KEY_TEAM_MEMBER_NAMES = "teammembernames";
private static final String KEY_VERSION = "version";
private static final String KEY_IS_EMPLOYEE = "isemployee";
private static final String[] CONTACTS_COLUMNS = new String[] {
KEY_ID,
KEY_KONTAKT_NAME,
KEY_PERSONOID,
KEY_PICTURE_BLOB,
KEY_IS_TEAM,
KEY_TEAM_MEMBER_OIDS,
KEY_TEAM_MEMBER_NAMES,
KEY_VERSION,
KEY_IS_EMPLOYEE
};
// ChatMessage-Tabelle
private static final String KEY_ID_CHATMESSAGE = "id";
@@ -100,7 +112,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
KEY_IS_TEAM + " INTEGER, " +
KEY_TEAM_MEMBER_NAMES + " TEXT, " +
KEY_TEAM_MEMBER_OIDS + " TEXT, " +
KEY_VERSION + " INTEGER)";
KEY_VERSION + " INTEGER, " +
KEY_IS_EMPLOYEE + " INTEGER)";
db.execSQL(CREATE_CONTACTS_TABLE);
@@ -294,6 +307,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
values.put(KEY_TEAM_MEMBER_NAMES, contact.teamMemberNames);
values.put(KEY_TEAM_MEMBER_OIDS, contact.teamMemberOids);
values.put(KEY_VERSION, contact.getVersion());
values.put(KEY_IS_EMPLOYEE, contact.getIsEmployee());
writableDatabase.insertOrThrow(TABLE_CONTACTS, null, values);
}
@@ -422,15 +436,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
SQLiteDatabase readableDatabase = this.getReadableDatabase();
Cursor cursor = readableDatabase.query(TABLE_CONTACTS,
new String[]{
KEY_ID,
KEY_KONTAKT_NAME,
KEY_PERSONOID,
KEY_PICTURE_BLOB,
KEY_IS_TEAM,
KEY_TEAM_MEMBER_NAMES,
KEY_TEAM_MEMBER_OIDS,
KEY_VERSION},
CONTACTS_COLUMNS,
KEY_ID + "=?",
new String[]{String.valueOf(id)},
null,null,null,null);
@@ -446,8 +452,9 @@ public class DatabaseHandler extends SQLiteOpenHelper {
String teamMemberOids = cursor.getString(5);
String teamMemberNames = cursor.getString(6);
int contactVersion = cursor.getInt(7);
boolean isEmployee = cursor.getInt(8) == 1;
ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactPicture, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion);
ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactPicture, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion, isEmployee);
cursor.close();
@@ -476,6 +483,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
contact.teamMemberNames = cursor.getString(5);
contact.teamMemberOids = cursor.getString(6);
contact.setVersion(cursor.getInt(7));
contact.setIsEmployee(cursor.getInt(8) == 1);
contactList.add(contact);
} while (cursor.moveToNext());
@@ -529,6 +537,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
values.put(KEY_TEAM_MEMBER_NAMES, contact.teamMemberNames);
values.put(KEY_TEAM_MEMBER_OIDS, contact.teamMemberOids);
values.put(KEY_VERSION, contact.getVersion());
values.put(KEY_IS_EMPLOYEE, contact.getIsEmployee());
return writableDatabase.update(TABLE_CONTACTS, values, KEY_ID + " = ?", new String[] { String.valueOf(contact.getId()) });
}
@@ -574,15 +583,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
SQLiteDatabase readableDatabase = this.getReadableDatabase();
Cursor cursor = readableDatabase.query(TABLE_CONTACTS,
new String[]{
KEY_ID,
KEY_KONTAKT_NAME,
KEY_PERSONOID,
KEY_PICTURE_BLOB,
KEY_IS_TEAM,
KEY_TEAM_MEMBER_NAMES,
KEY_TEAM_MEMBER_OIDS,
KEY_VERSION},
CONTACTS_COLUMNS,
KEY_PERSONOID + "=? AND " + KEY_IS_TEAM + "=?",
new String[]{String.valueOf(personOid), String.valueOf((isTeam ? 1 : 0))},
null,null,null,null);
@@ -597,8 +598,9 @@ public class DatabaseHandler extends SQLiteOpenHelper {
String teamMemberOids = cursor.getString(5);
String teamMemberNames = cursor.getString(6);
int contactVersion = cursor.getInt(7);
boolean isEmployee = cursor.getInt(8) == 1;
ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactPicture, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion);
ContactListItem contact = new ContactListItem(contactId, contactName, contactPersonOid, contactPicture, contactIsTeam, teamMemberOids, teamMemberNames, contactVersion, isEmployee);
cursor.close();

View File

@@ -80,6 +80,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
protected String teamMemberOids;
protected String teamMemberNames;
protected boolean isTeam;
protected boolean isEmployee;
private SpiceManager spiceManager = new SpiceManager(UncachedSpiceService.class);
@@ -139,11 +140,12 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
isTeam = zielkorb.getBoolean("IsTeam");
teamMemberOids = zielkorb.getString("TeamMemberOids");
teamMemberNames = zielkorb.getString("TeamMemberNames");
isEmployee = zielkorb.getBoolean("IsEmployee");
ReloadChatView(recipientName, recipientPersonOid, bildArray, isTeam, teamMemberOids, teamMemberNames);
ReloadChatView(recipientName, recipientPersonOid, bildArray, isTeam, teamMemberOids, teamMemberNames, isEmployee);
}
private void ReloadChatView(String contactName, int recipientOid, byte[] contactImage, boolean pIsTeam, String pTeamMemberOids, String pTeamMemberNames) {
private void ReloadChatView(String contactName, int recipientOid, byte[] contactImage, boolean pIsTeam, String pTeamMemberOids, String pTeamMemberNames, boolean pIsEmployee) {
chatMessages = new ArrayList<>();
recipientPersonOid = recipientOid;
@@ -151,6 +153,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
isTeam = pIsTeam;
teamMemberOids = pTeamMemberOids;
teamMemberNames = pTeamMemberNames;
isEmployee = pIsEmployee;
ImageView status = (ImageView) mCustomView.findViewById(R.id.status);
TextView titlename = (TextView) mCustomView.findViewById(R.id.PersonalName);
@@ -189,7 +192,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
adapter.sort(DATE_COMPARATOR);
adapter.notifyDataSetChanged();
} else {
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, getApplicationContext());
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, chatPacket.IsEmployee, getApplicationContext());
}
}
});
@@ -228,7 +231,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
adapter.sort(DATE_COMPARATOR);
adapter.notifyDataSetChanged();
} else {
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid, true, teamMemberOids, teamMemberNames, getApplicationContext());
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid, true, teamMemberOids, teamMemberNames, chatPacket.IsEmployee, getApplicationContext());
}
}
});
@@ -311,7 +314,7 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
NotificationManager mNotifyMgr = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
ChatEntity entity = new ChatEntity(recipientOid, isTeam);
ChatEntity entity = new ChatEntity(recipientOid, isTeam, isEmployee);
if(SocketManager.notificationEntities.get(entity) != null) {
mNotifyMgr.cancel(SocketManager.notificationEntities.get(entity).getNotificationId());
@@ -386,12 +389,13 @@ public class ChatActivity extends ActionBarActivity implements ConnectivityRecei
boolean blahIsTeam = zielkorb.getBoolean("IsTeam");
String tMemberOids = zielkorb.getString("TeamMemberOids");
String tMemberNames = zielkorb.getString("TeamMemberNames");
boolean blahIsEmployee = zielkorb.getBoolean("IsEmployee");
byte[] imageAsByteArray = databaseHandler.getUserImage(rpoid);
Log.i("ON_NEW_INTENT", "Erzeuge neuen Intent");
ReloadChatView(rn, rpoid, imageAsByteArray, blahIsTeam, tMemberOids, tMemberNames);
ReloadChatView(rn, rpoid, imageAsByteArray, blahIsTeam, tMemberOids, tMemberNames, blahIsEmployee);
}
private Bitmap GetCircleBitmap(Bitmap bitmap) {

View File

@@ -11,9 +11,10 @@ public class ContactListItem {
private byte[] mPicture;
private int mPersonOid;
private int mVersion;
private boolean mIsEmployee;
public boolean isTeam;
public boolean isOnline;
boolean isOnline;
public String teamMemberOids;
public String teamMemberNames;
@@ -22,25 +23,27 @@ public class ContactListItem {
public ContactListItem(){}
public ContactListItem(int id, String kontaktname, int personOid, byte[] picture, boolean isTeam, String teamMemberOids, String teamMemberNames, int version){
this.mId = id;
this.mChatName = kontaktname;
this.mPersonOid = personOid;
this.mPicture = picture;
this.isTeam = isTeam;
public ContactListItem(int id, String kontaktname, int personOid, byte[] picture, boolean isTeam, String teamMemberOids, String teamMemberNames, int version, boolean isEmployee){
this.mId = id;
this.mChatName = kontaktname;
this.mPersonOid = personOid;
this.mPicture = picture;
this.isTeam = isTeam;
this.teamMemberNames = teamMemberNames;
this.teamMemberOids = teamMemberOids;
this.mVersion = version;
this.teamMemberOids = teamMemberOids;
this.mVersion = version;
this.mIsEmployee = isEmployee;
}
public ContactListItem(String kontaktname, int personOid, boolean isTeam, String teamMemberOids, String teamMemberNames, int version){
this.mChatName = kontaktname;
this.mPersonOid = personOid;
this.mPicture = null;
this.isTeam = isTeam;
ContactListItem(String kontaktname, int personOid, boolean isTeam, String teamMemberOids, String teamMemberNames, int version, boolean isEmployee){
this.mChatName = kontaktname;
this.mPersonOid = personOid;
this.mPicture = null;
this.isTeam = isTeam;
this.teamMemberNames = teamMemberNames;
this.teamMemberOids = teamMemberOids;
this.mVersion = version;
this.teamMemberOids = teamMemberOids;
this.mVersion = version;
this.mIsEmployee = isEmployee;
}
public int getId(){
@@ -90,22 +93,30 @@ public class ContactListItem {
this.mVersion = mVersion;
}
public String getMessagePreview() {
String getMessagePreview() {
return messagePreview;
}
public void setMessagePreview(String message) {
void setMessagePreview(String message) {
messagePreview = message;
}
public boolean getIsNewMessage2Preview() {
boolean getIsNewMessage2Preview() {
return isNewMessage2Preview;
}
public void setIsNewMessage2Preview(boolean isNewMessage2Preview) {
void setIsNewMessage2Preview(boolean isNewMessage2Preview) {
this.isNewMessage2Preview = isNewMessage2Preview;
}
public boolean getIsEmployee() {
return mIsEmployee;
}
public void setIsEmployee(boolean newValue) {
mIsEmployee = newValue;
}
@Override
public String toString() {
String result = "";
@@ -120,11 +131,12 @@ public class ContactListItem {
}
result += "\nVersion: " + mVersion;
result += "\nIsEmployee: " + mIsEmployee;
return result;
}
public Boolean compareToChatPerson(ChatPerson chatPerson) {
return mPersonOid == chatPerson.Oid && isTeam == chatPerson.IsTeam;
return mPersonOid == chatPerson.Oid && isTeam == chatPerson.IsTeam && mIsEmployee == chatPerson.IsEmployee;
}
}

View File

@@ -11,6 +11,8 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -20,6 +22,8 @@ import android.widget.TextView;
import java.util.ArrayList;
import util.ImageConverter;
/**
* Created by bib on 03.05.2016.
*/
@@ -28,14 +32,8 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
private final Context context;
final ArrayList<ContactListItem> values;
private Bitmap bitmaping;
private Bitmap bitmaping;
private ImageView imageView;
private TextView messagePreview;
private TextView minitext;
public void setMinitext(TextView minitext) {
this.minitext = minitext;
}
KontaktAdapter(Context context, ArrayList<ContactListItem> values) {
super(context, R.layout.kontakt_list_chat, values);
@@ -43,16 +41,17 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
this.values = values;
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.contact_listview_item, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
minitext = (TextView) rowView.findViewById(R.id.subtitle);
messagePreview = (TextView) rowView.findViewById(R.id.messagePreview);
ImageView onlinestats = (ImageView) rowView.findViewById(R.id.status);
imageView = (ImageView) rowView.findViewById(R.id.logo);
View rowView = inflater.inflate(R.layout.contact_listview_item, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
TextView minitext = (TextView) rowView.findViewById(R.id.subtitle);
TextView messagePreview = (TextView) rowView.findViewById(R.id.messagePreview);
ImageView onlinestats = (ImageView) rowView.findViewById(R.id.status);
imageView = (ImageView) rowView.findViewById(R.id.logo);
textView.setText(values.get(position).getChatName());
@@ -65,7 +64,7 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
Thread getPic;
if(values.get(position).getPicture() != null) {
Log.i("Kontakt", "PersonOid hat Bild");
byte[] imageAsByteArray = values.get(position).getPicture();
Bitmap i = BitmapFactory.decodeByteArray(imageAsByteArray, 0, imageAsByteArray.length);
@@ -73,10 +72,23 @@ public class KontaktAdapter extends ArrayAdapter<ContactListItem> {
getPic = new Thread(new CircleBitmapCreator(i));
getPic.start();
} else {
Bitmap bitmap = decodeSampledBitmapFromResource(inflater.getContext().getResources(), R.drawable.katze3, 100, 100);//BitmapFactory.decodeResource(inflater.getContext().getResources(), R.drawable.katze3);
ContactListItem cli = values.get(position);
getPic = new Thread(new CircleBitmapCreator(bitmap));
getPic.start();
int bildId = R.drawable.mitarbeiter_avatar;
String blah = "Mitarbeiter";
if(cli.isTeam) {
bildId = R.drawable.mitarbeiter_team_avatar;
blah = "Team";
} else if(!cli.getIsEmployee()) {
bildId = R.drawable.klient_avatar;
blah = "Klient";
}
Log.i("KONTAKT_ADAPTER", "Kontakt hat KEIN Bild. Benutze Standardbild. Kontakt ist " + blah + "; Id: " + bildId);
Bitmap bitmap = decodeSampledBitmapFromResource(inflater.getContext().getResources(), bildId, 100, 100);
imageView.setImageBitmap(ImageConverter.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 2));
}
onlinestats.setImageResource((values.get(position).isOnline ? R.drawable.statusonline : R.drawable.statusoffline));

View File

@@ -91,13 +91,14 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
bundle.putBoolean("IsTeam", selectedValue.isTeam);
bundle.putString("TeamMemberOids", selectedValue.teamMemberOids);
bundle.putString("TeamMemberNames", selectedValue.teamMemberNames);
bundle.putBoolean("IsEmployee", selectedValue.getIsEmployee());
Intent in = new Intent(getBaseContext(), ChatActivity.class);
in.putExtras(bundle);
if(selectedValue.getPicture() == null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.katze3);
Bitmap a = BitmapFactory.decodeResource(getResources(), R.drawable.mitarbeiter_avatar);
a.compress(Bitmap.CompressFormat.JPEG,0,stream);
byte[] x = stream.toByteArray();
in.putExtra("Bild", x);
@@ -160,7 +161,7 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
try {
switch(chatPacket.ChatDataIdentifier) {
case MESSAGE:
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, getApplicationContext());
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, chatPacket.IsEmployee, getApplicationContext());
runOnUiThread(new Runnable() {
@Override
@@ -185,7 +186,7 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
case TEAM:
ContactListItem cli = DatabaseHandler.getInstance(getApplicationContext()).getContactByPersonOid(chatPacket.RecipientPersonOid, true);
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid, true, cli.teamMemberOids, cli.teamMemberNames, getApplicationContext());
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid, true, cli.teamMemberOids, cli.teamMemberNames, cli.getIsEmployee(), getApplicationContext());
runOnUiThread(new Runnable() {
@Override
@@ -353,12 +354,16 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
}
@Override
public void onBackPressed()
{
SocketManager.logout();
public void onBackPressed() {
// SocketManager.logout();
//
// Intent intent = new Intent(KontaktChatActivity.this, LoginActivity.class);
// KontaktChatActivity.this.startActivity(intent);
Intent intent = new Intent(KontaktChatActivity.this, LoginActivity.class);
KontaktChatActivity.this.startActivity(intent);
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
this.startActivity(i);
super.onBackPressed();
}
@@ -419,7 +424,7 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
@Override
public void onRequestSuccess(SoapPrimitive soapPrimitive) {
if(soapPrimitive == null) {
Log.e("KONTAKT_CHAT_ACTIVITY", "Der vom Server zurückgelieferte Wert ist NULL! (Laden der Kontakte)");
Log.e(LOGTAG, "Der vom Server zurückgelieferte Wert ist NULL! (Laden der Kontakte)");
return;
}
@@ -434,16 +439,22 @@ public class KontaktChatActivity extends ActionBarActivity implements Connectivi
Map<ChatEntity, Integer> oid2VersionList = new HashMap<>();
for(ContactListItem item : lc) {
Log.i(LOGTAG, "Aus DB: Oid: " + item.getPersonOid() + "; Version: " + item.getVersion() + "; " + item.getChatName());
oid2VersionList.put(new ChatEntity(item.getPersonOid(), item.isTeam), item.getVersion());
oid2VersionList.put(new ChatEntity(item.getPersonOid(), item.isTeam, item.getIsEmployee()), item.getVersion());
}
for(Map.Entry<ChatEntity, Integer> entry : oid2VersionList.entrySet()) {
ChatEntity key = entry.getKey();
Log.i(LOGTAG, "\nOid: " + key.getOid() + "\nIsTeam: " + key.getIsTeam() + "\nIsEmployee: " + key.getIsEmployee());
}
for(ChatPerson cp : result) {
ContactListItem contact = new ContactListItem(cp.Name, cp.Oid, cp.IsTeam, cp.TeamMemberOids, cp.TeamMemberNames, cp.Version);
Log.i(LOGTAG, cp.Name + " " + cp.IsEmployee);
ContactListItem contact = new ContactListItem(cp.Name, cp.Oid, cp.IsTeam, cp.TeamMemberOids, cp.TeamMemberNames, cp.Version, cp.IsEmployee);
ChatEntity cliEntity = new ChatEntity(cp.Oid, cp.IsTeam);
ChatEntity cliEntity = new ChatEntity(cp.Oid, cp.IsTeam, cp.IsEmployee);
if(!oid2VersionList.containsKey(cliEntity)) {
Log.i(LOGTAG, "Nicht in der Klientenliste enthalten");
databaseHandler.addContact(contact);
} else if(oid2VersionList.get(cliEntity) < cp.Version) {

View File

@@ -143,6 +143,25 @@ public class LoginActivity extends ActionBarActivity {
super.onStop();
}
@Override
public void onPause() {
super.onPause();
BeWoChatApplication.activityPaused();
}
@Override
protected void onResume() {
BeWoChatApplication.activityResumed();
if(SoapConnectionManager.User != null) {
Log.i("LOGIN", "Benutzer ist angemeldet");
} else {
Log.i("LOGIN", "Benutzer ist NICHT angemeldet");
}
super.onResume();
}
private void attemptLogin() {
mTenantView.setError(null);
mChatCodeView.setError(null);
@@ -307,6 +326,13 @@ public class LoginActivity extends ActionBarActivity {
public void doCallback() {
Log.e("LOGIN_CALLBACK", "LoginCallback aufgerufen. Ist verbunden und ruft die ChatActivity nun auf.");
runOnUiThread(new Runnable() {
@Override
public void run() {
showProgress(false);
}
});
Intent kontaktChatActivity = new Intent(LoginActivity.this, KontaktChatActivity.class);
LoginActivity.this.startActivity(kontaktChatActivity);
}

View File

@@ -62,7 +62,7 @@ public class MainActivityMitarbeiter extends Activity implements ConnectivityRec
public void updateUserInterface(Packet chatPacket) {
switch(chatPacket.ChatDataIdentifier) {
case MESSAGE:
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, getApplicationContext());
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.SenderPersonOid, false, null, null, chatPacket.IsEmployee, getApplicationContext());
break;
@@ -101,7 +101,7 @@ public class MainActivityMitarbeiter extends Activity implements ConnectivityRec
case TEAM:
ContactListItem cli = DatabaseHandler.getInstance(getApplicationContext()).getContactByPersonOid(chatPacket.RecipientPersonOid, true);
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid, true, cli.teamMemberOids, cli.teamMemberNames, getApplicationContext());
Util.SetNotify(chatPacket.ChatName, chatPacket.ChatMessage, chatPacket.RecipientPersonOid, true, cli.teamMemberOids, cli.teamMemberNames, cli.getIsEmployee(), getApplicationContext());
break;
}
}

View File

@@ -6,20 +6,24 @@ package entities;
public class ChatEntity {
private long oid;
private boolean isTeam;
private boolean isEmployee;
public ChatEntity(long pOid, boolean pIsTeam) {
public ChatEntity(long pOid, boolean pIsTeam, boolean pIsEmployee) {
oid = pOid;
isTeam = pIsTeam;
isEmployee = pIsEmployee;
}
public long getOid() {
return oid;
}
public boolean isTeam() {
public boolean getIsTeam() {
return isTeam;
}
public boolean getIsEmployee() {return isEmployee;}
@Override
public boolean equals(Object other) {
if(other == null || !(other instanceof ChatEntity)) {
@@ -32,13 +36,14 @@ public class ChatEntity {
ChatEntity otherEntity = (ChatEntity) other;
return this.oid == otherEntity.getOid() && this.isTeam == otherEntity.isTeam();
return this.oid == otherEntity.getOid() && this.isTeam == otherEntity.getIsTeam() && this.isEmployee == otherEntity.getIsEmployee();
}
@Override
public int hashCode() {
int result = (int) (oid ^ (oid >>> 32));
result = 31 * result + (isTeam ? 1 : 0);
result = 31 * result + (isEmployee ? 1 : 0);
return result;
}
}

View File

@@ -10,4 +10,5 @@ public class ChatPerson {
public String TeamMemberNames;
public String TeamMemberOids;
public int Version;
public boolean IsEmployee;
}

View File

@@ -7,6 +7,7 @@ public class ApplicationUser {
private String fullName;
private String username;
private Long employeeOid;
private Long customerOid;
private Long personOid;
private String tenant;
@@ -50,6 +51,10 @@ public class ApplicationUser {
this.personOid = personOid;
}
public boolean getIsEmployee() {
return employeeOid == 0 && customerOid > 0;
}
public ApplicationUser(String fullName, String username, Long employeeOid, Long personOid) {
this.fullName = fullName;
this.username = username;

View File

@@ -25,6 +25,7 @@ public class Packet {
public boolean IsDelivered;
public int ServerseitigeOid;
public int ClientseitigeOid;
public boolean IsEmployee;
public Packet() {
ChatDataIdentifier = DataIdentifier.NULL;
@@ -35,6 +36,7 @@ public class Packet {
RecipientPersonOid = 0;
IsDelivered = false;
MessageTimeStamp = Calendar.getInstance().getTime();
IsEmployee = SoapConnectionManager.User.getIsEmployee();
}
public String getFormattedMessageTimeStamp() {
@@ -44,7 +46,7 @@ public class Packet {
//Aufbau Message:
// die ersten fünf ";" ignorieren
// SenderOid;RecipientOid;ClientNameLength;MessageLength;ChatDataIdentifier;ServerseitigeOid;ClientseitigeOid;Tenant;[ClientName][ChatMessage][MessageTimeStamp][IsDelivered]
// SenderOid;RecipientOid;ClientNameLength;MessageLength;ChatDataIdentifier;ServerseitigeOid;ClientseitigeOid;Tenant;IsEmployee;[ClientName][ChatMessage][MessageTimeStamp][IsDelivered]
//23;281;20;389;1;38;932[Tenant]; 8 Semikola
@@ -61,18 +63,20 @@ public class Packet {
String serverseitigeOidString = gesplittet[5];
String clientseitigeOidString = gesplittet[6];
Tenant = gesplittet[7];
String isEmployeeString = gesplittet[8];
SenderPersonOid = Integer.parseInt(senderPersonOidString);
RecipientPersonOid = Integer.parseInt(recipientPersonOidString);
ServerseitigeOid = Integer.parseInt(serverseitigeOidString);
ClientseitigeOid = Integer.parseInt(clientseitigeOidString);
IsEmployee = Integer.parseInt(isEmployeeString) == 1;
ChatDataIdentifier = DataIdentifier.getEnumValue(Integer.parseInt(chatIdentifierString));
int chatNameLength = Integer.parseInt(chatNameLengthString);
int chatMessageLength = Integer.parseInt(chatMessageLengthString);
int headerLength = senderPersonOidString.length() + recipientPersonOidString.length() + chatNameLengthString.length() + chatMessageLengthString.length() + chatIdentifierString.length() + Tenant.length() + serverseitigeOidString.length() + clientseitigeOidString.length() + 9;
int headerLength = senderPersonOidString.length() + recipientPersonOidString.length() + chatNameLengthString.length() + chatMessageLengthString.length() + chatIdentifierString.length() + Tenant.length() + serverseitigeOidString.length() + clientseitigeOidString.length() + 10;
String actualMessage = message.substring(headerLength - 1);
ChatName = actualMessage.substring(0, chatNameLength);
@@ -82,6 +86,7 @@ public class Packet {
String dateString = actualMessage.substring(chatMessageLength + chatNameLength);
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", Locale.GERMAN);
try {
MessageTimeStamp = df.parse(dateString);
} catch (ParseException e) {
@@ -94,7 +99,7 @@ public class Packet {
}
public byte[] getDataStream() {
String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length()+ ";" + ChatDataIdentifier.getValue() + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";";
String dataStreamAsString = "" + SenderPersonOid + ";" + RecipientPersonOid + ";" + ChatName.length() + ";" + ChatMessage.length()+ ";" + ChatDataIdentifier.getValue() + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";" + (IsEmployee ? 1 : 0) + ";";
dataStreamAsString += ChatName + ChatMessage + getFormattedMessageTimeStamp() + "" + (IsDelivered ? 1 : 0);
@@ -111,7 +116,7 @@ public class Packet {
return blaaah;
}
public void writeToLog(String prefix) {
Log.i("PACKET_LOG", prefix + ": SenderPersonOid: " + SenderPersonOid + "\nRecipientPersonOid: " + RecipientPersonOid + "\nChatDataIdentifier: " + ChatDataIdentifier.name() + "\nChatName: " + ChatName + "\nChatMessage: " + ChatMessage + "\nTenant: " + Tenant + "\nIsDelivered: " + IsDelivered + "\nMessageTimeStamp: " + MessageTimeStamp + "\nServerseitigeOid: " + ServerseitigeOid + "\nClientseitigeOid: " + ClientseitigeOid);
private void writeToLog(String prefix) {
Log.i("PACKET_LOG", prefix + ": SenderPersonOid: " + SenderPersonOid + "\nRecipientPersonOid: " + RecipientPersonOid + "\nChatDataIdentifier: " + ChatDataIdentifier.name() + "\nChatName: " + ChatName + "\nChatMessage: " + ChatMessage + "\nTenant: " + Tenant + "\nIsDelivered: " + IsDelivered + "\nMessageTimeStamp: " + MessageTimeStamp + "\nServerseitigeOid: " + ServerseitigeOid + "\nClientseitigeOid: " + ClientseitigeOid + "\nIsEmployee: " + IsEmployee);
}
}

View File

@@ -12,24 +12,24 @@ public class SoapCalls {
public static String KEEP_ALIVE = "KeepAlive";
//TODO: "app4.bewoplaner.de";//
// public static String DESTINATION_ADDRESS = "app4.bewoplaner.de";
// public static int DESTINATION_PORT = 5000;
//
// public static String TOKEN_CHECK_URL = "https://" + DESTINATION_ADDRESS + "/mobil/main/checktoken?token=";
//
// public static String WEB_DOKU_URL = "https://" + DESTINATION_ADDRESS + "/mobil/login/demo";
//
// public static String WSDL_TARGET_NAME = "bliblablubb.org/";
// public static String SOAP_ADDRESS = "https://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
public static String DESTINATION_ADDRESS = "192.168.1.103";
public static String DESTINATION_ADDRESS = "app4.bewoplaner.de";
public static int DESTINATION_PORT = 5000;
public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token=";
public static String TOKEN_CHECK_URL = "https://" + DESTINATION_ADDRESS + "/mobil/main/checktoken?token=";
public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/login/demo";
public static String WEB_DOKU_URL = "https://" + DESTINATION_ADDRESS + "/mobil/login/demo";
static String WSDL_TARGET_NAME = "bliblablubb.org/";
static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
public static String WSDL_TARGET_NAME = "bliblablubb.org/";
public static String SOAP_ADDRESS = "https://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
// public static String DESTINATION_ADDRESS = "192.168.1.103";
// public static int DESTINATION_PORT = 5000;
//
// public static String TOKEN_CHECK_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/main/checktoken?token=";
//
// public static String WEB_DOKU_URL = "http://" + DESTINATION_ADDRESS + "/bewoplanermobil/login/demo";
//
// static String WSDL_TARGET_NAME = "bliblablubb.org/";
// static String SOAP_ADDRESS = "http://" + DESTINATION_ADDRESS + "/BeWoPlanerAndroid/AndroidSoapService.asmx";
}

View File

@@ -259,7 +259,7 @@ public class SocketManager {
}
if(!isAlreadyLoggedIn) {
SocketManager.onlineEntities.add(new ChatEntity(chatPacket.SenderPersonOid, false));
SocketManager.onlineEntities.add(new ChatEntity(chatPacket.SenderPersonOid, false, chatPacket.IsEmployee));
}
break;

View File

@@ -0,0 +1,37 @@
package util;
/**
* Created by JettenM on 07.10.2016.
*/
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
public class ImageConverter {
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
}

View File

@@ -21,11 +21,12 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
{
Log.i("NOTIFICATION_CANCELLED", "Benachrichtigung gelöscht");
Bundle extras = intent.getExtras();
int recipientOid = extras.getInt("RecipientOid");
boolean isTeam = extras.getBoolean("IsTeam");
Bundle extras = intent.getExtras();
int recipientOid = extras.getInt("RecipientOid");
boolean isTeam = extras.getBoolean("IsTeam");
boolean isEmployee = extras.getBoolean("IsEmployee");
Util.removeMessagesCount(new ChatEntity(recipientOid, isTeam));
Util.removeMessagesCount(new ChatEntity(recipientOid, isTeam, isEmployee));
Util.conversationsCount = 0;
SocketManager.notificationEntities.clear();

View File

@@ -52,7 +52,7 @@ public class Util {
public static HashMap<ChatEntity, Integer> entity2MessagesCountRel = new HashMap<>();
//TODO: Notifications zählen. Bei Nachrichten verschiedener Unterhaltungen nur noch eine kleine Notification anzeigen mit "Sie haben x Nachrichten in y Unterhaltungen
public static void SetNotify(String username, String message, int recipientOid, boolean isTeam, String teamMemberOids, String teamMemberNames, Context packageContext) {
public static void SetNotify(String username, String message, int recipientOid, boolean isTeam, String teamMemberOids, String teamMemberNames, boolean isEmployee, Context packageContext) {
int unreadMessagesCount = entity2MessagesCountRel.size() + 1;
//TODO: unterscheiden, ob es sich um eine einzelne Benachrichtigung handelt
@@ -82,6 +82,7 @@ public class Util {
bundle.putBoolean("IsTeam", isTeam);
bundle.putString("TeamMemberOids", teamMemberOids);
bundle.putString("TeamMemberNames", teamMemberNames);
bundle.putBoolean("IsEmployee", isEmployee);
resultIntent.putExtras(bundle);
}
@@ -97,7 +98,7 @@ public class Util {
Random random = new Random();
int notificationId = 1;
ChatEntity chatEntity = new ChatEntity(recipientOid, isTeam);
ChatEntity chatEntity = new ChatEntity(recipientOid, isTeam, isEmployee);
@@ -238,7 +239,7 @@ public class Util {
public static ChatEntity getChatEntityFromOnlineEntitiesByOid(int personOid, boolean isTeam) {
for(ChatEntity item : SocketManager.onlineEntities) {
if(item.getOid() == personOid && item.isTeam() == isTeam) {
if(item.getOid() == personOid && item.getIsTeam() == isTeam) {
return item;
}
}

View File

@@ -1,45 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/chk_on" />
<item android:state_checked="false" android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/chk_off" />
<item android:state_checked="true" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/chk_on" />
<item android:state_checked="false" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/chk_off_pressed" />
<item android:state_checked="true" android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/chk_on" />
<item android:state_checked="false" android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/chk_off" />
<item android:state_checked="false"
android:state_enabled="true"
android:drawable="@drawable/chk_off" />
<item android:state_checked="true"
android:state_enabled="true"
android:drawable="@drawable/chk_on" />
<!--&lt;!&ndash; Disabled states &ndash;&gt;-->
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/chk_on_disabled" />
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/chk_off_disabled" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/chk_on_disabled" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/chk_off_disabled" />
<item android:state_checked="false" android:drawable="@drawable/chk_off_disabled" />
</selector>

View File

@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:thickness="0dp"
android:shape="rectangle">
<stroke android:width="3dp"
android:color="#4799E8"/>
<corners android:radius="5dp" />
<gradient
android:startColor="#C8C8C8"
android:endColor="#FFFFFF"
android:type="linear"
android:angle="270"/>
</shape>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="-1dp"
android:top="-3dp"
android:left="-3dp"
android:right="-3dp"
>
<shape android:thickness="0dp"
android:shape="rectangle">
<stroke android:width="2dp"
android:color="@color/beyondsoft_orange"/>
<solid android:color="@color/white"/>
</shape>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

View File

@@ -11,19 +11,18 @@
android:background="@color/white"
tools:context="beyondsoft.bewomitarbeiterapp.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginBottom="20dp"
android:visibility="gone"/>
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/email_login_form"
@@ -84,14 +83,12 @@
<CheckBox
android:id="@+id/remember_me_checkbox"
style="checkBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/prompt_remember_me"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:onClick="rememberMeOnClick"
android:button="@drawable/bewo_checkbox"
/>
<Button
@@ -100,9 +97,9 @@
android:background="@drawable/orange_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_sign_in_short"
android:fontFamily="sans-serif"
android:layout_gravity="bottom"
/>
</LinearLayout>

View File

@@ -4,54 +4,63 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin"
android:padding="0dp"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ChatActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9">
android:layout_weight="0.9"
android:background="@color/white">
<ListView
android:id="@+id/list_msg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:divider="@null"
android:listSelector="@android:color/transparent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" />
android:background="@color/white"
android:transcriptMode="alwaysScroll"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="22dp"
android:layout_weight="0.1"
android:orientation="horizontal"
>
android:padding="0dp"
android:background="@android:color/white">
<EditText
android:layout_width="275dp"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:background="@drawable/edittext"
android:id="@+id/editText"
android:hint="@string/hinttxt_chat"
android:padding="10dp"
android:maxLength="1024"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/Sendebutton"
android:layout_margin="10dp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Chatbutton_name"
android:background="@drawable/abc_btn_radio_material"
android:textColor="@color/green"
style="@style/button_text"
android:background="@drawable/orange_button"
android:id="@+id/Sendebutton"
android:padding="10dp"
android:layout_alignParentEnd="true"
android:layout_margin="10dp"
android:layout_centerVertical="true"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@@ -14,7 +14,7 @@
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
android:src="@drawable/bslogo" />
android:src="@drawable/mitarbeiter_avatar" />
<ImageView
android:id="@+id/status"

View File

@@ -7,7 +7,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:background="@drawable/out_message_bg"
android:background="@drawable/out_msg"
android:paddingBottom="4dp"
android:orientation="vertical"
>

View File

@@ -8,7 +8,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@drawable/in_message_bg"
android:background="@drawable/in_msg"
android:orientation="vertical"
android:paddingBottom="4dp">

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/beyondsoft_orange</item>
<item name="colorAccent">@color/beyondsoft_orange</item>
<item name="android:statusBarColor">?android:attr/colorPrimary</item>
</style>
</resources>

View File

@@ -3,4 +3,5 @@
<color name="red">#f12727</color>
<color name="green">#25ea20</color>
<color name="white">#ffffff</color>
<color name="beyondsoft_orange">#ff5e00</color>
</resources>

View File

@@ -20,7 +20,7 @@
<string name="back">Zurück</string>
<string name="action_settings">Einstellungen</string>
<string name="Chatbutton_name">S</string>
<string name="Chatbutton_name">Senden</string>
<string name="hinttxt_chat">Nachricht Schreiben</string>
<string name="prompt_chat_code_button">Weiter</string>

View File

@@ -1,14 +1,15 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<!--<item name="actionBarStyle">@style/MyActionBar</item>-->
<item name="colorPrimary">@color/beyondsoft_orange</item>
<item name="colorAccent">@color/beyondsoft_orange</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF5E00</item>
</style>
<!--<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">-->
<!--<item name="android:background">#FF5E00</item>-->
<!--</style>-->
<style name="button_text" >
<item name="android:layout_width" >fill_parent</item>
@@ -16,7 +17,7 @@
<item name="android:textColor" >#ffffff</item>
<item name="android:gravity" >center</item>
<item name="android:layout_margin" >3dp</item>
<item name="android:textSize" >30dp</item>
<item name="android:textSize" >15dp</item>
<item name="android:textStyle" >normal</item>
<item name="android:shadowColor" >#000000</item>
<item name="android:shadowDx" >1</item>
@@ -24,9 +25,4 @@
<item name="android:shadowRadius" >2</item>
</style>
<style name="checkBoxStyle" parent="Base.Theme.AppCompat">
<item name="colorAccent">#ff0000</item>
<item name="android:textColorSecondary">#fcad49</item>
</style>
</resources>

View File

@@ -70,7 +70,7 @@ namespace BeWoChatServer
Console.WriteLine(DateTime.Now + ": Client hinzugefügt (" + workerSocket.RemoteEndPoint + ")");
WaitForClientData(workerSocket, "", 0, 0);
WaitForClientData(workerSocket, "", 0, 0, true);
serverSocket.BeginAccept(OnClientConnected, null);
@@ -82,7 +82,7 @@ namespace BeWoChatServer
}
}
public static void WaitForClientData(Socket socket, string clientName, long oid, long recipientPersonOid)
public static void WaitForClientData(Socket socket, string clientName, long oid, long recipientPersonOid, bool isEmployee)
{
try
{
@@ -91,7 +91,7 @@ namespace BeWoChatServer
asyncCallback = OnReceiveData;
}
var packet = new Packet(socket, clientName, oid, recipientPersonOid);
var packet = new Packet(socket, clientName, oid, recipientPersonOid, isEmployee);
socket.BeginReceive(packet.DataBuffer, 0, packet.DataBuffer.Length, SocketFlags.None, asyncCallback, packet);
}
@@ -167,7 +167,7 @@ namespace BeWoChatServer
clientList[dataPacket.Socket].MacAddress = dataPacket.ChatMessage;
}
var notificationPacket = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) {DataIdentifier = DataIdentifier.StatusNotificationLogin, Tenant = dataPacket.Tenant};
var notificationPacket = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0, dataPacket.IsEmployee) { DataIdentifier = DataIdentifier.StatusNotificationLogin, Tenant = dataPacket.Tenant };
Console.WriteLine(DateTime.Now + ": Benachrichtige die anderen angemeldeten Clients. Alte Logins enthalten: " + alteLogins);
foreach (var client in clientList.Where(w => !w.Value.PersonOid.Equals(dataPacket.SenderPersonOid)))
@@ -175,7 +175,7 @@ namespace BeWoChatServer
client.Key.Send(notificationPacket.GetDataStream());
}
var successfulLoginNotification = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) {DataIdentifier = DataIdentifier.LoginSuccess, Tenant = dataPacket.Tenant};
var successfulLoginNotification = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0, dataPacket.IsEmployee) { DataIdentifier = DataIdentifier.LoginSuccess, Tenant = dataPacket.Tenant };
dataPacket.Socket.Send(successfulLoginNotification.GetDataStream());
// Boradcast
@@ -216,7 +216,7 @@ namespace BeWoChatServer
Monitor.Enter(_Lock);
var notificationPacketLogout2 = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) {DataIdentifier = DataIdentifier.StatusNotificationLogout};
var notificationPacketLogout2 = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0, dataPacket.IsEmployee) { DataIdentifier = DataIdentifier.StatusNotificationLogout };
LoginData wtf = null;
var wasAbleToRemoveClient = clientList.TryRemove(dataPacket.Socket, out wtf);
@@ -241,68 +241,66 @@ namespace BeWoChatServer
return;
}
else
try
{
try
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(DateTime.Now + ": Chat-Nachricht erhalten: " + dataPacket.ChatMessage);
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Gray;
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(DateTime.Now + ": Chat-Nachricht erhalten: " + dataPacket.ChatMessage);
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Gray;
Monitor.Enter(_Lock);
Monitor.Enter(_Lock);
DefaultHibernateSessionManager.CurrentTenant = dataPacket.Tenant;
DefaultHibernateSessionManager.CurrentTenant = dataPacket.Tenant;
var chatMessage = new ChatMessage
var chatMessage = new ChatMessage
{
SenderPersonOid = dataPacket.SenderPersonOid,
ChatText = Encoding.UTF8.GetBytes(dataPacket.ChatMessage),
EmpfaengerPersonOid = dataPacket.RecipientPersonOid,
Uhrzeit = DateTime.Now,
InsUser = dataPacket.ClientName,
IsDelivered = true
};
Console.WriteLine(DateTime.Now + ": Speichere die Chat-Nachricht in die Datenbank");
DAOFactory.GenericDAO.Insert(chatMessage);
if(chatMessage.Oid != null)
{
Console.WriteLine(DateTime.Now + ": Chat-Nachricht erfolgreich mit Oid " + chatMessage.Oid.Value + " gespeichert");
dataPacket.ServerseitigeOid = chatMessage.Oid.Value;
}
if(dataPacket.RecipientPersonOid > 0)
{
if (clientList.Values.Any(a => a.PersonOid.Equals(dataPacket.RecipientPersonOid)))
{
SenderPersonOid = dataPacket.SenderPersonOid,
ChatText = Encoding.UTF8.GetBytes(dataPacket.ChatMessage),
EmpfaengerPersonOid = dataPacket.RecipientPersonOid,
Uhrzeit = DateTime.Now,
InsUser = dataPacket.ClientName,
IsDelivered = true//dataPacket.IsDelivered
var recipients = clientList.Where(w => w.Value.PersonOid.Equals(dataPacket.RecipientPersonOid));
Console.WriteLine(DateTime.Now + ": Leite die Chat-Nachricht an die Empfänger (Derselbe User angemeldet an verschiedenen Clients) weiter");
foreach(var recipient in recipients)
{
recipient.Key.Send(dataPacket.GetDataStream());
}
}
var packet = new Packet
{
ClientseitigeOid = dataPacket.ClientseitigeOid,
ServerseitigeOid = dataPacket.ServerseitigeOid,
DataIdentifier = DataIdentifier.MessageResponse
};
Console.WriteLine(DateTime.Now + ": Speichere die Chat-Nachricht in die Datenbank");
DAOFactory.GenericDAO.Insert(chatMessage);
if(chatMessage.Oid != null)
{
Console.WriteLine(DateTime.Now + ": Chat-Nachricht erfolgreich mit Oid " + chatMessage.Oid.Value + " gespeichert");
dataPacket.ServerseitigeOid = chatMessage.Oid.Value;
}
if(dataPacket.RecipientPersonOid > 0)
{
if (clientList.Values.Any(a => a.PersonOid.Equals(dataPacket.RecipientPersonOid)))
{
var recipients = clientList.Where(w => w.Value.PersonOid.Equals(dataPacket.RecipientPersonOid));
Console.WriteLine(DateTime.Now + ": Leite die Chat-Nachricht an die Empfänger (Derselbe User angemeldet an verschiedenen Clients) weiter");
foreach(var recipient in recipients)
{
recipient.Key.Send(dataPacket.GetDataStream());
}
}
var packet = new Packet
{
ClientseitigeOid = dataPacket.ClientseitigeOid,
ServerseitigeOid = dataPacket.ServerseitigeOid,
DataIdentifier = DataIdentifier.MessageResponse
};
Console.WriteLine(DateTime.Now + ": Sende Datenbank-Insert-Bestätigung an den Absender, damit die Nachricht später nicht doppelt auf den Client heruntergeladen wird");
dataPacket.Socket.Send(packet.GetDataStream());
}
}
finally
{
Monitor.Exit(_Lock);
Console.WriteLine(DateTime.Now + ": Sende Datenbank-Insert-Bestätigung an den Absender, damit die Nachricht später nicht doppelt auf den Client heruntergeladen wird");
dataPacket.Socket.Send(packet.GetDataStream());
}
}
finally
{
Monitor.Exit(_Lock);
}
break;
case DataIdentifier.Logout:
@@ -313,7 +311,7 @@ namespace BeWoChatServer
Console.WriteLine("Konnte den Client nicht aus der Liste entfernen.");
}
var notificationPacketLogout = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) {DataIdentifier = DataIdentifier.StatusNotificationLogout};
var notificationPacketLogout = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0, dataPacket.IsEmployee) {DataIdentifier = DataIdentifier.StatusNotificationLogout};
Console.WriteLine(DateTime.Now + ": Sende Logout von " + dataPacket.ClientName + " an alle anderen Clients");
foreach (var client in clientList.Where(w => !w.Value.PersonOid.Equals(dataPacket.SenderPersonOid)))
@@ -429,7 +427,7 @@ namespace BeWoChatServer
break;
}
WaitForClientData(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, dataPacket.RecipientPersonOid);
WaitForClientData(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, dataPacket.RecipientPersonOid, dataPacket.IsEmployee);
}
catch (Exception e)
{
@@ -437,7 +435,7 @@ namespace BeWoChatServer
var sender = dataPacket.Socket;
var notificationPacketLogout = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) { DataIdentifier = DataIdentifier.StatusNotificationLogout };
var notificationPacketLogout = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0, dataPacket.IsEmployee) { DataIdentifier = DataIdentifier.StatusNotificationLogout };
try
{
@@ -478,7 +476,7 @@ namespace BeWoChatServer
private static void SendNotificationPacket(Packet dataPacket, DataIdentifier dataIdentifier)
{
var notificationPacket = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0) { DataIdentifier = DataIdentifier.StatusNotificationLogout };
var notificationPacket = new Packet(dataPacket.Socket, dataPacket.ClientName, dataPacket.SenderPersonOid, 0, dataPacket.IsEmployee) { DataIdentifier = DataIdentifier.StatusNotificationLogout };
Console.WriteLine(DateTime.Now + ": Sende Statusänderung(" + dataIdentifier + ") an alle anderen Clients");
foreach (var client in clientList.Where(w => w.Value.PersonOid != dataPacket.SenderPersonOid))

View File

@@ -111,12 +111,6 @@ namespace BeWoPlanerAndroid
return JsonConvert.SerializeObject(jsonMessages);
}
[WebMethod(EnableSession = true)]
public string GetAllUnreadMessages()
{
return "";
}
[WebMethod(EnableSession = true)]
public string GetNewestMessages(long pRecipientPersonOid)
{
@@ -147,7 +141,7 @@ namespace BeWoPlanerAndroid
var isEmployee = customer == null;
// mit den eigenen Klienten und allen anderen Mitarbeitern
var allPersons = DAOFactory.SearchDAO.FindAllChatAuthorizedPersonsForEmployee(employee.Oid.Value).Where(w => w.Oid.Value != employee.Person.Oid.Value).Select(s => new ChatPerson(s.Oid.Value, s.FirstNameLastName, false, null, null, s.Version.Value)).ToList();
var allPersons = DAOFactory.SearchDAO.FindAllChatAuthorizedPersonsForEmployee(employee.Oid.Value).Where(w => w.Key.Oid.Value != employee.Person.Oid.Value).Select(s => new ChatPerson(s.Key.Oid.Value, s.Key.FirstNameLastName, false, null, null, s.Key.Version.Value, s.Value)).ToList();
var teams = DAOFactory.SearchDAO.FindTeamsOfEmployee(employee.Oid.Value).Where(w => w.MemberList.Count > 1);
@@ -170,7 +164,7 @@ namespace BeWoPlanerAndroid
}
}
allPersons.Add(new ChatPerson(team.Oid.Value, team.Name, true, memberString, memberNames, team.Version.Value));
allPersons.Add(new ChatPerson(team.Oid.Value, team.Name, true, memberString, memberNames, team.Version.Value, false));
}
return SerializeObject(allPersons);
@@ -201,7 +195,9 @@ namespace BeWoPlanerAndroid
public long Version { get; set; }
public ChatPerson(long pOid, string pName, bool pIsTeam, string pTeamMemberOids, string pTeamMemberNames, long pVersion)
public bool IsEmployee { get; set; }
public ChatPerson(long pOid, string pName, bool pIsTeam, string pTeamMemberOids, string pTeamMemberNames, long pVersion, bool pIsEmployee)
{
Oid = pOid;
Name = pName;
@@ -209,6 +205,7 @@ namespace BeWoPlanerAndroid
TeamMemberOids = pTeamMemberOids;
TeamMemberNames = pTeamMemberNames;
Version = pVersion;
IsEmployee = pIsEmployee;
}
}

View File

@@ -1639,8 +1639,10 @@ namespace BeWo.Data.Access
return c.List<ChatMessage>();
}
public IEnumerable<Person> FindAllChatAuthorizedPersonsForEmployee(long pEmployeeOid)
public Dictionary<Person, bool> FindAllChatAuthorizedPersonsForEmployee(long pEmployeeOid)
{
var result = new Dictionary<Person, bool>();
var employee = CreateCriteriaIsActive<Employee>().Add(Restrictions.Eq(BeWoEntityBase.PropertyName_Oid, pEmployeeOid)).UniqueResult<Employee>();
var relatedCustomerOids = employee.Employee2CustomerList.Select(s => s.CustomerOid.Value);
@@ -1655,13 +1657,10 @@ namespace BeWo.Data.Access
var customers = c2.List<Customer>();
var employees = FindAllChatActiveEmployees();
var oids = customers.Select(s => s.Person.Oid.Value).ToList();
oids.AddRange(employees.Select(s => s.Person.Oid.Value));
var c = CreateCriteriaIsActive<Person>()
.Add(Restrictions.In(BeWoEntityBase.PropertyName_Oid, oids.Distinct().ToList()));
employees.DoForEach(d => result.Add(d.Person, true));
customers.DoForEach(d => result.Add(d.Person, false));
return c.List<Person>();
return result;
}
public IEnumerable<ChatMessage> FindUnreadChatMessagesForRecipient(long pRecipientOid)

View File

@@ -20,6 +20,7 @@ namespace BS.Shared
public bool IsDelivered { get; set; }
public long ServerseitigeOid { get; set; }
public long ClientseitigeOid { get; set; }
public bool IsEmployee { get; set; }
public byte[] DataBuffer = new byte[1024];
@@ -27,9 +28,9 @@ namespace BS.Shared
// die ersten fünf ";" ignorieren
// SenderOid;RecipientOid;ClientNameLength;MessageLength;ChatDataIdentifier;Tenant;[ClientName][ChatMessage][MessageTimeStamp]
//23;281;20;389;1;39;[Tenant]; 7 Semikola
//[SenderOid];[RecipientOid];[ClientNameLength];[MessageLength];[ChatDataIdentifier];[ServerSeitigeOid];[ClientSeitigeOid];[Tenant];[IsEmployee]; 9 Semikola
public Packet(Socket pSocket, string pClientName, long pSenderPersonOid, long pRecipientPersonOid)
public Packet(Socket pSocket, string pClientName, long pSenderPersonOid, long pRecipientPersonOid, bool pIsEmployee)
{
Socket = pSocket;
ClientName = pClientName;
@@ -38,6 +39,7 @@ namespace BS.Shared
MessageTimeStamp = DateTime.Now;
ChatMessage = "";
Tenant = "";
IsEmployee = pIsEmployee;
}
public Packet()
@@ -64,6 +66,7 @@ namespace BS.Shared
var serverseitigeOidString = gesplittet[5];
var clientseitigeOidString = gesplittet[6];
Tenant = gesplittet[7];
var isEmployeeString = gesplittet[8];
DataIdentifier = (DataIdentifier) Convert.ToInt32(chatIdentifierString);
@@ -71,11 +74,12 @@ namespace BS.Shared
RecipientPersonOid = Convert.ToInt64(recipientPersonOidString);
ServerseitigeOid = Convert.ToInt64(serverseitigeOidString);
ClientseitigeOid = Convert.ToInt64(clientseitigeOidString);
IsEmployee = Convert.ToBoolean(isEmployeeString);
var chatNameLength = Convert.ToInt32(chatNameLengthString);
var chatMessageLength = Convert.ToInt32(chatMessageLengthString);
var headerLength = senderPersonOidString.Length + recipientPersonOidString.Length + chatNameLengthString.Length + chatMessageLengthString.Length + chatIdentifierString.Length + Tenant.Length + serverseitigeOidString.Length + clientseitigeOidString.Length + 9;
var headerLength = senderPersonOidString.Length + recipientPersonOidString.Length + chatNameLengthString.Length + chatMessageLengthString.Length + chatIdentifierString.Length + Tenant.Length + serverseitigeOidString.Length + clientseitigeOidString.Length + 10;
var actualMessage = message.Substring(headerLength - 1);
ClientName = actualMessage.Substring(0, chatNameLength);
@@ -99,7 +103,7 @@ namespace BS.Shared
{
var result = "";
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int) DataIdentifier + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (IsDelivered ? 1 : 0);
result += SenderPersonOid + ";" + RecipientPersonOid + ";" + ClientName.Length + ";" + ChatMessage.Length + ";" + (int) DataIdentifier + ";" + ServerseitigeOid + ";" + ClientseitigeOid + ";" + Tenant + ";" + (IsEmployee ? 1 : 0) + ";" + ClientName + ChatMessage + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (IsDelivered ? 1 : 0);
Debug.WriteLine("Verschicke Paket: " + result);
@@ -109,7 +113,7 @@ namespace BS.Shared
public byte[] GetDataStream(long senderPersonOid, long empfaengerPersonoid, string clientName, string message, DataIdentifier dataIdentifier, string tenant, bool isDelivered)
{
//Bewo Klient Speziallisiert
//Bewo-Client spezialisiert
var result = "";
result += senderPersonOid + ";" + empfaengerPersonoid + ";" + clientName.Length + ";" + message.Length + ";" + (int)dataIdentifier + ";" + 0 + ";" + 0 + ";" + tenant + ";" + clientName + message + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + "" + (isDelivered ? 1 : 0);