Support all vehicle parameters by clicking on shown vehicles

This commit is contained in:
tl 2022-07-11 14:33:07 +02:00
parent b36ecfbc81
commit 373d0c161b
33 changed files with 303 additions and 572 deletions

View File

@ -1,147 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="eu.csc.vehown">
xmlns:tools="http://schemas.android.com/tools"
package="eu.csc.vehown">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<!--
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"
tools:ignore="ScopedStorage"/
-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
android:name="android.hardware.camera"
android:required="false"/>
<application
android:name=".ApplicationEx"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.VehicleOwner"
android:usesCleartextTraffic="true"
tools:targetApi="n">
<activity android:name=".ui.base.ActivityBaseDetailContent"></activity>
<activity android:name=".ui.content.ActivityLocalContentNavigation" />
<activity
android:name=".ui.content.LocalContentNavigationActivity"
android:label="@string/title_activity_local_content_navigation"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.base.BaseRegistrationActivity"
android:exported="true"
android:label="@string/title_activity_base_registration">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.main.MainActivity" />
</activity>
<activity
android:name=".ui.md.ItemDetailHostActivity"
android:exported="true"
android:label="@string/title_activity_item_detail_host"
android:resizeableActivity="true"
tools:targetApi="24" />
<activity
android:name=".ui.login.CustomerRegistrationActivity"
android:exported="true"
android:label="@string/title_activity_customer_registration" />
<activity
android:name=".ui.svi.DashboardActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.main.MainActivity"
android:name=".ApplicationEx"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.VehicleOwner.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.VehicleOwner"
android:usesCleartextTraffic="true"
tools:targetApi="n">
<category android:name="android.intent.category.LAUNCHER" />
<activity
android:name=".ui.main.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.VehicleOwner.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".ui.base.ActivityBaseDetailContent"/>
<activity android:name=".ui.content.ActivityLocalContentNavigation"/>
<!--activity
android:name=".ui.content.LocalContentNavigationActivity"
android:label="@string/title_activity_local_content_navigation"
android:theme="@style/Theme.VehicleOwner.NoActionBar" /-->
<activity
android:name=".ui.svi.RegisterSVIActivity"
android:label="@string/register_svi"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.reportEvent.ReportEventActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.reportEvent.SelectEventsActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.reportEvent.SelectRepairShopActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.tp.TreatmentPlanActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.FailureEvent.FailureEventActivity"
android:label="@string/title_activity_failure_event"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.register.RegisterCustomerActivity"
android:label="@string/title_activity_register_customer"
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
android:name=".ui.register.RegisterVehicleActivity"
android:label="@string/title_activity_register_vehicle"
android:theme="@style/Theme.VehicleOwner.NoActionBar" />
<activity
android:name=".ui.login.LoginActivity"
android:label="@string/app_name">
android:name=".ui.base.BaseRegistrationActivity"
android:exported="true"
android:label="@string/title_activity_base_registration">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.main.MainActivity" />
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.main.MainActivity"/>
</activity>
<activity
android:name=".ui.settings.SettingsActivity"
android:label="@string/title_activity_settings" />
android:name=".ui.md.ItemDetailHostActivity"
android:exported="true"
android:label="@string/title_activity_item_detail_host"
android:resizeableActivity="true"
tools:targetApi="24"/>
<activity
android:name=".ui.registration.login.CustomerRegistrationActivity"
android:label="@string/title_activity_register_customer"
android:exported="true"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.svi.DashboardActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.svi.RegisterSVIActivity"
android:label="@string/register_svi"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.reportEvent.ReportEventActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.reportEvent.SelectEventsActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.reportEvent.SelectRepairShopActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.tp.TreatmentPlanActivity"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.FailureEvent.FailureEventActivity"
android:label="@string/title_activity_failure_event"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.registration.RegisterCustomerActivity"
android:label="@string/title_activity_register_customer"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.registration.RegisterVehicleActivity"
android:label="@string/title_activity_register_vehicle"
android:theme="@style/Theme.VehicleOwner.NoActionBar"/>
<activity
android:name=".ui.login.LoginActivity"
android:label="@string/app_name">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.main.MainActivity"/>
</activity>
<activity
android:name=".ui.settings.SettingsActivity"
android:label="@string/title_activity_settings"/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="eu.csc.app.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
android:name="androidx.core.content.FileProvider"
android:authorities="eu.csc.app.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
<receiver android:name=".broadcast.VehicleEventReceivedReceiver">
<intent-filter>
<action android:name="eu.csc.vehown.EVENTINTENT" />
<action android:name="eu.csc.vehown.EVENTINTENT"/>
</intent-filter>
</receiver>
<receiver
android:name=".broadcast.StartupReceiver"
android:enabled="true"
android:exported="true">
android:name=".broadcast.StartupReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</receiver>
<service
android:name=".ugp.UGPService"
android:enabled="true"
android:exported="true" />
<service
android:name=".services.rest.UploadFileService"
android:enabled="true"
android:exported="true" />
<service android:name=".services.DataServiceIntent" />
<service android:name=".ugp.UGPService" android:enabled="true" android:exported="false"/>
<service android:name=".services.rest.UploadFileService" android:enabled="true" android:exported="false"/>
<service android:name=".services.DataServiceIntent"/>
</application>
</manifest>

View File

@ -0,0 +1,6 @@
package eu.csc.vehown.ui;
public interface IEditTextChecker {
void check();
}

View File

@ -1,23 +1,13 @@
package eu.csc.vehown.ui.register;
package eu.csc.vehown.ui;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import java.util.List;
interface IEditTextChecker {
void check();
}
public class TextChangedListener implements TextWatcher {
private final IEditTextChecker checker;
TextChangedListener(IEditTextChecker checker) {
public TextChangedListener(IEditTextChecker checker) {
this.checker = checker;
}

View File

@ -9,10 +9,6 @@ import android.util.Log;
import eu.csc.vehown.R;
import eu.csc.vehown.ui.fragments.details.FragmentDetailDevice;
import eu.csc.vehown.ui.fragments.details.FragmentDetailVehicle;
import eu.csc.vehown.ui.md.ItemDetailFragment;
import eu.csc.vehown.ui.register.RegisterVehicleActivity;
import eu.csc.vehown.ui.register.ShowVehiclesAndDevicesFragment;
import eu.csc.vehown.ui.registration.devices.DeviceRegistrationFragment;
import eu.csc.vehown.ui.registration.vehicle.FragmentVehicleRegistration;

View File

@ -1,34 +1,16 @@
package eu.csc.vehown.ui.login;
import android.app.Activity;
import android.content.Intent;
import androidx.fragment.app.FragmentTransaction;
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.ui.fragments.ui.login.LoginFragment;
import eu.csc.vehown.ui.models.LoggedInUserView;
import eu.csc.vehown.ui.models.LoginResult;
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
import eu.csc.vehown.ui.registration.customer.FragmentCustomerRegistration;
/**

View File

@ -23,9 +23,7 @@ import eu.csc.log.CSCLog4jFactory;
import eu.csc.log.Log;
import eu.csc.vehown.R;
import eu.csc.vehown.broadcast.VehicleEventReceivedReceiver;
import eu.csc.vehown.persist.sharedPreferences.LocalStorageClient;
import eu.csc.vehown.persist.sharedPreferences.SharedPreferencesFactory;
import eu.csc.vehown.services.mqtt.MqttClient;
import eu.csc.vehown.services.notifications.NotificationService;
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
import eu.csc.vehown.ugp.WifiConnectedReceiver;
@ -34,13 +32,9 @@ import eu.csc.vehown.ui.content.ActivityLocalContentNavigation;
import eu.csc.vehown.ui.login.LoginActivity;
import eu.csc.vehown.ui.main.dboard.DashboardFragment;
import eu.csc.vehown.ui.md.ItemDetailHostActivity;
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
import eu.csc.vehown.ui.register.RegisterVehicleActivity;
import eu.csc.vehown.ui.registration.customer.FragmentCustomerRegistration;
import eu.csc.vehown.ui.registration.ui.login.CustomerRegistrationActivity;
import eu.csc.vehown.ui.registration.RegisterCustomerActivity;
import eu.csc.vehown.ui.settings.SettingsActivity;
import eu.csc.vehown.ui.svi.DashboardActivity;
import eu.csc.vehown.ui.svi.RegisterSVIActivity;
/**
* @see LoginActivity
@ -159,9 +153,9 @@ public class MainActivity extends AppCompatActivity {
case R.id.nav_register_user:
intent = new Intent(this, RegisterCustomerActivity.class);
break;
case R.id.nav_register_Customer:
intent = new Intent(this, RegisterVehicleActivity.class);
break;
// case R.id.nav_register_Customer:
// intent = new Intent(this, RegisterVehicleActivity.class);
// break;
case R.id.nav_show_vehicles_devices:
break;
// case R.id.nav_register_vehicle:

View File

@ -1,26 +1,20 @@
package eu.csc.vehown.ui.md;
import android.content.ClipData;
import android.content.Intent;
import android.os.Bundle;
import android.view.DragEvent;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import eu.csc.vehown.R;
import eu.csc.vehown.databinding.FragmentItemDetailBinding;
import eu.csc.vehown.persist.sharedPreferences.SharedPreferencesFactory;
import eu.csc.vehown.ui.md.placeholder.PlaceholderContent;
import eu.csc.vehown.ui.pub.UIUtils;
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
import eu.csc.vehown.ui.register.RegisterVehicleActivity;
import eu.csc.vehown.ui.registration.RegisterVehicleActivity;
import lombok.var;
/**

View File

@ -17,7 +17,7 @@ import android.widget.*;
import androidx.annotation.DrawableRes;
import androidx.appcompat.app.AlertDialog;
import eu.csc.vehown.R;
import eu.csc.vehown.ui.register.TextChangedListener;
import eu.csc.vehown.ui.TextChangedListener;
import org.jetbrains.annotations.NotNull;
import java.io.File;

View File

@ -1,4 +1,4 @@
package eu.csc.vehown.ui.register;
package eu.csc.vehown.ui.registration;
import android.os.Bundle;
import android.os.Handler;
@ -18,6 +18,7 @@ import eu.csc.vehown.databinding.ActivityRegisterCustomerBinding;
import eu.csc.vehown.persist.sharedPreferences.LocalStorageClient;
import eu.csc.vehown.persist.sharedPreferences.SharedPreferencesFactory;
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
import eu.csc.vehown.ui.TextChangedListener;
import eu.csc.vehown.ui.modal.Helper;
import eu.csc.vehown.ui.viewmodels.AppViewModelFactory;
import retrofit2.Call;

View File

@ -1,8 +1,10 @@
package eu.csc.vehown.ui.register;
package eu.csc.vehown.ui.registration;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -13,11 +15,13 @@ import android.widget.DatePicker;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import eu.csc.vehown.IVehOwnConsts;
import eu.csc.vehown.R;
import eu.csc.vehown.data.model.Vehicle;
import eu.csc.vehown.data.model.VehicleBrand;
import eu.csc.vehown.data.model.VehicleModel;
import eu.csc.vehown.data.model.VehiclePropulsionType;
import eu.csc.vehown.databinding.ActivityRegisterVehicleBinding;
import eu.csc.vehown.databinding.FragmentVehicleRegistrationBinding;
import eu.csc.vehown.ui.TextChangedListener;
import eu.csc.vehown.ui.adapters.PropulsionTypeAdapter;
import eu.csc.vehown.ui.adapters.VehicleBrandAdapter;
import eu.csc.vehown.ui.adapters.VehicleModelAdapter;
@ -30,19 +34,21 @@ import java.util.*;
public class RegisterVehicleActivity extends AppCompatActivity implements IVehOwnConsts {
//private LocalStorageClient sharedPref;
private static final String TAG = RegisterVehicleActivity.class.getSimpleName();
private static final int REQUEST_IMAGE_CAPTURE = 11;
private static final int REQUEST_IMAGE_GALLERY = 12;
private ActivityRegisterVehicleBinding binding;
private RegistrationViewModel model;
private FragmentVehicleRegistrationBinding binding;
private RegistrationViewModel viewModel;
private VehicleBrandAdapter brandAdapter;
private PropulsionTypeAdapter propulsionTypeAdapter;
private List<View> mandatoryFields;
private Bitmap bitmap;
private Handler handler;
private Runnable timer;
private List<View> mandatoryFields;
private VehicleBrandAdapter brandAdapter;
private VehicleModelAdapter modelAdapter;
private static final String TAG = RegisterVehicleActivity.class.getSimpleName();
public static Intent editCurrentItem(Context context, String id) {
Intent intent = new Intent(context, RegisterVehicleActivity.class);
intent.putExtra(ItemDetailFragment.ARG_ITEM_ID, id);
return intent;
@ -55,17 +61,15 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = FragmentVehicleRegistrationBinding.inflate(getLayoutInflater());
model = new ViewModelProvider(this, new AppViewModelFactory(this)).get(RegistrationViewModel.class);
String id = null;
Intent intent = getIntent();
if (intent.hasExtra(ItemDetailFragment.ARG_ITEM_ID)) {
id = intent.getStringExtra(ItemDetailFragment.ARG_ITEM_ID);
if (getIntent().hasExtra(ItemDetailFragment.ARG_ITEM_ID)) {
id = getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID);
}
Log.d(TAG, "PASSED ID: " + id);
//sharedPref = SharedPreferencesFactory.getInstance(getApplicationContext());
binding = ActivityRegisterVehicleBinding.inflate(getLayoutInflater());
viewModel = new ViewModelProvider(this, new AppViewModelFactory(this)).get(RegistrationViewModel.class);
setContentView(binding.getRoot());
mandatoryFields = new ArrayList<>(Arrays.asList(binding.spBrand, binding.spModel, binding.editPowertrain, binding.editVariant,
@ -75,11 +79,11 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
timer = () -> Helper.hideSoftKeyboard(this);
delayHidingKeyboard(500);
//brandAdapter = new VehicleBrandAdapter(getApplicationContext(), getLayoutInflater(), model.getVehicleBrands().getValue());
viewModel.fetchVehicleBrands();
viewModel.fetchVehiclePropulsionTypes();
viewModel.getCurrentVehicle().observe(this, this::setVehicle);
model.getCurrentVehicle().observe(this, this::setVehicle);
model.getVehicleBrands().observe(this, items -> {
viewModel.getVehicleBrands().observe(this, items -> {
Log.d(TAG, "observe brands " + items.size());
brandAdapter = new VehicleBrandAdapter(getApplicationContext(), getLayoutInflater(), items);
binding.spBrand.setAdapter(brandAdapter);
@ -88,7 +92,7 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id1) {
VehicleBrand brand = brandAdapter.getItem(position);
model.getVehicleModels().postValue(brand.getModels());
viewModel.getVehicleModels().postValue(brand.getModels());
}
@Override
@ -98,20 +102,19 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
brandAdapter.notifyDataSetChanged();
});
model.getVehicleModels().observe(this, items -> {
Log.d(TAG, "observe models " + items.size());
binding.spModel.setClickable(items != null);
// viewModel.getVehicleModels().observe(this, items -> {
// binding.spModel.setClickable(items != null);
//
// VehicleModelAdapter adapter = new VehicleModelAdapter(getApplicationContext(), getLayoutInflater(), items);
// binding.spModel.setAdapter(adapter);
// adapter.notifyDataSetChanged();
// });
VehicleModelAdapter adapter = new VehicleModelAdapter(getApplicationContext(), getLayoutInflater(), items);
binding.spModel.setAdapter(adapter);
adapter.notifyDataSetChanged();
});
model.getVehiclePropulsionTypes().observe(this, items -> {
PropulsionTypeAdapter adapter = new PropulsionTypeAdapter(getApplicationContext(), getLayoutInflater(), items);
binding.spPropulsion.setAdapter(adapter);
adapter.notifyDataSetChanged();
viewModel.getVehiclePropulsionTypes().observe(this, items -> {
Log.d(TAG, "observe propulsion types " + items.size());
propulsionTypeAdapter = new PropulsionTypeAdapter(getApplicationContext(), getLayoutInflater(), items);
binding.spPropulsion.setAdapter(propulsionTypeAdapter);
propulsionTypeAdapter.notifyDataSetChanged();
});
@ -124,23 +127,45 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
//binding.datePickerRegistration.setMaxDate();
List<Vehicle> vehicles = model.getRepository().getStoredUserVehicles();
List<Vehicle> vehicles = viewModel.getRepository().getStoredUserVehicles();
if (vehicles.size() > 0) {
if (id == null) {
model.getCurrentVehicle().postValue(vehicles.get(0));
viewModel.getCurrentVehicle().postValue(vehicles.get(0));
} else {
final String finalId = id;
model.getCurrentVehicle().postValue(vehicles.stream().filter(x -> x.getVin().equals(finalId)).findFirst().get());
viewModel.getCurrentVehicle().postValue(vehicles.stream().filter(x -> x.getVin().equals(finalId)).findFirst().get());
}
}
binding.imgVehicle.setImageResource(R.drawable.ic_menu_gallery);
binding.imgVehicle.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.add_vehicle_image));
// add a list
String[] items = {getString(R.string.take_photo), getString(R.string.choose_from_gallery)};
builder.setItems(items, (dialog, which) -> {
switch (which) {
case 0:
startActivityForResult(new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE), REQUEST_IMAGE_CAPTURE);
break;
case 1:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_IMAGE_GALLERY);
break;
}
});
builder.create().show();
});
binding.btnStore.setOnClickListener(v -> {
model.storeVehicle(getVehicle());
viewModel.storeVehicle(getVehicle());
//Helper.infoDialog(handler, getApplicationContext(), "success");
});
binding.btnUnDo.setOnClickListener(v -> {
model.deleteVehicle(getVehicle());
viewModel.deleteVehicle(getVehicle());
});
binding.btnReload.setOnClickListener(v -> {
@ -150,7 +175,7 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
binding.btnRegisterVehicle.setOnClickListener(v -> {
Vehicle vehicle = getVehicle();
model
viewModel
.getRepository()
.storeCustomerVehicle(vehicle);
@ -188,7 +213,7 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
});
binding.btnUnregisterVehicle.setOnClickListener(v -> {
//TODO? viewModel.unregisterVehicle();
});
// mandatoryFields = new ArrayList<>(Arrays.asList(binding.spBrand, binding.spModel, binding.editPowertrain, binding.editVariant,
@ -205,25 +230,23 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
*/
binding.editRegistrationDate.setOnClickListener(v -> showDatePicker());
model.fetchData();
viewModel.fetchData();
}
private void setVehicle(Vehicle vehicle) {
Log.d(TAG, "observe vehicle " + vehicle);
if (vehicle.getBitmap() != null) {
binding.imgVehicle.setImageBitmap(vehicle.getBitmap());
}
int position = brandAdapter.getPosition(vehicle.getBrand());
if (position >= 0) {
binding.spBrand.setSelection(position, true);
}
binding.editPowertrain.setText(vehicle.getPowertrain());
binding.editVariant.setText(vehicle.getVariant());
binding.editVIN.setText(vehicle.getVin());
binding.editLicensePlate.setText(vehicle.getLicensePlate());
setRegistrationDate(vehicle.getRegistrationDate());
}
private void showDatePicker() {
DatePickerDialog dialog = new DatePickerDialog(this);
// DatePickerDialog dialog = new DatePickerDialog(getBaseContext());
dialog.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
Log.d("DATE", year + " " + month + " " + dayOfMonth + " ");
Date today = new Date(year - 1900, month, dayOfMonth);//getting date
setRegistrationDate(today);
}
});
dialog.show();
}
private void setRegistrationDate(Date date) {
if (date == null) {
binding.editRegistrationDate.setText("");
@ -238,24 +261,34 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
}
}
private void showDatePicker() {
DatePickerDialog dialog = new DatePickerDialog(this);
// DatePickerDialog dialog = new DatePickerDialog(getBaseContext());
dialog.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
Log.d("DATE", year + " " + month + " " + dayOfMonth + " ");
Calendar calendar = Calendar.getInstance();
private void setVehicle(Vehicle vehicle) {
Log.d(TAG, "observe vehicle " + vehicle);
if (vehicle.getBitmap() != null) {
binding.imgVehicle.setImageBitmap(vehicle.getBitmap());
}
int position = brandAdapter.getPosition(vehicle.getBrand());
if (position >= 0) {
binding.spBrand.setSelection(position, true);
VehicleBrand vehicleBrand = (VehicleBrand) binding.spBrand.getSelectedItem();
VehicleModelAdapter modelAdapter = new VehicleModelAdapter(this, getLayoutInflater(), vehicleBrand.getModels());
binding.spModel.setAdapter(modelAdapter);
modelAdapter.notifyDataSetChanged();
position = modelAdapter.getPosition(vehicle.getModel());
if (position >= 0) binding.spModel.setSelection(position, true);
}
position = propulsionTypeAdapter.getPosition(vehicle.getPropulsionType());
if (position >= 0) binding.spPropulsion.setSelection(position, true);
Date today = new Date(year - 1900, month, dayOfMonth);//getting date
setRegistrationDate(today);
}
});
dialog.show();
binding.editPowertrain.setText(vehicle.getPowertrain());
binding.editVariant.setText(vehicle.getVariant());
binding.editVIN.setText(vehicle.getVin());
binding.editLicensePlate.setText(vehicle.getLicensePlate());
setRegistrationDate(vehicle.getRegistrationDate());
}
private Vehicle getVehicle() {
Vehicle vehicle = new Vehicle();
vehicle.setBitmap(bitmap);
vehicle.setBrand(((VehicleBrand) binding.spBrand.getSelectedItem()).getName());
vehicle.setModel(((VehicleModel) binding.spModel.getSelectedItem()).getName());
vehicle.setPowertrain(binding.editPowertrain.getText().toString());
@ -268,7 +301,6 @@ public class RegisterVehicleActivity extends AppCompatActivity implements IVehOw
return vehicle;
}
private void delayHidingKeyboard(final int delay) {
handler.removeCallbacks(timer);
handler.postDelayed(timer, delay);

View File

@ -1,4 +1,4 @@
package eu.csc.vehown.ui.register;
package eu.csc.vehown.ui.registration;
import android.content.Context;
import androidx.lifecycle.MutableLiveData;

View File

@ -1,18 +1,14 @@
package eu.csc.vehown.ui.register;
import android.bluetooth.BluetoothClass;
package eu.csc.vehown.ui.registration;
import androidx.lifecycle.MutableLiveData;
import java.util.List;
import eu.csc.vehown.data.model.CustomerDevice;
import eu.csc.vehown.data.model.Vehicle;
import eu.csc.vehown.persist.sharedPreferences.LocalStorageClient;
import eu.csc.vehown.persist.sharedPreferences.LocalStorageClientImpl;
import eu.csc.vehown.ui.viewmodels.AbstractBaseViewModel;
import lombok.Getter;
import java.util.List;
public class ShowVehicleAndDevicesViewModel extends AbstractBaseViewModel {
@Getter
@ -40,10 +36,11 @@ public class ShowVehicleAndDevicesViewModel extends AbstractBaseViewModel {
}
public void reloadVehicles() {
this.mVehicles.postValue(localStorageClient.loadVehicles());
mVehicles.setValue(localStorageClient.loadVehicles());
}
public void reloadDevices() {
mDevices.postValue(localStorageClient.loadDevices());
mDevices.setValue(localStorageClient.loadDevices());
}
public void deleteDevice(CustomerDevice item) {

View File

@ -1,4 +1,4 @@
package eu.csc.vehown.ui.register;
package eu.csc.vehown.ui.registration;
import android.app.Activity;
import android.content.Intent;
@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @see ShowVehicleAndDevicesViewModel
@ -45,20 +46,15 @@ public class ShowVehiclesAndDevicesFragment extends AbstractFragment {
@Override
public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentShowVehiclesAndDevicesBinding.inflate(inflater, container, false);
// sharedPref = SharedPreferencesFactory.getInstance(getActivity());
launcherEditVehicle = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (result.getResultCode() == Activity.RESULT_OK) {
model.reloadVehicles();
}
model.reloadVehicles();
Objects.requireNonNull(binding.listVehicles.getAdapter()).notifyDataSetChanged();
});
launcherEditDevice = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
Log.d(TAG, "GETTING RESULT: " + result.getResultCode());
if (result.getResultCode() == Activity.RESULT_OK) {
model.reloadDevices();
}
model.reloadDevices();
Objects.requireNonNull(binding.listDevices.getAdapter()).notifyDataSetChanged();
});
@ -84,7 +80,6 @@ public class ShowVehiclesAndDevicesFragment extends AbstractFragment {
binding.listDevices.setAdapter(adapter);
});
model.init();
// model = new ViewModelProvider(this, new AppViewModelFactory(getActivity())).get(RegistrationViewModel.class);
binding.btnAddVehicle.setOnClickListener(v -> {
Log.d(ShowVehiclesAndDevicesFragment.class.getSimpleName(), "Add vehicle");
@ -96,21 +91,21 @@ public class ShowVehiclesAndDevicesFragment extends AbstractFragment {
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == LAUNCH_ACTIVITY_REGISTER_VEHICLE) {
if (resultCode == Activity.RESULT_OK) {
model.reloadVehicles();
}
}
if (requestCode == LAUNCH_ACTIVITY_REGISTER_DEVICE) {
if (resultCode == Activity.RESULT_OK) {
model.reloadDevices();
}
}
} //onActivityResult
// @Override
// public void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
//
// if (requestCode == LAUNCH_ACTIVITY_REGISTER_VEHICLE) {
// if (resultCode == Activity.RESULT_OK) {
// model.reloadVehicles();
// }
// }
// if (requestCode == LAUNCH_ACTIVITY_REGISTER_DEVICE) {
// if (resultCode == Activity.RESULT_OK) {
// model.reloadDevices();
// }
// }
// } //onActivityResult
public class VehicleAdapter extends RecyclerView.Adapter<VehicleAdapter.ViewHolder> {

View File

@ -16,23 +16,17 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import eu.csc.vehown.R;
import eu.csc.vehown.data.model.CustomerDevice;
import eu.csc.vehown.databinding.DeviceRegistrationFragmentBinding;
import eu.csc.vehown.databinding.FragmentDashboardBinding;
import eu.csc.vehown.ui.base.AbstractFragment;
import eu.csc.vehown.ui.md.ItemDetailFragment;
import eu.csc.vehown.ui.modal.Helper;
import eu.csc.vehown.ui.models.Result;
import eu.csc.vehown.ui.pub.UIUtils;
import eu.csc.vehown.ui.register.RegisterCustomerActivity;
import eu.csc.vehown.ui.register.RegistrationViewModel;
import eu.csc.vehown.ui.registration.RegisterCustomerActivity;
import eu.csc.vehown.ui.registration.customer.ItemListDialogFragment;
import eu.csc.vehown.ui.viewmodels.AppViewModelFactory;
import lombok.var;

View File

@ -1,4 +1,4 @@
package eu.csc.vehown.ui.registration.ui.login;
package eu.csc.vehown.ui.registration.login;
import android.app.Activity;
import androidx.lifecycle.Observer;

View File

@ -1,4 +1,4 @@
package eu.csc.vehown.ui.registration.ui.login;
package eu.csc.vehown.ui.registration.login;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

View File

@ -8,6 +8,8 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -30,15 +32,14 @@ import eu.csc.vehown.ui.adapters.VehicleBrandAdapter;
import eu.csc.vehown.ui.adapters.VehicleModelAdapter;
import eu.csc.vehown.ui.base.ICallbackInterface;
import eu.csc.vehown.ui.md.ItemDetailFragment;
import eu.csc.vehown.ui.modal.Helper;
import eu.csc.vehown.ui.TextChangedListener;
import eu.csc.vehown.ui.viewmodels.AppViewModelFactory;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import static android.app.Activity.RESULT_OK;
@ -49,12 +50,14 @@ public class FragmentVehicleRegistration extends Fragment {
private static final int REQUEST_IMAGE_GALLERY = 12;
private FragmentVehicleRegistrationBinding binding;
private FragmentVehicleRegistrationViewModel mViewModel;
private FragmentVehicleRegistrationViewModel viewModel;
private VehicleBrandAdapter brandAdapter;
private PropulsionTypeAdapter propulsionTypeAdapter;
private List<View> mandatoryFields;
private ICallbackInterface mCallback;
private Bitmap bitmap;
private Handler handler;
private Runnable timer;
public static FragmentVehicleRegistration newInstance() {
return new FragmentVehicleRegistration();
@ -80,21 +83,22 @@ public class FragmentVehicleRegistration extends Fragment {
Bundle args = getArguments();
if (args != null) {
id = args.getString(ItemDetailFragment.ARG_ITEM_ID, null);
} else {
}
mViewModel = new ViewModelProvider(this, new AppViewModelFactory(getContext())).get(FragmentVehicleRegistrationViewModel.class);
viewModel = new ViewModelProvider(this, new AppViewModelFactory(getContext())).get(FragmentVehicleRegistrationViewModel.class);
mandatoryFields = new ArrayList<>(Arrays.asList(binding.spBrand, binding.spModel, binding.editPowertrain, binding.editVariant,
binding.editVIN, binding.editLicensePlate, binding.spPropulsion, binding.editRegistrationDate));
handler = new Handler(Looper.getMainLooper());
timer = () -> Helper.hideSoftKeyboard(getActivity());
delayHidingKeyboard(500);
mViewModel.fetchVehicleBrands();
mViewModel.fetchVehiclePropulsionTypes();
mViewModel.getCurrentVehicle().observe(getViewLifecycleOwner(), this::setVehicle);
viewModel.fetchVehicleBrands();
viewModel.fetchVehiclePropulsionTypes();
viewModel.getCurrentVehicle().observe(getViewLifecycleOwner(), this::setVehicle);
mViewModel.getVehicleBrands().observe(getViewLifecycleOwner(), items -> {
viewModel.getVehicleBrands().observe(getViewLifecycleOwner(), items -> {
Log.d(TAG, "observe brands " + items.size());
brandAdapter = new VehicleBrandAdapter(getContext(), getLayoutInflater(), items);
binding.spBrand.setAdapter(brandAdapter);
@ -102,7 +106,7 @@ public class FragmentVehicleRegistration extends Fragment {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id1) {
VehicleBrand brand = brandAdapter.getItem(position);
mViewModel.getVehicleModels().postValue(brand.getModels());
viewModel.getVehicleModels().postValue(brand.getModels());
}
@Override
@ -120,33 +124,30 @@ public class FragmentVehicleRegistration extends Fragment {
// adapter.notifyDataSetChanged();
// });
mViewModel.getVehiclePropulsionTypes().observe(getViewLifecycleOwner(), items -> {
viewModel.getVehiclePropulsionTypes().observe(getViewLifecycleOwner(), items -> {
Log.d(TAG, "observe propulsion types " + items.size());
propulsionTypeAdapter = new PropulsionTypeAdapter(getContext(), getLayoutInflater(), items);
binding.spPropulsion.setAdapter(propulsionTypeAdapter);
propulsionTypeAdapter.notifyDataSetChanged();
});
/*
final View.OnFocusChangeListener focusListener = (v, hasFocus) -> delayHidingKeyboard(3000);
final TextChangedListener changedListener = new TextChangedListener(() -> {
delayHidingKeyboard((3000));
Helper.enableButton(binding.btnRegisterVehicle, mandatoryFields);
});
Helper.addListener(mandatoryFields, focusListener, changedListener);
*/
//binding.datePickerRegistration.setMaxDate();
List<Vehicle> vehicles = mViewModel.getRepository().getStoredUserVehicles();
List<Vehicle> vehicles = viewModel.getRepository().getStoredUserVehicles();
if (vehicles.size() > 0) {
if (id == null) {
mViewModel.getCurrentVehicle().postValue(vehicles.get(0));
viewModel.getCurrentVehicle().postValue(vehicles.get(0));
} else {
final String finalId = id;
mViewModel.getCurrentVehicle().postValue(vehicles.stream().filter(x -> x.getVin().equals(finalId)).findFirst().get());
viewModel.getCurrentVehicle().postValue(vehicles.stream().filter(x -> x.getVin().equals(finalId)).findFirst().get());
}
}
@ -175,12 +176,12 @@ public class FragmentVehicleRegistration extends Fragment {
if (mCallback != null) {
mCallback.showIdle("RUNNING");
}
mViewModel.storeVehicle(getVehicle());
viewModel.storeVehicle(getVehicle());
//Helper.infoDialog(handler, getApplicationContext(), "success");
});
binding.btnUnDo.setOnClickListener(v -> {
mViewModel.deleteVehicle(getVehicle());
viewModel.deleteVehicle(getVehicle());
});
binding.btnReload.setOnClickListener(v -> {
@ -190,7 +191,7 @@ public class FragmentVehicleRegistration extends Fragment {
binding.btnRegisterVehicle.setOnClickListener(v -> {
Vehicle vehicle = getVehicle();
mViewModel
viewModel
.getRepository()
.storeCustomerVehicle(vehicle);
@ -228,12 +229,12 @@ public class FragmentVehicleRegistration extends Fragment {
});
binding.btnUnregisterVehicle.setOnClickListener(v -> {
mViewModel.unregisterVehicle();
viewModel.unregisterVehicle();
});
binding.editRegistrationDate.setOnClickListener(v -> showDatePicker());
mViewModel.fetchData();
viewModel.fetchData();
return root;
@ -248,7 +249,6 @@ public class FragmentVehicleRegistration extends Fragment {
Log.d("DATE", year + " " + month + " " + dayOfMonth + " ");
Date today = new Date(year - 1900, month, dayOfMonth);//getting date
setRegistrationDate(today);
}
});
@ -309,6 +309,10 @@ public class FragmentVehicleRegistration extends Fragment {
return vehicle;
}
private void delayHidingKeyboard(final int delay) {
handler.removeCallbacks(timer);
handler.postDelayed(timer, delay);
}
@Override
public void onAttach(Activity activity) {

View File

@ -9,14 +9,14 @@ import eu.csc.vehown.persist.sharedPreferences.LocalStorageClient;
import eu.csc.vehown.persist.sharedPreferences.SharedPreferencesFactory;
import eu.csc.vehown.ui.fragments.data.LoginRepository;
import eu.csc.vehown.ui.fragments.ui.login.LoginViewModel;
import eu.csc.vehown.ui.register.RegistrationViewModel;
import eu.csc.vehown.ui.register.ShowVehicleAndDevicesViewModel;
import eu.csc.vehown.ui.registration.RegistrationViewModel;
import eu.csc.vehown.ui.registration.ShowVehicleAndDevicesViewModel;
import eu.csc.vehown.ui.registration.customer.FragmentCustomerRegistrationViewModel;
import eu.csc.vehown.ui.registration.data.CustomerContentDataSource;
import eu.csc.vehown.ui.registration.data.CustomerRegistrationRepository;
import eu.csc.vehown.ui.registration.data.CustomerVehicleRegistrationRepository;
import eu.csc.vehown.ui.registration.devices.DeviceRegistrationViewModel;
import eu.csc.vehown.ui.registration.ui.login.CustomerRegistrationViewModel;
import eu.csc.vehown.ui.registration.login.CustomerRegistrationViewModel;
import eu.csc.vehown.ui.registration.vehicle.FragmentVehicleRegistrationViewModel;
/**

View File

@ -1,248 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp">
<ImageView
android:id="@+id/imgVehicle"
android:layout_width="@dimen/systemImageWidth1"
android:layout_height="@dimen/systemImageHeight1"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginBottom="15dp"
android:src="@drawable/ic_default_vehicle"
android:contentDescription="@string/image"/>
<TextView
android:id="@+id/tvBrand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imgVehicle"
android:textSize="@dimen/fontS"
android:text="@string/vehicle_brand"
/>
<Spinner
android:id="@+id/spBrand"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvBrand"
android:spinnerMode="dialog"
/>
<TextView
android:id="@+id/tvModel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/spBrand"
android:layout_marginTop="10dp"
android:textSize="@dimen/fontS"
android:text="@string/vehicle_model"
/>
<Spinner
android:id="@+id/spModel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvModel"
android:spinnerMode="dialog"
android:clickable="false"
/>
<TextView
android:id="@+id/tvPowertrain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/spModel"
android:layout_marginTop="10dp"
android:textSize="@dimen/fontS"
android:text="@string/powertrain"
android:labelFor="@id/editPowertrain"
/>
<EditText
android:id="@+id/editPowertrain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvPowertrain"
android:layout_marginTop="5dp"
android:inputType="text"
android:autofillHints="@string/powertrain"
android:ems="15"/>
<TextView
android:id="@+id/tvVariant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/editPowertrain"
android:layout_marginTop="5dp"
android:textSize="@dimen/fontS"
android:text="@string/variant"
android:labelFor="@id/editVariant"
/>
<EditText
android:id="@+id/editVariant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvVariant"
android:inputType="text"
android:autofillHints="@string/variant"
android:ems="15"/>
<TextView
android:id="@+id/tvVIN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/editVariant"
android:layout_marginTop="5dp"
android:textSize="@dimen/fontS"
android:text="@string/vin"
android:labelFor="@id/editVIN"
/>
<EditText
android:id="@+id/editVIN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvVIN"
android:inputType="text"
android:autofillHints="@string/vin"
android:ems="15"/>
<TextView
android:id="@+id/tvLicensePlate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/editVIN"
android:layout_marginTop="5dp"
android:textSize="@dimen/fontS"
android:text="@string/license_plate"
android:labelFor="@id/editLicensePlate"
/>
<EditText
android:id="@+id/editLicensePlate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvLicensePlate"
android:inputType="text"
android:autofillHints="@string/license_plate"
android:ems="15"/>
<TextView
android:id="@+id/tvPropulsion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editLicensePlate"
android:layout_marginTop="5dp"
android:textSize="@dimen/fontS"
android:text="@string/propulsion_type"
/>
<Spinner
android:id="@+id/spPropulsion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvPropulsion"
android:spinnerMode="dialog"
/>
<TextView
android:id="@+id/tvRegistrationDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/spPropulsion"
android:layout_marginTop="5dp"
android:textSize="@dimen/fontS"
android:text="@string/registration_date"
android:labelFor="@id/editRegistrationDate"
/>
<EditText
android:id="@+id/editRegistrationDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvRegistrationDate"
android:inputType="date"
android:autofillHints="@string/registration_date"
android:focusable="false"
/>
<!--androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginTop="20dp"
android:layout_below="@id/tvDatePickerRegistration"/-->
<LinearLayout
android:id="@+id/llLocalButtons"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_below="@+id/editRegistrationDate"
android:layout_width="match_parent">
<Button
android:id="@+id/btnStore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/store_register_vehicle"
style="?android:attr/buttonBarButtonStyle"
android:enabled="true"/>
<Button
android:id="@+id/btnUnDo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/undo_register_vehicle"
style="?android:attr/buttonBarButtonStyle"
android:enabled="true"/>
<Button
android:id="@+id/btnReload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/reload_from_storage_register_vehicle"
style="?android:attr/buttonBarButtonStyle"
android:enabled="true"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="@+id/llLocalButtons">
<Button
android:id="@+id/btnRegisterVehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/register_vehicle"
style="?android:attr/buttonBarButtonStyle"
android:enabled="false"/>
<Button
android:id="@+id/btnUnregisterVehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/unregister_vehicle"
style="?android:attr/buttonBarButtonStyle"
android:enabled="false"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>

View File

@ -4,7 +4,7 @@
android:id="@+id/llVehicle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
android:layout_marginBottom="10dp">
<ImageView
android:id="@+id/img"
@ -19,6 +19,7 @@
android:layout_height="wrap_content"
android:layout_toEndOf="@id/img"
android:layout_toStartOf="@id/btnDelete"
android:layout_marginStart="10dp"
android:textColor="@color/green"
android:textStyle="bold"/>
@ -30,5 +31,6 @@
android:layout_alignParentEnd="true"
app:tint="@android:color/holo_red_light"
app:backgroundTint="@android:color/transparent"
/>
android:contentDescription="@string/image"/>
</RelativeLayout>

View File

@ -21,7 +21,7 @@
android:layout_toStartOf="@id/btnAddVehicle"
android:text="@string/vehicles"
android:textSize="@dimen/fontL"
android:textStyle="normal"/>
android:textStyle="bold"/>
<ImageButton
android:id="@+id/btnAddVehicle"
@ -60,7 +60,7 @@
android:layout_toStartOf="@id/btnAddDevice"
android:text="@string/devices"
android:textSize="@dimen/fontL"
android:textStyle="normal" />
android:textStyle="bold" />
<ImageButton
android:id="@+id/btnAddDevice"

View File

@ -13,7 +13,7 @@
<fragment
android:id="@+id/nav_show_vehicles_devices"
android:name="eu.csc.vehown.ui.register.ShowVehiclesAndDevicesFragment"
android:name="eu.csc.vehown.ui.registration.ShowVehiclesAndDevicesFragment"
android:label="@string/show_vehicles_and_devices"
tools:layout="@layout/fragment_show_vehicles_and_devices"/>

View File

@ -82,21 +82,25 @@
<string name="invalid_username">Not a valid username</string>
<string name="invalid_password">Password must be >5 characters</string>
<string name="login_failed">"Login failed"</string>
<string name="title_activity_register_customer">RegisterCustomerActivity</string>
<string name="title_activity_register_vehicle">RegisterVehicleActivity</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="title_activity_failure_event">FailureEventActivity</string>
<string name="title_activity_main">MainActivity</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_settings">Settings</string>
<string name="title_activity_failure_event">FailureEventActivity</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_register_customer">RegisterCustomerActivity</string>
<string name="title_activity_register_device">RegisterDeviceActivity</string>
<string name="title_activity_register_vehicle">RegisterVehicleActivity</string>
<string name="title_activity_settings">SettingsActivity</string>
<string name="title_activity_item_detail_host">ItemDetailHostActivity</string>
<string name="title_activity_base_registration">BaseRegistrationActivity</string>
<string name="title_activity_local_content_navigation">LocalContentNavigationActivity</string>
<!-- Preference Titles -->
<string name="messages_header">Messages</string>
@ -131,7 +135,6 @@
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Password</string>
<string name="title_activity_register_device">RegisterDeviceActivity</string>
<string name="hello_first_fragment">Hello first fragment</string>
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
@ -139,7 +142,6 @@
<string name="vehicles">Vehicles</string>
<string name="devices">Devices</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 Customer</string>
<string name="prompt_firstname">Firstname</string>
@ -147,7 +149,6 @@
<string name="prompt_Postal">Zip/Postal</string>
<string name="store_register_vehicle">Store</string>
<string name="undo_register_vehicle">Undo</string>
<string name="title_activity_item_detail_host">ItemDetailHostActivity</string>
<string name="title_item_list">Items</string>
<string name="title_item_detail">Item Detail</string>
<string name="menu_list_vehicles">Customer Vehicles</string>
@ -156,7 +157,6 @@
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="unregister_vehicle">Unregister</string>
<string name="title_activity_base_registration">BaseRegistrationActivity</string>
<string name="title_home">Home</string>
<string name="title_dashboard">Dashboard</string>
<string name="title_notifications">Notifications</string>
@ -165,7 +165,6 @@
<string name="btn_registration">Register</string>
<string name="title_register_customer">Customer</string>
<string name="menu_list_content">Content</string>
<string name="title_activity_local_content_navigation">LocalContentNavigationActivity</string>
<string name="nav_header_title">Android Studio</string>
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="nav_header_desc">Navigation header</string>

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -69,6 +69,7 @@ public class Vehicle implements Serializable {
* @return the bitmap
*/
public Bitmap getBitmap() {
if (bitmapString == null) return null;
byte[] decodedString = Base64.decode(bitmapString, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
}}