init
35
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.HabitTracker"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name="View.AddHabit"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="View.CreateAccountActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="View.HomeActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="View.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
135
app/src/main/java/Database/DatabaseHelper.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package Database;
|
||||
|
||||
import static android.util.Log.println;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Model.Habit;
|
||||
import Model.User;
|
||||
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
|
||||
public static final String USER_TABLE = "USER_TABLE";
|
||||
public static final String HABIT_TABLE = "HABIT_TABLE";
|
||||
public static final String COLUMN_USER_ID = "USER_ID";
|
||||
public static final String COLUMN_USERNAME = "USERNAME";
|
||||
public static final String COLUMN_PASSWORD = "PASSWORD";
|
||||
public static final String COLUMN_HABIT_ID = "HABIT_ID";
|
||||
public static final String COLUMN_HABIT_NAME = "HABIT_NAME";
|
||||
public static final String COLUMN_HABIT_TIME = "TIME";
|
||||
|
||||
public DatabaseHelper(@Nullable Context context) {
|
||||
super(context, "HabitTracker.db", null, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||
String createUserTable = "CREATE TABLE " + USER_TABLE + " " +
|
||||
"(" + COLUMN_USER_ID + " TEXT PRIMARY KEY, " + COLUMN_USERNAME + " TEXT, " + COLUMN_PASSWORD + " TEXT)";
|
||||
|
||||
String createHabitTable = "CREATE TABLE " + HABIT_TABLE + " " +
|
||||
"(" + COLUMN_HABIT_ID + " TEXT PRIMARY KEY, " +
|
||||
COLUMN_USER_ID + " TEXT, " +
|
||||
COLUMN_HABIT_NAME + " TEXT, " +
|
||||
COLUMN_HABIT_TIME + " TEXT, " +
|
||||
"FOREIGN KEY(" + COLUMN_USER_ID + ") REFERENCES " + USER_TABLE + "(" + COLUMN_USER_ID + "))";
|
||||
|
||||
|
||||
sqLiteDatabase.execSQL(createUserTable);
|
||||
sqLiteDatabase.execSQL(createHabitTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
|
||||
if(oldVersion < 2) {
|
||||
String addHabitColumn = "ALTER TABLE " + HABIT_TABLE + " ADD COLUMN " + COLUMN_HABIT_TIME + " TEXT";
|
||||
sqLiteDatabase.execSQL(addHabitColumn);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean createAccount(User user) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues cv = new ContentValues();
|
||||
|
||||
cv.put(COLUMN_USER_ID, user.getUserId());
|
||||
cv.put(COLUMN_USERNAME, user.getUsername());
|
||||
cv.put(COLUMN_PASSWORD, user.getPassword());
|
||||
|
||||
long insert = db.insert(USER_TABLE, null, cv);
|
||||
return insert != -1;
|
||||
}
|
||||
|
||||
public User login(String username, String password) {
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
User user = new User();
|
||||
String query = "SELECT * FROM " + USER_TABLE + " WHERE " + COLUMN_USERNAME + " = ? AND " + COLUMN_PASSWORD + " = ?";
|
||||
String[] selectionArgs = {username, password};
|
||||
try (Cursor cursor = db.rawQuery(query, selectionArgs)) {
|
||||
|
||||
println(Log.DEBUG, "username provided: ", username);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
String userId = cursor.getString(0);
|
||||
user.setUserId(userId);
|
||||
user.setUsername(username);
|
||||
user.setPassword(password);
|
||||
|
||||
return user;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean createHabit(Habit habit) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues cv = new ContentValues();
|
||||
|
||||
cv.put(COLUMN_HABIT_ID, habit.getHabitId());
|
||||
cv.put(COLUMN_USER_ID, habit.getUserId());
|
||||
cv.put(COLUMN_HABIT_NAME, habit.getHabitName());
|
||||
cv.put(COLUMN_HABIT_TIME, habit.getTime());
|
||||
|
||||
long insert = db.insert(HABIT_TABLE, null, cv);
|
||||
return insert != -1;
|
||||
}
|
||||
|
||||
public ArrayList<Habit> getAllHabits(String userId) {
|
||||
ArrayList<Habit> habitList = new ArrayList<>();
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
|
||||
// Define the query
|
||||
String query = "SELECT * FROM " + HABIT_TABLE + " WHERE " + COLUMN_USER_ID + " = ?";
|
||||
String[] selectionArgs = {userId};
|
||||
Cursor cursor = db.rawQuery(query, selectionArgs);
|
||||
|
||||
// Loop through the cursor and populate the list
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
String habitName = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_HABIT_NAME));
|
||||
String time = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_HABIT_TIME));
|
||||
|
||||
// Create a new Habit object and add it to the list
|
||||
Habit habit = new Habit(habitName, time);
|
||||
habitList.add(habit);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
||||
// Close the cursor and database
|
||||
cursor.close();
|
||||
db.close();
|
||||
|
||||
return habitList;
|
||||
}
|
||||
|
||||
}
|
||||
49
app/src/main/java/Model/Habit.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package Model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Habit {
|
||||
private String habitId;
|
||||
private String userId;
|
||||
private String habitName;
|
||||
private String time;
|
||||
|
||||
public Habit(String userId, String habitName, String time) {
|
||||
this.habitId = UUID.randomUUID().toString();
|
||||
this.userId = userId;
|
||||
this.habitName = habitName;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
//second constructor for fetching habits
|
||||
public Habit(String name, String time) {
|
||||
this.habitName = name;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public void setHabitName(String habitName) {
|
||||
this.habitName = habitName;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getHabitId() {
|
||||
return habitId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getHabitName() {
|
||||
return habitName;
|
||||
}
|
||||
|
||||
public String getTime() { return time; }
|
||||
}
|
||||
41
app/src/main/java/Model/User.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package Model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class User {
|
||||
private String userId;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public User(String username, String password) {
|
||||
this.userId = UUID.randomUUID().toString();
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
//No parameter constructor
|
||||
public User() { };
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {this.userId = userId; }
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
}
|
||||
89
app/src/main/java/View/AddHabit.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package View;
|
||||
|
||||
import static android.app.PendingIntent.getActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.habittracker.R;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import Database.DatabaseHelper;
|
||||
import Model.Habit;
|
||||
|
||||
public class AddHabit extends AppCompatActivity {
|
||||
Button timePicker;
|
||||
TextView selectedTimeTv;
|
||||
EditText newHabitEt;
|
||||
String selectedTime;
|
||||
DatabaseHelper db;
|
||||
Button addHabitBtn;
|
||||
Button backBtn;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_add_habit);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
timePicker = findViewById(R.id.time_picker);
|
||||
addHabitBtn = findViewById(R.id.add_new_habit_btn);
|
||||
backBtn = findViewById(R.id.back_btn);
|
||||
selectedTimeTv = findViewById(R.id.selected_time_tv);
|
||||
newHabitEt = findViewById(R.id.new_habit_et);
|
||||
db = new DatabaseHelper(AddHabit.this);
|
||||
|
||||
timePicker.setOnClickListener(v -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
|
||||
// Show TimePickerDialog
|
||||
@SuppressLint("DefaultLocale") TimePickerDialog timePickerDialog = new TimePickerDialog(
|
||||
AddHabit.this,
|
||||
(view, hourOfDay, minuteOfHour) -> {
|
||||
// Update the TextView with the selected time
|
||||
selectedTime = String.format("%02d:%02d", hourOfDay, minuteOfHour);
|
||||
selectedTimeTv.setText(selectedTime);
|
||||
},
|
||||
hour,
|
||||
minute,
|
||||
true // Set to true for 24-hour format, false for AM/PM
|
||||
);
|
||||
timePickerDialog.show();
|
||||
});
|
||||
|
||||
addHabitBtn.setOnClickListener(v -> {
|
||||
boolean result = db.createHabit(new Habit(HomeActivity.userId, newHabitEt.getText().toString(), selectedTime));
|
||||
if(result) {
|
||||
Toast.makeText(this, "Habit added successfully", Toast.LENGTH_SHORT).show();
|
||||
}else {
|
||||
Toast.makeText(this, "Error adding habit", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
backBtn.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
85
app/src/main/java/View/CreateAccountActivity.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package View;
|
||||
|
||||
import static android.util.Log.println;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.habittracker.R;
|
||||
|
||||
import Database.DatabaseHelper;
|
||||
import Model.User;
|
||||
|
||||
public class CreateAccountActivity extends AppCompatActivity {
|
||||
|
||||
EditText usernameEt;
|
||||
EditText passwordEt;
|
||||
Button createAccountBtn;
|
||||
Button backBtn;
|
||||
DatabaseHelper db;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_create_account);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
usernameEt = findViewById(R.id.username_et);
|
||||
passwordEt = findViewById(R.id.password_et);
|
||||
createAccountBtn = findViewById(R.id.create_account_btn);
|
||||
backBtn = findViewById(R.id.back_btn);
|
||||
db = new DatabaseHelper(CreateAccountActivity.this);
|
||||
|
||||
createAccountBtn.setOnClickListener(v -> {
|
||||
//Test
|
||||
println(Log.DEBUG, "username: ", usernameEt.getText().toString());
|
||||
println(Log.DEBUG, "password: ", passwordEt.getText().toString());
|
||||
|
||||
//User creation
|
||||
if(formValidate()) {
|
||||
//Logic to create the user and store in the DB
|
||||
User user = new User(usernameEt.getText().toString(), passwordEt.getText().toString());
|
||||
|
||||
try {
|
||||
boolean result = db.createAccount(user);
|
||||
Toast.makeText(this, "Account creation successful = " + result, Toast.LENGTH_SHORT).show();
|
||||
|
||||
}catch (Exception e) {
|
||||
Toast.makeText(this, "Error creating account", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
backBtn.setOnClickListener(v -> {
|
||||
//Go back to login
|
||||
finish();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Method for form validation
|
||||
private boolean formValidate() {
|
||||
|
||||
if (usernameEt.getText().toString().isEmpty()|| passwordEt.getText().toString().isEmpty()) {
|
||||
Toast.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
119
app/src/main/java/View/HomeActivity.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package View;
|
||||
|
||||
import static android.util.Log.println;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.habittracker.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import Database.DatabaseHelper;
|
||||
import Model.Habit;
|
||||
|
||||
public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
String username;
|
||||
String password;
|
||||
public static String userId;
|
||||
TextView user_greeting_tv;
|
||||
Button addHabitButton;
|
||||
DatabaseHelper db;
|
||||
List<Habit> habitList;
|
||||
LinearLayout parentLayout;
|
||||
ImageButton refreshBtn;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_home);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
|
||||
user_greeting_tv = findViewById(R.id.user_greating_tv);
|
||||
addHabitButton = findViewById(R.id.add_habit);
|
||||
refreshBtn = findViewById(R.id.refresh_btn);
|
||||
userId = getIntent().getStringExtra("UserId");
|
||||
username = getIntent().getStringExtra("Username");
|
||||
password = getIntent().getStringExtra("Password");
|
||||
db = new DatabaseHelper(HomeActivity.this);
|
||||
habitList = db.getAllHabits(userId);
|
||||
parentLayout = findViewById(R.id.habits_list);
|
||||
|
||||
user_greeting_tv.setText(String.format("Hello, %s", username));
|
||||
|
||||
addHabitButton.setOnClickListener(v -> {
|
||||
startActivity(new Intent(this, AddHabit.class));
|
||||
|
||||
});
|
||||
|
||||
refreshBtn.setOnClickListener(v -> {
|
||||
habitList = db.getAllHabits(userId);
|
||||
parentLayout.removeAllViews();
|
||||
displayHabits();
|
||||
});
|
||||
|
||||
displayHabits();
|
||||
|
||||
}
|
||||
|
||||
private void displayHabits() {
|
||||
for (Habit habit : habitList) {
|
||||
println(Log.DEBUG, "Habit: ", habit.getHabitName());
|
||||
LinearLayout linearLayout = getLinearLayout(habit);
|
||||
parentLayout.addView(linearLayout);
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull LinearLayout getLinearLayout(Habit habit) {
|
||||
LinearLayout linearLayout = new LinearLayout(this);
|
||||
// Create LayoutParams with MATCH_PARENT for width and WRAP_CONTENT for height
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
linearLayout.setLayoutParams(params);
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
linearLayout.setPadding(25, 25, 25, 25);
|
||||
|
||||
CheckBox checkBox = new CheckBox(this);
|
||||
checkBox.setPadding(40, 40, 40, 40);
|
||||
|
||||
TextView habitTime = new TextView(this);
|
||||
habitTime.setPadding(40, 40, 40, 40);
|
||||
habitTime.setTextSize(20);
|
||||
habitTime.setText(habit.getTime());
|
||||
habitTime.setTextColor(Color.parseColor("#e2e2e2"));
|
||||
|
||||
TextView habitName = new TextView(this);
|
||||
habitName.setPadding(40, 40, 40, 40);
|
||||
habitName.setTextSize(20);
|
||||
habitName.setText(habit.getHabitName());
|
||||
habitName.setTextColor(Color.parseColor("#e2e2e2"));
|
||||
|
||||
linearLayout.addView(checkBox);
|
||||
linearLayout.addView(habitTime);
|
||||
linearLayout.addView(habitName);
|
||||
return linearLayout;
|
||||
}
|
||||
}
|
||||
76
app/src/main/java/View/MainActivity.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package View;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.habittracker.R;
|
||||
|
||||
import Database.DatabaseHelper;
|
||||
import Model.User;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
Button loginBtn;
|
||||
EditText usernameEt;
|
||||
EditText passwordEt;
|
||||
TextView createAccountTv;
|
||||
DatabaseHelper db;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_main);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
loginBtn = findViewById(R.id.login_btn);
|
||||
usernameEt = findViewById(R.id.username_et);
|
||||
passwordEt = findViewById(R.id.password_et);
|
||||
createAccountTv = findViewById(R.id.create_account_tv);
|
||||
db = new DatabaseHelper(MainActivity.this);
|
||||
|
||||
//Opens create Account activity
|
||||
createAccountTv.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(this, CreateAccountActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
|
||||
loginBtn.setOnClickListener(v -> {
|
||||
if (usernameEt.getText().toString().isEmpty() || passwordEt.getText().toString().isEmpty()) {
|
||||
Toast.makeText(this, "Please enter the credentials", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
User user = login();
|
||||
if(user != null) {
|
||||
Toast.makeText(this, "Authentication Success!", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(this, HomeActivity.class);
|
||||
intent.putExtra("UserId", user.getUserId());
|
||||
intent.putExtra("Username", user.getUsername());
|
||||
intent.putExtra("Password", user.getPassword());
|
||||
startActivity(intent);
|
||||
}else {
|
||||
Toast.makeText(this, "Authentication Failed!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private User login() {
|
||||
return db.login(usernameEt.getText().toString(), passwordEt.getText().toString());
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable/add_icon.png
Normal file
|
After Width: | Height: | Size: 436 B |
BIN
app/src/main/res/drawable/checkbox_checked.png
Normal file
|
After Width: | Height: | Size: 399 B |
7
app/src/main/res/drawable/checkbox_color.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="#474448"
|
||||
android:state_checked="false"/>
|
||||
<item android:color="@color/button_color" android:drawable="@drawable/checkbox_checked"
|
||||
android:state_checked="true" />
|
||||
</selector>
|
||||
7
app/src/main/res/drawable/cornered_box.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#282828"/>
|
||||
<stroke android:width="3dp" android:color="#282828" />
|
||||
<corners android:radius="18dp"/>
|
||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
||||
</shape>
|
||||
7
app/src/main/res/drawable/cornered_sublayer.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#494C5D"/>
|
||||
<stroke android:width="3dp" android:color="#494C5D" />
|
||||
<corners android:radius="18dp"/>
|
||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/habits_icon.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
app/src/main/res/drawable/home_icon.png
Normal file
|
After Width: | Height: | Size: 356 B |
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
30
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
7
app/src/main/res/drawable/menu_bar.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#282828"/>
|
||||
<stroke android:width="3dp" android:color="#282828" />
|
||||
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp"/>
|
||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/profile_icon.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/drawable/refresh_icon.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable/user.png
Normal file
|
After Width: | Height: | Size: 366 B |
BIN
app/src/main/res/drawable/user2.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/font/inter_black.ttf
Normal file
BIN
app/src/main/res/font/inter_bold.ttf
Normal file
BIN
app/src/main/res/font/inter_regular.ttf
Normal file
BIN
app/src/main/res/font/roboto.ttf
Normal file
107
app/src/main/res/layout/activity_add_habit.xml
Normal file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:background="#121212"
|
||||
tools:context="View.AddHabit">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:paddingTop="50dp"
|
||||
android:paddingBottom="50dp"
|
||||
android:paddingEnd="25dp"
|
||||
android:paddingStart="25dp"
|
||||
android:background="@drawable/cornered_box"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/new_habit_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/new_habit_tv"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#e2e2e2"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/new_habit_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autofillHints="username"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:inputType="text"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#e2e2e2"
|
||||
tools:ignore="LabelFor,SpeakableTextPresentCheck,VisualLintTextFieldSize" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/new_habit_tv"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#e2e2e2"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/selected_time_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="25sp"
|
||||
android:text="00:00 AM"
|
||||
android:layout_marginEnd="40dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/time_picker"
|
||||
android:layout_width="115dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Pick Time"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_new_habit_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:backgroundTint="@color/button_color"
|
||||
android:text="@string/add_new_habit_btn"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
tools:ignore="VisualLintButtonSize" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/back_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:backgroundTint="@color/button2_color"
|
||||
android:text="@string/back_btn"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
tools:ignore="VisualLintButtonSize" />
|
||||
|
||||
</LinearLayout>
|
||||
119
app/src/main/res/layout/activity_create_account.xml
Normal file
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:background="#121212"
|
||||
tools:context="View.CreateAccountActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/cornered_box"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:padding="35dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="35dp"
|
||||
android:fontFamily="@font/inter_black"
|
||||
android:text="@string/create_tv"
|
||||
android:textColor="#2497c9"
|
||||
android:textSize="25sp"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/username_tv"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#e2e2e2"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="username"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:inputType="text"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#e2e2e2"
|
||||
tools:ignore="LabelFor,SpeakableTextPresentCheck" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/password_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/password_tv"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#e2e2e2"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="username"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:inputType="textPassword"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#e2e2e2"
|
||||
tools:ignore="LabelFor,SpeakableTextPresentCheck" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/create_account_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:backgroundTint="@color/button_color"
|
||||
android:text="@string/create_account_btn"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/inter_bold"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/back_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:backgroundTint="@color/button2_color"
|
||||
android:text="@string/back_btn"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/inter_bold"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
185
app/src/main/res/layout/activity_home.xml
Normal file
@@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:background="#121212"
|
||||
tools:context="View.HomeActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="25dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/profile_icon"
|
||||
android:layout_marginStart="290dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_greating_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:text="Hello, Benjamin"
|
||||
android:textSize="25sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#615d6c"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/today_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:fontFamily="@font/inter_black"
|
||||
android:text="Today Wednesday, 6"
|
||||
android:textSize="40sp"
|
||||
android:textColor="#2497c9"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@drawable/cornered_box">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_black"
|
||||
android:text="@string/progress_tv"
|
||||
android:textSize="30sp"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#2497c9"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_percentage_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_black"
|
||||
android:text="50%"
|
||||
android:textSize="50sp"
|
||||
android:textStyle="bold"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#2497c9"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="30dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/habits_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_black"
|
||||
android:text="@string/habits_tv"
|
||||
android:textSize="25sp"
|
||||
android:textColor="#e2e2e2"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_habit"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="70dp"
|
||||
android:drawableStart="@drawable/add_icon"
|
||||
android:backgroundTint="@color/button_color"
|
||||
android:padding="15dp"
|
||||
android:layout_marginStart="80dp"
|
||||
android:text="@string/add_habit"
|
||||
android:textSize="22sp"
|
||||
android:fontFamily="@font/inter_bold"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ScrollView
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:background="@drawable/cornered_box">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/refresh_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:background="#282828"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/refresh_icon"
|
||||
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/habits_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- <LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/menu_bar"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp"
|
||||
android:contentDescription="Home icon"
|
||||
android:src="@drawable/home_icon"
|
||||
android:background="#282828"/>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="80dp"
|
||||
android:layout_marginEnd="80dp"
|
||||
android:contentDescription="habits icon"
|
||||
android:src="@drawable/habits_icon"
|
||||
android:background="#282828"/>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp"
|
||||
android:contentDescription="habits icon"
|
||||
android:src="@drawable/user"
|
||||
android:background="#282828"/>
|
||||
|
||||
|
||||
</LinearLayout> -->
|
||||
|
||||
</LinearLayout>
|
||||
114
app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#121212"
|
||||
tools:context="View.MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/login_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_black"
|
||||
android:text="@string/login_title"
|
||||
android:textSize="40sp"
|
||||
android:textAlignment="center"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2497c9"
|
||||
android:layout_marginTop="70dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/username_tv"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#e2e2e2"
|
||||
android:layout_marginTop="100dp"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autofillHints="username"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:inputType="text"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#e2e2e2"
|
||||
tools:ignore="LabelFor,SpeakableTextPresentCheck" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/password_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/password_tv"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#e2e2e2"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autofillHints="password"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:inputType="textPassword"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#e2e2e2"
|
||||
tools:ignore="LabelFor,SpeakableTextPresentCheck" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:backgroundTint="@color/button_color"
|
||||
android:layout_marginTop="40dp"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/login_btn"
|
||||
android:textSize="22sp"
|
||||
tools:ignore="DuplicateSpeakableTextCheck" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/note_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/note_tv"
|
||||
android:textSize="15sp"
|
||||
android:textAlignment="center"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/create_account_tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:fontFamily="@font/inter_bold"
|
||||
android:text="@string/create_account_tv"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#2497c9"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
6
app/src/main/res/mipmap-anydpi/ic_launcher.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
6
app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 982 B |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
7
app/src/main/res/values-night/themes.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.HabitTracker" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
||||
7
app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="button_color">#1B87EA</color>
|
||||
<color name="button2_color">#023e8a</color>
|
||||
</resources>
|
||||
20
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<resources>
|
||||
<string name="app_name">HabitTracker</string>
|
||||
<string name="login_title">Habit Tracker</string>
|
||||
<string name="username_tv">Username:</string>
|
||||
<string name="password_tv">Password:</string>
|
||||
<string name="login_btn">Login</string>
|
||||
<string name="note_tv">Don\'t have an account?</string>
|
||||
<string name="create_account_tv">Create an account</string>
|
||||
<string name="progress_tv">Today\'s progress</string>
|
||||
<string name="habits_tv">Your habits</string>
|
||||
<string name="add_habit">Add</string>
|
||||
<string name="create_account_btn">Create</string>
|
||||
<string name="email_tv">Email:</string>
|
||||
<string name="first_name_tv">First Name:</string>
|
||||
<string name="create_tv">Create Account</string>
|
||||
<string name="back_btn">Back</string>
|
||||
<string name="add_habit_heading">Add Habit</string>
|
||||
<string name="new_habit_tv">New Habit:</string>
|
||||
<string name="add_new_habit_btn">Add Habit</string>
|
||||
</resources>
|
||||
9
app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.HabitTracker" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.HabitTracker" parent="Base.Theme.HabitTracker" />
|
||||
</resources>
|
||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||