From 82e21e48ec12f0bc3179f210c7d6a6aca312c7d2 Mon Sep 17 00:00:00 2001 From: VanitasVitae Date: Tue, 22 Sep 2015 21:10:41 +0200 Subject: [PATCH] Reworked InputPreparer, Reworked Reflecto-/Rotor-creation --- CHANGELOG.txt | 4 +- .../enigmandroid/MainActivity.java | 36 +-- .../enigmandroid/SettingsActivity.java | 7 + .../enigmandroid/enigma/Enigma_D.java | 12 +- .../enigmandroid/enigma/Enigma_G260.java | 10 +- .../enigmandroid/enigma/Enigma_G31.java | 18 +- .../enigmandroid/enigma/Enigma_G312.java | 12 +- .../enigmandroid/enigma/Enigma_I.java | 8 +- .../enigmandroid/enigma/Enigma_K.java | 15 +- .../enigma/Enigma_K_Swiss_Airforce.java | 12 +- .../enigma/Enigma_K_Swiss_Standard.java | 12 +- .../enigmandroid/enigma/Enigma_M3.java | 8 +- .../enigmandroid/enigma/Enigma_M4.java | 10 +- .../enigmandroid/enigma/Enigma_R.java | 12 +- .../enigmandroid/enigma/Enigma_T.java | 23 +- .../enigmandroid/enigma/SeedInterpreter.java | 2 +- .../enigma/inputPreparer/EditTextAdapter.java | 17 +- .../enigma/inputPreparer/InputPreparer.java | 253 ++++++++++-------- .../enigmandroid/enigma/rotors/Reflector.java | 111 +++++--- .../enigmandroid/enigma/rotors/Rotor.java | 215 ++++++++------- .../layout/LayoutContainer_G260.java | 2 +- .../layout/LayoutContainer_G31.java | 2 +- .../layout/LayoutContainer_G312.java | 2 +- .../layout/LayoutContainer_I.java | 16 +- .../layout/LayoutContainer_K.java | 12 +- .../layout/LayoutContainer_K_Swiss.java | 12 +- .../LayoutContainer_K_Swiss_Airforce.java | 12 +- .../layout/LayoutContainer_M3.java | 16 +- .../layout/LayoutContainer_M4.java | 20 +- .../layout/LayoutContainer_R.java | 12 +- .../layout/LayoutContainer_T.java | 12 +- .../values-de/strings_activity_settings.xml | 22 ++ .../res/values/strings_activity_settings.xml | 32 ++- app/src/main/res/xml/pref_page.xml | 12 +- 34 files changed, 575 insertions(+), 406 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 54fe878..f6adf77 100755 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -10,10 +10,10 @@ v0.1.8-not-yet-released< *Updated the about-dialog text. *Shortened EnigmaStateBundle *Added different colors to the plugboard-/pluggable reflector dialog. This helps to differentiate connections. +*Reworked InputPreparer using decorator pattern and added options to customize input preparation +*Reworked Reflector-/Rotor creation/management *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) diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/MainActivity.java b/app/src/main/java/de/vanitasvitae/enigmandroid/MainActivity.java index 8797907..4809070 100755 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/MainActivity.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/MainActivity.java @@ -57,8 +57,8 @@ public class MainActivity extends Activity super.onCreate(savedInstanceState); Log.d("Activity","OnCreate!"); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - this.prefMachineType = sharedPreferences.getString("prefMachineType", getResources(). - getStringArray(R.array.pref_list_machine_type)[0]); + this.prefMachineType = sharedPreferences.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources(). + getStringArray(R.array.pref_alias_machine_type)[0]); ActivitySingleton singleton = ActivitySingleton.getInstance(); singleton.setActivity(this); updateContentView(); @@ -181,12 +181,12 @@ public class MainActivity extends Activity private void updatePreferenceValues() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - this.setPrefMachineType(sharedPreferences.getString("prefMachineType", getResources(). - getStringArray(R.array.pref_list_machine_type)[0])); - this.setPrefAnomaly(sharedPreferences.getBoolean("prefAnomaly", true)); - this.setPrefNumericLanguage(sharedPreferences.getString("prefNumericLanguage", getResources(). + this.setPrefMachineType(sharedPreferences.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources(). + getStringArray(R.array.pref_alias_machine_type)[0])); + this.setPrefAnomaly(sharedPreferences.getBoolean(SettingsActivity.PREF_ANOMALY, true)); + this.setPrefNumericLanguage(sharedPreferences.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, getResources(). getStringArray(R.array.pref_alias_numeric_spelling_language)[0])); - this.setPrefMessageFormatting(sharedPreferences.getString("prefMessageFormatting", getResources(). + this.setPrefMessageFormatting(sharedPreferences.getString(SettingsActivity.PREF_MESSAGE_FORMATTING, getResources(). getStringArray(R.array.pref_alias_message_formatting)[0])); } @@ -202,7 +202,7 @@ public class MainActivity extends Activity } updateContentView(); layoutContainer = LayoutContainer.createLayoutContainer(prefMachineType); - layoutContainer.setInputPreparer(InputPreparer.createInputPreparer(prefNumericLanguage)); + layoutContainer.setInputPreparer(InputPreparer.createInputPreparer()); layoutContainer.getInput().setText(savedInput); } } @@ -211,8 +211,8 @@ public class MainActivity extends Activity { if(prefMachineType != null) return prefMachineType; SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - this.prefMachineType = sharedPreferences.getString("prefMachineType", getResources(). - getStringArray(R.array.pref_list_machine_type)[0]); + this.prefMachineType = sharedPreferences.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources(). + getStringArray(R.array.pref_alias_machine_type)[0]); return prefMachineType; } @@ -235,7 +235,7 @@ public class MainActivity extends Activity if(prefNumericLanguage == null || !prefNumericLanguage.equals(lang)) { prefNumericLanguage = lang; - layoutContainer.setInputPreparer(InputPreparer.createInputPreparer(lang)); + layoutContainer.setInputPreparer(InputPreparer.createInputPreparer()); } } @@ -243,7 +243,7 @@ public class MainActivity extends Activity { if(prefNumericLanguage != null) return prefNumericLanguage; SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - this.prefNumericLanguage = sharedPreferences.getString("prefNumericLanguage", getResources(). + this.prefNumericLanguage = sharedPreferences.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, getResources(). getStringArray(R.array.pref_alias_numeric_spelling_language)[0]); return prefNumericLanguage; } @@ -261,7 +261,7 @@ public class MainActivity extends Activity { if(prefMessageFormatting != null) return prefMessageFormatting; SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - this.prefMessageFormatting = sharedPreferences.getString("prefMessageFormatting", getResources(). + this.prefMessageFormatting = sharedPreferences.getString(SettingsActivity.PREF_MESSAGE_FORMATTING, getResources(). getStringArray(R.array.pref_alias_message_formatting)[0]); return prefMessageFormatting; } @@ -373,12 +373,12 @@ public class MainActivity extends Activity case RESULT_SETTINGS: { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); - this.setPrefMachineType(sharedPrefs.getString("prefMachineType", getResources() - .getStringArray(R.array.pref_list_machine_type)[0])); - this.setPrefAnomaly(sharedPrefs.getBoolean("prefAnomaly", true)); - this.setPrefNumericLanguage(sharedPrefs.getString("prefNumericLanguage", getResources(). + this.setPrefMachineType(sharedPrefs.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources() + .getStringArray(R.array.pref_alias_machine_type)[0])); + this.setPrefAnomaly(sharedPrefs.getBoolean(SettingsActivity.PREF_ANOMALY, true)); + this.setPrefNumericLanguage(sharedPrefs.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, getResources(). getStringArray(R.array.pref_alias_numeric_spelling_language)[0])); - this.setPrefMessageFormatting(sharedPrefs.getString("prefMessageFormatting", + this.setPrefMessageFormatting(sharedPrefs.getString(SettingsActivity.PREF_MESSAGE_FORMATTING, getResources().getStringArray(R.array.pref_alias_message_formatting)[0])); break; } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/SettingsActivity.java b/app/src/main/java/de/vanitasvitae/enigmandroid/SettingsActivity.java index eaa4be6..83c61c4 100755 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/SettingsActivity.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/SettingsActivity.java @@ -24,6 +24,13 @@ import android.preference.PreferenceActivity; */ public class SettingsActivity extends PreferenceActivity { + public static final String PREF_NUMERIC_LANGUAGE = "prefNumericLanguage"; + public static final String PREF_MACHINE_TYPE = "prefMachineType"; + public static final String PREF_ANOMALY = "prefAnomaly"; + public static final String PREF_MESSAGE_FORMATTING = "prefMessageFormatting"; + public static final String PREF_REPLACE_SPECIAL_CHARACTERS = "prefReplaceSpecialCharacters"; + public static final String PREF_REPLACE_SPACES = "prefReplaceSpaces"; + @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_D.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_D.java index 87f3a4a..19bf136 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_D.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_D.java @@ -39,11 +39,11 @@ public class Enigma_D extends Enigma { @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(11, 0, 0); - this.rotor2 = Rotor.createRotor(12, 0, 0); - this.rotor3 = Rotor.createRotor(13, 0, 0); - this.reflector = new Reflector.ReflectorEnigma_D_KD_G31(); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(70, 0, 0); + this.rotor2 = Rotor.createRotor(71, 0, 0); + this.rotor3 = Rotor.createRotor(72, 0, 0); + this.reflector = (Reflector.ReflectorEnigma_D_KD_G31) Reflector.createReflector(70); } @Override @@ -107,6 +107,8 @@ public class Enigma_D extends Enigma { { EnigmaStateBundle state = new EnigmaStateBundle(); + state.setTypeEntryWheel(entryWheel.getNumber()); + state.setTypeRotor1(rotor1.getNumber()); state.setTypeRotor2(rotor2.getNumber()); state.setTypeRotor3(rotor3.getNumber()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G260.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G260.java index 640c1da..acad081 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G260.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G260.java @@ -32,10 +32,10 @@ public class Enigma_G260 extends Enigma_G31 @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(29, 0, 0); - this.rotor2 = Rotor.createRotor(30, 0, 0); - this.rotor3 = Rotor.createRotor(31, 0, 0); - this.reflector = Reflector.createReflector(10); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(60, 0, 0); + this.rotor2 = Rotor.createRotor(61, 0, 0); + this.rotor3 = Rotor.createRotor(62, 0, 0); + this.reflector = Reflector.createReflector(60); } } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G31.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G31.java index e0a49c9..0b0a517 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G31.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G31.java @@ -1,5 +1,7 @@ package de.vanitasvitae.enigmandroid.enigma; +import android.util.Log; + import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector; import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor; @@ -39,21 +41,21 @@ public class Enigma_G31 extends Enigma @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(32, 0, 0); - this.rotor2 = Rotor.createRotor(33, 0, 0); - this.rotor3 = Rotor.createRotor(34, 0, 0); - this.reflector = Reflector.createReflector(6); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(40, 0, 0); + this.rotor2 = Rotor.createRotor(41, 0, 0); + this.rotor3 = Rotor.createRotor(42, 0, 0); + this.reflector = Reflector.createReflector(40); } @Override public void nextState() { + Log.d("Anomaly",""+prefAnomaly+","+doAnomaly); rotor1.rotate(); - if (rotor1.isAtTurnoverPosition() || (this.doAnomaly && prefAnomaly)) + if (rotor1.isAtTurnoverPosition()) { rotor2.rotate(); - this.doAnomaly = rotor2.doubleTurnAnomaly(); if (rotor2.isAtTurnoverPosition()) { rotor3.rotate(); @@ -108,6 +110,8 @@ public class Enigma_G31 extends Enigma public EnigmaStateBundle getState() { EnigmaStateBundle state = new EnigmaStateBundle(); + state.setTypeEntryWheel(entryWheel.getNumber()); + state.setTypeRotor1(rotor1.getNumber()); state.setTypeRotor2(rotor2.getNumber()); state.setTypeRotor3(rotor3.getNumber()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G312.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G312.java index 76f3819..7ddac0d 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G312.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_G312.java @@ -1,5 +1,7 @@ package de.vanitasvitae.enigmandroid.enigma; +import java.sql.Ref; + import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector; import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor; @@ -32,10 +34,10 @@ public class Enigma_G312 extends Enigma_G31 @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(26, 0, 0); - this.rotor2 = Rotor.createRotor(27, 0, 0); - this.rotor3 = Rotor.createRotor(28, 0, 0); - this.reflector = Reflector.createReflector(9); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(50, 0, 0); + this.rotor2 = Rotor.createRotor(51, 0, 0); + this.rotor3 = Rotor.createRotor(52, 0, 0); + this.reflector = Reflector.createReflector(50); } } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_I.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_I.java index 2dc1d34..a9f3add 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_I.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_I.java @@ -42,10 +42,10 @@ public class Enigma_I extends Enigma public void initialize() { this.plugboard= new Plugboard(); - this.rotor1 = Rotor.createRotor(1, 0, 0); - this.rotor2 = Rotor.createRotor(2, 0, 0); - this.rotor3 = Rotor.createRotor(3, 0, 0); - this.reflector = Reflector.createReflector(1); + this.rotor1 = Rotor.createRotor(10, 0, 0); + this.rotor2 = Rotor.createRotor(11, 0, 0); + this.rotor3 = Rotor.createRotor(12, 0, 0); + this.reflector = Reflector.createReflector(10); } @Override diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K.java index b900d5a..3b20e48 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K.java @@ -39,11 +39,11 @@ public class Enigma_K extends Enigma @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(35, 0, 0); - this.rotor2 = Rotor.createRotor(36, 0, 0); - this.rotor3 = Rotor.createRotor(37, 0, 0); - this.reflector = Reflector.createReflector(7); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(80, 0, 0); + this.rotor2 = Rotor.createRotor(81, 0, 0); + this.rotor3 = Rotor.createRotor(82, 0, 0); + this.reflector = Reflector.createReflector(80); } @Override @@ -101,9 +101,12 @@ public class Enigma_K extends Enigma } @Override - public EnigmaStateBundle getState() { + public EnigmaStateBundle getState() + { EnigmaStateBundle state = new EnigmaStateBundle(); + state.setTypeEntryWheel(entryWheel.getNumber()); + state.setTypeRotor1(rotor1.getNumber()); state.setTypeRotor2(rotor2.getNumber()); state.setTypeRotor3(rotor3.getNumber()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Airforce.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Airforce.java index 08cae46..8d3efa8 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Airforce.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Airforce.java @@ -39,11 +39,11 @@ public class Enigma_K_Swiss_Airforce extends Enigma_K @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(38, 0, 0); - this.rotor2 = Rotor.createRotor(39, 0, 0); - this.rotor3 = Rotor.createRotor(40, 0, 0); - this.reflector = Reflector.createReflector(7); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(100, 0, 0); + this.rotor2 = Rotor.createRotor(101, 0, 0); + this.rotor3 = Rotor.createRotor(102, 0, 0); + this.reflector = Reflector.createReflector(100); } @Override @@ -104,6 +104,8 @@ public class Enigma_K_Swiss_Airforce extends Enigma_K public EnigmaStateBundle getState() { EnigmaStateBundle state = new EnigmaStateBundle(); + state.setTypeEntryWheel(entryWheel.getNumber()); + state.setTypeRotor1(rotor1.getNumber()); state.setTypeRotor2(rotor2.getNumber()); state.setTypeRotor3(rotor3.getNumber()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Standard.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Standard.java index f15348a..8336e38 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Standard.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_K_Swiss_Standard.java @@ -39,11 +39,11 @@ public class Enigma_K_Swiss_Standard extends Enigma_K @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(14, 0, 0); - this.rotor2 = Rotor.createRotor(15, 0, 0); - this.rotor3 = Rotor.createRotor(16, 0, 0); - this.reflector = Reflector.createReflector(7); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(90, 0, 0); + this.rotor2 = Rotor.createRotor(91, 0, 0); + this.rotor3 = Rotor.createRotor(92, 0, 0); + this.reflector = Reflector.createReflector(90); } @Override @@ -104,6 +104,8 @@ public class Enigma_K_Swiss_Standard extends Enigma_K public EnigmaStateBundle getState() { EnigmaStateBundle state = new EnigmaStateBundle(); + state.setTypeEntryWheel(entryWheel.getNumber()); + state.setTypeRotor1(rotor1.getNumber()); state.setTypeRotor2(rotor2.getNumber()); state.setTypeRotor3(rotor3.getNumber()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M3.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M3.java index 6af47a4..2104f2c 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M3.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M3.java @@ -32,9 +32,9 @@ public class Enigma_M3 extends Enigma_I public void initialize() { this.plugboard = new Plugboard(); - this.rotor1 = Rotor.createRotor(1, 0, 0); - this.rotor2 = Rotor.createRotor(2, 0, 0); - this.rotor3 = Rotor.createRotor(3, 0, 0); - this.reflector = Reflector.createReflector(2); + this.rotor1 = Rotor.createRotor(20, 0, 0); + this.rotor2 = Rotor.createRotor(21, 0, 0); + this.rotor3 = Rotor.createRotor(22, 0, 0); + this.reflector = Reflector.createReflector(20); } } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M4.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M4.java index 6d03c0d..dac411b 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M4.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_M4.java @@ -43,11 +43,11 @@ public class Enigma_M4 extends Enigma public void initialize() { this.plugboard = new Plugboard(); - this.rotor1 = Rotor.createRotor(1, 0, 0); - this.rotor2 = Rotor.createRotor(2, 0, 0); - this.rotor3 = Rotor.createRotor(3, 0, 0); - this.rotor4 = Rotor.createRotor(9, 0, 0); - this.reflector = Reflector.createReflector(4); + this.rotor1 = Rotor.createRotor(30, 0, 0); + this.rotor2 = Rotor.createRotor(31, 0, 0); + this.rotor3 = Rotor.createRotor(32, 0, 0); + this.rotor4 = Rotor.createRotor(38, 0, 0); + this.reflector = Reflector.createReflector(30); this.prefAnomaly = true; } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_R.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_R.java index 707eb5b..077cf52 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_R.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_R.java @@ -39,11 +39,11 @@ public class Enigma_R extends Enigma @Override public void initialize() { - this.entryWheel = Rotor.createRotor(0, 0, 0); - this.rotor1 = Rotor.createRotor(41, 0, 0); - this.rotor2 = Rotor.createRotor(42, 0, 0); - this.rotor3 = Rotor.createRotor(43, 0, 0); - this.reflector = Reflector.createReflector(11); + this.entryWheel = Rotor.createRotor(1, 0, 0); + this.rotor1 = Rotor.createRotor(110, 0, 0); + this.rotor2 = Rotor.createRotor(111, 0, 0); + this.rotor3 = Rotor.createRotor(112, 0, 0); + this.reflector = Reflector.createReflector(110); } @Override @@ -104,6 +104,8 @@ public class Enigma_R extends Enigma public EnigmaStateBundle getState() { EnigmaStateBundle state = new EnigmaStateBundle(); + state.setTypeEntryWheel(entryWheel.getNumber()); + state.setTypeRotor1(rotor1.getNumber()); state.setTypeRotor2(rotor2.getNumber()); state.setTypeRotor3(rotor3.getNumber()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_T.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_T.java index 1c4ee54..7f59fde 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_T.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/Enigma_T.java @@ -35,16 +35,16 @@ public class Enigma_T extends Enigma public Enigma_T() { super(); - machineType = "K"; + machineType = "T"; } @Override public void initialize() { - this.entryWheel = Rotor.createRotor(17,0,0); - this.rotor1 = Rotor.createRotor(18, 0, 0); - this.rotor2 = Rotor.createRotor(19, 0, 0); - this.rotor3 = Rotor.createRotor(20, 0, 0); - this.reflector = Reflector.createReflector(8); + this.entryWheel = Rotor.createRotor(2,0,0); + this.rotor1 = Rotor.createRotor(120, 0, 0); + this.rotor2 = Rotor.createRotor(121, 0, 0); + this.rotor3 = Rotor.createRotor(122, 0, 0); + this.reflector = Reflector.createReflector(120); } @Override @@ -68,35 +68,24 @@ public class Enigma_T extends Enigma int x = ((int) k)-65; //Cast to int and remove Unicode Offset (A=65 in Unicode.) //Encryption //forward direction - String log = " in: " + (char) (x+65); x = entryWheel.encryptForward(x); - log = log + " ew: " + (char) (x+65); x = rotor1.normalize(x + rotor1.getRotation() - rotor1.getRingSetting()); x = rotor1.encryptForward(x); - log = log + " r1: " + (char) (x+65); x = rotor1.normalize(x - rotor1.getRotation() + rotor1.getRingSetting() + rotor2.getRotation() - rotor2.getRingSetting()); x = rotor2.encryptForward(x); - log = log + " r2: " + (char) (x+65); x = rotor1.normalize(x - rotor2.getRotation() + rotor2.getRingSetting() + rotor3.getRotation() - rotor3.getRingSetting()); x = rotor3.encryptForward(x); - log = log + " r3: " + (char) (x+65); x = rotor1.normalize(x - rotor3.getRotation() + rotor3.getRingSetting() + reflector.getRotation() - reflector.getRingSetting()); //backward direction x = reflector.encrypt(x); - log = log + " ref: " + (char) (x+65); x = rotor1.normalize(x + rotor3.getRotation() - rotor3.getRingSetting() - reflector.getRotation() + reflector.getRingSetting()); x = rotor3.encryptBackward(x); - log = log + " r3: " + (char) (x+65); x = rotor1.normalize(x + rotor2.getRotation() - rotor2.getRingSetting() - rotor3.getRotation() + rotor3.getRingSetting()); x = rotor2.encryptBackward(x); - log = log + " r2: " + (char) (x+65); x = rotor1.normalize(x + rotor1.getRotation() - rotor1.getRingSetting() - rotor2.getRotation() + rotor2.getRingSetting()); x = rotor1.encryptBackward(x); - log = log + " r1: " + (char) (x+65); x = rotor1.normalize(x - rotor1.getRotation() + rotor1.getRingSetting()); x = entryWheel.encryptBackward(x); - log = log + " ew/out: " + (char) (x+65); - Log.d("EnryptionLog",log); return (char) (x + 65); //Add Offset again, cast back to char and return } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java index 53e3047..c650b02 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/SeedInterpreter.java @@ -117,7 +117,7 @@ public class SeedInterpreter public static int[] getPermutation(long seed) { - int[] per = Reflector.ReflectorEnigma_D_KD_G31.defaultWiring; + int[] per = Reflector.ReflectorEnigma_D_KD_G31.defaultWiring_D_KD_G31; long maxPermutations = Long.valueOf("532985208200576"); //long result = return per; diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/inputPreparer/EditTextAdapter.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/inputPreparer/EditTextAdapter.java index 518ecfc..e55e3ae 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/inputPreparer/EditTextAdapter.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/inputPreparer/EditTextAdapter.java @@ -54,7 +54,9 @@ public abstract class EditTextAdapter { switch (type) { - case "5": return new EditTextAdapter5Gap(editText); + case "4": return new EditTextAdapterGap(editText, 4); + case "5": return new EditTextAdapterGap(editText, 5); + case "6": return new EditTextAdapterGap(editText, 6); case "no": return new EditTextAdapterNoGap(editText); default: return new EditTextAdapterNoGap(editText); } @@ -75,11 +77,13 @@ public abstract class EditTextAdapter } } - public static class EditTextAdapter5Gap extends EditTextAdapter + public static class EditTextAdapterGap extends EditTextAdapter { - public EditTextAdapter5Gap(EditText editText) + protected int blocksize; + public EditTextAdapterGap(EditText editText, int blocksize) { super(editText); + this.blocksize = blocksize; } @Override @@ -88,13 +92,14 @@ public abstract class EditTextAdapter this.content = text; String out = ""; int i; - for(i=0; i= 65 && x <= 90) //x in [A..Z] - { - output = output + x; - } - else if (x >= 48 && x <= 57) //x in [0..9] - { - output = output + replaceNumber(x); - } - //x is special symbol - else if (x != ' ') - { - output = output + 'X'; - } + case "de": inPrep = new ReplaceNumbersGerman(inPrep); + break; + case "en": inPrep = new ReplaceNumbersEnglish(inPrep); + break; + case "fr": inPrep = new ReplaceNumbersFrench(inPrep); + break; + default: + break; + } + return inPrep; + } + + public static class ReplaceSpecialCharacters extends InputPreparer { + public ReplaceSpecialCharacters() { + this.child = null; + } + + public ReplaceSpecialCharacters(InputPreparer child) { + this.child = child; + } + + protected String prepare(String input) { + input = input.toUpperCase(); + return input.replace("Ä", "AE").replace("Ö", "OE").replace("Ü", "UE").replace("ß", "SS").replace(" ",""); } - return output; } /** - * Abstract method that spells numbers in a certain language specified by the implementation - * @param input character - * @return spelled number + * Concrete implementation of a german InputPreparer */ - public abstract String replaceNumber(char input); + public static class ReplaceNumbersGerman extends InputPreparer { + public ReplaceNumbersGerman() { + this.child = null; + } + + public ReplaceNumbersGerman(InputPreparer child) { + this.child = child; + } + + protected String prepare(String input) { + input = input.replace("0", "NULL") + .replace("1", "EINS") + .replace("2", "ZWEI") + .replace("3", "DREI") + .replace("4", "VIER") + .replace("5", "FUENF") + .replace("6", "SECHS") + .replace("7", "SIEBEN") + .replace("8", "ACHT") + .replace("9", "NEUN"); + return input; + } + } /** - * Factory method that creates a specific InputPreparer - * @param language language alias that specifies the language (de,fr,en) - * @return concrete InputPreparer + * Concrete implementation of a french InputPreparer */ - public static InputPreparer createInputPreparer(String language) + public static class ReplaceNumbersFrench extends InputPreparer { + public ReplaceNumbersFrench() { + this.child = null; + } + + public ReplaceNumbersFrench(InputPreparer child) { + this.child = child; + } + + protected String prepare(String input) { + input = input.replace("0", "ZERO") + .replace("1", "UN") + .replace("2", "DEUX") + .replace("3", "TROIS") + .replace("4", "QUATRE") + .replace("5", "CINQ") + .replace("6", "SIX") + .replace("7", "SEPT") + .replace("8", "HUIT") + .replace("9", "NEUF"); + return input; + } + } + + /** + * Concrete implementation of an english InputPreparer + */ + public static class ReplaceNumbersEnglish extends InputPreparer { + public ReplaceNumbersEnglish() { + this.child = null; + } + + public ReplaceNumbersEnglish(InputPreparer child) { + this.child = child; + } + + protected String prepare(String input) { + input = input.replace("0", "ZERO") + .replace("1", "ONE") + .replace("2", "TWO") + .replace("3", "THREE") + .replace("4", "FOUR") + .replace("5", "FIVE") + .replace("6", "SIX") + .replace("7", "SEVEN") + .replace("8", "EIGHT") + .replace("9", "NINE"); + return input; + } + } + + /** + * "Final Stage" of Input preparing. This should always be called last + * (choose this as the inner most capsule of InputPreparers) + * This cant have child Inputpreparers. + * This Input preparer removes all characters from the string besides A..Z + */ + public static class RemoveIllegalCharacters extends InputPreparer { - switch (language) + public RemoveIllegalCharacters() { - case "de": return new InputPreparerGerman(); - case "fr": return new InputPreparerFrench(); - default: return new InputPreparerEnglish(); + this.child = null; } - } -} -/** - * Concrete implementation of a german InputPreparer - */ -class InputPreparerGerman extends InputPreparer -{ - @Override - public String replaceNumber(char input) { - switch (input) + protected String prepare(String in) { - case '0': return "NULL"; - case '1': return "EINS"; - case '2': return "ZWEI"; - case '3': return "DREI"; - case '4': return "VIER"; - case '5': return "FUENF"; - case '6': return "SECHS"; - case '7': return "SIEBEN"; - case '8': return "ACHT"; - default: return "NEUN"; - } - } -} - -/** - * Concrete implementation of an english InputPreparer - */ -class InputPreparerEnglish extends InputPreparer -{ - @Override - public String replaceNumber(char input) - { - switch (input) { - case '0': return "ZERO"; - case '1': return "ONE"; - case '2': return "TWO"; - case '3': return "THREE"; - case '4': return "FOUR"; - case '5': return "FIVE"; - case '6': return "SIX"; - case '7': return "SEVEN"; - case '8': return "EIGHT"; - default: return "NINE"; - } - } -} - -/** - * Concrete implementation of a french InputPreparer - */ -class InputPreparerFrench extends InputPreparer -{ - - @Override - public String replaceNumber(char input) - { - switch (input) { - case '0': return "ZERO"; - case '1': return "UN"; - case '2': return "DEUX"; - case '3': return "TROIS"; - case '4': return "QUATRE"; - case '5': return "CINQ"; - case '6': return "SIX"; - case '7': return "SEPT"; - case '8': return "HUIT"; - default: return "NEUF"; + String out = ""; + for(char c : in.toUpperCase().toCharArray()) + { + if(c>=65 && c<=90) out = out+c; + } + return out; } } } \ No newline at end of file diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Reflector.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Reflector.java index 2ea92fb..84696eb 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Reflector.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Reflector.java @@ -1,5 +1,7 @@ package de.vanitasvitae.enigmandroid.enigma.rotors; +import android.util.Log; + /** * Reflector of the enigma machine. * The reflector was used to reflect the scrambled signal at the end of the wiring back to @@ -29,6 +31,8 @@ public class Reflector protected int rotation; protected int ringSetting; + public static final int[] defaultWiring_D_KD_G31 = {8,12,4,19,2,6,5,17,0,24,18,16,1,25,23,22,11,7,10,3,21,20,15,14,9,13}; + /** * This constructor is not accessible from outside this class file. * Use the one of the createReflector* methods instead to create concrete Reflectors from @@ -36,10 +40,9 @@ public class Reflector * @param type type indicator of the reflector * @param connections wiring of the reflector as Integer array */ - protected Reflector(String type, int number, int[] connections) + protected Reflector(String type, int[] connections) { this.type = type; - this.number = number; this.connections = connections; } @@ -63,6 +66,16 @@ public class Reflector this.ringSetting = ringSetting; } + public void setConfiguration(int[] c) + { + this.connections = c; + } + + public int[] getConfiguration() + { + return connections; + } + /** * Factory method to create reflectors. * @param type type of the created reflector @@ -84,21 +97,58 @@ public class Reflector { switch (type) { - case 1: return new ReflectorA(); - case 2: return new ReflectorB(); - case 3: return new ReflectorC(); - case 4: return new ReflectorThinB(); - case 5: return new ReflectorThinC(); - case 6: return new ReflectorEnigma_D_KD_G31(); - case 7: return new ReflectorEnigma_K(); - case 8: return new ReflectorEnigma_T(); - case 9: return new Reflector_G312(); - case 10: return new Reflector_G260(); - case 11: return new Reflector_R(); - default: return new ReflectorB(); + //Enigma I + case 10: return new ReflectorA().setTypeNumer(type); + case 11: return new ReflectorB().setTypeNumer(type); + case 12: return new ReflectorC().setTypeNumer(type); + + //Enigma M3 + case 20: return new ReflectorB().setTypeNumer(type); + case 21: return new ReflectorC().setTypeNumer(type); + + //Enigma M4 + case 30: return new ReflectorThinB().setTypeNumer(type); + case 31: return new ReflectorThinC().setTypeNumer(type); + + //Enigma G31 + case 40: return new ReflectorEnigma_D_KD_G31().setTypeNumer(type); + + //Enigma G312 + case 50: return new Reflector_G312().setTypeNumer(type); + + //Enigma G260 + case 60: return new Reflector_G260().setTypeNumer(type); + + //Enigma D + case 70: return new ReflectorEnigma_D_KD_G31().setTypeNumer(type); + + //Enigma K + case 80: return new ReflectorEnigma_K().setTypeNumer(type); + + //Enigma K Swiss + case 90: return new ReflectorEnigma_K().setTypeNumer(type); + + //Enigma K Swiss Airforce + case 100: return new ReflectorEnigma_K().setTypeNumer(type); + + //Enigma R + case 110: return new Reflector_R().setTypeNumer(type); + + //Enigma T + case 120: return new ReflectorEnigma_T().setTypeNumer(type); + + default: + Log.d("Reflector:","Fail! "+type); + return null; } } + public Reflector setTypeNumer(int nr) + { + this.number = nr; + return this; + } + /** * Substitute an input signal via the wiring of the reflector with a different (!) output. * The output MUST not be equal to the input for any input, since this was not possible @@ -156,7 +206,7 @@ public class Reflector { public ReflectorA() { - super("A", 1, new int[]{4,9,12,25,0,11,24,23,21,1,22,5,2,17,16,20,14,13,19,18,15,8,10,7,6,3}); + super("A", new int[]{4,9,12,25,0,11,24,23,21,1,22,5,2,17,16,20,14,13,19,18,15,8,10,7,6,3}); } } @@ -169,7 +219,7 @@ public class Reflector { public ReflectorB() { - super("B", 2, new int[]{24,17,20,7,16,18,11,3,15,23,13,6,14,10,12,8,4,1,5,25,2,22,21,9,0,19}); + super("B", new int[]{24,17,20,7,16,18,11,3,15,23,13,6,14,10,12,8,4,1,5,25,2,22,21,9,0,19}); } } @@ -182,7 +232,7 @@ public class Reflector { public ReflectorC() { - super("C", 3, new int[]{5,21,15,9,8,0,14,24,4,3,17,25,23,22,6,2,19,10,20,16,18,1,13,12,7,11}); + super("C", new int[]{5,21,15,9,8,0,14,24,4,3,17,25,23,22,6,2,19,10,20,16,18,1,13,12,7,11}); } } @@ -197,7 +247,7 @@ public class Reflector { public ReflectorThinB() { - super("ThinB", 4, new int[]{4,13,10,16,0,20,24,22,9,8,2,14,15,1,11,12,3,23,25,21,5,19,7,17,6,18}); + super("ThinB", new int[]{4,13,10,16,0,20,24,22,9,8,2,14,15,1,11,12,3,23,25,21,5,19,7,17,6,18}); } } @@ -212,7 +262,7 @@ public class Reflector { public ReflectorThinC() { - super("ThinC", 5, new int[]{17,3,14,1,9,13,19,10,21,4,7,12,11,5,2,22,25,0,23,6,24,8,15,18,20,16}); + super("ThinC", new int[]{17,3,14,1,9,13,19,10,21,4,7,12,11,5,2,22,25,0,23,6,24,8,15,18,20,16}); } } @@ -223,20 +273,9 @@ public class Reflector */ public static class ReflectorEnigma_D_KD_G31 extends Reflector { - public static final int[] defaultWiring = {8,12,4,19,2,6,5,17,0,24,18,16,1,25,23,22,11,7,10,3,21,20,15,14,9,13}; public ReflectorEnigma_D_KD_G31() { - super("Ref-D", 6, defaultWiring); - } - - public void setConfiguration(int[] conf) - { - this.connections = conf; - } - - public int[] getConfiguration() - { - return this.connections; + super("Ref-D", defaultWiring_D_KD_G31); } } @@ -248,7 +287,7 @@ public class Reflector { public ReflectorEnigma_K() { - super("Ref-K", 7, new int[]{8,12,4,19,2,6,5,17,0,24,18,16,1,25,23,22,11,7,10,3,21,20,15,14,9,13}); + super("Ref-K", new int[]{8,12,4,19,2,6,5,17,0,24,18,16,1,25,23,22,11,7,10,3,21,20,15,14,9,13}); } } /** @@ -259,7 +298,7 @@ public class Reflector { public ReflectorEnigma_T() { - super("Ref-T", 8, new int[]{6,4,10,15,1,19,0,20,12,14,2,13,8,11,9,3,23,25,24,5,7,22,21,16,18,17}); + super("Ref-T", new int[]{6,4,10,15,1,19,0,20,12,14,2,13,8,11,9,3,23,25,24,5,7,22,21,16,18,17}); } } @@ -271,7 +310,7 @@ public class Reflector { public Reflector_G312() { - super("Ref-G312", 9, new int[]{17,20,11,16,12,25,9,18,24,6,14,2,4,19,10,22,3,0,7,13,1,23,15,21,8,5}); + super("Ref-G312", new int[]{17,20,11,16,12,25,9,18,24,6,14,2,4,19,10,22,3,0,7,13,1,23,15,21,8,5}); } } @@ -283,7 +322,7 @@ public class Reflector { public Reflector_G260() { - super("Ref-G260", 10, new int[]{8,12,4,19,2,6,5,17,0,24,18,16,1,25,23,22,11,7,10,3,21,20,15,14,9,13}); + super("Ref-G260", new int[]{8,12,4,19,2,6,5,17,0,24,18,16,1,25,23,22,11,7,10,3,21,20,15,14,9,13}); } } @@ -294,7 +333,7 @@ public class Reflector { public Reflector_R() { - super("Ref-R", 11, new int[]{16,24,7,14,6,13,4,2,21,15,20,25,19,5,3,9,0,23,22,12,10,8,18,17,1,11}); + super("Ref-R", new int[]{16,24,7,14,6,13,4,2,21,15,20,25,19,5,3,9,0,23,22,12,10,8,18,17,1,11}); } } diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Rotor.java b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Rotor.java index dc318a5..1fb0943 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Rotor.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/enigma/rotors/Rotor.java @@ -52,11 +52,10 @@ public class Rotor * @param ringSetting setting of the ring that holds the letters * @param rotation rotation of the rotor */ - protected Rotor(String type, int number, Integer[] connections, Integer[] reversedConnections, + protected Rotor(String type, Integer[] connections, Integer[] reversedConnections, Integer[] turnOverNotches, int ringSetting, int rotation) { this.type = type; - this.number = number; this.connections = connections; this.reversedConnections = reversedConnections; this.turnOverNotches = turnOverNotches; @@ -64,6 +63,12 @@ public class Rotor this.rotation = rotation; } + protected Rotor setTypeNumber(int typenr) + { + this.number = typenr; + return this; + } + /** * Factory method that creates a rotor accordingly to the type. * Also initialize the rotor with ringSetting and rotation. @@ -79,63 +84,90 @@ public class Rotor { switch (type) { - case 0: return new EntryWheel_QWERTZ(); + case 1: Log.d("Rotor", "created " + type); return new EntryWheel_QWERTZ().setTypeNumber(type); + case 2: Log.d("Rotor","created "+type); return new EntryWheel_T().setTypeNumber(type); - case 1: return new Rotor_I(rotation, ringSetting); - case 2: return new Rotor_II(rotation, ringSetting); - case 3: return new Rotor_III(rotation, ringSetting); - case 4: return new Rotor_IV(rotation, ringSetting); - case 5: return new Rotor_V(rotation, ringSetting); - case 6: return new Rotor_VI(rotation, ringSetting); - case 7: return new Rotor_VII(rotation, ringSetting); - case 8: return new Rotor_VIII(rotation, ringSetting); + //Enigma I + case 10: Log.d("Rotor","created "+type); return new Rotor_I(rotation, ringSetting).setTypeNumber(type); + case 11: Log.d("Rotor","created "+type); return new Rotor_II(rotation, ringSetting).setTypeNumber(type); + case 12: Log.d("Rotor","created "+type); return new Rotor_III(rotation, ringSetting).setTypeNumber(type); + case 13: Log.d("Rotor","created "+type); return new Rotor_IV(rotation, ringSetting).setTypeNumber(type); + case 14: Log.d("Rotor","created "+type); return new Rotor_V(rotation, ringSetting).setTypeNumber(type); - case 9: return new Rotor_M4_Beta(rotation, ringSetting); - case 10: return new Rotor_M4_Gamma(rotation, ringSetting); + //Enigma M3 + case 20: Log.d("Rotor","created "+type); return new Rotor_I(rotation, ringSetting).setTypeNumber(type); + case 21: Log.d("Rotor","created "+type); return new Rotor_II(rotation, ringSetting).setTypeNumber(type); + case 22: Log.d("Rotor","created "+type); return new Rotor_III(rotation, ringSetting).setTypeNumber(type); + case 23: Log.d("Rotor","created "+type); return new Rotor_IV(rotation, ringSetting).setTypeNumber(type); + case 24: Log.d("Rotor","created "+type); return new Rotor_V(rotation, ringSetting).setTypeNumber(type); + case 25: Log.d("Rotor","created "+type); return new Rotor_VI(rotation, ringSetting).setTypeNumber(type); + case 26: Log.d("Rotor","created "+type); return new Rotor_VII(rotation, ringSetting).setTypeNumber(type); + case 27: Log.d("Rotor","created "+type); return new Rotor_VIII(rotation, ringSetting).setTypeNumber(type); - case 11: return new Rotor_D_I(rotation, ringSetting); - case 12: return new Rotor_D_II(rotation, ringSetting); - case 13: return new Rotor_D_III(rotation, ringSetting); + //Enigma M4 + case 30: Log.d("Rotor","created "+type); return new Rotor_I(rotation, ringSetting).setTypeNumber(type); + case 31: Log.d("Rotor","created "+type); return new Rotor_II(rotation, ringSetting).setTypeNumber(type); + case 32: Log.d("Rotor","created "+type); return new Rotor_III(rotation, ringSetting).setTypeNumber(type); + case 33: Log.d("Rotor","created "+type); return new Rotor_IV(rotation, ringSetting).setTypeNumber(type); + case 34: Log.d("Rotor","created "+type); return new Rotor_V(rotation, ringSetting).setTypeNumber(type); + case 35: Log.d("Rotor","created "+type); return new Rotor_VI(rotation, ringSetting).setTypeNumber(type); + case 36: Log.d("Rotor","created "+type); return new Rotor_VII(rotation, ringSetting).setTypeNumber(type); + case 37: Log.d("Rotor","created "+type); return new Rotor_VIII(rotation, ringSetting).setTypeNumber(type); + case 38: Log.d("Rotor","created "+type); return new Rotor_M4_Beta(rotation, ringSetting).setTypeNumber(type); + case 39: Log.d("Rotor","created "+type); return new Rotor_M4_Gamma(rotation, ringSetting).setTypeNumber(type); - case 14: return new Rotor_KSwiss_Standard_I(rotation, ringSetting); - case 15: return new Rotor_KSwiss_Standard_II(rotation, ringSetting); - case 16: return new Rotor_KSwiss_Standard_III(rotation, ringSetting); + //Enigma G31 + case 40: Log.d("Rotor","created "+type); return new Rotor_G31_I(rotation, ringSetting).setTypeNumber(type); + case 41: Log.d("Rotor","created "+type); return new Rotor_G31_II(rotation, ringSetting).setTypeNumber(type); + case 42: Log.d("Rotor","created "+type); return new Rotor_G31_III(rotation, ringSetting).setTypeNumber(type); - case 17: return new EntryWheel_T(); - case 18: return new Rotor_T_I(rotation, ringSetting); - case 19: return new Rotor_T_II(rotation, ringSetting); - case 20: return new Rotor_T_III(rotation, ringSetting); - case 21: return new Rotor_T_IV(rotation, ringSetting); - case 22: return new Rotor_T_V(rotation, ringSetting); - case 23: return new Rotor_T_VI(rotation, ringSetting); - case 24: return new Rotor_T_VII(rotation, ringSetting); - case 25: return new Rotor_T_VIII(rotation, ringSetting); + //Enigma G312 + case 50: Log.d("Rotor","created "+type); return new Rotor_G312_I(rotation, ringSetting).setTypeNumber(type); + case 51: Log.d("Rotor","created "+type); return new Rotor_G312_II(rotation, ringSetting).setTypeNumber(type); + case 52: Log.d("Rotor","created "+type); return new Rotor_G312_III(rotation, ringSetting).setTypeNumber(type); - case 26: return new Rotor_G312_I(rotation, ringSetting); - case 27: return new Rotor_G312_II(rotation, ringSetting); - case 28: return new Rotor_G312_III(rotation, ringSetting); + //Enigma G260 + case 60: Log.d("Rotor","created "+type); return new Rotor_G260_I(rotation, ringSetting).setTypeNumber(type); + case 61: Log.d("Rotor","created "+type); return new Rotor_G260_II(rotation, ringSetting).setTypeNumber(type); + case 62: Log.d("Rotor","created "+type); return new Rotor_G260_III(rotation, ringSetting).setTypeNumber(type); - case 29: return new Rotor_G260_I(rotation, ringSetting); - case 30: return new Rotor_G260_II(rotation, ringSetting); - case 31: return new Rotor_G260_III(rotation, ringSetting); + //Enigma D + case 70: Log.d("Rotor","created "+type); return new Rotor_D_I(rotation, ringSetting).setTypeNumber(type); + case 71: Log.d("Rotor","created "+type); return new Rotor_D_II(rotation, ringSetting).setTypeNumber(type); + case 72: Log.d("Rotor","created "+type); return new Rotor_D_III(rotation, ringSetting).setTypeNumber(type); - case 32: return new Rotor_G31_I(rotation, ringSetting); - case 33: return new Rotor_G31_II(rotation, ringSetting); - case 34: return new Rotor_G31_III(rotation, ringSetting); + //Enigma K + case 80: Log.d("Rotor","created "+type); return new Rotor_K_I(rotation, ringSetting).setTypeNumber(type); + case 81: Log.d("Rotor","created "+type); return new Rotor_K_II(rotation, ringSetting).setTypeNumber(type); + case 82: Log.d("Rotor","created "+type); return new Rotor_K_III(rotation, ringSetting).setTypeNumber(type); - case 35: return new Rotor_K_I(rotation, ringSetting); - case 36: return new Rotor_K_II(rotation, ringSetting); - case 37: return new Rotor_K_III(rotation, ringSetting); + //Enigma K Swiss + case 90: Log.d("Rotor","created "+type); return new Rotor_KSwiss_Standard_I(rotation, ringSetting).setTypeNumber(type); + case 91: Log.d("Rotor","created "+type); return new Rotor_KSwiss_Standard_II(rotation, ringSetting).setTypeNumber(type); + case 92: Log.d("Rotor","created "+type); return new Rotor_KSwiss_Standard_III(rotation, ringSetting).setTypeNumber(type); - case 38: return new Rotor_K_Swiss_Airforce_I(rotation, ringSetting); - case 39: return new Rotor_K_Swiss_Airforce_II(rotation, ringSetting); - case 40: return new Rotor_K_Swiss_Airforce_III(rotation, ringSetting); + //Enigma K Swiss Airforce + case 100: Log.d("Rotor","created "+type); return new Rotor_K_Swiss_Airforce_I(rotation, ringSetting).setTypeNumber(type); + case 101: Log.d("Rotor","created "+type); return new Rotor_K_Swiss_Airforce_II(rotation, ringSetting).setTypeNumber(type); + case 102: Log.d("Rotor","created "+type); return new Rotor_K_Swiss_Airforce_III(rotation, ringSetting).setTypeNumber(type); - case 41: return new Rotor_R_I(rotation, ringSetting); - case 42: return new Rotor_R_II(rotation, ringSetting); - case 43: return new Rotor_R_III(rotation, ringSetting); + //Enigma R + case 110: Log.d("Rotor","created "+type); return new Rotor_R_I(rotation, ringSetting).setTypeNumber(type); + case 111: Log.d("Rotor","created "+type); return new Rotor_R_II(rotation, ringSetting).setTypeNumber(type); + case 112: Log.d("Rotor","created "+type); return new Rotor_R_III(rotation, ringSetting).setTypeNumber(type); - default: return new Rotor_I(rotation, ringSetting); + //Enigma T + case 120: Log.d("Rotor","created "+type); return new Rotor_T_I(rotation, ringSetting).setTypeNumber(type); + case 121: Log.d("Rotor","created "+type); return new Rotor_T_II(rotation, ringSetting).setTypeNumber(type); + case 122: Log.d("Rotor","created "+type); return new Rotor_T_III(rotation, ringSetting).setTypeNumber(type); + case 123: Log.d("Rotor","created "+type); return new Rotor_T_IV(rotation, ringSetting).setTypeNumber(type); + case 124: Log.d("Rotor","created "+type); return new Rotor_T_V(rotation, ringSetting).setTypeNumber(type); + case 125: Log.d("Rotor","created "+type); return new Rotor_T_VI(rotation, ringSetting).setTypeNumber(type); + case 126: Log.d("Rotor","created "+type); return new Rotor_T_VII(rotation, ringSetting).setTypeNumber(type); + case 127: Log.d("Rotor","created "+type); return new Rotor_T_VIII(rotation, ringSetting).setTypeNumber(type); + + default: Log.d("Rotor:"," Fail! "+type); + return null; } } @@ -147,7 +179,6 @@ public class Rotor */ public int encryptForward(int input) { - Log.d(this.getType(),"in "+(char)(input+65)+", out "+(char) (this.connections[input]+65)); return this.connections[normalize(input)]; } @@ -277,7 +308,7 @@ public class Rotor { public Rotor_I(int rotation, int ringSetting) { - super("I", 1, + super("I", new Integer[]{4, 10, 12, 5, 11, 6, 3, 16, 21, 25, 13, 19, 14, 22, 24, 7, 23, 20, 18, 15, 0, 8, 1, 17, 2, 9}, new Integer[]{20, 22, 24, 6, 0, 3, 5, 15, 21, 25, 1, 4, 2, 10, 12, 19, 7, 23, 18, 11, 17, 8, 13, 16, 14, 9}, new Integer[]{17}, ringSetting, rotation); @@ -293,7 +324,7 @@ public class Rotor { public Rotor_II(int rotation, int ringSetting) { - super("II", 2, + super("II", new Integer[]{0, 9, 3, 10, 18, 8, 17, 20, 23, 1, 11, 7, 22, 19, 12, 2, 16, 6, 25, 13, 15, 24, 5, 21, 14, 4}, new Integer[]{0, 9, 15, 2, 25, 22, 17, 11, 5, 1, 3, 10, 14, 19, 24, 20, 16, 6, 4, 13, 7, 23, 12, 8, 21, 18}, new Integer[]{5}, ringSetting, rotation); @@ -309,7 +340,7 @@ public class Rotor { public Rotor_III(int rotation, int ringSetting) { - super("III", 3, + super("III", new Integer[]{1, 3, 5, 7, 9, 11, 2, 15, 17, 19, 23, 21, 25, 13, 24, 4, 8, 22, 6, 0, 10, 12, 20, 18, 16, 14}, new Integer[]{19, 0, 6, 1, 15, 2, 18, 3, 16, 4, 20, 5, 21, 13, 25, 7, 24, 8, 23, 9, 22, 11, 17, 10, 14, 12}, new Integer[]{22}, ringSetting, rotation); @@ -325,7 +356,7 @@ public class Rotor { public Rotor_IV(int rotation, int ringSetting) { - super("IV", 4, + super("IV", new Integer[]{4, 18, 14, 21, 15, 25, 9, 0, 24, 16, 20, 8, 17, 7, 23, 11, 13, 5, 19, 6, 10, 3, 2, 12, 22, 1}, new Integer[]{7, 25, 22, 21, 0, 17, 19, 13, 11, 6, 20, 15, 23, 16, 2, 4, 9, 12, 1, 18, 10, 3, 24, 14, 8, 5}, new Integer[]{10}, ringSetting, rotation); @@ -341,7 +372,7 @@ public class Rotor { public Rotor_V(int rotation, int ringSetting) { - super("V", 5, + super("V", new Integer[]{21, 25, 1, 17, 6, 8, 19, 24, 20, 15, 18, 3, 13, 7, 11, 23, 0, 22, 12, 9, 16, 14, 5, 4, 2, 10}, new Integer[]{16, 2, 24, 11, 23, 22, 4, 13, 5, 19, 25, 14, 18, 12, 21, 9, 20, 3, 10, 6, 8, 0, 17, 15, 7, 1}, new Integer[]{0}, ringSetting, rotation); @@ -357,7 +388,7 @@ public class Rotor { public Rotor_VI(int rotation, int ringSetting) { - super("VI", 6, + super("VI", new Integer[]{9,15,6,21,14,20,12,5,24,16,1,4,13,7,25,17,3,10,0,18,23,11,8,2,19,22}, new Integer[]{18,10,23,16,11,7,2,13,22,0,17,21,6,12,4,1,9,15,19,24,5,3,25,20,8,14}, new Integer[]{0,13}, ringSetting, rotation); @@ -373,7 +404,7 @@ public class Rotor { public Rotor_VII(int rotation, int ringSetting) { - super("VII", 7, + super("VII", new Integer[]{13,25,9,7,6,17,2,23,12,24,18,22,1,14,20,5,0,8,21,11,15,4,10,16,3,19}, new Integer[]{16,12,6,24,21,15,4,3,17,2,22,19,8,0,13,20,23,5,10,25,14,18,11,7,9,1}, new Integer[]{0,13}, ringSetting, rotation); @@ -389,7 +420,7 @@ public class Rotor { public Rotor_VIII(int rotation, int ringSetting) { - super("VIII", 8, + super("VIII", new Integer[]{5,10,16,7,19,11,23,14,2,1,9,18,15,3,25,17,0,12,4,22,13,8,20,24,6,21}, new Integer[]{16,9,8,13,18,0,24,3,21,10,1,5,17,20,7,12,2,15,11,4,22,25,19,6,23,14}, new Integer[]{0,13}, ringSetting, rotation); @@ -408,7 +439,7 @@ public class Rotor { public Rotor_M4_Beta(int rotation, int ringSetting) { - super("Beta", 9, + super("Beta", new Integer[]{11,4,24,9,21,2,13,8,23,22,15,1,16,12,3,17,19,0,10,25,6,5,20,7,14,18}, new Integer[]{17,11,5,14,1,21,20,23,7,3,18,0,13,6,24,10,12,15,25,16,22,4,9,8,2,19}, new Integer[]{}, ringSetting, rotation); @@ -439,7 +470,7 @@ public class Rotor { public Rotor_M4_Gamma(int rotation, int ringSetting) { - super("Gamma", 10, + super("Gamma", new Integer[]{5,18,14,10,0,13,20,4,17,7,12,1,19,8,24,2,22,11,16,15,25,23,21,6,9,3}, new Integer[]{4,11,15,25,7,0,23,9,13,24,3,17,10,5,2,19,18,8,1,12,6,22,16,21,14,20}, new Integer[]{}, ringSetting, rotation); @@ -466,7 +497,7 @@ public class Rotor { public EntryWheel_QWERTZ() { - super("ETW-D", 0, + super("ETW-D", new Integer[]{9,22,20,11,2,12,13,14,7,15,16,25,24,23,8,17,0,3,10,4,6,21,1,19,18,5}, new Integer[]{16,22,4,17,19,25,20,8,14,0,18,3,5,6,7,9,10,15,24,23,2,21,1,13,12,11}, new Integer[]{}, 0, 0); @@ -494,7 +525,7 @@ public class Rotor { public Rotor_D_I(int rotation, int ringSetting) { - super("D-I", 11, + super("D-I", new Integer[]{11,15,6,18,25,12,7,0,4,14,16,10,21,23,17,5,24,1,20,19,13,8,2,9,3,22}, new Integer[]{7,17,22,24,8,15,2,6,21,23,11,0,5,20,9,1,10,14,3,19,18,12,25,13,16,4}, new Integer[]{25}, ringSetting, rotation); @@ -510,7 +541,7 @@ public class Rotor { public Rotor_D_II(int rotation, int ringSetting) { - super("D-II", 12, + super("D-II", new Integer[]{18,11,21,6,1,19,5,23,9,16,14,7,4,22,8,17,25,24,0,12,10,15,2,13,3,20}, new Integer[]{18,4,22,24,12,6,3,11,14,8,20,1,19,23,10,21,9,15,0,5,25,2,13,7,17,16}, new Integer[]{5}, ringSetting, rotation); @@ -526,7 +557,7 @@ public class Rotor { public Rotor_D_III(int rotation, int ringSetting) { - super("D-III", 13, + super("D-III", new Integer[]{2,9,6,3,15,18,7,10,19,20,17,0,22,25,23,5,12,24,13,16,14,1,21,11,8,4}, new Integer[]{11,21,0,3,25,15,2,6,24,1,7,23,16,18,20,4,19,10,5,8,9,22,12,14,17,13}, new Integer[]{14}, ringSetting, rotation); @@ -542,7 +573,7 @@ public class Rotor { public Rotor_KSwiss_Standard_I(int rotation, int ringSetting) { - super("KS-I", 14, + super("KS-I", new Integer[]{15,4,25,20,14,7,23,18,2,21,5,12,19,1,6,11,17,8,13,16,9,22,0,24,3,10}, new Integer[]{22,13,8,24,1,10,14,5,17,20,25,15,11,18,4,0,19,16,7,12,3,9,21,6,23,2}, new Integer[]{25}, ringSetting, rotation); @@ -558,7 +589,7 @@ public class Rotor { public Rotor_KSwiss_Standard_II(int rotation, int ringSetting) { - super("KS-II", 15, + super("KS-II", new Integer[]{25,14,20,4,18,24,3,10,5,22,15,2,8,16,23,7,12,21,1,11,6,13,9,17,0,19}, new Integer[]{24,18,11,6,3,8,20,15,12,22,7,19,16,21,1,10,13,23,4,25,2,17,9,14,5,0}, new Integer[]{5}, ringSetting, rotation); @@ -574,7 +605,7 @@ public class Rotor { public Rotor_KSwiss_Standard_III(int rotation, int ringSetting) { - super("KS-III", 16, + super("KS-III", new Integer[]{4,7,17,21,23,6,0,14,1,16,20,18,8,12,25,5,11,24,13,22,10,19,15,3,9,2}, new Integer[]{6,8,25,23,0,15,5,1,12,24,20,16,13,18,7,22,9,2,11,21,10,3,19,4,17,14}, new Integer[]{14}, ringSetting, rotation); @@ -589,7 +620,7 @@ public class Rotor { public EntryWheel_T() { - super("T-ETW", 17, + super("T-ETW", new Integer[]{8,11,23,17,25,19,10,6,9,24,0,12,22,21,3,20,5,2,15,16,4,14,13,18,7,1}, new Integer[]{10,25,17,14,20,16,7,24,0,8,6,1,11,22,21,18,19,3,23,5,15,13,12,2,9,4}, new Integer[]{}, 0, 0); @@ -616,7 +647,7 @@ public class Rotor { public Rotor_T_I(int rotation, int ringSetting) { - super("T-I", 18, + super("T-I", new Integer[]{10,15,19,24,20,4,11,14,2,21,6,17,5,16,3,0,13,9,12,1,18,22,7,25,23,8}, new Integer[]{15,19,8,14,5,12,10,22,25,17,0,6,18,16,7,1,13,11,20,2,4,9,21,24,3,23}, new Integer[]{23,0,5,11,17}, ringSetting, rotation); @@ -632,7 +663,7 @@ public class Rotor { public Rotor_T_II(int rotation, int ringSetting) { - super("T-II", 19, + super("T-II", new Integer[]{20,15,7,25,11,22,4,16,12,19,3,9,23,2,0,10,18,14,8,6,21,1,24,5,13,17}, new Integer[]{14,21,13,10,6,23,19,2,18,11,15,4,8,24,17,1,7,25,16,9,0,20,5,12,22,3}, new Integer[]{23,0,6,12,18}, ringSetting, rotation); @@ -647,7 +678,7 @@ public class Rotor private static class Rotor_T_III extends Rotor { public Rotor_T_III(int rotation, int ringSetting) { - super("T-III", 20, + super("T-III", new Integer[]{16,20,3,11,24,17,5,4,10,14,13,21,25,0,23,22,7,12,6,15,9,1,18,8,2,19}, new Integer[]{13,21,24,2,7,6,18,16,23,20,8,3,17,10,9,19,0,5,22,25,1,11,15,14,4,12}, new Integer[]{23,0,5,11,17}, ringSetting, rotation); @@ -663,7 +694,7 @@ public class Rotor { public Rotor_T_IV(int rotation, int ringSetting) { - super("T-IV", 21, + super("T-IV", new Integer[]{2,8,22,19,1,10,23,13,17,4,18,15,5,11,24,3,0,6,21,7,16,20,14,9,25,12}, new Integer[]{16,4,0,15,9,12,17,19,1,23,5,13,25,7,22,11,20,8,10,3,21,18,2,6,14,24}, new Integer[]{23,0,6,12,18}, ringSetting, rotation); @@ -679,7 +710,7 @@ public class Rotor { public Rotor_T_V(int rotation, int ringSetting) { - super("T-V", 22, + super("T-V", new Integer[]{20,0,23,6,8,18,13,9,1,21,4,17,3,24,11,5,25,22,19,15,2,10,14,7,12,16}, new Integer[]{1,8,20,12,10,15,3,23,4,7,21,14,24,6,22,19,25,11,5,18,0,9,17,2,13,16}, new Integer[]{25,3,6,11,18}, ringSetting, rotation); @@ -695,7 +726,7 @@ public class Rotor { public Rotor_T_VI(int rotation, int ringSetting) { - super("T-VI", 23, + super("T-VI", new Integer[]{23,5,20,25,6,0,11,21,7,2,13,24,18,4,22,16,19,3,12,17,1,10,15,8,14,9}, new Integer[]{5,20,9,17,13,1,4,8,23,25,21,6,18,10,24,22,15,19,12,16,2,7,14,0,11,3}, new Integer[]{24,5,9,13,17}, ringSetting, rotation); @@ -711,7 +742,7 @@ public class Rotor { public Rotor_T_VII(int rotation, int ringSetting) { - super("T-VII", 24, + super("T-VII", new Integer[]{1,9,21,5,19,23,15,11,13,0,24,14,25,8,10,22,6,3,16,4,17,20,2,7,18,12}, new Integer[]{9,0,22,17,19,3,16,23,13,1,14,7,25,8,11,6,18,20,24,4,21,2,15,5,10,12}, new Integer[]{25,3,6,11,18}, ringSetting, rotation); @@ -727,7 +758,7 @@ public class Rotor { public Rotor_T_VIII(int rotation, int ringSetting) { - super("T-VIII", 25, + super("T-VIII", new Integer[]{24,12,19,15,13,25,7,22,10,14,3,0,9,23,4,11,20,16,21,6,2,1,8,18,5,17}, new Integer[]{11,21,20,10,14,24,19,6,22,12,8,15,1,4,9,3,17,25,23,2,16,18,7,13,0,5}, new Integer[]{24,5,9,13,17}, ringSetting, rotation); @@ -743,7 +774,7 @@ public class Rotor { public Rotor_G312_I(int rotation, int ringSetting) { - super("G312-I", 26, + super("G312-I", new Integer[]{3,12,19,22,18,8,11,17,20,24,16,13,10,5,4,9,2,0,25,1,15,6,23,14,7,21}, new Integer[]{17,19,16,0,14,13,21,24,5,15,12,6,1,11,23,20,10,7,4,2,8,25,3,22,9,18}, new Integer[]{19,21,22,23,0,1,2,3,5,6,7,9,11,12,15,16,17}, ringSetting, rotation); @@ -759,7 +790,7 @@ public class Rotor { public Rotor_G312_II(int rotation, int ringSetting) { - super("G312-II", 27, + super("G312-II", new Integer[]{7,16,25,6,15,9,19,12,14,1,11,13,2,8,5,3,24,0,22,21,4,20,18,17,10,23}, new Integer[]{17,9,12,15,20,14,3,0,13,5,24,10,7,11,8,4,1,23,22,6,21,19,18,25,16,2}, new Integer[]{19,20,22,25,0,1,3,4,6,7,8,11,13,14,17}, ringSetting, rotation); @@ -775,7 +806,7 @@ public class Rotor { public Rotor_G312_III(int rotation, int ringSetting) { - super("G312-III", 28, + super("G312-III", new Integer[]{20,16,13,19,11,18,25,5,12,17,4,7,3,15,23,10,8,1,21,24,6,9,2,22,14,0}, new Integer[]{25,17,22,12,10,7,20,11,16,21,15,4,8,2,24,13,1,9,5,3,0,18,23,14,19,6}, new Integer[]{21,23,24,1,5,6,8,11,13,14,18}, ringSetting, rotation); @@ -791,7 +822,7 @@ public class Rotor { public Rotor_G260_I(int rotation, int ringSetting) { - super("G260-I", 29, + super("G260-I", new Integer[]{17,2,18,15,1,11,10,16,0,20,12,7,22,24,19,8,5,25,21,6,14,9,13,4,23,3}, new Integer[]{8,4,1,25,23,16,19,11,15,21,6,5,10,22,20,3,7,0,2,14,9,18,12,24,13,17}, new Integer[]{19,21,22,23,0,1,2,3,5,6,7,9,11,12,15,16,17}, ringSetting, rotation); @@ -807,7 +838,7 @@ public class Rotor { public Rotor_G260_II(int rotation, int ringSetting) { - super("G260-II", 30, + super("G260-II", new Integer[]{22,2,12,8,1,21,15,9,23,0,17,14,18,6,13,3,11,25,10,4,24,7,20,5,16,19}, new Integer[]{9,4,1,15,19,23,13,21,3,7,18,16,2,14,11,6,24,10,12,25,22,5,0,8,20,17}, new Integer[]{19,20,22,25,0,1,3,4,6,7,8,11,13,14,17}, ringSetting, rotation); @@ -823,7 +854,7 @@ public class Rotor { public Rotor_G260_III(int rotation, int ringSetting) { - super("G260-III", 31, + super("G260-III", new Integer[]{5,21,3,7,25,4,11,18,16,12,0,23,14,10,24,8,22,15,6,2,1,20,9,19,13,17}, new Integer[]{10,20,19,2,5,0,18,3,15,22,13,6,9,24,12,17,8,25,7,23,21,1,16,11,14,4}, new Integer[]{21,23,24,1,5,6,8,11,13,14,18}, ringSetting, rotation); @@ -839,7 +870,7 @@ public class Rotor { public Rotor_G31_I(int rotation, int ringSetting) { - super("G31-I", 32, + super("G31-I", new Integer[]{11,15,6,18,25,12,7,0,4,14,16,10,21,23,17,5,24,1,20,19,13,8,2,9,3,22}, new Integer[]{7,17,22,24,8,15,2,6,21,23,11,0,5,20,9,1,10,14,3,19,18,12,25,13,16,4}, new Integer[]{19,21,22,23,0,1,2,3,5,6,7,9,11,12,15,16,17}, ringSetting, rotation); @@ -855,7 +886,7 @@ public class Rotor { public Rotor_G31_II(int rotation, int ringSetting) { - super("G31_II", 33, + super("G31_II", new Integer[]{18,11,21,6,1,19,5,23,9,16,14,7,4,22,8,17,25,24,0,12,10,15,2,13,3,20}, new Integer[]{18,4,22,24,12,6,3,11,14,8,20,1,19,23,10,21,9,15,0,5,25,2,13,7,17,16}, new Integer[]{19,20,22,25,0,1,3,4,6,7,8,11,13,14,17}, ringSetting, rotation); @@ -871,7 +902,7 @@ public class Rotor { public Rotor_G31_III(int rotation, int ringSetting) { - super("G31_III", 34, + super("G31_III", new Integer[]{2,9,6,3,15,18,7,10,19,20,17,0,22,25,23,5,12,24,13,16,14,1,21,11,8,4}, new Integer[]{11,21,0,3,25,15,2,6,24,1,7,23,16,18,20,4,19,10,5,8,9,22,12,14,17,13}, new Integer[]{21,23,24,1,5,6,8,11,13,14,18}, ringSetting, rotation); @@ -887,7 +918,7 @@ public class Rotor { public Rotor_K_I(int rotation, int ringSetting) { - super("K-I", 35, + super("K-I", new Integer[]{11,15,6,18,25,12,7,0,4,14,16,10,21,23,17,5,24,1,20,19,13,8,2,9,3,22}, new Integer[]{7,17,22,24,8,15,2,6,21,23,11,0,5,20,9,1,10,14,3,19,18,12,25,13,16,4}, new Integer[]{25}, ringSetting, rotation); @@ -903,7 +934,7 @@ public class Rotor { public Rotor_K_II(int rotation, int ringSetting) { - super("K-II", 36, + super("K-II", new Integer[]{18,11,21,6,1,19,5,23,9,16,14,7,4,22,8,17,25,24,0,12,10,15,2,13,3,20}, new Integer[]{18,4,22,24,12,6,3,11,14,8,20,1,19,23,10,21,9,15,0,5,25,2,13,7,17,16}, new Integer[]{5}, ringSetting, rotation); @@ -919,7 +950,7 @@ public class Rotor { public Rotor_K_III(int rotation, int ringSetting) { - super("K-III", 37, + super("K-III", new Integer[]{2,9,6,3,15,18,7,10,19,20,17,0,22,25,23,5,12,24,13,16,14,1,21,11,8,4}, new Integer[]{11,21,0,3,25,15,2,6,24,1,7,23,16,18,20,4,19,10,5,8,9,22,12,14,17,13}, new Integer[]{14}, ringSetting, rotation); @@ -935,7 +966,7 @@ public class Rotor { public Rotor_K_Swiss_Airforce_I(int rotation, int ringSetting) { - super("KSA-I", 38, + super("KSA-I", new Integer[]{15,4,25,20,14,7,23,18,2,21,5,12,19,1,6,11,17,8,13,16,9,22,0,24,3,10}, new Integer[]{22,13,8,24,1,10,14,5,17,20,25,15,11,18,4,0,19,16,7,12,3,9,21,6,23,2}, new Integer[]{25}, ringSetting, rotation); @@ -950,7 +981,7 @@ public class Rotor { public Rotor_K_Swiss_Airforce_II(int rotation, int ringSetting) { - super("KSA-II", 39, + super("KSA-II", new Integer[]{25,14,20,4,18,24,3,10,5,22,15,2,8,16,23,7,12,21,1,11,6,13,9,17,0,19}, new Integer[]{24,18,11,6,3,8,20,15,12,22,7,19,16,21,1,10,13,23,4,25,2,17,9,14,5,0}, new Integer[]{5}, ringSetting, rotation); @@ -965,7 +996,7 @@ public class Rotor { public Rotor_K_Swiss_Airforce_III(int rotation, int ringSetting) { - super("KSA-III", 40, + super("KSA-III", new Integer[]{4,7,17,21,23,6,0,14,1,16,20,18,8,12,25,5,11,24,13,22,10,19,15,3,9,2}, new Integer[]{6,8,25,23,0,15,5,1,12,24,20,16,13,18,7,22,9,2,11,21,10,3,19,4,17,14}, new Integer[]{14}, ringSetting, rotation); @@ -981,7 +1012,7 @@ public class Rotor { public Rotor_R_I(int rotation, int ringSetting) { - super("R-I", 41, + super("R-I", new Integer[]{9,6,3,16,14,23,20,18,2,0,12,8,5,17,21,19,15,13,4,22,10,1,11,25,24,7}, new Integer[]{9,21,8,2,18,12,1,25,11,0,20,22,10,17,4,16,3,13,7,15,6,14,19,5,24,23}, new Integer[]{14}, ringSetting, rotation); @@ -997,7 +1028,7 @@ public class Rotor { public Rotor_R_II(int rotation, int ringSetting) { - super("R-II", 42, + super("R-II", new Integer[]{13,19,25,15,18,5,1,14,10,12,22,17,2,9,3,8,21,11,0,4,24,20,23,7,6,16}, new Integer[]{18,6,12,14,19,5,24,23,15,13,8,17,9,0,7,3,25,11,4,1,21,16,10,22,20,2}, new Integer[]{5}, ringSetting, rotation); @@ -1013,7 +1044,7 @@ public class Rotor { public Rotor_R_III(int rotation, int ringSetting) { - super("R-III", 43, + super("R-III", new Integer[]{9,21,8,20,1,7,19,2,3,24,0,10,4,16,25,15,14,18,6,23,13,17,12,22,5,11}, new Integer[]{10,4,7,8,12,24,18,5,2,0,11,25,22,20,16,15,13,21,17,6,3,1,23,19,9,14}, new Integer[]{25}, ringSetting, rotation); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G260.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G260.java index 0339642..4d2a5f8 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G260.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G260.java @@ -32,7 +32,7 @@ public class LayoutContainer_G260 extends LayoutContainer { private Enigma_G260 enigma; - protected int offsetRot = 29; + protected int offsetRot = 60; protected Spinner rotor1View; protected Spinner rotor2View; diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G31.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G31.java index 3e85691..b576482 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G31.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G31.java @@ -32,7 +32,7 @@ public class LayoutContainer_G31 extends LayoutContainer { private Enigma_G31 enigma; - protected int offsetRot = 32; + protected int offsetRot = 40; protected Spinner rotor1View; protected Spinner rotor2View; diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G312.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G312.java index 00a3f71..9251355 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G312.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_G312.java @@ -32,7 +32,7 @@ public class LayoutContainer_G312 extends LayoutContainer { private Enigma_G312 enigma; - protected int offsetRot = 26; + protected int offsetRot = 50; protected Spinner rotor1View; protected Spinner rotor2View; diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_I.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_I.java index 80902f9..4cb4a86 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_I.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_I.java @@ -117,10 +117,10 @@ public class LayoutContainer_I extends LayoutContainer protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1() - 1); - this.rotor2View.setSelection(state.getTypeRotor2() - 1); - this.rotor3View.setSelection(state.getTypeRotor3() - 1); - this.reflectorView.setSelection(state.getTypeReflector() - 1); + this.rotor1View.setSelection(state.getTypeRotor1() - 10); + this.rotor2View.setSelection(state.getTypeRotor2() - 10); + this.rotor3View.setSelection(state.getTypeRotor3() - 10); + this.reflectorView.setSelection(state.getTypeReflector() - 10); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -129,10 +129,10 @@ public class LayoutContainer_I extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 1); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 1); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 1); - state.setTypeReflector(reflectorView.getSelectedItemPosition() + 1); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 10); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 10); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 10); + state.setTypeReflector(reflectorView.getSelectedItemPosition() + 10); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K.java index dd19118..cbc0f3a 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K.java @@ -115,9 +115,9 @@ public class LayoutContainer_K extends LayoutContainer protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1() - 35); - this.rotor2View.setSelection(state.getTypeRotor2() - 35); - this.rotor3View.setSelection(state.getTypeRotor3() - 35); + this.rotor1View.setSelection(state.getTypeRotor1() - 80); + this.rotor2View.setSelection(state.getTypeRotor2() - 80); + this.rotor3View.setSelection(state.getTypeRotor3() - 80); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -127,9 +127,9 @@ public class LayoutContainer_K extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 35); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 35); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 35); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 80); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 80); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 80); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss.java index 5e41cc2..b72f822 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss.java @@ -115,9 +115,9 @@ public class LayoutContainer_K_Swiss extends LayoutContainer protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1() - 14); - this.rotor2View.setSelection(state.getTypeRotor2() - 14); - this.rotor3View.setSelection(state.getTypeRotor3() - 14); + this.rotor1View.setSelection(state.getTypeRotor1() - 90); + this.rotor2View.setSelection(state.getTypeRotor2() - 90); + this.rotor3View.setSelection(state.getTypeRotor3() - 90); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -127,9 +127,9 @@ public class LayoutContainer_K_Swiss extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 14); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 14); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 14); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 90); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 90); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 90); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss_Airforce.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss_Airforce.java index 52ae386..b2b29ed 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss_Airforce.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_K_Swiss_Airforce.java @@ -115,9 +115,9 @@ public class LayoutContainer_K_Swiss_Airforce extends LayoutContainer protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1() - 38); - this.rotor2View.setSelection(state.getTypeRotor2() - 38); - this.rotor3View.setSelection(state.getTypeRotor3() - 38); + this.rotor1View.setSelection(state.getTypeRotor1() - 100); + this.rotor2View.setSelection(state.getTypeRotor2() - 100); + this.rotor3View.setSelection(state.getTypeRotor3() - 100); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -127,9 +127,9 @@ public class LayoutContainer_K_Swiss_Airforce extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 38); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 38); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 38); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 100); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 100); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 100); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M3.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M3.java index 999dfd8..68b71c7 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M3.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M3.java @@ -109,10 +109,10 @@ public class LayoutContainer_M3 extends LayoutContainer_I protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1()-1); - this.rotor2View.setSelection(state.getTypeRotor2() - 1); - this.rotor3View.setSelection(state.getTypeRotor3() - 1); - this.reflectorView.setSelection(state.getTypeReflector() - 2); + this.rotor1View.setSelection(state.getTypeRotor1() - 20); + this.rotor2View.setSelection(state.getTypeRotor2() - 20); + this.rotor3View.setSelection(state.getTypeRotor3() - 20); + this.reflectorView.setSelection(state.getTypeReflector() - 20); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -121,10 +121,10 @@ public class LayoutContainer_M3 extends LayoutContainer_I @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 1); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 1); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 1); - state.setTypeReflector(reflectorView.getSelectedItemPosition() + 2); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 20); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 20); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 20); + state.setTypeReflector(reflectorView.getSelectedItemPosition() + 20); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M4.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M4.java index 3c8ab1e..c6d1ede 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M4.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_M4.java @@ -141,11 +141,11 @@ public class LayoutContainer_M4 extends LayoutContainer @Override protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1()-1); - this.rotor2View.setSelection(state.getTypeRotor2() - 1); - this.rotor3View.setSelection(state.getTypeRotor3() - 1); - this.rotor4View.setSelection(state.getTypeRotor4() - 9); - this.reflectorView.setSelection(state.getTypeReflector() - 4); + this.rotor1View.setSelection(state.getTypeRotor1() - 30); + this.rotor2View.setSelection(state.getTypeRotor2() - 30); + this.rotor3View.setSelection(state.getTypeRotor3() - 30); + this.rotor4View.setSelection(state.getTypeRotor4() - 38); + this.reflectorView.setSelection(state.getTypeReflector() - 30); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -154,11 +154,11 @@ public class LayoutContainer_M4 extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 1); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 1); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 1); - state.setTypeRotor4(rotor4View.getSelectedItemPosition() + 9); - state.setTypeReflector(reflectorView.getSelectedItemPosition() + 4); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 30); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 30); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 30); + state.setTypeRotor4(rotor4View.getSelectedItemPosition() + 38); + state.setTypeReflector(reflectorView.getSelectedItemPosition() + 30); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_R.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_R.java index 527f22d..4d7c496 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_R.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_R.java @@ -114,9 +114,9 @@ public class LayoutContainer_R extends LayoutContainer protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1() - 41); - this.rotor2View.setSelection(state.getTypeRotor2() - 41); - this.rotor3View.setSelection(state.getTypeRotor3() - 41); + this.rotor1View.setSelection(state.getTypeRotor1() - 110); + this.rotor2View.setSelection(state.getTypeRotor2() - 110); + this.rotor3View.setSelection(state.getTypeRotor3() - 110); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); this.rotor3PositionView.setSelection(state.getRotationRotor3()); @@ -126,9 +126,9 @@ public class LayoutContainer_R extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 41); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 41); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 41); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 110); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 110); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 110); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_T.java b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_T.java index 61d9815..ac47f1f 100644 --- a/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_T.java +++ b/app/src/main/java/de/vanitasvitae/enigmandroid/layout/LayoutContainer_T.java @@ -114,9 +114,9 @@ public class LayoutContainer_T extends LayoutContainer protected void setLayoutState(EnigmaStateBundle state) { this.state = state; - this.rotor1View.setSelection(state.getTypeRotor1() - 18); - this.rotor2View.setSelection(state.getTypeRotor2() - 18); - this.rotor3View.setSelection(state.getTypeRotor3() - 18); + this.rotor1View.setSelection(state.getTypeRotor1() - 120); + this.rotor2View.setSelection(state.getTypeRotor2() - 120); + this.rotor3View.setSelection(state.getTypeRotor3() - 120); this.rotor1PositionView.setSelection(state.getRotationRotor1()); this.rotor2PositionView.setSelection(state.getRotationRotor2()); @@ -127,9 +127,9 @@ public class LayoutContainer_T extends LayoutContainer @Override protected void refreshState() { - state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 18); - state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 18); - state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 18); + state.setTypeRotor1(rotor1View.getSelectedItemPosition() + 120); + state.setTypeRotor2(rotor2View.getSelectedItemPosition() + 120); + state.setTypeRotor3(rotor3View.getSelectedItemPosition() + 120); state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition()); state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition()); state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition()); diff --git a/app/src/main/res/values-de/strings_activity_settings.xml b/app/src/main/res/values-de/strings_activity_settings.xml index b1a3e24..ee65914 100755 --- a/app/src/main/res/values-de/strings_activity_settings.xml +++ b/app/src/main/res/values-de/strings_activity_settings.xml @@ -3,15 +3,35 @@ Simulation Enigma Modell Welches Modell soll simuliert werden? + + I (Heer, Luftwaffe) + M3 (Heer, Marine) + M4 (\"Shark\", Marine) + G31/A865 (Abwehr) + G312 (Abwehr) + G260 (Abwehr) + D (Kommerziell) + K + K (Schweiz) + K (Schweiz, Luftwaffe) + R (\"Rocket\", Reichsbahn) + T (\"Tirpitz\", Japan) + Doppelschritt Anomalie Die Doppelschritt Anomalie lässt die mittlere Walze zweimal rotieren, falls sie sich vor dem Übertragspunkt befindet. + + Eingabe Vorbereitung + Sonderzeichen + Ersetze Sonderzeichen mit ähnlichen Zeichen + Entferne Sonderzeichen aus der Nachricht Zahlenbuchstabiersprache Sprache in der Zahlen buchstabiert werden sollen. Deutsch Französisch Englisch + Keine Ersetzung Erscheinungsbild @@ -19,6 +39,8 @@ Soll die Nachricht in Blöcke unterteilt werden? Keine Unterteilung + Viererblöcke Fünferblöcke + Sechserblöcke diff --git a/app/src/main/res/values/strings_activity_settings.xml b/app/src/main/res/values/strings_activity_settings.xml index b22122d..a2d1377 100755 --- a/app/src/main/res/values/strings_activity_settings.xml +++ b/app/src/main/res/values/strings_activity_settings.xml @@ -4,18 +4,18 @@ Simulation Enigma Model Which model do you want to simulate? - - I (Heer, Luftwaffe) - M3 (Heer, Marine) - M4 (\"Shark\", Marine) - G31/A865 (Abwehr) - G312 (Abwehr) - G260 (Abwehr) - D (Kommerziell) + + I (Army, Airforce) + M3 (Army, Navy) + M4 (\"Shark\", Navy) + G31/A865 (Defense) + G312 (Defense) + G260 (Defense) + D (Commercial) K K (Swiss) K (Swiss, Airforce) - R (\"Rocket\", Reichsbahn) + R (\"Rocket\", Railway) T (\"Tirpitz\", Japan) @@ -32,34 +32,44 @@ R T - Simulate Anomaly The double step anomaly causes the middle rotor to rotate twice, if it is one step before its turnover point. + + Input Preparation + Special characters + Replace special characters with similar ones + Remove special characters from the message Number spelling language Language, in which numbers are spelled. German French English + No replacing de fr en + no Appearance Message Formatting Do you want to split the message up into blocks? - No blocks + No division + Blocks of 4 Blocks of 5 + Blocks of 6 no + 4 5 + 6 diff --git a/app/src/main/res/xml/pref_page.xml b/app/src/main/res/xml/pref_page.xml index 13505e9..dbe7d9a 100755 --- a/app/src/main/res/xml/pref_page.xml +++ b/app/src/main/res/xml/pref_page.xml @@ -9,11 +9,20 @@ android:entries="@array/pref_list_machine_type" android:entryValues="@array/pref_alias_machine_type" android:defaultValue="Enigma I"/> - + + + + +