Icons für gesendete Dateien in der Kontaktliste als letzte Nachricht.
Text kann jetzt geteilt werden.
This commit is contained in:
@@ -34,8 +34,8 @@ android {
|
||||
applicationId "de.beyondsoft.ownchat"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 27
|
||||
versionCode 15
|
||||
versionName "1.15"
|
||||
versionCode 16
|
||||
versionName "1.16"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
}
|
||||
@@ -83,6 +83,9 @@ dependencies {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
|
||||
|
||||
implementation('com.github.bumptech.glide:glide:4.7.1') {
|
||||
exclude group: 'com.android.support'
|
||||
}
|
||||
@@ -109,7 +112,7 @@ dependencies {
|
||||
implementation 'de.hdodenhof:circleimageview:2.1.0'
|
||||
implementation 'com.scottyab:secure-preferences-lib:0.1.4'
|
||||
implementation 'com.google.firebase:firebase-messaging:17.0.0'
|
||||
implementation 'com.google.firebase:firebase-core:16.0.0'
|
||||
implementation 'com.google.firebase:firebase-core:16.0.1'
|
||||
implementation 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
|
||||
implementation 'com.github.lzyzsd:circleprogress:1.2.1'
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
|
||||
@@ -138,11 +138,26 @@
|
||||
android:label="ownChat"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/ChatStyle">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="image/*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="video/*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
@@ -8,19 +8,13 @@ import de.beyondsoft.ownchat.di.ApplicationModule;
|
||||
import de.beyondsoft.ownchat.di.DaggerApplicationComponent;
|
||||
import de.beyondsoft.ownchat.di.InjectionHelper;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.realm.Realm;
|
||||
|
||||
/**
|
||||
* Created by imarneanu on 2/9/17.
|
||||
*/
|
||||
public class BewoplanerApplication extends Application {
|
||||
public class BewoplanerApplication extends MultiDexApplication {
|
||||
|
||||
private ApplicationComponent mApplicationComponent;
|
||||
private static Context mContext;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package de.beyondsoft.ownchat.data;
|
||||
|
||||
/**
|
||||
* Created by imarneanu on 2/10/17.
|
||||
*/
|
||||
public interface AppPrefsConstants {
|
||||
String LOGIN_TOKEN = "login_token";
|
||||
String SAVE_PASSWORD = "save_password";
|
||||
@@ -25,4 +22,5 @@ public interface AppPrefsConstants {
|
||||
String VERIFY_CHAT_CODE_ERROR_MESSAGE = "verify_chat_code_error_message";
|
||||
String IS_COMING_FROM_SHARING_ACTIVITY = "is_coming_from_sharing_activity";
|
||||
String PATH_TO_FILE_TO_SHARE = "path_to_file_to_share";
|
||||
String IS_FILE = "is_file";
|
||||
}
|
||||
@@ -129,10 +129,6 @@ public class ApiModule {
|
||||
String writerAsString = writer.toString();
|
||||
String base64EncodedKey = writerAsString.split("-----BEGIN PUBLIC KEY-----")[1].split("-----END PUBLIC KEY-----")[0].replaceAll(System.getProperty("line.separator"), "");
|
||||
|
||||
if(name.contains("O=Let's Encrypt")) {
|
||||
Log.i(LOG_TAG_NETWORK_INTERCEPTOR, "\nSSL certificates:\nName: " + name + "\nSerial number: " + serialNumber + "\nUrl: " + url + "\nPublic key: " + base64EncodedKey + "\n" + writerAsString);
|
||||
}
|
||||
|
||||
if(name.contains("CN=Let's Encrypt Authority X3") && name.contains("O=Let's Encrypt") && (base64EncodedKey.equals(Constants.PUBLIC_KEY) || base64EncodedKey.equals(Constants.DICTIONARY_PUBLIC_KEY))) {
|
||||
isVerified = true;
|
||||
break;
|
||||
|
||||
@@ -62,6 +62,13 @@ public class AppPrefsModule {
|
||||
return new BooleanPreference(sharedPreferences, AppPrefsConstants.IS_COMING_FROM_SHARING_ACTIVITY);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
@Named(AppPrefsConstants.IS_FILE)
|
||||
BooleanPreference provideIsFile(@AppPrefs SecurePreferences sharedPreferences) {
|
||||
return new BooleanPreference(sharedPreferences, AppPrefsConstants.IS_FILE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
@Named(AppPrefsConstants.PATH_TO_FILE_TO_SHARE)
|
||||
|
||||
@@ -103,6 +103,9 @@ public interface ApplicationComponent {
|
||||
@Named(AppPrefsConstants.IS_COMING_FROM_SHARING_ACTIVITY)
|
||||
BooleanPreference provideIsComingFromSharingActivity();
|
||||
|
||||
@Named(AppPrefsConstants.IS_FILE)
|
||||
BooleanPreference provideIsFile();
|
||||
|
||||
NotificationManager provideNotificationManager();
|
||||
|
||||
GroupRealmRepository provideGroupRealmRepository();
|
||||
|
||||
@@ -5,7 +5,6 @@ import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.events.InvalidTokenEvent;
|
||||
import de.beyondsoft.ownchat.data.events.LogoutDirectlyEvent;
|
||||
import de.beyondsoft.ownchat.data.firebase.NotificationUtils;
|
||||
import de.beyondsoft.ownchat.data.prefs.BooleanPreference;
|
||||
import de.beyondsoft.ownchat.data.prefs.LongPreference;
|
||||
import de.beyondsoft.ownchat.data.prefs.StringPreference;
|
||||
@@ -34,7 +33,7 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.media.MediaRecorder;
|
||||
@@ -62,6 +61,7 @@ import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -85,9 +85,6 @@ import hani.momanii.supernova_emoji_library.Actions.EmojIconActions;
|
||||
import hani.momanii.supernova_emoji_library.Helper.EmojiconEditText;
|
||||
import okhttp3.MediaType;
|
||||
|
||||
/**
|
||||
* Created by Rares Teodorescu on 21/02/2017.
|
||||
*/
|
||||
abstract class BaseChatActivity extends RuntimePermissionActivity implements ChatView, BaseChatAdapter.MessageClickListener, LogoutNavigation {
|
||||
|
||||
private final static int STORAGE_REQUEST_CODE = 9999;
|
||||
@@ -156,6 +153,10 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
@Named(AppPrefsConstants.IS_COMING_FROM_SHARING_ACTIVITY)
|
||||
BooleanPreference mIsComingFromSharingActivity;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.IS_FILE)
|
||||
BooleanPreference mIsFile;
|
||||
|
||||
protected Group mGroup;
|
||||
protected ChatView.Callback mCallback;
|
||||
protected EndlessScrollListener mEndlessScrollListener;
|
||||
@@ -254,25 +255,30 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
mBaseChatAdapter.addMessages(messages);
|
||||
}
|
||||
|
||||
private void shareFile() {
|
||||
private void shareFile(boolean isFile) {
|
||||
mIsComingFromSharingActivity.set(false);
|
||||
|
||||
String path = mSelectedFilePath.get();
|
||||
|
||||
final Uri uri = Uri.parse(path);
|
||||
final File file = FileUtils.getFile(this, uri);
|
||||
String filePath = file.getPath();
|
||||
String filePath = null;
|
||||
|
||||
mSelectedFilePath.delete();
|
||||
if(isFile) {
|
||||
final Uri uri = Uri.parse(path);
|
||||
final File file = FileUtils.getFile(this, uri);
|
||||
filePath = file.getPath();
|
||||
|
||||
if(Build.VERSION.SDK_INT >= 19) {
|
||||
final int takeFlags = (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
mSelectedFilePath.delete();
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
if(Build.VERSION.SDK_INT >= 19) {
|
||||
final int takeFlags = (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("BASE_CHAT_ACTIVITY", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +287,11 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.FILENAME, filePath);
|
||||
if(isFile) {
|
||||
bundle.putString(Constants.FILENAME, filePath);
|
||||
} else {
|
||||
bundle.putString(Constants.TEXT_TO_SHARE, path);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(this, FileConfirmationActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
@@ -322,7 +332,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
mBaseChatAdapter.setLoading(false);
|
||||
|
||||
if(mIsComingFromSharingActivity.get()) {
|
||||
shareFile();
|
||||
shareFile(mIsFile.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +411,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
final long duration = ((mUploadMaxSize.get() / 10 * 9) * 8) / (Constants.RECORDING_BIT_RATE_IN_MS / 1000); // 10% Overhead
|
||||
final long duration = ((mUploadMaxSize.get() / 10 * 9) * 8) / (Constants.RECORDING_BIT_RATE_IN_MS / 1000); // 10% overhead
|
||||
CountDownTimer countDownTimer = new CountDownTimer(duration, 10) {
|
||||
@Override
|
||||
public void onTick(long millisecondsUntilFinished) {
|
||||
@@ -567,50 +577,62 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> var1 = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA);
|
||||
ArrayList<String> var2 = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS);
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
if((requestCode == SELECT_IMAGE_FILE || requestCode == SELECT_DOC_FILE) && ((var1 != null && var1.size() > 0) || (var2 != null && var2.size() > 0))) {
|
||||
String filePath = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA) != null ?
|
||||
data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA).get(0) :
|
||||
data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS).get(0);
|
||||
if(data.hasExtra(Constants.TEXT_TO_SHARE)) {
|
||||
String textToShare = data.getStringExtra(Constants.TEXT_TO_SHARE);
|
||||
String textToDisplay = textToShare != null ? textToShare + " " : "";
|
||||
|
||||
final Uri uri = Uri.fromFile(new File(filePath));
|
||||
mChatMessageEmojiEditText.setText(textToDisplay);
|
||||
mChatMessageEmojiEditText.requestFocus();
|
||||
mChatMessageEmojiEditText.setSelection(mChatMessageEmojiEditText.getText().length());
|
||||
|
||||
if(Build.VERSION.SDK_INT >= 19) {
|
||||
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if(inputMethodManager != null) {
|
||||
inputMethodManager.showSoftInput(mChatMessageEmojiEditText, InputMethodManager.SHOW_FORCED);
|
||||
}
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} else {
|
||||
ArrayList<String> var1 = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA);
|
||||
ArrayList<String> var2 = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS);
|
||||
|
||||
if((requestCode == SELECT_IMAGE_FILE || requestCode == SELECT_DOC_FILE) && ((var1 != null && var1.size() > 0) || (var2 != null && var2.size() > 0))) {
|
||||
String filePath = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA) != null ?
|
||||
data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA).get(0) :
|
||||
data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS).get(0);
|
||||
|
||||
final Uri uri = Uri.fromFile(new File(filePath));
|
||||
|
||||
if(Build.VERSION.SDK_INT >= 19) {
|
||||
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.FILENAME, filePath);
|
||||
|
||||
Intent intent = new Intent(this, FileConfirmationActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
|
||||
intent.putExtra(Constants.EXTRA_GROUP, mGroup);
|
||||
|
||||
startActivityForResult(intent, 666);
|
||||
}
|
||||
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.FILENAME, filePath);
|
||||
|
||||
Intent intent = new Intent(this, FileConfirmationActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
|
||||
intent.putExtra(Constants.EXTRA_GROUP, mGroup);
|
||||
|
||||
startActivityForResult(intent, 666);
|
||||
}
|
||||
|
||||
if(requestCode == CONFIRM_FILE) {
|
||||
String filePath = data.getStringExtra(Constants.FILE_PATH);
|
||||
String fileMessageText = data.getStringExtra(Constants.FILE_MESSAGE_TEXT);
|
||||
|
||||
if(!mChatPresenter.isAttached()) {
|
||||
mChatPresenter.attachView(this);
|
||||
}
|
||||
|
||||
mCallback.sendFile(Uri.fromFile(new File(filePath)), fileMessageText);
|
||||
}
|
||||
}
|
||||
@@ -706,7 +728,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(uri, fileType);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
// Verify the original intent will resolve to at least one activity
|
||||
|
||||
if(intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
|
||||
@@ -87,12 +87,12 @@ public class SingleChatActivity extends BaseChatActivity {
|
||||
|
||||
@Override
|
||||
protected void loadMessages() {
|
||||
if (!TextUtils.isEmpty(mGroup.mobile)) {
|
||||
if(!TextUtils.isEmpty(mGroup.mobile)) {
|
||||
mExtraImageView.setVisibility(View.VISIBLE);
|
||||
mExtraImageView.setImageResource(de.beyondsoft.ownchat.R.drawable.call);
|
||||
}
|
||||
|
||||
if (mSystemUtils.isNetworkUnavailable()) {
|
||||
if(mSystemUtils.isNetworkUnavailable()) {
|
||||
mCallback.loadMessagesFromDBByGroupId(mGroup.id, true);
|
||||
showError(de.beyondsoft.ownchat.R.string.error_no_internet_connection);
|
||||
} else {
|
||||
@@ -106,7 +106,7 @@ public class SingleChatActivity extends BaseChatActivity {
|
||||
mSingleChatTitleTextView.setText(mGroup.name);
|
||||
mSingleChatTitleTextView.setTextColor(ContextCompat.getColor(this, mGroup.onlyEmployees ? de.beyondsoft.ownchat.R.color.colorBlack : de.beyondsoft.ownchat.R.color.colorHelpGroup));
|
||||
|
||||
if (TextUtils.isEmpty(mGroup.avatar)) {
|
||||
if(TextUtils.isEmpty(mGroup.avatar)) {
|
||||
mChatImageView.setImageResource(mGroup.onlyEmployees ? de.beyondsoft.ownchat.R.drawable.avatar : R.drawable.avatar_help);
|
||||
} else {
|
||||
GlideApp.with(this)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.beyondsoft.ownchat.page.contacts;
|
||||
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.filepicker.utils.FileUtils;
|
||||
import de.beyondsoft.ownchat.model.Group;
|
||||
import de.beyondsoft.ownchat.utils.DateUtils;
|
||||
import de.beyondsoft.ownchat.utils.ui.GlideApp;
|
||||
@@ -53,7 +54,7 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
void setGroups(ArrayList<Group> groups) {
|
||||
mGroups.clear();
|
||||
|
||||
if (groups != null) {
|
||||
if(groups != null) {
|
||||
mGroups.addAll(groups);
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
@Override
|
||||
public final int getItemViewType(int position) {
|
||||
if (mGroups.get(position).users.size() > 2) {
|
||||
if(mGroups.get(position).users.size() > 2) {
|
||||
return GROUP_TYPE;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
int type = getItemViewType(position);
|
||||
|
||||
if (type == GROUP_TYPE) {
|
||||
if(type == GROUP_TYPE) {
|
||||
viewHolder.name.setText(group.name);
|
||||
viewHolder.name.setTextColor(ContextCompat.getColor(viewHolder.name.getContext(), group.isHelpGroup() ? R.color.colorHelpGroup : R.color.colorTeamGroup));
|
||||
viewHolder.avatar.setImageResource(group.isHelpGroup() ? R.drawable.avatar_help_group : R.drawable.avatar_team_group);
|
||||
@@ -109,7 +110,7 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
}
|
||||
|
||||
private void setLastMessage(Group group, ContactViewHolder viewHolder) {
|
||||
if (group.lastMessage == null) {
|
||||
if(group.lastMessage == null) {
|
||||
viewHolder.lastMessage.setText(null);
|
||||
viewHolder.messageTimestamp.setText(null);
|
||||
viewHolder.messageStatus.setImageResource(0);
|
||||
@@ -118,7 +119,7 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
boolean isMessageSentByUser = group.lastMessage.senderId == mUserId;
|
||||
|
||||
if (!group.isRead() && !isMessageSentByUser) {
|
||||
if(!group.isRead() && !isMessageSentByUser) {
|
||||
viewHolder.lastMessage.setTypeface(null, Typeface.BOLD);
|
||||
viewHolder.lastMessage.setTextColor(ContextCompat.getColor(viewHolder.lastMessage.getContext(), R.color.colorDefaultBright));
|
||||
} else {
|
||||
@@ -129,17 +130,49 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
viewHolder.lastMessage.setText(TextUtils.isEmpty(group.lastMessage.message) ? group.lastMessage.originalFilename : group.lastMessage.message);
|
||||
viewHolder.messageTimestamp.setText(DateUtils.toHourOrDateFormatHour(group.lastMessage.createdAt));
|
||||
|
||||
if (!isMessageSentByUser) {
|
||||
viewHolder.attachmentIcon.setVisibility(View.GONE);
|
||||
|
||||
if(group.lastMessage != null && group.lastMessage.filePath != null && group.lastMessage.filePath.length() > 0) {
|
||||
String fileType = de.beyondsoft.ownchat.utils.FileUtils.getFileTypeFromFilePath(group.lastMessage.filePath);
|
||||
String messageText;
|
||||
|
||||
if(fileType.contains("image")) {
|
||||
if(fileType.contains("gif")) {
|
||||
viewHolder.attachmentIcon.setImageResource(R.drawable.ic_gif_24px);
|
||||
messageText = viewHolder.lastMessage.getContext().getString(R.string.attachment_gif);
|
||||
} else {
|
||||
viewHolder.attachmentIcon.setImageResource(R.drawable.camera_24px);
|
||||
messageText = viewHolder.lastMessage.getContext().getString(R.string.attachment_image);
|
||||
}
|
||||
} else if(fileType.contains("video")) {
|
||||
viewHolder.attachmentIcon.setImageResource(R.drawable.videocam_24px);
|
||||
messageText = viewHolder.lastMessage.getContext().getString(R.string.attachment_video);
|
||||
} else if(fileType.contains("audio")) {
|
||||
viewHolder.attachmentIcon.setImageResource(R.drawable.headset_24px);
|
||||
messageText = viewHolder.lastMessage.getContext().getString(R.string.attachment_audio);
|
||||
} else {
|
||||
viewHolder.attachmentIcon.setImageResource(R.drawable.attachment_file_24px);
|
||||
messageText = viewHolder.lastMessage.getContext().getString(R.string.attachment_document);
|
||||
}
|
||||
|
||||
viewHolder.attachmentIcon.setVisibility(View.VISIBLE);
|
||||
|
||||
if(group.lastMessage.message == null || group.lastMessage.message.length() == 0) {
|
||||
viewHolder.lastMessage.setText(messageText);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isMessageSentByUser) {
|
||||
viewHolder.messageStatus.setImageResource(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int resourceId = group.lastMessage.getStatusResourceId();
|
||||
|
||||
if (resourceId != 0) {
|
||||
if(resourceId != 0) {
|
||||
viewHolder.messageStatusPending.setVisibility(resourceId == -1 ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (resourceId != -1) {
|
||||
if(resourceId != -1) {
|
||||
viewHolder.messageStatus.setImageResource(group.lastMessage.getStatusResourceId());
|
||||
} else {
|
||||
ViewUtils.setProgressBarColor(viewHolder.messageStatusPending, R.color.colorHint);
|
||||
@@ -171,6 +204,9 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
@BindView(R.id.contact_message_pending)
|
||||
ProgressBar messageStatusPending;
|
||||
|
||||
@BindView(R.id.attachmentImageView)
|
||||
ImageView attachmentIcon;
|
||||
|
||||
ContactViewHolder(View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
@@ -185,7 +221,7 @@ class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == GROUP_TYPE) {
|
||||
if(type == GROUP_TYPE) {
|
||||
mItemClickListener.onOpenGroupMessage(mGroups.get(getAdapterPosition()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ public class FileConfirmationActivity extends AppCompatActivity implements FileC
|
||||
|
||||
private Uri mSelectedUri;
|
||||
private Group mGroup;
|
||||
private String mSelectedString;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -93,37 +94,48 @@ public class FileConfirmationActivity extends AppCompatActivity implements FileC
|
||||
EmojIconActions emojiIcon = new EmojIconActions(this, mRelativeLayout, mMessageEmojiconEditText, mEmojiButtonImageView);
|
||||
emojiIcon.ShowEmojIcon();
|
||||
|
||||
String fileUri = getIntent().getStringExtra(Constants.FILENAME);
|
||||
|
||||
mSelectedUri = Uri.parse(fileUri);
|
||||
|
||||
ViewUtils.setProgressBarColor(statusProgressBar, R.color.colorDefault);
|
||||
|
||||
showLoading();
|
||||
|
||||
GlideApp.with(this)
|
||||
.load(fileUri)
|
||||
.placeholder(R.drawable.document)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
hideLoading();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
hideLoading();
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(new DrawableImageViewTarget(mFileImageView));
|
||||
|
||||
mGroup = getIntent().getParcelableExtra(Constants.EXTRA_GROUP);
|
||||
|
||||
setToolBar();
|
||||
|
||||
if(getIntent().hasExtra(Constants.TEXT_TO_SHARE)) {
|
||||
String textToShare = getIntent().getStringExtra(Constants.TEXT_TO_SHARE);
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Constants.TEXT_TO_SHARE, textToShare);
|
||||
|
||||
setResult(-1, intent);
|
||||
finish();
|
||||
} else {
|
||||
String fileUri = getIntent().getStringExtra(Constants.FILENAME);
|
||||
|
||||
mSelectedUri = Uri.parse(fileUri);
|
||||
|
||||
ViewUtils.setProgressBarColor(statusProgressBar, R.color.colorDefault);
|
||||
|
||||
showLoading();
|
||||
|
||||
GlideApp.with(this)
|
||||
.load(fileUri)
|
||||
.placeholder(R.drawable.document)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
hideLoading();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
hideLoading();
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(new DrawableImageViewTarget(mFileImageView));
|
||||
}
|
||||
}
|
||||
|
||||
private void setToolBar() {
|
||||
@@ -147,7 +159,7 @@ public class FileConfirmationActivity extends AppCompatActivity implements FileC
|
||||
mSingleChatTitleTextView.setText(mGroup.name);
|
||||
mSingleChatTitleTextView.setTextColor(ContextCompat.getColor(this, mGroup.onlyEmployees ? de.beyondsoft.ownchat.R.color.colorBlack : de.beyondsoft.ownchat.R.color.colorHelpGroup));
|
||||
|
||||
if (TextUtils.isEmpty(mGroup.avatar)) {
|
||||
if(TextUtils.isEmpty(mGroup.avatar)) {
|
||||
mChatImageView.setImageResource(mGroup.onlyEmployees ? de.beyondsoft.ownchat.R.drawable.avatar : R.drawable.avatar_help);
|
||||
} else {
|
||||
GlideApp.with(this)
|
||||
@@ -163,7 +175,10 @@ public class FileConfirmationActivity extends AppCompatActivity implements FileC
|
||||
void sendFile() {
|
||||
Intent intent = new Intent();
|
||||
|
||||
intent.putExtra(Constants.FILE_PATH, mSelectedUri.toString());
|
||||
if(mSelectedUri != null) {
|
||||
intent.putExtra(Constants.FILE_PATH, mSelectedUri.toString());
|
||||
}
|
||||
|
||||
intent.putExtra(Constants.FILE_MESSAGE_TEXT, mMessageEmojiconEditText.getText().toString());
|
||||
|
||||
setResult(-1, intent);
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -37,11 +38,9 @@ import de.beyondsoft.ownchat.utils.Constants;
|
||||
import de.beyondsoft.ownchat.utils.ui.EmptyLayout;
|
||||
import de.beyondsoft.ownchat.utils.ui.HorizontalDividerItemDecoration;
|
||||
|
||||
/**
|
||||
* Created by Lyndon on 03-Nov-2017.
|
||||
*/
|
||||
|
||||
public class SharingActivity extends RuntimePermissionActivity implements SharingView, SharingContactsAdapter.OnOpenClickListener {
|
||||
private static String LOG_TAG = "SHARING_ACTIVITY";
|
||||
|
||||
@Inject
|
||||
SharingPresenter mSharingPresenter;
|
||||
|
||||
@@ -69,6 +68,10 @@ public class SharingActivity extends RuntimePermissionActivity implements Sharin
|
||||
@Named(AppPrefsConstants.IS_COMING_FROM_SHARING_ACTIVITY)
|
||||
BooleanPreference mIsComingFromSharingActivity;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.IS_FILE)
|
||||
BooleanPreference mIsFile;
|
||||
|
||||
private SharingView.Callback mCallback;
|
||||
private SharingContactsAdapter mContactsAdapter;
|
||||
private Snackbar mSnackbar;
|
||||
@@ -89,10 +92,7 @@ public class SharingActivity extends RuntimePermissionActivity implements Sharin
|
||||
|
||||
mIntent = getIntent();
|
||||
|
||||
requestAppPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
R.string.permission_storage_explained,
|
||||
777,
|
||||
this::shareFile);
|
||||
requestAppPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, R.string.permission_storage_explained, 777, this::shareFile);
|
||||
}
|
||||
|
||||
private void returnToContactList(int requestCode) {
|
||||
@@ -112,8 +112,44 @@ public class SharingActivity extends RuntimePermissionActivity implements Sharin
|
||||
String action = mIntent.getAction();
|
||||
String type = mIntent.getType();
|
||||
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
handleSendFile(mIntent);
|
||||
Log.i(LOG_TAG, "action equals ACTION_SEND: " + Intent.ACTION_SEND.equals(action) + "; type: " + type);
|
||||
|
||||
if(Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if("text/plain".equals(type)) {
|
||||
handleSendText(mIntent);
|
||||
} else if(type.startsWith("image/") || type.startsWith("video") || type.startsWith("audio")) {
|
||||
handleSendFile(mIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleSendFile(Intent intent) {
|
||||
Uri fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
|
||||
if(fileUri != null) {
|
||||
mSelectedFilePath.set(fileUri.toString());
|
||||
mIsComingFromSharingActivity.set(true);
|
||||
mIsFile.set(true);
|
||||
|
||||
if(!mLoginTokenPreference.isSet()) {
|
||||
startActivity(new Intent(this, LoginActivity.class));
|
||||
finishAffinity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleSendText(Intent intent) {
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
|
||||
if(sharedText != null) {
|
||||
mSelectedFilePath.set(sharedText);
|
||||
mIsComingFromSharingActivity.set(true);
|
||||
mIsFile.set(false);
|
||||
|
||||
if(!mLoginTokenPreference.isSet()) {
|
||||
startActivity(new Intent(this, LoginActivity.class));
|
||||
finishAffinity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,20 +158,6 @@ public class SharingActivity extends RuntimePermissionActivity implements Sharin
|
||||
mSingleChatTitleTextView.setText(R.string.sharing_title);
|
||||
}
|
||||
|
||||
void handleSendFile(Intent intent) {
|
||||
Uri fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
|
||||
if (fileUri != null) {
|
||||
mSelectedFilePath.set(fileUri.toString());
|
||||
mIsComingFromSharingActivity.set(true);
|
||||
|
||||
if (!mLoginTokenPreference.isSet()) {
|
||||
startActivity(new Intent(this, LoginActivity.class));
|
||||
finishAffinity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -145,7 +167,7 @@ public class SharingActivity extends RuntimePermissionActivity implements Sharin
|
||||
|
||||
@Override
|
||||
public void showError(@StringRes int message) {
|
||||
if (mSnackbar == null) {
|
||||
if(mSnackbar == null) {
|
||||
mSnackbar = Snackbar.make(mCoordinatorLayout, message, Snackbar.LENGTH_LONG);
|
||||
mSnackbar.setActionTextColor(ContextCompat.getColor(this, R.color.colorDefault));
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public interface Constants {
|
||||
|
||||
int RECORDING_BIT_RATE_IN_MS = 32000;
|
||||
|
||||
String TEXT_TO_SHARE = "text_to_share";
|
||||
|
||||
String LOG_TAG_NETWORK_INTERCEPTOR = "NETWORK_INTERCEPTOR";
|
||||
String LOG_TAG_FILE_PICKER = "FILE_PICKER";
|
||||
|
||||
|
||||
@@ -1165,8 +1165,7 @@ public class FileUtils {
|
||||
} else if (extension.contains("txt")) {
|
||||
// Text file
|
||||
extension = "text/plain";
|
||||
} else if (extension.contains("3gp") || extension.contains("mpg") ||
|
||||
extension.contains("mpeg") || extension.contains("mpe") || extension.contains("mp4") || extension.contains("avi")) {
|
||||
} else if (extension.contains("3gp") || extension.contains("mpg") || extension.contains("mpeg") || extension.contains("mpe") || extension.contains("mp4") || extension.contains("avi")) {
|
||||
// Video files
|
||||
extension = "video/*";
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M14,2L6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6zM16,18L8,18v-2h8v2zM16,14L8,14v-2h8v2zM13,9L13,3.5L18.5,9L13,9z"
|
||||
android:fillColor="#9B9B9B"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"
|
||||
android:fillColor="#9B9B9B"/>
|
||||
<path
|
||||
android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"
|
||||
android:fillColor="#9B9B9B"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,1c-4.97,0 -9,4.03 -9,9v7c0,1.66 1.34,3 3,3h3v-8H5v-2c0,-3.87 3.13,-7 7,-7s7,3.13 7,7v2h-4v8h3c1.66,0 3,-1.34 3,-3v-7c0,-4.97 -4.03,-9 -9,-9z"
|
||||
android:fillColor="#9B9B9B"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<group>
|
||||
<clip-path android:pathData="M24,24H0V0h24v24z M 0,0"/>
|
||||
<path
|
||||
android:pathData="M11.5 9H13v6h-1.5zM9 9H6c-.6 0,-1 .5,-1 1v4c0 .5.4 1 1 1h3c.6 0 1,-.5 1,-1v-2H8.5v1.5h-2v-3H10V10c0,-.5,-.4,-1,-1,-1zm10 1.5V9h-4.5v6H16v-2h2v-1.5h-2v-1z"
|
||||
android:fillColor="#515151"/>
|
||||
</group>
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M17,10.5V7c0,-0.55 -0.45,-1 -1,-1H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1v-3.5l4,4v-11l-4,4z"
|
||||
android:fillColor="#9B9B9B"/>
|
||||
</vector>
|
||||
@@ -14,7 +14,6 @@
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginEnd="@dimen/item_contact_avatar_padding"
|
||||
android:layout_marginRight="@dimen/item_contact_avatar_padding"
|
||||
android:contentDescription="@null"
|
||||
tools:src="@drawable/avatar_list" />
|
||||
|
||||
@@ -32,12 +31,32 @@
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Sasha Grey" />
|
||||
|
||||
<hani.momanii.supernova_emoji_library.Helper.EmojiconTextView
|
||||
android:id="@+id/contact_message_last"
|
||||
style="@style/AppTheme.ListSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Great! My problem is that whenever I have..." />
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/attachmentImageView"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/videocam_24px"
|
||||
android:visibility="gone"
|
||||
android:layout_marginEnd="3dp"
|
||||
/>
|
||||
|
||||
<hani.momanii.supernova_emoji_library.Helper.EmojiconTextView
|
||||
android:id="@+id/contact_message_last"
|
||||
style="@style/AppTheme.ListSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Great! My problem is that whenever I have..."
|
||||
tools:textColor="@color/colorBlack"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -91,5 +91,10 @@
|
||||
|
||||
<string name="default_notification_channel_id">de.beyondsoft.ownchat.notification_channel</string>
|
||||
<string name="default_notification_channel_name">ownChat notification channel</string>
|
||||
<string name="attachment_image">Bild</string>
|
||||
<string name="attachment_video">Video</string>
|
||||
<string name="attachment_audio">Audiodatei</string>
|
||||
<string name="attachment_document">Dokument</string>
|
||||
<string name="attachment_gif">Gif</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user