Skip to content

Commit

Permalink
Merge pull request #6 from Crisonel/main
Browse files Browse the repository at this point in the history
splash screen added and ui updated and timer bug fixed
  • Loading branch information
mukul-dev authored Oct 11, 2024
2 parents 8deb101 + 88ab300 commit c2a8b47
Show file tree
Hide file tree
Showing 40 changed files with 313 additions and 404 deletions.
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.

2 changes: 1 addition & 1 deletion .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.

7 changes: 0 additions & 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.

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

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

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>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import androidx.fragment.app.Fragment;

import android.os.CountDownTimer;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -16,6 +17,8 @@
public class Fragment2MinTaskRule extends Fragment {
private TextView timerTextView;
private Button startTimerButton;

private boolean isClicked = false;
private CountDownTimer countDownTimer;

@Override
Expand All @@ -27,8 +30,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

startTimerButton.setOnClickListener(new View.OnClickListener() {
@Override
//animation for button click
public void onClick(View v) {
startTimer();
startTimerButton.setScaleX(0.9f);
startTimerButton.setScaleY(0.9f);

// Restore the button size after a short delay
startTimerButton.postDelayed(new Runnable() {
@Override
public void run() {
startTimerButton.setScaleX(1f);
startTimerButton.setScaleY(1f);
}
}, 100);//animation for button click
if(!isClicked) startTimer();
}
});

Expand All @@ -37,10 +52,12 @@ public void onClick(View v) {

private void startTimer() {
// Reset the timer text to 2 minutes
isClicked = true;
timerTextView.setText("02:00");
timerTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,64);

// Create a CountDownTimer for 2 minutes (120000 milliseconds)
countDownTimer = new CountDownTimer(10000, 1000) {
countDownTimer = new CountDownTimer(120000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// Update the timer text every second
Expand All @@ -53,8 +70,10 @@ public void onTick(long millisUntilFinished) {
public void onFinish() {
// Timer finished, play sound
timerTextView.setText("Time's up!");
timerTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,24);
playSound();
startTimerButton.setText("Restart!");
isClicked = false;
}
}.start();
}
Expand Down
22 changes: 21 additions & 1 deletion app/src/main/java/com/mukudev/easy2do/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;


import android.os.Bundle;
import android.view.Menu;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.mukudev.easy2do.Fragments.Fragment2DayRule;
Expand All @@ -13,48 +17,64 @@

public class MainActivity extends AppCompatActivity {



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
Toolbar toolbar = findViewById(R.id.toolBar);//object of ToolBar
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, new Fragment2DayRule())
.commit();

toolbar.setTitle("Building Habits Can be Tough");//changing according to fragment

bottomNavigationView.setSelectedItemId(R.id.nav_2day_rule);

}


// Set the BottomNavigationView listener
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
bottomNavigationView.setOnItemSelectedListener(new BottomNavigationView.OnItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull android.view.MenuItem item) {
Fragment selectedFragment = null;

if (item.getItemId() == R.id.nav_2min_task_rule) {
selectedFragment = new Fragment2MinTaskRule();
toolbar.setTitle("Get Things Done Faster!");//changing according to fragment

}
else if (item.getItemId() == R.id.nav_2day_rule) {
selectedFragment = new Fragment2DayRule();
toolbar.setTitle("Building Habits Can be Tough");//changing according to fragment

}
else{
selectedFragment = new Fragment2PriorityTaskRule();
toolbar.setTitle("Priority Tasks for Today");//changing according to fragment

}

// Replace the fragment
//added transition for fragment change
getSupportFragmentManager().beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.replace(R.id.fragment_container, selectedFragment)
.commit();

return true;
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar, menu);
return true;
}
}
23 changes: 23 additions & 0 deletions app/src/main/java/com/mukudev/easy2do/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mukudev.easy2do;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
private static final int SPLASH_SCREEN_DELAY = 2000; // 2 seconds

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);

//Handler to control the time of splash screen and move to main activity
new Handler().postDelayed(() -> {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish(); // Close the SplashActivity so the user can't go back to it
}, SPLASH_SCREEN_DELAY);
}
}
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_moon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="@android:color/white"
android:pathData="M10,2c-1.82,0 -3.53,0.5 -5,1.35C7.99,5.08 10,8.3 10,12s-2.01,6.92 -5,8.65C6.47,21.5 8.18,22 10,22c5.52,0 10,-4.48 10,-10S15.52,2 10,2z"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_sun.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="@android:color/white"
android:pathData="M20,8.69L20,4h-4.69L12,0.69 8.69,4L4,4v4.69L0.69,12 4,15.31L4,20h4.69L12,23.31 15.31,20L20,20v-4.69L23.31,12 20,8.69zM12,18c-3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6 6,2.69 6,6 -2.69,6 -6,6zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4z"/>
</vector>
Binary file added app/src/main/res/drawable-hdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke android:width="0dp"/>

<solid android:color="?attr/colorPrimaryVariant"/>

<size android:height="100dp"
android:width="100dp"/>


</shape>
Binary file added app/src/main/res/drawable/easytodologo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/rectangle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="25dp"/>

<stroke android:width="0dp" />

<solid android:color="?attr/colorPrimaryVariant"/>

</shape>
1 change: 0 additions & 1 deletion app/src/main/res/drawable/selector.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="@color/white" />
<item android:color="@color/gray" />
</selector>
10 changes: 10 additions & 0 deletions app/src/main/res/font/font.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font android:fontStyle="normal"
android:fontWeight="900"
android:font="@font/roboto_bold"/>

<font android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/roboto_regular" />
</font-family>
Binary file added app/src/main/res/font/roboto_bold.ttf
Binary file not shown.
Binary file added app/src/main/res/font/roboto_regular.ttf
Binary file not shown.
46 changes: 32 additions & 14 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/fragment_container"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="match_parent"
android:orientation="vertical">

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_navigation" />

<androidx.appcompat.widget.Toolbar
app:menu="@menu/toolbar"
android:id="@+id/toolBar"
app:title=""
app:titleTextColor="?attr/colorOnSecondary"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="?attr/colorSecondary"
android:gravity="left"
android:layout_marginLeft="0dp">


</androidx.appcompat.widget.Toolbar>

<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

<com.google.android.material.bottomnavigation.BottomNavigationView
android:background="?attr/colorSecondary"
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_navigation" />
</LinearLayout>
Loading

0 comments on commit c2a8b47

Please sign in to comment.