Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
04e89ba
splash screen
adityapratap2005 Oct 10, 2024
725910d
Update AndroidManifest.xml
adityapratap2005 Oct 10, 2024
548d89f
splash screen added
adityapratap2005 Oct 10, 2024
de26727
Splash screen added and changed ui
adityapratap2005 Oct 11, 2024
23f6af8
changed color scheme added a menu for chanaging theme and fixed the t…
adityapratap2005 Oct 11, 2024
d26312a
changed color scheme, added a menu to change theme, fixed the timer
adityapratap2005 Oct 11, 2024
88ab300
changed color scheme, added a menu to change theme, fixed the timer
adityapratap2005 Oct 11, 2024
c2a8b47
Merge pull request #6 from Crisonel/main
mukul-dev Oct 11, 2024
3c14391
fixed the timer and updated ui
adityapratap2005 Oct 11, 2024
ba89b5c
fixed the timer and updated ui
adityapratap2005 Oct 11, 2024
18296a5
Merge pull request #7 from Crisonel/main
mukul-dev Oct 11, 2024
70b2121
fixed issue #4
RITIK-CHAUDHRY Oct 17, 2024
6ffa3b7
improved fixes issue #8 #4
RITIK-CHAUDHRY Oct 18, 2024
be03222
Implement the 2 Priority Tasks for the Day
RITIK-CHAUDHRY Oct 20, 2024
cdad835
Update Fragment2PriorityTaskRule.java
RITIK-CHAUDHRY Oct 21, 2024
22f927c
Implement the Calendar Tracker Feature
RITIK-CHAUDHRY Oct 23, 2024
a410712
done changes that are mentioned
RITIK-CHAUDHRY Oct 25, 2024
5df9eff
implementing the 2 priority task rule for the day
RITIK-CHAUDHRY Oct 26, 2024
57ff998
Merge pull request #9 from RITIK-CHAUDHRY/Implement-the-Calendar-Trac…
mukul-dev Oct 26, 2024
6fcfb5b
improved Implement the 2 Priority Tasks for the Day
RITIK-CHAUDHRY Oct 29, 2024
08166d3
Merge branch 'main' into main
mukul-dev Oct 31, 2024
982eba7
Merge pull request #8 from RITIK-CHAUDHRY/main
mukul-dev Oct 31, 2024
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
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

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.

10 changes: 2 additions & 8 deletions .idea/gradle.xml

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

8 changes: 1 addition & 7 deletions .idea/misc.xml

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

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

This file was deleted.

17 changes: 17 additions & 0 deletions .idea/runConfigurations.xml

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

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {

defaultConfig {
applicationId = "com.mukudev.easy2do"
minSdk = 24
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/easytodologo"
android:supportsRtl="true"
android:theme="@style/Theme.Easy2Do"
android:theme="@style/Base.Theme.Easy2Do"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
</application>

</manifest>
</manifest>
173 changes: 162 additions & 11 deletions app/src/main/java/com/mukudev/easy2do/Fragments/Fragment2DayRule.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,191 @@

package com.mukudev.easy2do.Fragments;

import android.os.Bundle;
import android.content.Context;
import android.content.SharedPreferences;
import android.widget.Button;
import java.util.Set;
import java.util.HashSet;
import java.util.Calendar;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CalendarView;
import android.widget.Toast;
import android.widget.TextView;

import com.mukudev.easy2do.R;

public class Fragment2DayRule extends Fragment {
private Button markDoneButton;
private Set<String> markedDays;
private SharedPreferences sharedPreferences;
private CalendarView calendarView;
private TextView streakTextView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_2day_rule, container, false);

// Initialize the CalendarView
CalendarView calendarView = view.findViewById(R.id.calendarView);
calendarView = view.findViewById(R.id.calendarView);
markDoneButton = view.findViewById(R.id.markDoneButton);
streakTextView = view.findViewById(R.id.streakTextView);

// Set OnDateChangeListener to capture date changes
calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
sharedPreferences = requireContext().getSharedPreferences("HabitTracker", Context.MODE_PRIVATE);
markedDays = new HashSet<>(sharedPreferences.getStringSet("markedDays", new HashSet<>()));

String selectedDate = dayOfMonth + "/" + (month + 1) + "/" + year;
setupCalendarView();
setupMarkDoneButton();
updateStreak();

return view;
}

// Add functionality to save the mark date and it should be asserted because it cannot change after its marked
Toast.makeText(getContext(), "Selected Date: " + selectedDate, Toast.LENGTH_SHORT).show();
private void setupCalendarView() {
Calendar today = Calendar.getInstance();
calendarView.setMaxDate(today.getTimeInMillis());

calendarView.setOnDateChangeListener((view, year, month, dayOfMonth) -> {
Calendar selectedDate = Calendar.getInstance();
selectedDate.set(year, month, dayOfMonth);
Calendar currentDate = Calendar.getInstance();

if (selectedDate.before(currentDate)) {
showPastDatePopup();
} else if (selectedDate.after(currentDate)) {
Toast.makeText(getContext(), "You cannot select future dates", Toast.LENGTH_SHORT).show();
} else {
updateMarkDoneButtonState(selectedDate);
if (!isCurrentDateMarked()) {
showMarkAsDoneConfirmation();
} else {
Toast.makeText(getContext(), "This day is already marked as done!", Toast.LENGTH_SHORT).show();
}
}
});

return view;
calendarView.setDate(today.getTimeInMillis(), false, true);
highlightDates();
}

private void setupMarkDoneButton() {
markDoneButton.setOnClickListener(v -> showMarkAsDoneConfirmation());
updateMarkDoneButtonState(Calendar.getInstance());
}

private void showPastDatePopup() {
new AlertDialog.Builder(requireContext())
.setTitle("Past Date")
.setMessage("You cannot select previous dates.")
.setPositiveButton("OK", null)
.show();
}

private void showMarkAsDoneConfirmation() {
new AlertDialog.Builder(requireContext())
.setTitle("Mark as Done")
.setMessage("Are you sure you want to mark this day as done? This action cannot be undone.")
.setPositiveButton("Yes", (dialog, which) -> markTodayAsDone())
.setNegativeButton("No", null)
.show();
}

private void markTodayAsDone() {
Calendar calendar = Calendar.getInstance();
String currentDate = formatDate(calendar);

if (!markedDays.contains(currentDate)) {
markedDays.add(currentDate);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putStringSet("markedDays", markedDays);
editor.apply();

Toast.makeText(getContext(), "Marked as done!", Toast.LENGTH_SHORT).show();
}
updateMarkDoneButtonState(calendar);
updateStreak();
highlightDates();
}

private void updateMarkDoneButtonState(Calendar selectedDate) {
boolean isToday = isToday(selectedDate);
String currentDate = formatDate(selectedDate);
markDoneButton.setEnabled(isToday && !markedDays.contains(currentDate));
}

private String formatDate(Calendar calendar) {
return calendar.get(Calendar.DAY_OF_MONTH) + "/" +
(calendar.get(Calendar.MONTH) + 1) + "/" +
calendar.get(Calendar.YEAR);
}

private boolean isToday(Calendar date) {
Calendar today = Calendar.getInstance();
return date.get(Calendar.YEAR) == today.get(Calendar.YEAR) &&
date.get(Calendar.MONTH) == today.get(Calendar.MONTH) &&
date.get(Calendar.DAY_OF_MONTH) == today.get(Calendar.DAY_OF_MONTH);
}

private boolean isCurrentDateMarked() {
Calendar calendar = Calendar.getInstance();
String currentDate = formatDate(calendar);
return markedDays.contains(currentDate);
}

private void updateStreak() {
int streak = calculateStreak();
streakTextView.setText("Current Streak: " + streak + " days");
}

private int calculateStreak() {
Calendar today = Calendar.getInstance();
int streak = 0;

while (markedDays.contains(formatDate(today))) {
streak++;
today.add(Calendar.DAY_OF_MONTH, -1);
}

return streak;
}

private View getDayViewByDate(long dateInMillis) {
// Implement the logic to get the day view by date
// This is a placeholder implementation and may need to be adjusted based on your CalendarView implementation
return calendarView.findViewWithTag(dateInMillis);
}

private void highlightDates() {
for (String date : markedDays) {
// Logic to highlight the marked dates
String[] parts = date.split("/");
int day = Integer.parseInt(parts[0]);
int month = Integer.parseInt(parts[1]) - 1; // Calendar months are 0-based
int year = Integer.parseInt(parts[2]);

Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);

long dateInMillis = calendar.getTimeInMillis();
calendarView.setDate(dateInMillis, false, true);

// Assuming you have a method to get the day view by date
View dayView = getDayViewByDate(dateInMillis);
if (dayView != null) {
dayView.setBackgroundResource(R.drawable.dark_red_circle);
}
}
}

@Override
public void onResume() {
super.onResume();
setupCalendarView();
updateMarkDoneButtonState(Calendar.getInstance());
updateStreak();
}
}
Loading