Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/Chat
This commit is contained in:
@@ -114,6 +114,7 @@ dependencies {
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
|
||||
provided 'javax.annotation:jsr250-api:1.0'
|
||||
implementation files('libs/sanselan-0_97-android-1.0.0.jar')
|
||||
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
|
||||
}
|
||||
|
||||
task adp2upload(type: Exec, dependsOn: "build") {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:launchMode="singleInstance"
|
||||
android:name="de.beyondsoft.ownchat.page.splash.SplashActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.FullBackground">
|
||||
@@ -27,8 +26,8 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:launchMode="singleInstance"
|
||||
android:name="de.beyondsoft.ownchat.page.login.LoginActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.FullBackground" />
|
||||
@@ -69,7 +68,8 @@
|
||||
android:name="io.fabric.ApiKey"
|
||||
android:value="1dcc8d0ead50f1b328778876834fea3392c6fc22" />
|
||||
|
||||
<service android:name="de.beyondsoft.ownchat.data.firebase.MessagingInstanceIdService">
|
||||
<service android:name="de.beyondsoft.ownchat.data.firebase.MessagingInstanceIdService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
|
||||
</intent-filter>
|
||||
@@ -77,12 +77,19 @@
|
||||
<service
|
||||
android:name="de.beyondsoft.ownchat.utils.AppStoppedService"
|
||||
android:stopWithTask="false" />
|
||||
<service android:name="de.beyondsoft.ownchat.data.firebase.HandleMessagesService">
|
||||
<service
|
||||
android:name="de.beyondsoft.ownchat.data.firebase.HandleMessagesService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||
android:value="@string/default_notification_channel_id"
|
||||
/>
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
|
||||
@@ -8,6 +8,11 @@ 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.content.ContextWrapper;
|
||||
import android.os.Build;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.realm.Realm;
|
||||
@@ -31,6 +36,18 @@ public class BewoplanerApplication extends Application {
|
||||
|
||||
buildGraphAndInject();
|
||||
MessagingInstanceIdService.setApplicationContext(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
String channelId = getString(R.string.default_notification_channel_id);
|
||||
|
||||
if(manager != null && manager.getNotificationChannel(channelId) == null) {
|
||||
NotificationChannel channel = new NotificationChannel(channelId, getString(R.string.default_notification_channel_id), NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription(getString(R.string.default_notification_channel_id));
|
||||
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildGraphAndInject() {
|
||||
|
||||
@@ -144,7 +144,7 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
bitmapToDisplay = BitmapFactory.decodeResource(context.getResources(), R.drawable.avatar);
|
||||
}
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, getString(R.string.default_notification_channel_id))
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setContentTitle(setNotificationTitle(message, message.numberOfGroupUsers))
|
||||
.setContentText(getTextFromNotification(message))
|
||||
@@ -180,6 +180,7 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
false,
|
||||
mUserIdReference.get(),
|
||||
false);
|
||||
|
||||
storeMessageLocally(message);
|
||||
storeGroupLocally(groupId, message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.beyondsoft.ownchat.data.firebase;
|
||||
|
||||
import de.beyondsoft.ownchat.BewoplanerApplication;
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.api.common.ErrorHandlingResponseConverter;
|
||||
@@ -99,7 +100,7 @@ public class ReplyNotificationReceiver extends BroadcastReceiver {
|
||||
|
||||
private void updateNotificationOnReply(Context context, String replyMessage, int groupId) {
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "ownChat")
|
||||
.setSmallIcon(HandleMessagesService.getNotificationIcon())
|
||||
.setColor(ContextCompat.getColor(context, R.color.colorDefaultBright))
|
||||
.setContentTitle(context.getResources().getString(R.string.chat_you_name))
|
||||
|
||||
@@ -228,10 +228,12 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
mBaseChatAdapter.addMessages(messages);
|
||||
}
|
||||
|
||||
private void shareFile(int requestCode) {
|
||||
private void shareFile() {
|
||||
mIsComingFromSharingActivity.set(false);
|
||||
|
||||
final Uri uri = Uri.parse(mSelectedFilePath.get());
|
||||
String path = mSelectedFilePath.get();
|
||||
|
||||
final Uri uri = Uri.parse(path);
|
||||
final File file = FileUtils.getFile(this, uri);
|
||||
String filePath = file.getPath();
|
||||
|
||||
@@ -294,10 +296,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
mBaseChatAdapter.setLoading(false);
|
||||
|
||||
if(mIsComingFromSharingActivity.get()) {
|
||||
requestAppPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
R.string.permission_storage_explained,
|
||||
STORAGE_REQUEST_CODE,
|
||||
this::shareFile);
|
||||
shareFile();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,6 +622,25 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
mIsComingFromSharingActivity.set(false);
|
||||
mSelectedFilePath.delete();
|
||||
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
boolean test = intent.getBooleanExtra("TEST_EXTRA", false);
|
||||
|
||||
if(test) {
|
||||
Group group = intent.getParcelableExtra(GROUP_ARG);
|
||||
|
||||
if(group != null) {
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
super.onNewIntent(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package de.beyondsoft.ownchat.page.common;
|
||||
|
||||
/**
|
||||
* Created by Lyndon on 06-Nov-2017.
|
||||
*/
|
||||
|
||||
public interface PermissionDeniedListener {
|
||||
void onPermissionDenied(int requestCode);
|
||||
}
|
||||
@@ -26,6 +26,7 @@ public abstract class RuntimePermissionActivity extends AppCompatActivity {
|
||||
|
||||
private SparseIntArray mErrorString;
|
||||
private PermissionGrantedListener mPermissionGrantedListener;
|
||||
private PermissionDeniedListener mPermissionDeniedListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -69,6 +70,45 @@ public abstract class RuntimePermissionActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void requestAppPermissions(final String[] requestedPermissions,
|
||||
final int stringId,
|
||||
final int requestCode,
|
||||
@NonNull PermissionGrantedListener permissionGrantedListener,
|
||||
@NonNull PermissionDeniedListener permissionDeniedListener) {
|
||||
mPermissionGrantedListener = permissionGrantedListener;
|
||||
mPermissionDeniedListener = permissionDeniedListener;
|
||||
|
||||
mErrorString.put(requestCode, stringId);
|
||||
|
||||
int permissionCheck = PackageManager.PERMISSION_GRANTED;
|
||||
boolean shouldShowRequestPermissionRationale = false;
|
||||
|
||||
for (String permission : requestedPermissions) {
|
||||
permissionCheck = permissionCheck + ContextCompat.checkSelfPermission(this, permission);
|
||||
shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale || ActivityCompat.shouldShowRequestPermissionRationale(this, permission);
|
||||
}
|
||||
|
||||
// if(permissionCheck == PackageManager.PERMISSION_DENIED) {
|
||||
// mPermissionDeniedListener.onPermissionDenied(requestCode);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
|
||||
if (shouldShowRequestPermissionRationale) {
|
||||
Dialog dialog = DialogHandler.createNoTitleDialog(this,
|
||||
stringId,
|
||||
true,
|
||||
R.string.permission_grant,
|
||||
(dialogInterface, i) -> requestPermissionCorrectly(requestedPermissions, requestCode));
|
||||
dialog.show();
|
||||
} else {
|
||||
requestPermissionCorrectly(requestedPermissions, requestCode);
|
||||
}
|
||||
} else {
|
||||
mPermissionGrantedListener.onPermissionsGranted(requestCode);
|
||||
}
|
||||
}
|
||||
|
||||
protected void requestPermissionCorrectly(String[] requestedPermissions, int requestCode) {
|
||||
ActivityCompat.requestPermissions(this, requestedPermissions, requestCode);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
||||
|
||||
import butterknife.OnClick;
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.prefs.BooleanPreference;
|
||||
import de.beyondsoft.ownchat.data.prefs.StringPreference;
|
||||
import de.beyondsoft.ownchat.di.InjectionHelper;
|
||||
import de.beyondsoft.ownchat.model.Group;
|
||||
import de.beyondsoft.ownchat.utils.Constants;
|
||||
@@ -27,6 +30,7 @@ import de.beyondsoft.ownchat.utils.FileUtils;
|
||||
import java.io.File;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -172,8 +176,4 @@ public class FileConfirmationActivity extends AppCompatActivity implements FileC
|
||||
public void showError(String message) {
|
||||
|
||||
}
|
||||
|
||||
public File getFile(Uri fileUri) {
|
||||
return FileUtils.getFile(this, fileUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
|
||||
@@ -47,7 +47,6 @@ import io.realm.Realm;
|
||||
import rx.Observable;
|
||||
import rx.Subscriber;
|
||||
import rx.Subscription;
|
||||
import rx.functions.Func1;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,6 @@ import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.beyondsoft.ownchat.page.sharing;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -12,6 +13,7 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -21,6 +23,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.prefs.BooleanPreference;
|
||||
@@ -30,7 +33,10 @@ import de.beyondsoft.ownchat.di.InjectionHelper;
|
||||
import de.beyondsoft.ownchat.model.Group;
|
||||
import de.beyondsoft.ownchat.page.chat.GroupChatActivity;
|
||||
import de.beyondsoft.ownchat.page.chat.SingleChatActivity;
|
||||
import de.beyondsoft.ownchat.page.common.RuntimePermissionActivity;
|
||||
import de.beyondsoft.ownchat.page.contacts.ContactsFragment;
|
||||
import de.beyondsoft.ownchat.page.login.LoginActivity;
|
||||
import de.beyondsoft.ownchat.page.main.MainActivity;
|
||||
import de.beyondsoft.ownchat.utils.ui.EmptyLayout;
|
||||
import de.beyondsoft.ownchat.utils.ui.HorizontalDividerItemDecoration;
|
||||
|
||||
@@ -38,7 +44,7 @@ import de.beyondsoft.ownchat.utils.ui.HorizontalDividerItemDecoration;
|
||||
* Created by Lyndon on 03-Nov-2017.
|
||||
*/
|
||||
|
||||
public class SharingActivity extends AppCompatActivity implements SharingView, SharingContactsAdapter.OnOpenClickListener {
|
||||
public class SharingActivity extends RuntimePermissionActivity implements SharingView, SharingContactsAdapter.OnOpenClickListener {
|
||||
@Inject
|
||||
SharingPresenter mSharingPresenter;
|
||||
|
||||
@@ -46,10 +52,6 @@ public class SharingActivity extends AppCompatActivity implements SharingView, S
|
||||
@Named(AppPrefsConstants.LOGIN_TOKEN)
|
||||
StringPreference mLoginTokenPreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.USER_ID)
|
||||
LongPreference mUserIdPreference;
|
||||
|
||||
@BindView(R.id.sharing_contacts_recycler_view)
|
||||
RecyclerView mContactsRecyclerView;
|
||||
|
||||
@@ -73,9 +75,10 @@ public class SharingActivity extends AppCompatActivity implements SharingView, S
|
||||
private SharingView.Callback mCallback;
|
||||
private SharingContactsAdapter mContactsAdapter;
|
||||
private Snackbar mSnackbar;
|
||||
private Intent mIntent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_sharing);
|
||||
@@ -85,20 +88,35 @@ public class SharingActivity extends AppCompatActivity implements SharingView, S
|
||||
|
||||
mSharingPresenter.attachView(this);
|
||||
|
||||
setToolBar();
|
||||
|
||||
mIntent = getIntent();
|
||||
|
||||
requestAppPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
R.string.permission_storage_explained,
|
||||
777,
|
||||
this::shareFile);
|
||||
}
|
||||
|
||||
private void returnToContactList(int requestCode) {
|
||||
mSelectedFilePath.delete();
|
||||
mIsComingFromSharingActivity.set(false);
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
finishAffinity();
|
||||
}
|
||||
|
||||
private void shareFile(int requestCode) {
|
||||
mContactsRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).colorResId(R.color.colorFill).build());
|
||||
mContactsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
mContactsAdapter = new SharingContactsAdapter(this, mUserIdPreference.get());
|
||||
mContactsAdapter = new SharingContactsAdapter(this);
|
||||
mContactsRecyclerView.setAdapter(mContactsAdapter);
|
||||
|
||||
setToolBar();
|
||||
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
String action = mIntent.getAction();
|
||||
String type = mIntent.getType();
|
||||
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
handleSendFile(intent);
|
||||
handleSendFile(mIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,13 +159,20 @@ public class SharingActivity extends AppCompatActivity implements SharingView, S
|
||||
|
||||
@Override
|
||||
public void onOpenGroupMessage(Group group) {
|
||||
startActivity(GroupChatActivity.createIntent(this, group));
|
||||
Intent intent = GroupChatActivity.createIntent(this, group);
|
||||
intent.putExtra("TEST_EXTRA", true);
|
||||
|
||||
startActivity(intent);
|
||||
finishAffinity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenPrivateMessage(Group contact) {
|
||||
startActivity(SingleChatActivity.createIntent(this, contact));
|
||||
Intent intent = SingleChatActivity.createIntent(this, contact);
|
||||
|
||||
intent.putExtra("TEST_EXTRA", true);
|
||||
|
||||
startActivity(intent);
|
||||
finishAffinity();
|
||||
}
|
||||
|
||||
@@ -170,4 +195,9 @@ public class SharingActivity extends AppCompatActivity implements SharingView, S
|
||||
public void setGroups(ArrayList<Group> groups) {
|
||||
mContactsAdapter.setGroups(groups);
|
||||
}
|
||||
|
||||
@OnClick(R.id.chat_toolbar_back_arrow)
|
||||
public void onBackArrowClick(View view) {
|
||||
returnToContactList(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public class SharingContactsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
private ArrayList<Group> mGroups;
|
||||
private SharingContactsAdapter.OnOpenClickListener mItemClickListener;
|
||||
private long mUserId;
|
||||
|
||||
interface OnOpenClickListener {
|
||||
void onOpenGroupMessage(Group group);
|
||||
@@ -37,10 +36,9 @@ public class SharingContactsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
void onOpenPrivateMessage(Group contact);
|
||||
}
|
||||
|
||||
SharingContactsAdapter(OnOpenClickListener openClickListener, long userId) {
|
||||
SharingContactsAdapter(OnOpenClickListener openClickListener) {
|
||||
mItemClickListener = openClickListener;
|
||||
mGroups = new ArrayList<>();
|
||||
mUserId = userId;
|
||||
}
|
||||
|
||||
void setGroups(ArrayList<Group> groups) {
|
||||
|
||||
@@ -69,21 +69,6 @@ public class SharingPresenter extends MVPAbstractPresenter<SharingView> implemen
|
||||
@Named(AppPrefsConstants.USER_ID)
|
||||
LongPreference mUserIdReference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.AVATAR)
|
||||
StringPreference mAvatarPreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.NAME)
|
||||
StringPreference mProfileNamePreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.UPLOAD_MAX_SIZE)
|
||||
LongPreference mUploadMaxSizePreference;
|
||||
|
||||
@Inject
|
||||
RealmProvider mRealmProvider;
|
||||
|
||||
@Inject
|
||||
SharingPresenter() {}
|
||||
|
||||
|
||||
@@ -88,4 +88,6 @@
|
||||
<string name="error_file_is_too_large">Die Datei, die Sie versuchen hochzuladen, ist zu groß</string>
|
||||
<string name="sharing_title">Datei teilen</string>
|
||||
|
||||
<string name="default_notification_channel_id">ownChat</string>
|
||||
|
||||
</resources>
|
||||
@@ -3,16 +3,15 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||
//classpath 'me.tatarka:gradle-retrolambda:3.3.0'
|
||||
//classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
|
||||
classpath 'io.realm:realm-gradle-plugin:2.2.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
classpath 'com.google.gms:google-services:3.1.1'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user