Refactoring login
This commit is contained in:
parent
e3ebfcb27d
commit
55c1cb40a2
@ -134,7 +134,6 @@ dependencies {
|
||||
implementation 'com.github.cachapa:ExpandableLayout:2.9.2'
|
||||
implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
|
||||
implementation 'com.github.fede87:StatusBarAlert:1.0.1'
|
||||
implementation 'com.github.akshay2211:Stash:master'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
implementation 'com.github.zhukic:sectioned-recyclerview:1.2.3'
|
||||
implementation 'com.github.pedromassango:doubleClick:3.0'
|
||||
|
||||
@ -19,6 +19,8 @@ import it.integry.integrywmsnative.gest.contenuto_bancale.ContenutoBancaleCompon
|
||||
import it.integry.integrywmsnative.gest.contenuto_bancale.ContenutoBancaleModule;
|
||||
import it.integry.integrywmsnative.gest.lista_bancali.ListaBancaliComponent;
|
||||
import it.integry.integrywmsnative.gest.lista_bancali.ListaBancaliModule;
|
||||
import it.integry.integrywmsnative.gest.login.LoginComponent;
|
||||
import it.integry.integrywmsnative.gest.login.LoginModule;
|
||||
import it.integry.integrywmsnative.gest.main.MainActivityComponent;
|
||||
import it.integry.integrywmsnative.gest.main.MainActivityModule;
|
||||
import it.integry.integrywmsnative.gest.main.MainFragmentComponent;
|
||||
@ -76,6 +78,7 @@ import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCr
|
||||
RoomModule.class,
|
||||
SplashActivityModule.class,
|
||||
MainApplicationModule.class,
|
||||
LoginModule.class,
|
||||
MainActivityModule.class,
|
||||
MainFragmentModule.class,
|
||||
MainAccettazioneModule.class,
|
||||
@ -111,6 +114,7 @@ import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCr
|
||||
public interface MainApplicationComponent {
|
||||
|
||||
SplashActivityComponent.Factory splashActivityComponent();
|
||||
LoginComponent.Factory loginActivityComponent();
|
||||
MainActivityComponent.Factory mainActivityComponent();
|
||||
MainFragmentComponent.Factory mainFragmentComponent();
|
||||
MainAccettazioneComponent.Factory mainAccettazioneComponent();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package it.integry.integrywmsnative;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@ -38,6 +39,12 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
||||
|
||||
private RunnableArgsss<Integer, String[], List<Integer>> onRequestPermissionResult;
|
||||
|
||||
public static void startActivity(Context context) {
|
||||
Intent intent = new Intent(context, SplashActivity.class);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@ -100,7 +100,11 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
public static void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
getAvailableCodMdepsStatic(onSuccess, onFailed);
|
||||
}
|
||||
|
||||
public static void getAvailableCodMdepsStatic(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
||||
service.getAvailableCodMdeps().enqueue(new Callback<>() {
|
||||
|
||||
@ -130,7 +130,7 @@ public class SettingsManager {
|
||||
}
|
||||
|
||||
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
SystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
SystemRESTConsumer.getAvailableCodMdepsStatic(availableCodMdeps -> {
|
||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
|
||||
@ -13,13 +13,19 @@ import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by akshay on 01/03/18.
|
||||
*/
|
||||
|
||||
public class Stash {
|
||||
|
||||
private static Stash stash;
|
||||
private static Context instance;
|
||||
private SharedPreferences sp;
|
||||
|
||||
public static void init(Context context) {
|
||||
stash = new Stash();
|
||||
instance = context;
|
||||
if (stash.sp == null) {
|
||||
stash.sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
@ -34,7 +40,7 @@ public class Stash {
|
||||
public static void put(String key, String value) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().putString(key, value).apply();
|
||||
stash.sp.edit().putString(key, value).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -44,7 +50,7 @@ public class Stash {
|
||||
public static void put(String key, Set<String> value) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().putStringSet(key, value).apply();
|
||||
stash.sp.edit().putStringSet(key, value).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -54,7 +60,7 @@ public class Stash {
|
||||
public static void put(String key, int value) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().putInt(key, value).apply();
|
||||
stash.sp.edit().putInt(key, value).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -64,7 +70,7 @@ public class Stash {
|
||||
public static void put(String key, long value) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().putLong(key, value).apply();
|
||||
stash.sp.edit().putLong(key, value).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -74,7 +80,7 @@ public class Stash {
|
||||
public static void put(String key, float value) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().putFloat(key, value).apply();
|
||||
stash.sp.edit().putFloat(key, value).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -84,7 +90,7 @@ public class Stash {
|
||||
public static void put(String key, boolean value) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().putBoolean(key, value).apply();
|
||||
stash.sp.edit().putBoolean(key, value).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -95,7 +101,7 @@ public class Stash {
|
||||
checkfornull();
|
||||
try {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
stash.sp.edit().putString(key, gson.toJson(value).toString()).apply();
|
||||
stash.sp.edit().putString(key, gson.toJson(value)).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -112,18 +118,26 @@ public class Stash {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
return getString(key, "");
|
||||
}
|
||||
|
||||
|
||||
//getStringSet
|
||||
public static Set<String> getStringSet(String key, Set<String> defaultvalue) {
|
||||
checkfornull();
|
||||
try {
|
||||
return getStringSet(key, defaultvalue);
|
||||
return stash.sp.getStringSet(key, defaultvalue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return defaultvalue;
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getStringSet(String key) {
|
||||
return getStringSet(key, null);
|
||||
}
|
||||
|
||||
//getInt
|
||||
public static int getInt(String key, int defaultvalue) {
|
||||
checkfornull();
|
||||
@ -135,6 +149,10 @@ public class Stash {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getInt(String key) {
|
||||
return getInt(key, 0);
|
||||
}
|
||||
|
||||
//getLong
|
||||
public static long getLong(String key, long defaultvalue) {
|
||||
checkfornull();
|
||||
@ -146,6 +164,10 @@ public class Stash {
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLong(String key) {
|
||||
return getLong(key, (long) 0);
|
||||
}
|
||||
|
||||
//getFloat
|
||||
public static float getFloat(String key, float defaultvalue) {
|
||||
checkfornull();
|
||||
@ -157,6 +179,10 @@ public class Stash {
|
||||
}
|
||||
}
|
||||
|
||||
public static float getFloat(String key) {
|
||||
return getFloat(key, 0.0f);
|
||||
}
|
||||
|
||||
//getBoolean
|
||||
public static boolean getBoolean(String key, boolean defaultvalue) {
|
||||
checkfornull();
|
||||
@ -168,6 +194,10 @@ public class Stash {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key) {
|
||||
return getBoolean(key, false);
|
||||
}
|
||||
|
||||
//getObject
|
||||
public static <T> Object getObject(String key, Class<?> tClass) {
|
||||
checkfornull();
|
||||
@ -196,7 +226,7 @@ public class Stash {
|
||||
public static void clear(String key) {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().remove(key).apply();
|
||||
stash.sp.edit().remove(key).commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -206,12 +236,22 @@ public class Stash {
|
||||
public static void clearAll() {
|
||||
checkfornull();
|
||||
try {
|
||||
stash.sp.edit().clear().apply();
|
||||
stash.sp.edit().clear().commit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addListener(StashListener listener){
|
||||
checkfornull();
|
||||
stash.sp.registerOnSharedPreferenceChangeListener(listener);
|
||||
}
|
||||
|
||||
public static void removeListener(StashListener listener){
|
||||
checkfornull();
|
||||
stash.sp.unregisterOnSharedPreferenceChangeListener(listener);
|
||||
}
|
||||
|
||||
private static class GenericType implements ParameterizedType {
|
||||
|
||||
private Type type;
|
||||
@ -238,4 +278,7 @@ public class Stash {
|
||||
// implement equals method too! (as per javadoc)
|
||||
}
|
||||
|
||||
public interface StashListener extends SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,48 @@
|
||||
package it.integry.integrywmsnative.gest.login;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.SplashActivity;
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseActivity;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityWindow;
|
||||
import it.integry.integrywmsnative.databinding.ActivityLoginBinding;
|
||||
import it.integry.integrywmsnative.gest.login.viewmodel.LoginViewModel;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
public class LoginActivity extends BaseActivity implements LoginViewModel.Listener {
|
||||
|
||||
ActivityLoginBinding mBindings;
|
||||
|
||||
@Inject
|
||||
LoginViewModel mViewmodel;
|
||||
|
||||
|
||||
public BindableString username = new BindableString();
|
||||
public BindableString password = new BindableString();
|
||||
public BindableString codAzienda = new BindableString();
|
||||
|
||||
public BindableBoolean customSettingsCheckboxEnabled = new BindableBoolean();
|
||||
public BindableBoolean customSettingsCheckboxChecked = new BindableBoolean();
|
||||
|
||||
public BindableBoolean loginButtonEnabled = new BindableBoolean();
|
||||
|
||||
|
||||
public BindableString usernameError = new BindableString();
|
||||
public BindableString passwordError = new BindableString();
|
||||
public BindableString codAziendaError = new BindableString();
|
||||
|
||||
|
||||
@Override
|
||||
@ -18,9 +50,44 @@ public class LoginActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
UtilityWindow.maximizeToFullScreen(this);
|
||||
|
||||
ActivityLoginBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_login);
|
||||
LoginViewModel loginViewModel = new LoginViewModel(this);
|
||||
binding.setLoginViewModel(loginViewModel);
|
||||
mBindings = DataBindingUtil.setContentView(this, R.layout.activity_login);
|
||||
mBindings.setView(this);
|
||||
|
||||
MainApplication.appComponent
|
||||
.loginActivityComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
mViewmodel.setListener(this);
|
||||
|
||||
loginButtonEnabled.set(true);
|
||||
|
||||
codAzienda.set(SettingsManager.i().getServer().getCodAzienda());
|
||||
|
||||
customSettingsCheckboxChecked.set(SettingsManager.i().getServer().getHost() == null);
|
||||
customSettingsCheckboxEnabled.set(SettingsManager.i().getServer().getHost() != null);
|
||||
}
|
||||
|
||||
|
||||
public boolean validate(String username, String codAzienda) {
|
||||
if (username.isEmpty() || username.length() < 3) {
|
||||
usernameError.set(getText(R.string.username_error_not_valid).toString());
|
||||
return false;
|
||||
} else usernameError.set(null);
|
||||
|
||||
if (codAzienda.isEmpty() || codAzienda.length() < 3) {
|
||||
codAziendaError.set(getText(R.string.server_cod_azienda_error_not_valid).toString());
|
||||
return false;
|
||||
} else codAziendaError.set(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void login() {
|
||||
if (validate(username.get(), codAzienda.get())) {
|
||||
loginButtonEnabled.set(false);
|
||||
mViewmodel.login(codAzienda.get(), username.get(), password.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,4 +96,65 @@ public class LoginActivity extends BaseActivity {
|
||||
// disable going back to the MainActivity
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginCompleted(String host, int port, String fullName, List<String> availableProfiles) {
|
||||
|
||||
this.onLoadingEnded();
|
||||
runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(
|
||||
"Benvenuto",
|
||||
Html.fromHtml("Ciao <b>" + fullName + "</b>, la Integry le augura di svolgere al meglio il suo lavoro"),
|
||||
null,
|
||||
() -> showProfileDBSelectionDialog(host, port, availableProfiles))
|
||||
.show(getSupportFragmentManager(), "tag"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(Exception ex) {
|
||||
super.onError(ex);
|
||||
loginButtonEnabled.set(true);
|
||||
}
|
||||
|
||||
private void showProfileDBSelectionDialog(final String host, final int port, final List<String> availableProfiles) {
|
||||
Runnable onComplete = () -> {
|
||||
SettingsManager.update();
|
||||
|
||||
startSplashActivity();
|
||||
};
|
||||
|
||||
loginButtonEnabled.set(true);
|
||||
|
||||
if (availableProfiles != null && availableProfiles.size() == 1) {
|
||||
SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(0));
|
||||
|
||||
mViewmodel.loadDepo(codAzienda.get(), host, port, username.get(), password.get(), onComplete);
|
||||
} else {
|
||||
|
||||
// setup the alert builder
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.action_choose_profile_db);
|
||||
|
||||
// add a list
|
||||
String[] profiles = new String[availableProfiles.size()];
|
||||
profiles = availableProfiles
|
||||
.toArray(profiles);
|
||||
|
||||
builder.setItems(profiles, (dialog, which) -> {
|
||||
SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(which));
|
||||
|
||||
mViewmodel.loadDepo(codAzienda.get(), host, port, username.get(), password.get(), onComplete);
|
||||
});
|
||||
|
||||
// create and show the alert dialog
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void startSplashActivity() {
|
||||
finish();
|
||||
SplashActivity.startActivity(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.integrywmsnative.gest.login;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface LoginComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
LoginComponent create();
|
||||
}
|
||||
|
||||
void inject(LoginActivity loginActivity);
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package it.integry.integrywmsnative.gest.login;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.login.rest.LoginRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.login.viewmodel.LoginViewModel;
|
||||
|
||||
@Module(subcomponents = LoginComponent.class)
|
||||
public class LoginModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
LoginRESTConsumer provideLoginRESTConsumer() {
|
||||
return new LoginRESTConsumer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
LoginViewModel providesSpedizioneViewModel(SystemRESTConsumer systemRESTConsumer, LoginRESTConsumer loginRESTConsumer) {
|
||||
return new LoginViewModel(systemRESTConsumer, loginRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
package it.integry.integrywmsnative.gest.login.core;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import it.integry.integrywmsnative.core.CommonConst;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback;
|
||||
import it.integry.integrywmsnative.core.rest.model.EsitoType;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
|
||||
import it.integry.integrywmsnative.gest.login.dto.LoginDTO;
|
||||
import it.integry.integrywmsnative.gest.login.rest.LoginRESTConsumerService;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class LoginHelper {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private String mCodAzienda;
|
||||
private String mUsername;
|
||||
private String mPassword;
|
||||
|
||||
public LoginHelper(Context context, String codAzienda, String username, String password){
|
||||
this.mContext = context;
|
||||
|
||||
this.mCodAzienda = codAzienda;
|
||||
this.mUsername = username;
|
||||
this.mPassword = password;
|
||||
}
|
||||
|
||||
|
||||
public void retrieveServerData(final ISimpleOperationCallback<LoginAziendaDTO> callback){
|
||||
|
||||
String host = CommonConst.Login.Azienda.host;
|
||||
int port = CommonConst.Login.Azienda.port;
|
||||
|
||||
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, host, port, false, true);
|
||||
service.loginAzienda(mCodAzienda).enqueue(new Callback<ServiceRESTResponse<LoginAziendaDTO>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.body() != null) {
|
||||
if(response.body().getEsito() == EsitoType.OK) {
|
||||
callback.onSuccess(response.body().getDto());
|
||||
} else {
|
||||
Log.e("LoginAzienda", response.body().getErrorMessage());
|
||||
callback.onFailed(new Exception(response.body().getErrorMessage()));
|
||||
}
|
||||
} else {
|
||||
Log.e("LoginAzienda", response.message());
|
||||
callback.onFailed(new Exception(response.message()));
|
||||
}
|
||||
} else {
|
||||
Log.e("LoginAzienda", "Status " + response.code() + ": " + response.message());
|
||||
callback.onFailed(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Throwable t) {
|
||||
Log.e("LoginAzienda", t.toString());
|
||||
callback.onFailed(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void doLogin(String host, int port, final ISimpleOperationCallback<LoginDTO> callback){
|
||||
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, host, port, false);
|
||||
service.login(mUsername, mPassword).enqueue(new Callback<ServiceRESTResponse<LoginDTO>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<LoginDTO>> call, Response<ServiceRESTResponse<LoginDTO>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.body() != null) {
|
||||
if(response.body().getEsito() == EsitoType.OK) {
|
||||
callback.onSuccess(response.body().getDto());
|
||||
} else {
|
||||
Log.e("Login", response.body().getErrorMessage());
|
||||
callback.onFailed(new Exception(response.body().getErrorMessage()));
|
||||
}
|
||||
} else {
|
||||
Log.e("Login", response.message());
|
||||
callback.onFailed(new Exception(response.message()));
|
||||
}
|
||||
} else {
|
||||
Log.e("Login", "Status " + response.code() + ": " + response.message());
|
||||
callback.onFailed(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<LoginDTO>> call, final Throwable t) {
|
||||
|
||||
Log.e("Login", t.toString());
|
||||
callback.onFailed(new Exception(t));
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -2,10 +2,54 @@ package it.integry.integrywmsnative.gest.login.dto;
|
||||
|
||||
public class LoginAziendaDTO {
|
||||
|
||||
public String profileDb;
|
||||
public String endpointRestApi;
|
||||
public String phpApi;
|
||||
public String repoPhoto;
|
||||
public String endpointPvm;
|
||||
private String profileDb;
|
||||
private String endpointRestApi;
|
||||
private String phpApi;
|
||||
private String repoPhoto;
|
||||
private String endpointPvm;
|
||||
|
||||
public String getProfileDb() {
|
||||
return profileDb;
|
||||
}
|
||||
|
||||
public LoginAziendaDTO setProfileDb(String profileDb) {
|
||||
this.profileDb = profileDb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEndpointRestApi() {
|
||||
return endpointRestApi;
|
||||
}
|
||||
|
||||
public LoginAziendaDTO setEndpointRestApi(String endpointRestApi) {
|
||||
this.endpointRestApi = endpointRestApi;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhpApi() {
|
||||
return phpApi;
|
||||
}
|
||||
|
||||
public LoginAziendaDTO setPhpApi(String phpApi) {
|
||||
this.phpApi = phpApi;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRepoPhoto() {
|
||||
return repoPhoto;
|
||||
}
|
||||
|
||||
public LoginAziendaDTO setRepoPhoto(String repoPhoto) {
|
||||
this.repoPhoto = repoPhoto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEndpointPvm() {
|
||||
return endpointPvm;
|
||||
}
|
||||
|
||||
public LoginAziendaDTO setEndpointPvm(String endpointPvm) {
|
||||
this.endpointPvm = endpointPvm;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,24 @@ import java.util.List;
|
||||
|
||||
public class LoginDTO {
|
||||
|
||||
public String full_name;
|
||||
public List<String> availableProfiles;
|
||||
private String full_name;
|
||||
private List<String> availableProfiles;
|
||||
|
||||
public String getFull_name() {
|
||||
return full_name;
|
||||
}
|
||||
|
||||
public LoginDTO setFull_name(String full_name) {
|
||||
this.full_name = full_name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getAvailableProfiles() {
|
||||
return availableProfiles;
|
||||
}
|
||||
|
||||
public LoginDTO setAvailableProfiles(List<String> availableProfiles) {
|
||||
this.availableProfiles = availableProfiles;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package it.integry.integrywmsnative.gest.login.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class InvalidServerCodAziendaException extends Exception {
|
||||
|
||||
public InvalidServerCodAziendaException(String codAzienda, Throwable cause) {
|
||||
super(String.format(UtilityResources.getString(R.string.server_cod_azienda_not_valid), codAzienda), cause);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package it.integry.integrywmsnative.gest.login.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class InvalidUserDepositException extends Exception {
|
||||
|
||||
public InvalidUserDepositException() {
|
||||
super(UtilityResources.getString(R.string.no_codmdep_available));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package it.integry.integrywmsnative.gest.login.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class InvalidUsernameException extends Exception {
|
||||
|
||||
public InvalidUsernameException() {
|
||||
super(UtilityResources.getString(R.string.username_error_not_valid));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package it.integry.integrywmsnative.gest.login.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class ServerNotReachableException extends Exception {
|
||||
|
||||
public ServerNotReachableException(String host, int port, Throwable cause) {
|
||||
super(String.format(UtilityResources.getString(R.string.server_not_reachable), host, port), cause);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package it.integry.integrywmsnative.gest.login.rest;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.CommonConst;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
|
||||
import it.integry.integrywmsnative.gest.login.dto.LoginDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
@Singleton
|
||||
public class LoginRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
|
||||
public void retrieveServerData(String codAzienda, RunnableArgs<LoginAziendaDTO> onComplete, RunnableArgs<Exception> onFailed){
|
||||
|
||||
String host = CommonConst.Login.Azienda.host;
|
||||
int port = CommonConst.Login.Azienda.port;
|
||||
|
||||
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, host, port, false, true);
|
||||
service.loginAzienda(codAzienda).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {
|
||||
analyzeAnswer(response, "LoginAzienda", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Throwable t) {
|
||||
Log.e("LoginAzienda", t.toString());
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void authenticate(String host, int port, String username, String password, RunnableArgs<LoginDTO> onComplete, RunnableArgs<Exception> onFailed){
|
||||
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, host, port, false);
|
||||
service.login(username, password).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<LoginDTO>> call, Response<ServiceRESTResponse<LoginDTO>> response) {
|
||||
analyzeAnswer(response, "Login", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<LoginDTO>> call, final Throwable t) {
|
||||
Log.e("Login", t.toString());
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,167 +1,103 @@
|
||||
package it.integry.integrywmsnative.gest.login.viewmodel;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.SplashActivity;
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityServer;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.gest.login.LoginActivity;
|
||||
import it.integry.integrywmsnative.gest.login.core.LoginHelper;
|
||||
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
|
||||
import it.integry.integrywmsnative.gest.login.dto.LoginDTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
import it.integry.integrywmsnative.gest.login.exception.InvalidServerCodAziendaException;
|
||||
import it.integry.integrywmsnative.gest.login.exception.InvalidUserDepositException;
|
||||
import it.integry.integrywmsnative.gest.login.exception.ServerNotReachableException;
|
||||
import it.integry.integrywmsnative.gest.login.rest.LoginRESTConsumer;
|
||||
|
||||
public class LoginViewModel {
|
||||
|
||||
public BindableString username = new BindableString();
|
||||
public BindableString password = new BindableString();
|
||||
public BindableString codAzienda = new BindableString();
|
||||
|
||||
public BindableBoolean customSettingsCheckboxEnabled = new BindableBoolean();
|
||||
public BindableBoolean customSettingsCheckboxChecked = new BindableBoolean();
|
||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
||||
private final LoginRESTConsumer mLoginRESTConsumer;
|
||||
|
||||
public BindableBoolean loginButtonEnabled = new BindableBoolean();
|
||||
private Listener mListener;
|
||||
|
||||
|
||||
public BindableString usernameError = new BindableString();
|
||||
public BindableString passwordError = new BindableString();
|
||||
public BindableString codAziendaError = new BindableString();
|
||||
|
||||
|
||||
private LoginActivity mActivity;
|
||||
|
||||
private Dialog mProgress;
|
||||
|
||||
public LoginViewModel(LoginActivity activity) {
|
||||
this.mActivity = activity;
|
||||
|
||||
loginButtonEnabled.set(true);
|
||||
|
||||
codAzienda.set(SettingsManager.i().getServer().getCodAzienda());
|
||||
|
||||
customSettingsCheckboxChecked.set(SettingsManager.i().getServer().getHost() == null);
|
||||
customSettingsCheckboxEnabled.set(SettingsManager.i().getServer().getHost() != null);
|
||||
@Inject
|
||||
public LoginViewModel(SystemRESTConsumer systemRESTConsumer, LoginRESTConsumer loginRESTConsumer) {
|
||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
||||
this.mLoginRESTConsumer = loginRESTConsumer;
|
||||
}
|
||||
|
||||
|
||||
public boolean validate() {
|
||||
if (username.isEmpty() || username.get().length() < 3) {
|
||||
usernameError.set(mActivity.getText(R.string.username_error_not_valid).toString());
|
||||
return false;
|
||||
} else usernameError.set(null);
|
||||
public void login(String codAzienda, String username, String password) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
if (codAzienda.isEmpty() || codAzienda.get().length() < 3) {
|
||||
codAziendaError.set(mActivity.getText(R.string.server_cod_azienda_not_valid).toString());
|
||||
return false;
|
||||
} else codAziendaError.set(null);
|
||||
mLoginRESTConsumer.retrieveServerData(codAzienda, value -> {
|
||||
|
||||
return true;
|
||||
}
|
||||
final String serverEndpoint = value.getEndpointRestApi();
|
||||
|
||||
URL u;
|
||||
try {
|
||||
u = new URL(serverEndpoint);
|
||||
} catch (final MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
this.sendError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
public void login(boolean areValidData) {
|
||||
if (areValidData) {
|
||||
loginButtonEnabled.set(false);
|
||||
final String host = u.getHost();
|
||||
final int port = u.getPort();
|
||||
|
||||
mProgress = UtilityProgress.createDefaultProgressDialog(mActivity);
|
||||
UtilityServer.isEmsApiAvailable(host, port, value1 -> {
|
||||
|
||||
final LoginHelper loginHelper = new LoginHelper(mActivity, codAzienda.get(), username.get(), password.get());
|
||||
if (value1) { //Is online
|
||||
mLoginRESTConsumer.authenticate(host, port, username, password, loginDTO -> {
|
||||
|
||||
loginHelper.retrieveServerData(new ISimpleOperationCallback<LoginAziendaDTO>() {
|
||||
SettingsManager.iDB().setAvailableProfiles(loginDTO.getAvailableProfiles());
|
||||
|
||||
@Override
|
||||
public void onSuccess(LoginAziendaDTO value) {
|
||||
SettingsManager.i().createUserSession();
|
||||
SettingsManager.i().getUser().setFullname(!UtilityString.isNullOrEmpty(loginDTO.getFull_name()) ? loginDTO.getFull_name() : username);
|
||||
|
||||
final String serverEndpoint = value.endpointRestApi;
|
||||
|
||||
URL u;
|
||||
try {
|
||||
u = new URL(serverEndpoint);
|
||||
} catch (final MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
onLoginFailed(new SpannableString(e.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
final String host = u.getHost();
|
||||
final int port = u.getPort();
|
||||
|
||||
UtilityServer.isEmsApiAvailable(host, port, value1 -> {
|
||||
|
||||
if (value1) { //Is online
|
||||
loginHelper.doLogin(host, port, new ISimpleOperationCallback<LoginDTO>() {
|
||||
@Override
|
||||
public void onSuccess(final LoginDTO loginDTO) {
|
||||
|
||||
SettingsManager.iDB().setAvailableProfiles(loginDTO.availableProfiles);
|
||||
|
||||
SettingsManager.i().createUserSession();
|
||||
SettingsManager.i().getUser().setFullname(!UtilityString.isNullOrEmpty(loginDTO.full_name) ? loginDTO.full_name : username.get());
|
||||
|
||||
|
||||
mActivity.runOnUiThread(() -> onLoginSuccess(
|
||||
"Benvenuto",
|
||||
Html.fromHtml("Ciao <b>" + loginDTO.full_name + "</b>, la Integry le augura di svolgere al meglio il suo lavoro"),
|
||||
host, port, loginDTO.availableProfiles));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(final Exception ex) {
|
||||
onLoginFailed(new SpannableString(ex.getMessage()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else { //Is not online
|
||||
onLoginFailed(Html.fromHtml(String.format(mActivity.getText(R.string.server_not_reachable).toString(), host, port)));
|
||||
List<String> availableProfiles = null;
|
||||
if(loginDTO.getAvailableProfiles() != null && !loginDTO.getAvailableProfiles().isEmpty()) {
|
||||
availableProfiles = Stream.of(loginDTO.getAvailableProfiles())
|
||||
.sorted()
|
||||
.toList();
|
||||
}
|
||||
|
||||
});
|
||||
this.sendOnLoginCompleted(host, port, loginDTO.getFull_name(), availableProfiles);
|
||||
}, this::sendError);
|
||||
|
||||
|
||||
} else { //Is not online
|
||||
this.sendError(new ServerNotReachableException(host, port, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
onLoginFailed(Html.fromHtml(String.format(mActivity.getText(R.string.server_cod_azienda_not_valid).toString(), codAzienda.get())));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}, ex -> {
|
||||
this.sendError(new InvalidServerCodAziendaException(codAzienda, ex));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void loadDepo(String host, int port, Runnable onComplete) {
|
||||
public void loadDepo(String codAzienda, String host, int port, String username, String password, Runnable onComplete) {
|
||||
|
||||
SettingsManager.i().getServer().setCodAzienda(codAzienda.get());
|
||||
SettingsManager.i().getServer().setCodAzienda(codAzienda);
|
||||
SettingsManager.i().getServer().setHost(host);
|
||||
SettingsManager.i().getServer().setPort(port);
|
||||
|
||||
SettingsManager.i().getUser().setUsername(username.get());
|
||||
SettingsManager.i().getUser().setPassword(password.get());
|
||||
SettingsManager.i().getUser().setUsername(username);
|
||||
SettingsManager.i().getUser().setPassword(password);
|
||||
|
||||
SystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
this.mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
SettingsManager.iDB().setAvailableCodMdep(availableCodMdeps);
|
||||
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
onLoginFailed(Html.fromHtml(String.format(mActivity.getText(R.string.no_codmdep_available).toString())));
|
||||
this.sendError(new InvalidUserDepositException());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,72 +105,36 @@ public class LoginViewModel {
|
||||
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
//BOH
|
||||
onLoginFailed(new SpannableString(ex.getMessage()));
|
||||
});
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
private void onLoginFailed(final Spanned message) {
|
||||
mProgress.dismiss();
|
||||
loginButtonEnabled.set(true);
|
||||
mActivity.runOnUiThread(() -> DialogSimpleMessageView.makeErrorDialog(
|
||||
message,
|
||||
null,
|
||||
null)
|
||||
.show(mActivity.getSupportFragmentManager(), "tag"));
|
||||
private void sendOnLoadingStarted() {
|
||||
if (this.mListener != null) mListener.onLoadingStarted();
|
||||
}
|
||||
|
||||
|
||||
private void onLoginSuccess(final String title, final Spanned message, final String host, final int port, final List<String> availableProfiles) {
|
||||
mProgress.dismiss();
|
||||
mActivity.runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(
|
||||
title,
|
||||
message,
|
||||
null,
|
||||
() -> showProfileDBSelectionDialog(host, port, availableProfiles))
|
||||
.show(mActivity.getSupportFragmentManager(), "tag"));
|
||||
private void sendOnLoadingEnded() {
|
||||
if (this.mListener != null) mListener.onLoadingEnded();
|
||||
}
|
||||
|
||||
private void showProfileDBSelectionDialog(final String host, final int port, final List<String> availableProfiles) {
|
||||
if (availableProfiles != null && availableProfiles.size() == 1) {
|
||||
SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(0));
|
||||
|
||||
loadDepo(host, port, this::onLoginCompleted);
|
||||
} else {
|
||||
|
||||
// setup the alert builder
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||
builder.setTitle(R.string.action_choose_profile_db);
|
||||
|
||||
// add a list
|
||||
String[] profiles = new String[availableProfiles.size()];
|
||||
profiles = availableProfiles.toArray(profiles);
|
||||
builder.setItems(profiles, (dialog, which) -> {
|
||||
SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(which));
|
||||
|
||||
loadDepo(host, port, this::onLoginCompleted);
|
||||
});
|
||||
|
||||
// create and show the alert dialog
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
private void sendOnLoginCompleted(String host, int port, String fullName, List<String> availableProfiles) {
|
||||
if (this.mListener != null)
|
||||
mListener.onLoginCompleted(host, port, fullName, availableProfiles);
|
||||
}
|
||||
|
||||
public void onLoginCompleted() {
|
||||
loginButtonEnabled.set(true);
|
||||
SettingsManager.update();
|
||||
|
||||
startSplashActivity();
|
||||
private void sendError(Exception ex) {
|
||||
if (this.mListener != null) mListener.onError(ex);
|
||||
}
|
||||
|
||||
public LoginViewModel setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void startSplashActivity() {
|
||||
mActivity.finish();
|
||||
Intent myIntent = new Intent(mActivity, SplashActivity.class);
|
||||
mActivity.startActivity(myIntent);
|
||||
public interface Listener extends ILoadingListener {
|
||||
void onError(Exception ex);
|
||||
|
||||
void onLoginCompleted(String host, int port, String fullName, List<String> availableProfiles);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="loginViewModel"
|
||||
type="it.integry.integrywmsnative.gest.login.viewmodel.LoginViewModel" />
|
||||
name="view"
|
||||
type="it.integry.integrywmsnative.gest.login.LoginActivity" />
|
||||
</data>
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:errorText="@{loginViewModel.usernameError}"
|
||||
app:errorText="@{view.usernameError}"
|
||||
app:hintTextAppearance="@style/hint_text"
|
||||
style="@style/TextInputLayout.OutlinePrimary">
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Username"
|
||||
android:inputType="textEmailAddress"
|
||||
app:binding="@{loginViewModel.username}" />
|
||||
app:binding="@{view.username}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<!-- Password Label -->
|
||||
@ -55,7 +55,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:errorText="@{loginViewModel.passwordError}"
|
||||
app:errorText="@{view.passwordError}"
|
||||
app:hintTextAppearance="@style/hint_text"
|
||||
app:passwordToggleEnabled="true"
|
||||
style="@style/TextInputLayout.OutlinePrimary">
|
||||
@ -66,16 +66,16 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Password"
|
||||
android:inputType="textPassword"
|
||||
app:binding="@{loginViewModel.password}" />
|
||||
app:binding="@{view.password}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckBox
|
||||
android:id="@+id/login_checkbox_custom_server"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="@{loginViewModel.customSettingsCheckboxEnabled}"
|
||||
android:enabled="@{view.customSettingsCheckboxEnabled}"
|
||||
android:text="@string/action_customize_server_settings"
|
||||
app:checked="@{loginViewModel.customSettingsCheckboxChecked}" />
|
||||
app:checked="@{view.customSettingsCheckboxChecked}" />
|
||||
|
||||
<net.cachapa.expandablelayout.ExpandableLayout
|
||||
android:id="@+id/login_layout_server_details"
|
||||
@ -84,7 +84,7 @@
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="12dp"
|
||||
app:el_duration="400"
|
||||
app:el_expanded_bind="@{loginViewModel.customSettingsCheckboxChecked}">
|
||||
app:el_expanded_bind="@{view.customSettingsCheckboxChecked}">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -96,7 +96,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
app:errorText="@{loginViewModel.codAziendaError}"
|
||||
app:errorText="@{view.codAziendaError}"
|
||||
app:hintTextAppearance="@style/hint_text"
|
||||
style="@style/TextInputLayout.OutlinePrimary">
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Codice azienda"
|
||||
android:inputType="text"
|
||||
app:binding="@{loginViewModel.codAzienda}" />
|
||||
app:binding="@{view.codAzienda}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@ -121,9 +121,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:enabled="@{loginViewModel.loginButtonEnabled}"
|
||||
android:enabled="@{view.loginButtonEnabled}"
|
||||
android:text="@string/login"
|
||||
app:onClick="@{() -> loginViewModel.login(loginViewModel.validate())}" />
|
||||
app:onClick="@{() -> view.login()}" />
|
||||
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user