Cleaned code

This commit is contained in:
VanitasVitae 2015-11-07 16:42:24 +01:00
parent c938b745bc
commit 1ee60d1e5e
41 changed files with 249 additions and 251 deletions

View file

@ -12,6 +12,8 @@ v1.0.0-not-yet-released<
*Added Whats-new-Dialog
*New Icon!
*Added Script to automatically generate icons
*Reformated code
*TODO: Add tips on long clicks at parts
*TODO?: Move KD right below K
*TODO?: Add intent filters to recognize and automatically handle shared/copied configuration Strings
TODO: These are Strings starting with "EnigmAndroid/"

View file

@ -71,7 +71,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@ -89,7 +89,7 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
</component>
</module>

View file

@ -19,5 +19,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-v4:23.1.0'
}

View file

@ -147,7 +147,7 @@ public class IntentIntegrator {
private String buttonYes;
private String buttonNo;
private List<String> targetApplications;
private final Map<String,Object> moreExtras = new HashMap<String,Object>(3);
private final Map<String,Object> moreExtras = new HashMap<>(3);
/**
* @param activity {@link Activity} invoking the integration

View file

@ -82,14 +82,8 @@ public final class IntentResult {
@Override
public String toString() {
StringBuilder dialogText = new StringBuilder(100);
dialogText.append("Format: ").append(formatName).append('\n');
dialogText.append("Contents: ").append(contents).append('\n');
int rawBytesLength = rawBytes == null ? 0 : rawBytes.length;
dialogText.append("Raw bytes: (").append(rawBytesLength).append(" bytes)\n");
dialogText.append("Orientation: ").append(orientation).append('\n');
dialogText.append("EC level: ").append(errorCorrectionLevel).append('\n');
return dialogText.toString();
return "Format: "+formatName+'\n'+"Contents: "+contents+'\n'+"Raw bytes: ("+rawBytesLength+" bytes)\n"+"Orientation: "+orientation+'\n'+"EC level: "+errorCorrectionLevel+'\n';
}
}

View file

@ -104,11 +104,6 @@ public class MainActivity extends Activity
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
public SecureRandom getSecureRandom()
{
return this.secureRandom;

View file

@ -42,8 +42,8 @@ public class SettingsActivity extends PreferenceActivity
private boolean previousPrefReplaceSpecialCharacters;
private String previousPrefSavedEnigmaState;
SharedPreferences prefs;
Resources res;
private SharedPreferences prefs;
private Resources res;
@Override
protected void onCreate(Bundle savedInstanceState)
@ -106,11 +106,14 @@ public class SettingsActivity extends PreferenceActivity
return false;
}
/**
* Return whether special characters will be replaced.
* If the SettingsActivity is not fully initialized return false and ignore preference.
* @return boolean
*/
public boolean getPrefReplaceSpecialCharacters()
{
if (isFullyInitilaized())
return prefs.getBoolean(PREF_REPLACE_SPECIAL_CHARACTERS, true);
else return false;
return isFullyInitilaized() && prefs.getBoolean(PREF_REPLACE_SPECIAL_CHARACTERS, true);
}
public void setPrefReplaceSpecialCharacters(boolean replace)

View file

@ -31,17 +31,17 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public abstract class Enigma
{
protected static String machineType;
static String machineType;
protected boolean doAnomaly = false; //Has the time come to handle an anomaly?
boolean doAnomaly = false; //Has the time come to handle an anomaly?
protected ArrayList<EntryWheel> availableEntryWheels;
protected ArrayList<Rotor> availableRotors;
protected ArrayList<Reflector> availableReflectors;
ArrayList<EntryWheel> availableEntryWheels;
ArrayList<Rotor> availableRotors;
ArrayList<Reflector> availableReflectors;
protected Random rand;
Random rand;
public Enigma()
Enigma()
{
establishAvailableParts();
initialize();
@ -57,19 +57,19 @@ public abstract class Enigma
* Also set the index of the Rotor.
* @param r Rotor
*/
protected void addAvailableRotor(Rotor r)
void addAvailableRotor(Rotor r)
{
if(availableRotors == null) availableRotors = new ArrayList<>();
availableRotors.add(availableRotors.size(), r.setIndex(availableRotors.size()));
}
protected void addAvailableEntryWheel(EntryWheel e)
void addAvailableEntryWheel(EntryWheel e)
{
if(availableEntryWheels == null) availableEntryWheels = new ArrayList<>();
availableEntryWheels.add(availableEntryWheels.size(), e.setIndex(availableEntryWheels.size()));
}
protected void addAvailableReflector(Reflector r)
void addAvailableReflector(Reflector r)
{
if(availableReflectors == null) availableReflectors = new ArrayList<>();
availableReflectors.add(availableReflectors.size(), r.setIndex(availableReflectors.size()));
@ -90,30 +90,30 @@ public abstract class Enigma
return availableReflectors;
}
public EntryWheel getEntryWheel(int index)
EntryWheel getEntryWheel(int index)
{
if(availableEntryWheels == null || availableEntryWheels.size() == 0) return null;
return availableEntryWheels.get(index % availableEntryWheels.size()).getInstance();
}
public Rotor getRotor(int index)
Rotor getRotor(int index)
{
if(availableRotors == null || availableRotors.size() == 0) return null;
return availableRotors.get(index % availableRotors.size()).getInstance();
}
public Rotor getRotor(int index, int rotation, int ringSetting)
Rotor getRotor(int index, int rotation, int ringSetting)
{
return getRotor(index).setRotation(rotation).setRingSetting(ringSetting);
}
public Reflector getReflector(int index)
Reflector getReflector(int index)
{
if(availableReflectors == null || availableReflectors.size() == 0) return null;
return availableReflectors.get(index%availableReflectors.size()).getInstance();
}
public Reflector getReflector(int index, int rotation, int ringSetting)
Reflector getReflector(int index, int rotation, int ringSetting)
{
return getReflector(index).setRotation(rotation).setRingSetting(ringSetting);
}
@ -121,7 +121,7 @@ public abstract class Enigma
/**
* Set the enigma to an initial state
*/
public abstract void initialize();
protected abstract void initialize();
/**
* Encrypt / Decrypt a given String w.
@ -177,7 +177,7 @@ public abstract class Enigma
* @param k input char
* @return substituted output char
*/
public abstract char encryptChar(char k);
protected abstract char encryptChar(char k);
/**
* Set the state of the enigma
@ -208,9 +208,9 @@ public abstract class Enigma
{
return getEncodedState(MainActivity.latest_protocol_version);
}
public abstract BigInteger getEncodedState(int protocol_version);
protected abstract BigInteger getEncodedState(int protocol_version);
public static String numToMachineType(int n)
private static String numToMachineType(int n)
{
int m = 13;
n = (m+(n+m)%m)%m; //Problem? Trolololo

View file

@ -32,11 +32,11 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_D extends Enigma {
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
protected Reflector reflector;
private EntryWheel entryWheel;
private Rotor rotor1;
private Rotor rotor2;
private Rotor rotor3;
private Reflector reflector;
public Enigma_D()
{

View file

@ -30,11 +30,11 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_G31 extends Enigma
{
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
protected Reflector reflector;
private EntryWheel entryWheel;
Rotor rotor1;
Rotor rotor2;
Rotor rotor3;
Reflector reflector;
public Enigma_G31()
{

View file

@ -31,13 +31,13 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_I extends Enigma
{
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
protected Reflector reflector;
EntryWheel entryWheel;
Rotor rotor1;
Rotor rotor2;
Rotor rotor3;
Reflector reflector;
protected Plugboard plugboard;
Plugboard plugboard;
public Enigma_I()
{

View file

@ -30,11 +30,11 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_K extends Enigma
{
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
protected Reflector reflector;
private EntryWheel entryWheel;
Rotor rotor1;
Rotor rotor2;
Rotor rotor3;
Reflector reflector;
public Enigma_K()
{

View file

@ -32,11 +32,11 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_KD extends Enigma {
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
protected Reflector reflector;
private EntryWheel entryWheel;
private Rotor rotor1;
private Rotor rotor2;
private Rotor rotor3;
private Reflector reflector;
public Enigma_KD()
{

View file

@ -51,19 +51,19 @@ public class Enigma_M4 extends Enigma
Log.d(MainActivity.APP_ID, "Created Enigma M4");
}
protected void addAvailableThinRotor(Rotor r)
private void addAvailableThinRotor(Rotor r)
{
if(availableThinRotors == null) availableThinRotors = new ArrayList<>();
availableThinRotors.add(availableThinRotors.size(), r.setIndex(availableThinRotors.size()));
}
public Rotor getThinRotor(int index)
private Rotor getThinRotor(int index)
{
if(availableThinRotors == null || availableThinRotors.size() == 0) return null;
return availableThinRotors.get(index % availableThinRotors.size()).getInstance();
}
public Rotor getThinRotor(int index, int rotation, int ringSettings)
private Rotor getThinRotor(int index, int rotation, int ringSettings)
{
Rotor r = getThinRotor(index);
if(r == null) return null;

View file

@ -30,12 +30,12 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_R extends Enigma
{
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
private EntryWheel entryWheel;
private Rotor rotor1;
private Rotor rotor2;
private Rotor rotor3;
protected Reflector reflector;
private Reflector reflector;
public Enigma_R()
{

View file

@ -30,11 +30,11 @@ import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
*/
public class Enigma_T extends Enigma
{
protected EntryWheel entryWheel;
protected Rotor rotor1;
protected Rotor rotor2;
protected Rotor rotor3;
protected Reflector reflector;
private EntryWheel entryWheel;
private Rotor rotor1;
private Rotor rotor2;
private Rotor rotor3;
private Reflector reflector;
public Enigma_T()
{

View file

@ -8,10 +8,10 @@ import android.widget.EditText;
*/
public abstract class EditTextAdapter
{
protected EditText editText;
protected String content;
EditText editText;
String content;
public EditTextAdapter(EditText editText)
EditTextAdapter(EditText editText)
{
this.editText = editText;
}
@ -79,7 +79,7 @@ public abstract class EditTextAdapter
public static class EditTextAdapterGap extends EditTextAdapter
{
protected int blockSize;
int blockSize;
public EditTextAdapterGap(EditText editText, int blockSize)
{
super(editText);

View file

@ -27,7 +27,7 @@ import de.vanitasvitae.enigmandroid.SettingsActivity;
* @author vanitasvitae
*/
public abstract class InputPreparer {
protected InputPreparer child;
InputPreparer child;
public String prepareString(String in) {
if (child != null)

View file

@ -20,14 +20,14 @@ package de.vanitasvitae.enigmandroid.enigma.parts;
*/
public class EntryWheel
{
protected int type;
protected String name;
protected int index;
protected String summary;
protected Integer[] connections;
protected Integer[] reversedConnections;
private final int type;
private final String name;
private int index;
private final String summary;
private final Integer[] connections;
private final Integer[] reversedConnections;
public EntryWheel(int type, String name, String summary, Integer[] connections, Integer[] reversedConnections)
EntryWheel(int type, String name, String summary, Integer[] connections, Integer[] reversedConnections)
{
this.type = type;
this.name = name;
@ -56,7 +56,7 @@ public class EntryWheel
return this.connections[normalize(input)];
}
public int normalize(int input)
private int normalize(int input)
{
return (input+this.connections.length)%this.connections.length;
}
@ -83,7 +83,7 @@ public class EntryWheel
return this.reversedConnections[normalize(input)];
}
public EntryWheel createEntryWheel(int type)
private EntryWheel createEntryWheel(int type)
{
switch(type)
{

View file

@ -49,6 +49,7 @@ public class Plugboard
this.plugs = conf;
}
@SuppressWarnings("UnusedReturnValue")
public BigInteger setConfiguration(BigInteger b)
{
String s = "";
@ -175,7 +176,7 @@ public class Plugboard
* @param c array
* @return String representation
*/
public static String configurationToString(int[] c)
private static String configurationToString(int[] c)
{
String out = "";
for(int i=0; i<c.length; i++) // c.length = 26 (mostly)

View file

@ -31,13 +31,13 @@ import de.vanitasvitae.enigmandroid.enigma.Enigma;
*/
public class Reflector
{
protected int type;
protected String name;
protected int index;
protected String summary;
protected int[] connections;
protected int rotation;
protected int ringSetting;
private final int type;
private final String name;
private int index;
private final String summary;
private int[] connections;
private int rotation;
private int ringSetting;
/**
* This constructor is not accessible from outside this class file.
@ -46,7 +46,7 @@ public class Reflector
* @param type name indicator of the reflector
* @param connections wiring of the reflector as Integer array
*/
protected Reflector(int type, String name, String summary, int[] connections)
Reflector(int type, String name, String summary, int[] connections)
{
this.type = type;
this.name = name;
@ -106,6 +106,7 @@ public class Reflector
return this;
}
@SuppressWarnings("UnusedReturnValue")
public BigInteger setConfiguration(BigInteger b)
{
String s = "";
@ -143,7 +144,7 @@ public class Reflector
* default -> ReflectorB
* @return Reflector
*/
public static Reflector createReflector(int type)
private static Reflector createReflector(int type)
{
switch (type)
{

View file

@ -31,31 +31,31 @@ import de.vanitasvitae.enigmandroid.MainActivity;
public abstract class Rotor
{
/** Number of the rotor (used internally to create the Rotor via createRotor() ) */
protected int type;
private final int type;
/** Identifier of the Rotor */
protected String name;
private final String name;
/** Index of the Rotor in the parent machine's selection Spinner */
protected int index;
private int index;
/** Summary of the connections (internal wiring) */
protected String summary;
private final String summary;
/** Wiring of the rotor when the signal passes the first time */
protected Integer[] connections;
private final Integer[] connections;
/** Wiring of the rotor when the signal passes the second time (inverse of the first time) */
protected Integer[] reversedConnections;
private final Integer[] reversedConnections;
/** When the Rotor is at this Position and jumps one over, it also turns the next */
protected Integer[] turnOverNotches;
private final Integer[] turnOverNotches;
/** Offset of the labeled ring of the rotor */
protected int ringSetting;
private int ringSetting;
/** Rotation of the rotor */
protected int rotation;
private int rotation;
/**
* This constructor is not accessible from outside this class file.
@ -72,8 +72,8 @@ public abstract class Rotor
* @param ringSetting setting of the ring that holds the letters
* @param rotation rotation of the rotor
*/
protected Rotor(int type, String name, String summary, Integer[] connections, Integer[] reversedConnections,
Integer[] turnOverNotches, int ringSetting, int rotation)
Rotor(int type, String name, String summary, Integer[] connections, Integer[] reversedConnections,
Integer[] turnOverNotches, int ringSetting, int rotation)
{
this.type = type;
this.name = name;
@ -289,7 +289,7 @@ public abstract class Rotor
* Returns the positions of the turnover notches in a array
* @return turnOverNotches
*/
public Integer[] getTurnOverNotches()
private Integer[] getTurnOverNotches()
{
return this.turnOverNotches;
}
@ -309,7 +309,7 @@ public abstract class Rotor
* of the rotor
* @return size
*/
public int getRotorSize()
private int getRotorSize()
{
return this.connections.length;
}

View file

@ -1,7 +1,5 @@
package de.vanitasvitae.enigmandroid.layout;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
@ -36,19 +34,19 @@ import de.vanitasvitae.enigmandroid.enigma.inputPreparer.InputPreparer;
*/
public abstract class LayoutContainer
{
protected EditText inputView;
protected EditText outputView;
final EditText inputView;
private final EditText outputView;
protected EditTextAdapter input;
protected EditTextAdapter output;
EditTextAdapter input;
EditTextAdapter output;
protected InputPreparer inputPreparer;
protected MainActivity main;
InputPreparer inputPreparer;
final MainActivity main;
public abstract Enigma getEnigma();
protected abstract void assembleLayout();
public abstract void resetLayout();
public abstract void setLayoutState(EnigmaStateBundle state);
protected abstract void setLayoutState(EnigmaStateBundle state);
public abstract void syncStateFromLayoutToEnigma();
public void syncStateFromEnigmaToLayout()
{
@ -56,7 +54,7 @@ public abstract class LayoutContainer
}
public abstract void showRingSettingsDialog();
public LayoutContainer()
LayoutContainer()
{
main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
setEnigmaLayout();
@ -99,7 +97,7 @@ public abstract class LayoutContainer
return createLayoutContainer(SettingsActivity.SettingsSingleton.getInstance().getPrefMachineType());
}
public static LayoutContainer createLayoutContainer(String enigmaType)
private static LayoutContainer createLayoutContainer(String enigmaType)
{
switch (enigmaType) {
case "I":
@ -138,7 +136,7 @@ public abstract class LayoutContainer
* @param view Spinner
* @param resourceID ID of the referenced array (eg. R.array.rotor_1_8)
*/
protected void prepareSpinnerAdapter(Spinner view, int resourceID) {
void prepareSpinnerAdapter(Spinner view, int resourceID) {
MainActivity main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(main, resourceID,
@ -152,7 +150,7 @@ public abstract class LayoutContainer
* @param view Spinner
* @param array Character array
*/
protected void prepareSpinnerAdapter(Spinner view, Character[] array)
void prepareSpinnerAdapter(Spinner view, Character[] array)
{
MainActivity main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
ArrayAdapter<Character> adapter = new ArrayAdapter<>(main.getApplicationContext(),

View file

@ -33,10 +33,10 @@ public class LayoutContainer_D extends LayoutContainer
{
private Enigma_D enigma;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
protected Spinner reflectorPositionView;
private Spinner rotor1PositionView;
private Spinner rotor2PositionView;
private Spinner rotor3PositionView;
private Spinner reflectorPositionView;
public LayoutContainer_D()
{

View file

@ -1,6 +1,5 @@
package de.vanitasvitae.enigmandroid.layout;
import de.vanitasvitae.enigmandroid.R;
import de.vanitasvitae.enigmandroid.enigma.Enigma_G260;
/**

View file

@ -30,16 +30,16 @@ import de.vanitasvitae.enigmandroid.enigma.Enigma_G31;
*/
public class LayoutContainer_G31 extends LayoutContainer
{
protected Enigma enigma;
Enigma enigma;
protected Spinner rotor1View;
protected Spinner rotor2View;
protected Spinner rotor3View;
private Spinner rotor1View;
private Spinner rotor2View;
private Spinner rotor3View;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
protected Spinner reflectorPositionView;
private Spinner rotor1PositionView;
private Spinner rotor2PositionView;
private Spinner rotor3PositionView;
private Spinner reflectorPositionView;
public LayoutContainer_G31()
{

View file

@ -33,13 +33,13 @@ public class LayoutContainer_I extends LayoutContainer
{
private Enigma_I enigma;
protected Spinner rotor1View;
protected Spinner rotor2View;
protected Spinner rotor3View;
protected Spinner reflectorView;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
Spinner rotor1View;
Spinner rotor2View;
Spinner rotor3View;
Spinner reflectorView;
Spinner rotor1PositionView;
Spinner rotor2PositionView;
Spinner rotor3PositionView;
public LayoutContainer_I()
{

View file

@ -30,16 +30,16 @@ import de.vanitasvitae.enigmandroid.enigma.Enigma_K;
*/
public class LayoutContainer_K extends LayoutContainer
{
protected Enigma enigma;
Enigma enigma;
protected Spinner rotor1View;
protected Spinner rotor2View;
protected Spinner rotor3View;
private Spinner rotor1View;
private Spinner rotor2View;
private Spinner rotor3View;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
protected Spinner reflectorPositionView;
private Spinner rotor1PositionView;
private Spinner rotor2PositionView;
private Spinner rotor3PositionView;
private Spinner reflectorPositionView;
public LayoutContainer_K()
{

View file

@ -32,16 +32,16 @@ import de.vanitasvitae.enigmandroid.enigma.Enigma_KD;
*/
public class LayoutContainer_KD extends LayoutContainer
{
protected Enigma enigma;
private Enigma enigma;
protected Spinner rotor1View;
protected Spinner rotor2View;
protected Spinner rotor3View;
private Spinner rotor1View;
private Spinner rotor2View;
private Spinner rotor3View;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
protected Spinner reflectorPositionView;
private Spinner rotor1PositionView;
private Spinner rotor2PositionView;
private Spinner rotor3PositionView;
private Spinner reflectorPositionView;
public LayoutContainer_KD()
{

View file

@ -1,10 +1,5 @@
package de.vanitasvitae.enigmandroid.layout;
import android.widget.Spinner;
import de.vanitasvitae.enigmandroid.R;
import de.vanitasvitae.enigmandroid.enigma.Enigma;
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
import de.vanitasvitae.enigmandroid.enigma.Enigma_K_Swiss_Standard;
/**

View file

@ -1,10 +1,5 @@
package de.vanitasvitae.enigmandroid.layout;
import android.widget.Spinner;
import de.vanitasvitae.enigmandroid.R;
import de.vanitasvitae.enigmandroid.enigma.Enigma;
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
import de.vanitasvitae.enigmandroid.enigma.Enigma_K_Swiss_Airforce;
/**

View file

@ -32,14 +32,14 @@ public class LayoutContainer_R extends LayoutContainer
{
private Enigma_R enigma;
protected Spinner rotor1View;
protected Spinner rotor2View;
protected Spinner rotor3View;
private Spinner rotor1View;
private Spinner rotor2View;
private Spinner rotor3View;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
protected Spinner reflectorPositionView;
private Spinner rotor1PositionView;
private Spinner rotor2PositionView;
private Spinner rotor3PositionView;
private Spinner reflectorPositionView;
public LayoutContainer_R()
{

View file

@ -32,14 +32,14 @@ public class LayoutContainer_T extends LayoutContainer
{
private Enigma_T enigma;
protected Spinner rotor1View;
protected Spinner rotor2View;
protected Spinner rotor3View;
private Spinner rotor1View;
private Spinner rotor2View;
private Spinner rotor3View;
protected Spinner rotor1PositionView;
protected Spinner rotor2PositionView;
protected Spinner rotor3PositionView;
protected Spinner reflectorPositionView;
private Spinner rotor1PositionView;
private Spinner rotor2PositionView;
private Spinner rotor3PositionView;
private Spinner reflectorPositionView;
public LayoutContainer_T()
{

View file

@ -37,9 +37,9 @@ import de.vanitasvitae.enigmandroid.R;
*/
public class PassphraseDialogBuilder
{
private MainActivity main;
private View passphraseDialogView;
private EditText passphrase;
private final MainActivity main;
private final View passphraseDialogView;
private final EditText passphrase;
private Button positive;
public PassphraseDialogBuilder()
{

View file

@ -37,19 +37,19 @@ import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @author vanitasvitae
*/
public class PluggableDialogBuilder
class PluggableDialogBuilder
{
protected ArrayList<ButtonWrapper> buttons;
protected View dialogView;
protected MainActivity main;
protected EnigmaStateBundle state;
private ArrayList<ButtonWrapper> buttons;
private View dialogView;
private final MainActivity main;
private final EnigmaStateBundle state;
protected boolean allowIncompleteConnections;
protected Button positive;
private boolean allowIncompleteConnections;
private Button positive;
protected HashSet<Integer> colors;
private HashSet<Integer> colors;
protected int previouslyPressedButton = -1;
private int previouslyPressedButton = -1;
/**
* Constructor that prepares layout and buttons.
@ -148,7 +148,7 @@ public class PluggableDialogBuilder
/**
* Initialize array of buttons, initialize background-color hashset.
*/
public void initializeLayout()
private void initializeLayout()
{
buttons = new ArrayList<>();
dialogView = View.inflate(main, R.layout.dialog_plugs, null);
@ -199,7 +199,7 @@ public class PluggableDialogBuilder
/**
* Set listeners for all buttons
*/
public void setButtonListeners()
private void setButtonListeners()
{
for(int i=0; i<26; i++)
{
@ -219,7 +219,7 @@ public class PluggableDialogBuilder
* return false otherwise
* @return boolean
*/
protected boolean allConnectionsDone()
private boolean allConnectionsDone()
{
for(int i=0; i<buttons.size(); i++)
{
@ -232,7 +232,7 @@ public class PluggableDialogBuilder
/**
* restore the connections according to the plugboard
*/
protected void restoreConfigurationPlugboard()
private void restoreConfigurationPlugboard()
{
restoreConfiguration(state.getConfigurationPlugboard());
}
@ -240,7 +240,7 @@ public class PluggableDialogBuilder
/**
* restore the connections according to the reflector
*/
protected void restoreConfigurationReflector()
private void restoreConfigurationReflector()
{
restoreConfiguration(state.getConfigurationReflector());
}
@ -249,7 +249,7 @@ public class PluggableDialogBuilder
* Connect all the buttons according to c.
* @param c array of connections
*/
protected void restoreConfiguration(int[] c)
private void restoreConfiguration(int[] c)
{
for(int i=0; i<26; i++)
{
@ -265,7 +265,7 @@ public class PluggableDialogBuilder
* @param button1 first and
* @param button2 second button
*/
public void setPlug(int button1, int button2)
private void setPlug(int button1, int button2)
{
if(button1 == button2)
{
@ -303,7 +303,7 @@ public class PluggableDialogBuilder
* Update state of positive button. Check, if all connections are done and if so, enable positive
* button. Otherwise disable it.
*/
protected void updatePositiveButton()
private void updatePositiveButton()
{
if(!allowIncompleteConnections && positive != null)
{
@ -331,7 +331,7 @@ public class PluggableDialogBuilder
* Handle button pressed events.
* @param button button that got pressed
*/
public void buttonPressed(int button)
private void buttonPressed(int button)
{
if(previouslyPressedButton != -1)
{

View file

@ -37,7 +37,7 @@ public abstract class RingSettingsDialogBuilder
protected abstract void showDialog(EnigmaStateBundle stateBundle, ArrayAdapter[] adapters, int[] rIDs, Actions actions);
public abstract void createRingSettingsDialog(EnigmaStateBundle stateBundle);
public static ArrayAdapter createAdapter(Integer[] array)
private static ArrayAdapter createAdapter(Integer[] array)
{
ArrayAdapter adapter = new ArrayAdapter<>(
MainActivity.ActivitySingleton.getInstance().getActivity(),
@ -50,7 +50,7 @@ public abstract class RingSettingsDialogBuilder
* Creates a ArrayAdapter working over an array of numbers 1 to 26.
* @return ArrayAdapter
*/
public static ArrayAdapter createAdapter1_26()
private static ArrayAdapter createAdapter1_26()
{
Integer[] ringArray = new Integer[26];
for(int i=1; i<=26; i++) {ringArray[i-1] = i;}
@ -365,7 +365,7 @@ public abstract class RingSettingsDialogBuilder
*/
public static abstract class Actions
{
protected EnigmaStateBundle stateBundle;
final EnigmaStateBundle stateBundle;
public Actions(EnigmaStateBundle bundle)
{
this.stateBundle = bundle;

View file

@ -1,46 +1,55 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity" >
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity"
tools:ignore="UnusedAttribute">
<!-- RESET -->
<item android:id="@+id/action_reset"
<item
android:id="@+id/action_reset"
android:orderInCategory="96"
android:showAsAction="ifRoom"
android:title="@string/action_reset" />
android:title="@string/action_reset"/>
<!-- SEND -->
<item android:id="@+id/action_send_message"
<item
android:id="@+id/action_send_message"
android:icon="@drawable/ic_send_white_48dp"
android:orderInCategory="97"
android:showAsAction="always"
android:title="@string/action_send"
android:icon="@drawable/ic_send_white_48dp"/>
android:title="@string/action_send"/>
<!-- RINGSETTING -->
<item android:id="@+id/action_choose_ringsetting"
android:title="@string/action_choose_ring_settings"
<item
android:id="@+id/action_choose_ringsetting"
android:orderInCategory="98"
android:showAsAction="ifRoom" />
<!-- SHARE CONFIGURATION -->
<item android:id="@+id/action_share_configuration"
android:title="@string/action_share_configuration"
android:showAsAction="ifRoom"
android:orderInCategory="99" />
android:title="@string/action_choose_ring_settings"/>
<!-- SHARE CONFIGURATION -->
<item
android:id="@+id/action_share_configuration"
android:orderInCategory="99"
android:showAsAction="ifRoom"
android:title="@string/action_share_configuration"/>
<!-- RESTORE CONFIGURATION FROM QR OR ENTER SEED-->
<item android:id="@+id/action_restore_configuration"
android:title="@string/action_restore_configuration"
android:showAsAction="ifRoom"
android:orderInCategory="100" />
<item
android:id="@+id/action_restore_configuration"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/action_restore_configuration"/>
<!-- RANDOM -->
<item android:id="@+id/action_random_configuration"
<item
android:id="@+id/action_random_configuration"
android:orderInCategory="101"
android:showAsAction="ifRoom"
android:title="@string/action_random" />
android:title="@string/action_random"/>
<!-- SETTINGS -->
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
<item
android:id="@+id/action_settings"
android:orderInCategory="102"
android:showAsAction="ifRoom" />
android:showAsAction="ifRoom"
android:title="@string/action_settings"/>
<!-- ABOUT -->
<item android:id="@+id/action_about"
android:title="@string/title_action_about"
<item
android:id="@+id/action_about"
android:orderInCategory="103"
android:showAsAction="ifRoom" />
android:showAsAction="ifRoom"
android:title="@string/title_action_about"/>
</menu>

View file

@ -51,6 +51,4 @@
<string name="message_random">Enigma auf zufällige Konfiguration gesetzt.</string>
<string name="message_clipboard">In Zwischenablage kopiert</string>
<string name="dialog_whats_new_title">Was ist neu?</string>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="dialog_whats_new_title">Was ist neu?</string>
</resources>

View file

@ -48,15 +48,6 @@
<string name="message_random">Enigma set to random configuration.</string>
<string name="message_clipboard">Copied to clipboard</string>
<string name="dialog_whats_new_title">What\'s new?</string>
<string name="dialog_whats_new_header" translatable="false">%1$s:</string> <!--Version-->
<string name="dialog_whats_new_content" translatable="false">
- This splash screen!
\n- Protocol-versioning to ensure compatibility to upcoming releases/new functions\n
Unfortunately we had to break backwards compatibility to older versions :/
\n- Enigma KD\n
</string>
<string translatable="false" name="button_plug_title">%1$s:%2$s</string>
<string-array translatable="false" name="rotors_1_3">

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="dialog_whats_new_title">What\'s new?</string>
<string translatable="false" name="dialog_whats_new_header">%1$s:</string> <!--Version-->
<string translatable="false" name="dialog_whats_new_content">
- This splash screen!
\n- Protocol-versioning to ensure compatibility to upcoming releases/new functions.\n
Unfortunately we had to break backwards compatibility to older versions :/
\n- Enigma KD!
\n- New Icon!
</string>
</resources>