From 1a62f959f1a9955dba52110d2400b6e7f353478e Mon Sep 17 00:00:00 2001
From: Rito <116003382+vinhnamhai321@users.noreply.github.com>
Date: Fri, 9 Aug 2024 18:31:45 +0700
Subject: [PATCH 1/5] Add toDoButton and musicButton
---
.../CustomUIComponent/MyButton.java | 11 ++-
.../MainScreenActivity.java | 88 ++++++++++++++++---
app/src/main/res/drawable/music.xml | 20 +++++
app/src/main/res/drawable/note.xml | 9 ++
.../main/res/layout/activity_main_screen.xml | 56 ++++++++++++
app/src/main/res/values/styles.xml | 2 +-
6 files changed, 170 insertions(+), 16 deletions(-)
create mode 100644 app/src/main/res/drawable/music.xml
create mode 100644 app/src/main/res/drawable/note.xml
diff --git a/app/src/main/java/com/hfad/cs426_final_project/CustomUIComponent/MyButton.java b/app/src/main/java/com/hfad/cs426_final_project/CustomUIComponent/MyButton.java
index 873b569..d48c5e1 100644
--- a/app/src/main/java/com/hfad/cs426_final_project/CustomUIComponent/MyButton.java
+++ b/app/src/main/java/com/hfad/cs426_final_project/CustomUIComponent/MyButton.java
@@ -47,18 +47,25 @@ private void init() {
@Override
public boolean onTouchEvent(MotionEvent event) {
+ int color;
switch (event.getAction()) {
+ //case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_DOWN:
// Change tint color when the button is pressed
//DrawableCompat.setTint(originalDrawable, ContextCompat.getColor(getContext(), R.color.ripple_effect));
this.getBackground().setAlpha(128);
+ color = getCurrentTextColor();
+ this.setTextColor(Color.argb(128, Color.red(color),Color.green(color),Color.blue(color)));
break;
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL:
+ //case MotionEvent.ACTION_UP:
+ //case MotionEvent.ACTION_CANCEL:
+ default:
// Reset to the original tint color when the button is released
//DrawableCompat.setTintList(originalDrawable, null); // Reset to the original tint
this.getBackground().setAlpha(255);
+ color = getCurrentTextColor();
+ this.setTextColor(Color.argb(255, Color.red(color),Color.green(color),Color.blue(color)));
break;
}
return super.onTouchEvent(event);
diff --git a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
index 2a4d5e4..eb3b031 100644
--- a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
+++ b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
@@ -1,9 +1,14 @@
package com.hfad.cs426_final_project;
+import android.annotation.SuppressLint;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
+import android.util.Log;
+import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
+import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
@@ -12,6 +17,7 @@
import com.hfad.cs426_final_project.CustomUIComponent.MyButton;
import java.util.Locale;
+import java.util.Objects;
public class MainScreenActivity extends AppCompatActivity {
//Number of seconds displayed on the stopwatch.
@@ -20,15 +26,23 @@ public class MainScreenActivity extends AppCompatActivity {
private boolean running;
TextView timeView;
- MyButton startButton;
- ClickableImageView dropdownMenu, timer, stopwatch;
+ MyButton startButton, todoButton, musicButton;
+ ClickableImageView dropdownMenu, timer, stopwatch, todo, music ;
+ LinearLayout todoContainer, musicContainer;
+ @SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
+ getUIReferences();
+ startButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ }
+ });
- dropdownMenu = findViewById(R.id.dropdown_menu);
dropdownMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -36,7 +50,15 @@ public void onClick(View v) {
}
});
- timer = findViewById(R.id.timer);
+ todoContainer.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Log.d("debug","todoContainer");
+ todo.setPressed(true);
+
+ }
+ });
+
timer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -44,27 +66,67 @@ public void onClick(View v) {
}
});
- stopwatch = findViewById(R.id.stopwatch);
+
stopwatch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
- getUIReferences();
- runTimer();
- }
- private void getUIReferences() {
- timeView = findViewById(R.id.time_view);
- startButton = findViewById(R.id.plant_button);
- startButton.setOnClickListener(new View.OnClickListener() {
+ musicContainer.setOnTouchListener(new View.OnTouchListener() {
@Override
- public void onClick(View v) {
+ public boolean onTouch(View v, MotionEvent event) {
+ v.performClick();
+ // Pass the MotionEvent to the MyButton
+
+ return true; // Return true to indicate the touch was handled
+ }
+ });
+
+ musicButton.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ musicButton.onTouchEvent(event);
+ boolean isPressed = false;
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ isPressed = true;
+ }
+ music.setPressed(isPressed);
+ return true;
+ }
+ });
+ todoButton.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ todoButton.onTouchEvent(event);
+ boolean isPressed = false;
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ isPressed = true;
+ }
+ todo.setPressed(isPressed);
+ return true;
}
});
+
+
+ runTimer();
+ }
+
+ private void getUIReferences() {
+ timeView = findViewById(R.id.time_view);
+ startButton = findViewById(R.id.plant_button);
+ dropdownMenu = findViewById(R.id.dropdown_menu);
+ todo = findViewById(R.id.todo_image);
+ todoButton = findViewById(R.id.todo_button);
+ stopwatch = findViewById(R.id.stopwatch);
+ timer = findViewById(R.id.timer);
+ musicContainer = findViewById(R.id.music_container);
+ todoContainer = findViewById(R.id.to_do_container);
+ music=findViewById(R.id.music_image);
+ musicButton=findViewById(R.id.music_button);
}
private void runTimer() {
diff --git a/app/src/main/res/drawable/music.xml b/app/src/main/res/drawable/music.xml
new file mode 100644
index 0000000..866f9d8
--- /dev/null
+++ b/app/src/main/res/drawable/music.xml
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/note.xml b/app/src/main/res/drawable/note.xml
new file mode 100644
index 0000000..3ae1559
--- /dev/null
+++ b/app/src/main/res/drawable/note.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_main_screen.xml b/app/src/main/res/layout/activity_main_screen.xml
index 8deefca..874b5e3 100644
--- a/app/src/main/res/layout/activity_main_screen.xml
+++ b/app/src/main/res/layout/activity_main_screen.xml
@@ -37,6 +37,7 @@
android:background="@drawable/button_border"
android:backgroundTint="@color/primary_20"
android:text="@string/start"
+ style="@style/SubTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
@@ -235,6 +236,61 @@
app:layout_constraintTop_toTopOf="parent" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 13243fd..b39ab86 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -26,7 +26,7 @@
\ No newline at end of file
From f52d3441035d30984a4ad26575fdfcda349c8d7a Mon Sep 17 00:00:00 2001
From: Rito <116003382+vinhnamhai321@users.noreply.github.com>
Date: Fri, 9 Aug 2024 18:33:58 +0700
Subject: [PATCH 2/5] Update toDoButton and musicButton
---
.../MainScreenActivity.java | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
index eb3b031..62ebed5 100644
--- a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
+++ b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
@@ -97,6 +97,19 @@ public boolean onTouch(View v, MotionEvent event) {
}
});
+ music.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ musicButton.onTouchEvent(event);
+ boolean isPressed = false;
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ isPressed = true;
+ }
+ music.setPressed(isPressed);
+ return true;
+ }
+ });
+
todoButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -110,6 +123,19 @@ public boolean onTouch(View v, MotionEvent event) {
}
});
+ todo.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ todoButton.onTouchEvent(event);
+ boolean isPressed = false;
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ isPressed = true;
+ }
+ todo.setPressed(isPressed);
+ return true;
+ }
+ });
+
runTimer();
From 0589533f2035f51f28a8a3b42421c9bf6d307227 Mon Sep 17 00:00:00 2001
From: Rito <116003382+vinhnamhai321@users.noreply.github.com>
Date: Fri, 9 Aug 2024 18:33:58 +0700
Subject: [PATCH 3/5] Update toDoButton and musicButton
---
.idea/other.xml | 44 +++++++++++++++++++
.../MainScreenActivity.java | 26 +++++++++++
2 files changed, 70 insertions(+)
diff --git a/.idea/other.xml b/.idea/other.xml
index 4604c44..1b1a2c5 100644
--- a/.idea/other.xml
+++ b/.idea/other.xml
@@ -69,6 +69,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -146,6 +168,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -235,6 +268,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
index eb3b031..62ebed5 100644
--- a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
+++ b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
@@ -97,6 +97,19 @@ public boolean onTouch(View v, MotionEvent event) {
}
});
+ music.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ musicButton.onTouchEvent(event);
+ boolean isPressed = false;
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ isPressed = true;
+ }
+ music.setPressed(isPressed);
+ return true;
+ }
+ });
+
todoButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -110,6 +123,19 @@ public boolean onTouch(View v, MotionEvent event) {
}
});
+ todo.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ todoButton.onTouchEvent(event);
+ boolean isPressed = false;
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ isPressed = true;
+ }
+ todo.setPressed(isPressed);
+ return true;
+ }
+ });
+
runTimer();
From b209bbd5a56f3699d225e747c4d3f437f3565ed2 Mon Sep 17 00:00:00 2001
From: OHonSam
Date: Mon, 26 Aug 2024 15:21:55 +0700
Subject: [PATCH 4/5] Refactor music, todo effect
---
.idea/deploymentTargetSelector.xml | 8 ++
.../MainScreenActivity.java | 93 ++++++-------------
.../main/res/layout/activity_main_screen.xml | 2 +-
3 files changed, 36 insertions(+), 67 deletions(-)
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
index b268ef3..40e54ee 100644
--- a/.idea/deploymentTargetSelector.xml
+++ b/.idea/deploymentTargetSelector.xml
@@ -4,6 +4,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
index 62ebed5..e455ccd 100644
--- a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
+++ b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
@@ -1,13 +1,11 @@
package com.hfad.cs426_final_project;
import android.annotation.SuppressLint;
-import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -17,7 +15,6 @@
import com.hfad.cs426_final_project.CustomUIComponent.MyButton;
import java.util.Locale;
-import java.util.Objects;
public class MainScreenActivity extends AppCompatActivity {
//Number of seconds displayed on the stopwatch.
@@ -27,7 +24,7 @@ public class MainScreenActivity extends AppCompatActivity {
TextView timeView;
MyButton startButton, todoButton, musicButton;
- ClickableImageView dropdownMenu, timer, stopwatch, todo, music ;
+ ClickableImageView dropdownMenu, timer, stopwatch, todoImage, musicImage;
LinearLayout todoContainer, musicContainer;
@SuppressLint("ClickableViewAccessibility")
@@ -50,14 +47,6 @@ public void onClick(View v) {
}
});
- todoContainer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Log.d("debug","todoContainer");
- todo.setPressed(true);
-
- }
- });
timer.setOnClickListener(new View.OnClickListener() {
@Override
@@ -66,7 +55,6 @@ public void onClick(View v) {
}
});
-
stopwatch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -74,69 +62,42 @@ public void onClick(View v) {
}
});
- musicContainer.setOnTouchListener(new View.OnTouchListener() {
+
+ View.OnTouchListener musicTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- v.performClick();
- // Pass the MotionEvent to the MyButton
+ boolean isPressed = (event.getAction() == MotionEvent.ACTION_DOWN);
- return true; // Return true to indicate the touch was handled
- }
- });
+ // Handle pressed state for musicImage if it's the musicButton or musicImage
+ musicImage.setPressed(isPressed);
+ musicButton.onTouchEvent(event); // Pass the event to musicButton
- musicButton.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- musicButton.onTouchEvent(event);
- boolean isPressed = false;
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- isPressed = true;
- }
- music.setPressed(isPressed);
- return true;
+ return true; // Indicate the touch was handled
}
- });
+ };
- music.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- musicButton.onTouchEvent(event);
- boolean isPressed = false;
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- isPressed = true;
- }
- music.setPressed(isPressed);
- return true;
- }
- });
+ // Set the listener to the views
+ musicContainer.setOnTouchListener(musicTouchListener);
+ musicButton.setOnTouchListener(musicTouchListener);
+ musicImage.setOnTouchListener(musicTouchListener);
- todoButton.setOnTouchListener(new View.OnTouchListener() {
+ View.OnTouchListener todoTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
- todoButton.onTouchEvent(event);
- boolean isPressed = false;
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- isPressed = true;
- }
- todo.setPressed(isPressed);
- return true;
- }
- });
+ boolean isPressed = (event.getAction() == MotionEvent.ACTION_DOWN);
- todo.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- todoButton.onTouchEvent(event);
- boolean isPressed = false;
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- isPressed = true;
- }
- todo.setPressed(isPressed);
- return true;
- }
- });
+ // Handle pressed state for musicImage if it's the musicButton or musicImage
+ todoImage.setPressed(isPressed);
+ todoButton.onTouchEvent(event); // Pass the event to musicButton
+ return true; // Indicate the touch was handled
+ }
+ };
+ // Set the listener to the views
+ todoContainer.setOnTouchListener(todoTouchListener);
+ todoButton.setOnTouchListener(todoTouchListener);
+ todoImage.setOnTouchListener(todoTouchListener);
runTimer();
}
@@ -145,13 +106,13 @@ private void getUIReferences() {
timeView = findViewById(R.id.time_view);
startButton = findViewById(R.id.plant_button);
dropdownMenu = findViewById(R.id.dropdown_menu);
- todo = findViewById(R.id.todo_image);
+ todoImage = findViewById(R.id.todo_image);
todoButton = findViewById(R.id.todo_button);
stopwatch = findViewById(R.id.stopwatch);
timer = findViewById(R.id.timer);
musicContainer = findViewById(R.id.music_container);
todoContainer = findViewById(R.id.to_do_container);
- music=findViewById(R.id.music_image);
+ musicImage =findViewById(R.id.music_image);
musicButton=findViewById(R.id.music_button);
}
diff --git a/app/src/main/res/layout/activity_main_screen.xml b/app/src/main/res/layout/activity_main_screen.xml
index 874b5e3..a4cd038 100644
--- a/app/src/main/res/layout/activity_main_screen.xml
+++ b/app/src/main/res/layout/activity_main_screen.xml
@@ -288,7 +288,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
- android:text="To-do"/>
+ android:text="Music"/>
From b27e581a651d6ac0e0a670b0af6f10a0edb161ee Mon Sep 17 00:00:00 2001
From: OHonSam
Date: Mon, 26 Aug 2024 17:16:34 +0700
Subject: [PATCH 5/5] Add dim effect for Music popup window
---
.../MainScreenActivity.java | 142 ++++++++++--------
.../main/res/layout/popup_music_selection.xml | 20 +++
2 files changed, 97 insertions(+), 65 deletions(-)
create mode 100644 app/src/main/res/layout/popup_music_selection.xml
diff --git a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
index e455ccd..bbbb987 100644
--- a/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
+++ b/app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
@@ -1,68 +1,107 @@
package com.hfad.cs426_final_project;
import android.annotation.SuppressLint;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewGroupOverlay;
import android.widget.LinearLayout;
+import android.widget.PopupWindow;
import android.widget.TextView;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
import com.hfad.cs426_final_project.CustomUIComponent.ClickableImageView;
import com.hfad.cs426_final_project.CustomUIComponent.MyButton;
-import java.util.Locale;
-
public class MainScreenActivity extends AppCompatActivity {
- //Number of seconds displayed on the stopwatch.
- private int seconds = 0;
- //Is the stopwatch running?
- private boolean running;
-
TextView timeView;
MyButton startButton, todoButton, musicButton;
- ClickableImageView dropdownMenu, timer, stopwatch, todoImage, musicImage;
+ ClickableImageView todoImage, musicImage;
LinearLayout todoContainer, musicContainer;
+ ConstraintLayout popupMusicContainer;
+
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
getUIReferences();
- startButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- });
+ setupMusicListener();
+ setupTodoListener();
+ }
- dropdownMenu.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ private void showMusicSelectionPopup() {
+ // Inflate the popup layout
+ View popupView = getLayoutInflater().inflate(R.layout.popup_music_selection, null);
- }
- });
+ // Calculate portion of the screen to show the popup
+ DisplayMetrics displayMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
+ int width = (int) (displayMetrics.widthPixels / 2);
+ int height = (int) (displayMetrics.heightPixels / 2);
+ // Create the PopupWindow
+ PopupWindow popupWindow = new PopupWindow(popupView,
+ width,
+ height,
+ true);
- timer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ // Dim the background for the rest except the popup window
+ applyDim(popupMusicContainer, 0.5f);
+ // Return to the normal background for the rest if the popup window is dismissed
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ clearDim(popupMusicContainer);
}
});
- stopwatch.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ // Show the popup at the center of the container view
+ popupWindow.showAtLocation(musicContainer, Gravity.CENTER, 0, 0);
- }
- });
+ // Selecting music and play it
+ }
+
+ public static void applyDim(@NonNull ViewGroup parent, float dimAmount) {
+ Drawable dim = new ColorDrawable(Color.BLACK);
+ dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
+ dim.setAlpha((int) (255 * dimAmount));
+
+ ViewGroupOverlay overlay = parent.getOverlay();
+ overlay.add(dim);
+ }
+
+ public static void clearDim(@NonNull ViewGroup parent) {
+ ViewGroupOverlay overlay = parent.getOverlay();
+ overlay.clear();
+ }
+ private void getUIReferences() {
+ timeView = findViewById(R.id.time_view);
+ startButton = findViewById(R.id.plant_button);
+ todoImage = findViewById(R.id.todo_image);
+ todoButton = findViewById(R.id.todo_button);
+ todoContainer = findViewById(R.id.to_do_container);
+ musicContainer = findViewById(R.id.music_container);
+ musicImage =findViewById(R.id.music_image);
+ musicButton=findViewById(R.id.music_button);
+ popupMusicContainer = findViewById(R.id.main);
+ }
+ @SuppressLint("ClickableViewAccessibility")
+ private void setupMusicListener() {
View.OnTouchListener musicTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -76,11 +115,21 @@ public boolean onTouch(View v, MotionEvent event) {
}
};
+ View.OnClickListener musicClickListener = v -> showMusicSelectionPopup();
+
// Set the listener to the views
musicContainer.setOnTouchListener(musicTouchListener);
musicButton.setOnTouchListener(musicTouchListener);
musicImage.setOnTouchListener(musicTouchListener);
+ // Set the click listener to open the music selection popup
+ musicContainer.setOnClickListener(musicClickListener);
+ musicButton.setOnClickListener(musicClickListener);
+ musicImage.setOnClickListener(musicClickListener);
+ }
+
+ @SuppressLint("ClickableViewAccessibility")
+ private void setupTodoListener() {
View.OnTouchListener todoTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -98,43 +147,6 @@ public boolean onTouch(View v, MotionEvent event) {
todoContainer.setOnTouchListener(todoTouchListener);
todoButton.setOnTouchListener(todoTouchListener);
todoImage.setOnTouchListener(todoTouchListener);
-
- runTimer();
}
- private void getUIReferences() {
- timeView = findViewById(R.id.time_view);
- startButton = findViewById(R.id.plant_button);
- dropdownMenu = findViewById(R.id.dropdown_menu);
- todoImage = findViewById(R.id.todo_image);
- todoButton = findViewById(R.id.todo_button);
- stopwatch = findViewById(R.id.stopwatch);
- timer = findViewById(R.id.timer);
- musicContainer = findViewById(R.id.music_container);
- todoContainer = findViewById(R.id.to_do_container);
- musicImage =findViewById(R.id.music_image);
- musicButton=findViewById(R.id.music_button);
- }
-
- private void runTimer() {
- final Handler handler = new Handler();
- handler.post(new Runnable() {
- @Override
- public void run() {
- int hours = seconds/3600;
- int minutes = (seconds%3600)/60;
- int secs = seconds%60;
- String time = String.format(Locale.getDefault(),
- "%d:%02d:%02d", hours, minutes, secs);
- timeView.setText(time);
- if (running) {
- seconds++;
- }
- // 1 second = 1000 milliseconds
- handler.postDelayed(this, 1000);
- }
- });
- }
-
-
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/popup_music_selection.xml b/app/src/main/res/layout/popup_music_selection.xml
new file mode 100644
index 0000000..e31d253
--- /dev/null
+++ b/app/src/main/res/layout/popup_music_selection.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file