Reworked InputPreparer, Reworked Reflecto-/Rotor-creation

This commit is contained in:
VanitasVitae 2015-09-22 21:10:41 +02:00
parent 8e49652f91
commit 82e21e48ec
34 changed files with 575 additions and 406 deletions

View file

@ -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)

View file

@ -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;
}

View file

@ -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)
{

View file

@ -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());

View file

@ -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);
}
}

View file

@ -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());

View file

@ -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);
}
}

View file

@ -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

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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());

View file

@ -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
}

View file

@ -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;

View file

@ -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<text.length()/5; i++)
for(i=0; i<text.length()/blocksize; i++)
{
out = out + text.substring(i*5, (i+1)*5);
out = out + text.substring(i*blocksize, (i+1)*blocksize);
out = out + " ";
}
out = out + text.substring(i*5);
out = out + text.substring(i*blocksize);
this.editText.setText(out);
}
}
}

View file

@ -1,5 +1,12 @@
package de.vanitasvitae.enigmandroid.enigma.inputPreparer;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.R;
import de.vanitasvitae.enigmandroid.SettingsActivity;
/**
* Preparer class that prepares input text to only consist of [A..Z]
* Copyright (C) 2015 Paul Schaub
@ -19,128 +26,160 @@ package de.vanitasvitae.enigmandroid.enigma.inputPreparer;
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @author vanitasvitae
*/
public abstract class InputPreparer
{
/**
* Prepare the input String in a way that it only contains letters from [A..Z].
* Replace special characters, remove spaces and spell numbers.
* @param input String
* @return prepared String
*/
public String prepareString(String input)
{
input = input.toUpperCase();
input = input.replace("Ä","AE").replace("Ö","OE").replace("Ü","UE").replace("ß","SS");
String output = "";
public abstract class InputPreparer {
protected InputPreparer child;
for (char x : input.toCharArray())
public String prepareString(String in) {
if (child != null)
return child.prepareString(this.prepare(in));
else
return prepare(in);
}
protected abstract String prepare(String input);
public static InputPreparer createInputPreparer()
{
MainActivity main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main);
boolean replaceSpecialChars = sharedPreferences.getBoolean(SettingsActivity.PREF_REPLACE_SPECIAL_CHARACTERS, true);
String num_lang = sharedPreferences.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, main.getResources().
getStringArray(R.array.pref_alias_numeric_spelling_language)[0]);
boolean replaceSpaces = sharedPreferences.getBoolean(SettingsActivity.PREF_REPLACE_SPACES, false);
InputPreparer inPrep = new RemoveIllegalCharacters();
if(replaceSpecialChars) inPrep = new ReplaceSpecialCharacters(inPrep);
switch (num_lang)
{
if (x >= 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;
}
}
}

View file

@ -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});
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -3,15 +3,35 @@
<string name="pref_header_simulation">Simulation</string>
<string name="pref_title_machine_type">Enigma Modell</string>
<string name="pref_description_machine_type">Welches Modell soll simuliert werden?</string>
<string-array name="pref_list_machine_type">
<item>I (Heer, Luftwaffe)</item>
<item>M3 (Heer, Marine)</item>
<item>M4 (\"Shark\", Marine)</item>
<item>G31/A865 (Abwehr)</item>
<item>G312 (Abwehr)</item>
<item>G260 (Abwehr)</item>
<item>D (Kommerziell)</item>
<item>K</item>
<item>K (Schweiz)</item>
<item>K (Schweiz, Luftwaffe)</item>
<item>R (\"Rocket\", Reichsbahn)</item>
<item>T (\"Tirpitz\", Japan)</item>
</string-array>
<string name="pref_title_simulate_anomaly">Doppelschritt Anomalie</string>
<string name="pref_description_simulate_anomaly">Die Doppelschritt Anomalie lässt die mittlere Walze zweimal rotieren,
falls sie sich vor dem Übertragspunkt befindet.</string>
<string name="pref_header_input_preparation">Eingabe Vorbereitung</string>
<string name="pref_title_special_characters">Sonderzeichen</string>
<string name="pref_on_replace_special_characters">Ersetze Sonderzeichen mit ähnlichen Zeichen</string>
<string name="pref_off_replace_special_characters">Entferne Sonderzeichen aus der Nachricht</string>
<string name="pref_title_numeric_spelling_language">Zahlenbuchstabiersprache</string>
<string name="pref_description_numeric_spelling_language">Sprache in der Zahlen buchstabiert werden sollen.</string>
<string-array name="pref_list_numeric_spelling_language">
<item>Deutsch</item>
<item>Französisch</item>
<item>Englisch</item>
<item>Keine Ersetzung</item>
</string-array>
<string name="pref_header_appearance">Erscheinungsbild</string>
@ -19,6 +39,8 @@
<string name="pref_description_message_formatting">Soll die Nachricht in Blöcke unterteilt werden?</string>
<string-array name="pref_list_message_formatting">
<item>Keine Unterteilung</item>
<item>Viererblöcke</item>
<item>Fünferblöcke</item>
<item>Sechserblöcke</item>
</string-array>
</resources>

View file

@ -4,18 +4,18 @@
<string name="pref_header_simulation">Simulation</string>
<string name="pref_title_machine_type">Enigma Model</string>
<string name="pref_description_machine_type">Which model do you want to simulate?</string>
<string-array translatable="false" name="pref_list_machine_type">
<item>I (Heer, Luftwaffe)</item>
<item>M3 (Heer, Marine)</item>
<item>M4 (\"Shark\", Marine)</item>
<item>G31/A865 (Abwehr)</item>
<item>G312 (Abwehr)</item>
<item>G260 (Abwehr)</item>
<item>D (Kommerziell)</item>
<string-array name="pref_list_machine_type">
<item>I (Army, Airforce)</item>
<item>M3 (Army, Navy)</item>
<item>M4 (\"Shark\", Navy)</item>
<item>G31/A865 (Defense)</item>
<item>G312 (Defense)</item>
<item>G260 (Defense)</item>
<item>D (Commercial)</item>
<item>K</item>
<item>K (Swiss)</item>
<item>K (Swiss, Airforce)</item>
<item>R (\"Rocket\", Reichsbahn)</item>
<item>R (\"Rocket\", Railway)</item>
<item>T (\"Tirpitz\", Japan)</item>
</string-array>
<string-array translatable="false" name="pref_alias_machine_type">
@ -32,34 +32,44 @@
<item>R</item>
<item>T</item>
</string-array>
<string name="pref_title_simulate_anomaly">Simulate Anomaly</string>
<string name="pref_description_simulate_anomaly">The double step anomaly causes the middle rotor
to rotate twice, if it is one step before its turnover point.
</string>
<string name="pref_header_input_preparation">Input Preparation</string>
<string name="pref_title_special_characters">Special characters</string>
<string name="pref_on_replace_special_characters">Replace special characters with similar ones</string>
<string name="pref_off_replace_special_characters">Remove special characters from the message</string>
<string name="pref_title_numeric_spelling_language">Number spelling language</string>
<string name="pref_description_numeric_spelling_language">Language, in which numbers are spelled.</string>
<string-array name="pref_list_numeric_spelling_language">
<item>German</item>
<item>French</item>
<item>English</item>
<item>No replacing</item>
</string-array>
<string-array translatable="false" name="pref_alias_numeric_spelling_language">
<item>de</item>
<item>fr</item>
<item>en</item>
<item>no</item>
</string-array>
<string name="pref_header_appearance">Appearance</string>
<string name="pref_title_message_formatting">Message Formatting</string>
<string name="pref_description_message_formatting">Do you want to split the message up into blocks?</string>
<string-array name="pref_list_message_formatting">
<item>No blocks</item>
<item>No division</item>
<item>Blocks of 4</item>
<item>Blocks of 5</item>
<item>Blocks of 6</item>
</string-array>
<string-array translatable="false" name="pref_alias_message_formatting">
<item>no</item>
<item>4</item>
<item>5</item>
<item>6</item>
</string-array>
</resources>

View file

@ -9,11 +9,20 @@
android:entries="@array/pref_list_machine_type"
android:entryValues="@array/pref_alias_machine_type"
android:defaultValue="Enigma I"/>
<CheckBoxPreference
<SwitchPreference
android:key="prefAnomaly"
android:title="@string/pref_title_simulate_anomaly"
android:summary="@string/pref_description_simulate_anomaly"
android:defaultValue="true" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_header_input_preparation">
<SwitchPreference
android:title="@string/pref_title_special_characters"
android:key="prefReplaceSpecialCharacters"
android:summaryOn="@string/pref_on_replace_special_characters"
android:summaryOff="@string/pref_off_replace_special_characters"
android:defaultValue="true"/>
<ListPreference
android:key="prefNumericLanguage"
android:title="@string/pref_title_numeric_spelling_language"
@ -22,6 +31,7 @@
android:entryValues="@array/pref_alias_numeric_spelling_language"
android:defaultValue="de" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_header_appearance">
<ListPreference
android:key="prefMessageFormatting"