diff --git a/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java b/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java index eaef0c1..c2fe9ca 100644 --- a/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java +++ b/app/src/main/java/net/foucry/pilldroid/AlarmReceiver.java @@ -96,26 +96,24 @@ public class AlarmReceiver extends BroadcastReceiver { String description = context.getString(R.string.channel_description); int importance = NotificationManager.IMPORTANCE_DEFAULT; String CHANNEL_ID = "PillDroid"; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); - channel.setDescription(description); - channel.enableLights(true); - channel.setLightColor(R.color.led); - channel.enableVibration(true); - channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); - // Register the channel with the system; you can't change the importance - // or other notification behaviors after this - NotificationManager notificationManager = context.getSystemService(NotificationManager.class); - try { - notificationManager.createNotificationChannel(channel); - } catch (Exception e) { - // This will catch any exception, because they are all descended from Exception - Log.e(TAG, e.toString()); - //At the level Exception Class handle the error in Exception Table - // Exception Create That Error Object and throw it - //E.g: FileNotFoundException ,etc - e.printStackTrace(); - } + NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); + channel.setDescription(description); + channel.enableLights(true); + channel.setLightColor(R.color.led); + channel.enableVibration(true); + channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); + // Register the channel with the system; you can't change the importance + // or other notification behaviors after this + NotificationManager notificationManager = context.getSystemService(NotificationManager.class); + try { + notificationManager.createNotificationChannel(channel); + } catch (Exception e) { + // This will catch any exception, because they are all descended from Exception + Log.e(TAG, e.toString()); + //At the level Exception Class handle the error in Exception Table + // Exception Create That Error Object and throw it + //E.g: FileNotFoundException ,etc + e.printStackTrace(); } } public static void scheduleAlarm(Context context) { diff --git a/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java b/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java index 81efd5c..b3ff7c1 100644 --- a/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/CustomScannerActivity.java @@ -12,7 +12,6 @@ import android.widget.ImageButton; import androidx.annotation.NonNull; -import com.google.zxing.client.android.Intents; import com.journeyapps.barcodescanner.BarcodeCallback; import com.journeyapps.barcodescanner.BarcodeResult; import com.journeyapps.barcodescanner.CaptureManager; @@ -24,7 +23,7 @@ import java.util.Random; /** * Custom Scanner Activity extending from Activity to display a custom layout form scanner view. */ -public class CustomScannerActivity extends Activity { +public class CustomScannerActivity extends Activity implements DecoratedBarcodeView.TorchListener { private static final String TAG = CustomScannerActivity.class.getName(); @@ -33,7 +32,6 @@ public class CustomScannerActivity extends Activity { private ImageButton switchFlashlightButton; private ViewfinderView viewfinderView; - final Intent captureIntent = new Intent(); final Bundle captureIntentBundle = new Bundle(); @Override @@ -41,9 +39,6 @@ public class CustomScannerActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_scanner); -/* manualAddLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), - result -> handleActivityResult(result.getResultCode(), - result.getData()));*/ //barcodeScannerView.setTorchListener(this); @@ -61,22 +56,11 @@ public class CustomScannerActivity extends Activity { findViewById(R.id.switch_flashlight).setVisibility(View.GONE); } - captureIntentBundle.putBoolean(Intents.Scan.BEEP_ENABLED, true); - captureIntentBundle.putInt("Intents.Scan.MIXED_SCAN", Intents.Scan.MIXED_SCAN); - captureIntentBundle.putInt("Intents.Scan.INVERTED_SCAN", Intents.Scan.INVERTED_SCAN); - - captureIntent.putExtras(captureIntentBundle); - - /*captureIntent.putExtra("Intents.Scan.MIXED_SCAN", Intents.Scan.MIXED_SCAN); - captureIntent.putExtra("Intents.Scan.INVERTED_SCAN", Intents.Scan.INVERTED_SCAN); - captureIntent.putExtra("Intents.Scan.BEEP_ENABLED", Intents.Scan.BEEP_ENABLED);*/ - capture = new CaptureManager(this, barcodeScannerView); capture.initializeFromIntent(getIntent(), savedInstanceState); capture.setShowMissingCameraPermissionDialog(false); - //capture.decode(); - changeMaskColor(null); + //changeMaskColor(null); changeLaserVisibility(true); barcodeScannerView.decodeSingle(new BarcodeCallback() { @Override @@ -137,8 +121,10 @@ public class CustomScannerActivity extends Activity { Log.d(TAG, "Switch torch"); if (switchFlashlightButton.isActivated()) { barcodeScannerView.setTorchOff(); + switchFlashlightButton.setActivated(false); } else { barcodeScannerView.setTorchOn(); + switchFlashlightButton.setActivated(true); } } @@ -183,27 +169,4 @@ public class CustomScannerActivity extends Activity { finish(); } - /*private void handleActivityResult(int resultCode, Intent intent) { - super.onActivityResult(Utils.SELECT_BARCODE_REQUEST, resultCode, intent); - - BarcodeValues barcodeValues; - - try { - barcodeValues = Utils.parseSetBarcodeActivityResult(Utils.SELECT_BARCODE_REQUEST, resultCode, intent, this); - } catch (NullPointerException e) { - Toast.makeText(this, "Error reading image", Toast.LENGTH_LONG).show(); - return; - } - - if (!barcodeValues.isEmpty()) { - Intent manualResult = new Intent(); - Bundle manualResultBundle = new Bundle(); - manualResultBundle.putString("BarcodeContent", barcodeValues.content()); - manualResultBundle.putString("BarcodeFormat", barcodeValues.format()); - - manualResult.putExtras(manualResultBundle); - CustomScannerActivity.this.setResult(RESULT_OK, manualResult); - finish(); - } - }*/ } diff --git a/app/src/main/java/net/foucry/pilldroid/DBDrugs.java b/app/src/main/java/net/foucry/pilldroid/DBDrugs.java index 226fa4d..912cf42 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBDrugs.java +++ b/app/src/main/java/net/foucry/pilldroid/DBDrugs.java @@ -109,9 +109,8 @@ class DBDrugs extends SQLiteOpenHelper { @Override public synchronized void close() { - if (myDataBase != null) { - myDataBase.close(); - } + assert false; + myDataBase.close(); } /** diff --git a/app/src/main/java/net/foucry/pilldroid/DBHelper.java b/app/src/main/java/net/foucry/pilldroid/DBHelper.java index 01252d7..73a003d 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBHelper.java +++ b/app/src/main/java/net/foucry/pilldroid/DBHelper.java @@ -276,9 +276,6 @@ class DBHelper extends SQLiteOpenHelper { Log.d(TAG, "Before sort == " + drugs); - /*drugs.sort(Comparator.comparing(Drug::getDateEndOfStock) - .thenComparing(Drug::getStock));*/ - drugs.sort(new Comparator() { @Override public int compare(Drug lhs, Drug rhs) { diff --git a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java index 4a5d5e6..3ee2e7b 100644 --- a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java +++ b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java @@ -88,7 +88,7 @@ public class PillDroidJobService extends JobService { Log.d(TAG, "schedule notification"); createNotificationChannel(); Intent intent = new Intent(this, DrugListActivity.class); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,0); + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,PendingIntent.FLAG_MUTABLE); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "PillDroid") .setSmallIcon(R.drawable.ic_pill_alarm) .setContentTitle(getString(R.string.app_name)) @@ -113,23 +113,21 @@ public class PillDroidJobService extends JobService { int importance = NotificationManager.IMPORTANCE_DEFAULT; String CHANNEL_ID = "PillDroid"; NotificationChannel channel; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { - channel = new NotificationChannel(CHANNEL_ID, name, importance); + channel = new NotificationChannel(CHANNEL_ID, name, importance); - channel.setDescription(description); - // Register the channel with the system; you can't change the importance - // or other notification behaviors after this - NotificationManager notificationManager = getSystemService(NotificationManager.class); - try { - notificationManager.createNotificationChannel(channel); - } catch (Exception e) { - // This will catch any exception, because they are all descended from Exception - Log.e(TAG, e.toString()); - //At the level Exception Class handle the error in Exception Table - // Exception Create That Error Object and throw it - //E.g: FileNotFoundException ,etc - e.printStackTrace(); - } + channel.setDescription(description); + // Register the channel with the system; you can't change the importance + // or other notification behaviors after this + NotificationManager notificationManager = getSystemService(NotificationManager.class); + try { + notificationManager.createNotificationChannel(channel); + } catch (Exception e) { + // This will catch any exception, because they are all descended from Exception + Log.e(TAG, e.toString()); + //At the level Exception Class handle the error in Exception Table + // Exception Create That Error Object and throw it + //E.g: FileNotFoundException ,etc + e.printStackTrace(); } } } diff --git a/app/src/main/java/net/foucry/pilldroid/Utils.java b/app/src/main/java/net/foucry/pilldroid/Utils.java index 07e8f47..0db4c80 100644 --- a/app/src/main/java/net/foucry/pilldroid/Utils.java +++ b/app/src/main/java/net/foucry/pilldroid/Utils.java @@ -45,34 +45,4 @@ public class Utils { Random r = new Random(); return r.nextInt(max - min) +max; } - - /** - * parse barcode result into barcodevalues - * @param requestCode int - * @param resultCode int - * @param intent Intent - * @param context Context - * @return BarcodeValues - */ - static public BarcodeValues parseSetBarcodeActivityResult(int requestCode, int resultCode, - Intent intent, Context context) { - String contents = null; - String format = null; - - if (resultCode != Activity.RESULT_OK) { - return new BarcodeValues(null, null); - } - - if (requestCode == Utils.BARCODE_SCAN || requestCode == Utils.SELECT_BARCODE_REQUEST) { - if (requestCode == Utils.BARCODE_SCAN) { - Log.d(TAG, "Received barcode information form camera"); - } else if (requestCode == Utils.SELECT_BARCODE_REQUEST) { - Log.d(TAG, "Received barcode information form typeing it"); - } - - contents = intent.getStringExtra("BarcodeContent"); - format = intent.getStringExtra("BarcodeFormat"); - } - return new BarcodeValues(format, contents); - } } diff --git a/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java b/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java index 7761e90..fe0946a 100644 --- a/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java @@ -217,7 +217,7 @@ public class WelcomeActivity extends AppCompatActivity { } @Override - public boolean isViewFromObject(@NonNull View view, Object obj) { + public boolean isViewFromObject(@NonNull View view, @NonNull Object obj) { return view == obj; } diff --git a/app/src/main/res/layout-w900dp/drug_list.xml b/app/src/main/res/layout-w900dp/drug_list.xml index 05c8107..2d16261 100644 --- a/app/src/main/res/layout-w900dp/drug_list.xml +++ b/app/src/main/res/layout-w900dp/drug_list.xml @@ -17,8 +17,7 @@ --> - + app:zxing_viewfinder_mask="@color/grey"/> #3F51B5 #303F9F #FF4081 + #FFFFFF #4f91ff diff --git a/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt b/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt index 2b9c958..7572a40 100644 --- a/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt +++ b/fastlane/metadata/android/en-US/changelogs/v0.100-beta.txt @@ -1,6 +1,6 @@ # beta-0.100 – First public release -**REMENBER** Pilldroid is a French people user only. +**REMEMBER** Pilldroid is a French people user only. I made a lot a tests but there must stay some bugs. @@ -23,4 +23,4 @@ do not stress me it will be unproductive. Pilldroid will available only from [f-droid](https://f-droid.org) -You can reach me and discuss on [Pildroid](mailto://jacques+pilldroid@foucry.net). +You can reach me and discuss on [Pilldroid](mailto://jacques+pilldroid@foucry.net). diff --git a/fastlane/metadata/android/en-US/full_description.txt b/fastlane/metadata/android/en-US/full_description.txt index 59c2be4..59460e5 100644 --- a/fastlane/metadata/android/en-US/full_description.txt +++ b/fastlane/metadata/android/en-US/full_description.txt @@ -1,8 +1,8 @@ -Pilldroid is a theorical medics manager. It for French people +Pilldroid is a theoretical medics manager. It for French people only. Why for french people only? -

Pilldroid use a medics databases that come from French governement website, with +

Pilldroid use a medics databases that come from French government website, with medics which are refund by french health care national insurance (Sécurité Sociale).