Added a dialog to choose between categories to pick files from
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 29 KiB |
@@ -19,4 +19,7 @@ public interface AppPrefsConstants {
|
||||
String IS_EMPLOYEE = "is_employee";
|
||||
String SHOW_LOGIN_AGAIN = "show_login_again";
|
||||
String LAST_ACCOUNT_NO = "last_account_no";
|
||||
|
||||
String USER_PASSWORD = "user_password";
|
||||
String USER_NAME = "user_name";
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
package de.beyondsoft.ownchat.data.events;
|
||||
|
||||
public class LogoutDirectlyEvent {
|
||||
private boolean mClearAllPrefs;
|
||||
|
||||
public boolean getClearAllPrefs() {
|
||||
return mClearAllPrefs;
|
||||
}
|
||||
|
||||
public LogoutDirectlyEvent(boolean clearAllPrefs) {
|
||||
mClearAllPrefs = clearAllPrefs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.google.firebase.messaging.RemoteMessage;
|
||||
import de.beyondsoft.ownchat.R;
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.api.common.ErrorHandlingResponseConverter;
|
||||
import de.beyondsoft.ownchat.data.api.responses.MessageResponse;
|
||||
import de.beyondsoft.ownchat.data.api.services.ChatService;
|
||||
import de.beyondsoft.ownchat.data.prefs.LongPreference;
|
||||
import de.beyondsoft.ownchat.data.repository.GroupRealmRepository;
|
||||
@@ -18,10 +17,8 @@ import de.beyondsoft.ownchat.model.Group;
|
||||
import de.beyondsoft.ownchat.model.Message;
|
||||
import de.beyondsoft.ownchat.page.main.MainActivity;
|
||||
import de.beyondsoft.ownchat.utils.Constants;
|
||||
import de.beyondsoft.ownchat.utils.LoggedOutUtils;
|
||||
import de.beyondsoft.ownchat.utils.rx.RxUtils;
|
||||
import rx.Observable;
|
||||
import rx.functions.Func1;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
@@ -75,16 +72,13 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
@Named(AppPrefsConstants.USER_ID)
|
||||
LongPreference mUserIdReference;
|
||||
|
||||
@Inject
|
||||
LoggedOutUtils mLoggedOutUtils;
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||
InjectionHelper.getMessagingComponent(this).inject(HandleMessagesService.this);
|
||||
|
||||
if (mLoggedOutUtils.checkLoggedOutPrefs()) {
|
||||
return;
|
||||
}
|
||||
// if (mLoggedOutUtils.checkLoggedOutPrefs()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
customizeNotification(remoteMessage.getData());
|
||||
}
|
||||
@@ -109,12 +103,7 @@ public class HandleMessagesService extends FirebaseMessagingService {
|
||||
mChatService.getMessage(messageId)
|
||||
.compose(RxUtils.provideDefaultTransformer())
|
||||
.flatMap(new ErrorHandlingResponseConverter<>())
|
||||
.flatMap(new Func1<MessageResponse, Observable<Message>>() {
|
||||
@Override
|
||||
public Observable<Message> call(MessageResponse messageResponse) {
|
||||
return Observable.just(messageResponse.response.message);
|
||||
}
|
||||
})
|
||||
.flatMap(messageResponse -> Observable.just(messageResponse.response.message))
|
||||
.subscribe(this::getMessageSuccess, this::getMessageError);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.securepreferences.SecurePreferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.Settings;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
@@ -54,6 +55,20 @@ public class AppPrefsModule {
|
||||
return new BooleanPreference(sharedPreferences, AppPrefsConstants.SAVE_PASSWORD);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
@Named(AppPrefsConstants.USER_NAME)
|
||||
StringPreference provideUserName(@AppPrefs SecurePreferences sharedPreferences) {
|
||||
return new StringPreference(sharedPreferences, AppPrefsConstants.USER_NAME);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
@Named(AppPrefsConstants.USER_PASSWORD)
|
||||
StringPreference providePassword(@AppPrefs SecurePreferences sharedPreferences) {
|
||||
return new StringPreference(sharedPreferences, AppPrefsConstants.USER_PASSWORD);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ApplicationScope
|
||||
@Named(AppPrefsConstants.CHAT_CODE)
|
||||
|
||||
@@ -88,6 +88,12 @@ public interface ApplicationComponent {
|
||||
@Named(AppPrefsConstants.SHOW_LOGIN_AGAIN)
|
||||
BooleanPreference provideShowLoginAgain();
|
||||
|
||||
@Named(AppPrefsConstants.USER_NAME)
|
||||
StringPreference provideUserName();
|
||||
|
||||
@Named(AppPrefsConstants.USER_PASSWORD)
|
||||
StringPreference providePassword();
|
||||
|
||||
NotificationManager provideNotificationManager();
|
||||
|
||||
GroupRealmRepository provideGroupRealmRepository();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FilePickerConst {
|
||||
public final static int MEDIA_TYPE_IMAGE=1;
|
||||
public final static int MEDIA_TYPE_VIDEO=3;
|
||||
|
||||
public enum FILE_TYPE{
|
||||
public enum FILE_TYPE {
|
||||
PDF,
|
||||
WORD,
|
||||
EXCEL,
|
||||
|
||||
@@ -73,7 +73,7 @@ public class FolderGridAdapter extends SelectableAdapter<FolderGridAdapter.Image
|
||||
if(AndroidLifecycleUtils.canLoadImage(holder.imageView.getContext())) {
|
||||
glide.load(new File(photoDirectory.getCoverPath()))
|
||||
.override(imageSize, imageSize)
|
||||
.placeholder(R.drawable.document)
|
||||
.fallback(R.drawable.document)
|
||||
.thumbnail(0.5f)
|
||||
.into(holder.imageView);
|
||||
}
|
||||
@@ -84,22 +84,23 @@ public class FolderGridAdapter extends SelectableAdapter<FolderGridAdapter.Image
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(folderGridAdapterListener!=null)
|
||||
if(folderGridAdapterListener!=null) {
|
||||
folderGridAdapterListener.onFolderClicked(photoDirectory);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.bottomOverlay.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.imageView.setImageResource(PickerManager.getInstance().getCameraDrawable());
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(folderGridAdapterListener!=null)
|
||||
folderGridAdapterListener.onCameraClicked();
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
if(folderGridAdapterListener!=null) {
|
||||
folderGridAdapterListener.onCameraClicked();
|
||||
}
|
||||
});
|
||||
|
||||
holder.bottomOverlay.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -124,18 +125,18 @@ public class FolderGridAdapter extends SelectableAdapter<FolderGridAdapter.Image
|
||||
this.folderGridAdapterListener = onClickListener;
|
||||
}
|
||||
|
||||
public static class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||
static class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imageView;
|
||||
TextView folderTitle;
|
||||
TextView folderCount;
|
||||
View bottomOverlay;
|
||||
View selectBg;
|
||||
|
||||
public ImageViewHolder(View itemView) {
|
||||
ImageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
imageView = (ImageView) itemView.findViewById(R.id.iv_photo);
|
||||
folderTitle = (TextView) itemView.findViewById(R.id.folder_title);
|
||||
folderCount = (TextView) itemView.findViewById(R.id.folder_count);
|
||||
imageView = itemView.findViewById(R.id.iv_photo);
|
||||
folderTitle = itemView.findViewById(R.id.folder_title);
|
||||
folderCount = itemView.findViewById(R.id.folder_count);
|
||||
bottomOverlay = itemView.findViewById(R.id.bottomOverlay);
|
||||
selectBg = itemView.findViewById(R.id.transparent_bg);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.beyondsoft.ownchat.filepicker.utils;
|
||||
|
||||
import android.database.DataSetObserver;
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TabLayout;
|
||||
@@ -15,6 +16,8 @@ import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import de.beyondsoft.ownchat.R;
|
||||
|
||||
/**
|
||||
* Created by Lyndon on 26-Oct-2017.
|
||||
*/
|
||||
@@ -43,6 +46,7 @@ public class TabLayoutHelper {
|
||||
}/**/
|
||||
|
||||
mTabLayout = tabLayout;
|
||||
mTabLayout.setSelectedTabIndicatorColor(Color.parseColor("#FF5E00"));
|
||||
mViewPager = viewPager;
|
||||
|
||||
mInternalDataSetObserver = new DataSetObserver() {
|
||||
@@ -71,12 +75,7 @@ public class TabLayoutHelper {
|
||||
|
||||
mInternalTabLayoutOnPageChangeListener = new FixedTabLayoutOnPageChangeListener(mTabLayout);
|
||||
|
||||
mInternalOnAdapterChangeListener = new ViewPager.OnAdapterChangeListener() {
|
||||
@Override
|
||||
public void onAdapterChanged(@NonNull ViewPager viewPager, @Nullable PagerAdapter oldAdapter, @Nullable PagerAdapter newAdapter) {
|
||||
handleOnAdapterChanged(viewPager, oldAdapter, newAdapter);
|
||||
}
|
||||
};
|
||||
mInternalOnAdapterChangeListener = (viewPager1, oldAdapter, newAdapter) -> handleOnAdapterChanged(viewPager1, oldAdapter, newAdapter);
|
||||
|
||||
setupWithViewPager(mTabLayout, mViewPager);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import de.beyondsoft.ownchat.utils.Constants;
|
||||
import de.beyondsoft.ownchat.utils.EndlessScrollListener;
|
||||
import de.beyondsoft.ownchat.utils.FileUtils;
|
||||
import de.beyondsoft.ownchat.utils.SystemUtils;
|
||||
import de.beyondsoft.ownchat.utils.Utils;
|
||||
import de.beyondsoft.ownchat.utils.ui.EmptyLayout;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@@ -74,7 +75,8 @@ import okhttp3.MediaType;
|
||||
abstract class BaseChatActivity extends RuntimePermissionActivity implements ChatView, BaseChatAdapter.MessageClickListener, LogoutNavigation {
|
||||
|
||||
private final static int STORAGE_REQUEST_CODE = 9999;
|
||||
private final static int SELECT_FILE = 233;
|
||||
private final static int SELECT_IMAGE_FILE = 233;
|
||||
private final static int SELECT_DOC_FILE = 234;
|
||||
private final static int CONFIRM_FILE = 666;
|
||||
private final static int VISIBLE_THRESHOLD = 25;
|
||||
protected final static String MESSAGE_ARG = "message_arg";
|
||||
@@ -273,36 +275,23 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
}
|
||||
|
||||
private void selectFile(int requestCode) {
|
||||
// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
// intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
|
||||
//
|
||||
// intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
//
|
||||
// intent.setType("*/*");
|
||||
// intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||
// intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
//
|
||||
// startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.chat_select_file)), SELECT_FILE);
|
||||
|
||||
// TODO: show attachment type dialog first
|
||||
final String[] zipFileTypes = {".zip", ".rar", ".7zip"};
|
||||
final String[] pdfFileTypes = {".pdf"};
|
||||
final String[] docFileTypes = {".txt", ".doc", ".xls", ".docx", ".xlsx", ".odt"};
|
||||
|
||||
|
||||
final Dialog dialog = new Dialog(this);
|
||||
dialog.setContentView(R.layout.file_chooser_dialog);
|
||||
|
||||
ImageView attachFromGalleryImageView = dialog.findViewById(R.id.attachFromGalleryBtn);
|
||||
ImageView attachDocumentImageView = dialog.findViewById(R.id.attachDocumentBtn);
|
||||
ImageView attachAudioImageView = dialog.findViewById(R.id.attachAudioBtn);
|
||||
|
||||
attachAudioImageView.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
attachDocumentImageView.setOnClickListener(v -> {
|
||||
FilePickerBuilder.getInstance().setMaxCount(1)
|
||||
.addFileSupport("ZIP", zipFileTypes)
|
||||
.addFileSupport("PDF", pdfFileTypes)
|
||||
.addFileSupport("DOC", docFileTypes)
|
||||
.enableDocSupport(false)
|
||||
.withOrientation(Orientation.PORTRAIT_ONLY)
|
||||
.pickFile(this);
|
||||
@@ -343,15 +332,16 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
return;
|
||||
}
|
||||
|
||||
if (requestCode == SELECT_FILE) {
|
||||
// TODO: support documents too (FilePickerConst.KEY_SELECTED_DOCS)
|
||||
final Uri uri = Uri.fromFile(new File(data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA) != null ?
|
||||
if (requestCode == SELECT_IMAGE_FILE || requestCode == SELECT_DOC_FILE) {
|
||||
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)));
|
||||
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);
|
||||
// Check for the freshest data.
|
||||
|
||||
try {
|
||||
//noinspection WrongConstant
|
||||
getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
@@ -365,7 +355,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.FILENAME, data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_MEDIA).get(0));
|
||||
bundle.putString(Constants.FILENAME, filePath);
|
||||
|
||||
Intent intent = new Intent(this, FileConfirmationActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
@@ -389,7 +379,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
|
||||
@Override
|
||||
public void logoutDirectly(boolean clearAllPrefs) {
|
||||
EventBus.getDefault().post(new LogoutDirectlyEvent());
|
||||
EventBus.getDefault().post(new LogoutDirectlyEvent(clearAllPrefs));
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -500,14 +490,17 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mChatOpenedPref.set(false);
|
||||
|
||||
if (mEndlessScrollListener != null) {
|
||||
mRecyclerView.removeOnScrollListener(mEndlessScrollListener);
|
||||
}
|
||||
|
||||
getWindow().getDecorView().getViewTreeObserver().removeOnGlobalLayoutListener(mKeyboardListener);
|
||||
EventBus.getDefault().unregister(this);
|
||||
InjectionHelper.destroyChatComponent();
|
||||
mRecyclerView.setAdapter(null);
|
||||
mEmptyLayout.setOnTryAgainClickListener(null);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ public class FileConfirmationActivity extends AppCompatActivity implements FileC
|
||||
|
||||
mSelectedUri = Uri.parse(fileUri);
|
||||
|
||||
// getFile(mSelectedUri).getPath()
|
||||
Glide.with(this)
|
||||
.load(fileUri)
|
||||
.dontAnimate()
|
||||
.placeholder(R.drawable.document)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.into(new GlideDrawableImageViewTarget(mFileImageView));
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ 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;
|
||||
@@ -135,6 +137,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
|
||||
InjectionHelper.destroyLoginComponent();
|
||||
InjectionHelper.getLoginComponent(this).inject(this);
|
||||
mLoginPresenter.attachView(this);
|
||||
|
||||
mCallback.tryToLogin(mUsernameEditText.getText().toString().trim(), mPasswordEditText.getText().toString(), mChatCodeEditText.getText().toString().trim());
|
||||
}
|
||||
|
||||
@@ -166,6 +169,12 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
|
||||
mChatCodeEditText.setText(String.valueOf(mSecuredPrefs.getString(AppPrefsConstants.CHAT_CODE, null)));
|
||||
} else if (key.equals(SecurePreferences.hashPrefKey(AppPrefsConstants.ACCOUNT_NO))) {
|
||||
mAccountEditText.setText(String.valueOf(mSecuredPrefs.getString(AppPrefsConstants.ACCOUNT_NO, null)));
|
||||
} else if(key.equals(SecurePreferences.hashPrefKey(AppPrefsConstants.USER_NAME))) {
|
||||
mUsernameEditText.setText(String.valueOf(mSecuredPrefs.getString(AppPrefsConstants.USER_NAME, null)));
|
||||
} else if(key.equals(SecurePreferences.hashPrefKey(AppPrefsConstants.USER_PASSWORD))) {
|
||||
mPasswordEditText.setText(String.valueOf(mSecuredPrefs.getString(AppPrefsConstants.USER_PASSWORD, null)));
|
||||
} else if(key.equals(SecurePreferences.hashPrefKey(AppPrefsConstants.SAVE_PASSWORD))) {
|
||||
mSavePasswordCheckbox.setChecked(mSecuredPrefs.getBoolean(AppPrefsConstants.SAVE_PASSWORD, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,14 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
@Named(AppPrefsConstants.CHAT_CODE)
|
||||
StringPreference mChatCodePreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.USER_PASSWORD)
|
||||
StringPreference mPasswordPreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.USER_NAME)
|
||||
StringPreference mUserNamePreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.SAVE_PASSWORD)
|
||||
BooleanPreference mSavePasswordPreference;
|
||||
@@ -183,7 +191,17 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
Subscription subscription = mLoginService.loginWithChatCode(username, password, chatCode)
|
||||
.compose(RxUtils.provideDefaultTransformer())
|
||||
.flatMap(new ErrorHandlingResponseConverter<>())
|
||||
.map(loginResponse -> loginResponse.response.user)
|
||||
.map(loginResponse -> {
|
||||
if(mSavePasswordPreference.get()) {
|
||||
mUserNamePreference.set(username);
|
||||
mPasswordPreference.set(password);
|
||||
} else {
|
||||
mUserNamePreference.delete();
|
||||
mPasswordPreference.delete();
|
||||
}
|
||||
|
||||
return loginResponse.response.user;
|
||||
})
|
||||
.subscribe(this::loginSuccess, this::loginError);
|
||||
|
||||
addSubscription(subscription);
|
||||
@@ -242,8 +260,7 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
String lastAccountNumber = mLastAccountNumberPreference.get();
|
||||
|
||||
if(!accountNumber.equals(lastAccountNumber)) {
|
||||
//deleteData(true);
|
||||
deleteData2();
|
||||
deleteDataOnCustomerIdChange();
|
||||
}
|
||||
|
||||
mIsEmployee.set(user.isEmployee);
|
||||
@@ -253,6 +270,7 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
mAvatarPreference.set(user.avatar);
|
||||
mPhoneNumberPreference.set(user.mobile);
|
||||
mProfileNamePreference.set(user.firstName.concat(" ").concat(user.lastName));
|
||||
|
||||
getView().loginSuccessful();
|
||||
}
|
||||
|
||||
@@ -329,32 +347,29 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
getView().showLoading();
|
||||
|
||||
Subscription subscription = mLoginService.getServiceType("1", customerId)
|
||||
.flatMap(new Func1<JsonObject, Observable<Boolean>>() {
|
||||
@Override
|
||||
public Observable<Boolean> call(JsonObject response) {
|
||||
JsonObject serviceObject = response.getAsJsonObject();
|
||||
.flatMap(response -> {
|
||||
JsonObject serviceObject = response.getAsJsonObject();
|
||||
|
||||
if (serviceObject.has("Status")
|
||||
&& !TextUtils.isEmpty(serviceObject.get("Status").getAsString())
|
||||
&& serviceObject.has("URL")
|
||||
&& !TextUtils.isEmpty(serviceObject.get("URL").getAsString())) {
|
||||
if (serviceObject.has("Status")
|
||||
&& !TextUtils.isEmpty(serviceObject.get("Status").getAsString())
|
||||
&& serviceObject.has("URL")
|
||||
&& !TextUtils.isEmpty(serviceObject.get("URL").getAsString())) {
|
||||
|
||||
|
||||
String serverName = serviceObject.get("URL").getAsString();
|
||||
String serverName = serviceObject.get("URL").getAsString();
|
||||
|
||||
if (!serverName.startsWith("https")) {
|
||||
serverName = "https://" + serverName + "/";
|
||||
}
|
||||
|
||||
mApiEndpointPreference.set(serverName);
|
||||
|
||||
return Observable.just(true);
|
||||
} else if(serviceObject.has("Status") && !TextUtils.isEmpty(serviceObject.get("Status").getAsString())) {
|
||||
mStatus = serviceObject.get("Status").getAsInt();
|
||||
if (!serverName.startsWith("https")) {
|
||||
serverName = "https://" + serverName + "/";
|
||||
}
|
||||
|
||||
return Observable.just(false);
|
||||
mApiEndpointPreference.set(serverName);
|
||||
|
||||
return Observable.just(true);
|
||||
} else if(serviceObject.has("Status") && !TextUtils.isEmpty(serviceObject.get("Status").getAsString())) {
|
||||
mStatus = serviceObject.get("Status").getAsInt();
|
||||
}
|
||||
|
||||
return Observable.just(false);
|
||||
})
|
||||
.compose(RxUtils.provideDefaultTransformer())
|
||||
.subscribe(this::checkTypeAndCustomerIdSuccessful, this::checkTypeAndCustomerIdError);
|
||||
@@ -392,17 +407,14 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
getView().showLoading();
|
||||
|
||||
Subscription subscription = mLoginService.getUploadMaxSize()
|
||||
.flatMap(new Func1<JsonObject, Observable<Integer>>() {
|
||||
@Override
|
||||
public Observable<Integer> call(JsonObject response) {
|
||||
JsonObject maxSizeObject = response.getAsJsonObject();
|
||||
.flatMap(response -> {
|
||||
JsonObject maxSizeObject = response.getAsJsonObject();
|
||||
|
||||
if(maxSizeObject.has("file_upload_max_size")) {
|
||||
mUploadMaxSizePreference.set(maxSizeObject.get("file_upload_max_size").getAsLong());
|
||||
}
|
||||
|
||||
return Observable.just(0);
|
||||
if(maxSizeObject.has("file_upload_max_size")) {
|
||||
mUploadMaxSizePreference.set(maxSizeObject.get("file_upload_max_size").getAsLong());
|
||||
}
|
||||
|
||||
return Observable.just(0);
|
||||
})
|
||||
.compose(RxUtils.provideDefaultTransformer())
|
||||
.subscribe(this::retrieveUploadMaxSizeSuccessful, this::retrieveUploadMaxSizeError);
|
||||
@@ -480,6 +492,7 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
|
||||
@Override
|
||||
public void tryToLogout(String deviceId, MainNavigation mainNavigation) {
|
||||
// TODO: what if the password save checkbox is set and the user logs out?
|
||||
if (mSavePasswordPreference.get()) {
|
||||
return;
|
||||
}
|
||||
@@ -592,13 +605,7 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteData2() {
|
||||
// Observable.create(subscriber -> mGlide.clearDiskCache())
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .subscribe();
|
||||
//
|
||||
// mGlide.clearMemory();
|
||||
|
||||
private void deleteDataOnCustomerIdChange() {
|
||||
File dir = mContext.getExternalFilesDir(null);
|
||||
|
||||
if (dir != null) {
|
||||
|
||||
@@ -38,7 +38,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;
|
||||
@@ -267,7 +266,7 @@ public class MainActivity extends AppCompatActivity implements MainNavigation, L
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLogoutDirectlyEvent(LogoutDirectlyEvent logoutDirectlyEvent) {
|
||||
logoutDirectly(true);
|
||||
logoutDirectly(logoutDirectlyEvent.getClearAllPrefs());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,11 +274,6 @@ public class MainActivity extends AppCompatActivity implements MainNavigation, L
|
||||
EventBus.getDefault().unregister(this);
|
||||
mChatOpenedPref.set(false);
|
||||
|
||||
if (!mLogoutClicked && getIntent().getBooleanExtra(LOGOUT, true)) {
|
||||
mLoginPresenter.tryToLogout(Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID), this);
|
||||
}
|
||||
|
||||
getIntent().removeExtra(LOGOUT);
|
||||
InjectionHelper.destroyMainComponents();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -37,6 +38,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnTextChanged;
|
||||
import de.beyondsoft.ownchat.utils.ui.ViewUtils;
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
|
||||
/**
|
||||
@@ -61,6 +63,9 @@ public class ProfileFragment extends RuntimePermissionBaseFragment implements Pr
|
||||
@BindView(R.id.profile_update_button)
|
||||
Button mUpdateProfileButton;
|
||||
|
||||
@BindView(R.id.profile_avatar_progress_bar)
|
||||
ProgressBar mProgressBar;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.NAME)
|
||||
StringPreference mProfileNamePreference;
|
||||
@@ -97,8 +102,11 @@ public class ProfileFragment extends RuntimePermissionBaseFragment implements Pr
|
||||
getActivity().setTitle(R.string.title_profile);
|
||||
Glide.with(getActivity())
|
||||
.load(mAvatarPreference.get())
|
||||
.placeholder(R.drawable.avatar)
|
||||
.into(mAvatarImageview);
|
||||
|
||||
ViewUtils.setProgressBarColor(mProgressBar, R.color.colorDefault);
|
||||
|
||||
if (!TextUtils.isEmpty(mPhoneNumberPreference.get())) {
|
||||
mPhoneNumberEditText.setText(mPhoneNumberPreference.get());
|
||||
}
|
||||
@@ -145,6 +153,7 @@ public class ProfileFragment extends RuntimePermissionBaseFragment implements Pr
|
||||
mProfilePresenter.attachView(this);
|
||||
}
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mCallback.uploadImage(uri);
|
||||
}
|
||||
}
|
||||
@@ -180,10 +189,13 @@ public class ProfileFragment extends RuntimePermissionBaseFragment implements Pr
|
||||
|
||||
@Override
|
||||
public void refreshImage(String imageUrl) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
Glide.with(getContext())
|
||||
.load(imageUrl)
|
||||
.error(R.drawable.avatar)
|
||||
.into(mAvatarImageview);
|
||||
|
||||
mAvatarPreference.set(imageUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,7 @@ public class AppStoppedService extends Service {
|
||||
@Override
|
||||
public void onTaskRemoved(Intent rootIntent) {
|
||||
mAppKilledPreference.set(true);
|
||||
if (!mSavedPasswordPref.get()) {
|
||||
mNotificationManager.cancelAll();
|
||||
}
|
||||
|
||||
stopSelf();
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package de.beyondsoft.ownchat.utils;
|
||||
|
||||
import de.beyondsoft.ownchat.data.AppPrefsConstants;
|
||||
import de.beyondsoft.ownchat.data.prefs.BooleanPreference;
|
||||
import de.beyondsoft.ownchat.di.scopes.ActivityScope;
|
||||
import de.beyondsoft.ownchat.page.login.LoginPresenter;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@ActivityScope
|
||||
public class LoggedOutUtils {
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.APP_KILLED)
|
||||
BooleanPreference mAppKilledPreference;
|
||||
|
||||
@Inject
|
||||
@Named(AppPrefsConstants.SAVE_PASSWORD)
|
||||
BooleanPreference mSavePasswordPreference;
|
||||
|
||||
@Inject
|
||||
NotificationManager mNotificationManager;
|
||||
|
||||
@Inject
|
||||
LoginPresenter mLoginPresenter;
|
||||
|
||||
@Inject
|
||||
Context mContext;
|
||||
|
||||
@Inject
|
||||
LoggedOutUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is still logged in.
|
||||
*/
|
||||
public boolean checkLoggedOutPrefs() {
|
||||
if (!mSavePasswordPreference.get() && mAppKilledPreference.get()) {
|
||||
mNotificationManager.cancelAll();
|
||||
mLoginPresenter.logout(Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID), true, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
package de.beyondsoft.ownchat.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Created by imarneanu on 2/13/17.
|
||||
*/
|
||||
|
||||
|
After Width: | Height: | Size: 841 KiB |
@@ -4,32 +4,27 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/attachFromGalleryBtn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".33"
|
||||
android:layout_weight=".50"
|
||||
android:adjustViewBounds="false"
|
||||
android:contentDescription="@null"
|
||||
android:cropToPadding="false"
|
||||
android:layout_margin="10dp"
|
||||
android:src="@mipmap/ic_file_dialog_gallery" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/attachDocumentBtn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".33"
|
||||
android:layout_weight=".50"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/ic_file_picker_document" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/attachAudioBtn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".33"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/ic_file_dialog_audio" />
|
||||
android:layout_margin="10dp"
|
||||
android:src="@mipmap/ic_file_dialog_document" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -21,6 +21,15 @@
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/avatar" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/profile_avatar_progress_bar"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="70dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/profile_change_button"
|
||||
style="@style/AppTheme.Profile.Button"
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/file_iv"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/document"
|
||||
android:layout_margin="10dp"
|
||||
android:contentDescription="@null" />
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/document" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_name_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="PPDF_112121_jfioweijf_fiowejfowjfeowf_oifwjefowjifoiwjf_joiwjeofjwiojf0j.pdf"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_toEndOf="@+id/file_iv"
|
||||
android:layout_toStartOf="@+id/checkbox"
|
||||
android:layout_marginTop="10dp"
|
||||
android:ellipsize="end"
|
||||
/>
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp"
|
||||
tools:text="PPDF_112121_jfioweijf_fiowejfowjfeowf_oifwjefowjifoiwjf_joiwjeofjwiojf0j.pdf" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_size_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/file_name_tv"
|
||||
tools:text="1.2MB"
|
||||
android:layout_toEndOf="@+id/file_iv"
|
||||
android:layout_marginStart="5dp"/>
|
||||
tools:text="1.2MB" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="20dp"
|
||||
/>
|
||||
android:layout_margin="20dp" />
|
||||
</RelativeLayout>
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/document"
|
||||
android:background="@android:color/white"
|
||||
android:contentDescription="@null"
|
||||
android:padding="1dp"
|
||||
android:scaleType="center" />
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.beyondsoft.ownchat.filepicker.views.SquareRelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<de.beyondsoft.ownchat.filepicker.views.SquareRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/document"
|
||||
android:background="@color/colorWhite"
|
||||
android:contentDescription="@null"
|
||||
android:padding="1dip"
|
||||
android:scaleType="center" />
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/test_image" />
|
||||
|
||||
<View
|
||||
android:id="@+id/transparent_bg"
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 979 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 788 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 935 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |