print successfully integrated!
This commit is contained in:
@@ -55,6 +55,8 @@ dependencies {
|
|||||||
implementation(libs.recyclerview.v7)
|
implementation(libs.recyclerview.v7)
|
||||||
implementation(libs.appcompat)
|
implementation(libs.appcompat)
|
||||||
implementation(libs.material)
|
implementation(libs.material)
|
||||||
|
implementation(libs.google.core)
|
||||||
|
implementation(libs.zxing.android.embedded)
|
||||||
implementation(libs.constraintlayout)
|
implementation(libs.constraintlayout)
|
||||||
implementation(libs.navigation.fragment)
|
implementation(libs.navigation.fragment)
|
||||||
implementation(libs.navigation.ui)
|
implementation(libs.navigation.ui)
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -42,6 +44,10 @@ import com.example.quiz.utils.Result;
|
|||||||
import com.example.quiz.viewModel.PariViewModel;
|
import com.example.quiz.viewModel.PariViewModel;
|
||||||
import com.example.quiz.viewModel.SharedViewModel;
|
import com.example.quiz.viewModel.SharedViewModel;
|
||||||
import com.google.android.material.appbar.MaterialToolbar;
|
import com.google.android.material.appbar.MaterialToolbar;
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.MultiFormatWriter;
|
||||||
|
import com.google.zxing.WriterException;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@@ -65,6 +71,7 @@ public class BetValidation extends Fragment {
|
|||||||
SharedViewModel shared;
|
SharedViewModel shared;
|
||||||
|
|
||||||
|
|
||||||
|
private boolean order;
|
||||||
|
|
||||||
|
|
||||||
private TypeOfBet typeOfBet;
|
private TypeOfBet typeOfBet;
|
||||||
@@ -73,6 +80,8 @@ public class BetValidation extends Fragment {
|
|||||||
|
|
||||||
private Course course;
|
private Course course;
|
||||||
|
|
||||||
|
private int coeff;
|
||||||
|
|
||||||
private int mise;
|
private int mise;
|
||||||
|
|
||||||
private ActivityResultLauncher<Intent> enableBluetoothLauncher;
|
private ActivityResultLauncher<Intent> enableBluetoothLauncher;
|
||||||
@@ -83,9 +92,6 @@ public class BetValidation extends Fragment {
|
|||||||
PariViewModel pariViewModel;
|
PariViewModel pariViewModel;
|
||||||
|
|
||||||
|
|
||||||
boolean order = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public BetValidation() {
|
public BetValidation() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@@ -107,7 +113,34 @@ public class BetValidation extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
binding = FragmentBetValidationBinding.inflate(inflater, container, false);
|
binding = FragmentBetValidationBinding.inflate(inflater, container, false);
|
||||||
binding.combination.setText(getString(R.string.combination,""));
|
binding.coeff.setText(String.valueOf(1));
|
||||||
|
coeff = Integer.parseInt(binding.coeff.getText().toString());
|
||||||
|
binding.coeff.addTextChangedListener(new TextWatcher(){
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
if(charSequence.toString().isEmpty()){
|
||||||
|
binding.coeff.setError("Le coefficient est obligatoire");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(Integer.parseInt(charSequence.toString())<1){
|
||||||
|
binding.coeff.setError("Le coefficient doit être supérieur ou égal à 1 ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
coeff = Integer.parseInt(charSequence.toString());
|
||||||
|
calculateMise(selectedHorses.getValue().size());
|
||||||
|
binding.mise.setText(String.valueOf(mise+" CFA"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +187,7 @@ public class BetValidation extends Fragment {
|
|||||||
String combinationText = selectedHorses.getValue().stream()
|
String combinationText = selectedHorses.getValue().stream()
|
||||||
.map(h -> h)
|
.map(h -> h)
|
||||||
.collect(Collectors.joining("-"));
|
.collect(Collectors.joining("-"));
|
||||||
binding.combination.setText(getString(R.string.combination, combinationText));
|
binding.combination.setText( combinationText);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -166,6 +199,9 @@ public class BetValidation extends Fragment {
|
|||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
shared = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);
|
shared = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);
|
||||||
pariViewModel = new ViewModelProvider(this).get(PariViewModel.class);
|
pariViewModel = new ViewModelProvider(this).get(PariViewModel.class);
|
||||||
|
typeOfBet = shared.typeOfBet.getValue();
|
||||||
|
reunion = shared.selectedReunion.getValue();
|
||||||
|
course = shared.selectedCourse.getValue();
|
||||||
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
||||||
if(activity != null){
|
if(activity != null){
|
||||||
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
||||||
@@ -195,18 +231,23 @@ public class BetValidation extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
binding.order.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
||||||
order = isChecked;
|
|
||||||
calculateMise(selectedHorses.getValue().size(), shared.typeOfBet.getValue().getLabel());
|
|
||||||
});
|
|
||||||
|
|
||||||
selectedHorses.observe(getViewLifecycleOwner(), new Observer<List<String>>() {
|
selectedHorses.observe(getViewLifecycleOwner(), new Observer<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(List<String> horses) {
|
public void onChanged(List<String> horses) {
|
||||||
calculateMise(horses.size(), shared.typeOfBet.getValue().getLabel());
|
calculateMise(horses.size());
|
||||||
binding.mise.setText(String.valueOf(mise+" CFA"));
|
binding.mise.setText(String.valueOf(mise+" CFA"));
|
||||||
|
if(shared.typeOfBet.getValue().getNumberOfHorse() > 2 && horses.size() >= shared.typeOfBet.getValue().getNumberOfHorse()){
|
||||||
|
binding.order.setVisibility(View.VISIBLE);
|
||||||
|
}else{
|
||||||
|
binding.order.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
binding.order.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
order = isChecked;
|
||||||
|
calculateMise(selectedHorses.getValue().size());
|
||||||
|
binding.mise.setText(String.valueOf(mise+" CFA"));
|
||||||
|
});
|
||||||
|
|
||||||
binding.betValidateBtn.setOnClickListener(v->{
|
binding.betValidateBtn.setOnClickListener(v->{
|
||||||
if(binding.paymentType.getSelectedItem().toString().equals("Orange Money") && binding.phoneNumber.getText().toString().isEmpty()){
|
if(binding.paymentType.getSelectedItem().toString().equals("Orange Money") && binding.phoneNumber.getText().toString().isEmpty()){
|
||||||
@@ -217,12 +258,9 @@ public class BetValidation extends Fragment {
|
|||||||
if(shared.typeOfBet == null || shared.selectedReunion.getValue() == null || shared.selectedCourse == null){
|
if(shared.typeOfBet == null || shared.selectedReunion.getValue() == null || shared.selectedCourse == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
typeOfBet = shared.typeOfBet.getValue();
|
|
||||||
reunion = shared.selectedReunion.getValue();
|
|
||||||
course = shared.selectedCourse.getValue();
|
|
||||||
|
|
||||||
int required = typeOfBet.getNumberOfHorse();
|
int required = typeOfBet.getNumberOfHorse();
|
||||||
|
|
||||||
if(selectedHorses.getValue().size() < required){
|
if(selectedHorses.getValue().size() < required){
|
||||||
Toast.makeText(getContext(), "Veuillez sélectionner au moins"+required+" chevaux", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Veuillez sélectionner au moins"+required+" chevaux", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
@@ -238,12 +276,12 @@ public class BetValidation extends Fragment {
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
new PariCourseDto(shared.selectedCourse.getValue().getId()),
|
new PariCourseDto(shared.selectedCourse.getValue().getId()),
|
||||||
selectedHorses.getValue(),
|
selectedHorses.getValue(),
|
||||||
order?selectedHorses.getValue():new ArrayList<String>(),
|
order?new ArrayList<String>(): selectedHorses.getValue(),
|
||||||
order,
|
order,
|
||||||
"MULTI_4"
|
"MULTI_4"
|
||||||
);
|
);
|
||||||
pariViewModel.createPari(pari).observe(getViewLifecycleOwner(), new Observer<Result<Pari>>() {
|
pariViewModel.createPari(pari).observe(getViewLifecycleOwner(),new Observer<Result<Pari>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Result<Pari> pariResult) {
|
public void onChanged(Result<Pari> pariResult) {
|
||||||
switch (pariResult.status){
|
switch (pariResult.status){
|
||||||
@@ -254,7 +292,11 @@ public class BetValidation extends Fragment {
|
|||||||
Toast.makeText(getContext(), "En cours", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "En cours", Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
printPari();
|
try {
|
||||||
|
printPari(pariResult.data);
|
||||||
|
} catch (WriterException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,32 +308,37 @@ public class BetValidation extends Fragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
binding.deleteBtn.setOnClickListener(v->{
|
binding.deleteBtn.setOnClickListener(v->{
|
||||||
selectedHorses.setValue(List.of());
|
_initializeToZero();
|
||||||
binding.combination.setText(getString(R.string.combination,""));
|
|
||||||
setupNumberGrid(binding.gridNumbers);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printPari(){
|
public void printPari(Pari pari) throws WriterException {
|
||||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pmu_logo);
|
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pmu_logo);
|
||||||
|
Bitmap barcode = generateBarcodeBitmap(pari.getNumeroTicket(), 384, 100);
|
||||||
StringBuilder tspl = new StringBuilder();
|
StringBuilder tspl = new StringBuilder();
|
||||||
tspl.append("PARIS HIPPIQUE (PMU MALI)\n");
|
|
||||||
|
|
||||||
tspl.append(typeOfBet).append("\n");
|
tspl.append("Bamako").append("\n");
|
||||||
tspl.append("Tel: 555-1234\n");
|
tspl.append(shared.selectedCourse.getValue().getNom()).append("\n");
|
||||||
tspl.append("----------------------------\n");
|
|
||||||
tspl.append(reunion.getNom()).append("/").append(course.getLieu());
|
LocalDateTime dateTime = LocalDateTime.parse(shared.selectedCourse.getValue().getDateDepartCourse());
|
||||||
tspl.append("----------------------------\n");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
|
||||||
|
String formattedDate = dateTime.format(formatter);
|
||||||
|
tspl.append(formattedDate).append("\n");
|
||||||
|
tspl.append("Course ").append(String.valueOf(shared.selectedCourse.getValue().getId())).append("\n");
|
||||||
|
tspl.append(shared.selectedCourse.getValue().getType()).append("\n");
|
||||||
|
tspl.append("--------------------------------\n");
|
||||||
|
boolean isElargie = selectedHorses.getValue().size()>shared.typeOfBet.getValue().getNumberOfHorse();
|
||||||
|
tspl.append(isElargie?pari.getTypePari()+"/Elargie":pari.getTypePari()).append("\n");
|
||||||
String combinationText = selectedHorses.getValue().stream()
|
String combinationText = selectedHorses.getValue().stream()
|
||||||
.map(String::valueOf)
|
.map(String::valueOf)
|
||||||
.collect(Collectors.joining("-"));
|
.collect(Collectors.joining("-"));
|
||||||
|
tspl.append(combinationText).append("\n");
|
||||||
tspl.append("COMBINAISON : ").append(combinationText);
|
tspl.append("COEF: "+String.valueOf(coeff)).append(".0").append("\n");
|
||||||
|
tspl.append("--------------------------------\n");
|
||||||
tspl.append("\n----------------------------\n");
|
tspl.append("MONTANT: ").append(mise).append(" XOF\n");
|
||||||
tspl.append("TOTAL MISE: ").append(mise).append(" Fcfa\n");
|
tspl.append("-------------------------------\n");
|
||||||
tspl.append("----------------------------\n");
|
tspl.append("AGENT: ").append(" 3332\n");
|
||||||
tspl.append("Bonne chance !\n\n\n");
|
tspl.append("DATE: ").append(DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss").format(LocalDateTime.now())).append("\n");
|
||||||
if (BluetoothUtils.needsBluetoothPermissions()) {
|
if (BluetoothUtils.needsBluetoothPermissions()) {
|
||||||
if (!BluetoothUtils.hasBluetoothPermission(requireContext())) {
|
if (!BluetoothUtils.hasBluetoothPermission(requireContext())) {
|
||||||
// Demande la permission si non accordée
|
// Demande la permission si non accordée
|
||||||
@@ -302,37 +349,43 @@ public class BetValidation extends Fragment {
|
|||||||
|
|
||||||
// 2️⃣ Permission OK, on peut afficher la liste
|
// 2️⃣ Permission OK, on peut afficher la liste
|
||||||
try {
|
try {
|
||||||
Printama.with(getContext()).pintTextBuilder(tspl);
|
Printama.with(getContext()).printTextBuilder(tspl, bitmap, pari.getNumeroTicket(), barcode);
|
||||||
|
_initializeToZero();
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Toast.makeText(requireContext(),
|
Toast.makeText(requireContext(),
|
||||||
"Permission Bluetooth non accordée", Toast.LENGTH_SHORT).show();
|
"Permission Bluetooth non accordée", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
selectedHorses.setValue(List.of());
|
|
||||||
binding.combination.setText(getString(R.string.combination,""));
|
|
||||||
setupNumberGrid(binding.gridNumbers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void calculateMise(int nombreChevauxSelectionnes, String typeOfBet){
|
void _initializeToZero(){
|
||||||
if(typeOfBet.toString().toLowerCase().contains("couple")){
|
mise = 0;
|
||||||
if(nombreChevauxSelectionnes == 2){
|
binding.mise.setText(String.valueOf(mise+" CFA"));
|
||||||
|
selectedHorses.setValue(List.of());
|
||||||
|
binding.combination.setText("");
|
||||||
|
binding.order.setChecked(false);
|
||||||
|
order = false;
|
||||||
|
binding.order.setVisibility(View.GONE);
|
||||||
|
binding.coeff.setText("1");
|
||||||
|
coeff = Integer.parseInt(binding.coeff.getText().toString());
|
||||||
|
setupNumberGrid(binding.gridNumbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculateMise(int nombreChevauxSelectionnes){
|
||||||
|
if(typeOfBet.getNumberOfHorse() == 1){
|
||||||
|
if(nombreChevauxSelectionnes==1){
|
||||||
mise = 300;
|
mise = 300;
|
||||||
}
|
}
|
||||||
if(nombreChevauxSelectionnes > 2){
|
|
||||||
mise = 300 + (nombreChevauxSelectionnes - 3)*300;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(typeOfBet.toString().toLowerCase().contains("tierce")){
|
if(typeOfBet.getNumberOfHorse() == 2){
|
||||||
if(nombreChevauxSelectionnes == 3){
|
if(nombreChevauxSelectionnes == 2){
|
||||||
mise = 400;
|
mise = 400;
|
||||||
}
|
}
|
||||||
if(nombreChevauxSelectionnes > 3){
|
if(nombreChevauxSelectionnes > 2){
|
||||||
mise = 400 + (nombreChevauxSelectionnes - 3)*400;
|
mise = 400 + (nombreChevauxSelectionnes - 2)*300;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(typeOfBet.toString().toLowerCase().contains("quarte")){
|
if(typeOfBet.getNumberOfHorse() == 3){
|
||||||
if(nombreChevauxSelectionnes == 3){
|
if(nombreChevauxSelectionnes == 3){
|
||||||
mise = 500;
|
mise = 500;
|
||||||
}
|
}
|
||||||
@@ -340,16 +393,47 @@ public class BetValidation extends Fragment {
|
|||||||
mise = 500 + (nombreChevauxSelectionnes - 3)*500;
|
mise = 500 + (nombreChevauxSelectionnes - 3)*500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(typeOfBet.toString().toLowerCase().contains("quinte")){
|
if(typeOfBet.getNumberOfHorse() == 4){
|
||||||
if(nombreChevauxSelectionnes == 3){
|
if(nombreChevauxSelectionnes == 4){
|
||||||
mise = 1000;
|
mise = 600;
|
||||||
}
|
}
|
||||||
if(nombreChevauxSelectionnes > 3){
|
if(nombreChevauxSelectionnes > 4){
|
||||||
mise = 1000 + (nombreChevauxSelectionnes - 3)*1000;
|
mise = 600 + (nombreChevauxSelectionnes - 4)*600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(typeOfBet.getNumberOfHorse() == 5){
|
||||||
|
if(nombreChevauxSelectionnes == 5){
|
||||||
|
mise = 1200;
|
||||||
|
}
|
||||||
|
if(nombreChevauxSelectionnes > 5){
|
||||||
|
mise = 1200 + (nombreChevauxSelectionnes - 5)*1200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mise = order?mise * coeff * _calculateFactorial(shared.typeOfBet.getValue().getNumberOfHorse()):mise * coeff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer _calculateFactorial(int n){
|
||||||
|
int f = 1;
|
||||||
|
if(n == 0){
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
for(int i = 1; i <=n; i++){
|
||||||
|
f *= i;
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Bitmap generateBarcodeBitmap(String contents, int width, int height) throws WriterException {
|
||||||
|
BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.CODE_128, width, height);
|
||||||
|
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
bmp.setPixel(x, y, bitMatrix.get(x, y) ? android.graphics.Color.BLACK : android.graphics.Color.WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
public static String generate12Digits() {
|
public static String generate12Digits() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|||||||
@@ -66,14 +66,6 @@ public class ListOFBets extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
|
||||||
if(activity != null){
|
|
||||||
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
|
||||||
activity.setSupportActionBar(toolbar);
|
|
||||||
if(activity.getSupportActionBar() != null){
|
|
||||||
activity.getSupportActionBar().setTitle("Liste des courses");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -170,4 +162,17 @@ public class ListOFBets extends Fragment {
|
|||||||
}
|
}
|
||||||
}, getViewLifecycleOwner(), Lifecycle.State.RESUMED);
|
}, getViewLifecycleOwner(), Lifecycle.State.RESUMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
||||||
|
activity.setSupportActionBar(toolbar);
|
||||||
|
if(activity.getSupportActionBar() != null){
|
||||||
|
activity.getSupportActionBar().setTitle("Liste des courses");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,11 @@ public class ListOfReunions extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
||||||
@@ -126,10 +130,8 @@ public class ListOfReunions extends Fragment {
|
|||||||
activity.getSupportActionBar().show();
|
activity.getSupportActionBar().show();
|
||||||
activity.getSupportActionBar().setTitle("Liste des réunions");
|
activity.getSupportActionBar().setTitle("Liste des réunions");
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar.setBackgroundColor(getResources().getColor(R.color.primary_green, null));
|
toolbar.setBackgroundColor(getResources().getColor(R.color.primary_green, null));
|
||||||
toolbar.setTitleTextColor(getResources().getColor(R.color.white, null));
|
toolbar.setTitleTextColor(getResources().getColor(R.color.white, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ import com.google.android.material.appbar.MaterialToolbar;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
|
||||||
@@ -57,14 +58,6 @@ public class ListOfTypeOfBets extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
|
||||||
if(activity != null){
|
|
||||||
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
|
||||||
activity.setSupportActionBar(toolbar);
|
|
||||||
if(activity.getSupportActionBar() != null){
|
|
||||||
activity.getSupportActionBar().setTitle("Liste des jeux");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,18 +81,8 @@ public class ListOfTypeOfBets extends Fragment {
|
|||||||
binding.typeOfBetRecyclerView.setAdapter(adapter);
|
binding.typeOfBetRecyclerView.setAdapter(adapter);
|
||||||
List<TypeOfBet> types = List.of(
|
List<TypeOfBet> types = List.of(
|
||||||
new TypeOfBet(
|
new TypeOfBet(
|
||||||
"Simple",
|
"Couple placé",
|
||||||
"SIMPLE",
|
"COUPLE_PLACE",
|
||||||
1
|
|
||||||
),
|
|
||||||
new TypeOfBet(
|
|
||||||
"Jumellé placé",
|
|
||||||
"JUMELLE_PLACE",
|
|
||||||
2
|
|
||||||
),
|
|
||||||
new TypeOfBet(
|
|
||||||
"Jumellé gagnant",
|
|
||||||
"JUMELLE_GAGNANT",
|
|
||||||
2
|
2
|
||||||
),
|
),
|
||||||
new TypeOfBet(
|
new TypeOfBet(
|
||||||
@@ -123,25 +106,24 @@ public class ListOfTypeOfBets extends Fragment {
|
|||||||
5
|
5
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
String betType = shared.selectedCourse.getValue().getType();
|
||||||
// Observer les résultats
|
Log.d("BET_TYPE", betType);
|
||||||
/*viewModel.types.observe(getViewLifecycleOwner(), type -> {
|
List<TypeOfBet> useList = new ArrayList<>();
|
||||||
List<String> types = List.of();
|
if(betType.toLowerCase().startsWith("quinte")){
|
||||||
if(type == null){
|
useList = types.stream()
|
||||||
return;
|
.filter(bet -> !bet.getName().toLowerCase().contains("quarte"))
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
switch (type){
|
}
|
||||||
case TIERCE:
|
if(betType.toLowerCase().startsWith("quarte")){
|
||||||
types = List.of("Couple Gagnant", "Couple Place", "Tierce");
|
useList = types.subList(0, 4);
|
||||||
case QUARTE:
|
}
|
||||||
types = List.of("Couple Gagnant", "Couple Place", "Tierce", "Quarte");
|
if(betType.toLowerCase().startsWith("tierce")){
|
||||||
case QUINTE:
|
useList = types.subList(0, 3);
|
||||||
types = List.of("Couple Gagnant", "Couple Place", "Tierce", "Quinte");
|
}
|
||||||
break;
|
if(betType.toLowerCase().contains("couple")){
|
||||||
}
|
useList = types.subList(0, 2);
|
||||||
adapter.setTypes(types);
|
}
|
||||||
});*/
|
adapter.setTypes(useList);
|
||||||
adapter.setTypes(types);
|
|
||||||
adapter.setOnItemClickListener(type -> {
|
adapter.setOnItemClickListener(type -> {
|
||||||
shared.setTypeOfBet(type);
|
shared.setTypeOfBet(type);
|
||||||
});
|
});
|
||||||
@@ -159,4 +141,17 @@ public class ListOfTypeOfBets extends Fragment {
|
|||||||
.commit();
|
.commit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
|
||||||
|
activity.setSupportActionBar(toolbar);
|
||||||
|
if(activity.getSupportActionBar() != null){
|
||||||
|
activity.getSupportActionBar().setTitle("Liste des jeux");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,10 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import android.os.Bundle;
|
|||||||
import com.anggastudio.printama.Pref;
|
import com.anggastudio.printama.Pref;
|
||||||
import com.anggastudio.printama.Printama;
|
import com.anggastudio.printama.Printama;
|
||||||
import com.example.quiz.utils.BluetoothUtils;
|
import com.example.quiz.utils.BluetoothUtils;
|
||||||
|
import com.example.quiz.utils.SessionManager;
|
||||||
import com.example.quiz.utils.SharedPrefsHelper;
|
import com.example.quiz.utils.SharedPrefsHelper;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -27,6 +29,10 @@ import dagger.hilt.android.AndroidEntryPoint;
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class PageQuiz extends AppCompatActivity {
|
public class PageQuiz extends AppCompatActivity {
|
||||||
|
|
||||||
|
private SessionManager sessionManager;
|
||||||
|
private Handler handler = new Handler();
|
||||||
|
private Runnable checkRunnable;
|
||||||
|
|
||||||
private AppBarConfiguration appBarConfiguration;
|
private AppBarConfiguration appBarConfiguration;
|
||||||
private ActivityPageQuizBinding binding;
|
private ActivityPageQuizBinding binding;
|
||||||
|
|
||||||
@@ -60,6 +66,20 @@ public class PageQuiz extends AppCompatActivity {
|
|||||||
requestPermission();
|
requestPermission();
|
||||||
binding = ActivityPageQuizBinding.inflate(getLayoutInflater());
|
binding = ActivityPageQuizBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
sessionManager = new SessionManager();
|
||||||
|
|
||||||
|
// Vérification périodique
|
||||||
|
checkRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (sessionManager.isExpired()) {
|
||||||
|
Toast.makeText(getApplicationContext(), "I'm herer", Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
handler.postDelayed(this, 60 * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handler.postDelayed(checkRunnable, 60 * 1000);
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
binding.toolbar.setBackgroundColor(Color.parseColor("#501C5A29"));
|
binding.toolbar.setBackgroundColor(Color.parseColor("#501C5A29"));
|
||||||
binding.fab.setOnClickListener(new View.OnClickListener() {
|
binding.fab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Course {
|
public class Course {
|
||||||
private int id;
|
private int id;
|
||||||
private String stype;
|
private String type;
|
||||||
private String numero;
|
private String numero;
|
||||||
private String nom;
|
private String nom;
|
||||||
private String lieu;
|
private String lieu;
|
||||||
@@ -20,9 +20,9 @@ public class Course {
|
|||||||
private String statut;
|
private String statut;
|
||||||
private int nombreChevauxInscrits;
|
private int nombreChevauxInscrits;
|
||||||
|
|
||||||
public Course(int id, String stype, String numero, String nom, String lieu, String dateDepartCourse, int reunionId, String particularite, int partants, String statut, int nombreChevauxInscrits) {
|
public Course(int id, String type, String numero, String nom, String lieu, String dateDepartCourse, int reunionId, String particularite, int partants, String statut, int nombreChevauxInscrits) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.stype = stype;
|
this.type = type;
|
||||||
this.numero = numero;
|
this.numero = numero;
|
||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
this.lieu = lieu;
|
this.lieu = lieu;
|
||||||
@@ -42,12 +42,12 @@ public class Course {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStype() {
|
public String getType() {
|
||||||
return stype;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStype(String stype) {
|
public void setType(String stype) {
|
||||||
this.stype = stype;
|
this.type = stype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNumero() {
|
public String getNumero() {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||||||
@Module
|
@Module
|
||||||
@InstallIn(SingletonComponent.class)
|
@InstallIn(SingletonComponent.class)
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private static final String BASE_URL = "https://e3a593a96788.ngrok-free.app/api/v1/";
|
private static final String BASE_URL = "https://performances-leeds-operations-continued.trycloudflare.com/api/v1/";
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|||||||
25
app/src/main/java/com/example/quiz/utils/SessionManager.java
Normal file
25
app/src/main/java/com/example/quiz/utils/SessionManager.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.example.quiz.utils;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class SessionManager {
|
||||||
|
// 10 minutes en millisecondes
|
||||||
|
private static final long sessionExpiredTime = 60 * 1000;
|
||||||
|
|
||||||
|
private LocalDateTime lastExpiredDate;
|
||||||
|
|
||||||
|
public SessionManager() {
|
||||||
|
updateLastExpiredDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLastExpiredDate() {
|
||||||
|
lastExpiredDate = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpired() {
|
||||||
|
// Vérifie si le temps écoulé depuis lastExpiredDate > sessionExpiredTime
|
||||||
|
Duration elapsed = Duration.between(lastExpiredDate, LocalDateTime.now());
|
||||||
|
return elapsed.toMillis() > sessionExpiredTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
4
app/src/main/res/drawable/combination_text_input.xml
Normal file
4
app/src/main/res/drawable/combination_text_input.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
|
<solid android:color="@color/gray"/>
|
||||||
|
</shape>
|
||||||
@@ -2,138 +2,185 @@
|
|||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="15dp"
|
android:background="@color/gray"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="5dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="15dp"
|
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="15dp"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
<TextView
|
|
||||||
android:text="@string/hors_choice"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="25sp"
|
|
||||||
android:layout_marginTop="35dp"
|
|
||||||
android:textColor="@color/text_color"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/horseName"
|
android:id="@+id/horseName"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="17sp"
|
|
||||||
android:textColor="@color/primary_green"
|
|
||||||
android:layout_marginTop="15dp"
|
android:layout_marginTop="15dp"
|
||||||
android:layout_marginBottom="25dp"
|
android:layout_marginBottom="5dp"
|
||||||
|
android:textColor="@color/primary_green"
|
||||||
android:textFontWeight="300"
|
android:textFontWeight="300"
|
||||||
>
|
android:textSize="17sp">
|
||||||
|
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider2"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingVertical="8dp"
|
android:gravity="start"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="start">
|
android:paddingVertical="8dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/combination"
|
android:id="@+id/combination"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40sp"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@drawable/edittext_border"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="10sp"
|
||||||
|
android:text=""
|
||||||
|
android:textColor="@color/primary_green"
|
||||||
android:textFontWeight="800"
|
android:textFontWeight="800"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:text="@string/combination"
|
tools:ignore="RtlSymmetry"></TextView>
|
||||||
android:textColor="@color/primary_green">
|
|
||||||
</TextView>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<View
|
|
||||||
android:id="@+id/divider3"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginVertical="13dp"
|
android:layout_marginVertical="13dp"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
>
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<GridLayout
|
<GridLayout
|
||||||
android:id="@+id/grid_numbers"
|
android:id="@+id/grid_numbers"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:useDefaultMargins="true"/>
|
android:useDefaultMargins="true" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:gravity="center_vertical"
|
android:padding="16dp">
|
||||||
android:padding="12dp">
|
|
||||||
|
|
||||||
|
<!-- Bloc coefficient + checkbox -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:elevation="4dp"
|
||||||
|
android:layout_marginBottom="14dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:clipToPadding="false">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/coefficient"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#444444" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:padding="10dp">
|
||||||
|
|
||||||
|
<!-- EditText -->
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/coeff"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:inputType="number"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="1"
|
||||||
|
android:background="@drawable/edittext_border" />
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/order"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/tout_ordre"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Mise -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mise"
|
android:id="@+id/mise"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:text="1"
|
||||||
android:textSize="22sp"
|
android:textSize="28sp"
|
||||||
android:textColor="@color/primary_green"
|
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="0" />
|
android:textColor="@color/primary_green"
|
||||||
|
android:gravity="center"
|
||||||
<CheckBox
|
android:padding="12dp"
|
||||||
android:id="@+id/order"
|
android:background="@android:color/white"
|
||||||
android:layout_width="wrap_content"
|
android:elevation="4dp"
|
||||||
android:layout_height="wrap_content"
|
android:clipToPadding="false"/>
|
||||||
android:paddingStart="12dp"
|
|
||||||
android:text="Ordre" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/paymentType"
|
android:id="@+id/paymentType"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:background="@drawable/edittext_border"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="15dp"
|
android:background="@drawable/edittext_border"
|
||||||
android:scrollbarSize="10dp"
|
|
||||||
android:defaultFocusHighlightEnabled="true"
|
android:defaultFocusHighlightEnabled="true"
|
||||||
android:entries="@array/paymentType">
|
android:entries="@array/paymentType"
|
||||||
</Spinner>
|
android:padding="15dp"
|
||||||
|
android:scrollbarSize="10dp"></Spinner>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/phoneNumber"
|
android:id="@+id/phoneNumber"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="15dp"
|
android:layout_marginTop="15dp"
|
||||||
android:drawableStart="@android:drawable/stat_sys_vp_phone_call"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:background="@drawable/edittext_border"
|
android:background="@drawable/edittext_border"
|
||||||
|
android:drawableStart="@android:drawable/stat_sys_vp_phone_call"
|
||||||
android:inputType="phone"
|
android:inputType="phone"
|
||||||
android:visibility="gone"
|
android:padding="10dp"
|
||||||
>
|
android:visibility="gone"></EditText>
|
||||||
</EditText>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:weightSum="3">
|
android:weightSum="3">
|
||||||
|
|
||||||
@@ -142,39 +189,36 @@
|
|||||||
style="?android:attr/buttonBarButtonStyle"
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:backgroundTint="@color/primary_red"
|
|
||||||
android:text="@string/cancel"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
/>
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@color/primary_red"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/cancel"
|
||||||
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/deleteBtn"
|
android:id="@+id/deleteBtn"
|
||||||
style="?android:attr/buttonBarButtonStyle"
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:backgroundTint="@android:color/holo_blue_dark"
|
|
||||||
android:text="@string/delete"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
/>
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@android:color/holo_blue_dark"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/delete"
|
||||||
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/betValidateBtn"
|
android:id="@+id/betValidateBtn"
|
||||||
style="?android:attr/buttonBarButtonStyle"
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:backgroundTint="@color/primary_green"
|
|
||||||
android:text="@string/validate"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
/>
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@color/primary_green"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/validate"
|
||||||
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:background="@color/text_hint_color">
|
android:background="@color/white">
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -69,4 +69,6 @@
|
|||||||
</string>
|
</string>
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
<string name="coefficient">Coefficient</string>
|
||||||
|
<string name="tout_ordre">Tout ordre</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.7.3"
|
agp = "8.7.3"
|
||||||
|
googleCore = "3.5.1"
|
||||||
hiltAndroid = "2.51"
|
hiltAndroid = "2.51"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.3.0"
|
junitVersion = "1.3.0"
|
||||||
@@ -30,9 +31,11 @@ powermockModuleJunit4 = "2.0.9"
|
|||||||
preference = "1.1.1"
|
preference = "1.1.1"
|
||||||
robolectric = "4.11.1"
|
robolectric = "4.11.1"
|
||||||
runner = "1.5.2"
|
runner = "1.5.2"
|
||||||
|
zxingAndroidEmbedded = "4.3.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
|
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
|
||||||
|
google-core = { module = "com.google.zxing:core", version.ref = "googleCore" }
|
||||||
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
|
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
|
||||||
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hiltAndroid" }
|
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hiltAndroid" }
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
@@ -65,6 +68,7 @@ preference = { group = "androidx.preference", name = "preference", version.ref =
|
|||||||
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
|
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
|
||||||
rules = { module = "androidx.test:rules", version.ref = "core" }
|
rules = { module = "androidx.test:rules", version.ref = "core" }
|
||||||
runner = { module = "androidx.test:runner", version.ref = "runner" }
|
runner = { module = "androidx.test:runner", version.ref = "runner" }
|
||||||
|
zxing-android-embedded = { module = "com.journeyapps:zxing-android-embedded", version.ref = "zxingAndroidEmbedded" }
|
||||||
|
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
|||||||
@@ -351,11 +351,19 @@ public class Printama {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pintTextBuilder(StringBuilder text){
|
public void printTextBuilder(StringBuilder text, Bitmap bitmap, String numeroTicket,Bitmap barCode){
|
||||||
_printama.connect(printama -> {
|
_printama.connect(printama -> {
|
||||||
|
printama.printImage(bitmap);
|
||||||
|
printama.printText("\n\n--------------------------------\n");
|
||||||
|
printama.printImage(barCode);
|
||||||
|
printama.printText("\n"+numeroTicket+"\n",PA.CENTER);
|
||||||
|
printama.printText("\n--------------------------------\n");
|
||||||
printama.setNormalText();
|
printama.setNormalText();
|
||||||
_util.setAlign(PA.CENTER);
|
_util.setAlign(PA.LEFT);
|
||||||
printTextBuilder(text);
|
printTextBuilder(text);
|
||||||
|
printama.printText("--------------------------------\n");
|
||||||
|
printama.printText("Powered by PMU-MALI", PA.CENTER);
|
||||||
|
printama.printText("\n--------------------------------\n \n \n");
|
||||||
printama.feedPaper();
|
printama.feedPaper();
|
||||||
printama.close();
|
printama.close();
|
||||||
});
|
});
|
||||||
@@ -554,7 +562,7 @@ public class Printama {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void printTextBuilder(StringBuilder text){
|
private void printTextBuilder(StringBuilder text){
|
||||||
text.append("\n \n \n");
|
text.append("\n");
|
||||||
_util.printTextBuilder(text);
|
_util.printTextBuilder(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user