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/.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/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..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,91 +1,152 @@
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.DisplayMetrics;
+import android.view.Gravity;
+import android.view.MotionEvent;
import android.view.View;
-import android.widget.Button;
+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;
- ClickableImageView dropdownMenu, timer, stopwatch;
+ MyButton startButton, todoButton, musicButton;
+ 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();
- dropdownMenu = findViewById(R.id.dropdown_menu);
- dropdownMenu.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ setupMusicListener();
+ setupTodoListener();
+ }
- }
- });
+ private void showMusicSelectionPopup() {
+ // Inflate the popup layout
+ View popupView = getLayoutInflater().inflate(R.layout.popup_music_selection, null);
- timer = findViewById(R.id.timer);
- timer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ // 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);
- stopwatch = findViewById(R.id.stopwatch);
- stopwatch.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);
}
});
- getUIReferences();
- runTimer();
+
+ // 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);
- startButton.setOnClickListener(new View.OnClickListener() {
+ 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 void onClick(View v) {
+ public boolean onTouch(View v, MotionEvent event) {
+ boolean isPressed = (event.getAction() == MotionEvent.ACTION_DOWN);
+
+ // Handle pressed state for musicImage if it's the musicButton or musicImage
+ musicImage.setPressed(isPressed);
+ musicButton.onTouchEvent(event); // Pass the event to musicButton
+ return true; // Indicate the touch was handled
}
- });
+ };
+
+ 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);
}
- private void runTimer() {
- final Handler handler = new Handler();
- handler.post(new Runnable() {
+ @SuppressLint("ClickableViewAccessibility")
+ private void setupTodoListener() {
+ View.OnTouchListener todoTouchListener = new View.OnTouchListener() {
@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);
+ public boolean onTouch(View v, MotionEvent event) {
+ boolean isPressed = (event.getAction() == MotionEvent.ACTION_DOWN);
+
+ // 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);
+ }
}
\ No newline at end of file
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..a4cd038 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/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
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