diff --git a/app/build.gradle b/app/build.gradle index ef4b465..7eb0a1e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ android { compileSdk 31 defaultConfig { - applicationId "com.bernard.calchulator" + applicationId "com.bernard.emorph" minSdk 21 targetSdk 31 versionCode 1 @@ -27,6 +27,7 @@ android { } buildFeatures { viewBinding true + dataBinding true } } @@ -34,10 +35,9 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' implementation 'androidx.navigation:navigation-fragment:2.3.5' implementation 'androidx.navigation:navigation-ui:2.3.5' - implementation 'com.jjoe64:graphview:4.2.2' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' diff --git a/app/src/androidTest/java/com/bernard/calchulator/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/bernard/calchulator/ExampleInstrumentedTest.java deleted file mode 100644 index d7c489a..0000000 --- a/app/src/androidTest/java/com/bernard/calchulator/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.bernard.calchulator; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.bernard.calchulator", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 97d6de1..a2ce6c0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,19 +1,37 @@ + package="com.bernard.emorph"> + android:theme="@style/Theme.AppCompat.Light.NoActionBar"> + android:name=".activities.GraphActivity" + android:exported="false" /> + + + + + + diff --git a/app/src/main/java/com/bernard/emorph/EMorphApplication.java b/app/src/main/java/com/bernard/emorph/EMorphApplication.java new file mode 100644 index 0000000..750dd31 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/EMorphApplication.java @@ -0,0 +1,923 @@ +package com.bernard.emorph; + +import android.app.Application; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +import com.bernard.emorph.model.Group; +import com.bernard.emorph.model.MeasureOnSubject; +import com.bernard.emorph.model.Subject; + +import java.util.ArrayList; +import java.util.List; + +public class EMorphApplication extends Application { + + public static final String APP_PREFERENCES_FILE = "emorph.prefs"; + public static final String DB_FILE = "app.db"; + + SQLiteDatabase db; + + @Override + public void onCreate() { + super.onCreate(); + EMorphDbHelper dbHelper = new EMorphDbHelper(getApplicationContext()); + db = dbHelper.getWritableDatabase(); + //putInitialData(db); + } + + @Override + public void onTerminate() { + super.onTerminate(); + db.close(); + } + + public List listGroups(){ + + Cursor dbResult = db.query("groups",new String[]{"ID","name"}, + null,null, null, null, null); + ArrayList list = new ArrayList<>(); + dbResult.moveToFirst(); + while(!dbResult.isAfterLast()) { + list.add(new Group(dbResult.getInt(0), dbResult.getString(1))); + dbResult.moveToNext(); + } + dbResult.close(); + return list; + } + + public List getSubjects(long groupID){ + Cursor dbResult = db.query("subjects",new String[]{"ID","name","dateNaissance"}, + "groupID=?",new String[]{Long.toString(groupID)}, null, null, null); + ArrayList list = new ArrayList<>(); + dbResult.moveToFirst(); + while(!dbResult.isAfterLast()) { + list.add(new Subject(dbResult.getInt(0), dbResult.getString(1), dbResult.getInt(2))); + dbResult.moveToNext(); + } + dbResult.close(); + return list; + } + + public long newGroup(String name){ + ContentValues cv = new ContentValues(); + cv.put("name", name); + return db.insert("groups", null, cv); + } + + public void removeSubject(long subjectID) { + db.delete("subjectID","ID=?", new String[]{Long.toString(subjectID)}); + } + + public void renameSubject(long subjectID, String newName) { + ContentValues cv = new ContentValues(); + cv.put("name", newName); + db.update("subjectID", cv,"ID=?", new String[]{Long.toString(subjectID)}); + } + + public long newSubject(String newName, int dateNaissance) { + ContentValues cv = new ContentValues(); + cv.put("name", newName); + cv.put("dateNaissance", dateNaissance); + return db.insert("subjects", null, cv); + } + + public boolean hasData(long groupID){ + Cursor result = db.query("measures",new String[]{"ID"},"groupID=?", new String[]{Long.toString(groupID)},null,null,null); + + boolean out = result.getCount()>0; + result.close(); + return out; + } + + + public String getGroupName(long groupID) { + Cursor result = db.query("groups",new String[]{"name"},"ID=?", new String[]{Long.toString(groupID)},null,null,null); + if(result.getCount()==0)return null; + result.moveToFirst(); + String out = result.getString(0); + result.close(); + return out; + } + + public String getSubjectName(long subjectId) { + Cursor result = db.query("subjects",new String[]{"name"},"ID=?", new String[]{Long.toString(subjectId)},null,null,null); + if(result.getCount()==0)return null; + result.moveToFirst(); + String out = result.getString(0); + result.close(); + return out; + } + + public long newMeasure(long groupMeasured){ + ContentValues values = new ContentValues(); + values.put("groupID", groupMeasured); + values.put("time", System.currentTimeMillis()/1000); + return db.insert("measures", null, values); + } + + public MeasureOnSubject newMOS(long measureID, + long subjectId, + float abdomen, + float bras, + float epaules, + float taille, + float cuisse, + float cheville, + float avantBras) { + + ContentValues values = new ContentValues(); + values.put("measureID", measureID); + values.put("subjectID", subjectId); + values.put("circAbdomen", abdomen); + values.put("circBras", bras); + values.put("circEpaules", epaules); + values.put("circTaille", taille); + values.put("circCuisse", cuisse); + values.put("circCheville", cheville); + values.put("circAvantBras", avantBras); + long newId = db.insert("measureOnSubject", null, values); + + return new MeasureOnSubject(newId, subjectId, abdomen, bras, epaules, taille, cuisse, cheville, avantBras); + } + + + public static class EMorphDbHelper extends SQLiteOpenHelper { + // If you change the database schema, you must increment the database version. + public static final int DATABASE_VERSION = 2; + // ,[0-9.]+,[0-9]+,[A-Za-zïçéèëà- ]+,[0-9]+,"[0-9,]+", + public static final String SQL_CREATE_GROUPS = + "CREATE TABLE `groups` (`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL UNIQUE); "; + public static final String SQL_CREATE_SUBJECTS = + "CREATE TABLE `subjects` (`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," + + "`name` TEXT NOT NULL UNIQUE,`groupID` INTEGER NOT NULL,`dateNaissance` INTEGER);"; + public static final String SQL_CREATE_MEASURES = + "CREATE TABLE `measures` (`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," + + "`groupID` INTEGER NOT NULL,`time` INTEGER NOT NULL);"; + public static final String SQL_CREATE_MOS = + "CREATE TABLE `measuresOnSubjects` (`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,`measureID` INTEGER NOT NULL," + + "`subjectID` INTEGER NOT NULL,`circAbdomen` REAL,`circBras` REAL,`circEpaules` REAL," + + "`circTaille` REAL,`circCuisse` REAL,`circCheville` REAL,`circAvantBras` REAL);"; + + public EMorphDbHelper(Context context) { + super(context, DB_FILE, null, DATABASE_VERSION); + } + public void onCreate(SQLiteDatabase db) { + Log.v("EMorphDbHelper", "Creating the database"); + db.execSQL(SQL_CREATE_GROUPS); + db.execSQL(SQL_CREATE_SUBJECTS); + db.execSQL(SQL_CREATE_MEASURES); + db.execSQL(SQL_CREATE_MOS); + + putInitialData(db); + } + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + Log.e("DBUpgrade", "I don't know how to upgrade the DB, it should work i guess ..."); + } + public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { + onUpgrade(db, oldVersion, newVersion); + } + } + + public static void putInitialData(SQLiteDatabase db){ + for (double[] testDatum : testData) { + ContentValues cv = new ContentValues(); + cv.put("ID", testDatum[0]); + cv.put("measureID", testDatum[1]); + cv.put("subjectID", testDatum[2]); + cv.put("circAbdomen", testDatum[3]); + cv.put("circBras", testDatum[4]); + cv.put("circEpaules", testDatum[5]); + cv.put("circTaille", testDatum[6]); + cv.put("circCuisse", testDatum[7]); + cv.put("circCheville", testDatum[8]); + cv.put("circAvantBras", testDatum[9]); + db.insert("measuresOnSubjects", null, cv); + } + for (Object[] testDatum : testData2) { + ContentValues cv = new ContentValues(); + cv.put("ID", (Integer)testDatum[0]); + cv.put("name", (String)testDatum[1]); + cv.put("groupID", (Integer)testDatum[2]); + cv.put("dateNaissance", (Integer)testDatum[3]); + db.insert("subjects", null, cv); + } + + for(int i=1;i<=15;i++){ + ContentValues cv = new ContentValues(); + cv.put("ID", i); + cv.put("name", "Groupe num "+i); + db.insert("groups", null, cv); + } + for(int i=1;i<=15;i++){ + ContentValues cv = new ContentValues(); + cv.put("ID", i); + cv.put("groupID", i); + cv.put("time", System.currentTimeMillis()/1000); + db.insert("measures", null, cv); + } + + + } + + public static final double[][] testData = {{1,1,1,26.4,64.5,28.5,33.3,108,86.5,92.3},{ + 2,1,2,27.7,60.4,27.8,28.9,100.9,86.6,91.3},{ + 3,1,3,26.6,64.5,27.3,31,111,90.2,98.5},{ + 4,1,4,23.2,54,24.7,25.3,103.1,72.6,75.5},{ + 5,1,5,25.6,54.3,27.8,29.5,105.5,75.5,81.5},{ + 6,1,6,27,65.7,28.8,32.6,105.5,87.9,90.8},{ + 7,1,7,27.2,59,26.8,29,109,83.7,90.5},{ + 8,1,8,24.3,55.7,25,28.7,100.5,77.5,82},{ + 9,1,9,26,56.6,26.4,28.4,111.5,78.8,84.2},{ + 10,1,10,28.8,68,30.5,36.4,117,97.8,106.4},{ + 11,1,11,28.5,71.5,28.6,33.4,99.8,95.8,104.6},{ + 12,1,12,25.8,54.3,26.3,27.8,106.5,74.5,76},{ + 13,1,13,28.6,68,29,35.6,112.1,96.7,103.1},{ + 14,1,14,27,64,26.7,30.9,106.6,96.8,99.2},{ + 15,1,15,27.6,74.4,29.5,34.5,113,113.5,117.8},{ + 16,1,16,26.8,60.9,28.8,33.2,111.2,86.6,90.1},{ + 17,1,17,27.3,63.2,26.9,29.4,97.6,89,94.3},{ + 18,1,18,25.3,54.8,24.4,25.6,99.2,77.3,78.7},{ + 19,1,19,24.9,54.1,25,27.8,97,73.7,79.4},{ + 20,1,20,27.2,60.4,27.3,29,110.4,81,86},{ + 21,1,21,25,59.6,24.5,27.5,98.2,82.3,89},{ + 22,1,22,26.7,63.1,26.6,32.5,99.5,81.8,90.4},{ + 23,1,23,26.5,56.5,28,30,113.8,73.5,79},{ + 24,1,24,25.2,59.8,24.8,28.5,95.5,81.5,84.5},{ + 25,1,25,28.2,62.5,26.6,29.5,102,80.9,84.5},{ + 26,1,26,25.2,53.8,26.2,27.1,104.8,72.7,78.5},{ + 27,1,27,26.6,56.1,26.5,27.7,102,71,75.6},{ + 28,1,28,25.8,63.3,28,28.8,108.9,81.5,84},{ + 29,1,29,28.7,65.5,28.8,32.8,111.5,88.4,102.1},{ + 30,1,30,24.7,56,24.4,26.5,102.5,73,82.7},{ + 31,1,31,26.5,65,27.2,31.3,100,94.5,97.8},{ + 32,1,32,26.9,61.7,29.3,33.6,119,80,83},{ + 33,1,33,27.5,62,27.4,29.1,120,89.9,98},{ + 34,1,34,27,53,26.4,27,107.5,70,73.1},{ + 35,1,35,25.1,52.3,25.6,24.9,100.1,72.7,80.1},{ + 36,1,36,27.2,63.2,28.2,32.8,104.6,85,87.8},{ + 37,1,37,29.9,78.2,30.3,34.9,110.2,116.3,115.4},{ + 38,1,38,25,58.4,27,30.2,98.7,92.3,97},{ + 39,1,39,35.7,66.8,26.4,29.2,102.2,97.2,106.7},{ + 40,1,40,24.1,56.6,24.2,26.5,98.6,84,87.9},{ + 41,1,41,25.5,65,27,30,103,88.5,89.8},{ + 42,1,42,25.2,54.5,24.4,26.8,96,71.6,77},{ + 43,1,43,27,60.1,26.3,28.2,96,84.8,89},{ + 44,1,44,28.2,56,28.5,28.6,108,73.5,77},{ + 45,1,45,25,69.4,30.4,35.7,117.8,96.5,106.5},{ + 46,1,46,27.1,68.9,31.4,33.3,117.9,98.4,101.4},{ + 47,1,47,24.8,58.9,26.3,27,97.5,74.8,80},{ + 48,1,48,26.9,50,24.5,24.4,103,74,79.5},{ + 49,2,49,27.8,51.3,25.3,26.5,105.5,72.9,78.2},{ + 50,2,50,26.6,64.2,26.5,32.4,102.6,84.8,92.3},{ + 51,2,51,27.4,63.2,28.7,31,110,93,98.5},{ + 52,2,52,27.4,71.1,28.9,31,112,94.5,105},{ + 53,2,53,26.7,64.3,28.1,31.9,104.8,89.7,94.5},{ + 54,2,54,26.7,61.3,29.5,32.6,111.6,87.6,93},{ + 55,2,55,28.3,74.8,28.7,35.6,124.6,114,121},{ + 56,2,56,26,71.4,30.6,33.9,107.1,100.3,105.2},{ + 57,2,57,26.8,74,29.2,33,116.2,98.5,109.5},{ + 58,2,58,27.3,63.6,29.9,34.5,117.4,90.2,98.1},{ + 59,2,59,27.3,63.8,27.8,30.7,101.6,83.6,87.9},{ + 60,2,60,28.6,66.6,29.1,32.2,109,94,100.7},{ + 61,2,61,27.7,53.1,26,26,102.6,72.5,76.5},{ + 62,2,62,28,61,27.5,30.8,110.2,93.5,100.7},{ + 63,2,63,27.5,62.8,28.8,31.3,110,78.6,79.4},{ + 64,2,64,24.5,51.5,24,24.8,96,66.5,72.2},{ + 65,2,65,25.5,61.5,25.6,29.3,104.6,85,92},{ + 66,2,66,27,57.9,24.6,26.5,101.3,82.9,88.6},{ + 67,2,67,26.2,54.1,24.8,25.4,95.7,70.2,79.5},{ + 68,2,68,25.8,56.6,28.2,28.7,109.5,74,78.4},{ + 69,2,69,28.2,68.6,31.3,34.7,110.5,93.7,102.7},{ + 70,2,70,27.3,61.8,29.8,31.2,108.6,82.6,88.4},{ + 71,2,71,31.2,67.6,31.6,33.1,119.2,97.1,100.7},{ + 72,3,72,25.9,47.8,23.7,22.8,92.7,69.3,76.8},{ + 73,3,73,26.2,48.9,24,24.5,92,68,73.8},{ + 74,3,74,25.8,51.5,23.8,25.7,99.4,71,75.3},{ + 75,3,75,27.7,54.7,23.7,24.9,103,73.4,79.2},{ + 76,3,76,27.6,67,29.2,31.7,108.4,92,97.9},{ + 77,3,77,25.1,63.4,26.9,29.1,109.7,81.4,83},{ + 78,3,78,24.4,59.8,26.1,28.4,104,81,83.5},{ + 79,3,79,29.8,63.2,28.5,32,111,88.2,96.5},{ + 80,3,80,28.1,66.4,28.1,34.7,103.5,104.7,109.5},{ + 81,3,81,24.8,47.9,24.8,22.5,101.7,70.5,73.2},{ + 82,3,82,27,51.8,25.8,26.5,103.5,74.4,78.1},{ + 83,3,83,28.7,66.8,28,31.5,108.4,92.9,99.1},{ + 84,3,84,26.2,65.7,26.8,30.2,100.4,86.2,91.5},{ + 85,3,85,26.3,60.8,27.3,29.6,103.2,92.2,96.7},{ + 86,3,86,26.5,54,24.5,25.3,99,76,81},{ + 87,4,87,27.5,60.8,27.7,30.9,106.6,78.2,86.1},{ + 88,4,88,27,65.5,29,31.3,113.5,86,94.5},{ + 89,4,89,27.9,63.4,25.6,30.6,101.7,87.3,99.1},{ + 90,4,90,27.5,59.3,28.1,31.3,105.9,83,89.8},{ + 91,4,91,28.7,76.3,30.8,33,118,111.5,118.6},{ + 92,4,92,27.5,53.7,25,26.5,98.7,70,77},{ + 93,4,93,28,55,26.5,27.2,102.2,77.7,83},{ + 94,5,94,26,68,27.7,32.6,110.2,106.5,110.7},{ + 95,5,95,28.8,70.4,29.2,34.1,99.3,101.7,105.3},{ + 96,5,96,26.5,50.8,24.5,25,100.5,70,76},{ + 97,5,97,27.6,66,28.5,34,106,104.5,110.8},{ + 98,5,98,27.4,55.3,25.5,27,100,74,83.2},{ + 99,5,99,23.5,40.5,22.2,21.5,87.8,63,66.8},{ + 100,5,100,27,68.8,26.9,31.9,106.7,103.5,113.2},{ + 101,5,101,28.3,58.1,26.6,29.8,107.5,81.4,88.4},{ + 102,5,102,25.3,67,28.5,31.9,105,93.4,104},{ + 103,5,103,24.3,50,25,25.2,102.5,74.1,74.5},{ + 104,5,104,25.2,56.4,25.7,29,108.5,76.8,81.1},{ + 105,5,105,25.5,57.5,23.6,27.4,89.5,79.9,86.1},{ + 106,5,106,26,57.2,24.9,29,103.5,91.4,98.4},{ + 107,5,107,25.8,53.3,25.5,25.8,93.5,74.6,81.3},{ + 108,5,108,26.3,66.5,27.1,28.6,112,97.6,107.3},{ + 109,5,109,25.2,58.7,24.8,28,94,83.8,89},{ + 110,5,110,27.1,80.3,30.8,36.6,113.7,102.7,113.2},{ + 111,5,111,25.6,64.5,25,29.3,104.4,87.3,97.3},{ + 112,5,112,25,49.1,24.2,24.3,93.2,71,73.2},{ + 113,5,113,24.8,60.5,27,30.5,105.2,85,92},{ + 114,5,114,25,63.8,27.5,31.3,104.1,84.5,87.2},{ + 115,5,115,24,50.7,24.8,25.2,98,76.3,83},{ + 116,5,116,26.4,55,25.9,27.5,99,69.2,74.5},{ + 117,5,117,28.7,60,26.3,28.8,102.3,83.5,89},{ + 118,5,118,26.2,57.4,25.3,26.5,105.3,76.6,82.3},{ + 119,5,119,25.6,57.1,25.8,28.9,91.7,79.4,89.3},{ + 120,5,120,26.3,57.2,25.6,31,100.5,85.5,89},{ + 121,5,121,28.6,60.5,27.9,29.5,108.8,80.5,88.9},{ + 122,6,122,26,58.3,26.5,30,102,85.5,90.4},{ + 123,6,123,26.9,63.4,27.7,32.7,106.7,85.3,89.6},{ + 124,6,124,24.7,58,25.4,27.9,93.3,80.1,85.6},{ + 125,6,125,26.5,58.5,27.7,29.2,104.4,78.3,85},{ + 126,6,126,26.8,62.5,27.9,32.9,109.8,89.7,95.4},{ + 127,6,127,27.1,63.7,27.1,30,98.7,79.6,88.5},{ + 128,6,128,26.9,52,25.7,25.5,102.7,72.2,76.3},{ + 129,7,129,27.9,54.5,26.4,26.5,104,76,80.2},{ + 130,7,130,25.4,54.5,26,28.5,99,74.7,83.7},{ + 131,7,131,26.9,58.6,26,27.5,108.7,75.5,86.5},{ + 132,7,132,25.9,57.3,25.6,26.4,98.8,89,89.7},{ + 133,7,133,25.3,70.9,27.8,32.2,106.3,97.8,103.2},{ + 134,7,134,25.4,56.4,25.4,26.5,97.5,80.8,88},{ + 135,7,135,27.2,66.8,25.5,29.3,106.3,92.4,103.5},{ + 136,7,136,23,52.3,23.5,25.5,91,75.5,82.2},{ + 137,7,137,24.6,57.5,25.1,27.1,93.2,74.7,80},{ + 138,7,138,24.7,54.3,25.8,27.3,92.7,69.5,72.2},{ + 139,7,139,25.6,45,23.5,23.1,97.6,69.9,73.6},{ + 140,7,140,27.4,59.8,25.6,30.3,100.3,88,94.2},{ + 141,7,141,23.3,45.2,20.7,20.3,83.5,63.6,66.7},{ + 142,7,142,27.1,58.3,26.4,29,100.1,77.6,84.1},{ + 143,7,143,27.7,60.5,27,30,100.2,86.3,90.1},{ + 144,7,144,28.2,62.9,26.4,29.3,103,85.2,91},{ + 145,7,145,27.7,49.5,25.7,27.5,93.4,80.2,85.6},{ + 146,7,146,26.2,59,27.2,28.7,102.2,82.2,90.5},{ + 147,7,147,24.2,50.7,24,25.2,86.7,76.7,83.2},{ + 148,7,148,23.9,45,21.8,21.9,95.7,64.6,70.8},{ + 149,7,149,27.1,54.3,26.1,26.8,98.2,74.5,78.9},{ + 150,7,150,25.5,46.6,23.2,25.4,89.7,71.7,76.6},{ + 151,7,151,26.6,54.3,25.5,27.4,90.5,73.7,77},{ + 152,7,152,25.7,48.5,23.8,25.3,92.5,75.7,80},{ + 153,7,153,27.3,64,25.7,29,95.7,88.8,95.3},{ + 154,7,154,27.4,49.2,23.3,25.2,89.1,76.2,80.2},{ + 155,7,155,22.7,47.1,23.5,23.4,93.2,69.3,68.4},{ + 156,7,156,27.5,49.8,24.9,25.1,98.3,68.2,77.6},{ + 157,7,157,27.3,62.9,27.1,30.7,103.2,94.2,97.9},{ + 158,7,158,25.7,49,24.8,23.7,92.2,68.4,72.2},{ + 159,7,159,25,53.2,25,27.9,91.5,74.6,83.7},{ + 160,7,160,26.9,50.5,24,26.6,93.5,68.7,72.9},{ + 161,7,161,26.5,58,25.5,27.9,96.8,78,84.2},{ + 162,7,162,23.7,43.4,20.9,21.5,88.1,63.5,63.7},{ + 163,7,163,25.2,43.7,21,21.6,85.8,65.5,67.6},{ + 164,7,164,24.6,53.6,23.7,24.4,79,70.2,73.2},{ + 165,7,165,26.8,51,26.1,27.1,96.7,77.8,86.8},{ + 166,8,166,24.2,47.3,23.5,22.3,95.7,66.4,68.9},{ + 167,8,167,26.1,59.5,26.2,27.2,92.2,80.1,84.7},{ + 168,8,168,23.3,47,23.6,24,77.6,63.3,68.2},{ + 169,8,169,20.8,45.4,20.5,21.3,86.3,63.3,69.1},{ + 170,8,170,28.4,59,27.7,21.7,94.3,89.5,96.7},{ + 171,8,171,25.2,53.7,24.7,26.4,95.8,76.5,83.1},{ + 172,8,172,22.6,38.2,19.8,19,74.1,58.4,51.1},{ + 173,8,173,25.2,52.6,25.5,27.2,92.6,80.1,85.6},{ + 174,8,174,24.5,50.5,25.4,25.9,88.8,71.7,73.7},{ + 175,8,175,24,41.1,21.2,20.6,80.2,65.1,63.5},{ + 176,8,176,21.1,44.5,21.6,20.1,82.7,63.1,65},{ + 177,8,177,26.2,54.1,23.6,25.8,87.5,76.9,82.3},{ + 178,8,178,26.1,50.7,24.9,27.3,92,83.9,90},{ + 179,8,179,21.5,47,21,21.7,80.5,63.5,66.2},{ + 180,8,180,24.3,56.5,25.2,26.3,95.8,86.1,89.8},{ + 181,8,181,26.9,54.7,25.9,27.4,101.7,82.3,91.5},{ + 182,8,182,19.5,39.2,19.1,19.5,79.1,59.3,58.7},{ + 183,8,183,24.2,42.7,20.9,20.9,81.7,63.7,63.8},{ + 184,8,184,25.6,60.2,26.1,28.7,93.9,76.4,85.2},{ + 185,8,185,24.5,44.6,21.5,21.2,83.7,63.3,67.3},{ + 186,8,186,23.7,40.1,20.1,20.1,78.1,59.9,64.8},{ + 187,8,187,21.2,44.5,20.6,20.8,78.5,61.7,62.7},{ + 188,9,188,24.9,54.2,24.6,25.6,86.6,82.7,88.4},{ + 189,9,189,23.3,44.5,22.9,22.1,76.2,61.8,64.6},{ + 190,9,190,22.1,44.6,22.1,23.4,83.3,69.9,72.5},{ + 191,9,191,23.9,44.7,23.3,22.4,84.6,68,67.9},{ + 192,9,192,24.1,51.2,24.9,28.3,90.5,81.9,86.7},{ + 193,9,193,23.2,48.9,22.7,23.6,82.5,62.5,67.8},{ + 194,9,194,24.6,50.5,24.2,26.5,92.5,70.8,76.7},{ + 195,9,195,24.8,51.4,22.5,23.1,96.5,70.1,71.6},{ + 196,9,196,23.7,44.2,21,21.4,84,62.1,70.3},{ + 197,9,197,24,49.5,22.9,22.8,91,69,69.6},{ + 198,9,198,28.2,57.9,26,27.2,97,76.7,83.3},{ + 199,9,199,23.8,48.7,22.5,22.3,86.5,65.5,71.6},{ + 200,9,200,25.4,63,25,28.3,93.9,82,89},{ + 201,9,201,26.5,53.8,25.5,26.6,96.6,73.5,77.2},{ + 202,9,202,24.2,54.3,23.6,26.4,87,69.8,74},{ + 203,9,203,22.6,43.9,20.5,19.9,82.5,63.5,64.4},{ + 204,9,204,25.4,26.8,24.7,27.1,91.3,75,77.3},{ + 205,9,205,24.3,55.9,24.5,25.8,96.9,72.9,80.9},{ + 206,9,206,24.9,61.7,23.9,28,91.6,76.4,92.3},{ + 207,9,207,23,51,21.8,24.4,87.5,71.4,75.6},{ + 208,9,208,22.2,48.6,21.1,24.3,82.3,63.9,67.6},{ + 209,9,209,27.5,71,29.6,32.8,109.2,101,107.1},{ + 210,9,210,26.8,55.4,24.7,25.4,100,74.5,81},{ + 211,9,211,24.4,56.1,23.9,26.3,85.8,76.5,85},{ + 212,9,212,23.1,58,23.5,27.7,92.3,79.6,89.8},{ + 213,9,213,20.2,50.3,23.7,24,91.3,71,73.5},{ + 214,10,214,23,36.5,21.3,19.7,80.2,60.1,65},{ + 215,10,215,23.2,47.2,23.3,24.7,84.8,70.2,73.8},{ + 216,10,216,24.5,54.3,25.2,29.5,94.9,80.9,88.9},{ + 217,10,217,24.7,46.9,22.9,26.4,69.4,67.7,75.7},{ + 218,10,218,25,51.5,22.7,23.4,88.5,69.4,76.8},{ + 219,10,219,24.2,50.4,22.5,22.2,92.3,70.3,75},{ + 220,10,220,24.1,49.1,23.7,26.6,87,74.4,83.1},{ + 221,10,221,23.1,49.9,23.9,25.9,87.8,78.5,85.1},{ + 222,10,222,24.6,52.7,23,23.2,86.2,69.2,70.4},{ + 223,10,223,22.6,49,24,25.6,94.4,74.1,78.2},{ + 224,10,224,21.7,51.2,22.5,23.5,86.6,68.3,71.1},{ + 225,10,225,21.5,36.5,18.5,19,77.4,61.7,63.7},{ + 226,10,226,23.6,51.8,23.2,25.9,84.5,74.7,79},{ + 227,10,227,21.6,42.1,19.4,18.6,80.4,62.8,68.8},{ + 228,10,228,23.5,50.9,21.9,24.3,80.5,75.6,79.7},{ + 229,10,229,24.8,46.4,22.4,22.6,80.6,58.8,67},{ + 230,10,230,26.8,61,26.1,30.2,93.2,84.2,92.9},{ + 231,10,231,23.6,46.1,21.9,21,81.2,63.5,63.8},{ + 232,10,232,25.3,50,22,23,89.5,77.7,81.3},{ + 233,10,233,24.8,48.7,23.7,24.9,88.2,66.5,72.7},{ + 234,10,234,24.2,60.2,25.5,30.7,91.9,85,89.1},{ + 235,10,235,22.4,40.7,20,20.2,84.7,63.9,65.7},{ + 236,10,236,23.8,52.1,21.7,24.9,88.5,69.8,75.8},{ + 237,11,237,22.1,47,21.2,22,78.4,68.4,72.3},{ + 238,11,238,22.1,54.5,24.2,26,89.6,77.6,83.1},{ + 239,11,239,23.7,43.6,20.7,20.2,82,63.8,64.5},{ + 240,11,240,22.3,47.8,22,23.3,85.1,69.2,70.3},{ + 241,11,241,24.5,57.3,23.6,25.9,89.4,79.6,82.5},{ + 242,11,242,22.3,47.8,22,23.3,85.1,69.2,70.3},{ + 243,12,243,20.6,46.5,20.9,23,79.6,64.5,64.9},{ + 244,12,244,20.5,39.1,18.4,18.4,77,57,60.5},{ + 245,12,245,23.3,51.3,21.2,24.7,85,72.1,76.2},{ + 246,12,246,21.1,43.9,21.6,22,83.5,66,64.2},{ + 247,12,247,20.8,46.6,24.9,24.1,86.8,67.2,68.9},{ + 248,12,248,27.2,60.5,25,28.9,97.5,80.5,88.6},{ + 249,12,249,23,43.9,20.2,21.3,80.9,66.2,67.5},{ + 250,12,250,21.5,44.5,20.6,21.9,85.5,62.3,65.3},{ + 251,12,251,24,47.1,22.5,21.9,84.3,63,62.3},{ + 252,12,252,23.5,53.7,22.1,25.2,87,71,74.5},{ + 253,12,253,25.6,51.6,24.7,25.9,92.3,70,75},{ + 254,12,254,25,50.5,24.2,24.5,94.8,70.1,73},{ + 255,12,255,24,49.2,20.9,22.4,82.5,67.5,73},{ + 256,12,256,22,39.5,20,19.9,82.5,58,61.5},{ + 257,12,257,21.7,47.3,21.2,22.6,86.6,66.4,67.6},{ + 258,12,258,26.4,50.3,23.1,22.5,89.4,70,75.3},{ + 259,12,259,24,45.5,20.7,22.3,80.6,66.7,67.3},{ + 260,12,260,24,48.2,22.1,23.5,85.5,69.2,71.8},{ + 261,12,261,22.1,40.8,21.3,21.5,84.8,70.1,72.3},{ + 262,12,262,23.3,40.9,21.4,21.6,77.2,65.3,71.9},{ + 263,12,263,21.4,42.5,19.5,19.6,80.4,66.7,66.6},{ + 264,12,264,22,46,21.6,22.5,85.2,65.6,68.1},{ + 265,12,265,21.5,39.8,20.2,20.3,80.5,61.5,63.5},{ + 266,12,266,21.4,39.6,19.7,19.6,75.3,60.2,63.8},{ + 267,12,267,21.8,42.6,20.6,20.1,81.6,59.2,61.8},{ + 268,12,268,23.6,42.9,22.9,22.7,78.1,64.8,67.3},{ + 269,12,269,23.4,43.2,22,21.4,84.4,67,69.7},{ + 270,12,270,25.2,57.2,25,29.9,95.2,78.4,85.4},{ + 271,12,271,25.4,48.8,22.5,24.4,88.4,70.4,76.1},{ + 272,12,272,22.8,41.9,21.1,22.2,79,63.6,66.2},{ + 273,12,273,23.6,40.3,20.3,19,76.5,60.2,61.5},{ + 274,12,274,24.2,48.2,23.2,26.1,88.8,70.2,76.4},{ + 275,12,275,20.2,30.9,19.6,19,74.9,59.2,57.4},{ + 276,12,276,22.1,50,22.6,24.7,87.7,74.6,81.4},{ + 277,12,277,24.4,46.3,21.9,22.2,82.7,60.1,64.7},{ + 278,12,278,23.2,46.9,22.9,23.1,83.5,65.2,69.5},{ + 279,13,279,24.1,51.9,23.3,25,83.7,81.6,83},{ + 280,13,280,23.9,48.3,22.2,22.5,79.6,64.9,67.9},{ + 281,13,281,22.6,42.8,21.5,20.9,80.8,61.1,62.5},{ + 282,13,282,22.1,39.7,20.2,19.1,79.2,58.3,63.1},{ + 283,13,283,23.3,46.2,21.5,21.1,80.6,64.9,64.5},{ + 284,13,284,21.6,46.5,20.7,22.9,79.6,69.5,75},{ + 285,13,285,21.2,37.7,19.9,18.7,77,57.6,57.1},{ + 286,13,286,22.6,47.6,22.8,24.5,85.4,72,75.4},{ + 287,13,287,22.1,54.1,23.7,24.6,86.9,65.5,76.5},{ + 288,13,288,23.7,52.8,21.6,23,85.2,69.5,76.9},{ + 289,13,289,21,38.1,18.5,17.7,75.8,60.9,61.4},{ + 290,13,290,22.5,39,19.1,18.1,77,66.9,60.7},{ + 291,13,291,21.6,45.5,20.4,20.6,83,60.5,65.8},{ + 292,13,292,22.8,41.3,20.7,20.4,75.2,61.9,61.4},{ + 293,13,293,22.1,46.8,22.3,22.3,78.6,65.8,68.4},{ + 294,13,294,23.3,43.2,22,22.2,79.6,59.5,61.8},{ + 295,13,295,26.6,63.4,26.3,30.7,100.5,97.9,100.9},{ + 296,13,296,23.5,48.5,20.9,23.1,76.7,68.8,72},{ + 297,13,297,22.7,42.2,20.5,22.5,78.3,68.6,70.2},{ + 298,13,298,22.4,48.5,23,24.4,85.3,71.3,75.2},{ + 299,13,299,21.1,42,20,20.2,74.5,63.8,69.1},{ + 300,13,300,22.1,43.4,20.6,20.2,78.5,59.2,65.1},{ + 301,13,301,23.7,45.9,21.7,21.7,85.2,67.2,69.4},{ + 302,13,302,20.7,39.5,18,17.6,76.5,57.2,57.6},{ + 303,13,303,24.5,48.8,23,23.5,86.9,68,68.2},{ + 304,13,304,23.3,54.5,22.1,25.5,82.9,68.4,73},{ + 305,13,305,22.8,52.6,23,26.8,90.8,80.6,84.4},{ + 306,13,306,24,43.9,21.4,20.5,83.3,69.5,65.8},{ + 307,13,307,22,47.8,20.9,22.2,89,63,69.5},{ + 308,13,308,24.6,55.4,24.3,26.6,94.5,81.5,78.4},{ + 309,13,309,25.7,60.3,26.6,30,102.5,91.5,94},{ + 310,13,310,24.2,55,21.5,23,93,71,79.3},{ + 311,13,311,23.4,51.7,22,24.4,87,73.5,76.5},{ + 312,13,312,22.6,42.9,21.6,21.9,81.2,59.9,60.5},{ + 313,13,313,21.7,43.6,20.3,21.3,76.3,62.3,67.2},{ + 314,13,314,23.7,47.1,23.2,25,86.7,67.7,69.1},{ + 315,13,315,22.1,38,19.7,18,75.2,60.2,62.6},{ + 316,13,316,21.6,47.2,21,22.7,80.6,65.8,71.5},{ + 317,13,317,23.3,48.7,24.1,26.4,84.5,72.2,79.8},{ + 318,13,318,22.5,43.5,21.3,21.3,80.7,66,66.5},{ + 319,13,319,19.6,39.3,18.7,18.8,77.2,57.5,60.3},{ + 320,13,320,22.8,50,21.6,24.4,84.8,72.5,79.2},{ + 321,14,321,24.1,49.6,23.6,23.4,85.2,70,70.4},{ + 322,14,322,20.9,44.1,21.4,22.2,78.1,62.1,67},{ + 323,14,323,21.3,39.2,19.5,19.1,78.7,59.4,61.8},{ + 324,14,324,22.3,41.9,21.2,22,80.6,63.7,63.2},{ + 325,14,325,20,41.7,21,20.5,73.8,61.8,64.2},{ + 326,14,326,22.6,40.9,21.6,21.8,81.4,63.5,65.7},{ + 327,14,327,24.3,51.9,23.3,24.8,83.8,68.8,74.5},{ + 328,14,328,22.7,48,22.5,23.9,75.7,64.8,67.7},{ + 329,14,329,21.1,40.3,19.5,18,75.2,57.3,56.5},{ + 330,14,330,20.8,44.7,20,21.3,76.7,65.8,64.5},{ + 331,14,331,20.3,39.4,18.3,18.1,70.9,58.3,59.6},{ + 332,14,332,22.8,50,23.9,25.9,86.6,71.6,75},{ + 333,14,333,22.3,40.9,20.2,19.6,81.5,60.8,63.9},{ + 334,14,334,24.2,50.3,23.4,24.8,88.1,72,75.4},{ + 335,14,335,24.2,49.9,23.1,25,88.7,73.9,79.9},{ + 336,14,336,22.4,41.6,20.4,20.6,78.1,61,62.9},{ + 337,14,337,22.5,46.9,21.5,22.3,81,63.5,64.6},{ + 338,14,338,24.2,48.7,22.3,23.7,83.4,67.2,69.9},{ + 339,14,339,21.5,39.1,18.7,18.5,78.2,56.6,59},{ + 340,14,340,21.3,40.6,20.3,19.6,77.1,59,65.4},{ + 341,14,341,23.7,51.5,22.9,24.7,89.2,73.6,77.2},{ + 342,14,342,23.5,44.2,19.6,19.7,77.4,59.4,62.6},{ + 343,14,343,23.4,51.1,22.5,25,90.2,76.6,78.3},{ + 344,14,344,23,48.3,24.5,23.2,83.5,70.5,78},{ + 345,15,345,23.7,49.3,21.5,22.4,86,68.1,74.8},{ + 346,15,346,20.5,41.1,19.8,21.5,78.6,61.5,64.4},{ + 347,15,347,23.2,47.7,21.9,24,83.6,72,74.5}}; + + public static final Object[][] testData2 = {{1,"Sylviane",1,1618039019}, + {2,"Perrine",1,1618067838}, + {3,"Friedrich",1,1618089452}, + {4,"Fabrice",1,1618121873}, + {5,"Florian",1,1618136283}, + {6,"Aude",1,1618183113}, + {7,"Adam",1,1618204728}, + {8,"Jonas",1,1618219137}, + {9,"Freddy",1,1618229944}, + {10,"Pascaline",1,1618233546}, + {11,"Anaïs",1,1618251558}, + {12,"Marie-Joseph",1,1618269570}, + {13,"Yannick",1,1618280377}, + {14,"Chiara",1,1618283980}, + {15,"Simone",1,1618298389}, + {16,"Allan-David",1,1618312799}, + {17,"Ulrika",1,1618327208}, + {18,"Claire",1,1618327208}, + {19,"Tito",1,1618348822}, + {20,"Jennifer",1,1618363232}, + {21,"Nasser",1,1618377641}, + {22,"Marie-Claire",1,1618406460}, + {23,"Samantha",1,1618478507}, + {24,"Fabio",1,1618492917}, + {25,"Joaquim",1,1618496519}, + {26,"Stefanie",1,1618503724}, + {27,"Marieva",1,1618514531}, + {28,"Marie-Reine",1,1618521736}, + {29,"Lyna",1,1618543350}, + {30,"Benjamin",1,1618586578}, + {31,"Suzanna",1,1618608193}, + {32,"Alexander",1,1618622602}, + {33,"Willem",1,1618633409}, + {34,"Brian",1,1618637012}, + {35,"Marie-Françoise",1,1618647819}, + {36,"Stewart",1,1618716264}, + {37,"Jean-Max",1,1618737878}, + {38,"Anne-Marie",1,1618748685}, + {39,"Florence",1,1618752287}, + {40,"Miloud",1,1618755890}, + {41,"Eléonore",1,1618784709}, + {42,"Natacha",1,1618795516}, + {43,"Ulla",1,1618799118}, + {44,"Zoubida",1,1618799118}, + {45,"Ludovic",1,1618817130}, + {46,"Estelle",1,1618824335}, + {47,"Tanguy",1,1618845949}, + {48,"Bruno",1,1618853154}, + {49,"Ian",2,1618853154}, + {50,"Marianne",2,1618853154}, + {51,"Adolf",2,1618867563}, + {52,"Lauretta",2,1618881973}, + {53,"Jeanine",2,1618896382}, + {54,"Reynald",2,1618979236}, + {55,"Emmanuelle",2,1619008055}, + {56,"Anne-Charlotte",2,1619026067}, + {57,"Anna-Lisa",2,1619029670}, + {58,"Ludiwine",2,1619029670}, + {59,"Magaly",2,1619094512}, + {60,"Roselyne",2,1619108922}, + {61,"Johanna",2,1619130536}, + {62,"Erick",2,1619130536}, + {63,"Alain",2,1619162957}, + {64,"Marine",2,1619180969}, + {65,"Maria",2,1619191776}, + {66,"Colette",2,1619191776}, + {67,"Oswald",2,1619198981}, + {68,"Carlo",2,1619213390}, + {69,"Hector",2,1619216993}, + {70,"Antoni",2,1619267426}, + {71,"Pierre-Alain",2,1619278233}, + {72,"Joëlle",3,1619357485}, + {73,"Andrea",3,1619357485}, + {74,"Cendrine",3,1619400713}, + {75,"Franck",3,1619411521}, + {76,"Manuela",3,1619429532}, + {77,"Raymonde",3,1619458351}, + {78,"Julien",3,1619483568}, + {79,"Gervais",3,1619505182}, + {80,"Marie-Joëlle",3,1619508784}, + {81,"Jean-Francis",3,1619526796}, + {82,"Mylène",3,1619606048}, + {83,"J.M.",3,1619616855}, + {84,"Xavier",3,1619660084}, + {85,"Jean-Noël",3,1619667289}, + {86,"Sylvette",3,1619685300}, + {87,"Eugénie",4,1619688903}, + {88,"Gad",4,1619710517}, + {89,"Miguel",4,1619714119}, + {90,"Augusta",4,1619714119}, + {91,"Raymond",4,1619717722}, + {92,"Habib",4,1619735734}, + {93,"Laetitia",4,1619750143}, + {94,"Guy",5,1619829395}, + {95,"François",5,1619836600}, + {96,"Lucy",5,1619847407}, + {97,"Thierry",5,1619858214}, + {98,"Séverine",5,1619869021}, + {99,"Gabriel",5,1619876226}, + {100,"Jurgen",5,1619876226}, + {101,"Rolande",5,1619876226}, + {102,"Jean-Luc",5,1619915852}, + {103,"Brice",5,1619919454}, + {104,"Patricia",5,1619926659}, + {105,"Tomy",5,1619955478}, + {106,"Alan",5,1619955478}, + {107,"Nathan",5,1619977092}, + {108,"Renaud",5,1619977092}, + {109,"Bruce",5,1620049140}, + {110,"Benaïcha",5,1620088766}, + {111,"Josephus",5,1620113982}, + {112,"Léo",5,1620200439}, + {113,"Célia",5,1620204041}, + {114,"Franz-Georg",5,1620236463}, + {115,"Reinhard",5,1620250872}, + {116,"Renato",5,1620254474}, + {117,"Yolande",5,1620254474}, + {118,"Dounia",5,1620276089}, + {119,"Juliana",5,1620290498}, + {120,"Bérengère",5,1620301305}, + {121,"Fanny",5,1620301305}, + {122,"Sandrino",6,1620315715}, + {123,"Dany",6,1620330124}, + {124,"Nicole",6,1620333727}, + {125,"Nathalie",6,1620337329}, + {126,"Mark",6,1620409376}, + {127,"Alison",6,1620449002}, + {128,"Francis",6,1620456207}, + {129,"Mohammad",7,1620528254}, + {130,"Yvonne",7,1620564278}, + {131,"Jean-Loïc",7,1620567880}, + {132,"Cyril",7,1620571483}, + {133,"Jean-François",7,1620589495}, + {134,"Fernand",7,1620600302}, + {135,"Rudy",7,1620600302}, + {136,"Sidonie",7,1620632723}, + {137,"Lucette",7,1620661542}, + {138,"Chrystel",7,1620665144}, + {139,"Karl-Otto",7,1620675951}, + {140,"Jean-Hugues",7,1620697566}, + {141,"Lorenzo",7,1620766011}, + {142,"Brian-John",7,1620780420}, + {143,"Aurélien",7,1620787625}, + {144,"Sandie",7,1620856070}, + {145,"Lawrence",7,1620859672}, + {146,"Maïté",7,1620859672}, + {147,"Vladimir",7,1620884889}, + {148,"Judith",7,1620931719}, + {149,"Madeline",7,1620946129}, + {150,"Annabel",7,1620953334}, + {151,"Marco",7,1621010972}, + {152,"Marie-Paule",7,1621054200}, + {153,"Sabrina",7,1621068609}, + {154,"Pedro",7,1621137054}, + {155,"Flavie",7,1621180283}, + {156,"Faridah",7,1621183885}, + {157,"Audebert",7,1621223511}, + {158,"Henri-Charles",7,1621291956}, + {159,"Otto",7,1621313570}, + {160,"Giorgio",7,1621349594}, + {161,"Émile",7,1621443256}, + {162,"Fernando",7,1621475677}, + {163,"Corine",7,1621508098}, + {164,"Ralph",7,1621518905}, + {165,"Nicaise",7,1621558531}, + {166,"Pierre-Loïc",8,1621583748}, + {167,"Rafaël",8,1621594555}, + {168,"Géraud",8,1621623374}, + {169,"Gino",8,1621681012}, + {170,"Marc",8,1621681012}, + {171,"Nadège",8,1621713433}, + {172,"Corinne",8,1621720638}, + {173,"Jean-Nicolas",8,1621745854}, + {174,"Vivian",8,1621756662}, + {175,"Desmond",8,1621825106}, + {176,"César",8,1621839516}, + {177,"Kurt",8,1621893551}, + {178,"Brahim",8,1621940382}, + {179,"Johannes",8,1621947587}, + {180,"Emmanuelle",8,1622152922}, + {181,"Elena",8,1622167331}, + {182,"Arnaud",8,1622174536}, + {183,"Richard",8,1622196150}, + {184,"Jean-Claude",8,1622250186}, + {185,"Frederik",8,1622257391}, + {186,"Jean-Patrick",8,1622318631}, + {187,"Gaëtan",8,1622333040}, + {188,"Mariana",9,1622365462}, + {189,"Alexia",9,1622520363}, + {190,"Chloé",9,1622527568}, + {191,"Amina",9,1622574399}, + {192,"Camille",9,1622578001}, + {193,"Anne-Lise",9,1622585206}, + {194,"Siegfried",9,1622621230}, + {195,"Oscar",9,1622624832}, + {196,"Anouk",9,1622624832}, + {197,"Henri",9,1622624832}, + {198,"Marie-Jo",9,1622624832}, + {199,"Marie-Régine",9,1622624832}, + {200,"Jean-Paul",9,1622624832}, + {201,"Claudius",9,1622624832}, + {202,"Océane",9,1622624832}, + {203,"Andrée",9,1622624832}, + {204,"Vanina",9,1622624832}, + {205,"Houria",9,1622624832}, + {206,"Natanael",9,1622624832}, + {207,"Karina",9,1622624832}, + {208,"Joanna",9,1622624832}, + {209,"Mourad",9,1622624832}, + {210,"Louise",9,1622624832}, + {211,"Romuald",9,1622624832}, + {212,"Juliette",9,1622624832}, + {213,"Wolfgang",9,1622624832}, + {214,"Pierre-Marc",10,1622660856}, + {215,"Léone",10,1622686072}, + {216,"Gwen",10,1622722096}, + {217,"Jean-Baptiste",10,1622750915}, + {218,"Sophie",10,1622891407}, + {219,"Maria-Lisa",10,1622902214}, + {220,"Léonard",10,1622923828}, + {221,"Gonzague",10,1622945443}, + {222,"Stéphane",10,1622970659}, + {223,"Lionel",10,1623006683}, + {224,"Warren",10,1623057116}, + {225,"Simon",10,1623345305}, + {226,"Gerardo",10,1623413750}, + {227,"Harold",10,1623453376}, + {228,"Loïc",10,1623467786}, + {229,"Raphaëlle",10,1623554243}, + {230,"Auguste",10,1623565050}, + {231,"Dorothée",10,1623583062}, + {232,"Claudie",10,1623593869}, + {233,"Eugenio",10,1623619085}, + {234,"Alec",10,1623647904}, + {235,"Jean-Philippe",10,1623687530}, + {236,"Donald",10,1623737963}, + {237,"Ahmad",11,1623788397}, + {238,"Anne-Clotilde",11,1623838830}, + {239,"Tatiana",11,1623846034}, + {240,"Darlène",11,1623939696}, + {241,"Jean-Frédéric",11,1623939696}, + {242,"Maxence",11,1623939696}, + {243,"Darren",12,1623939696}, + {244,"Marie-Sophie",12,1623939696}, + {245,"Cynthia",12,1623939696}, + {246,"Pietro",12,1623939696}, + {247,"Gunther",12,1623939696}, + {248,"Jean-Antoine",12,1623939696}, + {249,"Yvan",12,1623939696}, + {250,"Karima",12,1623939696}, + {251,"Rosine",12,1623939696}, + {252,"J.M.",12,1623939696}, + {253,"Pierre-Emmanuel",12,1623939696}, + {254,"Thibaut",12,1623939696}, + {255,"Cyprien",12,1623939696}, + {256,"Stéphanie",12,1623939696}, + {257,"Aristide",12,1623939696}, + {258,"Hassan",12,1623939696}, + {259,"Lorraine",12,1623946901}, + {260,"Emmanuelle",12,1624105405}, + {261,"Mathieu",12,1624170247}, + {262,"Jan",12,1624253102}, + {263,"Paule",12,1624256704}, + {264,"Gwenaëlle",12,1624281921}, + {265,"Concepcion",12,1624296330}, + {266,"Marie-Noëlle",12,1624325149}, + {267,"Gabriele",12,1624350366}, + {268,"Mélanie",12,1624393594}, + {269,"Stephen",12,1624408004}, + {270,"Anne-France",12,1624415208}, + {271,"Michelle",12,1624415208}, + {272,"Marylaine",12,1624451232}, + {273,"Sidney",12,1624458437}, + {274,"Paul-Antoine",12,1624462039}, + {275,"Félix",12,1624530484}, + {276,"Hughes",12,1624566508}, + {277,"José",12,1624656567}, + {278,"Gaetano",12,1624670977}, + {279,"Annie",13,1624699795}, + {280,"Johann",13,1624717807}, + {281,"Annette",13,1624779048}, + {282,"Jacques-Olivier",13,1624818674}, + {283,"Manuel",13,1624833083}, + {284,"Philip",13,1624923142}, + {285,"Samy",13,1624933949}, + {286,"Diogo",13,1624948359}, + {287,"Charles-Emile",13,1624962768}, + {288,"Linda",13,1625005997}, + {289,"Albert",13,1625024009}, + {290,"Enrico",13,1625024009}, + {291,"Léopold",13,1625031213}, + {292,"Tobias",13,1625038418}, + {293,"Jérémie",13,1625038418}, + {294,"Rosette",13,1625063635}, + {295,"Étienne",13,1625067237}, + {296,"Pierre-Yves",13,1625106863}, + {297,"Guido",13,1625121272}, + {298,"Salvatore",13,1625128477}, + {299,"Charlotte",13,1625218536}, + {300,"Francine",13,1625232946}, + {301,"Mireille",13,1625240151}, + {302,"Tommy",13,1625254560}, + {303,"Viviane",13,1625254560}, + {304,"Émilia",13,1625254560}, + {305,"Marielle",13,1625254560}, + {306,"Pierre",13,1625254560}, + {307,"Rodolphe",13,1625254560}, + {308,"Olga",13,1625254560}, + {309,"Vittorio",13,1625254560}, + {310,"Graham",13,1625254560}, + {311,"François",13,1625265367}, + {312,"Wilfried",13,1625265367}, + {313,"Blaise",13,1625301391}, + {314,"Louisa",13,1625341017}, + {315,"Abdallah",13,1625341017}, + {316,"Jean-André",13,1625362631}, + {317,"Pascal",13,1625369836}, + {318,"Johanne",13,1625409462}, + {319,"Bernard-Eric",13,1625420269}, + {320,"Aglaé",13,1625445485}, + {321,"Pierre-Guy",14,1625495919}, + {322,"Rolland",14,1625531942}, + {323,"Régis",14,1625542749}, + {324,"Edwin",14,1625567966}, + {325,"Victoire",14,1625618399}, + {326,"Maximilien",14,1625622001}, + {327,"Dominoco",14,1625683242}, + {328,"Adeline",14,1625791313}, + {329,"Sylvain",14,1625852553}, + {330,"Cécil",14,1625859758}, + {331,"Erwann",14,1625866962}, + {332,"Abdel",14,1626000250}, + {333,"Anne-Catherine",14,1626032671}, + {334,"Victor",14,1626111923}, + {335,"Sylvia",14,1626133538}, + {336,"Franco",14,1626241609}, + {337,"Liliane",14,1626288439}, + {338,"Charles",14,1626353282}, + {339,"Gislain",14,1626392908}, + {340,"Marie-Odile",14,1626443341}, + {341,"Jean-Lou",14,1626464955}, + {342,"Sigrid",14,1626486570}, + {343,"Murielle",14,1626493774}, + {344,"Cécilia",14,1626569424}, + {345,"Marcello",15,1626619857}, + {346,"Erwin",15,1626857613}, + {347,"Alida",15,1627044936}}; + +} diff --git a/app/src/main/java/com/bernard/emorph/activities/EditSubjectListActivity.java b/app/src/main/java/com/bernard/emorph/activities/EditSubjectListActivity.java new file mode 100644 index 0000000..f054bd0 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/activities/EditSubjectListActivity.java @@ -0,0 +1,176 @@ +package com.bernard.emorph.activities; + +import android.app.DatePickerDialog; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.bernard.emorph.EMorphApplication; +import com.bernard.emorph.R; +import com.bernard.emorph.model.Subject; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +public class EditSubjectListActivity extends AppCompatActivity { + + public static final String GROUPID_EXTRA = "com.bernard.emorph.activities.EditSubjectListActivity.GroupID"; + public static final String GROUP_SUBJECT_COUNT_EXTRA = "com.bernard.emorph.activities.EditSubjectListActivity.SubjectCount"; + + EMorphApplication theApp; + + long groupID; + + List subjects; + + RecyclerView rv; + Button newSubjectButton; + Button endButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.setContentView(R.layout.activity_edit_subject_list); + + theApp = (EMorphApplication) getApplication(); + + Intent theIntent = getIntent(); + groupID = theIntent.getLongExtra(GROUPID_EXTRA,-1L); + + + if(theIntent.hasExtra(GROUP_SUBJECT_COUNT_EXTRA)) { + int subjectCount = theIntent.getIntExtra(GROUP_SUBJECT_COUNT_EXTRA, -1); + subjects = new ArrayList<>(subjectCount); + for(int i=0;i esla.newSubjectLine()); + endButton.setOnClickListener((e)->applyModifications()); + } + + public void applyModifications(){ + for(Subject s : subjects){ + if(!s.name.trim().isEmpty() && s.birthDate==-1){ + Toast.makeText(this,getResources().getString(R.string.subjectNoBirthDate,s.name),Toast.LENGTH_SHORT).show(); + return; + } + } + for(Subject s : subjects) + if(!s.name.trim().isEmpty()) + if(s.id==-1) + theApp.newSubject(s.name, s.birthDate); + else + theApp.renameSubject(s.id,s.name); + //TODO: Put regex on names (is it really a good idea ?) + + Intent theIntent = new Intent(this, GroupListActivity.class); + theIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(theIntent); + } + + public void askCalendar(int subjectPos){ + Calendar mcurrentDate=Calendar.getInstance(); + int year = mcurrentDate.get(Calendar.YEAR); + int month = mcurrentDate.get(Calendar.MONTH); + int day = mcurrentDate.get(Calendar.DAY_OF_MONTH); + + DatePickerDialog mDatePicker=new DatePickerDialog(EditSubjectListActivity.this, + (datepicker, selectedYear, selectedMonth, selectedDay) -> { + Log.d("Date Selected", "Month: " + selectedMonth + " Day: " + selectedDay + " Year: " + selectedYear); + Calendar selected = Calendar.getInstance(); + selected.set(selectedYear, selectedMonth, selectedDay); + subjects.get(subjectPos).birthDate = (int) (selected.getTimeInMillis()/1000); + },year, month, day); + mDatePicker.setTitle(getResources().getString(R.string.calendarForSubject, subjects.get(subjectPos).name)); + mDatePicker.show(); + } + + class EditableSubjectsListAdapter extends RecyclerView.Adapter { + + public EditableSubjectsListAdapter(){} + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View theView = LayoutInflater.from(parent.getContext()).inflate(R.layout.subject_group_list_item, parent, false); + + return new ViewHolder(theView); + } + + public void newSubjectLine(){ + subjects.add(new Subject(-1L, "", -1)); + notifyItemInserted(subjects.size()-1); + } + + public void deleteSubjectLine(int position){ + new AlertDialog.Builder(EditSubjectListActivity.this) + .setTitle(R.string.deleteSubjectConfirmationTitle) + .setMessage(getResources().getString(R.string.deleteSubjectConfirmationText,subjects.get(position))) + + .setPositiveButton(android.R.string.yes, (dialogInterface, i) -> { + long theID = subjects.get(position).id; + if(theID!=-1)theApp.removeSubject(theID); + subjects.remove(position); + notifyItemRemoved(position); + }) + .setNegativeButton(android.R.string.no, null) + .setIcon(android.R.drawable.ic_dialog_alert) + .show(); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + holder.nameEditText.setText(subjects.get(position).name); + holder.nameEditText.setHint(getResources().getString(R.string.subjectNameHint, position+1)); + + holder.deleteSubjectButton.setOnClickListener((e) -> deleteSubjectLine(position)); + holder.calendarSubjectButton.setOnClickListener((e)->askCalendar(position)); + } + + @Override + public int getItemCount() { + return subjects.size(); + } + + + class ViewHolder extends RecyclerView.ViewHolder{ + + EditText nameEditText; + ImageButton calendarSubjectButton; + ImageButton deleteSubjectButton; + View theView; + + public ViewHolder(View theView) { + super(theView); + this.theView = theView; + this.nameEditText = theView.findViewById(R.id.subjectNameEdit); + this.calendarSubjectButton = theView.findViewById(R.id.subjectCalendarButton); + this.deleteSubjectButton = theView.findViewById(R.id.subjectDeleteButton); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bernard/emorph/activities/GraphActivity.java b/app/src/main/java/com/bernard/emorph/activities/GraphActivity.java new file mode 100644 index 0000000..a536bd7 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/activities/GraphActivity.java @@ -0,0 +1,14 @@ +package com.bernard.emorph.activities; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class GraphActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_graph); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bernard/emorph/activities/GroupListActivity.java b/app/src/main/java/com/bernard/emorph/activities/GroupListActivity.java new file mode 100644 index 0000000..58709b2 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/activities/GroupListActivity.java @@ -0,0 +1,169 @@ +package com.bernard.emorph.activities; + +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.widget.TextViewCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.bernard.emorph.EMorphApplication; +import com.bernard.emorph.R; +import com.bernard.emorph.model.Group; + +import java.util.List; + +public class GroupListActivity extends AppCompatActivity { + + EMorphApplication theApp; + List groups; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_group_list); + + Toolbar theToolbar = findViewById(R.id.app_toolbar); + setSupportActionBar(theToolbar); + + theApp = (EMorphApplication)getApplication(); + + groups = theApp.listGroups(); + + GroupListAdapter gla = new GroupListAdapter(findViewById(R.id.buttonsLayout)); + + RecyclerView lv = findViewById(R.id.groupes_list); + + lv.setLayoutManager(new LinearLayoutManager(this)); + lv.setAdapter(gla); + + } + + public void startModifyGroup(Group g){ + Intent theIntent = new Intent(this, EditSubjectListActivity.class); + theIntent.putExtra(EditSubjectListActivity.GROUPID_EXTRA, g.id); + startActivity(theIntent); + } + + public void startNewGroup(){ + Intent theIntent = new Intent(this, NewGroupActivity.class); + startActivity(theIntent); + } + + public void startNewMeasure(Group g){ + Intent theIntent = new Intent(this, NewMeasureActivity.class); + theIntent.putExtra(NewMeasureActivity.GROUPID_TO_MEASURE_EXTRA, g.id); + startActivity(theIntent); + } + + class GroupListAdapter extends RecyclerView.Adapter { + + Button dataViewButton; + Button newDataButton; + Button modifyGroupButton; + + int selectedIndex; + ViewHolder selectedHolder; + + public GroupListAdapter( LinearLayout buttonsLayout){ + this.selectedIndex = -1; + this.dataViewButton = buttonsLayout.findViewById(R.id.data_view_button); + this.newDataButton = buttonsLayout.findViewById(R.id.new_data_button); + this.modifyGroupButton = buttonsLayout.findViewById(R.id.modify_group_button); + + this.modifyGroupButton.setOnClickListener((e)->{ + if(selectedIndex==groups.size()) + startNewGroup(); + else + startModifyGroup(groups.get(selectedIndex)); + }); + this.newDataButton.setOnClickListener((e)->{ + if(selectedIndex!=groups.size())startNewMeasure(groups.get(selectedIndex)); + }); + + + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View theView = LayoutInflater.from(parent.getContext()).inflate(R.layout.group_list_item, parent, false); + + return new ViewHolder(theView); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + if(position==groups.size()) { // C'est la ligne «nouveau groupe» + holder.titleText.setText(R.string.newGroupItem); + TextViewCompat.setTextAppearance(holder.titleText,R.style.group_list_newgroup_item_text); + } else { + holder.titleText.setText(groups.get(position).name); + TextViewCompat.setTextAppearance(holder.titleText,R.style.group_list_item_text); + } + holder.theView.setOnClickListener((e) -> selectItem(holder, position)); + } + + public void selectItem(ViewHolder vh, int i){ + + if(this.selectedIndex!=-1){ + if(selectedIndex==groups.size()) // C'est la ligne «nouveau groupe» + TextViewCompat.setTextAppearance(selectedHolder.titleText,R.style.group_list_newgroup_item_text); + else + TextViewCompat.setTextAppearance(selectedHolder.titleText,R.style.group_list_item_text); + + } + if(i!=-1){ + if(selectedIndex==groups.size()) // C'est la ligne «nouveau groupe» + TextViewCompat.setTextAppearance(vh.titleText,R.style.group_list_newgroup_item_text_selected); + else + TextViewCompat.setTextAppearance(vh.titleText,R.style.group_list_item_text_selected); + if(i mGetContent = registerForActivityResult(new ActivityResultContracts.GetContent(), + new ActivityResultCallback() { + @Override + public void onActivityResult(Uri uri) { + // Handle the returned Uri + } + }); + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_new_group); + + theApp = (EMorphApplication) getApplication(); + + groupNameText = findViewById(R.id.nameAskField); + + subjectsSelector = findViewById(R.id.subjectsSelectors); + + subjectsSelector.setMinValue(1); + subjectsSelector.setMaxValue(Integer.MAX_VALUE); + subjectsSelector.setFormatter((i) -> this.getResources().getString(R.string.nth_subject,i)); + subjectsSelector.setWrapSelectorWheel(false); + + okButton = findViewById(R.id.okButton); + + okButton.setOnClickListener((e)->okNextActivity()); + } + + private void okNextActivity(){ + + String theName = groupNameText.getText().toString().trim(); + if(!groupNamePattern.matcher(theName).matches()){ + Toast.makeText(this, R.string.invalidGroupName, Toast.LENGTH_SHORT).show(); + return; + } + + int subjectCount = subjectsSelector.getValue(); + long groupID = theApp.newGroup(theName); + + Intent theIntent = new Intent(this, EditSubjectListActivity.class); + theIntent.putExtra(EditSubjectListActivity.GROUPID_EXTRA,groupID); + theIntent.putExtra(EditSubjectListActivity.GROUP_SUBJECT_COUNT_EXTRA, subjectCount); + + startActivity(theIntent); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/bernard/emorph/activities/NewMeasureActivity.java b/app/src/main/java/com/bernard/emorph/activities/NewMeasureActivity.java new file mode 100644 index 0000000..920aa17 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/activities/NewMeasureActivity.java @@ -0,0 +1,178 @@ +package com.bernard.emorph.activities; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContract; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.widget.TextViewCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.bernard.emorph.EMorphApplication; +import com.bernard.emorph.R; +import com.bernard.emorph.model.MeasureOnSubject; +import com.bernard.emorph.model.Subject; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class NewMeasureActivity extends AppCompatActivity { + + public static final String GROUPID_TO_MEASURE_EXTRA = "com.bernard.emorph.activities.NewMeasure.GroupToMeasure"; + + EMorphApplication theApp; + + long groupToMeasure; + long measureID; + List subjects; + Map subjectsMoz; + Map holderz; + + ActivityResultLauncher arlNewMos = registerForActivityResult(new NewMeasureOnSubjectContract(), + measure -> { + if(measure!=null) { + subjectsMoz.put(measure.subjectID, measure); + TextViewCompat.setTextAppearance(Objects.requireNonNull(holderz.get(measure.subjectID)).titleText, R.style.newmeasure_subject_list_item_disable); + } + }); + + + RecyclerView rv; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_new_measure); + + subjectsMoz = new HashMap<>(); + holderz = new HashMap<>(); + + Intent theIntent = getIntent(); + + groupToMeasure = theIntent.getLongExtra(GROUPID_TO_MEASURE_EXTRA, 0L); + + theApp = (EMorphApplication)getApplication(); + + measureID = theApp.newMeasure(groupToMeasure); + + rv = findViewById(R.id.subjectsList); + Toolbar theBar = findViewById(R.id.app_toolbar); + theBar.setTitle(getResources().getString(R.string.newDataTitle, theApp.getGroupName(groupToMeasure))); + + subjects = theApp.getSubjects(groupToMeasure); + + SubjectListAdapter sla = new SubjectListAdapter(); + + rv.setLayoutManager(new LinearLayoutManager(this)); + rv.setAdapter(sla); + + Button okButton = findViewById(R.id.okButton); + okButton.setOnClickListener((e)->endMeasure()); + } + + public void measureSubject(Subject s){ + + if(!subjectsMoz.containsKey(s.id)) { + arlNewMos.launch(s.id); + } else { + Toast.makeText(this, R.string.mosAlreadyGiven, Toast.LENGTH_SHORT).show(); + } + } + + public void endMeasure(){ + + for(int i=0;i finish()) + .setNegativeButton(android.R.string.no, null) + .setIcon(android.R.drawable.ic_dialog_alert) + .show(); + return; + } + } + + class SubjectListAdapter extends RecyclerView.Adapter { + + + + + public SubjectListAdapter(){} + + @NonNull + @Override + public NewMeasureActivity.SubjectListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View theView = LayoutInflater.from(parent.getContext()).inflate(R.layout.newmeasure_subject_list_item, parent, false); + + return new NewMeasureActivity.SubjectListAdapter.ViewHolder(theView); + } + + @Override + public void onBindViewHolder(@NonNull NewMeasureActivity.SubjectListAdapter.ViewHolder holder, int position) { + holder.titleText.setText(subjects.get(position).name); + + holder.theView.setOnClickListener((e) -> measureSubject(subjects.get(position))); + + holderz.put(subjects.get(position).id, holder); + } + + @Override + public int getItemCount() { + return subjects.size(); + } + + + class ViewHolder extends RecyclerView.ViewHolder{ + + TextView titleText; + View theView; + + public ViewHolder(View theView) { + super(theView); + this.theView = theView; + this.titleText = theView.findViewById(R.id.itemTitle); + } + } + } + + public class NewMeasureOnSubjectContract extends ActivityResultContract { + + @NonNull + @Override + public Intent createIntent(@NonNull Context context, Long input) { + Intent intent = new Intent(NewMeasureActivity.this, NewMeasureOnSubjectActivity.class); + intent.putExtra(NewMeasureOnSubjectActivity.TARGET_SUBJECT_EXTRA, input); + intent.putExtra(NewMeasureOnSubjectActivity.GROUPID_TO_MEASURE_EXTRA, groupToMeasure); + intent.putExtra(NewMeasureOnSubjectActivity.MEASUREID_EXTRA, NewMeasureActivity.this.measureID); + return intent; + } + + @Override + public MeasureOnSubject parseResult(int resultCode, @Nullable Intent result) { + if (resultCode != Activity.RESULT_OK || result == null) { + return null; + } + return result.getParcelableExtra(NewMeasureOnSubjectActivity.MOS_RETURNED_EXTRA); + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/bernard/emorph/activities/NewMeasureOnSubjectActivity.java b/app/src/main/java/com/bernard/emorph/activities/NewMeasureOnSubjectActivity.java new file mode 100644 index 0000000..6914833 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/activities/NewMeasureOnSubjectActivity.java @@ -0,0 +1,139 @@ +package com.bernard.emorph.activities; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.StringRes; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.bernard.emorph.EMorphApplication; +import com.bernard.emorph.R; +import com.bernard.emorph.model.MeasureOnSubject; + +public class NewMeasureOnSubjectActivity extends AppCompatActivity { + + public static final String TARGET_SUBJECT_EXTRA = "com.bernard.emorph.activities.NewMeasureOnSubjectActivity.TargetSubject"; + public static final String MEASUREID_EXTRA = "com.bernard.emorph.activities.NewMeasureOnSubjectActivity.MeasureId"; + public static final String GROUPID_TO_MEASURE_EXTRA = "com.bernard.emorph.activities.NewMeasureOnSubjectActivity.GroupId"; + + public static final String MOS_RETURNED_EXTRA = "com.bernard.emorph.activities.NewMeasureOnSubjectActivity.MosId"; + + EMorphApplication theApp; + long subjectId; + long measureID; + long groupID; + + public static final String maxiMinusFloatP = "maxiMinusFloatDelta", + miniMinusFloatP = "miniMinusFloatDelta", + maxiPlusFloatP = "maxiPlusFloatDelta", + miniPlusFloatP = "miniPlusFloatDelta"; + + public static final String abdomenDefaultValue = "abdomenDefaultValue", + brasDefaultValue = "brasDefaultValue", + epaulesDefaultValue = "epaulesDefaultValue", + tailleDefaultValue = "tailleDefaultValue", + cuisseDefaultValue = "cuisseDefaultValue", + chevilleDefaultValue = "chevilleDefaultValue", + avantBrasDefaultValue = "avantBrasDefaultValue"; + + EditText abdomenET, brasET, epaulesET, tailleET, cuisseET, chevilleET, avantBrasET; + + Button okButton; + + SharedPreferences sp; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_new_measure_on_subject); + + Intent theIntent = getIntent(); + subjectId = theIntent.getLongExtra(TARGET_SUBJECT_EXTRA,0L); + measureID = theIntent.getLongExtra(MEASUREID_EXTRA,0L); + groupID = theIntent.getLongExtra(GROUPID_TO_MEASURE_EXTRA, 0L); + + theApp = (EMorphApplication)getApplication(); + + Toolbar theBar = findViewById(R.id.app_toolbar); + theBar.setTitle(getResources().getString(R.string.newDataSubjectTitle, theApp.getSubjectName(subjectId))); + + sp = getSharedPreferences(EMorphApplication.APP_PREFERENCES_FILE, Context.MODE_PRIVATE); + + abdomenET = treatLayout(findViewById(R.id.abdomenLayout), R.string.abdomenCirc, sp.getFloat(abdomenDefaultValue,75.32f)); + brasET = treatLayout(findViewById(R.id.brasLayout), R.string.brasCirc, sp.getFloat(brasDefaultValue,25.93f)); + epaulesET = treatLayout(findViewById(R.id.epaulesLayout), R.string.epaulesCirc, sp.getFloat(epaulesDefaultValue,93.31f)); + tailleET = treatLayout(findViewById(R.id.tailleLayout), R.string.tailleCirc, sp.getFloat(tailleDefaultValue,79.88f)); + cuisseET = treatLayout(findViewById(R.id.cuisseLayout), R.string.cuisseCirc, sp.getFloat(cuisseDefaultValue,53.09f)); + chevilleET = treatLayout(findViewById(R.id.chevilleLayout), R.string.chevilleCirc, sp.getFloat(chevilleDefaultValue,24.82f)); + avantBrasET = treatLayout(findViewById(R.id.avantBrasLayout), R.string.avantBrasCirc, sp.getFloat(avantBrasDefaultValue,24.26f)); + + + okButton = findViewById(R.id.okButton); + okButton.setOnClickListener((e)->commitData()); + } + + public void commitData(){ + try { + MeasureOnSubject mos = theApp.newMOS( + measureID, + subjectId, + Float.parseFloat(abdomenET.getText().toString()), + Float.parseFloat(brasET.getText().toString()), + Float.parseFloat(epaulesET.getText().toString()), + Float.parseFloat(tailleET.getText().toString()), + Float.parseFloat(cuisseET.getText().toString()), + Float.parseFloat(chevilleET.getText().toString()), + Float.parseFloat(avantBrasET.getText().toString()) + ); + + Intent theIntent = new Intent(); + theIntent.putExtra(NewMeasureActivity.GROUPID_TO_MEASURE_EXTRA, groupID); + theIntent.putExtra(MOS_RETURNED_EXTRA, mos); + setResult(Activity.RESULT_OK, theIntent); + finish(); + + + }catch(NumberFormatException nfe){ + Toast.makeText(this,R.string.pleaseEnterFloat,Toast.LENGTH_SHORT).show(); + } + } + public EditText treatLayout(ConstraintLayout theLayout, @StringRes int titleRes, float defaultValue){ + EditText theET = theLayout.findViewById(R.id.editableField); + TextView theTV = theLayout.findViewById(R.id.fieldTitle); + + ImageButton + miniPlusB = theLayout.findViewById(R.id.miniPlusButton), + miniMinusB = theLayout.findViewById(R.id.miniMinusButton), + maxiPlusB = theLayout.findViewById(R.id.maxiPlusButton), + maxiMinusB = theLayout.findViewById(R.id.maxiMinusButton); + + + theTV.setText(titleRes); + theET.setText(String.valueOf(defaultValue)); + + miniPlusB.setOnClickListener((e)->applyDeltaToContent(theET,sp.getFloat(miniPlusFloatP,+0.03f))); + miniMinusB.setOnClickListener((e)->applyDeltaToContent(theET,sp.getFloat(miniMinusFloatP,-0.03f))); + maxiPlusB.setOnClickListener((e)->applyDeltaToContent(theET,sp.getFloat(maxiPlusFloatP,+1f))); + maxiMinusB.setOnClickListener((e)->applyDeltaToContent(theET,sp.getFloat(maxiMinusFloatP,-1f))); + + return theET; + } + + public void applyDeltaToContent(EditText theET, float delta){ + try { + theET.setText(String.valueOf(Float.parseFloat(theET.getText().toString()) + delta)); + }catch(NumberFormatException nfe){ + Toast.makeText(this,R.string.pleaseEnterFloat,Toast.LENGTH_SHORT).show(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bernard/emorph/activities/PrepareMeasureActivity.java b/app/src/main/java/com/bernard/emorph/activities/PrepareMeasureActivity.java new file mode 100644 index 0000000..f571d30 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/activities/PrepareMeasureActivity.java @@ -0,0 +1,14 @@ +package com.bernard.emorph.activities; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class PrepareMeasureActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_prepare_measure); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bernard/emorph/model/Group.java b/app/src/main/java/com/bernard/emorph/model/Group.java new file mode 100644 index 0000000..6ff8e59 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/model/Group.java @@ -0,0 +1,11 @@ +package com.bernard.emorph.model; + +public class Group { + public long id; + public String name; + + public Group(long id, String name){ + this.id = id; + this.name = name; + } +} diff --git a/app/src/main/java/com/bernard/emorph/model/MeasureOnSubject.java b/app/src/main/java/com/bernard/emorph/model/MeasureOnSubject.java new file mode 100644 index 0000000..2154844 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/model/MeasureOnSubject.java @@ -0,0 +1,67 @@ +package com.bernard.emorph.model; + +import android.os.Parcel; +import android.os.Parcelable; + +public class MeasureOnSubject implements Parcelable { + + public long mosId; + + public long subjectID; + + public float abdomen, bras, epaules, taille, cuisse, cheville, avantBras; + + public MeasureOnSubject(long mosId, long subjectID, float abdomen, float bras, float epaules, float taille, float cuisse, float cheville, float avantBras) { + this.mosId = mosId; + this.subjectID = subjectID; + this.abdomen = abdomen; + this.bras = bras; + this.epaules = epaules; + this.taille = taille; + this.cuisse = cuisse; + this.cheville = cheville; + this.avantBras = avantBras; + } + + private MeasureOnSubject(Parcel p){ + this.mosId = p.readLong(); + this.subjectID = p.readLong(); + this.abdomen = p.readFloat(); + this.bras = p.readFloat(); + this.epaules = p.readFloat(); + this.taille = p.readFloat(); + this.cuisse = p.readFloat(); + this.cheville = p.readFloat(); + this.avantBras = p.readFloat(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public MeasureOnSubject createFromParcel(Parcel parcel) { + return new MeasureOnSubject(parcel); + } + + @Override + public MeasureOnSubject[] newArray(int i) { + return new MeasureOnSubject[i]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel p, int flags) { + p.writeLong(mosId); + p.writeLong(subjectID); + p.writeFloat(abdomen); + p.writeFloat(bras); + p.writeFloat(epaules); + p.writeFloat(taille); + p.writeFloat(cuisse); + p.writeFloat(cheville); + p.writeFloat(avantBras); + } +} diff --git a/app/src/main/java/com/bernard/emorph/model/Subject.java b/app/src/main/java/com/bernard/emorph/model/Subject.java new file mode 100644 index 0000000..40930d5 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/model/Subject.java @@ -0,0 +1,13 @@ +package com.bernard.emorph.model; + +public final class Subject{ + public long id; + public String name; + public int birthDate; + + public Subject(long id, String name, int birthDate){ + this.id = id; + this.name = name; + this.birthDate = birthDate; + } +} diff --git a/app/src/main/java/com/bernard/emorph/model/ToGraph.java b/app/src/main/java/com/bernard/emorph/model/ToGraph.java new file mode 100644 index 0000000..bf7e1e8 --- /dev/null +++ b/app/src/main/java/com/bernard/emorph/model/ToGraph.java @@ -0,0 +1,15 @@ +package com.bernard.emorph.model; + +public class ToGraph { + + long[] measuresID; + + long[] subjectsID; + + Base base; + + enum Base { + LABO, GROUPE; + } + +} diff --git a/app/src/main/res/drawable/ic_minus.xml b/app/src/main/res/drawable/ic_minus.xml new file mode 100644 index 0000000..382bfd4 --- /dev/null +++ b/app/src/main/res/drawable/ic_minus.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_plus.xml b/app/src/main/res/drawable/ic_plus.xml new file mode 100644 index 0000000..a59c532 --- /dev/null +++ b/app/src/main/res/drawable/ic_plus.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_edit_subject_list.xml b/app/src/main/res/layout/activity_edit_subject_list.xml new file mode 100644 index 0000000..0c402ee --- /dev/null +++ b/app/src/main/res/layout/activity_edit_subject_list.xml @@ -0,0 +1,47 @@ + + + + + + + + +