mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-21 20:19:23 +01:00
Some improvement after code Analysis
This commit is contained in:
parent
207179a5b1
commit
8fccb00f3a
13 changed files with 48 additions and 123 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -109,9 +109,8 @@ class DBDrugs extends SQLiteOpenHelper {
|
|||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (myDataBase != null) {
|
||||
myDataBase.close();
|
||||
}
|
||||
assert false;
|
||||
myDataBase.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<Drug>() {
|
||||
@Override
|
||||
public int compare(Drug lhs, Drug rhs) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
-->
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/drug_list"
|
||||
android:name="net.foucry.pilldroid.MedicamentListFragment"
|
||||
android:layout_width="@dimen/item_width"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
app:zxing_result_view="@color/zxing_custom_result_view"
|
||||
app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
|
||||
app:zxing_viewfinder_laser_visibility="true"
|
||||
app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask" />
|
||||
app:zxing_viewfinder_mask="@color/grey"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/zxing_status_view"
|
||||
|
@ -33,7 +33,7 @@
|
|||
android:textSize="32sp"
|
||||
android:textAlignment="center"
|
||||
android:text="@string/zxing_msg_default_status"
|
||||
android:textColor="@color/design_default_color_primary_dark"
|
||||
android:textColor="@color/white"
|
||||
tools:ignore="PrivateResource" />
|
||||
|
||||
<ImageButton
|
||||
|
|
0
app/src/main/res/mipmap-anydpi
Normal file
0
app/src/main/res/mipmap-anydpi
Normal file
|
@ -3,6 +3,7 @@
|
|||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="white">#FFFFFF</color>
|
||||
|
||||
<!-- slide bg -->
|
||||
<color name="bg_screen1">#4f91ff</color>
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<strong>Pilldroid</strong> is a theorical medics manager. It for French people
|
||||
<strong>Pilldroid</strong> is a theoretical medics manager. It for French people
|
||||
only.
|
||||
|
||||
<strong>Why for french people only?</strong>
|
||||
<p>Pilldroid use a medics databases that come from French governement website, with
|
||||
<p>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).</p>
|
||||
|
||||
|
|
Loading…
Reference in a new issue