Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
159 changes: 110 additions & 49 deletions app/src/main/java/com/hfad/cs426_final_project/MainScreenActivity.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/music.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M3,17C3,17.796 3.316,18.559 3.879,19.121C4.441,19.684 5.204,20 6,20C6.796,20 7.559,19.684 8.121,19.121C8.684,18.559 9,17.796 9,17C9,16.204 8.684,15.441 8.121,14.879C7.559,14.316 6.796,14 6,14C5.204,14 4.441,14.316 3.879,14.879C3.316,15.441 3,16.204 3,17ZM13,17C13,17.796 13.316,18.559 13.879,19.121C14.441,19.684 15.204,20 16,20C16.796,20 17.559,19.684 18.121,19.121C18.684,18.559 19,17.796 19,17C19,16.204 18.684,15.441 18.121,14.879C17.559,14.316 16.796,14 16,14C15.204,14 14.441,14.316 13.879,14.879C13.316,15.441 13,16.204 13,17Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M9,17V4H19V17M9,8H19"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/note.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M23.719,4.121L19.879,0.281C19.79,0.192 19.684,0.121 19.567,0.073C19.451,0.025 19.326,0 19.2,0C19.074,0 18.949,0.025 18.833,0.073C18.716,0.121 18.61,0.192 18.521,0.281L7.001,11.801C6.821,11.981 6.72,12.225 6.72,12.48V16.32C6.72,16.575 6.821,16.819 7.001,16.999C7.181,17.179 7.425,17.28 7.68,17.28H11.52C11.775,17.28 12.019,17.179 12.199,16.999L23.719,5.479C23.899,5.299 24,5.055 24,4.8C24,4.545 23.899,4.301 23.719,4.121ZM11.122,15.36H8.64V12.878L16.32,5.198L18.802,7.68L11.122,15.36ZM20.16,6.322L17.678,3.84L19.2,2.318L21.682,4.8L20.16,6.322ZM23.04,11.52V22.08C23.039,22.589 22.837,23.077 22.477,23.437C22.117,23.797 21.629,23.999 21.12,24H1.92C1.411,23.999 0.923,23.797 0.563,23.437C0.203,23.077 0.001,22.589 0,22.08V2.88C0.001,2.371 0.203,1.883 0.563,1.523C0.923,1.163 1.411,0.961 1.92,0.96H12.48C12.735,0.96 12.979,1.061 13.159,1.241C13.339,1.421 13.44,1.665 13.44,1.92C13.44,2.175 13.339,2.419 13.159,2.599C12.979,2.779 12.735,2.88 12.48,2.88H1.92V22.08H21.12V11.52C21.12,11.265 21.221,11.021 21.401,10.841C21.581,10.661 21.825,10.56 22.08,10.56C22.335,10.56 22.579,10.661 22.759,10.841C22.939,11.021 23.04,11.265 23.04,11.52Z"
android:fillColor="#000000"/>
</vector>
Loading