-
This commit is contained in:
Binary file not shown.
@@ -17,4 +17,5 @@ public interface AppPrefsConstants {
|
|||||||
String APP_KILLED = "app_killed";
|
String APP_KILLED = "app_killed";
|
||||||
String UPLOAD_MAX_SIZE = "upload_max_size";
|
String UPLOAD_MAX_SIZE = "upload_max_size";
|
||||||
String IS_EMPLOYEE = "is_employee";
|
String IS_EMPLOYEE = "is_employee";
|
||||||
|
String SHOW_LOGIN_AGAIN = "show_login_again";
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,7 @@ public class ApiModule {
|
|||||||
} else {
|
} else {
|
||||||
interceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
|
interceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return interceptor;
|
return interceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,12 +66,15 @@ public class ApiModule {
|
|||||||
if (token.isSet()) {
|
if (token.isSet()) {
|
||||||
builder.addHeader("Token", token.get());
|
builder.addHeader("Token", token.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customerId.isSet()) {
|
if (customerId.isSet()) {
|
||||||
builder.addHeader("CustomerID", customerId.get());
|
builder.addHeader("CustomerID", customerId.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHeaderSet) {
|
if (isHeaderSet) {
|
||||||
return chain.proceed(builder.build());
|
return chain.proceed(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain.proceed(original.newBuilder().build());
|
return chain.proceed(original.newBuilder().build());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.p3.bewoplaner.data.api.responses.ProfileResponse;
|
|||||||
import retrofit2.http.Field;
|
import retrofit2.http.Field;
|
||||||
import retrofit2.http.FormUrlEncoded;
|
import retrofit2.http.FormUrlEncoded;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.Header;
|
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|||||||
@@ -123,4 +123,11 @@ public class AppPrefsModule {
|
|||||||
BooleanPreference provideIsEmployee(@AppPrefs SharedPreferences sharedPreferences) {
|
BooleanPreference provideIsEmployee(@AppPrefs SharedPreferences sharedPreferences) {
|
||||||
return new BooleanPreference(sharedPreferences, AppPrefsConstants.IS_EMPLOYEE);
|
return new BooleanPreference(sharedPreferences, AppPrefsConstants.IS_EMPLOYEE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@ApplicationScope
|
||||||
|
@Named(AppPrefsConstants.SHOW_LOGIN_AGAIN)
|
||||||
|
BooleanPreference provideShowLoginAgain(@AppPrefs SharedPreferences sharedPreferences) {
|
||||||
|
return new BooleanPreference(sharedPreferences, AppPrefsConstants.SHOW_LOGIN_AGAIN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -82,6 +82,9 @@ public interface ApplicationComponent {
|
|||||||
@Named(AppPrefsConstants.IS_EMPLOYEE)
|
@Named(AppPrefsConstants.IS_EMPLOYEE)
|
||||||
BooleanPreference provideIsEmployee();
|
BooleanPreference provideIsEmployee();
|
||||||
|
|
||||||
|
@Named(AppPrefsConstants.SHOW_LOGIN_AGAIN)
|
||||||
|
BooleanPreference provideShowLoginAgain();
|
||||||
|
|
||||||
NotificationManager provideNotificationManager();
|
NotificationManager provideNotificationManager();
|
||||||
|
|
||||||
GroupRealmRepository provideGroupRealmRepository();
|
GroupRealmRepository provideGroupRealmRepository();
|
||||||
|
|||||||
@@ -280,7 +280,6 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
// mLoginPresenter.checkIfVoucherStillAvailable(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -323,7 +322,7 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logoutDirectly() {
|
public void logoutDirectly(boolean clearAllPrefs) {
|
||||||
EventBus.getDefault().post(new LogoutDirectlyEvent());
|
EventBus.getDefault().post(new LogoutDirectlyEvent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -359,7 +358,6 @@ abstract class BaseChatActivity extends RuntimePermissionActivity implements Cha
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resendMessage(Message message) {
|
public void resendMessage(Message message) {
|
||||||
// mLoginPresenter.checkIfVoucherStillAvailable(this);
|
|
||||||
if (!mChatPresenter.isAttached()) {
|
if (!mChatPresenter.isAttached()) {
|
||||||
mChatPresenter.attachView(this);
|
mChatPresenter.attachView(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,10 +267,12 @@ public class ChatPresenter extends MVPAbstractPresenter<ChatView>
|
|||||||
Log.e(ChatPresenter.class.getSimpleName(), throwable.getMessage(), throwable);
|
Log.e(ChatPresenter.class.getSimpleName(), throwable.getMessage(), throwable);
|
||||||
getView().hideLoading();
|
getView().hideLoading();
|
||||||
getView().hideMessagesLoading();
|
getView().hideMessagesLoading();
|
||||||
|
|
||||||
if (mSystemUtils.isNetworkUnavailable()) {
|
if (mSystemUtils.isNetworkUnavailable()) {
|
||||||
getView().showError(R.string.error_no_internet_connection);
|
getView().showError(R.string.error_no_internet_connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getView().showError(R.string.error_something_went_wrong);
|
getView().showError(R.string.error_something_went_wrong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.p3.bewoplaner.BewoplanerApplication;
|
|||||||
import com.p3.bewoplaner.R;
|
import com.p3.bewoplaner.R;
|
||||||
import com.p3.bewoplaner.data.AppPrefsConstants;
|
import com.p3.bewoplaner.data.AppPrefsConstants;
|
||||||
import com.p3.bewoplaner.data.prefs.AppPrefs;
|
import com.p3.bewoplaner.data.prefs.AppPrefs;
|
||||||
|
import com.p3.bewoplaner.data.prefs.BooleanPreference;
|
||||||
import com.p3.bewoplaner.di.InjectionHelper;
|
import com.p3.bewoplaner.di.InjectionHelper;
|
||||||
import com.p3.bewoplaner.page.main.MainActivity;
|
import com.p3.bewoplaner.page.main.MainActivity;
|
||||||
import com.p3.bewoplaner.utils.AppStoppedService;
|
import com.p3.bewoplaner.utils.AppStoppedService;
|
||||||
@@ -31,6 +32,7 @@ import android.widget.ProgressBar;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@@ -57,6 +59,10 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
|
|||||||
@BindView(R.id.login_save_password_checkBox)
|
@BindView(R.id.login_save_password_checkBox)
|
||||||
CheckBox mSavePasswordCheckbox;
|
CheckBox mSavePasswordCheckbox;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named(AppPrefsConstants.SHOW_LOGIN_AGAIN)
|
||||||
|
BooleanPreference mShowLoginAgainPreference;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LoginPresenter mLoginPresenter;
|
LoginPresenter mLoginPresenter;
|
||||||
|
|
||||||
@@ -76,6 +82,12 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
|
|||||||
mLoginPresenter.attachView(this);
|
mLoginPresenter.attachView(this);
|
||||||
decryptPreference();
|
decryptPreference();
|
||||||
ViewUtils.setProgressBarColor(mProgressBar, R.color.colorDefault);
|
ViewUtils.setProgressBarColor(mProgressBar, R.color.colorDefault);
|
||||||
|
|
||||||
|
if(mShowLoginAgainPreference.get()) {
|
||||||
|
mShowLoginAgainPreference.set(false);
|
||||||
|
showError(R.string.login_again);
|
||||||
|
}
|
||||||
|
|
||||||
mCallback.logout(Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID), true, null);
|
mCallback.logout(Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID), true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
|||||||
@Inject
|
@Inject
|
||||||
RegisterService mRegisterService;
|
RegisterService mRegisterService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named(AppPrefsConstants.SHOW_LOGIN_AGAIN)
|
||||||
|
BooleanPreference mShowLoginAgainPreference;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named(AppPrefsConstants.API_ENDPOINT)
|
@Named(AppPrefsConstants.API_ENDPOINT)
|
||||||
StringPreference mApiEndpointPreference;
|
StringPreference mApiEndpointPreference;
|
||||||
@@ -451,6 +455,7 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(RegisterResponse registerResponse) {
|
public void onNext(RegisterResponse registerResponse) {
|
||||||
Log.d(TAG, "onNext: " + registerResponse);
|
Log.d(TAG, "onNext: " + registerResponse);
|
||||||
|
getView().showError("Topkek");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -493,17 +498,24 @@ public class LoginPresenter extends MVPAbstractPresenter<LoginView> implements L
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(JsonObject response) {
|
public void onNext(JsonObject response) {
|
||||||
if (!response.has("result") || response.get("result") == null) {
|
if (!response.has("result") || response.get("result") == null) {
|
||||||
logoutNavigation.logoutDirectly();
|
logoutNavigation.logoutDirectly(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = response.get("result").getAsInt();
|
int result = response.get("result").getAsInt();
|
||||||
|
|
||||||
|
boolean shouldClearAllPrefs = false;
|
||||||
|
|
||||||
if(result == 0) {
|
if(result == 0) {
|
||||||
deleteData(true);
|
deleteData(true);
|
||||||
|
shouldClearAllPrefs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
logoutNavigation.logoutDirectly();
|
if(result == 1) {
|
||||||
|
mShowLoginAgainPreference.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
logoutNavigation.logoutDirectly(shouldClearAllPrefs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ package com.p3.bewoplaner.page.main;
|
|||||||
|
|
||||||
public interface LogoutNavigation {
|
public interface LogoutNavigation {
|
||||||
|
|
||||||
void logoutDirectly();
|
void logoutDirectly(boolean clearAllPrefs);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -53,8 +53,7 @@ import de.hdodenhof.circleimageview.CircleImageView;
|
|||||||
/**
|
/**
|
||||||
* Created by imarneanu on 2/9/17.
|
* Created by imarneanu on 2/9/17.
|
||||||
*/
|
*/
|
||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity implements MainNavigation, LogoutNavigation {
|
||||||
implements MainNavigation, LogoutNavigation {
|
|
||||||
|
|
||||||
private static final String REDIRECT_TO_CHAT = "redirect_to_chat";
|
private static final String REDIRECT_TO_CHAT = "redirect_to_chat";
|
||||||
private static final String BUNDLE = "bundle";
|
private static final String BUNDLE = "bundle";
|
||||||
@@ -228,6 +227,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
mLoginPresenter.logout(Settings.Secure.getString(MainActivity.this.getContentResolver(), Settings.Secure.ANDROID_ID), false, this);
|
mLoginPresenter.logout(Settings.Secure.getString(MainActivity.this.getContentResolver(), Settings.Secure.ANDROID_ID), false, this);
|
||||||
},
|
},
|
||||||
(dialog, which) -> dialog.dismiss());
|
(dialog, which) -> dialog.dismiss());
|
||||||
|
|
||||||
if (!isFinishing()) {
|
if (!isFinishing()) {
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
}
|
}
|
||||||
@@ -241,8 +241,8 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logoutDirectly() {
|
public void logoutDirectly(boolean clearAllPrefs) {
|
||||||
mLoginPresenter.logout(Settings.Secure.getString(MainActivity.this.getContentResolver(), Settings.Secure.ANDROID_ID), true, this);
|
mLoginPresenter.logout(Settings.Secure.getString(MainActivity.this.getContentResolver(), Settings.Secure.ANDROID_ID), clearAllPrefs, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -251,7 +251,9 @@ public class MainActivity extends AppCompatActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
startActivity(new Intent(MainActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
|
Intent intent = new Intent(MainActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +267,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLogoutDirectlyEvent(LogoutDirectlyEvent logoutDirectlyEvent) {
|
public void onLogoutDirectlyEvent(LogoutDirectlyEvent logoutDirectlyEvent) {
|
||||||
logoutDirectly();
|
logoutDirectly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user