diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 45cfbae..54fe878 100755 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/EnigmaStateBundle.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/EnigmaStateBundle.java index 1cf007b..7eccf24 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/EnigmaStateBundle.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/EnigmaStateBundle.java @@ -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; } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java new file mode 100644 index 0000000..53e3047 --- /dev/null +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java @@ -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; + + } +} diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/PluggableDialogBuilder.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/PluggableDialogBuilder.java index df5a561..8062c2b 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/PluggableDialogBuilder.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/PluggableDialogBuilder.java @@ -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