Commit b6c2fd89 authored by Ishankha K.C's avatar Ishankha K.C

modify activity logs view

parent 6a3bcfe2
......@@ -12,7 +12,9 @@ import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
......@@ -21,6 +23,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
......@@ -94,6 +97,35 @@ public class ActivityLogsActivity extends AppCompatActivity {
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
ImageView clearIcon = findViewById(R.id.clear_icon);
clearIcon.setOnTouchListener((v, event) -> {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Apply the pressed color tint
clearIcon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.cancel_red));
break;
case MotionEvent.ACTION_UP:
// Revert to the default color
clearIcon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.purple));
// Call performClick() to handle the click action properly
clearIcon.performClick();
break;
case MotionEvent.ACTION_CANCEL:
// Revert to the default color
clearIcon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.purple));
break;
}
return true; // Return true to indicate the touch event is consumed
});
// Override performClick to provide click handling
clearIcon.setOnClickListener(v -> {
// Handle the click action here
// You can add your click handling logic here
});
}
private void loadData() {
......
......@@ -42,6 +42,7 @@ public class DashboardActivity extends AppCompatActivity {
btn1.setOnClickListener(v -> {
Intent intent = new Intent(this, LiveFeedActivity.class);
startActivity(intent);
animationChanger(this);
});
btn2.setOnClickListener(v -> {
......@@ -49,6 +50,7 @@ public class DashboardActivity extends AppCompatActivity {
btn3.setOnClickListener(v -> {
Intent intent = new Intent(this, ActivityLogsActivity.class);
startActivity(intent);
animationChanger(this);
});
btn4.setOnClickListener(v -> {
Intent intent = new Intent(this, DeviceControlsActivity.class);
......@@ -58,10 +60,12 @@ public class DashboardActivity extends AppCompatActivity {
btn5.setOnClickListener(v -> {
Intent intent = new Intent(this, BabyDashboardActivity.class);
startActivity(intent);
animationChanger(this);
});
btn6.setOnClickListener(v -> {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
animationChanger(this);
});
}
......
package com.kaluwa.enterprises.babycare.adapter;
import static com.kaluwa.enterprises.babycare.utils.Utils.getDateTimeFormatter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -13,6 +16,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.dto.ActivityLogDto;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.List;
public class ActivityLogsAdapter extends RecyclerView.Adapter<ActivityLogsAdapter.ActivityLogItemHolder> {
......@@ -35,12 +41,19 @@ public class ActivityLogsAdapter extends RecyclerView.Adapter<ActivityLogsAdapte
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull ActivityLogsAdapter.ActivityLogItemHolder holder, int position) {
public void onBindViewHolder(@NonNull ActivityLogItemHolder holder, int position) {
ActivityLogDto activityLogDto = activityLogList.get(position);
holder.tvActivityLogId.setText(activityLogDto.getActivityLogId().toString());
holder.tvActivityType.setText(activityLogDto.getActivityLogType());
// holder.tvActivityLogId.setText(activityLogDto.getActivityLogId().toString());
if (activityLogDto.getActivityLogType().equals("EMOTION")) {
holder.tvActivityType.setText("MOOD");
} else {
holder.tvActivityType.setText(activityLogDto.getActivityLogType());
}
holder.tvDescription.setText(activityLogDto.getActivityLogDescription());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
holder.tvLogTime.setText(LocalDateTime.now().format(formatter));
}
}
@Override
......@@ -50,11 +63,11 @@ public class ActivityLogsAdapter extends RecyclerView.Adapter<ActivityLogsAdapte
public static class ActivityLogItemHolder extends RecyclerView.ViewHolder {
public TextView tvActivityLogId, tvActivityType, tvDescription;
public TextView tvLogTime, tvActivityType, tvDescription;
public ActivityLogItemHolder(@NonNull View view) {
super(view);
tvActivityLogId = view.findViewById(R.id.tvActivityLogId);
tvLogTime = view.findViewById(R.id.tvLogTime);
tvActivityType = view.findViewById(R.id.tvActivityType);
tvDescription = view.findViewById(R.id.tvDescription);
}
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/cancel_red" /> <!-- Pressed state -->
<item android:color="@color/purple" /> <!-- Default state -->
</selector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="32dp" android:viewportHeight="72" android:viewportWidth="72" android:width="32dp">
<path android:fillColor="@android:color/black" android:pathData="M34.3,8c-0.5,1.8 -1.4,2 -7.4,2 -3.8,-0 -7.9,0.5 -9.2,1.2 -1.2,0.6 -2.8,1.4 -3.5,1.7 -0.8,0.3 -1.3,1 -1.3,1.6 0.1,0.6 8.5,1 23.1,1 14.6,-0 23,-0.4 23.1,-1 0,-0.6 -0.5,-1.3 -1.3,-1.6 -0.7,-0.3 -2.3,-1.1 -3.5,-1.7 -1.3,-0.7 -5.4,-1.2 -9.2,-1.2 -6,-0 -6.9,-0.2 -7.4,-2 -0.3,-1.1 -1,-2 -1.7,-2 -0.7,-0 -1.4,0.9 -1.7,2z" android:strokeColor="#00000000"/>
<path android:fillColor="@android:color/black" android:pathData="M15.4,25.2c0.3,1.8 1.3,10.3 2.1,18.8 1.2,11.9 2,15.8 3.2,16.7 1.2,0.9 6,1.3 15.4,1.3 11.2,-0 14.1,-0.3 15.3,-1.6 0.9,-0.8 1.6,-1.8 1.6,-2 0,-1.1 3,-29.1 3.5,-32.7l0.5,-3.7 -21,-0 -21.1,-0 0.5,3.2z" android:strokeColor="#00000000"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white"/> <!-- Background color -->
<corners android:radius="16dp"/> <!-- Adjust the radius for the corners -->
</shape>
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/cancel_red">
<item android:id="@android:id/mask">
<color android:color="@android:color/white" />
</item>
</ripple>
......@@ -51,55 +51,12 @@
</RelativeLayout>
<!-- Header Row for the Table -->
<LinearLayout
android:id="@+id/headerRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/gray"
android:paddingTop="6dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingBottom="6dp"
app:layout_constraintTop_toBottomOf="@id/rl_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="Id"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Activity Type"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Description"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black"/>
</LinearLayout>
<!-- RecyclerView for the Table Content -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_activity_notifications"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/headerRow"
app:layout_constraintTop_toBottomOf="@id/rl_header"
app:layout_constraintBottom_toBottomOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
app:layout_constraintStart_toStartOf="@id/background"
......@@ -107,7 +64,41 @@
android:paddingTop="6dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingBottom="6dp"/>
android:paddingBottom="6dp"
android:background="@drawable/noti_recycler_view_background"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"/>
<!-- Notification Icon -->
<ImageView
android:id="@+id/notification_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:src="@drawable/ico_notifications_active_32"
android:contentDescription="Notification Icon"
app:layout_constraintTop_toTopOf="@id/rv_activity_notifications"
app:layout_constraintEnd_toEndOf="@id/rv_activity_notifications"
android:layout_gravity="end"
app:tint="@color/purple" />
<!-- Clear Icon -->
<ImageView
android:id="@+id/clear_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:src="@drawable/ico_delete"
android:contentDescription="Clear History Icon"
app:layout_constraintBottom_toBottomOf="@id/rv_activity_notifications"
app:layout_constraintEnd_toEndOf="@id/rv_activity_notifications"
android:layout_gravity="end"
app:tint="@color/icon_color_selector" />
<TextView
android:id="@+id/no_content_message"
......
......@@ -6,21 +6,25 @@
android:padding="8dp">
<TextView
android:id="@+id/tvActivityLogId"
android:id="@+id/tvLogTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="Id"
android:layout_weight="2"
android:text="Date &amp; Time"
android:textSize="16sp"
android:textStyle="bold"/>
android:textStyle="bold"
android:paddingRight="4dp"
android:textColor="@color/black"
android:fontFamily="@font/acme_regular"/>
<TextView
android:id="@+id/tvActivityType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_weight="1.6"
android:text="Activity Type"
android:textSize="16sp" />
android:textSize="16sp"
android:paddingRight="4dp"/>
<TextView
android:id="@+id/tvDescription"
......@@ -28,6 +32,8 @@
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Description"
android:textSize="16sp" />
android:textSize="16sp"
android:textColor="@color/black"
android:fontFamily="@font/acme_regular" />
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment