added on viewmodels
This commit is contained in:
parent
17cf9c2ac4
commit
08c2b90141
|
|
@ -1,7 +1,11 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
}
|
}
|
||||||
|
def environmentExtractor = { File path ->
|
||||||
|
def rawJson = path.text
|
||||||
|
def escapedJson = rawJson.replace("\"", "\\\"").replace("\n", "").replace("\r", "")
|
||||||
|
return "\"${escapedJson}\""
|
||||||
|
}
|
||||||
def Properties properties = new Properties()
|
def Properties properties = new Properties()
|
||||||
properties.load(project.rootProject.file("local.properties").newDataInputStream())
|
properties.load(project.rootProject.file("local.properties").newDataInputStream())
|
||||||
android {
|
android {
|
||||||
|
|
@ -34,6 +38,13 @@ android {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def devEnvironmentFile = file("../test_environments.json")
|
||||||
|
if (devEnvironmentFile.exists()) {
|
||||||
|
def devEnvJson = environmentExtractor(devEnvironmentFile)
|
||||||
|
buildConfigField "String", "ENVIRONMENT_JSONDATA", devEnvJson
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
testOptions {
|
testOptions {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,10 @@ uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android
|
||||||
android:theme="@style/Theme.VehicleOwner"
|
android:theme="@style/Theme.VehicleOwner"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:targetApi="n">
|
tools:targetApi="n">
|
||||||
|
<activity
|
||||||
|
android:name=".ui.login.CustomerRegistrationActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="@string/title_activity_customer_registration"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.svi.DashboardActivity"
|
android:name=".ui.svi.DashboardActivity"
|
||||||
android:theme="@style/Theme.VehicleOwner.NoActionBar">
|
android:theme="@style/Theme.VehicleOwner.NoActionBar">
|
||||||
|
|
@ -65,6 +68,10 @@ uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android
|
||||||
android:name=".ui.register.RegisterCustomerActivity"
|
android:name=".ui.register.RegisterCustomerActivity"
|
||||||
android:label="@string/title_activity_register_customer"
|
android:label="@string/title_activity_register_customer"
|
||||||
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
|
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
|
||||||
|
<activity
|
||||||
|
android:name=".ui.registration.ui.login.CustomerRegistrationActivity"
|
||||||
|
android:label="@string/title_activity_register_customer"
|
||||||
|
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.register.RegisterVehicleActivity"
|
android:name=".ui.register.RegisterVehicleActivity"
|
||||||
android:label="@string/title_activity_register_vehicle"
|
android:label="@string/title_activity_register_vehicle"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.csc.vehown.services.rest.vehownserver;
|
package eu.csc.vehown.services.rest.vehownserver;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.util.Log;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.service.AuthenticationService;
|
import eu.csc.ODPAppVehOwnServer.client.service.AuthenticationService;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.service.ClientService;
|
import eu.csc.ODPAppVehOwnServer.client.service.ClientService;
|
||||||
|
|
@ -20,19 +22,25 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class VehOwnApiClientFactory {
|
public class VehOwnApiClientFactory {
|
||||||
|
|
||||||
public static boolean dummyMode = true;
|
public static boolean dummyMode = false;
|
||||||
|
|
||||||
public static String URL = null;
|
public static String URL = null;
|
||||||
|
|
||||||
public static void setUrl(Context context){
|
public static void setUrl(Context context){
|
||||||
|
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
URL = res.getString(res.getIdentifier("default_webserver_url", "string", context.getPackageName()));
|
URL = res.getString(res.getIdentifier("default_webserver_url", "string", context.getPackageName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getURL(){
|
public static String getURL(){
|
||||||
if(URL == null)
|
if(URL == null)
|
||||||
return String.valueOf(R.string.default_webserver_url);
|
|
||||||
|
|
||||||
|
{
|
||||||
|
String u = String.valueOf(R.string.default_webserver_url);
|
||||||
|
Log.d(VehOwnApiClientFactory.class.getSimpleName(), "getURL: " + u);
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
Log.d(VehOwnApiClientFactory.class.getSimpleName(), "getURL: " + URL);
|
||||||
return URL;
|
return URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +60,12 @@ public class VehOwnApiClientFactory {
|
||||||
return ClientFactory.createService(getURL(), AuthenticationService.class).login(request);
|
return ClientFactory.createService(getURL(), AuthenticationService.class).login(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AuthenticationService getAuthenticationService() {
|
||||||
|
|
||||||
|
|
||||||
|
return ClientFactory.createService(getURL(), AuthenticationService.class);
|
||||||
|
}
|
||||||
|
|
||||||
public JWTTokenResponse getAccessToken(ICustomer customer) throws IOException {
|
public JWTTokenResponse getAccessToken(ICustomer customer) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -97,7 +111,7 @@ public class VehOwnApiClientFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Call<Long> registerCustomer(Customer customer) {
|
public static Call<Long> registerCustomer(ICustomer customer) {
|
||||||
|
|
||||||
if (dummyMode)
|
if (dummyMode)
|
||||||
return OfflineDummyCall.getInstance(42L);
|
return OfflineDummyCall.getInstance(42L);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.csc.vehown.ui.login;
|
package eu.csc.vehown.ui.login;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -19,6 +20,8 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import eu.csc.vehown.R;
|
import eu.csc.vehown.R;
|
||||||
|
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
|
||||||
|
import eu.csc.vehown.ui.reportEvent.SelectRepairShopActivity;
|
||||||
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
@ -34,6 +37,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
final EditText usernameEditText = findViewById(R.id.username);
|
final EditText usernameEditText = findViewById(R.id.username);
|
||||||
final EditText passwordEditText = findViewById(R.id.password);
|
final EditText passwordEditText = findViewById(R.id.password);
|
||||||
final Button loginButton = findViewById(R.id.login);
|
final Button loginButton = findViewById(R.id.login);
|
||||||
|
final Button btnRegisterCustomer = findViewById(R.id.btnRegisterCustomer);
|
||||||
|
|
||||||
final ProgressBar loadingProgressBar = findViewById(R.id.loading);
|
final ProgressBar loadingProgressBar = findViewById(R.id.loading);
|
||||||
|
|
||||||
|
|
@ -103,7 +107,15 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
btnRegisterCustomer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(LoginActivity.this, RegisterCustomerActivity.class);
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
loginButton.setOnClickListener(new View.OnClickListener() {
|
loginButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import eu.csc.vehown.ugp.WifiConnectedReceiver;
|
||||||
|
|
||||||
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
|
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
|
||||||
import eu.csc.vehown.ui.register.RegisterVehicleActivity;
|
import eu.csc.vehown.ui.register.RegisterVehicleActivity;
|
||||||
|
import eu.csc.vehown.ui.registration.ui.login.CustomerRegistrationActivity;
|
||||||
import eu.csc.vehown.ui.svi.DashboardActivity;
|
import eu.csc.vehown.ui.svi.DashboardActivity;
|
||||||
import eu.csc.vehown.ui.svi.RegisterSVIActivity;
|
import eu.csc.vehown.ui.svi.RegisterSVIActivity;
|
||||||
import eu.csc.vehown.ui.settings.SettingsActivity;
|
import eu.csc.vehown.ui.settings.SettingsActivity;
|
||||||
|
|
@ -107,6 +108,9 @@ for(int i = 0; i<10; ++i){
|
||||||
case R.id.nav_register_user:
|
case R.id.nav_register_user:
|
||||||
intent = new Intent(this, RegisterCustomerActivity.class);
|
intent = new Intent(this, RegisterCustomerActivity.class);
|
||||||
break;
|
break;
|
||||||
|
case R.id.nav_register_Customer:
|
||||||
|
intent = new Intent(this, CustomerRegistrationActivity.class);
|
||||||
|
break;
|
||||||
case R.id.nav_register_vehicle:
|
case R.id.nav_register_vehicle:
|
||||||
intent = new Intent(this, RegisterVehicleActivity.class);
|
intent = new Intent(this, RegisterVehicleActivity.class);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ public abstract class Helper {
|
||||||
dialog(handler, context, R.drawable.ic_dlg_warning, "Error", message, okHandler);
|
dialog(handler, context, R.drawable.ic_dlg_warning, "Error", message, okHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void infoDialog(@NotNull Handler handler, @NotNull Context context, @NotNull String message) {
|
||||||
|
infoDialog(handler, context,message, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static void infoDialog(@NotNull Handler handler, @NotNull Context context, @NotNull String message, IDialogOkHandler okHandler) {
|
public static void infoDialog(@NotNull Handler handler, @NotNull Context context, @NotNull String message, IDialogOkHandler okHandler) {
|
||||||
dialog(handler, context, R.drawable.ic_dlg_info, "Info", message, okHandler);
|
dialog(handler, context, R.drawable.ic_dlg_info, "Info", message, okHandler);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package eu.csc.vehown.ui.register;
|
||||||
|
|
||||||
|
public class ApiDataRepository {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
package eu.csc.vehown.ui.register;
|
package eu.csc.vehown.ui.register;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.*;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import eu.csc.ODPAppVehOwnServer.models.JWTTokenResponse;
|
import eu.csc.ODPAppVehOwnServer.models.JWTTokenResponse;
|
||||||
import eu.csc.vehown.IVehOwnConsts;
|
import eu.csc.vehown.IVehOwnConsts;
|
||||||
import eu.csc.vehown.R;
|
import eu.csc.vehown.R;
|
||||||
|
|
@ -35,6 +32,8 @@ public class RegisterCustomerActivity
|
||||||
|
|
||||||
private LocalStorageClient sharedPref;
|
private LocalStorageClient sharedPref;
|
||||||
|
|
||||||
|
private static final String TAG = RegisterCustomerActivity.class.getSimpleName();
|
||||||
|
|
||||||
private ActivityRegisterCustomerBinding binding;
|
private ActivityRegisterCustomerBinding binding;
|
||||||
private RegistrationViewModel model;
|
private RegistrationViewModel model;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
|
|
@ -105,20 +104,24 @@ public class RegisterCustomerActivity
|
||||||
|
|
||||||
|
|
||||||
sharedPref.storeCustomer(customer);
|
sharedPref.storeCustomer(customer);
|
||||||
|
|
||||||
|
Log.d("Reg", "START RREGISTERING");
|
||||||
//ToDo run register
|
//ToDo run register
|
||||||
|
|
||||||
VehOwnApiClientFactory.registerCustomer(customer).enqueue(new Callback<Long>() {
|
VehOwnApiClientFactory.registerCustomer(customer).enqueue(new Callback<Long>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<Long> call, Response<Long> response) {
|
public void onResponse(Call<Long> call, Response<Long> response) {
|
||||||
|
Log.d(TAG, "SUCCESS");
|
||||||
customer.setServerId(response.body());
|
customer.setServerId(response.body());
|
||||||
sharedPref.storeCustomer(customer);
|
sharedPref.storeCustomer(customer);
|
||||||
|
|
||||||
|
Helper.infoDialog(handler, RegisterCustomerActivity.this, "Registration Success");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<Long> call, Throwable t) {
|
public void onFailure(Call<Long> call, Throwable t) {
|
||||||
Log.e(RegisterCustomerActivity.class.getSimpleName(), t.toString());
|
Log.e(RegisterCustomerActivity.class.getSimpleName(), t.toString());
|
||||||
|
Helper.errorDialog(handler, RegisterCustomerActivity.this, t.toString(), null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -143,7 +146,6 @@ public class RegisterCustomerActivity
|
||||||
//loadingProgressBar.setVisibility(View.VISIBLE);
|
//loadingProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//loginViewModel.login(usernameEditText.getText().toString(),
|
//loginViewModel.login(usernameEditText.getText().toString(),
|
||||||
// passwordEditText.getText().toString());
|
// passwordEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,78 @@
|
||||||
package eu.csc.vehown.ui.register;
|
package eu.csc.vehown.ui.register;
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
import eu.csc.vehown.data.model.Customer;
|
import eu.csc.vehown.data.model.Customer;
|
||||||
|
import eu.csc.vehown.data.model.Language;
|
||||||
|
import eu.csc.vehown.data.model.VehicleBrand;
|
||||||
|
import eu.csc.vehown.data.model.VehiclePropulsionType;
|
||||||
import eu.csc.vehown.databinding.ActivityRegisterCustomerBinding;
|
import eu.csc.vehown.databinding.ActivityRegisterCustomerBinding;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.var;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class RegisterCustomerViewModel extends ViewModel {
|
public class RegisterCustomerViewModel extends ViewModel {
|
||||||
|
|
||||||
private ActivityRegisterCustomerBinding binding;
|
private ActivityRegisterCustomerBinding binding;
|
||||||
|
|
||||||
|
//region Observable
|
||||||
|
|
||||||
|
private final MutableLiveData<List<Language>> languages;
|
||||||
|
|
||||||
|
public RegisterCustomerViewModel() {
|
||||||
|
languages = new MutableLiveData<>();
|
||||||
|
|
||||||
|
var languageList = new ArrayList<Language>();
|
||||||
|
languageList.add(new Language("en", "English"));
|
||||||
|
|
||||||
|
this.languages.setValue(languageList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
public void setBinding(ActivityRegisterCustomerBinding binding) {
|
public void setBinding(ActivityRegisterCustomerBinding binding) {
|
||||||
|
|
||||||
|
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
|
|
||||||
|
|
||||||
this.initBinding();
|
this.initBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBinding() {
|
private void initBinding() {
|
||||||
if(this.binding == null)
|
if(this.binding == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomer(Customer customer){
|
public void setCustomer(Customer customer){
|
||||||
binding.editEmail.setText(customer.getEmail());
|
binding.editEmail.setText(customer.getEmail());
|
||||||
|
binding.editPassword.setText(customer.getPassword());
|
||||||
|
binding.editFirstName.setText(customer.getFirstname());
|
||||||
|
binding.editLastName.setText(customer.getLastname());
|
||||||
|
binding.editCity.setText(customer.getCity());
|
||||||
|
binding.editStreet.setText(customer.getStreet());
|
||||||
|
binding.editPhone.setText(customer.getPhone());
|
||||||
|
binding.editPassword2.setText(customer.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Customer getCustomer(){
|
||||||
|
var result = new Customer();
|
||||||
|
|
||||||
|
result.setCity(binding.editCity.getText().toString());
|
||||||
|
result.setEmail(binding.editEmail.getText().toString());
|
||||||
|
result.setPassword(binding.editPassword.getText().toString());
|
||||||
|
result.setFirstname(binding.editFirstName.getText().toString());
|
||||||
|
result.setLastname(binding.editLastName.getText().toString());
|
||||||
|
result.setCity(binding.editCity.getText().toString());
|
||||||
|
result.setStreet(binding.editStreet.getText().toString());
|
||||||
|
result.setPhone(binding.editPhone.getText().toString());
|
||||||
|
result.setLanguageName(binding.spLanguage.getSelectedItem().toString());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package eu.csc.vehown.ui.registration.data;
|
||||||
|
|
||||||
|
import eu.csc.vehown.data.model.ICustomer;
|
||||||
|
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
|
||||||
|
import eu.csc.vehown.ui.registration.data.model.LoggedInUser;
|
||||||
|
import lombok.var;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that handles authentication w/ login credentials and retrieves user information.
|
||||||
|
*/
|
||||||
|
public class CustomerRegistrationDataSource {
|
||||||
|
|
||||||
|
public Result<LoggedInUser> login(ICustomer customer) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
var result = VehOwnApiClientFactory.registerCustomer(customer).execute();
|
||||||
|
|
||||||
|
if (result.isSuccessful()) {
|
||||||
|
LoggedInUser fakeUser =
|
||||||
|
new LoggedInUser(
|
||||||
|
result.body().toString(),
|
||||||
|
customer.getEmail());
|
||||||
|
return new Result.Success<>(fakeUser);
|
||||||
|
} else {
|
||||||
|
return new Result.Error(new Exception("Error logging in " + result.errorBody().toString()));
|
||||||
|
}
|
||||||
|
// TODO: handle loggedInUser authentication
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new Result.Error(new IOException("Error logging in ", e));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logout() {
|
||||||
|
// TODO: revoke authentication
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package eu.csc.vehown.ui.registration.data;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.client.service.AuthenticationService;
|
||||||
|
import eu.csc.vehown.data.model.ICustomer;
|
||||||
|
import eu.csc.vehown.persist.sharedPreferences.LocalStorageClient;
|
||||||
|
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
|
||||||
|
import eu.csc.vehown.ui.registration.data.model.LoggedInUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that requests authentication and user information from the remote data source and
|
||||||
|
* maintains an in-memory cache of login status and user credentials information.
|
||||||
|
*/
|
||||||
|
public class CustomerRegistrationRepository {
|
||||||
|
|
||||||
|
private static volatile CustomerRegistrationRepository instance;
|
||||||
|
|
||||||
|
private CustomerRegistrationDataSource dataSource;
|
||||||
|
private LocalStorageClient localStorageClient;
|
||||||
|
private final AuthenticationService authenticationService;
|
||||||
|
|
||||||
|
// If user credentials will be cached in local storage, it is recommended it be encrypted
|
||||||
|
// @see https://developer.android.com/training/articles/keystore
|
||||||
|
private LoggedInUser user = null;
|
||||||
|
|
||||||
|
// private constructor : singleton access
|
||||||
|
private CustomerRegistrationRepository(CustomerRegistrationDataSource dataSource, LocalStorageClient localStorageClient) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
this.localStorageClient = localStorageClient;
|
||||||
|
this.authenticationService = VehOwnApiClientFactory.getAuthenticationService();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomerRegistrationRepository getInstance(CustomerRegistrationDataSource dataSource, LocalStorageClient localStorageClient) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CustomerRegistrationRepository(dataSource, localStorageClient);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLoggedIn() {
|
||||||
|
return user != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logout() {
|
||||||
|
user = null;
|
||||||
|
dataSource.logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLoggedInUser(LoggedInUser user) {
|
||||||
|
this.user = user;
|
||||||
|
// If user credentials will be cached in local storage, it is recommended it be encrypted
|
||||||
|
// @see https://developer.android.com/training/articles/keystore
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Result<LoggedInUser> registerCustomer(ICustomer customer) {
|
||||||
|
// handle login
|
||||||
|
Result<LoggedInUser> result = dataSource.login(customer);
|
||||||
|
if (result instanceof Result.Success) {
|
||||||
|
setLoggedInUser(((Result.Success<LoggedInUser>) result).getData());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package eu.csc.vehown.ui.registration.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generic class that holds a result success w/ data or an error exception.
|
||||||
|
*/
|
||||||
|
public class Result<T> {
|
||||||
|
// hide the private constructor to limit subclass types (Success, Error)
|
||||||
|
private Result() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (this instanceof Result.Success) {
|
||||||
|
Result.Success success = (Result.Success) this;
|
||||||
|
return "Success[data=" + success.getData().toString() + "]";
|
||||||
|
} else if (this instanceof Result.Error) {
|
||||||
|
Result.Error error = (Result.Error) this;
|
||||||
|
return "Error[exception=" + error.getError().toString() + "]";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Success sub-class
|
||||||
|
public final static class Success<T> extends Result {
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
public Success(T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error sub-class
|
||||||
|
public final static class Error extends Result {
|
||||||
|
private Exception error;
|
||||||
|
|
||||||
|
public Error(Exception error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Exception getError() {
|
||||||
|
return this.error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package eu.csc.vehown.ui.registration.data.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data class that captures user information for logged in users retrieved from LoginRepository
|
||||||
|
*/
|
||||||
|
public class LoggedInUser {
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
private String displayName;
|
||||||
|
|
||||||
|
public LoggedInUser(String userId, String displayName) {
|
||||||
|
this.userId = userId;
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
package eu.csc.vehown.ui.registration.ui.login;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import eu.csc.vehown.R;
|
||||||
|
import eu.csc.vehown.data.model.Customer;
|
||||||
|
import eu.csc.vehown.data.model.ICustomer;
|
||||||
|
import eu.csc.vehown.databinding.ActivityCustomerRegistrationBinding;
|
||||||
|
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public class CustomerRegistrationActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private CustomerRegistrationViewModel viewModel;
|
||||||
|
private ActivityCustomerRegistrationBinding binding;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
binding = ActivityCustomerRegistrationBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
VehOwnApiClientFactory.setUrl(this);
|
||||||
|
viewModel = new ViewModelProvider(this, new CustomerRegistrationViewModelFactory(this))
|
||||||
|
.get(CustomerRegistrationViewModel.class);
|
||||||
|
|
||||||
|
final EditText usernameEditText = binding.edEmail;
|
||||||
|
final EditText passwordEditText = binding.password;
|
||||||
|
final EditText password2EditText = binding.edPassword2;
|
||||||
|
final EditText edFirstname = binding.edFirstname;
|
||||||
|
final EditText edLastname = binding.edLastname;
|
||||||
|
final EditText edStreet = binding.edStreet;
|
||||||
|
final Button btnRegister = binding.btnRegister;
|
||||||
|
final ProgressBar loadingProgressBar = binding.loading;
|
||||||
|
|
||||||
|
viewModel.getLoginFormState().observe(this, new Observer<LoginFormState>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable LoginFormState loginFormState) {
|
||||||
|
if (loginFormState == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
btnRegister.setEnabled(loginFormState.isDataValid());
|
||||||
|
if (loginFormState.getUsernameError() != null) {
|
||||||
|
usernameEditText.setError(getString(loginFormState.getUsernameError()));
|
||||||
|
}
|
||||||
|
if (loginFormState.getPasswordError() != null) {
|
||||||
|
passwordEditText.setError(getString(loginFormState.getPasswordError()));
|
||||||
|
//password2EditText.setError(getString(loginFormState.getPasswordError()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
viewModel.getLoginResult().observe(this, new Observer<LoginResult>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable LoginResult loginResult) {
|
||||||
|
if (loginResult == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadingProgressBar.setVisibility(View.GONE);
|
||||||
|
if (loginResult.getError() != null) {
|
||||||
|
showLoginFailed(loginResult.getError());
|
||||||
|
}
|
||||||
|
if (loginResult.getSuccess() != null) {
|
||||||
|
updateUiWithUser(loginResult.getSuccess());
|
||||||
|
}
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
|
||||||
|
//Complete and destroy login activity once successful
|
||||||
|
//finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TextWatcher afterTextChangedListener = new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
viewModel.loginDataChanged(usernameEditText.getText().toString(),
|
||||||
|
passwordEditText.getText().toString(),
|
||||||
|
passwordEditText.getText().toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
usernameEditText.addTextChangedListener(afterTextChangedListener);
|
||||||
|
passwordEditText.addTextChangedListener(afterTextChangedListener);
|
||||||
|
//password2EditText.addTextChangedListener(afterTextChangedListener);
|
||||||
|
passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
|
// viewModel.registerCustomer(getC);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnRegister.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
loadingProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
viewModel.registerCustomer(getCustomer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICustomer getCustomer() {
|
||||||
|
Customer result = new Customer();
|
||||||
|
result.setEmail(usernameEditText.getText().toString());
|
||||||
|
result.setPassword(passwordEditText.getText().toString());
|
||||||
|
//result.setFirstname(edFirstname.getText().toString());
|
||||||
|
//result.setLastname(edLastname.getText().toString());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateUiWithUser(LoggedInUserView model) {
|
||||||
|
String welcome = getString(R.string.welcome) + model.getDisplayName();
|
||||||
|
// TODO : initiate successful logged in experience
|
||||||
|
Toast.makeText(getApplicationContext(), welcome, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showLoginFailed(@StringRes Integer errorString) {
|
||||||
|
Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package eu.csc.vehown.ui.registration.ui.login;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import android.util.Patterns;
|
||||||
|
|
||||||
|
import eu.csc.vehown.R;
|
||||||
|
import eu.csc.vehown.data.model.ICustomer;
|
||||||
|
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
|
||||||
|
import eu.csc.vehown.ui.registration.data.CustomerRegistrationRepository;
|
||||||
|
import eu.csc.vehown.ui.registration.data.Result;
|
||||||
|
import eu.csc.vehown.ui.registration.data.model.LoggedInUser;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
|
||||||
|
public class CustomerRegistrationViewModel extends ViewModel {
|
||||||
|
|
||||||
|
ExecutorService executorService = Executors.newFixedThreadPool(4);
|
||||||
|
private MutableLiveData<LoginFormState> loginFormState = new MutableLiveData<>();
|
||||||
|
private MutableLiveData<LoginResult> loginResult = new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
|
private CustomerRegistrationRepository registrationRepository;
|
||||||
|
|
||||||
|
CustomerRegistrationViewModel(CustomerRegistrationRepository registrationRepository) {
|
||||||
|
this.registrationRepository = registrationRepository;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<LoginFormState> getLoginFormState() {
|
||||||
|
return loginFormState;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<LoginResult> getLoginResult() {
|
||||||
|
return loginResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCustomer(ICustomer customer) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
executorService.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
// can be launched in a separate asynchronous job
|
||||||
|
Result<LoggedInUser> result = registrationRepository.registerCustomer(customer);
|
||||||
|
|
||||||
|
if (result instanceof Result.Success) {
|
||||||
|
LoggedInUser data = ((Result.Success<LoggedInUser>) result).getData();
|
||||||
|
loginResult.postValue(new LoginResult(new LoggedInUserView(data.getDisplayName())));
|
||||||
|
} else {
|
||||||
|
loginResult.postValue(new LoginResult(R.string.login_failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loginDataChanged(String username, String password, String password2) {
|
||||||
|
if (!isUserNameValid(username)) {
|
||||||
|
loginFormState.setValue(new LoginFormState(R.string.invalid_username, null));
|
||||||
|
} else if (!isPasswordValid(password, password2)) {
|
||||||
|
loginFormState.setValue(new LoginFormState(null, R.string.invalid_password));
|
||||||
|
} else {
|
||||||
|
loginFormState.setValue(new LoginFormState(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A placeholder username validation check
|
||||||
|
private boolean isUserNameValid(String username) {
|
||||||
|
if (username == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (username.contains("@")) {
|
||||||
|
return Patterns.EMAIL_ADDRESS.matcher(username).matches();
|
||||||
|
} else {
|
||||||
|
return !username.trim().isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A placeholder password validation check
|
||||||
|
private boolean isPasswordValid(String password, String repeat) {
|
||||||
|
return password != null && password.trim().length() > 5 && password.equals(repeat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package eu.csc.vehown.ui.registration.ui.login;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import eu.csc.vehown.persist.sharedPreferences.LocalStorageClientImpl;
|
||||||
|
import eu.csc.vehown.persist.sharedPreferences.SharedPreferencesFactory;
|
||||||
|
import eu.csc.vehown.ui.registration.data.CustomerRegistrationDataSource;
|
||||||
|
import eu.csc.vehown.ui.registration.data.CustomerRegistrationRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ViewModel provider factory to instantiate LoginViewModel.
|
||||||
|
* Required given LoginViewModel has a non-empty constructor
|
||||||
|
*/
|
||||||
|
public class CustomerRegistrationViewModelFactory implements ViewModelProvider.Factory {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
public CustomerRegistrationViewModelFactory(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||||
|
if (modelClass.isAssignableFrom(CustomerRegistrationViewModel.class)) {
|
||||||
|
return (T) new CustomerRegistrationViewModel(CustomerRegistrationRepository.getInstance(
|
||||||
|
new CustomerRegistrationDataSource(),
|
||||||
|
SharedPreferencesFactory.getInstance(context)));
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unknown ViewModel class");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.csc.vehown.ui.registration.ui.login;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class exposing authenticated user details to the UI.
|
||||||
|
*/
|
||||||
|
class LoggedInUserView {
|
||||||
|
private String displayName;
|
||||||
|
//... other data fields that may be accessible to the UI
|
||||||
|
|
||||||
|
LoggedInUserView(String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package eu.csc.vehown.ui.registration.ui.login;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data validation state of the login form.
|
||||||
|
*/
|
||||||
|
class LoginFormState {
|
||||||
|
@Nullable
|
||||||
|
private Integer usernameError;
|
||||||
|
@Nullable
|
||||||
|
private Integer passwordError;
|
||||||
|
private boolean isDataValid;
|
||||||
|
|
||||||
|
LoginFormState(@Nullable Integer usernameError, @Nullable Integer passwordError) {
|
||||||
|
this.usernameError = usernameError;
|
||||||
|
this.passwordError = passwordError;
|
||||||
|
this.isDataValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoginFormState(boolean isDataValid) {
|
||||||
|
this.usernameError = null;
|
||||||
|
this.passwordError = null;
|
||||||
|
this.isDataValid = isDataValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Integer getUsernameError() {
|
||||||
|
return usernameError;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Integer getPasswordError() {
|
||||||
|
return passwordError;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isDataValid() {
|
||||||
|
return isDataValid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.csc.vehown.ui.registration.ui.login;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication result : success (user details) or error message.
|
||||||
|
*/
|
||||||
|
class LoginResult {
|
||||||
|
@Nullable
|
||||||
|
private LoggedInUserView success;
|
||||||
|
@Nullable
|
||||||
|
private Integer error;
|
||||||
|
|
||||||
|
LoginResult(@Nullable Integer error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoginResult(@Nullable LoggedInUserView success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
LoggedInUserView getSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Integer getError() {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".ui.registration.ui.login.CustomerRegistrationActivity">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/username"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="96dp"
|
||||||
|
android:autofillHints="@string/prompt_email"
|
||||||
|
android:hint="@string/prompt_email"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/password"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_password"
|
||||||
|
android:hint="@string/prompt_password"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/username"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/login"
|
||||||
|
android:enabled="false"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:text="@string/action_sign_in"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||||
|
app:layout_constraintVertical_bias="0.2"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/password"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.3"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".ui.registration.ui.login.CustomerRegistrationActivity">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="840dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/username"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="96dp"
|
||||||
|
android:autofillHints="@string/prompt_email"
|
||||||
|
android:hint="@string/prompt_email"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/password"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_password"
|
||||||
|
android:hint="@string/prompt_password"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/username"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/login"
|
||||||
|
android:enabled="false"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:text="@string/action_sign_in"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||||
|
app:layout_constraintVertical_bias="0.2"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/password"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.3"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
@ -0,0 +1,145 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".ui.registration.ui.login.CustomerRegistrationActivity">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edEmail"
|
||||||
|
android:nextFocusDown="@id/edFirstname"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="96dp"
|
||||||
|
android:autofillHints="@string/prompt_email"
|
||||||
|
android:hint="@string/prompt_email"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edFirstname"
|
||||||
|
android:nextFocusDown="@id/edLastname"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_firstname"
|
||||||
|
android:hint="@string/prompt_firstname"
|
||||||
|
android:inputType="text"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/edEmail"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edLastname"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:autofillHints="@string/prompt_lastname"
|
||||||
|
android:hint="@string/prompt_lastname"
|
||||||
|
android:inputType="text"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/edFirstname"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
|
||||||
|
android:id="@+id/edZip"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_Postal"
|
||||||
|
android:hint="@string/prompt_Postal"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="text"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/edLastname"/>
|
||||||
|
<EditText
|
||||||
|
|
||||||
|
android:id="@+id/edStreet"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_street"
|
||||||
|
android:hint="@string/prompt_street"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="text"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/edZip"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/password"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_password"
|
||||||
|
android:hint="@string/prompt_password"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/edStreet"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edPassword2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:autofillHints="@string/prompt_password"
|
||||||
|
android:hint="@string/prompt_password"
|
||||||
|
android:imeActionLabel="@string/action_sign_in_short"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/password"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnRegister"
|
||||||
|
android:enabled="false"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:text="@string/action_register_customer"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/edPassword2"
|
||||||
|
app:layout_constraintVertical_bias="0.2"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/password"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.3"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
@ -61,6 +61,24 @@
|
||||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||||
app:layout_constraintVertical_bias="0.2"/>
|
app:layout_constraintVertical_bias="0.2"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnRegisterCustomer"
|
||||||
|
android:enabled="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:text="@string/action_register_customer"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/login"
|
||||||
|
app:layout_constraintVertical_bias="0.2"/>
|
||||||
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/loading"
|
android:id="@+id/loading"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,12 @@
|
||||||
android:icon="@drawable/ic_register"
|
android:icon="@drawable/ic_register"
|
||||||
android:title="@string/register_user"
|
android:title="@string/register_user"
|
||||||
android:onClick="menuItemOnClicked"
|
android:onClick="menuItemOnClicked"
|
||||||
/>
|
/><item
|
||||||
|
android:id="@+id/nav_register_Customer"
|
||||||
|
android:icon="@drawable/ic_register"
|
||||||
|
android:title="@string/action_register_customer"
|
||||||
|
android:onClick="menuItemOnClicked"
|
||||||
|
/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_register_vehicle"
|
android:id="@+id/nav_register_vehicle"
|
||||||
android:icon="@drawable/ic_register"
|
android:icon="@drawable/ic_register"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="fab_margin">48dp</dimen>
|
<dimen name="fab_margin">48dp</dimen>
|
||||||
|
<dimen name="activity_horizontal_margin">48dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="fab_margin">200dp</dimen>
|
<dimen name="fab_margin">200dp</dimen>
|
||||||
|
<dimen name="activity_horizontal_margin">200dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="fab_margin">48dp</dimen>
|
<dimen name="fab_margin">48dp</dimen>
|
||||||
|
<dimen name="activity_horizontal_margin">48dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -133,6 +133,13 @@
|
||||||
|
|
||||||
<string name="hello_first_fragment">Hello first fragment</string>
|
<string name="hello_first_fragment">Hello first fragment</string>
|
||||||
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
|
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
|
||||||
|
<string name="pref_offline_mode">pref_offline_mode</string>
|
||||||
|
<string name="title_activity_customer_registration">CustomerRegistrationActivity</string>
|
||||||
|
<string name="prompt_street">Street</string>
|
||||||
|
<string name="action_register_customer">Register</string>
|
||||||
|
<string name="prompt_firstname">Firstname</string>
|
||||||
|
<string name="prompt_lastname">Lastname</string>
|
||||||
|
<string name="prompt_Postal">Zip/Postal</string>
|
||||||
|
|
||||||
<!--string-array name="languages">
|
<!--string-array name="languages">
|
||||||
<item>english</item>
|
<item>english</item>
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,9 @@
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
app:title="@string/use_dark_mode"/>
|
app:title="@string/use_dark_mode"/>
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:key="pref_offline_mode"
|
||||||
|
android:defaultValue="true"
|
||||||
|
app:title="@string/pref_offline_mode"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
@ -3,5 +3,6 @@
|
||||||
<domain-config cleartextTrafficPermitted="true">
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
<domain includeSubdomains="true">10.10.101.40</domain>
|
<domain includeSubdomains="true">10.10.101.40</domain>
|
||||||
<domain includeSubdomains="true">10.10.101.30</domain>
|
<domain includeSubdomains="true">10.10.101.30</domain>
|
||||||
|
<domain includeSubdomains="true">192.168.188.54</domain>
|
||||||
</domain-config>
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
|
|
@ -21,7 +21,9 @@ public class ExampleUnitTest {
|
||||||
public void testProperties(){
|
public void testProperties(){
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
String p = BuildConfig.ENVIRONMENT_JSONDATA;
|
||||||
|
|
||||||
|
System.out.println(p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 31
|
||||||
buildToolsVersion "30.0.3"
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,7 @@ public interface ICustomer {
|
||||||
String getPhone();
|
String getPhone();
|
||||||
String getLogin();
|
String getLogin();
|
||||||
String getEmail();
|
String getEmail();
|
||||||
|
String getCity();
|
||||||
String getPassword();
|
String getPassword();
|
||||||
|
String getStreet();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,14 @@ public class LoggedInUser implements Serializable, ICustomer {
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return this.getLogin();
|
return this.getLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStreet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,4 +23,26 @@ public class ExampleInstrumentedTest {
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
assertEquals("eu.csc.ssv.localstorage.test", appContext.getPackageName());
|
assertEquals("eu.csc.ssv.localstorage.test", appContext.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProp(){
|
||||||
|
String prop = System.getProperties().getProperty("ENVIRONMENT_JSONDATA", null);
|
||||||
|
|
||||||
|
System.out.println(System.getProperties());
|
||||||
|
System.out.println(prop);
|
||||||
|
System.out.println(getSystemProperty("ENVIRONMENT_JSONDATA"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSystemProperty(String key) {
|
||||||
|
String value = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
value = (String) Class.forName("android.os.SystemProperties")
|
||||||
|
.getMethod("get", String.class).invoke(null, key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public class LocalStorageClientImpl implements LocalStorageClient {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedPreferences.edit().putString(PREF_CUSTOMER, value);
|
sharedPreferences.edit().putString(PREF_CUSTOMER, value).apply();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
package eu.csc.vehown.persist.localstorage;
|
package eu.csc.vehown.persist.localstorage;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
|
import lombok.var;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -14,4 +19,7 @@ public class ExampleUnitTest {
|
||||||
public void addition_isCorrect() {
|
public void addition_isCorrect() {
|
||||||
assertEquals(4, 2 + 2);
|
assertEquals(4, 2 + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"url": "ASD"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue