Correction bug > Choix d'un mot de passe avec une pièce vide alors que que non autorisée

This commit is contained in:
Mathis CHAIGNEAU 2023-04-08 13:42:19 +02:00
parent 901c514158
commit cdc3597786
8 changed files with 13 additions and 9 deletions

View File

@ -15,28 +15,34 @@ import java.util.Random;
public class ChoixDuMotDePasse extends AppCompatActivity { public class ChoixDuMotDePasse extends AppCompatActivity {
private UnePiece un, deux, trois, quatre; private UnePiece un, deux, trois, quatre;
private boolean vide;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choix_du_mot_de_passe); setContentView(R.layout.activity_choix_du_mot_de_passe);
this.vide = this.getIntent().getBooleanExtra("vide", false);
this.un=(UnePiece) this.findViewById(R.id.code1); this.un=(UnePiece) this.findViewById(R.id.code1);
this.deux=(UnePiece) this.findViewById(R.id.code2); this.deux=(UnePiece) this.findViewById(R.id.code2);
this.trois=(UnePiece) this.findViewById(R.id.code3); this.trois=(UnePiece) this.findViewById(R.id.code3);
this.quatre=(UnePiece) this.findViewById(R.id.code4); this.quatre=(UnePiece) this.findViewById(R.id.code4);
boolean t=this.getIntent().getBooleanExtra("vide", false); this.un.setOnTouchListener(new MonOnTouchListener(this.un, this.vide));
this.un.setOnTouchListener(new MonOnTouchListener(this.un, t)); this.deux.setOnTouchListener(new MonOnTouchListener(this.deux, this.vide));
this.deux.setOnTouchListener(new MonOnTouchListener(this.deux, t)); this.trois.setOnTouchListener(new MonOnTouchListener(this.trois, this.vide));
this.trois.setOnTouchListener(new MonOnTouchListener(this.trois, t)); this.quatre.setOnTouchListener(new MonOnTouchListener(this.quatre, this.vide));
this.quatre.setOnTouchListener(new MonOnTouchListener(this.quatre, t));
this.findViewById(R.id.bouton_valider_code).setOnTouchListener(new OnTouchBoutonValider(this)); this.findViewById(R.id.bouton_valider_code).setOnTouchListener(new OnTouchBoutonValider(this));
} }
public void start(){ public void start(){
if(!this.vide && (this.un.getColor()==6 || this.deux.getColor()==6 || this.trois.getColor()==6 || this.quatre.getColor()==6)){
return;
}
Intent mastermind=new Intent(this, MasterMindActivity.class); Intent mastermind=new Intent(this, MasterMindActivity.class);
Intent data=this.getIntent(); Intent data=this.getIntent();
mastermind.putExtra("vide", data.getBooleanExtra("vide", false)); mastermind.putExtra("vide", data.getBooleanExtra("vide", false));

View File

@ -14,9 +14,7 @@ public class MonOnTouchListener implements View.OnTouchListener {
public MonOnTouchListener(UnePiece p, boolean t){ public MonOnTouchListener(UnePiece p, boolean t){
this.detector=new GestureDetector(new MonGestureListener(p)); this.detector=new GestureDetector(new MonGestureListener(p));
this.detector.setOnDoubleTapListener(new MonOnDoubleTapListener(p)); this.detector.setOnDoubleTapListener(new MonOnDoubleTapListener(p));
if(t==false){ this.detector.setIsLongpressEnabled(t);
this.detector.setIsLongpressEnabled(t);
}
} }
@Override @Override