Chnage backupprefs layout

This commit is contained in:
jacques 2024-07-09 21:46:34 +02:00
parent c45957d813
commit 7aca0ee21b
7 changed files with 211 additions and 65 deletions

View file

@ -87,7 +87,8 @@ public class CustomScannerActivity extends AppCompatActivity implements Decorate
} }
@Override @Override
public void onBackPressed(){ public void onBackPressed() {
super.onBackPressed();
onCancel(this.getCurrentFocus()); onCancel(this.getCurrentFocus());
} }

View file

@ -310,8 +310,7 @@ public class DrugListActivity extends AppCompatActivity {
startActivity(new Intent(this, WelcomeActivity.class)); startActivity(new Intent(this, WelcomeActivity.class));
return true; return true;
} else if (id == R.id.ImportExport) { } else if (id == R.id.ImportExport) {
//backupPrescriptions(); backupprefs();
// TODO: a changer ainsi que le menu.
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -711,4 +710,33 @@ public class DrugListActivity extends AppCompatActivity {
} }
} }
} }
void backupprefs() {
final Dialog dlg = new Dialog(this);
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
Objects.requireNonNull(dlg.getWindow()).setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dlg.setContentView(R.layout.backupprefs);
dlg.setCancelable(false);
Button btn_export = dlg.findViewById(R.id.switch_btn_export);
Button btn_import = dlg.findViewById(R.id.switch_btn_import);
Button btn_location = dlg.findViewById(R.id.btn_backup_location);
Button btn_properties = dlg.findViewById(R.id.btn_properties);
btn_export.setEnabled(true);
btn_import.setEnabled(false);
Button ok = dlg.findViewById(R.id.ok_btn);
Button cancel = dlg.findViewById(R.id.cancel_btn);
ok.setOnClickListener(v -> {
dlg.cancel();
//TODO: manage the options
Log.i(TAG, "ok button");
});
cancel.setOnClickListener(v -> {
dlg.cancel();
Log.i(TAG, "dismiss dialog");
});
dlg.show();
}
} }

View file

@ -1,75 +1,148 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cl_main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingBottom="16dp" tools:ignore="MissingDefaultResource">
tools:ignore="HardcodedText"
tools:context=".DrugListActivity">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout" android:id="@+id/materialCardView"
android:layout_width="match_parent" android:layout_width="370dp"
android:layout_height="match_parent"/> android:layout_height="319dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
app:cardCornerRadius="@dimen/btn_radius"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.35">
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.button.MaterialButton
android:id="@+id/btn_addFruit" android:id="@+id/switch_btn_export"
android:layout_width="wrap_content" style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_gravity="bottom|end"
android:layout_margin="32dp"
android:src="@drawable/ic_add"
android:contentDescription="Add new Fruit" />
<LinearLayout
android:id="@+id/ll_properties"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:orientation="vertical"
android:padding="16dp"
app:layout_anchor="@+id/constraintLayout"
app:layout_anchorGravity="center">
<include layout="@layout/custom_switch_btn"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_marginEnd="68dp"
android:layout_weight="1"
android:backgroundTint="@color/selected_background"
android:gravity="center"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="@string/export_prescriptions"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@+id/switch_btn_import"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/switch_btn_import" />
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/btn_backup_location" android:id="@+id/switch_btn_import"
style="@style/Widget.MaterialComponents.Button" style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp" android:layout_weight="1"
android:layout_weight="1" android:backgroundTint="@color/unselected_background"
android:background="@drawable/rounded_btn" android:gravity="center"
android:text="Backup Location" android:maxLines="1"
android:textAllCaps="false" android:minWidth="100dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body2" android:paddingStart="25dp"
android:textColor="@android:color/white" /> android:paddingEnd="25dp"
android:text="@string/import_prescriptions"
android:textColor="@color/white"
app:layout_constraintEnd_toStartOf="@+id/switch_btn_export"
app:layout_constraintHorizontal_bias="0.99"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="93dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/notagreed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/rounded_btn"
android:gravity="center"
android:maxLines="1"
android:minWidth="100dp"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="@string/button_cancel"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/agreed"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="HardcodedText,SpUsage" />
<Button <com.google.android.material.button.MaterialButton
android:id="@+id/btn_properties" android:id="@+id/btn_backup_location"
style="@style/Widget.MaterialComponents.Button" android:layout_width="wrap_content"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_marginStart="76dp"
android:layout_marginStart="16dp" android:layout_marginEnd="2dp"
android:layout_weight="1" android:background="@drawable/rounded_btn"
android:background="@drawable/rounded_btn" android:gravity="center"
android:text="Properties" android:maxLines="1"
android:textAllCaps="false" android:minWidth="100dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body2" android:paddingStart="25dp"
android:textColor="@android:color/white" /> android:paddingEnd="25dp"
android:text="@string/location"
app:layout_constraintBottom_toBottomOf="@+id/btn_properties"
app:layout_constraintEnd_toStartOf="@+id/btn_properties"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/btn_properties"
app:layout_constraintVertical_bias="0.0" />
</LinearLayout> <com.google.android.material.button.MaterialButton
</LinearLayout> android:id="@+id/btn_properties"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="68dp"
android:background="@drawable/rounded_btn"
android:gravity="center"
android:maxLines="1"
android:minWidth="100dp"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="@string/properties"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteY="173dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/agreed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="@drawable/rounded_btn"
android:gravity="center"
android:maxLines="1"
android:minWidth="100dp"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:text="@string/button_ok"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@+id/notagreed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/notagreed"
app:layout_constraintVertical_bias="0.0"
tools:ignore="HardcodedText,SpUsage" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/shapeableImageView"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="4dp"
android:background="@drawable/shadow_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_conversion_absoluteHeight="61dp"
tools:layout_conversion_absoluteWidth="61dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:id="@+id/ok_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="178dp"
android:text="@string/button_ok"
android:textColor="@color/white"
android:backgroundTint="@color/colorPrimary"
app:layout_constraintEnd_toStartOf="@+id/cancel_btn"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:id="@+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:text="@string/button_cancel"
android:textColor="@color/white"
android:backgroundTint="@color/material_on_surface_disabled"
app:layout_constraintBaseline_toBaselineOf="@+id/ok_btn"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -12,7 +12,7 @@
android:layout_height="237dp" android:layout_height="237dp"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
app:cardCornerRadius="11dp" app:cardCornerRadius="@dimen/btn_radius"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View file

@ -74,4 +74,6 @@
<string name="Undo">Annuler</string> <string name="Undo">Annuler</string>
<string name="trash_icon">Icône de poubelle</string> <string name="trash_icon">Icône de poubelle</string>
<string name="addInList">Ajouter à votre liste de médicament</string> <string name="addInList">Ajouter à votre liste de médicament</string>
<string name="location">Chemin</string>
<string name="properties">Préférences</string>
</resources> </resources>

View file

@ -79,4 +79,6 @@
<string name="import_export" translatable="false">Import/Export</string> <string name="import_export" translatable="false">Import/Export</string>
<string name="import_prescriptions" translatable="false">Import</string> <string name="import_prescriptions" translatable="false">Import</string>
<string name="export_prescriptions" translatable="false">Export</string> <string name="export_prescriptions" translatable="false">Export</string>
<string name="location">Location</string>
<string name="properties">Properties</string>
</resources> </resources>