Browse Source

Added alarm history to project and renaming

DoNotMerge_Runnable_Test_Branch
Christian Tinz 1 year ago
parent
commit
032ab2788d

+ 28
- 18
app/src/main/java/com/example/greenwatch/AccelerometerActivity.java View File

@@ -3,6 +3,8 @@ package com.example.greenwatch;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
@@ -14,6 +16,8 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.greenwatch.adapters.AlarmHistoryListAdapter;
import com.example.greenwatch.adapters.DeviceListAdapter;
import com.example.greenwatch.models.Device;
import com.example.greenwatch.viewmodels.AccelerometerViewModel;

@@ -39,6 +43,20 @@ public class AccelerometerActivity extends AppCompatActivity implements SensorEv
accelerometerWarningTV = (TextView) findViewById(R.id.tvAccelerometerWarning);
backToMainActivityButton = (Button) findViewById(R.id.accelerometerBackToMainActivity);

RecyclerView recyclerView = findViewById(R.id.deviceListRecyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);

final DeviceListAdapter deviceListAdapter = new DeviceListAdapter();
recyclerView.setAdapter(deviceListAdapter);

RecyclerView alarmHistoryListRecyclerView = findViewById(R.id.alarmHistoryListRecyclerView);
alarmHistoryListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
alarmHistoryListRecyclerView.setHasFixedSize(true);

final AlarmHistoryListAdapter alarmHistoryListAdapter = new AlarmHistoryListAdapter();
alarmHistoryListRecyclerView.setAdapter(alarmHistoryListAdapter);

backToMainActivityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -51,34 +69,26 @@ public class AccelerometerActivity extends AppCompatActivity implements SensorEv
mAccelerometerViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() {
@Override
public void onChanged(List<Device> devices) {
StringBuilder sb = new StringBuilder();
sb.append("Time Stamp: ");
sb.append(mAccelerometerViewModel.getTimeStamp(mAccelerometerViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("DeviceID: ");
sb.append(mAccelerometerViewModel.getDeviceID(mAccelerometerViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("Sensor Status: ");
sb.append(mAccelerometerViewModel.getSensorStatus(mAccelerometerViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("Sensor Type: ");
sb.append(mAccelerometerViewModel.getSensorType(mAccelerometerViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("Sensor Massage: ");
sb.append(mAccelerometerViewModel.getSensorMassage(mAccelerometerViewModel.getLocalDeviceUUID()));
accelerometerStatusMessage.setText(sb);
deviceListAdapter.setDevices(devices);
Toast.makeText(AccelerometerActivity.this, "onChanged", Toast.LENGTH_LONG).show();
}
});

mAccelerometerViewModel.getAlarmHistoryList().observe(this, new Observer<List<Device>>() {
@Override
public void onChanged(List<Device> devices) {
alarmHistoryListAdapter.setAlarmHistoryList(devices);
}
});

mAccelerometerViewModel.getMovementDetectedValue().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
if (aBoolean) {
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
}
else {
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), false, "Accelerometer", 0);
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), false, "Accelerometer", 0);
}

}

+ 22
- 26
app/src/main/java/com/example/greenwatch/MainActivity.java View File

@@ -10,9 +10,9 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.greenwatch.adapters.AlarmHistoryListAdapter;
import com.example.greenwatch.adapters.DeviceListAdapter;
import com.example.greenwatch.models.Device;
import com.example.greenwatch.viewmodels.MainActivityViewModel;
@@ -21,7 +21,6 @@ import java.util.List;

public class MainActivity extends AppCompatActivity {

private TextView tvstatusmessage;
private Button audiodetectionButton;
private Button videodetectionButton;
private Button accelerometerButton;
@@ -35,7 +34,6 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

tvstatusmessage = (TextView) findViewById(R.id.tvStatusmessage);
audiodetectionButton = (Button) findViewById(R.id.audiodetectionButton);
videodetectionButton = (Button) findViewById(R.id.videodetectionButton);
accelerometerButton = (Button) findViewById(R.id.accelerometerButton);
@@ -43,12 +41,19 @@ public class MainActivity extends AppCompatActivity {
videodetectionAndAccelerometerButton = (Button) findViewById(R.id.videodetectionAndAccelerometerButton);
connectionButton = (Button) findViewById(R.id.connectionButton);

RecyclerView recyclerView = findViewById(R.id.deviceListRecyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
RecyclerView deviceListRecyclerView = findViewById(R.id.deviceListRecyclerView);
deviceListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
deviceListRecyclerView.setHasFixedSize(true);

final DeviceListAdapter deviceListAdapter = new DeviceListAdapter();
recyclerView.setAdapter(deviceListAdapter);
deviceListRecyclerView.setAdapter(deviceListAdapter);

RecyclerView alarmHistoryListRecyclerView = findViewById(R.id.alarmHistoryListRecyclerView);
alarmHistoryListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
alarmHistoryListRecyclerView.setHasFixedSize(true);

final AlarmHistoryListAdapter alarmHistoryListAdapter = new AlarmHistoryListAdapter();
alarmHistoryListRecyclerView.setAdapter(alarmHistoryListAdapter);

mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
mMainActivityViewModel.init();
@@ -56,31 +61,22 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onChanged(List<Device> devices) {
deviceListAdapter.setDevices(devices);
StringBuilder sb = new StringBuilder();
sb.append("Time Stamp: ");
sb.append(mMainActivityViewModel.getTimeStamp(mMainActivityViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("DeviceID: ");
sb.append(mMainActivityViewModel.getDeviceID(mMainActivityViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("Sensor Status: ");
sb.append(mMainActivityViewModel.getSensorStatus(mMainActivityViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("Sensor Type: ");
sb.append(mMainActivityViewModel.getSensorType(mMainActivityViewModel.getLocalDeviceUUID()));
sb.append(";\n");
sb.append("Sensor Massage: ");
sb.append(mMainActivityViewModel.getSensorMassage(mMainActivityViewModel.getLocalDeviceUUID()));
tvstatusmessage.setText(sb);
Toast.makeText(MainActivity.this, "onChanged", Toast.LENGTH_LONG).show();
}
});

mMainActivityViewModel.getAlarmHistoryList().observe(this, new Observer<List<Device>>() {
@Override
public void onChanged(List<Device> devices) {
alarmHistoryListAdapter.setAlarmHistoryList(devices);
}
});

audiodetectionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//openAudiodetectionActivity();
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", false, "Audio", 10);
mMainActivityViewModel.updateDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", false, "Audio", 10);
}
});
videodetectionButton.setOnClickListener(new View.OnClickListener() {
@@ -140,12 +136,12 @@ public class MainActivity extends AppCompatActivity {
public void openVideodetectionAndAccelerometerActivity(){
//Intent intent = new Intent(this, VideodetectionAndAccelerometerActivity.class);
//startActivity(intent);
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "24:00", false, "Video", 0);
mMainActivityViewModel.updateDevice(mMainActivityViewModel.getLocalDeviceUUID(), "24:00", false, "Video", 0);
}
public void openConnectionActivity(){
//Intent intent = new Intent(this, ConnectionActivity.class);
//startActivity(intent);
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", true, "Audio", 10);
mMainActivityViewModel.updateDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", true, "Audio", 10);
}

}

+ 62
- 0
app/src/main/java/com/example/greenwatch/adapters/AlarmHistoryListAdapter.java View File

@@ -0,0 +1,62 @@
package com.example.greenwatch.adapters;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.greenwatch.R;
import com.example.greenwatch.models.Device;

import java.util.ArrayList;
import java.util.List;

public class AlarmHistoryListAdapter extends RecyclerView.Adapter<AlarmHistoryListAdapter.AlarmHistoryListHolder> {
private List<Device> alarmHistoryList = new ArrayList<>();


@NonNull
@Override
public AlarmHistoryListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.alarm_history_item, parent, false);
return new AlarmHistoryListHolder(itemView);
}

@Override
public void onBindViewHolder(@NonNull AlarmHistoryListHolder holder, int position) {
Device currentDevice = alarmHistoryList.get(position);
holder.textViewSensorType.setText(holder.itemView.getContext().getString(R.string.sensor_type_placeholder, currentDevice.getSensorType()));
holder.textViewDeviceID.setText(holder.itemView.getContext().getString(R.string.deviceID_placeholder, currentDevice.getDeviceID()));
holder.textViewTimeStamp.setText(holder.itemView.getContext().getString(R.string.sensor_time_stamp_placeholder, currentDevice.getTimeStamp()));
holder.textViewSensorMessage.setText(holder.itemView.getContext().getString(R.string.sensor_message_placeholder, currentDevice.getSensorMassage()));
}

@Override
public int getItemCount() {
return alarmHistoryList.size();
}

public void setAlarmHistoryList(List<Device> alarmHistoryList) {
this.alarmHistoryList = alarmHistoryList;
notifyDataSetChanged();
}

class AlarmHistoryListHolder extends RecyclerView.ViewHolder {
private TextView textViewSensorType;
private TextView textViewDeviceID;
private TextView textViewTimeStamp;
private TextView textViewSensorMessage;

public AlarmHistoryListHolder(View itemView) {
super(itemView);
textViewSensorType = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceSensorType);
textViewDeviceID = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceID);
textViewTimeStamp = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceTimeStamp);
textViewSensorMessage = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceSensorMassage);
}
}
}

+ 70
- 33
app/src/main/java/com/example/greenwatch/repositories/DeviceRepository.java View File

@@ -6,21 +6,26 @@ import androidx.lifecycle.MutableLiveData;
import com.example.greenwatch.models.Device;
import com.example.greenwatch.communication.WiFiCommunication;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

public class DeviceRepository {

private final int maxAlarmHistoryListSize = 20;
private final String delimiter = ", ";
private final String SensorStatusKey = "An";
private String localDeviceUUID;
private static DeviceRepository deviceRepositoryInstance;
private WiFiCommunication mWiFiCommunication;
private MutableLiveData<List<Device>> deviceList = new MutableLiveData<>();
private MutableLiveData<List<Device>> alarmHistoryList = new MutableLiveData<>();
private HashMap<String, Device> connectedDevicesList = new HashMap<>();
private HashMap<String, String> deviceIDMapper = new HashMap<>();
private List<Device> alarmHistoryDeviceList = new ArrayList<>();

private DeviceRepository() {
setLocalDeviceUUID();
@@ -38,15 +43,42 @@ public class DeviceRepository {
}

public MutableLiveData<List<Device>> getConnectedDeviceList() {
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
return deviceList;
}

public MutableLiveData<List<Device>> getAlarmHistoryDeviceList() {
setMutableLiveDataAlarmHistoryList();
return alarmHistoryList;
}

public void createNewDevice(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage){
Device newDevice = new Device(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
setDeviceIDMapper(deviceID);
if (sensorStatus) {
setAlarmHistoryDeviceList(newDevice);
}
addToConnectedDeviceList(newDevice.getDeviceID(), newDevice);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
}

public void getNewReceivedMessage(String newMessage) {
String[] messageString = messageStringSplitter(newMessage);
String timeStamp = messageString[0];
String deviceID = messageString[1];
boolean sensorStatus = convertSensorStatus(messageString[2]);
String sensorType = messageString[3];
int sensorMassage = Integer.valueOf(messageString[4]);

if (deviceID.equals(checkDeviceID(localDeviceUUID))) {
return;
}

if(!connectedDevicesList.containsKey(deviceID)) {
createNewDevice(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
}
else {
updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}
}

private String messageStringBuilder(String deviceID) {
@@ -62,7 +94,6 @@ public class DeviceRepository {
.append(device.getSensorType())
.append(delimiter)
.append(device.getSensorMassage());
return message.toString();
}
else {
message.append("")
@@ -74,8 +105,8 @@ public class DeviceRepository {
.append("")
.append(delimiter)
.append("");
return message.toString();
}
return message.toString();
}

public String getLocalDeviceUUID() {
@@ -87,11 +118,14 @@ public class DeviceRepository {
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {
device.setTimeStamp(timeStamp);
device.setSensorStatus(sensorStatus);
device.setSensorType(sensorType);
device.setSensorMassage(sensorMassage);
if (!device.getSensorStatus() && sensorStatus) {
setAlarmHistoryDeviceList(device);
}
device.setSensorStatus(sensorStatus);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
}
}

@@ -101,7 +135,7 @@ public class DeviceRepository {
if(device != null) {
device.setTimeStamp(timeStamp);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
}
}

@@ -122,7 +156,7 @@ public class DeviceRepository {
setDeviceIDMapper(newDeviceID);
connectedDevicesList.remove(checkedDeviceID);
addToConnectedDeviceList(newDeviceID, device);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
}
}

@@ -139,9 +173,13 @@ public class DeviceRepository {
String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {
if (!device.getSensorStatus() && sensorStatus) {
setAlarmHistoryDeviceList(device);
}
device.setSensorStatus(sensorStatus);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();

}
}

@@ -160,7 +198,7 @@ public class DeviceRepository {
if(device != null) {
device.setSensorType(sensorType);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
}
}

@@ -179,7 +217,7 @@ public class DeviceRepository {
if(device != null) {
device.setSensorMassage(sensorMessage);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataValue();
setMutableLiveDataDeviceList();
}
}

@@ -192,11 +230,21 @@ public class DeviceRepository {
return 0;
}

private void setMutableLiveDataValue() {
public String getSystemTimeStamp() {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date(System.currentTimeMillis());
return formatter.format(date);
}

private void setMutableLiveDataDeviceList() {
List<Device> list = new ArrayList<>(connectedDevicesList.values());
deviceList.setValue(list);
}

private void setMutableLiveDataAlarmHistoryList() {
alarmHistoryList.setValue(alarmHistoryDeviceList);
}

private void addToConnectedDeviceList(String key, Device device) {
connectedDevicesList.put(key, device);
if (key.equals(checkDeviceID(localDeviceUUID))) {
@@ -223,27 +271,16 @@ public class DeviceRepository {
return message.split(delimiter);
}

public void getNewReceivedMessage(String newMessage) {
String[] messageString = messageStringSplitter(newMessage);
String timeStamp = messageString[0];
String deviceID = messageString[1];
boolean sensorStatus = convertSensorStatus(messageString[2]);
String sensorType = messageString[3];
int sensorMassage = Integer.valueOf(messageString[4]);

if (deviceID.equals(checkDeviceID(localDeviceUUID))) {
return;
}

if(!connectedDevicesList.containsKey(deviceID)) {
createNewDevice(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
}
else {
updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}
}

private boolean convertSensorStatus(String status) {
return status.equals(SensorStatusKey);
}

private void setAlarmHistoryDeviceList(Device device) {
if (alarmHistoryDeviceList.size() == maxAlarmHistoryListSize) {
alarmHistoryDeviceList.remove(alarmHistoryDeviceList.size() -1);
}
Device alarmHistoryDevice = new Device(device.getTimeStamp(), device.getDeviceID(), device.getSensorStatus(), device.getSensorType(), device.getSensorMassage());
alarmHistoryDeviceList.add(0, alarmHistoryDevice);
setMutableLiveDataAlarmHistoryList();
}
}

+ 8
- 4
app/src/main/java/com/example/greenwatch/viewmodels/AccelerometerViewModel.java View File

@@ -16,6 +16,7 @@ public class AccelerometerViewModel extends ViewModel {

private MutableLiveData<List<Device>> mDeviceList;
private MutableLiveData<Boolean> mMovementDetected = new MutableLiveData<>();
private MutableLiveData<List<Device>> mAlarmHistoryList;
private DeviceRepository mDeviceRepository;
private ArrayList<Float> Gesamt_be;
int arraySize = 500;
@@ -29,6 +30,7 @@ public class AccelerometerViewModel extends ViewModel {
if (mDeviceList == null) {
mDeviceRepository = DeviceRepository.getInstance();
mDeviceList = mDeviceRepository.getConnectedDeviceList();
mAlarmHistoryList = mDeviceRepository.getAlarmHistoryDeviceList();
}
initGesamtBE();
mMovementDetected.setValue(false);
@@ -80,9 +82,7 @@ public class AccelerometerViewModel extends ViewModel {
}

public String getSystemTimeStamp() {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date(System.currentTimeMillis());
return formatter.format(date);
return mDeviceRepository.getSystemTimeStamp();
}

public LiveData<Boolean> getMovementDetectedValue() {
@@ -93,7 +93,11 @@ public class AccelerometerViewModel extends ViewModel {
return mDeviceList;
}

public void setDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public LiveData<List<Device>> getAlarmHistoryList() {
return mAlarmHistoryList;
}

public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}


+ 9
- 2
app/src/main/java/com/example/greenwatch/viewmodels/MainActivityViewModel.java View File

@@ -13,6 +13,7 @@ import java.util.List;
public class MainActivityViewModel extends ViewModel {

private MutableLiveData<List<Device>> mDeviceList;
private MutableLiveData<List<Device>> mAlarmHistoryList;
private DeviceRepository mDeviceRepository;


@@ -26,15 +27,21 @@ public class MainActivityViewModel extends ViewModel {
mWiFiCommunication = WiFiCommunication.getInstance();
mDeviceRepository.setWiFiCommunication(mWiFiCommunication);
mWiFiCommunication.setDeviceRepository(mDeviceRepository);
mDeviceRepository.createNewDevice("", mDeviceRepository.getLocalDeviceUUID(), false, "No Sensor selected", 0);
mDeviceRepository.createNewDevice(mDeviceRepository.getSystemTimeStamp(), mDeviceRepository.getLocalDeviceUUID(), false, "No Sensor selected", 0);
mDeviceRepository.createNewDevice("00:00", "1234", true, "Test", 21);
mDeviceList = mDeviceRepository.getConnectedDeviceList();
mAlarmHistoryList = mDeviceRepository.getAlarmHistoryDeviceList();
}

public LiveData<List<Device>> getConnectedDeviceList() {
return mDeviceList;
}

public void setDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public LiveData<List<Device>> getAlarmHistoryList() {
return mAlarmHistoryList;
}

public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}


+ 23
- 0
app/src/main/res/layout/activity_accelerometer.xml View File

@@ -36,4 +36,27 @@
android:text="Back to MainActivity">
</Button>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/deviceListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/device_item"
android:layout_weight="1">
</androidx.recyclerview.widget.RecyclerView>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alarmHistoryListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/alarm_history_item"
android:layout_weight="1">
</androidx.recyclerview.widget.RecyclerView>

</LinearLayout>

</LinearLayout>

+ 6
- 6
app/src/main/res/layout/activity_main.xml View File

@@ -8,19 +8,19 @@
android:padding="10dp"
tools:context=".MainActivity">

<TextView
android:id="@+id/tvStatusmessage"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alarmHistoryListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello World!"
android:layout_weight="4">
</TextView>
android:layout_weight="3"
tools:listitem="@layout/alarm_history_item">
</androidx.recyclerview.widget.RecyclerView>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/deviceListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_weight="3"
tools:listitem="@layout/device_item">
</androidx.recyclerview.widget.RecyclerView>

+ 51
- 0
app/src/main/res/layout/alarm_history_item.xml View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp">

<TextView
android:id="@+id/tvAlarmHistoryDeviceSensorType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sensor_type_placeholder"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:maxLines="1"
android:layout_alignParentStart="true"
android:ellipsize="end">
</TextView>

<TextView
android:id="@+id/tvAlarmHistoryDeviceID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvAlarmHistoryDeviceSensorType"
android:text="@string/deviceID_placeholder">
</TextView>

<TextView
android:id="@+id/tvAlarmHistoryDeviceTimeStamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvAlarmHistoryDeviceID"
android:text="@string/sensor_time_stamp_placeholder">
</TextView>

<TextView
android:id="@+id/tvAlarmHistoryDeviceSensorMassage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvAlarmHistoryDeviceTimeStamp"
android:text="@string/sensor_message_placeholder">
</TextView>

</RelativeLayout>

</androidx.cardview.widget.CardView>

Loading…
Cancel
Save