Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts

This commit is contained in:
VanitasVitae 2015-11-07 16:11:24 +01:00
parent dbfb1d5d79
commit c938b745bc
20 changed files with 118 additions and 109 deletions

View file

@ -10,20 +10,21 @@ import android.util.Log;
* Class that represents the settings activity.
* Use the singleton to get an instance of this class to get preferences
* Copyright (C) 2015 Paul Schaub
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* <p>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author vanitasvitae
*/
public class SettingsActivity extends PreferenceActivity
@ -66,7 +67,8 @@ public class SettingsActivity extends PreferenceActivity
{
if (prefs == null)
{
Log.e(MainActivity.APP_ID, "SharedPreferences not initialized via setSharedPreferences!");
Log.e(MainActivity.APP_ID,
"SharedPreferences not initialized via setSharedPreferences!");
return false;
}
if (res == null)
@ -94,7 +96,8 @@ public class SettingsActivity extends PreferenceActivity
public boolean prefNumericLanguageChanged()
{
if(this.previousPrefNumericLanguage == null || !this.previousPrefNumericLanguage.equals(getPrefNumericLanguage()))
if (this.previousPrefNumericLanguage == null || !this.previousPrefNumericLanguage.equals(
getPrefNumericLanguage()))
{
this.previousPrefNumericLanguage = this.getPrefNumericLanguage();
Log.d(MainActivity.APP_ID, PREF_NUMERIC_LANGUAGE+" changed!");
@ -144,7 +147,8 @@ public class SettingsActivity extends PreferenceActivity
public boolean prefMachineTypeChanged()
{
if(this.previousPrefMachineType == null || !this.previousPrefMachineType.equals(getPrefMachineType()))
if (this.previousPrefMachineType == null || !this.previousPrefMachineType.equals(
getPrefMachineType()))
{
this.previousPrefMachineType = this.getPrefMachineType();
Log.d(MainActivity.APP_ID, PREF_MACHINE_TYPE+" changed!");
@ -223,6 +227,7 @@ public class SettingsActivity extends PreferenceActivity
public static class SettingsSingleton extends SettingsActivity
{
private static SettingsActivity instance;
private SettingsSingleton()
{
super();

View file

@ -5,9 +5,9 @@ import java.util.ArrayList;
import java.util.Random;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Main component of the Enigma machine

View file

@ -5,9 +5,10 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Plugboard;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Concrete implementation of an enigma machine of name D

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name G31 (Abwehr)

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name G31 (Abwehr)

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name G31 (Abwehr)

View file

@ -5,9 +5,10 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Plugboard;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Concrete implementation of an enigma machine of name I

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name K

View file

@ -5,9 +5,10 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Plugboard;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Concrete implementation of an enigma machine of name D
@ -47,7 +48,7 @@ public class Enigma_KD extends Enigma {
@Override
protected void establishAvailableParts()
{
addAvailableEntryWheel(new EntryWheel.EntryWheel_QWERTZ()); //TODO: Really?
addAvailableEntryWheel(new EntryWheel.EntryWheel_QWERTZ());
addAvailableRotor(new Rotor.Rotor_KD_I(0, 0));
addAvailableRotor(new Rotor.Rotor_KD_II(0, 0));
@ -232,7 +233,7 @@ public class Enigma_KD extends Enigma {
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
s = addDigit(s, 12, 20); //Machine #12 TODO: Reorder?
s = addDigit(s, 12, 20); //Machine #12
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
return s;

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name K (Switzerland, Airforce)

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name K (Switzerland)

View file

@ -5,9 +5,10 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Plugboard;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Concrete implementation of an enigma machine model M3

View file

@ -6,9 +6,10 @@ import java.math.BigInteger;
import java.util.ArrayList;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Plugboard;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Concrete Implementation of the Enigma Machine name M4 of the german Kriegsmarine

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name R ("Rocket", Reichsbahn)

View file

@ -5,9 +5,9 @@ import android.util.Log;
import java.math.BigInteger;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.rotors.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.rotors.Reflector;
import de.vanitasvitae.enigmandroid.enigma.rotors.Rotor;
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
/**
* Implementation of the Enigma machine of name T Tirpitz

View file

@ -1,4 +1,4 @@
package de.vanitasvitae.enigmandroid.enigma.rotors;
package de.vanitasvitae.enigmandroid.enigma.parts;
/**
* Implementation of several EntryWheels

View file

@ -1,4 +1,4 @@
package de.vanitasvitae.enigmandroid.enigma;
package de.vanitasvitae.enigmandroid.enigma.parts;
import android.util.Log;
@ -7,6 +7,7 @@ import java.util.Arrays;
import java.util.Random;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.Enigma;
import de.vanitasvitae.enigmandroid.enigma.inputPreparer.InputPreparer;
/**

View file

@ -1,4 +1,4 @@
package de.vanitasvitae.enigmandroid.enigma.rotors;
package de.vanitasvitae.enigmandroid.enigma.parts;
import android.util.Log;
@ -7,7 +7,6 @@ import java.util.Arrays;
import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.enigma.Enigma;
import de.vanitasvitae.enigmandroid.enigma.Plugboard;
/**
* Reflector of the enigma machine.

View file

@ -1,4 +1,4 @@
package de.vanitasvitae.enigmandroid.enigma.rotors;
package de.vanitasvitae.enigmandroid.enigma.parts;
import android.util.Log;

View file

@ -189,4 +189,3 @@ public abstract class LayoutContainer
//TODO
}
}