mirror of
https://github.com/vanitasvitae/EnigmAndroid.git
synced 2024-11-21 20:02:06 +01:00
Added colors to Pluggables-Dialog, started SeedInterpreter (just started EXCLAMATIONMARK)
This commit is contained in:
parent
63682d6462
commit
8e49652f91
16 changed files with 743 additions and 188 deletions
|
@ -8,11 +8,14 @@ v0.1.8-not-yet-released<
|
|||
*Changed identifiers of enigma models
|
||||
*Changed landscape layout of enigma model d
|
||||
*Updated the about-dialog text.
|
||||
*Shortened EnigmaStateBundle
|
||||
*Added different colors to the plugboard-/pluggable reflector dialog. This helps to differentiate connections.
|
||||
*TODO: Add Enigma Z (Probably wont happen due to lack of information :/)
|
||||
*TODO: Rework Rotor-/Reflector creation
|
||||
*TODO: Add multi-Enigma (select any rotor/reflector etc. Probably wont happen too soon)
|
||||
*TODO: Rework InputPreparer using decorator pattern to allow user customization
|
||||
*
|
||||
*TODO: Button to set the Enigma into a random configuration
|
||||
*TODO: Enigma configuration from seed (text or qr code)
|
||||
|
||||
v0.1.7-15.09.2015<
|
||||
*Added Enigma K
|
||||
|
|
|
@ -21,34 +21,24 @@ package de.vanitasvitae.enigmandroid.enigma;
|
|||
* @author vanitasvitae
|
||||
*/
|
||||
public class EnigmaStateBundle{
|
||||
private String machineType;
|
||||
|
||||
private int typeEntryWheel;
|
||||
|
||||
private int typeRotor1;
|
||||
private int typeRotor2;
|
||||
private int typeRotor3;
|
||||
private int typeRotor4;
|
||||
private int typeRotor5;
|
||||
private int typeRotor6;
|
||||
private int typeRotor7;
|
||||
private int typeRotor8;
|
||||
|
||||
private int rotationRotor1;
|
||||
private int rotationRotor2;
|
||||
private int rotationRotor3;
|
||||
private int rotationRotor4;
|
||||
private int rotationRotor5;
|
||||
private int rotationRotor6;
|
||||
private int rotationRotor7;
|
||||
private int rotationRotor8;
|
||||
|
||||
private int ringSettingRotor1;
|
||||
private int ringSettingRotor2;
|
||||
private int ringSettingRotor3;
|
||||
private int ringSettingRotor4;
|
||||
private int ringSettingRotor5;
|
||||
private int ringSettingRotor6;
|
||||
private int ringSettingRotor7;
|
||||
private int ringSettingRotor8;
|
||||
|
||||
private int typeReflector;
|
||||
|
||||
|
@ -59,6 +49,16 @@ public class EnigmaStateBundle{
|
|||
|
||||
private int[] configurationReflector;
|
||||
|
||||
public String getMachineType()
|
||||
{
|
||||
return this.machineType;
|
||||
}
|
||||
|
||||
public void setMachineType(String type)
|
||||
{
|
||||
this.machineType = type;
|
||||
}
|
||||
|
||||
public int getTypeRotor1() {
|
||||
return typeRotor1;
|
||||
}
|
||||
|
@ -91,38 +91,6 @@ public class EnigmaStateBundle{
|
|||
this.typeRotor4 = typeRotor4;
|
||||
}
|
||||
|
||||
public int getTypeRotor5() {
|
||||
return typeRotor5;
|
||||
}
|
||||
|
||||
public void setTypeRotor5(int typeRotor5) {
|
||||
this.typeRotor5 = typeRotor5;
|
||||
}
|
||||
|
||||
public int getTypeRotor6() {
|
||||
return typeRotor6;
|
||||
}
|
||||
|
||||
public void setTypeRotor6(int typeRotor6) {
|
||||
this.typeRotor6 = typeRotor6;
|
||||
}
|
||||
|
||||
public int getTypeRotor7() {
|
||||
return typeRotor7;
|
||||
}
|
||||
|
||||
public void setTypeRotor7(int typeRotor7) {
|
||||
this.typeRotor7 = typeRotor7;
|
||||
}
|
||||
|
||||
public int getTypeRotor8() {
|
||||
return typeRotor8;
|
||||
}
|
||||
|
||||
public void setTypeRotor8(int typeRotor8) {
|
||||
this.typeRotor8 = typeRotor8;
|
||||
}
|
||||
|
||||
public int getRotationRotor1() {
|
||||
return rotationRotor1;
|
||||
}
|
||||
|
@ -155,38 +123,6 @@ public class EnigmaStateBundle{
|
|||
this.rotationRotor4 = rotationRotor4;
|
||||
}
|
||||
|
||||
public int getRotationRotor5() {
|
||||
return rotationRotor5;
|
||||
}
|
||||
|
||||
public void setRotationRotor5(int rotationRotor5) {
|
||||
this.rotationRotor5 = rotationRotor5;
|
||||
}
|
||||
|
||||
public int getRotationRotor6() {
|
||||
return rotationRotor6;
|
||||
}
|
||||
|
||||
public void setRotationRotor6(int rotationRotor6) {
|
||||
this.rotationRotor6 = rotationRotor6;
|
||||
}
|
||||
|
||||
public int getRotationRotor7() {
|
||||
return rotationRotor7;
|
||||
}
|
||||
|
||||
public void setRotationRotor7(int rotationRotor7) {
|
||||
this.rotationRotor7 = rotationRotor7;
|
||||
}
|
||||
|
||||
public int getRotationRotor8() {
|
||||
return rotationRotor8;
|
||||
}
|
||||
|
||||
public void setRotationRotor8(int rotationRotor8) {
|
||||
this.rotationRotor8 = rotationRotor8;
|
||||
}
|
||||
|
||||
public int getRingSettingRotor1() {
|
||||
return ringSettingRotor1;
|
||||
}
|
||||
|
@ -219,38 +155,6 @@ public class EnigmaStateBundle{
|
|||
this.ringSettingRotor4 = ringSettingRotor4;
|
||||
}
|
||||
|
||||
public int getRingSettingRotor5() {
|
||||
return ringSettingRotor5;
|
||||
}
|
||||
|
||||
public void setRingSettingRotor5(int ringSettingRotor5) {
|
||||
this.ringSettingRotor5 = ringSettingRotor5;
|
||||
}
|
||||
|
||||
public int getRingSettingRotor6() {
|
||||
return ringSettingRotor6;
|
||||
}
|
||||
|
||||
public void setRingSettingRotor6(int ringSettingRotor6) {
|
||||
this.ringSettingRotor6 = ringSettingRotor6;
|
||||
}
|
||||
|
||||
public int getRingSettingRotor7() {
|
||||
return ringSettingRotor7;
|
||||
}
|
||||
|
||||
public void setRingSettingRotor7(int ringSettingRotor7) {
|
||||
this.ringSettingRotor7 = ringSettingRotor7;
|
||||
}
|
||||
|
||||
public int getRingSettingRotor8() {
|
||||
return ringSettingRotor8;
|
||||
}
|
||||
|
||||
public void setRingSettingRotor8(int ringSettingRotor8) {
|
||||
this.ringSettingRotor8 = ringSettingRotor8;
|
||||
}
|
||||
|
||||
public int getTypeReflector() {
|
||||
return typeReflector;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
package de.vanitasvitae.enigmandroid.enigma;
|
||||
|
||||
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 18.09.15.
|
||||
*/
|
||||
public class SeedInterpreter
|
||||
{
|
||||
/*
|
||||
12 machineType
|
||||
1-8 rotor1
|
||||
1-8 rotor2
|
||||
1-8 rotor3
|
||||
2 rotor4
|
||||
1-3 ukw
|
||||
26 pos1
|
||||
26 pos2
|
||||
26 pos3
|
||||
26 pos4/posukw
|
||||
--plugboard
|
||||
#plugs 13
|
||||
|
||||
|
||||
*/
|
||||
|
||||
public double prepareSeed(long input)
|
||||
{
|
||||
double maxIn = Long.MAX_VALUE;
|
||||
double maxOut = 100000; //TODO: Temporär!
|
||||
|
||||
return (input / maxIn) * maxOut;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle seedToState(long seed)
|
||||
{
|
||||
long s = seed/12;
|
||||
switch ((int) seed % 12)
|
||||
{
|
||||
case 0: return prepState_I(s);
|
||||
case 1: return prepState_M3(s);
|
||||
case 2: return prepState_M4(s);
|
||||
case 3: return prepState_G31(s);
|
||||
case 4: return prepState_G312(s);
|
||||
case 5: return prepState_G260(s);
|
||||
case 6: return prepState_D(s);
|
||||
case 7: return prepState_K(s);
|
||||
case 8: return prepState_KS(s);
|
||||
case 9: return prepState_KSA(s);
|
||||
case 10: return prepState_R(s);
|
||||
default: return prepState_T(s);
|
||||
}
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_I(long seed)
|
||||
{
|
||||
EnigmaStateBundle state = new EnigmaStateBundle();
|
||||
state.setMachineType("I");
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_M3(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_M4(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_G31(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_G312(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_G260(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_D(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_K(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_KS(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_KSA(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_R(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnigmaStateBundle prepState_T(long seed)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int[] getPermutation(long seed)
|
||||
{
|
||||
int[] per = Reflector.ReflectorEnigma_D_KD_G31.defaultWiring;
|
||||
long maxPermutations = Long.valueOf("532985208200576");
|
||||
//long result =
|
||||
return per;
|
||||
|
||||
}
|
||||
}
|
|
@ -4,12 +4,16 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||
import de.vanitasvitae.enigmandroid.R;
|
||||
|
@ -36,11 +40,12 @@ import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
|||
*/
|
||||
public class PluggableDialogBuilder
|
||||
{
|
||||
protected ArrayList<Button> buttons;
|
||||
protected ArrayList<ButtonWrapper> buttons;
|
||||
protected View dialogView;
|
||||
protected MainActivity main;
|
||||
protected EnigmaStateBundle state;
|
||||
protected Drawable defaultLayout;
|
||||
|
||||
protected HashSet<Integer> colors;
|
||||
|
||||
protected int previouslyPressedButton = -1;
|
||||
|
||||
|
@ -63,9 +68,7 @@ public class PluggableDialogBuilder
|
|||
public void onClick(DialogInterface dialog, int id) {
|
||||
int[] plugs = new int[26];
|
||||
for (int i = 0; i < 26; i++) {
|
||||
int o = getConnectedButton(i);
|
||||
if (o == -1) plugs[i] = i;
|
||||
else plugs[i] = o;
|
||||
plugs[i] = buttons.get(i).getConnectedButton();
|
||||
}
|
||||
state.setConfigurationPlugboard(plugs);
|
||||
Toast.makeText(main.getApplication(), R.string.dialog_plugboard_set, Toast.LENGTH_SHORT).show();
|
||||
|
@ -98,9 +101,7 @@ public class PluggableDialogBuilder
|
|||
public void onClick(DialogInterface dialog, int id) {
|
||||
int[] plugs = new int[26];
|
||||
for (int i = 0; i < 26; i++) {
|
||||
int o = getConnectedButton(i);
|
||||
if (o == -1) plugs[i] = i;
|
||||
else plugs[i] = o;
|
||||
plugs[i] = buttons.get(i).getConnectedButton();
|
||||
}
|
||||
state.setConfigurationReflector(plugs);
|
||||
Toast.makeText(main.getApplication(), R.string.dialog_reflector_set, Toast.LENGTH_SHORT).show();
|
||||
|
@ -126,40 +127,55 @@ public class PluggableDialogBuilder
|
|||
buttons = new ArrayList<>();
|
||||
dialogView = View.inflate(main, R.layout.dialog_plugs, null);
|
||||
|
||||
buttons.add((Button) dialogView.findViewById(R.id.A));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.B));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.C));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.D));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.E));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.F));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.G));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.H));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.I));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.J));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.K));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.L));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.M));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.N));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.O));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.P));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.Q));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.R));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.S));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.T));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.U));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.V));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.W));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.X));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.Y));
|
||||
buttons.add((Button) dialogView.findViewById(R.id.Z));
|
||||
this.defaultLayout = buttons.get(0).getBackground();
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.A),0));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.B),1));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.C),2));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.D),3));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.E),4));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.F),5));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.G),6));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.H),7));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.I),8));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.J),9));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.K),10));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.L),11));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.M),12));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.N),13));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.O),14));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.P),15));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.Q),16));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.R),17));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.S),18));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.T),19));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.U),20));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.V),21));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.W),22));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.X),23));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.Y),24));
|
||||
buttons.add(new ButtonWrapper((Button) dialogView.findViewById(R.id.Z),25));
|
||||
|
||||
colors = new HashSet<>();
|
||||
colors.add(R.drawable.button_orange);
|
||||
colors.add(R.drawable.button_olive);
|
||||
colors.add(R.drawable.button_blue);
|
||||
colors.add(R.drawable.button_red);
|
||||
colors.add(R.drawable.button_yellow);
|
||||
colors.add(R.drawable.button_purple);
|
||||
colors.add(R.drawable.button_green);
|
||||
colors.add(R.drawable.button_cyan);
|
||||
colors.add(R.drawable.button_berry);
|
||||
colors.add(R.drawable.button_brown);
|
||||
colors.add(R.drawable.button_pink);
|
||||
colors.add(R.drawable.button_elder);
|
||||
colors.add(R.drawable.button_black);
|
||||
Log.d("Dialogtest", ""+R.drawable.button_red);
|
||||
}
|
||||
|
||||
public void setButtonListeners()
|
||||
{
|
||||
for(int i=0; i<26; i++)
|
||||
{
|
||||
Button b = buttons.get(i);
|
||||
Button b = buttons.get(i).getButton();
|
||||
final int id = i;
|
||||
b.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -184,72 +200,110 @@ public class PluggableDialogBuilder
|
|||
{
|
||||
for(int i=0; i<26; i++)
|
||||
{
|
||||
int o = c[i];
|
||||
if(i != o)
|
||||
setPlug(i, o);
|
||||
setPlug(i, c[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlug(int button1, int button2)
|
||||
{
|
||||
if(button1 != button2)
|
||||
if(button1 == button2)
|
||||
{
|
||||
Button b1 = buttons.get(button1);
|
||||
Button b2 = buttons.get(button2);
|
||||
|
||||
int other = getConnectedButton(button1);
|
||||
if(other != -1) setButtonFree(other);
|
||||
other = getConnectedButton(button2);
|
||||
if(other != -1) setButtonFree(other);
|
||||
|
||||
b1.setText((char) (button1 + 65) + ":" + (char) (button2 + 65));
|
||||
setButtonUsed(button1);
|
||||
b2.setText((char) (button2 + 65) + ":" + (char) (button1 + 65));
|
||||
setButtonUsed(button2);
|
||||
setButtonFree(buttons.get(button1).getConnectedButton());
|
||||
setButtonFree(button1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int other = getConnectedButton(button1);
|
||||
if(other != -1) setButtonFree(other);
|
||||
setButtonFree(button1);
|
||||
ButtonWrapper b1 = buttons.get(button1);
|
||||
ButtonWrapper b2 = buttons.get(button2);
|
||||
|
||||
if (b1.getConnectedButton() != button1) {
|
||||
setButtonFree(b1.getConnectedButton());
|
||||
}
|
||||
if (b2.getConnectedButton() != button2) {
|
||||
setButtonFree(b2.getConnectedButton());
|
||||
}
|
||||
|
||||
b1.setConnectedButton(button2);
|
||||
b2.setConnectedButton(button1);
|
||||
|
||||
int res;
|
||||
Iterator<Integer> it = colors.iterator();
|
||||
res = it.next();
|
||||
if(res == 0) res = it.next();
|
||||
colors.remove(res);
|
||||
|
||||
b1.setResourceID(res);
|
||||
b2.setResourceID(res);
|
||||
}
|
||||
}
|
||||
|
||||
private int getConnectedButton(int button)
|
||||
private void setButtonFree(int b)
|
||||
{
|
||||
Button b = buttons.get(button);
|
||||
char c = (b.getText().charAt(2));
|
||||
if(c != ' ')
|
||||
{
|
||||
return ((int) c) - 65;
|
||||
}
|
||||
else return -1;
|
||||
ButtonWrapper button = buttons.get(b);
|
||||
int res = button.getResourceID();
|
||||
if(res != R.drawable.button_grey)
|
||||
colors.add(button.getResourceID());
|
||||
button.setResourceID(R.drawable.button_grey);
|
||||
button.setConnectedButton(b);
|
||||
}
|
||||
|
||||
public void buttonPressed(int button)
|
||||
{
|
||||
if(previouslyPressedButton == -1)
|
||||
{
|
||||
previouslyPressedButton = button;
|
||||
setButtonUsed(button);
|
||||
}
|
||||
else
|
||||
if(previouslyPressedButton != -1)
|
||||
{
|
||||
setPlug(previouslyPressedButton, button);
|
||||
previouslyPressedButton = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
previouslyPressedButton = button;
|
||||
buttons.get(button).setWaiting();
|
||||
}
|
||||
}
|
||||
|
||||
private void setButtonUsed(int button)
|
||||
private static class ButtonWrapper
|
||||
{
|
||||
buttons.get(button).setBackgroundResource(R.drawable.button_orange);
|
||||
}
|
||||
private void setButtonFree(int button)
|
||||
{
|
||||
Button b = buttons.get(button);
|
||||
b.setBackgroundResource(R.drawable.button_grey);
|
||||
//b.setBackground(defaultLayout);
|
||||
b.setText((char) (button+65) + ": ");
|
||||
}
|
||||
private Button button;
|
||||
private int connectedButton;
|
||||
private int resourceID;
|
||||
private int index;
|
||||
public ButtonWrapper(Button button, int index)
|
||||
{
|
||||
this.button = button;
|
||||
this.index = index;
|
||||
this.connectedButton = index;
|
||||
}
|
||||
|
||||
public void setConnectedButton(int other)
|
||||
{
|
||||
this.connectedButton = other;
|
||||
this.getButton().setText((char) (index + 65) + ":" + (char) (connectedButton + 65));
|
||||
}
|
||||
|
||||
public int getConnectedButton()
|
||||
{
|
||||
return this.connectedButton;
|
||||
}
|
||||
|
||||
public void setWaiting()
|
||||
{
|
||||
this.getButton().setText((char) (index + 65) + ": ");
|
||||
}
|
||||
|
||||
public void setResourceID(int r)
|
||||
{
|
||||
button.setBackgroundResource(r);
|
||||
this.resourceID = r;
|
||||
}
|
||||
|
||||
public int getResourceID()
|
||||
{
|
||||
return this.resourceID;
|
||||
}
|
||||
|
||||
public Button getButton()
|
||||
{
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}
|
39
app/src/main/res/drawable/button_berry.xml
Executable file
39
app/src/main/res/drawable/button_berry.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#ea138f" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#810e41"
|
||||
android:endColor="#930e52"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#52082e" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_black.xml
Executable file
39
app/src/main/res/drawable/button_black.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#444552" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#23262e"
|
||||
android:endColor="#24252e"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#181719" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_blue.xml
Executable file
39
app/src/main/res/drawable/button_blue.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#b94b52e4" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#b94b52e4"
|
||||
android:endColor="#a74e55ff"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#1e2153" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_brown.xml
Executable file
39
app/src/main/res/drawable/button_brown.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#de9307" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#864f07"
|
||||
android:endColor="#9c6007"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#462606" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_cyan.xml
Executable file
39
app/src/main/res/drawable/button_cyan.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#15dbdc" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#139e9f"
|
||||
android:endColor="#13aeaf"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#115c5d" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_elder.xml
Executable file
39
app/src/main/res/drawable/button_elder.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#c895ad" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#815f6b"
|
||||
android:endColor="#8e6a77"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#53353f" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_green.xml
Executable file
39
app/src/main/res/drawable/button_green.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#6aff46" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#54bb32"
|
||||
android:endColor="#56cc33"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#3b7727" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_olive.xml
Executable file
39
app/src/main/res/drawable/button_olive.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#a4e82b" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#4f7d1d"
|
||||
android:endColor="#5f8e1e"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#365013" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_pink.xml
Executable file
39
app/src/main/res/drawable/button_pink.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#95ff168e" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#d1156d"
|
||||
android:endColor="#e5157f"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#8c0e49" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_purple.xml
Executable file
39
app/src/main/res/drawable/button_purple.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#cf54ff" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#9944c2"
|
||||
android:endColor="#de9944c2"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#703290" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_red.xml
Executable file
39
app/src/main/res/drawable/button_red.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#ff4f52" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#d9ef241e"
|
||||
android:endColor="#bdef3f3f"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#5a1717" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
39
app/src/main/res/drawable/button_yellow.xml
Executable file
39
app/src/main/res/drawable/button_yellow.xml
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#cbfffc0f" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#222222" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#b7b40e"
|
||||
android:endColor="#d2cf0e"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#5c5903" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
Loading…
Reference in a new issue