mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 12:30:42 +01:00
Merge branch 'bugfix/Create_MainActivity' into develop
This commit is contained in:
commit
1ea57f813c
7 changed files with 74 additions and 46 deletions
|
@ -148,4 +148,10 @@ public class AlarmReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) { Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show(); }
|
if (BuildConfig.DEBUG) { Toast.makeText(context, "Alarm scheduled for " + UtilDate.convertDate(calendar.getTimeInMillis()), Toast.LENGTH_SHORT).show(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean isAlarmScheduled(Context context) {
|
||||||
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
|
return alarmManager.getNextAlarmClock() != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package net.foucry.pilldroid;
|
|
||||||
|
|
||||||
public class BarcodeValues {
|
|
||||||
private final String mFormat;
|
|
||||||
private final String mContent;
|
|
||||||
|
|
||||||
public BarcodeValues(String format, String content) {
|
|
||||||
mFormat = format;
|
|
||||||
mContent = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String format() {
|
|
||||||
return mFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String content() {
|
|
||||||
return mContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return mFormat == null && mContent == null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -79,7 +79,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
if(net.foucry.pilldroid.BuildConfig.DEBUG) {
|
if(BuildConfig.DEBUG) {
|
||||||
String manufacturer = Build.MANUFACTURER;
|
String manufacturer = Build.MANUFACTURER;
|
||||||
String model = Build.MODEL;
|
String model = Build.MODEL;
|
||||||
int version = Build.VERSION.SDK_INT;
|
int version = Build.VERSION.SDK_INT;
|
||||||
|
@ -92,12 +92,19 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create medicines Room database from drugs.db files
|
||||||
medicines = Room
|
medicines = Room
|
||||||
.databaseBuilder(getApplicationContext(), MedicineDatabase.class, "medicines")
|
.databaseBuilder(getApplicationContext(), MedicineDatabase.class, "medicines")
|
||||||
.createFromAsset("drugs.db")
|
.createFromAsset("drugs.db")
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
// Create prescriptions Room database
|
||||||
|
prescriptions = Room
|
||||||
|
.databaseBuilder(getApplicationContext(), PrescriptionDatabase.class, "prescriptions")
|
||||||
|
.allowMainThreadQueries()
|
||||||
|
.build();
|
||||||
|
|
||||||
// Manually migrate old database to room
|
// Manually migrate old database to room
|
||||||
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
PrescriptionsDAO prescriptionsDAO = prescriptions.getPrescriptionsDAO();
|
||||||
DBHelper dbHelper = new DBHelper(this);
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
@ -134,11 +141,19 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
nm.cancelAll();
|
nm.cancelAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// start tutorial (only in non debug mode
|
// start tutorial (only in non debug mode)
|
||||||
if(!net.foucry.pilldroid.BuildConfig.DEBUG) {
|
// if(!net.foucry.pilldroid.BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "Launch tutorial");
|
Log.i(TAG, "Launch tutorial");
|
||||||
startActivity(new Intent(this, WelcomeActivity.class));
|
startActivity(new Intent(this, WelcomeActivity.class));
|
||||||
|
// }
|
||||||
|
|
||||||
|
PrefManager prefManager = new PrefManager(this);
|
||||||
|
if (!prefManager.isUnderstood()) {
|
||||||
|
askForComprehensive();
|
||||||
|
prefManager.setUnderstood(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,9 +161,18 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
Log.d(TAG, "onPause");
|
||||||
|
|
||||||
|
if (!AlarmReceiver.isAlarmScheduled(this)){
|
||||||
|
AlarmReceiver.scheduleAlarm(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// Create Room database
|
// Create Room database
|
||||||
|
@ -295,12 +319,6 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
constructDrugsList();
|
constructDrugsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
Log.d(TAG, "onPause");
|
|
||||||
AlarmReceiver.scheduleAlarm(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
@ -343,7 +361,6 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
MedicinesDAO medicineDAO = medicines.getMedicinesDAO();
|
MedicinesDAO medicineDAO = medicines.getMedicinesDAO();
|
||||||
Medicine aMedicine = medicineDAO.getMedicineByCIP13(cip13);
|
Medicine aMedicine = medicineDAO.getMedicineByCIP13(cip13);
|
||||||
//Prescription aPrescription = medications.getDrugByCIP13(cip13);
|
|
||||||
askToAddInDB(aMedicine);
|
askToAddInDB(aMedicine);
|
||||||
})
|
})
|
||||||
.setNegativeButton("Cancel",
|
.setNegativeButton("Cancel",
|
||||||
|
@ -415,6 +432,21 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
dlg.show();
|
dlg.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* askForCompréhensive
|
||||||
|
*/
|
||||||
|
private void askForComprehensive() {
|
||||||
|
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
|
||||||
|
dlg.setTitle(getString(R.string.app_name));
|
||||||
|
|
||||||
|
dlg.setMessage(R.string.understood);
|
||||||
|
dlg.setPositiveButton(R.string.Yes, (dialog, which) -> {
|
||||||
|
// Nothing to do just dismiss dialog
|
||||||
|
});
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add New drug to the user database
|
* Add New drug to the user database
|
||||||
*
|
*
|
||||||
|
@ -434,17 +466,6 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAppName() {
|
|
||||||
PackageManager packageManager = getApplicationContext().getPackageManager();
|
|
||||||
ApplicationInfo applicationInfo = null;
|
|
||||||
try {
|
|
||||||
applicationInfo = packageManager.getApplicationInfo(this.getPackageName(), 0);
|
|
||||||
} catch (final PackageManager.NameNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
return (String) ((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setupRecyclerView (list of drugs)
|
* setupRecyclerView (list of drugs)
|
||||||
*
|
*
|
||||||
|
@ -581,4 +602,14 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAppName() {
|
||||||
|
PackageManager packageManager = getApplicationContext().getPackageManager();
|
||||||
|
ApplicationInfo applicationInfo = null;
|
||||||
|
try {
|
||||||
|
applicationInfo = packageManager.getApplicationInfo(this.getPackageName(), 0);
|
||||||
|
} catch (final PackageManager.NameNotFoundException ignored) {
|
||||||
|
}
|
||||||
|
return (String) ((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.content.SharedPreferences;
|
||||||
private static final String PREF_NAME = "Pildroid-Prefs";
|
private static final String PREF_NAME = "Pildroid-Prefs";
|
||||||
private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
|
private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
|
||||||
private static final String DATABASE_VERSION = "DatabaseVersion";
|
private static final String DATABASE_VERSION = "DatabaseVersion";
|
||||||
|
private static final String IS_UNDERSTOOD = "IsUnderStood";
|
||||||
|
|
||||||
public PrefManager(Context context) {
|
public PrefManager(Context context) {
|
||||||
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
|
||||||
|
@ -35,10 +36,17 @@ import android.content.SharedPreferences;
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnderstood(boolean isUnderstood) {
|
||||||
|
editor = pref.edit();
|
||||||
|
editor.putBoolean(IS_UNDERSTOOD, isUnderstood);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFirstTimeLaunch() {
|
public boolean isFirstTimeLaunch() {
|
||||||
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
|
||||||
}
|
}
|
||||||
public int getDatabaseVersion() {
|
public int getDatabaseVersion() {
|
||||||
return pref.getInt(DATABASE_VERSION, 0);
|
return pref.getInt(DATABASE_VERSION, 0);
|
||||||
}
|
}
|
||||||
|
public boolean isUnderstood() {return pref.getBoolean(IS_UNDERSTOOD, false); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/white">
|
android:background="@android:color/white"
|
||||||
|
tools:ignore="Overdraw">
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/aboutHtml"
|
android:id="@+id/aboutHtml"
|
||||||
|
|
|
@ -66,4 +66,6 @@
|
||||||
<string name="notInterpreted">Le code barre ne peut pas être interprété</string>
|
<string name="notInterpreted">Le code barre ne peut pas être interprété</string>
|
||||||
<string name="cancelled_scan">Scan annulé</string>
|
<string name="cancelled_scan">Scan annulé</string>
|
||||||
<string name="missing_camera_permission">Permission appareil photo manquante</string>
|
<string name="missing_camera_permission">Permission appareil photo manquante</string>
|
||||||
|
<string name="Yes">Oui, j\'ai compris</string>
|
||||||
|
<string name="understood">Je comprend que le développeur de app_name n\'est pas responsable de la gestion de vos médicaments. CELA RELÈVE DE VOTRE SEULE RESPONSABILITË.</string>
|
||||||
</resources>
|
</resources>
|
|
@ -68,4 +68,6 @@
|
||||||
<string name="notInterpreted">Barre code cannot be interpreted</string>
|
<string name="notInterpreted">Barre code cannot be interpreted</string>
|
||||||
<string name="cancelled_scan">Scan canceled</string>
|
<string name="cancelled_scan">Scan canceled</string>
|
||||||
<string name="missing_camera_permission">Missing camera permission</string>
|
<string name="missing_camera_permission">Missing camera permission</string>
|
||||||
|
<string name="Yes">Yes, I understood</string>
|
||||||
|
<string name="understood">I understood that de developer of app_name cannot be responsible ot your medication management. IT\'S YOU OWN RESPONSIBILITY.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue