Unzip folder for post-school
15
Project/.gitignore
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
1
Project/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
40
Project/app/build.gradle.kts
Normal file
|
@ -0,0 +1,40 @@
|
|||
plugins {
|
||||
alias(libs.plugins.androidApplication)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "edu.snhu.cs360.ccook.project"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "edu.snhu.cs360.ccook.project"
|
||||
minSdk = 34
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation(libs.appcompat)
|
||||
implementation(libs.material)
|
||||
implementation(libs.activity)
|
||||
implementation(libs.constraintlayout)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.ext.junit)
|
||||
androidTestImplementation(libs.espresso.core)
|
||||
}
|
21
Project/app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,26 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("edu.snhu.cs360.ccook.project", appContext.getPackageName());
|
||||
}
|
||||
}
|
43
Project/app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
android:required="false" />
|
||||
|
||||
<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"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Project"
|
||||
tools:targetApi="34">
|
||||
|
||||
<activity
|
||||
android:name=".Main"
|
||||
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=".Login"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name=".SMS"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name=".Home"
|
||||
android:exported="true" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,161 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Database extends SQLiteOpenHelper {
|
||||
|
||||
// define database file and version
|
||||
private static final String DATABASE_NAME = String.valueOf(R.string.database_file);
|
||||
private static final int VERSION = 17;
|
||||
|
||||
// set constructors
|
||||
public Database(Login context) {
|
||||
super(context, DATABASE_NAME, null, VERSION);
|
||||
}
|
||||
|
||||
public Database(Main context) {
|
||||
super(context, DATABASE_NAME, null, VERSION);
|
||||
}
|
||||
|
||||
public Database(Home context) {
|
||||
super(context, DATABASE_NAME, null, VERSION);
|
||||
}
|
||||
|
||||
public Database(FragmentActivity activity) {
|
||||
super(activity, DATABASE_NAME, null, VERSION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
// create a new database if it doesn't exist
|
||||
Log.d(String.valueOf(R.string.database), String.valueOf(R.string.creating_new_database_with_tables));
|
||||
db.execSQL("CREATE TABLE " + UserTable.TABLE + " (" + UserTable.COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + UserTable.COL_USERNAME + " TEXT, " + UserTable.COL_PASSWORD + " TEXT, " + UserTable.COL_GOAL + " REAL, " + UserTable.COL_GOAL_UNIT + " TEXT)");
|
||||
db.execSQL("CREATE TABLE " + WeightTable.TABLE + " (" + WeightTable.COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + WeightTable.COL_USER_ID + " INTEGER, " + WeightTable.COL_DATE + " TEXT, " + WeightTable.COL_WEIGHT + " REAL, " + WeightTable.COL_WEIGHT_UNIT + " TEXT)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
// purge existing database and create new
|
||||
Log.d(String.valueOf(R.string.database), String.valueOf(R.string.upgrading_database_due_to_version_change_wiping_data));
|
||||
db.execSQL("DROP TABLE IF EXISTS " + UserTable.TABLE);
|
||||
db.execSQL("DROP TABLE IF EXISTS " + WeightTable.TABLE);
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
private String encryptPassword(String password) throws NoSuchAlgorithmException {
|
||||
// store password in database as a hash for security
|
||||
MessageDigest hash = MessageDigest.getInstance("SHA-256");
|
||||
return Arrays.toString(hash.digest(password.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
public Cursor checkUserExists(SQLiteDatabase db, String username) {
|
||||
// look if the user exists
|
||||
Log.d(String.valueOf(R.string.database), R.string.checking_database_for_user + username);
|
||||
return db.rawQuery("SELECT " + UserTable.COL_ID + " FROM " + UserTable.TABLE + " WHERE " + UserTable.COL_USERNAME + " = ?", new String[]{username});
|
||||
}
|
||||
|
||||
public Cursor checkUserPassword(SQLiteDatabase db, String username, String password) throws NoSuchAlgorithmException {
|
||||
// return the id if the user exists with a matching password
|
||||
Log.d(String.valueOf(R.string.database), R.string.validating_password_for_user + username);
|
||||
return db.rawQuery("SELECT " + UserTable.COL_ID + " FROM " + UserTable.TABLE + " WHERE " + UserTable.COL_USERNAME + " = ? AND " + UserTable.COL_PASSWORD + " = ?", new String[]{username, encryptPassword(password)});
|
||||
}
|
||||
|
||||
public void registerUser(SQLiteDatabase db, String username, String password) throws NoSuchAlgorithmException {
|
||||
// Prepare default values for the new user
|
||||
double defaultGoalWeight = -1; // Default goal weight
|
||||
String defaultGoalUnit = String.valueOf(R.string.lb); // Default goal weight unit
|
||||
|
||||
// Log registration attempt
|
||||
Log.d(String.valueOf(R.string.database), String.valueOf(R.string.registering_new_user) + username);
|
||||
|
||||
// Execute SQL command to insert new user with default goal values
|
||||
String sql = "INSERT INTO " + UserTable.TABLE + " (" + UserTable.COL_USERNAME + ", " + UserTable.COL_PASSWORD + ", " + UserTable.COL_GOAL + ", " + UserTable.COL_GOAL_UNIT + ") VALUES (?, ?, ?, ?)";
|
||||
|
||||
db.execSQL(sql, new String[]{username, encryptPassword(password), String.valueOf(defaultGoalWeight), defaultGoalUnit});
|
||||
}
|
||||
|
||||
public void addWeight(SQLiteDatabase db, int user_id, String date, double weight, String weight_unit) {
|
||||
// add weight to the database
|
||||
Log.d(String.valueOf(R.string.database), String.valueOf(R.string.adding_weight_for_user_id) + user_id);
|
||||
db.execSQL("INSERT INTO " + WeightTable.TABLE + " (" + WeightTable.COL_USER_ID + ", " + WeightTable.COL_DATE + ", " + WeightTable.COL_WEIGHT + ", " + WeightTable.COL_WEIGHT_UNIT + ") VALUES (?, ?, ?, ?)", new String[]{String.valueOf(user_id), date, String.valueOf(weight), weight_unit});
|
||||
}
|
||||
|
||||
public Cursor getUserWeights(SQLiteDatabase db, int userId, boolean sortDesc) {
|
||||
// get a user's weight based on their userId, sort as needed
|
||||
Log.d(String.valueOf(R.string.database), String.valueOf(R.string.grabbing_weights_in_for_user_id) + userId);
|
||||
String sort = "DESC";
|
||||
if (!sortDesc) {
|
||||
sort = "ASC";
|
||||
}
|
||||
return db.rawQuery("SELECT * FROM " + WeightTable.TABLE + " WHERE " + WeightTable.COL_USER_ID + " = ? ORDER BY " + WeightTable.COL_DATE + " " + sort, new String[]{String.valueOf(userId)});
|
||||
}
|
||||
|
||||
public Cursor getWeight(SQLiteDatabase db, int userId, String date) {
|
||||
// get weight; not currently used
|
||||
return db.rawQuery("SELECT * FROM " + WeightTable.TABLE + " WHERE " + WeightTable.COL_USER_ID + " = ? AND " + WeightTable.COL_DATE + " = ?", new String[]{String.valueOf(userId), date});
|
||||
}
|
||||
|
||||
public Cursor getRecentWeight(SQLiteDatabase db, int user_id) {
|
||||
// pull the most recent weight of the user
|
||||
return db.rawQuery("SELECT " + WeightTable.COL_WEIGHT + "," + WeightTable.COL_WEIGHT_UNIT + " FROM " + WeightTable.TABLE + " WHERE " + WeightTable.COL_USER_ID + " = ? ORDER BY " + WeightTable.COL_DATE + " DESC LIMIT 1", new String[]{String.valueOf(user_id)});
|
||||
}
|
||||
|
||||
public void removeWeight(SQLiteDatabase db, int id) {
|
||||
// remove the specific weight from the table
|
||||
db.execSQL("DELETE FROM " + WeightTable.TABLE + " WHERE " + WeightTable.COL_ID + " = ?", new String[]{String.valueOf(id)});
|
||||
}
|
||||
|
||||
public void setWeightGoal(SQLiteDatabase db, int userId, double goalWeight, String goalWeightUnit) {
|
||||
// set the weight goal to the user
|
||||
db.execSQL("UPDATE " + UserTable.TABLE + " SET " + UserTable.COL_GOAL + " = ?, " + UserTable.COL_GOAL_UNIT + " = ? WHERE " + UserTable.COL_ID + " = ?", new String[]{String.valueOf(goalWeight), goalWeightUnit, String.valueOf(userId)});
|
||||
}
|
||||
|
||||
public void clearWeightGoal(SQLiteDatabase db, int userId) {
|
||||
// remove the weight goal
|
||||
db.execSQL("UPDATE " + UserTable.TABLE + " SET " + UserTable.COL_GOAL + " = ?, " + UserTable.COL_GOAL_UNIT + " = ? WHERE " + UserTable.COL_ID + " = ?", new String[]{"-1", String.valueOf(R.string.lb), String.valueOf(userId)});
|
||||
}
|
||||
|
||||
public Cursor getWeightGoal(SQLiteDatabase db, int userId) {
|
||||
// get user's goal weight
|
||||
return db.rawQuery("SELECT " + UserTable.COL_GOAL + "," + UserTable.COL_GOAL_UNIT + " FROM " + UserTable.TABLE + " WHERE " + UserTable.COL_ID + " = ?", new String[]{String.valueOf(userId)});
|
||||
}
|
||||
|
||||
public void updateWeight(SQLiteDatabase db, int id, double weight, String weightUnit) {
|
||||
// update the weight
|
||||
db.execSQL("UPDATE " + WeightTable.TABLE + " SET " + WeightTable.COL_WEIGHT + " = ?, " + WeightTable.COL_WEIGHT_UNIT + " = ? WHERE " + WeightTable.COL_ID + " = ?", new String[]{String.valueOf(weight), weightUnit, String.valueOf(id)});
|
||||
}
|
||||
|
||||
/* Tables */
|
||||
public static final class UserTable {
|
||||
|
||||
public static final String TABLE = "users";
|
||||
public static final String COL_ID = "_id";
|
||||
public static final String COL_USERNAME = "username";
|
||||
public static final String COL_PASSWORD = "password";
|
||||
public static final String COL_GOAL = "goal_weight";
|
||||
public static final String COL_GOAL_UNIT = "goal_weight_unit";
|
||||
}
|
||||
|
||||
public static final class WeightTable {
|
||||
public static final String TABLE = "weight";
|
||||
public static final String COL_ID = "_id";
|
||||
public static final String COL_USER_ID = "user_id";
|
||||
public static final String COL_DATE = "date";
|
||||
public static final String COL_WEIGHT = "weight";
|
||||
public static final String COL_WEIGHT_UNIT = "weight_unit";
|
||||
}
|
||||
|
||||
|
||||
}
|
309
Project/app/src/main/java/edu/snhu/cs360/ccook/project/Home.java
Normal file
|
@ -0,0 +1,309 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.SmsManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Home extends AppCompatActivity implements WeightEntryAdapter.OnEntryInteractionListener {
|
||||
boolean sortDesc = true;
|
||||
private Database dbHelper;
|
||||
private RecyclerView recyclerView;
|
||||
private Button goalWeightButton, currentWeightButton, weightDifferenceButton;
|
||||
private TextView losegainTextView;
|
||||
private double currentWeight;
|
||||
private double goalWeight;
|
||||
private boolean sentTextMessageThisSession = false;
|
||||
|
||||
|
||||
// convert lb to kg if necessary; future feature
|
||||
public double lbsToKg(double lbs) {
|
||||
return lbs * 0.453592;
|
||||
}
|
||||
|
||||
// convert kg to lb
|
||||
public double kgToLbs(double kg) {
|
||||
return kg * 2.20462;
|
||||
}
|
||||
|
||||
void fetchWeightEntries(int userId, boolean sortDesc) {
|
||||
// build the list of weights with a new thread
|
||||
new Thread(() -> {
|
||||
List<WeightEntry> weightEntries = new ArrayList<>();
|
||||
SQLiteDatabase db = dbHelper.getReadableDatabase();
|
||||
Cursor cursor = dbHelper.getUserWeights(db, userId, sortDesc);
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
// get column details
|
||||
@SuppressLint("Range") int id = cursor.getInt(cursor.getColumnIndex(Database.WeightTable.COL_ID));
|
||||
@SuppressLint("Range") String date = cursor.getString(cursor.getColumnIndex(Database.WeightTable.COL_DATE));
|
||||
@SuppressLint("Range") double weight = cursor.getDouble(cursor.getColumnIndex(Database.WeightTable.COL_WEIGHT));
|
||||
@SuppressLint("Range") String unit = cursor.getString(cursor.getColumnIndex(Database.WeightTable.COL_WEIGHT_UNIT));
|
||||
|
||||
// date is an epoch; convert to Mm/dd/yy
|
||||
long epochMillis = Long.parseLong(date) * 1000; // Convert seconds to milliseconds
|
||||
date = new SimpleDateFormat(getString(R.string.dateFormat)).format(new Date(epochMillis));
|
||||
|
||||
if (unit.equalsIgnoreCase(getString(R.string.kg))) {
|
||||
weight = kgToLbs(weight);
|
||||
// round weight to the closest
|
||||
weight = (double) Math.round(weight);
|
||||
unit = getString(R.string.lb);
|
||||
}
|
||||
weightEntries.add(new WeightEntry(id, userId, date, weight, unit));
|
||||
} while (cursor.moveToNext());
|
||||
} else {
|
||||
this.currentWeight = 0.0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
|
||||
// Update the RecyclerView on the main thread
|
||||
runOnUiThread(() -> recyclerView.setAdapter(new WeightEntryAdapter(weightEntries, this)));
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void goalAchieved() {
|
||||
// alert the user on goal achievement
|
||||
if (!sentTextMessageThisSession) {
|
||||
// only alert on the first time you open the app per session
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
// the Android Device manager phone number was +15551234567; reusing here without requesting new permissions
|
||||
String phoneNo = getString(R.string.phoneNumber);
|
||||
String message = getString(R.string.congrats_on_reaching_your_goal);
|
||||
|
||||
try {
|
||||
SmsManager smsManager = SmsManager.getDefault();
|
||||
smsManager.sendTextMessage(phoneNo, null, message, null, null);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getApplicationContext(), String.valueOf(R.string.sms_failed_to_send_please_try_again), Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, String.valueOf(R.string.congrats_on_reaching_your_goal_we_know_you_could_do_it), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
sentTextMessageThisSession = true;
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("Range")
|
||||
private void setGoalWeightText(int userId) {
|
||||
String string;
|
||||
double weight;
|
||||
String unit;
|
||||
|
||||
SQLiteDatabase db = dbHelper.getReadableDatabase();
|
||||
Cursor cursor = dbHelper.getWeightGoal(db, userId);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
weight = cursor.getDouble(cursor.getColumnIndex(Database.UserTable.COL_GOAL));
|
||||
unit = cursor.getString(cursor.getColumnIndex(Database.UserTable.COL_GOAL_UNIT));
|
||||
if (unit.equalsIgnoreCase(getString(R.string.kg))) {
|
||||
weight = kgToLbs(weight);
|
||||
weight = Math.round(weight);
|
||||
unit = getString(R.string.lb);
|
||||
}
|
||||
|
||||
if (weight <= 0) {
|
||||
string = getString(R.string.unset);
|
||||
} else {
|
||||
string = weight + " " + unit;
|
||||
}
|
||||
this.goalWeight = weight;
|
||||
goalWeightButton.setText(string);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLoseGainText() {
|
||||
double difference = this.goalWeight - this.currentWeight;
|
||||
String string = Math.abs(difference) + " " + getString(R.string.lb);
|
||||
|
||||
// if the goalWeight and currentWeight are set
|
||||
if (this.goalWeight > 0.0 && this.currentWeight > 0.0) {
|
||||
// and there is no difference
|
||||
if (difference == 0.0) {
|
||||
// the goal was met
|
||||
losegainTextView.setText(getString(R.string.goal_met));
|
||||
string = getString(R.string.congrats);
|
||||
goalAchieved();
|
||||
}
|
||||
// if the difference is negative
|
||||
if (difference < 0.0) {
|
||||
losegainTextView.setText(getString(R.string.to_lose));
|
||||
} else if (difference > 0.0) {
|
||||
losegainTextView.setText(getString(R.string.to_gain));
|
||||
}
|
||||
} else {
|
||||
losegainTextView.setText(getString(R.string.lose_gain));
|
||||
string = "";
|
||||
}
|
||||
weightDifferenceButton.setText(string);
|
||||
}
|
||||
|
||||
@SuppressLint("Range")
|
||||
private void setCurrentWeight(int userId) {
|
||||
double weight = 0.0;
|
||||
String unit;
|
||||
String string = getString(R.string.unset);
|
||||
|
||||
SQLiteDatabase db = dbHelper.getReadableDatabase();
|
||||
Cursor cursor = dbHelper.getRecentWeight(db, userId);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
weight = cursor.getDouble(cursor.getColumnIndex(Database.WeightTable.COL_WEIGHT));
|
||||
unit = cursor.getString(cursor.getColumnIndex(Database.WeightTable.COL_WEIGHT_UNIT));
|
||||
if (unit.equalsIgnoreCase(getString(R.string.kg))) {
|
||||
weight = kgToLbs(weight);
|
||||
// round weight to the closest
|
||||
weight = Math.round(weight);
|
||||
unit = getString(R.string.lb);
|
||||
}
|
||||
if (weight > 0) {
|
||||
string = weight + " " + unit;
|
||||
}
|
||||
}
|
||||
this.currentWeight = weight;
|
||||
currentWeightButton.setText(string);
|
||||
}
|
||||
|
||||
void setBannerWidgets(int userId) {
|
||||
// update the banner widgets
|
||||
setCurrentWeight(userId);
|
||||
setGoalWeightText(userId);
|
||||
setLoseGainText();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void toggleSortOrder() {
|
||||
// toggle sorting
|
||||
sortDesc = !sortDesc;
|
||||
|
||||
ImageView sortByDateIcon = findViewById(R.id.sortByDateIcon);
|
||||
|
||||
if (sortDesc) {
|
||||
sortByDateIcon.setImageResource(R.drawable.sortdesc);
|
||||
} else {
|
||||
sortByDateIcon.setImageResource(R.drawable.sortasc);
|
||||
}
|
||||
|
||||
// retrieve the entries in the requested order and update banner widgets, if needed
|
||||
fetchWeightEntries(getIntent().getIntExtra("userId", -1), sortDesc);
|
||||
setBannerWidgets(getIntent().getIntExtra("userId", -1));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.home);
|
||||
|
||||
dbHelper = new Database(this);
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
goalWeightButton = findViewById(R.id.goalWeightButton);
|
||||
currentWeightButton = findViewById(R.id.currentWeightButton);
|
||||
weightDifferenceButton = findViewById(R.id.weightDifferenceButton);
|
||||
losegainTextView = findViewById(R.id.losegainTextView);
|
||||
FloatingActionButton addButton = findViewById(R.id.addDataButton);
|
||||
ImageView sortByDateIcon = findViewById(R.id.sortByDateIcon);
|
||||
|
||||
// set a listener for the sort toggler
|
||||
sortByDateIcon.setOnClickListener(v -> toggleSortOrder());
|
||||
|
||||
// pull in the userId from the previous page
|
||||
Intent getExtras = getIntent();
|
||||
int userId = getExtras.getIntExtra("userId", -1);
|
||||
|
||||
// get the latest weight entries with the proper sort
|
||||
fetchWeightEntries(userId, sortDesc);
|
||||
|
||||
// add button tap listener; bring up menu
|
||||
addButton.setOnClickListener(v -> {
|
||||
PopupMenu popup = new PopupMenu(this, v);
|
||||
popup.getMenuInflater().inflate(R.menu.add, popup.getMenu());
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.record_weight) {
|
||||
// Record weight here
|
||||
RecordWeight dialogFragment = RecordWeight.newInstance(userId, -1, RecordWeight.getDate(),-1, false);
|
||||
dialogFragment.show(getSupportFragmentManager(), "RecordWeight");
|
||||
fetchWeightEntries(getIntent().getIntExtra("userId", -1), sortDesc);
|
||||
return true;
|
||||
} else if (id == R.id.set_Goal) {
|
||||
// Set the goal weight here
|
||||
SetGoal dialogFragment = SetGoal.newInstance(userId);
|
||||
dialogFragment.show(getSupportFragmentManager(), "SetGoal");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
popup.show();
|
||||
});
|
||||
|
||||
// now that data is loaded, set banners.
|
||||
setBannerWidgets(userId);
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, (v, insets) -> {
|
||||
v.setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEditClicked(WeightEntry entry) {
|
||||
// Show dialog for editing
|
||||
RecordWeight dialogFragment = RecordWeight.newInstance(entry.getUserId(), entry.getId(), entry.getDate(), entry.getWeight(), Objects.equals(entry.getWeightUnit(), String.valueOf(R.string.kg)));
|
||||
dialogFragment.show(getSupportFragmentManager(), "EditWeight");
|
||||
|
||||
// Refresh the list
|
||||
fetchWeightEntries(entry.getUserId(), sortDesc);
|
||||
setBannerWidgets(entry.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteClicked(WeightEntry entry) {
|
||||
SQLiteDatabase db = dbHelper.getWritableDatabase();
|
||||
dbHelper.removeWeight(db, entry.getId());
|
||||
db.close();
|
||||
|
||||
// Refresh the list
|
||||
fetchWeightEntries(entry.getUserId(), sortDesc);
|
||||
setBannerWidgets(entry.getUserId());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
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;
|
||||
|
||||
public class Login extends AppCompatActivity {
|
||||
|
||||
private EditText textUsername, textPassword;
|
||||
private Button buttonLogin, buttonRegister;
|
||||
private Database dbHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.login);
|
||||
dbHelper = new Database(this);
|
||||
|
||||
// identify the fields in the layout
|
||||
textUsername = findViewById(R.id.textUsername);
|
||||
textPassword = findViewById(R.id.textPassword);
|
||||
buttonLogin = findViewById(R.id.buttonLogin);
|
||||
buttonRegister = findViewById(R.id.buttonRegister);
|
||||
|
||||
// set watchers to watch changes in text
|
||||
textUsername.addTextChangedListener(new UserTextWatcher());
|
||||
textPassword.addTextChangedListener(new PasswordTextWatcher());
|
||||
|
||||
// set button listeners
|
||||
buttonLogin.setOnClickListener(v -> loginUser());
|
||||
buttonRegister.setOnClickListener(v -> registerUser());
|
||||
|
||||
// Initially disable both buttons
|
||||
updateButtonStates();
|
||||
}
|
||||
|
||||
private void updateButtonStates() {
|
||||
String username = textUsername.getText().toString().trim();
|
||||
boolean hasPassword = textPassword.getText().length() > 0;
|
||||
|
||||
// when the username isn't empty and there is a password
|
||||
if (!username.isEmpty() && hasPassword) {
|
||||
new Thread(() -> {
|
||||
// find if this user exists
|
||||
SQLiteDatabase db = dbHelper.getReadableDatabase();
|
||||
Cursor cursor = dbHelper.checkUserExists(db, username);
|
||||
final boolean userExists = cursor.getCount() > 0;
|
||||
cursor.close();
|
||||
db.close();
|
||||
|
||||
runOnUiThread(() -> {
|
||||
// either register or login based on experience
|
||||
buttonRegister.setEnabled(!userExists && hasPassword);
|
||||
buttonLogin.setEnabled(userExists && hasPassword);
|
||||
});
|
||||
}).start();
|
||||
} else {
|
||||
runOnUiThread(() -> {
|
||||
// default to disabled when the conditions are not met
|
||||
buttonRegister.setEnabled(false);
|
||||
buttonLogin.setEnabled(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void registerUser() {
|
||||
String username = textUsername.getText().toString().trim();
|
||||
String password = textPassword.getText().toString().trim();
|
||||
|
||||
new Thread(() -> {
|
||||
// Encrypt the password before storing it
|
||||
try (SQLiteDatabase db = dbHelper.getWritableDatabase()) {
|
||||
dbHelper.registerUser(db, username, password);
|
||||
runOnUiThread(() -> {
|
||||
Toast.makeText(Login.this, getString(R.string.registration_successful), Toast.LENGTH_SHORT).show();
|
||||
textPassword.setText(""); // Clear password field after registration for security
|
||||
buttonRegister.setEnabled(false); // Disable register button as this user now exists
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e(getString(R.string.loginactivity), getString(R.string.failed_to_register_user), e);
|
||||
runOnUiThread(() -> Toast.makeText(Login.this, String.valueOf(R.string.registration_failed), Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void loginUser() {
|
||||
String username = textUsername.getText().toString().trim();
|
||||
String password = textPassword.getText().toString().trim();
|
||||
|
||||
new Thread(() -> {
|
||||
try (SQLiteDatabase db = dbHelper.getReadableDatabase()) {
|
||||
Cursor cursor = dbHelper.checkUserPassword(db, username, password);
|
||||
|
||||
// Check login success
|
||||
final boolean loginSuccess = cursor.moveToFirst();
|
||||
|
||||
// Get user ID if login successful
|
||||
final int userId = loginSuccess ? cursor.getInt(0) : -1;
|
||||
|
||||
runOnUiThread(() -> {
|
||||
if (loginSuccess) {
|
||||
Toast.makeText(Login.this, getString(R.string.login_successful), Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(Login.this, Home.class);
|
||||
intent.putExtra("userId", userId);
|
||||
|
||||
// start the activity
|
||||
startActivity(intent);
|
||||
|
||||
// Close login activity
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(Login.this, getString(R.string.authentication_failed), Toast.LENGTH_SHORT).show();
|
||||
// Clear password field on failed login
|
||||
textPassword.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
cursor.close(); // Close cursor after data retrieval
|
||||
} catch (Exception e) {
|
||||
Log.e(getString(R.string.loginactivity), getString(R.string.failed_to_login_user), e);
|
||||
runOnUiThread(() -> Toast.makeText(Login.this, getString(R.string.login_error), Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
private class UserTextWatcher implements TextWatcher {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
updateButtonStates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
}
|
||||
|
||||
private class PasswordTextWatcher implements TextWatcher {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
updateButtonStates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
public class Main extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Initialize database (checks if it exists and creates if not)
|
||||
initializeDatabase();
|
||||
|
||||
// Check SMS permissions and navigate accordingly
|
||||
checkPermissions();
|
||||
}
|
||||
|
||||
private void initializeDatabase() {
|
||||
try {
|
||||
// Create database helper
|
||||
Database dbHelper = new Database(this);
|
||||
|
||||
// Calling getWritableDatabase() ensures database is created if it doesn't exist
|
||||
dbHelper.getWritableDatabase();
|
||||
|
||||
} catch (Exception e) {
|
||||
// User output for an error occurred with the db
|
||||
Toast.makeText(Main.this, "Error initializing database", Toast.LENGTH_SHORT).show();
|
||||
Log.e("Main", "Error initializing database", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermissions() {
|
||||
// Check if app previously given SMS permissions
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED) {
|
||||
// Permission already exists, skip requesting SMS permissions and go to login page
|
||||
showLogin();
|
||||
} else {
|
||||
// Permission wasn't granted, request it
|
||||
requestSMS();
|
||||
}
|
||||
|
||||
// Finish Main activity
|
||||
finish();
|
||||
}
|
||||
|
||||
private void showLogin() {
|
||||
// Show the login screen
|
||||
Intent loginIntent = new Intent(this, Login.class);
|
||||
startActivity(loginIntent);
|
||||
}
|
||||
|
||||
private void requestSMS() {
|
||||
// Show the SMS request permission screen
|
||||
Intent smsIntent = new Intent(this, SMS.class);
|
||||
startActivity(smsIntent);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
public class RecordWeight extends DialogFragment {
|
||||
|
||||
private EditText weightInput;
|
||||
private RadioGroup weightUnitGroup;
|
||||
private Database dbHelper;
|
||||
|
||||
|
||||
public static RecordWeight newInstance(int userId, int entryId, String date, double weight, boolean isKg) {
|
||||
// configure a new fragment with the user id so it can be updated or added
|
||||
RecordWeight fragment = new RecordWeight();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("userId", userId);
|
||||
args.putInt("entryId", entryId);
|
||||
args.putDouble("weight", weight);
|
||||
args.putString("date", date);
|
||||
args.putBoolean("isKg", isKg);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static String getDate() {
|
||||
// parse timestamp properly
|
||||
return String.valueOf(System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// start a new database connection
|
||||
dbHelper = new Database(getActivity());
|
||||
|
||||
// build view and layout for fragment dialog
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.record_weight, null);
|
||||
|
||||
// identify the fields in the layout
|
||||
weightInput = view.findViewById(R.id.weight_input);
|
||||
weightUnitGroup = view.findViewById(R.id.weight_unit_group);
|
||||
|
||||
Bundle args = getArguments();
|
||||
assert args != null;
|
||||
int entryId = args.getInt("entryId", -1);
|
||||
|
||||
// Check if it's an edit
|
||||
if (entryId != -1) {
|
||||
double weight = args.getDouble("weight");
|
||||
boolean isKg = args.getBoolean("isKg");
|
||||
weightInput.setText(String.valueOf(weight));
|
||||
weightUnitGroup.check(isKg ? R.id.unit_kg : R.id.unit_lb);
|
||||
}
|
||||
|
||||
// pop open a Record Weight window
|
||||
builder.setView(view).setMessage(entryId == -1 ? "Record Weight" : "Edit Weight").setPositiveButton("Save", (dialog, id) -> {
|
||||
assert getArguments() != null;
|
||||
|
||||
// on save, confirm it looks okay
|
||||
validateAndAddOrEditWeight(entryId);
|
||||
|
||||
// refresh the Home screen after adding
|
||||
((Home) getActivity()).fetchWeightEntries(getArguments().getInt("userId", -1), ((Home) getActivity()).sortDesc);
|
||||
((Home) getActivity()).setBannerWidgets(getArguments().getInt("userId", -1));
|
||||
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> {
|
||||
// cancel out if desired
|
||||
dismiss();
|
||||
});
|
||||
// return dialog box
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
private void validateAndAddOrEditWeight(int entryId) {
|
||||
int userId = getArguments().getInt("userId", -1);
|
||||
String weightStr = weightInput.getText().toString();
|
||||
double weight = Double.parseDouble(weightStr);
|
||||
SQLiteDatabase db = dbHelper.getWritableDatabase();
|
||||
boolean isKg = weightUnitGroup.getCheckedRadioButtonId() == R.id.unit_kg;
|
||||
String weightUnit = isKg ? getString(R.string.kg) : getString(R.string.lb);
|
||||
|
||||
if ((isKg && (weight < 20 || weight > 430)) || (!isKg && (weight < 45 || weight > 950))) {
|
||||
Toast.makeText(getContext(), isKg ? "Weight must be between 20 kg and 430 kg" : "Weight must be between 45 lbs and 950 lbs", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (entryId == -1) {
|
||||
dbHelper.addWeight(db, userId, getDate(), weight, weightUnit);
|
||||
} else {
|
||||
dbHelper.updateWeight(db, entryId, weight, weightUnit);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
public class SMS extends AppCompatActivity {
|
||||
|
||||
private static final int SMS_PERMISSION_CODE = 101;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.sms);
|
||||
|
||||
// set request SMS button ID
|
||||
Button btnRequestSMSPermission = findViewById(R.id.btnRequestSMSPermission);
|
||||
|
||||
// set onclick listener
|
||||
btnRequestSMSPermission.setOnClickListener(view -> {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED) {
|
||||
// request permissions
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, SMS_PERMISSION_CODE);
|
||||
} else {
|
||||
// Permission has already been granted
|
||||
permissionGranted();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == SMS_PERMISSION_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// Permission granted
|
||||
permissionGranted();
|
||||
} else {
|
||||
// Permission denied
|
||||
permissionRejected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionGranted() {
|
||||
// SMS permission has been granted
|
||||
Intent intent = new Intent(this, Login.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void permissionRejected() {
|
||||
// SMS wasn't granted; skip to login anyway
|
||||
Intent intent = new Intent(this, Login.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
public class SetGoal extends DialogFragment {
|
||||
|
||||
private EditText weightInput;
|
||||
private RadioGroup weightUnitGroup;
|
||||
private Database dbHelper;
|
||||
private boolean toLose;
|
||||
|
||||
public static SetGoal newInstance(int userId) {
|
||||
// configure a new fragment with the user id so it can be saved to the database
|
||||
SetGoal fragment = new SetGoal();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("userId", userId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// start a new database connection
|
||||
dbHelper = new Database(getActivity());
|
||||
|
||||
// build view and layout for fragment dialog
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.set_goal, null);
|
||||
|
||||
// identify the fields in the layout
|
||||
weightInput = view.findViewById(R.id.weight_input);
|
||||
weightUnitGroup = view.findViewById(R.id.weight_unit_group);
|
||||
|
||||
builder.setView(view).setMessage("Set Goal").setPositiveButton("Set", (dialog, id) -> {
|
||||
// validate and reparse the widgets; goals don't alter weight table
|
||||
validateAndAddWeight();
|
||||
((Home) getActivity()).setBannerWidgets(getArguments().getInt("userId", -1));
|
||||
}).setNegativeButton("Cancel", (dialog, id) -> {
|
||||
// cancel out if desired
|
||||
dismiss();
|
||||
});
|
||||
// return dialog box
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
private void validateAndAddWeight() {
|
||||
assert getArguments() != null;
|
||||
SQLiteDatabase db = dbHelper.getWritableDatabase();
|
||||
int userId = getArguments().getInt("userId", -1);
|
||||
String weightStr = weightInput.getText().toString();
|
||||
double weight = Double.parseDouble(weightStr);
|
||||
String weightUnit = getString(R.string.lb);
|
||||
boolean isKg = weightUnitGroup.getCheckedRadioButtonId() == R.id.unit_kg;
|
||||
|
||||
if (isKg) {
|
||||
weightUnit = getString(R.string.kg);
|
||||
}
|
||||
|
||||
if (weight != 0) {
|
||||
if (isKg) {
|
||||
if (weight < 20 || weight > 430) { // Converted values for 45 lbs and 950 lbs
|
||||
Toast.makeText(getContext(), "Weight must be between 20 kg and 430 kg", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (weight < 45 || weight > 950) {
|
||||
Toast.makeText(getContext(), "Weight must be between 45 lbs and 950 lbs", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Add weight to database
|
||||
dbHelper.setWeightGoal(db, userId, weight, weightUnit);
|
||||
} else {
|
||||
dbHelper.clearWeightGoal(db, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
public class WeightEntry {
|
||||
private final int userId;
|
||||
private final String date;
|
||||
private final double weight;
|
||||
private final String unit;
|
||||
private final int id;
|
||||
|
||||
public WeightEntry(int id, int userId, String date, double weight, String unit) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.date = date;
|
||||
this.weight = weight;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public String getWeightUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WeightEntryAdapter extends RecyclerView.Adapter<WeightEntryAdapter.ViewHolder> {
|
||||
private final List<WeightEntry> weightEntries;
|
||||
private final OnEntryInteractionListener listener;
|
||||
|
||||
public WeightEntryAdapter(List<WeightEntry> weightEntries, OnEntryInteractionListener listener) {
|
||||
this.weightEntries = weightEntries;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.weight_items, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
WeightEntry entry = weightEntries.get(position);
|
||||
holder.dateTextView.setText(entry.getDate());
|
||||
holder.weightTextView.setText(entry.getWeight() + " " + entry.getWeightUnit());
|
||||
holder.editIcon.setOnClickListener(v -> listener.onEditClicked(entry));
|
||||
holder.deleteIcon.setOnClickListener(v -> listener.onDeleteClicked(entry));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return weightEntries.size();
|
||||
}
|
||||
|
||||
public interface OnEntryInteractionListener {
|
||||
void onEditClicked(WeightEntry entry);
|
||||
|
||||
void onDeleteClicked(WeightEntry entry);
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView dateTextView, weightTextView;
|
||||
ImageView editIcon, deleteIcon;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
dateTextView = itemView.findViewById(R.id.dateTextView);
|
||||
weightTextView = itemView.findViewById(R.id.weightTextView);
|
||||
editIcon = itemView.findViewById(R.id.editIcon);
|
||||
deleteIcon = itemView.findViewById(R.id.deleteIcon);
|
||||
}
|
||||
}
|
||||
}
|
BIN
Project/app/src/main/play_store_512.png
Normal file
After Width: | Height: | Size: 122 KiB |
9
Project/app/src/main/res/drawable/border.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#111111" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
11
Project/app/src/main/res/drawable/grid_item_background.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/purpleLight" />
|
||||
<corners android:radius="8dp" />
|
||||
<padding
|
||||
android:bottom="8dp"
|
||||
android:left="8dp"
|
||||
android:right="8dp"
|
||||
android:top="8dp" />
|
||||
</shape>
|
9
Project/app/src/main/res/drawable/home.xml
Normal file
|
@ -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:fillColor="#FF000000"
|
||||
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
|
||||
</vector>
|
170
Project/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
Project/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>
|
12
Project/app/src/main/res/drawable/notebook.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/black"
|
||||
android:pathData="M19,3H5c-1.1,0 -1.99,0.9 -1.99,2L3,19c0,1.1 0.89,2 1.99,2H19c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2zM5,19V5h14v14H5z" />
|
||||
<path
|
||||
android:fillColor="#101010"
|
||||
android:pathData="M7,15h10v2H7zM7,11h10v2H7zM7,7h10v2H7z" />
|
||||
</vector>
|
BIN
Project/app/src/main/res/drawable/scale.png
Normal file
After Width: | Height: | Size: 84 KiB |
9
Project/app/src/main/res/drawable/settings.xml
Normal file
|
@ -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:fillColor="@color/black"
|
||||
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.28 -0.61,-0.16l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.97l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.43l-0.38,2.65c-0.61,0.24 -1.17,0.57 -1.69,0.97l-2.49,-1c-0.22,-0.12 -0.49,-0.06 -0.61,0.16l-2,3.46c-0.12,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.64 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.28 0.61,0.16l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.97l0.38,2.65c0.03,0.25 0.24,0.43 0.49,0.43h4c0.25,0 0.46,-0.18 0.49,-0.43l0.38,-2.65c0.61,-0.24 1.17,-0.57 1.69,-0.97l2.49,1c0.22,0.12 0.49,0.06 0.61,-0.16l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64L19.43,12.98zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z" />
|
||||
</vector>
|
9
Project/app/src/main/res/drawable/sortasc.xml
Normal file
|
@ -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:fillColor="#000000"
|
||||
android:pathData="M8,14l4,-4 4,4H8z" />
|
||||
</vector>
|
9
Project/app/src/main/res/drawable/sortdesc.xml
Normal file
|
@ -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:fillColor="@color/black"
|
||||
android:pathData="M7,10l5,5 5,-5H7z" />
|
||||
</vector>
|
185
Project/app/src/main/res/layout/home.xml
Normal file
|
@ -0,0 +1,185 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".Home">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/appLogo"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:contentDescription="@string/the_app_s_logo"
|
||||
android:src="@drawable/scale"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/appNameHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@id/appLogo"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/weightJourneyHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:text="@string/your_weight_journey"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/appLogo" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/weightJourneyLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/weightJourneyHeader">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/goal_weight"
|
||||
android:textAppearance="?attr/textAppearanceListItem"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/current_weight"
|
||||
android:textAppearance="?attr/textAppearanceListItem"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/losegainTextView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/to_lose"
|
||||
android:textAppearance="?attr/textAppearanceListItem"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/goalWeightButton"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/unset"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/currentWeightButton"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/unset"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/weightDifferenceButton"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/unset"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sortButtonLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="end|center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/weightJourneyLayout">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sortByDateDescText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sort_by_date"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sortByDateIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:contentDescription="@string/edit"
|
||||
android:src="@drawable/sortdesc" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/border"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:layout_constraintBottom_toTopOf="@id/addDataButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sortButtonLayout"
|
||||
app:spanCount="1"
|
||||
tools:listitem="@layout/weight_items" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/addDataButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:contentDescription="@string/add_new_data"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:srcCompat="@android:drawable/ic_input_add" />
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
116
Project/app/src/main/res/layout/login.xml
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".Login">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="68dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="68dp"
|
||||
android:text="@string/app_name"
|
||||
android:textAlignment="center"
|
||||
android:textSize="34sp"
|
||||
android:typeface="normal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textPassword"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:autofillHints="password"
|
||||
android:ems="10"
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textUsername" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textUsername"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:autofillHints="name"
|
||||
android:ems="10"
|
||||
android:hint="@string/username"
|
||||
android:inputType="textPersonName"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textPassword"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonLogin"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="108dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:text="@string/login"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/buttonRegister"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textPassword" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonRegister"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="108dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:text="@string/register"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/buttonLogin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textPassword" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageScale"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:contentDescription="@string/the_app_s_logo"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textUsername"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textName"
|
||||
app:srcCompat="@drawable/scale" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textLoginToContinue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="87dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="87dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:text="@string/log_into_your_account_or_register_a_new_one"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textUsername"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageScale" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
38
Project/app/src/main/res/layout/record_weight.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/weight_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/enter_weight"
|
||||
android:inputType="numberSigned"
|
||||
android:digits="0123456789"
|
||||
android:maxLength="3"/>
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/weight_unit_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/unit_lb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lb"
|
||||
android:checked="true"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/unit_kg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/kg"/>
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
38
Project/app/src/main/res/layout/set_goal.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/weight_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/enter_weight"
|
||||
android:inputType="numberSigned"
|
||||
android:digits="0123456789"
|
||||
android:maxLength="3"/>
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/weight_unit_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/unit_lb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lb"
|
||||
android:checked="true"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/unit_kg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/kg"/>
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
57
Project/app/src/main/res/layout/sms.xml
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SMS">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/appLogo"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:src="@drawable/scale"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/appName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/appLogo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/smsPermissionExplanation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:text="@string/sms_permission_offer"
|
||||
android:textAlignment="center"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/appName" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnRequestSMSPermission"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="@string/request_sms_permission"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/smsPermissionExplanation" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
72
Project/app/src/main/res/layout/weight_items.xml
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
|
||||
android:background="@drawable/grid_item_background"
|
||||
android:padding="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/calendarIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/calendar"
|
||||
android:src="@android:drawable/ic_menu_my_calendar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/weight_date"
|
||||
android:textColor="@color/design_default_color_on_primary"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/calendarIcon"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/weightScaleIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/weight_scale"
|
||||
android:src="@android:drawable/ic_menu_more"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/dateTextView"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/weightTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/weight"
|
||||
android:textColor="@color/design_default_color_on_primary"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/weightScaleIcon"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/editIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/edit"
|
||||
android:src="@android:drawable/ic_menu_edit"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/deleteIcon"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/deleteIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/delete"
|
||||
android:src="@android:drawable/ic_delete"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
12
Project/app/src/main/res/menu/add.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/record_weight"
|
||||
android:icon="@drawable/home"
|
||||
android:title="@string/record_weight" />
|
||||
<item
|
||||
android:id="@+id/set_Goal"
|
||||
android:icon="@drawable/home"
|
||||
android:title="@string/record_goal" />
|
||||
|
||||
</menu>
|
15
Project/app/src/main/res/menu/mainmenu.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/navigation_home"
|
||||
android:icon="@drawable/home"
|
||||
android:title="@string/home" />
|
||||
<item
|
||||
android:id="@+id/navigation_stats"
|
||||
android:icon="@drawable/notebook"
|
||||
android:title="@string/stats" />
|
||||
<item
|
||||
android:id="@+id/navigation_settings"
|
||||
android:icon="@drawable/settings"
|
||||
android:title="@string/settings" />
|
||||
</menu>
|
6
Project/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="@mipmap/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
BIN
Project/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
Project/app/src/main/res/mipmap-hdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 852 B |
BIN
Project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
Project/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
Project/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
Project/app/src/main/res/mipmap-mdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 459 B |
BIN
Project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
Project/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
Project/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
Project/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
Project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
Project/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
Project/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 25 KiB |
BIN
Project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 43 KiB |
7
Project/app/src/main/res/values-night/themes.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Project" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
6
Project/app/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="purpleLight">@android:color/system_secondary_container_light</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
74
Project/app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="add_new_data">Add New Data</string>
|
||||
<string name="adding_weight_for_user_id">"Adding weight for user_id "</string>
|
||||
<string name="app_name">Weight-Tracking App</string>
|
||||
<string name="authentication_failed">Authentication failed.</string>
|
||||
<string name="calendar">Date</string>
|
||||
<string name="checking_database_for_user">"Checking database for user "</string>
|
||||
<string name="configure_grid">Change Settings</string>
|
||||
<string name="congrats">Congrats!</string>
|
||||
<string name="congrats_on_reaching_your_goal">Congrats on reaching your goal!</string>
|
||||
<string name="congrats_on_reaching_your_goal_we_know_you_could_do_it">Congrats on reaching your goal, we know you could do it.</string>
|
||||
<string name="creating_new_database_with_tables">Creating new database with tables</string>
|
||||
<string name="current_weight">Current Weight:</string>
|
||||
<string name="database">Database</string>
|
||||
<string name="database_file">app.db</string>
|
||||
<string name="dateFormat">MM/dd/yy</string>
|
||||
<string name="date_header">Date</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="developer_name">Cody Cook</string>
|
||||
<string name="edit">Edit</string>
|
||||
<string name="edit_weight">Edit Weight</string>
|
||||
<string name="enter_weight">Enter weight</string>
|
||||
<string name="error_init_db">Error initializing database</string>
|
||||
<string name="failed_to_login_user">Failed to login user</string>
|
||||
<string name="failed_to_register_user">Failed to register user</string>
|
||||
<string name="go_back">Go Back</string>
|
||||
<string name="goal_met">Goal Met</string>
|
||||
<string name="goal_weight">Goal Weight:</string>
|
||||
<string name="grabbing_weights_in_for_user_id">"Grabbing weights in for user_id "</string>
|
||||
<string name="home">Home</string>
|
||||
<string name="kg">kg</string>
|
||||
<string name="lb">lb</string>
|
||||
<string name="log_into_your_account_or_register_a_new_one">Log into your account, or register a new one.</string>
|
||||
<string name="login">Login</string>
|
||||
<string name="login_error">Login error.</string>
|
||||
<string name="login_successful">Login successful!</string>
|
||||
<string name="loginactivity">LoginActivity</string>
|
||||
<string name="lose_gain">Lose/Gain</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="phoneNumber">+15551234567</string>
|
||||
<string name="record_goal">Set Goal</string>
|
||||
<string name="record_weight">Record Weight</string>
|
||||
<string name="register">Register</string>
|
||||
<string name="registering_new_user">"Registering new user "</string>
|
||||
<string name="registration_failed">Registration failed.</string>
|
||||
<string name="registration_successful">Registration successful!</string>
|
||||
<string name="request_sms_permission">Check SMS Permissions</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="sms_failed_to_send_please_try_again">SMS failed to send, please try again.</string>
|
||||
<string name="sms_permission_offer">We request SMS permissions to notify you about recording your weight and when you reach your goal weight.</string>
|
||||
<string name="sort">Sort\n</string>
|
||||
<string name="sort_by_date">Sort by Date</string>
|
||||
<string name="stats">Stats</string>
|
||||
<string name="the_app_s_logo">The app\'s logo.</string>
|
||||
<string name="to_gain">To Gain:</string>
|
||||
<string name="to_lose">To Lose:</string>
|
||||
<string name="unset">Unset</string>
|
||||
<string name="upgrading_database_due_to_version_change_wiping_data">Upgrading database due to version change; wiping data.</string>
|
||||
<string name="username">Username</string>
|
||||
<string name="validating_password_for_user">"Validating password for user "</string>
|
||||
<string name="weight">weight</string>
|
||||
<string name="weight_date">2024–04–01</string>
|
||||
<string name="weight_header">Weight</string>
|
||||
<string name="weight_must_be_between_20_kg_and_430_kg">Weight must be between 20 kg and 430 kg</string>
|
||||
<string name="weight_must_be_between_45_lbs_and_950_lbs">Weight must be between 45 lbs and 950 lbs</string>
|
||||
<string name="weight_scale">Weight</string>
|
||||
<string name="your_weight_journey">Your Weight Journey</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="userid">userId</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="entryid">entryId</string>
|
||||
<string name="iskg">isKg</string>
|
||||
</resources>
|
9
Project/app/src/main/res/values/themes.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Project" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Project" parent="Base.Theme.Project" />
|
||||
</resources>
|
13
Project/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
Project/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>
|
|
@ -0,0 +1,17 @@
|
|||
package edu.snhu.cs360.ccook.project;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
4
Project/build.gradle.kts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.androidApplication) apply false
|
||||
}
|
21
Project/gradle.properties
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
22
Project/gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,22 @@
|
|||
[versions]
|
||||
agp = "8.3.2"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
appcompat = "1.6.1"
|
||||
material = "1.11.0"
|
||||
activity = "1.9.0"
|
||||
constraintlayout = "2.1.4"
|
||||
|
||||
[libraries]
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
|
||||
[plugins]
|
||||
androidApplication = { id = "com.android.application", version.ref = "agp" }
|
||||
|
BIN
Project/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
Project/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Sat Apr 20 15:39:45 PDT 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
185
Project/gradlew
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
89
Project/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
24
Project/settings.gradle.kts
Normal file
|
@ -0,0 +1,24 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Project"
|
||||
include(":app")
|
||||
|