mirror of
https://github.com/vanitasvitae/EnigmAndroid.git
synced 2024-09-27 18:29:33 +02:00
Added Enigma KD, Added protocol version to ensure compatibility with upcoming releases, Added options to share configuration as string, organized sharing/receiving of configuration, moved preference-management to SettingsActivity, Added whats-New-Dialog that informs user about latest changes
This commit is contained in:
parent
ba4a0f590f
commit
1f3c3d33a7
|
@ -1,4 +1,22 @@
|
||||||
CHANGELOG ENIGMANDROID
|
CHANGELOG ENIGMANDROID
|
||||||
|
v1.0.0-not-yet-released<
|
||||||
|
*Added Enigma KD
|
||||||
|
*Added "protocol version" to QR-Code-shared configuration strings.
|
||||||
|
This breaks backwards compatibility to older versions, but I added it to enable backwards-
|
||||||
|
compatibility in upcoming releases.
|
||||||
|
*Configurations can now be shared to EnigmAndroid as text
|
||||||
|
*Moved preference management to SettingsActivity
|
||||||
|
*Added dialog to choose whether to share configuration via text or via QR-code
|
||||||
|
*Same for receiving
|
||||||
|
*Added TextBox to configuration-share-dialog that lets the user see and copy the configuration string.
|
||||||
|
*Added Whats-new-Dialog
|
||||||
|
*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/"
|
||||||
|
*TODO: Write tests to ensure correct functionality (Pull Requests welcome)
|
||||||
|
*TODO: Add multi-Enigma (select any rotor/reflector etc. Probably wont happen too soon)
|
||||||
|
|
||||||
|
|
||||||
v0.1.9-09.10.2015<
|
v0.1.9-09.10.2015<
|
||||||
*Added option to share/receive configurations via QR-Code (ZXing Barcode Scanner)
|
*Added option to share/receive configurations via QR-Code (ZXing Barcode Scanner)
|
||||||
*Prevent user from setting incomplete reflector wiring
|
*Prevent user from setting incomplete reflector wiring
|
||||||
|
@ -7,9 +25,6 @@ v0.1.9-09.10.2015<
|
||||||
*Completely verified correct functionality of Enigma T
|
*Completely verified correct functionality of Enigma T
|
||||||
*Added number spelling in spanish, italian
|
*Added number spelling in spanish, italian
|
||||||
*Added backwards compatibility to API level 10 (Gingerbread 2.3.3)
|
*Added backwards compatibility to API level 10 (Gingerbread 2.3.3)
|
||||||
*TODO: Write tests to ensure correct functionality
|
|
||||||
*TODO: Migrate preferences to SettingsActivity
|
|
||||||
*TODO: Add multi-Enigma (select any rotor/reflector etc. Probably wont happen too soon)
|
|
||||||
|
|
||||||
v0.1.8-27.09.2015<
|
v0.1.8-27.09.2015<
|
||||||
*Added Enigma G31
|
*Added Enigma G31
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
|
@ -1,336 +0,0 @@
|
||||||
package de.vanitasvitae.enigmandroid;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
|
||||||
import com.google.zxing.integration.android.IntentResult;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
|
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
|
||||||
import de.vanitasvitae.enigmandroid.layout.LayoutContainer;
|
|
||||||
import de.vanitasvitae.enigmandroid.layout.PassphraseDialogBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reimplementation of MainActivity
|
|
||||||
* Created by vanitas on 11.10.15.
|
|
||||||
*/
|
|
||||||
public class Main2 extends Activity
|
|
||||||
{
|
|
||||||
private static final int RESULT_SETTINGS = 1;
|
|
||||||
private static final String URI_CHANGELOG =
|
|
||||||
"https://github.com/vanitasvitae/EnigmAndroid/blob/master/CHANGELOG.txt";
|
|
||||||
public static final String APP_ID = "EnigmAndroid";
|
|
||||||
|
|
||||||
private LayoutContainer layoutContainer;
|
|
||||||
private SecureRandom numberGenerator;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState)
|
|
||||||
{
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
this.numberGenerator = new SecureRandom();
|
|
||||||
MainActivity.ActivitySingleton singleton = MainActivity.ActivitySingleton.getInstance();
|
|
||||||
singleton.setActivity(this);
|
|
||||||
numberGenerator = new SecureRandom();
|
|
||||||
restoreEnigmaModelAndState();
|
|
||||||
|
|
||||||
//Handle shared text
|
|
||||||
Intent intent = getIntent();
|
|
||||||
String action = intent.getAction();
|
|
||||||
String type = intent.getType();
|
|
||||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
|
||||||
if ("text/plain".equals(type))
|
|
||||||
{
|
|
||||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
|
||||||
if (sharedText != null)
|
|
||||||
{
|
|
||||||
layoutContainer.getInput().setRawText(sharedText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu)
|
|
||||||
{
|
|
||||||
this.getMenuInflater().inflate(R.menu.main, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* Handle Options menu clicks
|
|
||||||
*/
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item)
|
|
||||||
{
|
|
||||||
int id = item.getItemId();
|
|
||||||
if (id == R.id.action_reset)
|
|
||||||
{
|
|
||||||
layoutContainer.resetLayout();
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.message_reset,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_send)
|
|
||||||
{
|
|
||||||
actionShareMessage();
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_choose_ringsetting)
|
|
||||||
{
|
|
||||||
layoutContainer.showRingSettingsDialog();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(id == R.id.action_enter_seed)
|
|
||||||
{
|
|
||||||
new PassphraseDialogBuilder().showDialog();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_receive_scan)
|
|
||||||
{
|
|
||||||
IntentIntegrator integrator = new IntentIntegrator(this);
|
|
||||||
integrator.initiateScan();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(id == R.id.action_share_scan)
|
|
||||||
{
|
|
||||||
actionShareConfiguration();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_random_configuration)
|
|
||||||
{
|
|
||||||
actionRandomConfiguration();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_settings)
|
|
||||||
{
|
|
||||||
Intent i = new Intent(this, SettingsActivity.class);
|
|
||||||
startActivityForResult(i, RESULT_SETTINGS);
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_about)
|
|
||||||
{
|
|
||||||
actionAbout();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle preference changes
|
|
||||||
* @param requestCode requestCode
|
|
||||||
* @param resultCode resultCode (RESULT_SETTINGS is defined at the top)
|
|
||||||
* @param data data (not important here)
|
|
||||||
*/
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
switch (requestCode) {
|
|
||||||
//Settings
|
|
||||||
case RESULT_SETTINGS:
|
|
||||||
{
|
|
||||||
restoreEnigmaModelAndState();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//QR_Scanner
|
|
||||||
case IntentIntegrator.REQUEST_CODE:
|
|
||||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
|
|
||||||
if (scanResult != null) {
|
|
||||||
String content = scanResult.getContents();
|
|
||||||
if(content == null) Log.e(APP_ID, "Error! Received nothing from QR-Code!");
|
|
||||||
else {
|
|
||||||
Log.d(APP_ID, "Received " + content + " from QR-Code!");
|
|
||||||
restoreEnigmaModelAndState(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause()
|
|
||||||
{
|
|
||||||
super.onPause();
|
|
||||||
//TODO: Save state
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean restoreEnigmaModelAndState()
|
|
||||||
{
|
|
||||||
String savedState = SettingsActivity.SettingsSingleton.getInstance().getPrefSavedEnigmaState();
|
|
||||||
if (savedState.equals("-1") || SettingsActivity.SettingsSingleton.getInstance().prefSavedEnigmaStateChanged())
|
|
||||||
{
|
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer(
|
|
||||||
SettingsActivity.SettingsSingleton.getInstance().getPrefMachineType());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//No changes
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean restoreEnigmaModelAndState(BigInteger savedState)
|
|
||||||
{
|
|
||||||
SettingsActivity.SettingsSingleton.getInstance().setPrefMachineType(
|
|
||||||
Enigma.chooseEnigmaFromSave(savedState));
|
|
||||||
String savedInput = "";
|
|
||||||
if(layoutContainer != null) savedInput = layoutContainer.getInput().getText();
|
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer(
|
|
||||||
SettingsActivity.SettingsSingleton.getInstance().getPrefMachineType());
|
|
||||||
layoutContainer.getEnigma().restoreState(Enigma.removeDigit(savedState, 20));
|
|
||||||
layoutContainer.syncStateFromEnigmaToLayout();
|
|
||||||
layoutContainer.getInput().setText(savedInput);
|
|
||||||
layoutContainer.getOutput().setText("");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restore Enigma state from String. String has to start with "EnigmAndroid/"
|
|
||||||
* @param savedState String
|
|
||||||
* @return success
|
|
||||||
*/
|
|
||||||
private boolean restoreEnigmaModelAndState(String savedState)
|
|
||||||
{
|
|
||||||
if(!savedState.startsWith(APP_ID+"/"))
|
|
||||||
{
|
|
||||||
Toast.makeText(this, R.string.error_no_valid_qr, Toast.LENGTH_LONG).show();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
savedState = savedState.substring((APP_ID+"/").length());
|
|
||||||
BigInteger s = new BigInteger(savedState, 16);
|
|
||||||
return restoreEnigmaModelAndState(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set EnigmAndroid into a state calculated from the seed.
|
|
||||||
* @param seed seed
|
|
||||||
*/
|
|
||||||
public void createStateFromSeed(String seed)
|
|
||||||
{
|
|
||||||
String savedInput = "";
|
|
||||||
if(layoutContainer != null) savedInput = layoutContainer.getInput().getText();
|
|
||||||
SettingsActivity.SettingsSingleton.getInstance().setPrefMachineType(
|
|
||||||
Enigma.chooseEnigmaFromSeed(seed));
|
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer();
|
|
||||||
layoutContainer.getEnigma().setStateFromSeed(seed);
|
|
||||||
layoutContainer.syncStateFromEnigmaToLayout();
|
|
||||||
layoutContainer.getInput().setText(savedInput);
|
|
||||||
layoutContainer.getOutput().setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the chosen Configuration to the enigma, get the input string from the input text box and
|
|
||||||
* prepare it, set the input to the prepared text, encrypt the prepared input and set the
|
|
||||||
* encrypted string to the output text box and update the spinners to their new positions.
|
|
||||||
* @param v View
|
|
||||||
*/
|
|
||||||
public void doCrypto(View v)
|
|
||||||
{
|
|
||||||
layoutContainer.doCrypto();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If there is any message inside the right text field, share it via intent.
|
|
||||||
* Otherwise show a Toast.
|
|
||||||
*/
|
|
||||||
private void actionShareMessage()
|
|
||||||
{
|
|
||||||
if(layoutContainer.getOutput().getText().length() == 0)
|
|
||||||
{
|
|
||||||
Toast.makeText(this, R.string.error_no_text_to_send, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Intent sendIntent = new Intent();
|
|
||||||
sendIntent.setAction(Intent.ACTION_SEND);
|
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, layoutContainer.getOutput().getModifiedText());
|
|
||||||
sendIntent.setType("text/plain");
|
|
||||||
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Share current enigma configuration via QR-Code
|
|
||||||
*/
|
|
||||||
private void actionShareConfiguration()
|
|
||||||
{
|
|
||||||
IntentIntegrator QRIntegrator = new IntentIntegrator(this);
|
|
||||||
layoutContainer.syncStateFromLayoutToEnigma();
|
|
||||||
Log.d(APP_ID,
|
|
||||||
"Sharing configuration to QR: "+layoutContainer.getEnigma().stateToString());
|
|
||||||
QRIntegrator.shareText(APP_ID+"/"+layoutContainer.getEnigma().stateToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the enigma to a random state.
|
|
||||||
* Do not change enigma model.
|
|
||||||
*/
|
|
||||||
private void actionRandomConfiguration()
|
|
||||||
{
|
|
||||||
layoutContainer.getEnigma().randomState();
|
|
||||||
layoutContainer.syncStateFromEnigmaToLayout();
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.message_random,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
layoutContainer.getOutput().setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the credits dialog of the app
|
|
||||||
*/
|
|
||||||
private void actionAbout()
|
|
||||||
{
|
|
||||||
final View aboutView = View.inflate(this, R.layout.dialog_about, null);
|
|
||||||
//Get and set Version code
|
|
||||||
PackageInfo pInfo = null;
|
|
||||||
try{ pInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);}
|
|
||||||
catch (PackageManager.NameNotFoundException e){ e.printStackTrace();}
|
|
||||||
assert pInfo != null;
|
|
||||||
String version = pInfo.versionName+ " ("+pInfo.versionCode+")";
|
|
||||||
TextView versionText = (TextView) aboutView.findViewById(R.id.about_version_section);
|
|
||||||
versionText.setText(version);
|
|
||||||
|
|
||||||
//Build and show dialog
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setTitle(R.string.title_about_dialog);
|
|
||||||
builder.setView(aboutView)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setPositiveButton(R.string.dialog_positive, new DialogInterface.OnClickListener()
|
|
||||||
{
|
|
||||||
public void onClick(DialogInterface dialog, int id)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.button_show_changelog, new DialogInterface.OnClickListener()
|
|
||||||
{
|
|
||||||
public void onClick(DialogInterface dialog, int id)
|
|
||||||
{
|
|
||||||
dialog.cancel();
|
|
||||||
Uri webPage = Uri.parse(URI_CHANGELOG);
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, webPage);
|
|
||||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SecureRandom getNumberGenerator()
|
|
||||||
{
|
|
||||||
return this.numberGenerator;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,10 @@
|
||||||
package de.vanitasvitae.enigmandroid;
|
package de.vanitasvitae.enigmandroid;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.ClipData;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -11,10 +14,15 @@ import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -55,11 +63,10 @@ public class MainActivity extends Activity
|
||||||
private static final String URI_CHANGELOG =
|
private static final String URI_CHANGELOG =
|
||||||
"https://github.com/vanitasvitae/EnigmAndroid/blob/master/CHANGELOG.txt";
|
"https://github.com/vanitasvitae/EnigmAndroid/blob/master/CHANGELOG.txt";
|
||||||
public static final String APP_ID = "EnigmAndroid";
|
public static final String APP_ID = "EnigmAndroid";
|
||||||
|
public static final int latest_protocol_version = 1;
|
||||||
|
public static final int max_protocol_version = 256;
|
||||||
|
|
||||||
private LayoutContainer layoutContainer;
|
private LayoutContainer layoutContainer;
|
||||||
private String prefMachineType;
|
|
||||||
private String prefNumericLanguage;
|
|
||||||
private String prefMessageFormatting;
|
|
||||||
|
|
||||||
private SecureRandom secureRandom;
|
private SecureRandom secureRandom;
|
||||||
|
|
||||||
|
@ -68,15 +75,13 @@ public class MainActivity extends Activity
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
secureRandom = new SecureRandom();
|
secureRandom = new SecureRandom();
|
||||||
ActivitySingleton singleton = ActivitySingleton.getInstance();
|
ActivitySingleton.getInstance().setActivity(this);
|
||||||
singleton.setActivity(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SettingsActivity.SettingsSingleton.getInstance(prefs, getResources());
|
||||||
this.prefMachineType = sharedPreferences.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources().
|
layoutContainer = LayoutContainer.createLayoutContainer();
|
||||||
getStringArray(R.array.pref_alias_machine_type)[0]);
|
|
||||||
|
|
||||||
updateContentView();
|
//Handle whats-new dialog
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer(prefMachineType);
|
handleVersionUpdate();
|
||||||
updatePreferenceValues();
|
|
||||||
|
|
||||||
//Handle shared text
|
//Handle shared text
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
@ -88,6 +93,11 @@ public class MainActivity extends Activity
|
||||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
if (sharedText != null)
|
if (sharedText != null)
|
||||||
{
|
{
|
||||||
|
//If shared text consists of an encoded configuration, try to restore it
|
||||||
|
if(sharedText.startsWith(APP_ID+"/"))
|
||||||
|
restoreStateFromCode(sharedText);
|
||||||
|
//Else put it in the input text box
|
||||||
|
else
|
||||||
layoutContainer.getInput().setRawText(sharedText);
|
layoutContainer.getInput().setRawText(sharedText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,114 +107,6 @@ public class MainActivity extends Activity
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
this.updateContentView();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateContentView()
|
|
||||||
{
|
|
||||||
switch (prefMachineType)
|
|
||||||
{
|
|
||||||
case "I":
|
|
||||||
setContentView(R.layout.activity_main_i_m3);
|
|
||||||
break;
|
|
||||||
case "M3":
|
|
||||||
this.setContentView(R.layout.activity_main_i_m3);
|
|
||||||
break;
|
|
||||||
case "M4":
|
|
||||||
this.setContentView(R.layout.activity_main_m4);
|
|
||||||
break;
|
|
||||||
case "D":
|
|
||||||
this.setContentView(R.layout.activity_main_d);
|
|
||||||
break;
|
|
||||||
case "K":
|
|
||||||
case "KS":
|
|
||||||
case "KSA":
|
|
||||||
case "T":
|
|
||||||
case "R":
|
|
||||||
case "G31":
|
|
||||||
case "G312":
|
|
||||||
case "G260":
|
|
||||||
this.setContentView(R.layout.activity_main_g_k_r_t);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.setContentView(R.layout.activity_main_i_m3);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePreferenceValues()
|
|
||||||
{
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
this.setPrefMachineType(sharedPreferences.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_machine_type)[0]));
|
|
||||||
this.setPrefNumericLanguage(sharedPreferences.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_numeric_spelling_language)[0]));
|
|
||||||
this.setPrefMessageFormatting(sharedPreferences.getString(SettingsActivity.PREF_MESSAGE_FORMATTING, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_message_formatting)[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPrefMachineType(String type)
|
|
||||||
{
|
|
||||||
if(prefMachineType == null || !prefMachineType.equals(type))
|
|
||||||
{
|
|
||||||
prefMachineType = type;
|
|
||||||
String savedInput = "";
|
|
||||||
if(layoutContainer != null)
|
|
||||||
{
|
|
||||||
savedInput = layoutContainer.getInput().getText();
|
|
||||||
}
|
|
||||||
updateContentView();
|
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer(prefMachineType);
|
|
||||||
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
|
||||||
layoutContainer.getInput().setText(savedInput);
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
sharedPreferences.edit().putString(SettingsActivity.PREF_MACHINE_TYPE, type).apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefMachineType()
|
|
||||||
{
|
|
||||||
if(prefMachineType != null) return prefMachineType;
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
this.prefMachineType = sharedPreferences.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_machine_type)[0]);
|
|
||||||
return prefMachineType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrefNumericLanguage(String lang)
|
|
||||||
{
|
|
||||||
if(prefNumericLanguage == null || !prefNumericLanguage.equals(lang))
|
|
||||||
{
|
|
||||||
prefNumericLanguage = lang;
|
|
||||||
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefNumericLanguage()
|
|
||||||
{
|
|
||||||
if(prefNumericLanguage != null) return prefNumericLanguage;
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
this.prefNumericLanguage = sharedPreferences.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_numeric_spelling_language)[0]);
|
|
||||||
return prefNumericLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrefMessageFormatting(String messageFormatting)
|
|
||||||
{
|
|
||||||
if(prefMessageFormatting == null || !prefMessageFormatting.equals(messageFormatting))
|
|
||||||
{
|
|
||||||
prefMessageFormatting = messageFormatting;
|
|
||||||
layoutContainer.setEditTextAdapter(messageFormatting);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefMessageFormatting()
|
|
||||||
{
|
|
||||||
if(prefMessageFormatting != null) return prefMessageFormatting;
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
this.prefMessageFormatting = sharedPreferences.getString(SettingsActivity.PREF_MESSAGE_FORMATTING, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_message_formatting)[0]);
|
|
||||||
return prefMessageFormatting;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecureRandom getSecureRandom()
|
public SecureRandom getSecureRandom()
|
||||||
|
@ -238,31 +140,7 @@ public class MainActivity extends Activity
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (id == R.id.action_random_configuration)
|
else if (id == R.id.action_send_message)
|
||||||
{
|
|
||||||
layoutContainer.getEnigma().randomState();
|
|
||||||
layoutContainer.syncStateFromEnigmaToLayout();
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.message_random,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
layoutContainer.getOutput().setText("");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_choose_ringsetting)
|
|
||||||
{
|
|
||||||
layoutContainer.showRingSettingsDialog();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_settings)
|
|
||||||
{
|
|
||||||
Intent i = new Intent(this, SettingsActivity.class);
|
|
||||||
startActivityForResult(i, RESULT_SETTINGS);
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_about)
|
|
||||||
{
|
|
||||||
showAboutDialog();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (id == R.id.action_send)
|
|
||||||
{
|
{
|
||||||
if(layoutContainer.getOutput().getText().length() == 0)
|
if(layoutContainer.getOutput().getText().length() == 0)
|
||||||
{
|
{
|
||||||
|
@ -277,23 +155,37 @@ public class MainActivity extends Activity
|
||||||
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
|
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id == R.id.action_receive_scan)
|
else if (id == R.id.action_choose_ringsetting)
|
||||||
{
|
{
|
||||||
IntentIntegrator integrator = new IntentIntegrator(this);
|
layoutContainer.showRingSettingsDialog();
|
||||||
integrator.initiateScan();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(id == R.id.action_share_scan)
|
else if(id == R.id.action_share_configuration)
|
||||||
{
|
{
|
||||||
IntentIntegrator QRIntegrator = new IntentIntegrator(this);
|
showShareConfigurationDialog();
|
||||||
layoutContainer.syncStateFromLayoutToEnigma();
|
}
|
||||||
Log.d(APP_ID, "Sharing configuration to QR: " + layoutContainer.getEnigma().stateToString());
|
else if (id == R.id.action_restore_configuration)
|
||||||
QRIntegrator.shareText(APP_ID+"/"+layoutContainer.getEnigma().stateToString());
|
{
|
||||||
|
showReceiveConfigurationDialog();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(id == R.id.action_enter_seed)
|
else if (id == R.id.action_random_configuration)
|
||||||
{
|
{
|
||||||
new PassphraseDialogBuilder().showDialog();
|
layoutContainer.getEnigma().randomState();
|
||||||
|
layoutContainer.syncStateFromEnigmaToLayout();
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.message_random,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
layoutContainer.getOutput().setText("");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (id == R.id.action_settings)
|
||||||
|
{
|
||||||
|
Intent i = new Intent(this, SettingsActivity.class);
|
||||||
|
startActivityForResult(i, RESULT_SETTINGS);
|
||||||
|
}
|
||||||
|
else if (id == R.id.action_about)
|
||||||
|
{
|
||||||
|
showAboutDialog();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
@ -310,6 +202,80 @@ public class MainActivity extends Activity
|
||||||
layoutContainer.doCrypto();
|
layoutContainer.doCrypto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void shareConfigurationAsQR()
|
||||||
|
{
|
||||||
|
IntentIntegrator QRIntegrator = new IntentIntegrator(this);
|
||||||
|
layoutContainer.syncStateFromLayoutToEnigma();
|
||||||
|
String encoded_state = APP_ID+"/"+layoutContainer.getEnigma().getEncodedState().toString(16);
|
||||||
|
Log.d(APP_ID, "Sharing configuration to QR: "+encoded_state);
|
||||||
|
QRIntegrator.shareText(encoded_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shareConfigurationAsText()
|
||||||
|
{
|
||||||
|
Intent sendIntent = new Intent();
|
||||||
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_TEXT,
|
||||||
|
APP_ID+"/"+layoutContainer.getEnigma().getEncodedState().toString(16));
|
||||||
|
sendIntent.setType("text/plain");
|
||||||
|
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void receiveConfigurationQR()
|
||||||
|
{
|
||||||
|
IntentIntegrator integrator = new IntentIntegrator(this);
|
||||||
|
integrator.initiateScan();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void receiveConfigurationText()
|
||||||
|
{
|
||||||
|
new PassphraseDialogBuilder().showDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleVersionUpdate()
|
||||||
|
{
|
||||||
|
int currentVersionNumber = 0;
|
||||||
|
int savedVersionNumber = SettingsActivity.SettingsSingleton.getInstance().getVersionNumber();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PackageInfo p = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
|
currentVersionNumber = p.versionCode;
|
||||||
|
}
|
||||||
|
catch (Exception ignored) {}
|
||||||
|
if(currentVersionNumber > savedVersionNumber)
|
||||||
|
{
|
||||||
|
showWhatsNewDialog();
|
||||||
|
SettingsActivity.SettingsSingleton.getInstance().setVersionNumber(currentVersionNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showWhatsNewDialog()
|
||||||
|
{
|
||||||
|
PackageInfo pInfo = null;
|
||||||
|
try{ pInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);}
|
||||||
|
catch (PackageManager.NameNotFoundException e){ e.printStackTrace();}
|
||||||
|
assert pInfo != null;
|
||||||
|
String version = pInfo.versionName;
|
||||||
|
LayoutInflater li = LayoutInflater.from(this);
|
||||||
|
@SuppressLint("InflateParams")
|
||||||
|
View dialog = li.inflate(R.layout.dialog_whats_new, null);
|
||||||
|
((TextView) dialog.findViewById(R.id.dialog_whats_new_header)).setText(
|
||||||
|
String.format(getResources().getText(R.string.dialog_whats_new_header).toString(),version));
|
||||||
|
((TextView) dialog.findViewById(R.id.dialog_whats_new_details)).setText(
|
||||||
|
R.string.dialog_whats_new_content);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setView(dialog).setTitle(R.string.dialog_whats_new_title)
|
||||||
|
.setPositiveButton(R.string.dialog_positive, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which)
|
||||||
|
{
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Show a Dialog containing information about the app, license, usage, author and a link
|
* Show a Dialog containing information about the app, license, usage, author and a link
|
||||||
* to the changelog
|
* to the changelog
|
||||||
|
@ -348,27 +314,110 @@ public class MainActivity extends Activity
|
||||||
}).show();
|
}).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showShareConfigurationDialog()
|
||||||
|
{
|
||||||
|
final String configuration = APP_ID+"/"+layoutContainer.getEnigma().getEncodedState().toString(16);
|
||||||
|
final View shareView = View.inflate(this, R.layout.dialog_two_options, null);
|
||||||
|
LinearLayout l = (LinearLayout) shareView.findViewById(R.id.dialog_two_options_lay);
|
||||||
|
EditText e = new EditText(this);
|
||||||
|
e.setText(configuration);
|
||||||
|
e.setInputType(InputType.TYPE_NULL);
|
||||||
|
e.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB){
|
||||||
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip;
|
||||||
|
clip = ClipData.newPlainText("label", configuration);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
} else{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
clipboard.setText(configuration);
|
||||||
|
}
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.message_clipboard, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
l.addView(e);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.dialog_title_share_configuration)
|
||||||
|
.setView(shareView).setCancelable(true);
|
||||||
|
final Dialog d = builder.create();
|
||||||
|
Button one = (Button) shareView.findViewById(R.id.dialog_two_options_2);
|
||||||
|
one.setText(R.string.dialog_share_qr);
|
||||||
|
one.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
shareConfigurationAsQR();
|
||||||
|
d.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Button two = (Button) shareView.findViewById(R.id.dialog_two_options_1);
|
||||||
|
two.setText(R.string.dialog_share_code);
|
||||||
|
two.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
shareConfigurationAsText();
|
||||||
|
d.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showReceiveConfigurationDialog()
|
||||||
|
{
|
||||||
|
final View shareView = View.inflate(this, R.layout.dialog_two_options, null);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.dialog_title_restore_configuration)
|
||||||
|
.setView(shareView).setCancelable(true);
|
||||||
|
final Dialog d = builder.create();
|
||||||
|
Button one = (Button) shareView.findViewById(R.id.dialog_two_options_2);
|
||||||
|
one.setText(R.string.dialog_restore_qr);
|
||||||
|
one.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
receiveConfigurationQR();
|
||||||
|
d.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Button two = (Button) shareView.findViewById(R.id.dialog_two_options_1);
|
||||||
|
two.setText(R.string.dialog_restore_code);
|
||||||
|
two.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
receiveConfigurationText();
|
||||||
|
d.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle preference changes
|
* Handle Activity Results
|
||||||
* @param requestCode requestCode
|
* @param requestCode requestCode
|
||||||
* @param resultCode resultCode (RESULT_SETTINGS is defined at the top)
|
* @param resultCode resultCode (RESULT_SETTINGS is defined at the top)
|
||||||
* @param data data (not important here)
|
* @param data data
|
||||||
*/
|
*/
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
|
//Come back from Settings
|
||||||
case RESULT_SETTINGS:
|
case RESULT_SETTINGS:
|
||||||
{
|
{
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
applyPreferenceChanges();
|
||||||
this.setPrefMachineType(sharedPrefs.getString(SettingsActivity.PREF_MACHINE_TYPE, getResources()
|
|
||||||
.getStringArray(R.array.pref_alias_machine_type)[0]));
|
|
||||||
this.setPrefNumericLanguage(sharedPrefs.getString(SettingsActivity.PREF_NUMERIC_LANGUAGE, getResources().
|
|
||||||
getStringArray(R.array.pref_alias_numeric_spelling_language)[0]));
|
|
||||||
this.setPrefMessageFormatting(sharedPrefs.getString(SettingsActivity.PREF_MESSAGE_FORMATTING,
|
|
||||||
getResources().getStringArray(R.array.pref_alias_message_formatting)[0]));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Receive from QR
|
||||||
case IntentIntegrator.REQUEST_CODE:
|
case IntentIntegrator.REQUEST_CODE:
|
||||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
|
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
|
||||||
if (scanResult != null) {
|
if (scanResult != null) {
|
||||||
|
@ -382,6 +431,26 @@ public class MainActivity extends Activity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle changes in preferences and apply those changes to the app
|
||||||
|
*/
|
||||||
|
private void applyPreferenceChanges()
|
||||||
|
{
|
||||||
|
SettingsActivity s = SettingsActivity.SettingsSingleton.getInstance();
|
||||||
|
if(s.prefMachineTypeChanged())
|
||||||
|
{
|
||||||
|
layoutContainer = LayoutContainer.createLayoutContainer();
|
||||||
|
}
|
||||||
|
if(s.prefMessageFormattingChanged())
|
||||||
|
{
|
||||||
|
layoutContainer.setEditTextAdapter(s.getPrefMessageFormatting());
|
||||||
|
}
|
||||||
|
if(s.prefNumericLanguageChanged())
|
||||||
|
{
|
||||||
|
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set EnigmAndroid into a certain state as described in the QR-Code
|
* Set EnigmAndroid into a certain state as described in the QR-Code
|
||||||
* @param mem content of the QR-Code
|
* @param mem content of the QR-Code
|
||||||
|
@ -397,11 +466,14 @@ public class MainActivity extends Activity
|
||||||
String inputString = layoutContainer.getInput().getText();
|
String inputString = layoutContainer.getInput().getText();
|
||||||
mem = mem.substring((APP_ID+"/").length());
|
mem = mem.substring((APP_ID+"/").length());
|
||||||
BigInteger s = new BigInteger(mem, 16);
|
BigInteger s = new BigInteger(mem, 16);
|
||||||
Log.d(APP_ID, "Try to restore configuration from BigInteger value "+ s.toString());
|
int protocol_version = Enigma.getValue(s, max_protocol_version);
|
||||||
setPrefMachineType(Enigma.chooseEnigmaFromSave(s));
|
s = Enigma.removeDigit(s, max_protocol_version);
|
||||||
updateContentView();
|
Log.d(APP_ID,
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer(getPrefMachineType());
|
"Try to restore configuration from BigInteger value "+s.toString()+" in protocol version "+protocol_version+".");
|
||||||
layoutContainer.getEnigma().restoreState(Enigma.removeDigit(s,20));
|
SettingsActivity.SettingsSingleton.getInstance()
|
||||||
|
.setPrefMachineType(Enigma.chooseEnigmaFromSave(s));
|
||||||
|
layoutContainer = LayoutContainer.createLayoutContainer();
|
||||||
|
layoutContainer.getEnigma().restoreState(Enigma.removeDigit(s,20), protocol_version);
|
||||||
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
||||||
layoutContainer.syncStateFromEnigmaToLayout();
|
layoutContainer.syncStateFromEnigmaToLayout();
|
||||||
layoutContainer.getInput().setText(inputString);
|
layoutContainer.getInput().setText(inputString);
|
||||||
|
@ -413,12 +485,12 @@ public class MainActivity extends Activity
|
||||||
* Set EnigmAndroid into a state calculated from the seed.
|
* Set EnigmAndroid into a state calculated from the seed.
|
||||||
* @param seed seed
|
* @param seed seed
|
||||||
*/
|
*/
|
||||||
public void createStateFromSeed(String seed)
|
public void applyStateFromSeed(String seed)
|
||||||
{
|
{
|
||||||
String inputString = layoutContainer.getInput().getText();
|
String inputString = layoutContainer.getInput().getText();
|
||||||
setPrefMachineType(Enigma.chooseEnigmaFromSeed(seed));
|
SettingsActivity.SettingsSingleton.getInstance()
|
||||||
updateContentView();
|
.setPrefMachineType(Enigma.chooseEnigmaFromSeed(seed));
|
||||||
layoutContainer = LayoutContainer.createLayoutContainer(getPrefMachineType());
|
layoutContainer = LayoutContainer.createLayoutContainer();
|
||||||
layoutContainer.getEnigma().setStateFromSeed(seed);
|
layoutContainer.getEnigma().setStateFromSeed(seed);
|
||||||
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
layoutContainer.setInputPreparer(InputPreparer.createInputPreparer());
|
||||||
layoutContainer.syncStateFromEnigmaToLayout();
|
layoutContainer.syncStateFromEnigmaToLayout();
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package de.vanitasvitae.enigmandroid;
|
package de.vanitasvitae.enigmandroid;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceManager;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that represents the settings activity.
|
* Class that represents the settings activity.
|
||||||
|
@ -30,6 +32,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
public static final String PREF_MESSAGE_FORMATTING = "prefMessageFormatting";
|
public static final String PREF_MESSAGE_FORMATTING = "prefMessageFormatting";
|
||||||
public static final String PREF_REPLACE_SPECIAL_CHARACTERS = "prefReplaceSpecialCharacters";
|
public static final String PREF_REPLACE_SPECIAL_CHARACTERS = "prefReplaceSpecialCharacters";
|
||||||
public static final String PREF_SAVED_ENIGMA_STATE = "prefSavedEnigmaState";
|
public static final String PREF_SAVED_ENIGMA_STATE = "prefSavedEnigmaState";
|
||||||
|
public static final String PREF_VERSION_NUMBER = "prefVersionNumber";
|
||||||
|
|
||||||
private String previousPrefNumericLanguage;
|
private String previousPrefNumericLanguage;
|
||||||
private String previousPrefMachineType;
|
private String previousPrefMachineType;
|
||||||
|
@ -37,29 +40,55 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
private boolean previousPrefReplaceSpecialCharacters;
|
private boolean previousPrefReplaceSpecialCharacters;
|
||||||
private String previousPrefSavedEnigmaState;
|
private String previousPrefSavedEnigmaState;
|
||||||
|
|
||||||
|
SharedPreferences prefs;
|
||||||
|
Resources res;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
addPreferencesFromResource(R.xml.pref_page);
|
addPreferencesFromResource(R.xml.pref_page);
|
||||||
this.previousPrefMachineType = getPrefMachineType();
|
}
|
||||||
this.previousPrefSavedEnigmaState = getPrefSavedEnigmaState();
|
|
||||||
this.previousPrefMessageFormatting = getPrefMessageFormatting();
|
public void setSharedPreferences(SharedPreferences prefs)
|
||||||
this.previousPrefNumericLanguage = getPrefNumericLanguage();
|
{
|
||||||
|
this.prefs = prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResources(Resources res)
|
||||||
|
{
|
||||||
|
this.res = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFullyInitilaized()
|
||||||
|
{
|
||||||
|
if(prefs == null)
|
||||||
|
{
|
||||||
|
Log.e(MainActivity.APP_ID, "SharedPreferences not initialized via setSharedPreferences!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(res == null)
|
||||||
|
{
|
||||||
|
Log.e(MainActivity.APP_ID, "Resources not initialized via setResources!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefNumericLanguage()
|
public String getPrefNumericLanguage()
|
||||||
{
|
{
|
||||||
return PreferenceManager.getDefaultSharedPreferences(this).getString(
|
if(isFullyInitilaized())
|
||||||
|
return prefs.getString(
|
||||||
PREF_NUMERIC_LANGUAGE,
|
PREF_NUMERIC_LANGUAGE,
|
||||||
getResources().getStringArray(R.array.pref_alias_message_formatting)[0]);
|
res.getStringArray(R.array.pref_alias_message_formatting)[0]);
|
||||||
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrefNumericLanguage(String lang)
|
public void setPrefNumericLanguage(String lang)
|
||||||
{
|
{
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).edit()
|
if(isFullyInitilaized())
|
||||||
.putString(PREF_NUMERIC_LANGUAGE, lang).apply();
|
prefs.edit().putString(PREF_NUMERIC_LANGUAGE, lang).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean prefNumericLanguageChanged()
|
public boolean prefNumericLanguageChanged()
|
||||||
|
@ -67,6 +96,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
if(this.previousPrefNumericLanguage == null || !this.previousPrefNumericLanguage.equals(getPrefNumericLanguage()))
|
if(this.previousPrefNumericLanguage == null || !this.previousPrefNumericLanguage.equals(getPrefNumericLanguage()))
|
||||||
{
|
{
|
||||||
this.previousPrefNumericLanguage = this.getPrefNumericLanguage();
|
this.previousPrefNumericLanguage = this.getPrefNumericLanguage();
|
||||||
|
Log.d(MainActivity.APP_ID, PREF_NUMERIC_LANGUAGE +" changed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,14 +104,15 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
public boolean getPrefReplaceSpecialCharacters()
|
public boolean getPrefReplaceSpecialCharacters()
|
||||||
{
|
{
|
||||||
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
|
if(isFullyInitilaized())
|
||||||
PREF_REPLACE_SPECIAL_CHARACTERS, true);
|
return prefs.getBoolean(PREF_REPLACE_SPECIAL_CHARACTERS, true);
|
||||||
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrefReplaceSpecialCharacters(boolean replace)
|
public void setPrefReplaceSpecialCharacters(boolean replace)
|
||||||
{
|
{
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).edit()
|
if(isFullyInitilaized())
|
||||||
.putBoolean(PREF_REPLACE_SPECIAL_CHARACTERS, replace).apply();
|
prefs.edit().putBoolean(PREF_REPLACE_SPECIAL_CHARACTERS, replace).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean prefReplaceSpecialCharactersChanged()
|
public boolean prefReplaceSpecialCharactersChanged()
|
||||||
|
@ -90,6 +121,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
if(changed)
|
if(changed)
|
||||||
{
|
{
|
||||||
previousPrefReplaceSpecialCharacters = getPrefReplaceSpecialCharacters();
|
previousPrefReplaceSpecialCharacters = getPrefReplaceSpecialCharacters();
|
||||||
|
Log.d(MainActivity.APP_ID, PREF_REPLACE_SPECIAL_CHARACTERS +" changed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -97,15 +129,16 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
public String getPrefMachineType()
|
public String getPrefMachineType()
|
||||||
{
|
{
|
||||||
return PreferenceManager.getDefaultSharedPreferences(this).getString(
|
if(isFullyInitilaized())
|
||||||
PREF_MACHINE_TYPE,
|
return prefs.getString(PREF_MACHINE_TYPE,
|
||||||
getResources().getStringArray(R.array.pref_alias_machine_type)[0]);
|
res.getStringArray(R.array.pref_alias_machine_type)[0]);
|
||||||
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrefMachineType(String pref)
|
public void setPrefMachineType(String pref)
|
||||||
{
|
{
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).edit()
|
if(isFullyInitilaized())
|
||||||
.putString(PREF_MACHINE_TYPE, pref).apply();
|
prefs.edit().putString(PREF_MACHINE_TYPE, pref).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean prefMachineTypeChanged()
|
public boolean prefMachineTypeChanged()
|
||||||
|
@ -113,6 +146,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
if(this.previousPrefMachineType == null || !this.previousPrefMachineType.equals(getPrefMachineType()))
|
if(this.previousPrefMachineType == null || !this.previousPrefMachineType.equals(getPrefMachineType()))
|
||||||
{
|
{
|
||||||
this.previousPrefMachineType = this.getPrefMachineType();
|
this.previousPrefMachineType = this.getPrefMachineType();
|
||||||
|
Log.d(MainActivity.APP_ID, PREF_MACHINE_TYPE +" changed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -120,8 +154,9 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
public String getPrefSavedEnigmaState()
|
public String getPrefSavedEnigmaState()
|
||||||
{
|
{
|
||||||
return PreferenceManager.getDefaultSharedPreferences(this)
|
if(isFullyInitilaized())
|
||||||
.getString(PREF_SAVED_ENIGMA_STATE, "-1");
|
return prefs.getString(PREF_SAVED_ENIGMA_STATE, "-1");
|
||||||
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,8 +164,8 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
*/
|
*/
|
||||||
public void setPrefSavedEnigmaState(String state)
|
public void setPrefSavedEnigmaState(String state)
|
||||||
{
|
{
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).edit()
|
if(isFullyInitilaized())
|
||||||
.putString(PREF_SAVED_ENIGMA_STATE, state).apply();
|
prefs.edit().putString(PREF_SAVED_ENIGMA_STATE, state).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean prefSavedEnigmaStateChanged()
|
public boolean prefSavedEnigmaStateChanged()
|
||||||
|
@ -139,6 +174,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
.equals(getPrefSavedEnigmaState()))
|
.equals(getPrefSavedEnigmaState()))
|
||||||
{
|
{
|
||||||
this.previousPrefSavedEnigmaState = this.getPrefSavedEnigmaState();
|
this.previousPrefSavedEnigmaState = this.getPrefSavedEnigmaState();
|
||||||
|
Log.d(MainActivity.APP_ID, PREF_SAVED_ENIGMA_STATE +" changed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -146,15 +182,16 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
public String getPrefMessageFormatting()
|
public String getPrefMessageFormatting()
|
||||||
{
|
{
|
||||||
return PreferenceManager.getDefaultSharedPreferences(this)
|
if(isFullyInitilaized())
|
||||||
.getString(SettingsActivity.PREF_MESSAGE_FORMATTING, getResources().
|
return prefs.getString(SettingsActivity.PREF_MESSAGE_FORMATTING,
|
||||||
getStringArray(R.array.pref_alias_message_formatting)[0]);
|
res.getStringArray(R.array.pref_alias_message_formatting)[0]);
|
||||||
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrefMessageFormatting(String format)
|
public void setPrefMessageFormatting(String format)
|
||||||
{
|
{
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).edit()
|
if(isFullyInitilaized())
|
||||||
.putString(PREF_MESSAGE_FORMATTING, format).apply();
|
prefs.edit().putString(PREF_MESSAGE_FORMATTING, format).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean prefMessageFormattingChanged()
|
public boolean prefMessageFormattingChanged()
|
||||||
|
@ -163,11 +200,25 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
.equals(getPrefMessageFormatting()))
|
.equals(getPrefMessageFormatting()))
|
||||||
{
|
{
|
||||||
this.previousPrefMessageFormatting = this.getPrefMessageFormatting();
|
this.previousPrefMessageFormatting = this.getPrefMessageFormatting();
|
||||||
|
Log.d(MainActivity.APP_ID, PREF_MESSAGE_FORMATTING +" changed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getVersionNumber()
|
||||||
|
{
|
||||||
|
if(isFullyInitilaized())
|
||||||
|
return prefs.getInt(PREF_VERSION_NUMBER, -1);
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersionNumber(int v)
|
||||||
|
{
|
||||||
|
if(isFullyInitilaized())
|
||||||
|
prefs.edit().putInt(PREF_VERSION_NUMBER, v).apply();
|
||||||
|
}
|
||||||
|
|
||||||
public static class SettingsSingleton extends SettingsActivity
|
public static class SettingsSingleton extends SettingsActivity
|
||||||
{
|
{
|
||||||
private static SettingsActivity instance;
|
private static SettingsActivity instance;
|
||||||
|
@ -176,9 +227,21 @@ public class SettingsActivity extends PreferenceActivity
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SettingsActivity getInstance(SharedPreferences prefs, Resources res)
|
||||||
|
{
|
||||||
|
instance = new SettingsActivity();
|
||||||
|
instance.setSharedPreferences(prefs);
|
||||||
|
instance.setResources(res);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public static SettingsActivity getInstance()
|
public static SettingsActivity getInstance()
|
||||||
{
|
{
|
||||||
if(instance == null) instance = new SettingsActivity();
|
if(instance == null)
|
||||||
|
{
|
||||||
|
instance = new SettingsActivity();
|
||||||
|
Log.d(MainActivity.APP_ID, "Created new SettingsActivity!");
|
||||||
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ public abstract class Enigma
|
||||||
public Reflector getReflector(int index)
|
public Reflector getReflector(int index)
|
||||||
{
|
{
|
||||||
if(availableReflectors == null || availableReflectors.size() == 0) return null;
|
if(availableReflectors == null || availableReflectors.size() == 0) return null;
|
||||||
return availableReflectors.get(index % availableReflectors.size()).getInstance();
|
return availableReflectors.get(index%availableReflectors.size()).getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reflector getReflector(int index, int rotation, int ringSetting)
|
public Reflector getReflector(int index, int rotation, int ringSetting)
|
||||||
|
@ -202,13 +202,18 @@ public abstract class Enigma
|
||||||
generateState();
|
generateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void restoreState(BigInteger mem);
|
public abstract void restoreState(BigInteger mem, int protocol_version);
|
||||||
|
|
||||||
public abstract String stateToString();
|
public BigInteger getEncodedState()
|
||||||
|
{
|
||||||
|
return getEncodedState(MainActivity.latest_protocol_version);
|
||||||
|
}
|
||||||
|
public abstract BigInteger getEncodedState(int protocol_version);
|
||||||
|
|
||||||
public static String numToMachineType(int n)
|
public static String numToMachineType(int n)
|
||||||
{
|
{
|
||||||
n = (12+(n+12)%12)%12; //Problem? Trolololo
|
int m = 13;
|
||||||
|
n = (m+(n+m)%m)%m; //Problem? Trolololo
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 0: return "I";
|
case 0: return "I";
|
||||||
case 1: return "M3";
|
case 1: return "M3";
|
||||||
|
@ -221,18 +226,20 @@ public abstract class Enigma
|
||||||
case 8: return "KS";
|
case 8: return "KS";
|
||||||
case 9: return "KSA";
|
case 9: return "KSA";
|
||||||
case 10: return "R";
|
case 10: return "R";
|
||||||
default: return "T";
|
case 11: return "T";
|
||||||
|
case 12: return "KD";
|
||||||
|
default: return "KD";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String chooseEnigmaFromSeed(String seed)
|
public static String chooseEnigmaFromSeed(String seed)
|
||||||
{
|
{
|
||||||
return numToMachineType(seed.hashCode() % 12);
|
return numToMachineType(seed.hashCode() % 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String chooseEnigmaFromSave(BigInteger save)
|
public static String chooseEnigmaFromSave(BigInteger save)
|
||||||
{
|
{
|
||||||
return numToMachineType(getValue(save,20));
|
return numToMachineType(getValue(save, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class Enigma_D extends Enigma {
|
||||||
addAvailableRotor(new Rotor.Rotor_K_D_II(0, 0));
|
addAvailableRotor(new Rotor.Rotor_K_D_II(0, 0));
|
||||||
addAvailableRotor(new Rotor.Rotor_K_D_III(0, 0));
|
addAvailableRotor(new Rotor.Rotor_K_D_III(0, 0));
|
||||||
|
|
||||||
addAvailableReflector(new Reflector.ReflectorEnigma_D_KD_G31());
|
addAvailableReflector(new Reflector.ReflectorEnigma_D_G31());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -169,8 +169,11 @@ public class Enigma_D extends Enigma {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch(protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int rot1 = getValue(s, 26);
|
int rot1 = getValue(s, 26);
|
||||||
s = removeDigit(s, 26);
|
s = removeDigit(s, 26);
|
||||||
int ring1 = getValue(s, 26);
|
int ring1 = getValue(s, 26);
|
||||||
|
@ -193,10 +196,14 @@ public class Enigma_D extends Enigma {
|
||||||
this.rotor3 = getRotor(2, rot3, ring3);
|
this.rotor3 = getRotor(2, rot3, ring3);
|
||||||
this.reflector = getReflector(0, rotRef, ringRef);
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
this.reflector.setConfiguration(s);
|
this.reflector.setConfiguration(s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString() {
|
public BigInteger getEncodedState(int protocol_version) {
|
||||||
BigInteger s = Plugboard.configurationToBigInteger(reflector.getConfiguration());
|
BigInteger s = Plugboard.configurationToBigInteger(reflector.getConfiguration());
|
||||||
s = addDigit(s, reflector.getRingSetting(), 26);
|
s = addDigit(s, reflector.getRingSetting(), 26);
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -206,7 +213,9 @@ public class Enigma_D extends Enigma {
|
||||||
s = addDigit(s, rotor2.getRotation(), 26);
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
s = addDigit(s, rotor1.getRingSetting(), 26);
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor1.getRotation(), 26);
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
s = addDigit(s, 6, 20); //Machine #6
|
s = addDigit(s, 6, 20); //Machine #6
|
||||||
return s.toString(16);
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class Enigma_G260 extends Enigma_G31
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -64,7 +64,8 @@ public class Enigma_G260 extends Enigma_G31
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
|
|
||||||
s = addDigit(s, 5, 20); //Machine #5
|
s = addDigit(s, 5, 20); //Machine #5
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
return s.toString(16);
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Enigma_G31 extends Enigma
|
||||||
addAvailableRotor(new Rotor.Rotor_G31_I(0, 0));
|
addAvailableRotor(new Rotor.Rotor_G31_I(0, 0));
|
||||||
addAvailableRotor(new Rotor.Rotor_G31_II(0, 0));
|
addAvailableRotor(new Rotor.Rotor_G31_II(0, 0));
|
||||||
addAvailableRotor(new Rotor.Rotor_G31_III(0, 0));
|
addAvailableRotor(new Rotor.Rotor_G31_III(0, 0));
|
||||||
addAvailableReflector(new Reflector.ReflectorEnigma_D_KD_G31());
|
addAvailableReflector(new Reflector.ReflectorEnigma_D_G31());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -168,8 +168,11 @@ public class Enigma_G31 extends Enigma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int r1 = getValue(s, availableRotors.size());
|
int r1 = getValue(s, availableRotors.size());
|
||||||
s = removeDigit(s, availableRotors.size());
|
s = removeDigit(s, availableRotors.size());
|
||||||
int r2 = getValue(s, availableRotors.size());
|
int r2 = getValue(s, availableRotors.size());
|
||||||
|
@ -199,10 +202,14 @@ public class Enigma_G31 extends Enigma
|
||||||
this.rotor2 = getRotor(r2, rot2, ring2);
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
this.rotor3 = getRotor(r3, rot3, ring3);
|
this.rotor3 = getRotor(r3, rot3, ring3);
|
||||||
this.reflector = getReflector(0, rotRef, ringRef);
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -218,6 +225,7 @@ public class Enigma_G31 extends Enigma
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
|
|
||||||
s = addDigit(s, 3, 20); //Machine #3
|
s = addDigit(s, 3, 20); //Machine #3
|
||||||
return s.toString(16);
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class Enigma_G312 extends Enigma_G31
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -64,7 +64,8 @@ public class Enigma_G312 extends Enigma_G31
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
|
|
||||||
s = addDigit(s, 4, 20); //Machine #4
|
s = addDigit(s, 4, 20); //Machine #4
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
return s.toString(16);
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,8 +176,11 @@ public class Enigma_I extends Enigma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int r1 = getValue(s, availableRotors.size());
|
int r1 = getValue(s, availableRotors.size());
|
||||||
s = removeDigit(s, availableRotors.size());
|
s = removeDigit(s, availableRotors.size());
|
||||||
int r2 = getValue(s, availableRotors.size());
|
int r2 = getValue(s, availableRotors.size());
|
||||||
|
@ -207,10 +210,14 @@ public class Enigma_I extends Enigma
|
||||||
|
|
||||||
this.plugboard = new Plugboard();
|
this.plugboard = new Plugboard();
|
||||||
plugboard.setConfiguration(s);
|
plugboard.setConfiguration(s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString() {
|
public BigInteger getEncodedState(int protocol_version) {
|
||||||
BigInteger s = Plugboard.configurationToBigInteger(plugboard.getConfiguration());
|
BigInteger s = Plugboard.configurationToBigInteger(plugboard.getConfiguration());
|
||||||
s = addDigit(s, rotor3.getRingSetting(), 26);
|
s = addDigit(s, rotor3.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor3.getRotation(), 26);
|
s = addDigit(s, rotor3.getRotation(), 26);
|
||||||
|
@ -218,12 +225,15 @@ public class Enigma_I extends Enigma
|
||||||
s = addDigit(s, rotor2.getRotation(), 26);
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
s = addDigit(s, rotor1.getRingSetting(), 26);
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor1.getRotation(), 26);
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
s = addDigit(s, reflector.getIndex(), availableReflectors.size());
|
s = addDigit(s, reflector.getIndex(), availableReflectors.size());
|
||||||
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, 0, 20); //Machine #0
|
|
||||||
|
|
||||||
return s.toString(16);
|
s = addDigit(s, 0, 20); //Machine #0
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,11 @@ public class Enigma_K extends Enigma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int r1 = getValue(s,availableRotors.size());
|
int r1 = getValue(s,availableRotors.size());
|
||||||
s = removeDigit(s,availableRotors.size());
|
s = removeDigit(s,availableRotors.size());
|
||||||
int r2 = getValue(s,availableRotors.size());
|
int r2 = getValue(s,availableRotors.size());
|
||||||
|
@ -195,10 +198,14 @@ public class Enigma_K extends Enigma
|
||||||
this.rotor2 = getRotor(r2, rot2, ring2);
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
this.rotor3 = getRotor(r3, rot3, ring3);
|
this.rotor3 = getRotor(r3, rot3, ring3);
|
||||||
this.reflector = getReflector(0, rotRef, ringRef);
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -208,11 +215,14 @@ public class Enigma_K extends Enigma
|
||||||
s = addDigit(s, rotor2.getRotation(), 26);
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
s = addDigit(s, rotor1.getRingSetting(), 26);
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor1.getRotation(), 26);
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, 7, 20); //Machine #7
|
|
||||||
|
|
||||||
return s.toString(16);
|
s = addDigit(s, 7, 20); //Machine #7
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,240 @@
|
||||||
|
package de.vanitasvitae.enigmandroid.enigma;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concrete implementation of an enigma machine of name D
|
||||||
|
* This machine has a rewirable UKW, non changeable rotors.
|
||||||
|
* 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.
|
||||||
|
* @author vanitasvitae
|
||||||
|
*/
|
||||||
|
public class Enigma_KD extends Enigma {
|
||||||
|
|
||||||
|
protected EntryWheel entryWheel;
|
||||||
|
protected Rotor rotor1;
|
||||||
|
protected Rotor rotor2;
|
||||||
|
protected Rotor rotor3;
|
||||||
|
protected Reflector reflector;
|
||||||
|
|
||||||
|
public Enigma_KD()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
machineType = "KD";
|
||||||
|
Log.d(MainActivity.APP_ID, "Created Enigma KD");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void establishAvailableParts()
|
||||||
|
{
|
||||||
|
addAvailableEntryWheel(new EntryWheel.EntryWheel_QWERTZ()); //TODO: Really?
|
||||||
|
|
||||||
|
addAvailableRotor(new Rotor.Rotor_KD_I(0, 0));
|
||||||
|
addAvailableRotor(new Rotor.Rotor_KD_II(0, 0));
|
||||||
|
addAvailableRotor(new Rotor.Rotor_KD_III(0, 0));
|
||||||
|
|
||||||
|
addAvailableReflector(new Reflector.ReflectorEnigma_KD());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize()
|
||||||
|
{
|
||||||
|
this.entryWheel = availableEntryWheels.get(0);
|
||||||
|
this.rotor1 = availableRotors.get(0);
|
||||||
|
this.rotor2 = availableRotors.get(1);
|
||||||
|
this.rotor3 = availableRotors.get(2);
|
||||||
|
this.reflector = availableReflectors.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void nextState()
|
||||||
|
{
|
||||||
|
rotor1.rotate();
|
||||||
|
if (rotor1.isAtTurnoverPosition() || this.doAnomaly)
|
||||||
|
{
|
||||||
|
rotor2.rotate();
|
||||||
|
this.doAnomaly = rotor2.doubleTurnAnomaly();
|
||||||
|
if (rotor2.isAtTurnoverPosition())
|
||||||
|
{
|
||||||
|
rotor3.rotate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void generateState() {
|
||||||
|
int r1, r2=-1, r3;
|
||||||
|
r1 = rand.nextInt(3);
|
||||||
|
while(r2 == -1 || r2 == r1) r2 = rand.nextInt(3);
|
||||||
|
r3 = 3 - r1 - r2;
|
||||||
|
|
||||||
|
int rot1 = rand.nextInt(26);
|
||||||
|
int rot2 = rand.nextInt(26);
|
||||||
|
int rot3 = rand.nextInt(26);
|
||||||
|
int rotRef = rand.nextInt(26);
|
||||||
|
int ring1 = rand.nextInt(26);
|
||||||
|
int ring2 = rand.nextInt(26);
|
||||||
|
int ring3 = rand.nextInt(26);
|
||||||
|
int ringRef = rand.nextInt(26);
|
||||||
|
|
||||||
|
this.entryWheel = getEntryWheel(0);
|
||||||
|
this.rotor1 = getRotor(r1, rot1, ring1);
|
||||||
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
|
this.rotor3 = getRotor(r3, rot3, ring3);
|
||||||
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
|
this.reflector.setRotation(rotRef).setRingSetting(ringRef)
|
||||||
|
.setConfiguration(Plugboard.seedToReflectorConfiguration(rand));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char encryptChar(char k)
|
||||||
|
{
|
||||||
|
nextState();
|
||||||
|
int x = ((int) k)-65; //Cast to int and remove Unicode Offset (A=65 in Unicode.)
|
||||||
|
//Encryption
|
||||||
|
//forward direction
|
||||||
|
x = entryWheel.encryptForward(x);
|
||||||
|
x = rotor1.normalize(x + rotor1.getRotation() - rotor1.getRingSetting());
|
||||||
|
x = rotor1.encryptForward(x);
|
||||||
|
x = rotor1.normalize(x - rotor1.getRotation() + rotor1.getRingSetting() + rotor2.getRotation() - rotor2.getRingSetting());
|
||||||
|
x = rotor2.encryptForward(x);
|
||||||
|
x = rotor1.normalize(x - rotor2.getRotation() + rotor2.getRingSetting() + rotor3.getRotation() - rotor3.getRingSetting());
|
||||||
|
x = rotor3.encryptForward(x);
|
||||||
|
x = rotor1.normalize(x - rotor3.getRotation() + rotor3.getRingSetting() + reflector.getRotation() - reflector.getRingSetting());
|
||||||
|
//backward direction
|
||||||
|
x = reflector.encrypt(x);
|
||||||
|
x = rotor1.normalize(x + rotor3.getRotation() - rotor3.getRingSetting() - reflector.getRotation() + reflector.getRingSetting());
|
||||||
|
x = rotor3.encryptBackward(x);
|
||||||
|
x = rotor1.normalize(x + rotor2.getRotation() - rotor2.getRingSetting() - rotor3.getRotation() + rotor3.getRingSetting());
|
||||||
|
x = rotor2.encryptBackward(x);
|
||||||
|
x = rotor1.normalize(x + rotor1.getRotation() - rotor1.getRingSetting() - rotor2.getRotation() + rotor2.getRingSetting());
|
||||||
|
x = rotor1.encryptBackward(x);
|
||||||
|
x = rotor1.normalize(x - rotor1.getRotation() + rotor1.getRingSetting());
|
||||||
|
x = entryWheel.encryptBackward(x);
|
||||||
|
return (char) (x + 65); //Add Offset again, cast back to char and return
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setState(EnigmaStateBundle state)
|
||||||
|
{
|
||||||
|
this.entryWheel = getEntryWheel(state.getTypeEntryWheel());
|
||||||
|
this.rotor1 = getRotor(state.getTypeRotor1(), state.getRotationRotor1(), state.getRingSettingRotor1());
|
||||||
|
this.rotor2 = getRotor(state.getTypeRotor2(), state.getRotationRotor2(), state.getRingSettingRotor2());
|
||||||
|
this.rotor3 = getRotor(state.getTypeRotor3(), state.getRotationRotor3(), state.getRingSettingRotor3());
|
||||||
|
this.reflector = getReflector(state.getTypeReflector(),
|
||||||
|
state.getRotationReflector(),
|
||||||
|
state.getRingSettingReflector())
|
||||||
|
.setConfiguration(state.getConfigurationReflector());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnigmaStateBundle getState()
|
||||||
|
{
|
||||||
|
EnigmaStateBundle state = new EnigmaStateBundle();
|
||||||
|
|
||||||
|
state.setTypeEntryWheel(entryWheel.getIndex());
|
||||||
|
|
||||||
|
state.setTypeRotor1(rotor1.getIndex());
|
||||||
|
state.setTypeRotor2(rotor2.getIndex());
|
||||||
|
state.setTypeRotor3(rotor3.getIndex());
|
||||||
|
|
||||||
|
state.setRotationRotor1(rotor1.getRotation());
|
||||||
|
state.setRotationRotor2(rotor2.getRotation());
|
||||||
|
state.setRotationRotor3(rotor3.getRotation());
|
||||||
|
|
||||||
|
state.setRingSettingRotor1(rotor1.getRingSetting());
|
||||||
|
state.setRingSettingRotor2(rotor2.getRingSetting());
|
||||||
|
state.setRingSettingRotor3(rotor3.getRingSetting());
|
||||||
|
|
||||||
|
state.setTypeReflector(reflector.getIndex());
|
||||||
|
state.setRotationReflector(reflector.getRotation());
|
||||||
|
state.setRingSettingReflector(reflector.getRingSetting());
|
||||||
|
state.setConfigurationReflector(reflector.getConfiguration());
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
int r1 = getValue(s, availableRotors.size());
|
||||||
|
s = removeDigit(s, availableRotors.size());
|
||||||
|
int r2 = getValue(s, availableRotors.size());
|
||||||
|
s = removeDigit(s, availableRotors.size());
|
||||||
|
int r3 = getValue(s, availableRotors.size());
|
||||||
|
s = removeDigit(s, availableRotors.size());
|
||||||
|
|
||||||
|
int rot1 = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int ring1 = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int rot2 = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int ring2 = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int rot3 = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int ring3 = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int rotRef = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
int ringRef = getValue(s, 26);
|
||||||
|
s = removeDigit(s, 26);
|
||||||
|
|
||||||
|
this.rotor1 = getRotor(r1, rot1, ring1);
|
||||||
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
|
this.rotor3 = getRotor(r3, rot3, ring3);
|
||||||
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
|
this.reflector.setConfiguration(s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigInteger getEncodedState(int protocol_version) {
|
||||||
|
BigInteger s = Plugboard.configurationToBigInteger(reflector.getConfiguration());
|
||||||
|
s = addDigit(s, reflector.getRingSetting(), 26);
|
||||||
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
s = addDigit(s, rotor3.getRingSetting(), 26);
|
||||||
|
s = addDigit(s, rotor3.getRotation(), 26);
|
||||||
|
s = addDigit(s, rotor2.getRingSetting(), 26);
|
||||||
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
|
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, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,7 +48,7 @@ public class Enigma_K_Swiss_Airforce extends Enigma_K
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -58,11 +58,14 @@ public class Enigma_K_Swiss_Airforce extends Enigma_K
|
||||||
s = addDigit(s, rotor2.getRotation(), 26);
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
s = addDigit(s, rotor1.getRingSetting(), 26);
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor1.getRotation(), 26);
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, 9, 20); //Machine #9
|
|
||||||
|
|
||||||
return s.toString(16);
|
s = addDigit(s, 9, 20); //Machine #9
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class Enigma_K_Swiss_Standard extends Enigma_K
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -58,12 +58,15 @@ public class Enigma_K_Swiss_Standard extends Enigma_K
|
||||||
s = addDigit(s, rotor2.getRotation(), 26);
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
s = addDigit(s, rotor1.getRingSetting(), 26);
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor1.getRotation(), 26);
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, 8, 20); //Machine #8
|
|
||||||
|
|
||||||
return s.toString(16);
|
s = addDigit(s, 8, 20); //Machine #8
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class Enigma_M3 extends Enigma_I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString() {
|
public BigInteger getEncodedState(int protocol_version) {
|
||||||
BigInteger s = Plugboard.configurationToBigInteger(plugboard.getConfiguration());
|
BigInteger s = Plugboard.configurationToBigInteger(plugboard.getConfiguration());
|
||||||
s = addDigit(s, rotor3.getRingSetting(), 26);
|
s = addDigit(s, rotor3.getRingSetting(), 26);
|
||||||
s = addDigit(s, rotor3.getRotation(), 26);
|
s = addDigit(s, rotor3.getRotation(), 26);
|
||||||
|
@ -92,7 +92,8 @@ public class Enigma_M3 extends Enigma_I
|
||||||
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
s = addDigit(s, 1, 20); //Machine #1
|
s = addDigit(s, 1, 20); //Machine #1
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
return s.toString(16);
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,8 +242,11 @@ public class Enigma_M4 extends Enigma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int r1 = getValue(s, availableRotors.size());
|
int r1 = getValue(s, availableRotors.size());
|
||||||
s = removeDigit(s, availableRotors.size());
|
s = removeDigit(s, availableRotors.size());
|
||||||
int r2 = getValue(s, availableRotors.size());
|
int r2 = getValue(s, availableRotors.size());
|
||||||
|
@ -274,7 +277,7 @@ public class Enigma_M4 extends Enigma
|
||||||
int rotRef = getValue(s, 26);
|
int rotRef = getValue(s, 26);
|
||||||
s = removeDigit(s,26);
|
s = removeDigit(s,26);
|
||||||
int ringRef = getValue(s, 26);
|
int ringRef = getValue(s, 26);
|
||||||
s = removeDigit(s,26);
|
s = removeDigit(s, 26);
|
||||||
|
|
||||||
this.rotor1 = getRotor(r1, rot1, ring1);
|
this.rotor1 = getRotor(r1, rot1, ring1);
|
||||||
this.rotor2 = getRotor(r2, rot2, ring2);
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
|
@ -283,10 +286,14 @@ public class Enigma_M4 extends Enigma
|
||||||
this.reflector = getReflector(ref, rotRef, ringRef);
|
this.reflector = getReflector(ref, rotRef, ringRef);
|
||||||
this.plugboard = new Plugboard();
|
this.plugboard = new Plugboard();
|
||||||
plugboard.setConfiguration(s);
|
plugboard.setConfiguration(s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString() {
|
public BigInteger getEncodedState(int protocol_version) {
|
||||||
BigInteger s = Plugboard.configurationToBigInteger(plugboard.getConfiguration());
|
BigInteger s = Plugboard.configurationToBigInteger(plugboard.getConfiguration());
|
||||||
s = addDigit(s, reflector.getRingSetting(), 26);
|
s = addDigit(s, reflector.getRingSetting(), 26);
|
||||||
s = addDigit(s, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
|
@ -306,6 +313,8 @@ public class Enigma_M4 extends Enigma
|
||||||
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
|
|
||||||
s = addDigit(s, 2, 20);
|
s = addDigit(s, 2, 20);
|
||||||
return s.toString(16);
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,8 +166,11 @@ public class Enigma_R extends Enigma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int r1 = getValue(s,availableRotors.size());
|
int r1 = getValue(s,availableRotors.size());
|
||||||
s = removeDigit(s,availableRotors.size());
|
s = removeDigit(s,availableRotors.size());
|
||||||
int r2 = getValue(s,availableRotors.size());
|
int r2 = getValue(s,availableRotors.size());
|
||||||
|
@ -197,24 +200,33 @@ public class Enigma_R extends Enigma
|
||||||
this.rotor2 = getRotor(r2, rot2, ring2);
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
this.rotor3 = getRotor(r3, rot3, ring3);
|
this.rotor3 = getRotor(r3, rot3, ring3);
|
||||||
this.reflector = getReflector(0, rotRef, ringRef);
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger t = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
t = addDigit(t, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
t = addDigit(t, rotor3.getRingSetting(),26);
|
|
||||||
t = addDigit(t, rotor3.getRotation(), 26);
|
|
||||||
t = addDigit(t, rotor2.getRingSetting(),26);
|
|
||||||
t = addDigit(t, rotor2.getRotation(), 26);
|
|
||||||
t = addDigit(t, rotor1.getRingSetting(), 26);
|
|
||||||
t = addDigit(t, rotor1.getRotation(), 26);
|
|
||||||
t = addDigit(t, rotor3.getIndex(), availableRotors.size());
|
|
||||||
t = addDigit(t, rotor2.getIndex(), availableRotors.size());
|
|
||||||
t = addDigit(t, rotor1.getIndex(), availableRotors.size());
|
|
||||||
t = addDigit(t, 10, 20); //Machine #10
|
|
||||||
|
|
||||||
return t.toString(16);
|
s = addDigit(s, rotor3.getRingSetting(),26);
|
||||||
|
s = addDigit(s, rotor3.getRotation(), 26);
|
||||||
|
s = addDigit(s, rotor2.getRingSetting(),26);
|
||||||
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
|
|
||||||
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
|
|
||||||
|
s = addDigit(s, 10, 20); //Machine #10
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,8 +166,11 @@ public class Enigma_T extends Enigma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreState(BigInteger s)
|
public void restoreState(BigInteger s, int protocol_version)
|
||||||
{
|
{
|
||||||
|
switch (protocol_version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
int r1 = getValue(s,availableRotors.size());
|
int r1 = getValue(s,availableRotors.size());
|
||||||
s = removeDigit(s,availableRotors.size());
|
s = removeDigit(s,availableRotors.size());
|
||||||
int r2 = getValue(s,availableRotors.size());
|
int r2 = getValue(s,availableRotors.size());
|
||||||
|
@ -188,31 +191,39 @@ public class Enigma_T extends Enigma
|
||||||
int ring3 = getValue(s,26);
|
int ring3 = getValue(s,26);
|
||||||
s = removeDigit(s,26);
|
s = removeDigit(s,26);
|
||||||
int rotRef = getValue(s,26);
|
int rotRef = getValue(s,26);
|
||||||
s = removeDigit(s,26);
|
s = removeDigit(s, 26);
|
||||||
int ringRef = getValue(s,26);
|
int ringRef = getValue(s,26);
|
||||||
|
|
||||||
this.rotor1 = getRotor(r1, rot1, ring1);
|
this.rotor1 = getRotor(r1, rot1, ring1);
|
||||||
this.rotor2 = getRotor(r2, rot2, ring2);
|
this.rotor2 = getRotor(r2, rot2, ring2);
|
||||||
this.rotor3 = getRotor(r3, rot3, ring3);
|
this.rotor3 = getRotor(r3, rot3, ring3);
|
||||||
this.reflector = getReflector(0, rotRef, ringRef);
|
this.reflector = getReflector(0, rotRef, ringRef);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: Log.e(MainActivity.APP_ID, "Unsupported protocol version "+protocol_version);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stateToString()
|
public BigInteger getEncodedState(int protocol_version)
|
||||||
{
|
{
|
||||||
BigInteger t = BigInteger.valueOf(reflector.getRingSetting());
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
||||||
t = addDigit(t, reflector.getRotation(), 26);
|
s = addDigit(s, reflector.getRotation(), 26);
|
||||||
t = addDigit(t, rotor3.getRingSetting(),26);
|
s = addDigit(s, rotor3.getRingSetting(),26);
|
||||||
t = addDigit(t, rotor3.getRotation(), 26);
|
s = addDigit(s, rotor3.getRotation(), 26);
|
||||||
t = addDigit(t, rotor2.getRingSetting(),26);
|
s = addDigit(s, rotor2.getRingSetting(),26);
|
||||||
t = addDigit(t, rotor2.getRotation(), 26);
|
s = addDigit(s, rotor2.getRotation(), 26);
|
||||||
t = addDigit(t, rotor1.getRingSetting(), 26);
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
||||||
t = addDigit(t, rotor1.getRotation(), 26);
|
s = addDigit(s, rotor1.getRotation(), 26);
|
||||||
t = addDigit(t, rotor3.getIndex(), availableRotors.size());
|
|
||||||
t = addDigit(t, rotor2.getIndex(), availableRotors.size());
|
|
||||||
t = addDigit(t, rotor1.getIndex(), availableRotors.size());
|
|
||||||
t = addDigit(t, 11, 20); //Machine #11
|
|
||||||
|
|
||||||
return t.toString(16);
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
||||||
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
||||||
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
||||||
|
|
||||||
|
s = addDigit(s, 11, 20); //Machine #11
|
||||||
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class Plugboard
|
||||||
public static int[] stringToConfiguration(String in)
|
public static int[] stringToConfiguration(String in)
|
||||||
{
|
{
|
||||||
String pairs = trimString(new InputPreparer.RemoveIllegalCharacters().prepareString(in));
|
String pairs = trimString(new InputPreparer.RemoveIllegalCharacters().prepareString(in));
|
||||||
int[] out = empty;
|
int[] out = Arrays.copyOf(empty, empty.length);
|
||||||
//Check if in is too long or odd
|
//Check if in is too long or odd
|
||||||
int l = pairs.length();
|
int l = pairs.length();
|
||||||
if(l>1 && (pairs.length() > 26 || pairs.length()/2 == (pairs.length()-1)/2))
|
if(l>1 && (pairs.length() > 26 || pairs.length()/2 == (pairs.length()-1)/2))
|
||||||
|
|
|
@ -3,6 +3,7 @@ package de.vanitasvitae.enigmandroid.enigma.rotors;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import de.vanitasvitae.enigmandroid.MainActivity;
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
||||||
|
@ -152,7 +153,8 @@ public class Reflector
|
||||||
case 2: return new Reflector_C();
|
case 2: return new Reflector_C();
|
||||||
case 10: return new Reflector_Thin_B();
|
case 10: return new Reflector_Thin_B();
|
||||||
case 11: return new ReflectorThinC();
|
case 11: return new ReflectorThinC();
|
||||||
case 20: return new ReflectorEnigma_D_KD_G31();
|
case 20: return new ReflectorEnigma_D_G31();
|
||||||
|
case 21: return new ReflectorEnigma_KD();
|
||||||
case 30: return new Reflector_G312();
|
case 30: return new Reflector_G312();
|
||||||
case 40: return new Reflector_K_G260();
|
case 40: return new Reflector_K_G260();
|
||||||
case 50: return new Reflector_R();
|
case 50: return new Reflector_R();
|
||||||
|
@ -273,16 +275,30 @@ public class Reflector
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pluggable Reflector of the Enigma machine of name D and KD
|
* Pluggable Reflector of the Enigma machine of name D and G31
|
||||||
* Standard wiring: AI,BM,CE,DT,FG,HR,JY,KS,LQ,NZ,OX,PW,UV
|
* Standard wiring: AI,BM,CE,DT,FG,HR,JY,KS,LQ,NZ,OX,PW,UV
|
||||||
* Has additional ringSetting and can rotate
|
* Has additional ringSetting and can rotate
|
||||||
*/
|
*/
|
||||||
public static class ReflectorEnigma_D_KD_G31 extends Reflector
|
public static class ReflectorEnigma_D_G31 extends Reflector
|
||||||
{
|
{
|
||||||
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};
|
public static final int[] defaultWiring_D_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};
|
||||||
public ReflectorEnigma_D_KD_G31()
|
public ReflectorEnigma_D_G31()
|
||||||
{
|
{
|
||||||
super(20, "Ref-D", "Default: IMETCGFRAYSQBZXWLHKDVUPOJN", defaultWiring_D_KD_G31);
|
super(20, "Ref-D", "Default: IMETCGFRAYSQBZXWLHKDVUPOJN", Arrays.copyOf(defaultWiring_D_G31,defaultWiring_D_G31.length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pluggable Reflector as used in the Enigma of Type KD
|
||||||
|
* Standard wiring: KOTVPNLMJIAGHFBEWYXCZDQSRU
|
||||||
|
* Has additional ringSetting and can rotate
|
||||||
|
*/
|
||||||
|
public static class ReflectorEnigma_KD extends Reflector
|
||||||
|
{
|
||||||
|
public static final int[] defaultWiring_KD = {10,14,19,21,15,13,11,12,9,8,0,6,7,5,1,4,22,24,23,2,25,3,16,18,17,20};
|
||||||
|
public ReflectorEnigma_KD()
|
||||||
|
{
|
||||||
|
super(21, "Ref-KD", "Default: KOTVPNLMJIAGHFBEWYXCZDQSRU", Arrays.copyOf(defaultWiring_KD, defaultWiring_KD.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,26 +140,30 @@ public abstract class Rotor
|
||||||
case 51: return new Rotor_K_D_II(rotation, ringSetting);
|
case 51: return new Rotor_K_D_II(rotation, ringSetting);
|
||||||
case 52: return new Rotor_K_D_III(rotation, ringSetting);
|
case 52: return new Rotor_K_D_III(rotation, ringSetting);
|
||||||
|
|
||||||
case 60: return new Rotor_KSwiss_Standard_I(rotation, ringSetting);
|
case 60: return new Rotor_KD_I(rotation, ringSetting);
|
||||||
case 61: return new Rotor_KSwiss_Standard_II(rotation, ringSetting);
|
case 61: return new Rotor_KD_II(rotation, ringSetting);
|
||||||
case 62: return new Rotor_KSwiss_Standard_III(rotation, ringSetting);
|
case 62: return new Rotor_KD_III(rotation, ringSetting);
|
||||||
|
|
||||||
case 70: return new Rotor_K_Swiss_Airforce_I(rotation, ringSetting);
|
case 70: return new Rotor_KSwiss_Standard_I(rotation, ringSetting);
|
||||||
case 71: return new Rotor_K_Swiss_Airforce_II(rotation, ringSetting);
|
case 71: return new Rotor_KSwiss_Standard_II(rotation, ringSetting);
|
||||||
case 72: return new Rotor_K_Swiss_Airforce_III(rotation, ringSetting);
|
case 72: return new Rotor_KSwiss_Standard_III(rotation, ringSetting);
|
||||||
|
|
||||||
case 80: return new Rotor_R_I(rotation, ringSetting);
|
case 80: return new Rotor_K_Swiss_Airforce_I(rotation, ringSetting);
|
||||||
case 81: return new Rotor_R_II(rotation, ringSetting);
|
case 81: return new Rotor_K_Swiss_Airforce_II(rotation, ringSetting);
|
||||||
case 82: return new Rotor_R_III(rotation, ringSetting);
|
case 82: return new Rotor_K_Swiss_Airforce_III(rotation, ringSetting);
|
||||||
|
|
||||||
case 90: return new Rotor_T_I(rotation, ringSetting);
|
case 90: return new Rotor_R_I(rotation, ringSetting);
|
||||||
case 91: return new Rotor_T_II(rotation, ringSetting);
|
case 91: return new Rotor_R_II(rotation, ringSetting);
|
||||||
case 92: return new Rotor_T_III(rotation, ringSetting);
|
case 92: return new Rotor_R_III(rotation, ringSetting);
|
||||||
case 93: return new Rotor_T_IV(rotation, ringSetting);
|
|
||||||
case 94: return new Rotor_T_V(rotation, ringSetting);
|
case 100: return new Rotor_T_I(rotation, ringSetting);
|
||||||
case 95: return new Rotor_T_VI(rotation, ringSetting);
|
case 101: return new Rotor_T_II(rotation, ringSetting);
|
||||||
case 96: return new Rotor_T_VII(rotation, ringSetting);
|
case 102: return new Rotor_T_III(rotation, ringSetting);
|
||||||
case 97: return new Rotor_T_VIII(rotation, ringSetting);
|
case 103: return new Rotor_T_IV(rotation, ringSetting);
|
||||||
|
case 104: return new Rotor_T_V(rotation, ringSetting);
|
||||||
|
case 105: return new Rotor_T_VI(rotation, ringSetting);
|
||||||
|
case 106: return new Rotor_T_VII(rotation, ringSetting);
|
||||||
|
case 107: return new Rotor_T_VIII(rotation, ringSetting);
|
||||||
|
|
||||||
default: Log.e(MainActivity.APP_ID," Tried to create Rotor of invalid name "+type);
|
default: Log.e(MainActivity.APP_ID," Tried to create Rotor of invalid name "+type);
|
||||||
return null;
|
return null;
|
||||||
|
@ -707,6 +711,54 @@ public abstract class Rotor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotor I as used in the Enigma Type KD
|
||||||
|
* VEZIOJCXKYDUNTWAPLQGBHSFMR
|
||||||
|
* Turnover TVZBFIMOR
|
||||||
|
*/
|
||||||
|
public static class Rotor_KD_I extends Rotor
|
||||||
|
{
|
||||||
|
public Rotor_KD_I(int rotation, int ringSetting)
|
||||||
|
{
|
||||||
|
super(60, "KD-I", "VEZIOJCXKYDUNTWAPLQGBHSFMR",
|
||||||
|
new Integer[]{21,4,25,8,14,9,2,23,10,24,3,20,13,19,22,0,15,11,16,6,1,7,18,5,12,17},
|
||||||
|
new Integer[]{15,20,6,10,1,23,19,21,3,5,8,17,24,12,4,16,18,25,22,13,11,0,14,7,9,2},
|
||||||
|
new Integer[]{19,21,25,1,5,8,12,14,17}, ringSetting, rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotor II as used in the Enigma Type KD
|
||||||
|
* HGRBSJZETDLVPMQYCXAOKINFUW
|
||||||
|
* Turnover TVZBFIMOR
|
||||||
|
*/
|
||||||
|
public static class Rotor_KD_II extends Rotor
|
||||||
|
{
|
||||||
|
public Rotor_KD_II(int rotation, int ringSetting)
|
||||||
|
{
|
||||||
|
super(61, "KD-II", "HGRBSJZETDLVPMQYCXAOKINFUW",
|
||||||
|
new Integer[]{7,6,17,1,18,9,25,4,19,3,11,21,15,12,16,24,2,23,0,14,10,8,13,5,20,22},
|
||||||
|
new Integer[]{18,3,16,9,7,23,1,0,21,5,20,10,13,22,19,12,14,2,4,8,24,11,25,17,15,6},
|
||||||
|
new Integer[]{19,21,25,1,5,8,12,14,17}, ringSetting, rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotor III as used in the Enigma Type KD
|
||||||
|
* NWLHXGRBYOJSAZDVTPKFQMEUIC
|
||||||
|
* Turnover TVZBFIMOR
|
||||||
|
*/
|
||||||
|
public static class Rotor_KD_III extends Rotor
|
||||||
|
{
|
||||||
|
public Rotor_KD_III(int rotation, int ringSetting)
|
||||||
|
{
|
||||||
|
super(62, "KD-II", "NWLHXGRBYOJSAZDVTPKFQMEUIC",
|
||||||
|
new Integer[]{13,22,11,7,23,6,17,1,24,14,9,18,0,25,3,21,19,15,10,5,16,12,4,20,8,2},
|
||||||
|
new Integer[]{12,7,25,14,22,19,5,3,24,10,18,2,21,0,9,17,20,6,11,16,23,15,1,4,8,13},
|
||||||
|
new Integer[]{19,21,25,1,5,8,12,14,17}, ringSetting, rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotor I as used in the Enigma Type K (Switzerland)
|
* Rotor I as used in the Enigma Type K (Switzerland)
|
||||||
* P E Z U O H X S C V F M T B G L R I N Q J W A Y D K
|
* P E Z U O H X S C V F M T B G L R I N Q J W A Y D K
|
||||||
|
@ -716,7 +768,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_KSwiss_Standard_I(int rotation, int ringSetting)
|
public Rotor_KSwiss_Standard_I(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(60, "KS-I", "PEZUOHXSCVFMTBGLRINQJWAYDK",
|
super(70, "KS-I", "PEZUOHXSCVFMTBGLRINQJWAYDK",
|
||||||
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[]{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[]{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);
|
new Integer[]{25}, ringSetting, rotation);
|
||||||
|
@ -732,7 +784,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_KSwiss_Standard_II(int rotation, int ringSetting)
|
public Rotor_KSwiss_Standard_II(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(61, "KS-II", "ZOUESYDKFWPCIQXHMVBLGNJRAT",
|
super(71, "KS-II", "ZOUESYDKFWPCIQXHMVBLGNJRAT",
|
||||||
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[]{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[]{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);
|
new Integer[]{5}, ringSetting, rotation);
|
||||||
|
@ -748,7 +800,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_KSwiss_Standard_III(int rotation, int ringSetting)
|
public Rotor_KSwiss_Standard_III(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(62, "KS-III", "EHRVXGAOBQUSIMZFLYNWKTPDJC",
|
super(72, "KS-III", "EHRVXGAOBQUSIMZFLYNWKTPDJC",
|
||||||
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[]{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[]{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);
|
new Integer[]{14}, ringSetting, rotation);
|
||||||
|
@ -764,7 +816,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_K_Swiss_Airforce_I(int rotation, int ringSetting)
|
public Rotor_K_Swiss_Airforce_I(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(70, "KSA-I", "PEZUOHXSCVFMTBGLRINQJWAYDK",
|
super(80, "KSA-I", "PEZUOHXSCVFMTBGLRINQJWAYDK",
|
||||||
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[]{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[]{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);
|
new Integer[]{25}, ringSetting, rotation);
|
||||||
|
@ -779,7 +831,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_K_Swiss_Airforce_II(int rotation, int ringSetting)
|
public Rotor_K_Swiss_Airforce_II(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(71, "KSA-II", "ZOUESYDKFWPCIQXHMVBLGNJRAT",
|
super(81, "KSA-II", "ZOUESYDKFWPCIQXHMVBLGNJRAT",
|
||||||
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[]{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[]{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);
|
new Integer[]{5}, ringSetting, rotation);
|
||||||
|
@ -794,7 +846,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_K_Swiss_Airforce_III(int rotation, int ringSetting)
|
public Rotor_K_Swiss_Airforce_III(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(72, "KSA-III", "EHRVXGAOBQUSIMZFLYNWKTPDJC",
|
super(82, "KSA-III", "EHRVXGAOBQUSIMZFLYNWKTPDJC",
|
||||||
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[]{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[]{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);
|
new Integer[]{14}, ringSetting, rotation);
|
||||||
|
@ -810,7 +862,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_R_I(int rotation, int ringSetting)
|
public Rotor_R_I(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(80, "R-I", "JGDQOXUSCAMIFRVTPNEWKBLZYH",
|
super(90, "R-I", "JGDQOXUSCAMIFRVTPNEWKBLZYH",
|
||||||
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,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[]{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);
|
new Integer[]{14}, ringSetting, rotation);
|
||||||
|
@ -826,7 +878,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_R_II(int rotation, int ringSetting)
|
public Rotor_R_II(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(81, "R-II", "NTZPSFBOKMWRCJDIVLAEYUXHGQ",
|
super(91, "R-II", "NTZPSFBOKMWRCJDIVLAEYUXHGQ",
|
||||||
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[]{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[]{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);
|
new Integer[]{5}, ringSetting, rotation);
|
||||||
|
@ -842,7 +894,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_R_III(int rotation, int ringSetting)
|
public Rotor_R_III(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(82, "R-III", "JVIUBHTCDYAKEQZPOSGXNRMWFL",
|
super(92, "R-III", "JVIUBHTCDYAKEQZPOSGXNRMWFL",
|
||||||
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[]{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[]{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);
|
new Integer[]{25}, ringSetting, rotation);
|
||||||
|
@ -858,7 +910,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_I(int rotation, int ringSetting)
|
public Rotor_T_I(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(90, "T-I", "KPTYUELOCVGRFQDANJMBSWHZXI",
|
super(100, "T-I", "KPTYUELOCVGRFQDANJMBSWHZXI",
|
||||||
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[]{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[]{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);
|
new Integer[]{23,0,5,11,17}, ringSetting, rotation);
|
||||||
|
@ -874,7 +926,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_II(int rotation, int ringSetting)
|
public Rotor_T_II(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(91, "T-II", "UPHZLWEQMTDJXCAKSOIGVBYFNR",
|
super(101, "T-II", "UPHZLWEQMTDJXCAKSOIGVBYFNR",
|
||||||
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[]{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[]{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);
|
new Integer[]{23,0,6,12,18}, ringSetting, rotation);
|
||||||
|
@ -889,7 +941,7 @@ public abstract class Rotor
|
||||||
public static class Rotor_T_III extends Rotor
|
public static class Rotor_T_III extends Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_III(int rotation, int ringSetting) {
|
public Rotor_T_III(int rotation, int ringSetting) {
|
||||||
super(92, "T-III", "QUDLYRFEKONVZAXWHMGPJBSICT",
|
super(102, "T-III", "QUDLYRFEKONVZAXWHMGPJBSICT",
|
||||||
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[]{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[]{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);
|
new Integer[]{23,0,5,11,17}, ringSetting, rotation);
|
||||||
|
@ -905,7 +957,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_IV(int rotation, int ringSetting)
|
public Rotor_T_IV(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(93, "T-IV", "CIWTBKXNRESPFLYDAGVHQUOJZM",
|
super(103, "T-IV", "CIWTBKXNRESPFLYDAGVHQUOJZM",
|
||||||
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[]{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[]{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);
|
new Integer[]{23,0,6,12,18}, ringSetting, rotation);
|
||||||
|
@ -921,7 +973,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_V(int rotation, int ringSetting)
|
public Rotor_T_V(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(94, "T-V", "UAXGISNJBVERDYLFZWTPCKOHMQ",
|
super(104, "T-V", "UAXGISNJBVERDYLFZWTPCKOHMQ",
|
||||||
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[]{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[]{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);
|
new Integer[]{25,3,6,11,18}, ringSetting, rotation);
|
||||||
|
@ -937,7 +989,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_VI(int rotation, int ringSetting)
|
public Rotor_T_VI(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(95, "T-VI", "XFUZGALVHCNYSEWQTDMRBKPIOJ",
|
super(105, "T-VI", "XFUZGALVHCNYSEWQTDMRBKPIOJ",
|
||||||
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[]{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[]{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);
|
new Integer[]{24,5,9,13,17}, ringSetting, rotation);
|
||||||
|
@ -953,7 +1005,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_VII(int rotation, int ringSetting)
|
public Rotor_T_VII(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(96, "T-VII", "BJVFTXPLNAYOZIKWGDQERUCHSM",
|
super(106, "T-VII", "BJVFTXPLNAYOZIKWGDQERUCHSM",
|
||||||
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[]{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[]{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);
|
new Integer[]{25,3,6,11,18}, ringSetting, rotation);
|
||||||
|
@ -969,7 +1021,7 @@ public abstract class Rotor
|
||||||
{
|
{
|
||||||
public Rotor_T_VIII(int rotation, int ringSetting)
|
public Rotor_T_VIII(int rotation, int ringSetting)
|
||||||
{
|
{
|
||||||
super(97, "T-VIII", "YMTPNZHWKODAJXELUQVGCBISFR",
|
super(107, "T-VIII", "YMTPNZHWKODAJXELUQVGCBISFR",
|
||||||
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[]{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[]{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);
|
new Integer[]{24,5,9,13,17}, ringSetting, rotation);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package de.vanitasvitae.enigmandroid.layout;
|
package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
@ -44,7 +46,7 @@ public abstract class LayoutContainer
|
||||||
protected MainActivity main;
|
protected MainActivity main;
|
||||||
|
|
||||||
public abstract Enigma getEnigma();
|
public abstract Enigma getEnigma();
|
||||||
protected abstract void initializeLayout();
|
protected abstract void assembleLayout();
|
||||||
public abstract void resetLayout();
|
public abstract void resetLayout();
|
||||||
public abstract void setLayoutState(EnigmaStateBundle state);
|
public abstract void setLayoutState(EnigmaStateBundle state);
|
||||||
public abstract void syncStateFromLayoutToEnigma();
|
public abstract void syncStateFromLayoutToEnigma();
|
||||||
|
@ -57,12 +59,16 @@ public abstract class LayoutContainer
|
||||||
public LayoutContainer()
|
public LayoutContainer()
|
||||||
{
|
{
|
||||||
main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
|
main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
|
||||||
|
setEnigmaLayout();
|
||||||
this.inputView = (EditText) main.findViewById(R.id.input);
|
this.inputView = (EditText) main.findViewById(R.id.input);
|
||||||
this.outputView = (EditText) main.findViewById(R.id.output);
|
this.outputView = (EditText) main.findViewById(R.id.output);
|
||||||
input = EditTextAdapter.createEditTextAdapter(inputView, main.getPrefMessageFormatting());
|
input = EditTextAdapter.createEditTextAdapter(inputView,
|
||||||
output = EditTextAdapter.createEditTextAdapter(outputView, main.getPrefMessageFormatting());
|
SettingsActivity.SettingsSingleton.getInstance().getPrefMessageFormatting());
|
||||||
|
output = EditTextAdapter.createEditTextAdapter(outputView,
|
||||||
|
SettingsActivity.SettingsSingleton.getInstance().getPrefMessageFormatting());
|
||||||
inputPreparer = InputPreparer.createInputPreparer();
|
inputPreparer = InputPreparer.createInputPreparer();
|
||||||
initializeLayout();
|
assembleLayout();
|
||||||
|
finishLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doCrypto()
|
public void doCrypto()
|
||||||
|
@ -120,6 +126,8 @@ public abstract class LayoutContainer
|
||||||
return new LayoutContainer_G312();
|
return new LayoutContainer_G312();
|
||||||
case "G260":
|
case "G260":
|
||||||
return new LayoutContainer_G260();
|
return new LayoutContainer_G260();
|
||||||
|
case "KD":
|
||||||
|
return new LayoutContainer_KD();
|
||||||
default:
|
default:
|
||||||
return new LayoutContainer_I();
|
return new LayoutContainer_I();
|
||||||
}
|
}
|
||||||
|
@ -168,5 +176,17 @@ public abstract class LayoutContainer
|
||||||
output = EditTextAdapter.createEditTextAdapter(outputView, type);
|
output = EditTextAdapter.createEditTextAdapter(outputView, type);
|
||||||
output.setText(out);
|
output.setText(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setMainActivityLayout()
|
||||||
|
{
|
||||||
|
setEnigmaLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected void setEnigmaLayout();
|
||||||
|
|
||||||
|
private void finishLayout()
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma_D;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma_D;
|
||||||
|
@ -40,13 +41,18 @@ public class LayoutContainer_D extends LayoutContainer
|
||||||
public LayoutContainer_D()
|
public LayoutContainer_D()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_d);
|
|
||||||
main.setTitle("D - EnigmAndroid");
|
main.setTitle("D - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout()
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void assembleLayout()
|
||||||
{
|
{
|
||||||
this.rotor1PositionView = (Spinner) main.findViewById(R.id.rotor1position);
|
this.rotor1PositionView = (Spinner) main.findViewById(R.id.rotor1position);
|
||||||
this.rotor2PositionView = (Spinner) main.findViewById(R.id.rotor2position);
|
this.rotor2PositionView = (Spinner) main.findViewById(R.id.rotor2position);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.vanitasvitae.enigmandroid.layout;
|
package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma_G260;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma_G260;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
|
@ -43,18 +44,23 @@ public class LayoutContainer_G31 extends LayoutContainer
|
||||||
public LayoutContainer_G31()
|
public LayoutContainer_G31()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_g_k_r_t);
|
|
||||||
main.setTitle("G31 - EnigmAndroid");
|
main.setTitle("G31 - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_g_k_r_t);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enigma getEnigma() {
|
public Enigma getEnigma() {
|
||||||
return this.enigma;
|
return this.enigma;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout() {
|
protected void assembleLayout() {
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma_I;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma_I;
|
||||||
|
@ -43,13 +44,18 @@ public class LayoutContainer_I extends LayoutContainer
|
||||||
public LayoutContainer_I()
|
public LayoutContainer_I()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_i_m3);
|
|
||||||
main.setTitle("I - EnigmAndroid");
|
main.setTitle("I - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout()
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_i_m3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void assembleLayout()
|
||||||
{
|
{
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
|
@ -43,18 +44,23 @@ public class LayoutContainer_K extends LayoutContainer
|
||||||
public LayoutContainer_K()
|
public LayoutContainer_K()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_g_k_r_t);
|
|
||||||
main.setTitle("K - EnigmAndroid");
|
main.setTitle("K - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_g_k_r_t);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enigma getEnigma() {
|
public Enigma getEnigma() {
|
||||||
return this.enigma;
|
return this.enigma;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout() {
|
protected void assembleLayout() {
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
|
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
||||||
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
|
import de.vanitasvitae.enigmandroid.enigma.Enigma_KD;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LayoutContainer for the Enigma Model K
|
||||||
|
* This class contains the layout and controls the layout elements such as spinners and stuff
|
||||||
|
* 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.
|
||||||
|
* @author vanitasvitae
|
||||||
|
*/
|
||||||
|
public class LayoutContainer_KD extends LayoutContainer
|
||||||
|
{
|
||||||
|
protected Enigma enigma;
|
||||||
|
|
||||||
|
protected Spinner rotor1View;
|
||||||
|
protected Spinner rotor2View;
|
||||||
|
protected Spinner rotor3View;
|
||||||
|
|
||||||
|
protected Spinner rotor1PositionView;
|
||||||
|
protected Spinner rotor2PositionView;
|
||||||
|
protected Spinner rotor3PositionView;
|
||||||
|
protected Spinner reflectorPositionView;
|
||||||
|
|
||||||
|
public LayoutContainer_KD()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
main.setTitle("KD - EnigmAndroid");
|
||||||
|
this.resetLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_kd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Enigma getEnigma() {
|
||||||
|
return this.enigma;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void assembleLayout() {
|
||||||
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
|
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
||||||
|
this.rotor1PositionView = (Spinner) main.findViewById(R.id.rotor1position);
|
||||||
|
this.rotor2PositionView = (Spinner) main.findViewById(R.id.rotor2position);
|
||||||
|
this.rotor3PositionView = (Spinner) main.findViewById(R.id.rotor3position);
|
||||||
|
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
|
||||||
|
Button reflectorWiring = (Button) main.findViewById(R.id.button_reflector);
|
||||||
|
reflectorWiring.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
new PluggableDialogBuilder(getEnigma().getState()).showDialogReflector();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Character[] rotorPositionArray = new Character[26];
|
||||||
|
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
|
||||||
|
|
||||||
|
prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
|
||||||
|
prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
|
||||||
|
prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
|
||||||
|
|
||||||
|
prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
|
||||||
|
prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
|
||||||
|
prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
|
||||||
|
prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetLayout() {
|
||||||
|
enigma = new Enigma_KD();
|
||||||
|
setLayoutState(enigma.getState());
|
||||||
|
output.setText("");
|
||||||
|
input.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLayoutState(EnigmaStateBundle state)
|
||||||
|
{
|
||||||
|
this.rotor1View.setSelection(state.getTypeRotor1());
|
||||||
|
this.rotor2View.setSelection(state.getTypeRotor2());
|
||||||
|
this.rotor3View.setSelection(state.getTypeRotor3());
|
||||||
|
this.rotor1PositionView.setSelection(state.getRotationRotor1());
|
||||||
|
this.rotor2PositionView.setSelection(state.getRotationRotor2());
|
||||||
|
this.rotor3PositionView.setSelection(state.getRotationRotor3());
|
||||||
|
this.reflectorPositionView.setSelection(state.getRotationReflector());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void syncStateFromLayoutToEnigma()
|
||||||
|
{
|
||||||
|
EnigmaStateBundle state = getEnigma().getState();
|
||||||
|
state.setTypeRotor1(rotor1View.getSelectedItemPosition());
|
||||||
|
state.setTypeRotor2(rotor2View.getSelectedItemPosition());
|
||||||
|
state.setTypeRotor3(rotor3View.getSelectedItemPosition());
|
||||||
|
state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition());
|
||||||
|
state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition());
|
||||||
|
state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition());
|
||||||
|
state.setRotationReflector(reflectorPositionView.getSelectedItemPosition());
|
||||||
|
getEnigma().setState(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showRingSettingsDialog()
|
||||||
|
{
|
||||||
|
new RingSettingsDialogBuilder.RingSettingsDialogBuilderRotRotRotRef().
|
||||||
|
createRingSettingsDialog(getEnigma().getState());
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,7 +40,7 @@ public class LayoutContainer_M3 extends LayoutContainer_I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout()
|
protected void assembleLayout()
|
||||||
{
|
{
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma_M4;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma_M4;
|
||||||
|
@ -45,11 +46,15 @@ public class LayoutContainer_M4 extends LayoutContainer
|
||||||
public LayoutContainer_M4()
|
public LayoutContainer_M4()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_m4);
|
|
||||||
main.setTitle("M4 - EnigmAndroid");
|
main.setTitle("M4 - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_m4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Enigma_M4 getEnigma()
|
public Enigma_M4 getEnigma()
|
||||||
|
@ -58,7 +63,7 @@ public class LayoutContainer_M4 extends LayoutContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout() {
|
protected void assembleLayout() {
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
||||||
|
@ -69,7 +74,7 @@ public class LayoutContainer_M4 extends LayoutContainer
|
||||||
this.rotor4PositionView = (Spinner) main.findViewById(R.id.thin_rotor_position);
|
this.rotor4PositionView = (Spinner) main.findViewById(R.id.thin_rotor_position);
|
||||||
this.reflectorView = (Spinner) main.findViewById(R.id.reflector);
|
this.reflectorView = (Spinner) main.findViewById(R.id.reflector);
|
||||||
Button setPlugboardButton = (Button) main.findViewById(R.id.button_plugboard);
|
Button setPlugboardButton = (Button) main.findViewById(R.id.button_plugboard);
|
||||||
setPlugboardButton.setOnClickListener(new View.OnClickListener() {
|
if(setPlugboardButton != null) setPlugboardButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
new PluggableDialogBuilder(getEnigma().getState()).showDialogPlugboard();
|
new PluggableDialogBuilder(getEnigma().getState()).showDialogPlugboard();
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
|
@ -43,18 +44,23 @@ public class LayoutContainer_R extends LayoutContainer
|
||||||
public LayoutContainer_R()
|
public LayoutContainer_R()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_g_k_r_t);
|
|
||||||
main.setTitle("R - EnigmAndroid");
|
main.setTitle("R - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_g_k_r_t);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enigma getEnigma() {
|
public Enigma getEnigma() {
|
||||||
return this.enigma;
|
return this.enigma;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout() {
|
protected void assembleLayout() {
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.vanitasvitae.enigmandroid.layout;
|
||||||
|
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
||||||
import de.vanitasvitae.enigmandroid.R;
|
import de.vanitasvitae.enigmandroid.R;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
import de.vanitasvitae.enigmandroid.enigma.Enigma;
|
||||||
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
||||||
|
@ -43,7 +44,6 @@ public class LayoutContainer_T extends LayoutContainer
|
||||||
public LayoutContainer_T()
|
public LayoutContainer_T()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
main.setContentView(R.layout.activity_main_g_k_r_t);
|
|
||||||
main.setTitle("T - EnigmAndroid");
|
main.setTitle("T - EnigmAndroid");
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,20 @@ public class LayoutContainer_T extends LayoutContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setEnigmaLayout()
|
||||||
|
{
|
||||||
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(
|
||||||
|
R.layout.activity_main_g_k_r_t);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enigma getEnigma() {
|
public Enigma getEnigma() {
|
||||||
return this.enigma;
|
return this.enigma;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeLayout() {
|
protected void assembleLayout() {
|
||||||
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
this.rotor1View = (Spinner) main.findViewById(R.id.rotor1);
|
||||||
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
this.rotor2View = (Spinner) main.findViewById(R.id.rotor2);
|
||||||
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
this.rotor3View = (Spinner) main.findViewById(R.id.rotor3);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class PassphraseDialogBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(main);
|
AlertDialog.Builder builder = new AlertDialog.Builder(main);
|
||||||
builder.setTitle(R.string.hint_passphrase);
|
builder.setTitle(R.string.hint_configuration);
|
||||||
Dialog d = builder.setView(passphraseDialogView)
|
Dialog d = builder.setView(passphraseDialogView)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.dialog_positive, new DialogInterface.OnClickListener()
|
.setPositiveButton(R.string.dialog_positive, new DialogInterface.OnClickListener()
|
||||||
|
@ -89,7 +89,7 @@ public class PassphraseDialogBuilder
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
main.createStateFromSeed(pass);
|
main.applyStateFromSeed(pass);
|
||||||
String message = String.format(main.getResources().getString(
|
String message = String.format(main.getResources().getString(
|
||||||
R.string.dialog_passphrase_set), " \'"+pass+"\'");
|
R.string.dialog_passphrase_set), " \'"+pass+"\'");
|
||||||
Toast.makeText(main, message, Toast.LENGTH_LONG).show();
|
Toast.makeText(main, message, Toast.LENGTH_LONG).show();
|
||||||
|
|
170
app/src/main/res/layout/activity_main_kd.xml
Executable file
170
app/src/main/res/layout/activity_main_kd.xml
Executable file
|
@ -0,0 +1,170 @@
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/lin_lay_names_1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_rotor3"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_rotor2"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_rotor1"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/lin_lay_1"
|
||||||
|
android:layout_below="@+id/lin_lay_names_1">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/rotor3">
|
||||||
|
</Spinner>
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/rotor2">
|
||||||
|
</Spinner>
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/rotor1">
|
||||||
|
</Spinner>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_below="@+id/lin_lay_1"
|
||||||
|
android:id="@+id/lin_lay_names_2">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_reflector_position"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_rotor3_position"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_rotor2_position"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/hint_rotor1_position"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/lin_lay_2"
|
||||||
|
android:layout_below="@+id/lin_lay_names_2">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/reflector_position">
|
||||||
|
</Spinner>
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/rotor3position">
|
||||||
|
</Spinner>
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/rotor2position">
|
||||||
|
</Spinner>
|
||||||
|
<Spinner
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/rotor1position">
|
||||||
|
</Spinner>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/lin_lay_2"
|
||||||
|
android:layout_above="@+id/buttons_lay"
|
||||||
|
android:id="@+id/text_layer">
|
||||||
|
<EditText
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight=".50"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/input"
|
||||||
|
android:inputType="textNoSuggestions|textMultiLine"
|
||||||
|
android:hint="@string/hint_enigma_type_here" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight=".50"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:inputType="none"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:id="@+id/output"
|
||||||
|
android:hint="@string/hint_enigma_code"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/buttons_lay"
|
||||||
|
android:layout_alignParentBottom="true">
|
||||||
|
<Button
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/button_reflector"
|
||||||
|
android:text="@string/hint_enigma_reflector_wiring"
|
||||||
|
tools:ignore="ButtonStyle"/>
|
||||||
|
<Button
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/button_crypt"
|
||||||
|
android:onClick="doCrypto"
|
||||||
|
android:text="@string/button_crypt"
|
||||||
|
android:background="@drawable/button_orange"
|
||||||
|
tools:ignore="ButtonStyle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -7,6 +7,6 @@
|
||||||
<EditText
|
<EditText
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/hint_passphrase"
|
android:hint="@string/hint_configuration"
|
||||||
android:id="@+id/passphrase"/>
|
android:id="@+id/passphrase"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
17
app/src/main/res/layout/dialog_two_options.xml
Normal file
17
app/src/main/res/layout/dialog_two_options.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/dialog_two_options_lay">
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/dialog_two_options_1"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/dialog_two_options_2"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
23
app/src/main/res/layout/dialog_whats_new.xml
Executable file
23
app/src/main/res/layout/dialog_whats_new.xml
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
<ScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Medium"
|
||||||
|
android:id="@+id/dialog_whats_new_header"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Small"
|
||||||
|
android:id="@+id/dialog_whats_new_details"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
|
@ -4,33 +4,28 @@
|
||||||
|
|
||||||
<!-- RESET -->
|
<!-- RESET -->
|
||||||
<item android:id="@+id/action_reset"
|
<item android:id="@+id/action_reset"
|
||||||
android:orderInCategory="95"
|
android:orderInCategory="96"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/action_reset" />
|
android:title="@string/action_reset" />
|
||||||
<!-- SEND -->
|
<!-- SEND -->
|
||||||
<item android:id="@+id/action_send"
|
<item android:id="@+id/action_send_message"
|
||||||
android:orderInCategory="96"
|
android:orderInCategory="97"
|
||||||
android:showAsAction="always"
|
android:showAsAction="always"
|
||||||
android:title="@string/action_send"
|
android:title="@string/action_send"
|
||||||
android:icon="@drawable/ic_send_white_48dp"/>
|
android:icon="@drawable/ic_send_white_48dp"/>
|
||||||
<!-- RINGSETTING -->
|
<!-- RINGSETTING -->
|
||||||
<item android:id="@+id/action_choose_ringsetting"
|
<item android:id="@+id/action_choose_ringsetting"
|
||||||
android:title="@string/action_choose_ring_settings"
|
android:title="@string/action_choose_ring_settings"
|
||||||
android:orderInCategory="97"
|
android:orderInCategory="98"
|
||||||
android:showAsAction="ifRoom" />
|
android:showAsAction="ifRoom" />
|
||||||
<!-- ENTER SEED -->
|
<!-- SHARE CONFIGURATION -->
|
||||||
<item android:id="@+id/action_enter_seed"
|
<item android:id="@+id/action_share_configuration"
|
||||||
android:title="@string/action_read_passphrase"
|
android:title="@string/action_share_configuration"
|
||||||
android:showAsAction="ifRoom"
|
|
||||||
android:orderInCategory="98" />
|
|
||||||
<!-- RECEIVE QR -->
|
|
||||||
<item android:id="@+id/action_receive_scan"
|
|
||||||
android:title="@string/action_read_qr"
|
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:orderInCategory="99" />
|
android:orderInCategory="99" />
|
||||||
<!-- SHARE QR -->
|
<!-- RESTORE CONFIGURATION FROM QR OR ENTER SEED-->
|
||||||
<item android:id="@+id/action_share_scan"
|
<item android:id="@+id/action_restore_configuration"
|
||||||
android:title="@string/action_send_qr"
|
android:title="@string/action_restore_configuration"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:orderInCategory="100" />
|
android:orderInCategory="100" />
|
||||||
<!-- RANDOM -->
|
<!-- RANDOM -->
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
<string name="action_version">Version</string>
|
<string name="action_version">Version</string>
|
||||||
<string name="action_reset">Zurücksetzen</string>
|
<string name="action_reset">Zurücksetzen</string>
|
||||||
<string name="action_random">Zufällige Konfiguration</string>
|
<string name="action_random">Zufällige Konfiguration</string>
|
||||||
<string name="action_read_qr">Lese Konfiguration aus QR-Code</string>
|
<string name="action_restore_configuration">Konfiguration wiederherstellen</string>
|
||||||
<string name="action_send_qr">Teile Konfiguration per QR-Code</string>
|
<string name="action_share_configuration">Konfiguration teilen</string>
|
||||||
<string name="action_read_passphrase">Konfiguration aus Schlüsselwort</string>
|
|
||||||
<string name="action_settings">Einstellungen</string>
|
<string name="action_settings">Einstellungen</string>
|
||||||
<string name="action_choose_ring_settings">Ringstellung</string>
|
<string name="action_choose_ring_settings">Ringstellung</string>
|
||||||
<string name="action_send">Senden</string>
|
<string name="action_send">Senden</string>
|
||||||
|
@ -25,15 +24,23 @@
|
||||||
<string name="hint_reflector_position">Position\nUmkehr-\nWalze</string>
|
<string name="hint_reflector_position">Position\nUmkehr-\nWalze</string>
|
||||||
<string name="hint_thin_rotor_position">Position\nWalze 4</string>
|
<string name="hint_thin_rotor_position">Position\nWalze 4</string>
|
||||||
<string name="hint_enigma_reflector_wiring">Verkabelung Umkehrwalze</string>
|
<string name="hint_enigma_reflector_wiring">Verkabelung Umkehrwalze</string>
|
||||||
<string name="hint_passphrase">Schlüsselwort eingeben</string>
|
<string name="hint_configuration">Schlüsselwort/Konfiguration</string>
|
||||||
<string name="button_crypt">Ver-/Entschlüsseln</string>
|
<string name="button_crypt">Ver-/Entschlüsseln</string>
|
||||||
<string name="error_no_text_to_send">Nachricht ist leer.</string>
|
<string name="error_no_text_to_send">Nachricht ist leer.</string>
|
||||||
<string name="error_no_valid_qr">Fehler: Kein korrekter EnigmAndroid QR-Code!</string>
|
<string name="error_no_valid_qr">Fehler: Kein korrekter EnigmAndroid QR-Code!</string>
|
||||||
<string name="title_ring_setting">Ringstellungen</string>
|
<string name="title_ring_setting">Ringstellungen</string>
|
||||||
|
|
||||||
<string name="title_plugboard_dialog">Steckbrett-\nVerbindungen</string>
|
<string name="title_plugboard_dialog">Steckbrett-\nVerbindungen</string>
|
||||||
<string name="title_reflector_dialog">Verkabelung Umkehrwalze</string>
|
<string name="title_reflector_dialog">Verkabelung Umkehrwalze</string>
|
||||||
|
|
||||||
<string name="dialog_positive">OK</string>
|
<string name="dialog_positive">OK</string>
|
||||||
<string name="dialog_negative">Abbrechen</string>
|
<string name="dialog_negative">Abbrechen</string>
|
||||||
|
<string name="dialog_title_restore_configuration">Konfiguration wiederherstellen…</string>
|
||||||
|
<string name="dialog_restore_code">…aus Text/Schlüsselwort</string>
|
||||||
|
<string name="dialog_restore_qr">…aus QR-code</string>
|
||||||
|
<string name="dialog_title_share_configuration">Konfiguration teilen…</string>
|
||||||
|
<string name="dialog_share_qr">…per QR-code</string>
|
||||||
|
<string name="dialog_share_code">…als kodierten Text</string>
|
||||||
<string name="dialog_ring_settings_success">Setze Ringe auf %1$s.</string>
|
<string name="dialog_ring_settings_success">Setze Ringe auf %1$s.</string>
|
||||||
<string name="dialog_reflector_set">Umkehrwalze verkabelt.</string>
|
<string name="dialog_reflector_set">Umkehrwalze verkabelt.</string>
|
||||||
<string name="dialog_plugboard_set">Steckbrettverbindungen gesetzt.</string>
|
<string name="dialog_plugboard_set">Steckbrettverbindungen gesetzt.</string>
|
||||||
|
@ -42,5 +49,7 @@
|
||||||
<string name="dialog_abort">Keine Änderungen.</string>
|
<string name="dialog_abort">Keine Änderungen.</string>
|
||||||
<string name="message_reset">Enigma zurückgesetzt.</string>
|
<string name="message_reset">Enigma zurückgesetzt.</string>
|
||||||
<string name="message_random">Enigma auf zufällige Konfiguration gesetzt.</string>
|
<string name="message_random">Enigma auf zufällige Konfiguration gesetzt.</string>
|
||||||
|
<string name="dialog_whats_new_title">Was ist neu?</string>
|
||||||
|
<string name="message_clipboard">In Zwischenablage kopiert</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -14,11 +14,12 @@
|
||||||
<item>K</item>
|
<item>K</item>
|
||||||
<item>Swiss-K (Schweiz)</item>
|
<item>Swiss-K (Schweiz)</item>
|
||||||
<item>Swiss-K (Schweiz, Luftwaffe)</item>
|
<item>Swiss-K (Schweiz, Luftwaffe)</item>
|
||||||
|
<item>KD</item>
|
||||||
<item>R (\"Rocket\", Reichsbahn)</item>
|
<item>R (\"Rocket\", Reichsbahn)</item>
|
||||||
<item>T (\"Tirpitz\", Japan)</item>
|
<item>T (\"Tirpitz\", Japan)</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="pref_header_input_preparation">Eingabe Vorbereitung</string>
|
<string name="pref_header_input_preparation">Klartextvorbereitung</string>
|
||||||
<string name="pref_title_numeric_spelling_language">Zahlenbuchstabiersprache</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 name="pref_description_numeric_spelling_language">Sprache in der Zahlen buchstabiert werden sollen.</string>
|
||||||
<string-array name="pref_list_numeric_spelling_language">
|
<string-array name="pref_list_numeric_spelling_language">
|
||||||
|
|
10
app/src/main/res/values/dialog_whats_new.xml
Normal file
10
app/src/main/res/values/dialog_whats_new.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<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 is some information about the release\n
|
||||||
|
- Please send me a mail, if you read this, because I probably forgot to change this :)\n
|
||||||
|
- lol\n
|
||||||
|
</string>
|
||||||
|
</resources>
|
|
@ -4,9 +4,8 @@
|
||||||
<string name="action_version">Version</string>
|
<string name="action_version">Version</string>
|
||||||
<string name="action_reset">Reset</string>
|
<string name="action_reset">Reset</string>
|
||||||
<string name="action_random">Random configuration</string>
|
<string name="action_random">Random configuration</string>
|
||||||
<string name="action_read_qr">Read configuration from QR-Code</string>
|
<string name="action_restore_configuration">Restore configuration</string>
|
||||||
<string name="action_send_qr">Share configuration via QR-Code</string>
|
<string name="action_share_configuration">Share configuration</string>
|
||||||
<string name="action_read_passphrase">Create configuration from passphrase</string>
|
|
||||||
<string name="action_choose_ring_settings">Ring-Settings</string>
|
<string name="action_choose_ring_settings">Ring-Settings</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="action_send">Send</string>
|
<string name="action_send">Send</string>
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
<string name="hint_reflector_position">Position\nReflector</string>
|
<string name="hint_reflector_position">Position\nReflector</string>
|
||||||
<string name="hint_thin_rotor_position">Position\nRotor 4</string>
|
<string name="hint_thin_rotor_position">Position\nRotor 4</string>
|
||||||
<string name="hint_enigma_reflector_wiring">Wiring Reflector</string>
|
<string name="hint_enigma_reflector_wiring">Wiring Reflector</string>
|
||||||
<string name="hint_passphrase">Enter passphrase</string>
|
<string name="hint_configuration">Passphrase/Configuration</string>
|
||||||
<string name="button_crypt">En-/Decrypt!</string>
|
<string name="button_crypt">En-/Decrypt!</string>
|
||||||
<string name="error_no_text_to_send">Can\'t send empty text.</string>
|
<string name="error_no_text_to_send">Can\'t send empty text.</string>
|
||||||
<string name="error_no_valid_qr">Error: Not a valid EnigmAndroid QR-Code!</string>
|
<string name="error_no_valid_qr">Error: Not a valid EnigmAndroid QR-Code!</string>
|
||||||
|
@ -33,6 +32,12 @@
|
||||||
<string name="title_reflector_dialog">Reflector Wiring</string>
|
<string name="title_reflector_dialog">Reflector Wiring</string>
|
||||||
<string name="dialog_positive">OK</string>
|
<string name="dialog_positive">OK</string>
|
||||||
<string name="dialog_negative">Cancel</string>
|
<string name="dialog_negative">Cancel</string>
|
||||||
|
<string name="dialog_title_restore_configuration">Restore configuration…</string>
|
||||||
|
<string name="dialog_restore_code">…from text</string>
|
||||||
|
<string name="dialog_restore_qr">…from QR-code</string>
|
||||||
|
<string name="dialog_title_share_configuration">Share configuration…</string>
|
||||||
|
<string name="dialog_share_qr">…as QR-code</string>
|
||||||
|
<string name="dialog_share_code">…encoded in text</string>
|
||||||
<string name="dialog_ring_settings_success">Set Ring-Settings to %1$s.</string>
|
<string name="dialog_ring_settings_success">Set Ring-Settings to %1$s.</string>
|
||||||
<string name="dialog_reflector_set">Rewired Reflector.</string>
|
<string name="dialog_reflector_set">Rewired Reflector.</string>
|
||||||
<string name="dialog_plugboard_set">Set Plugboard configuration.</string>
|
<string name="dialog_plugboard_set">Set Plugboard configuration.</string>
|
||||||
|
@ -41,8 +46,9 @@
|
||||||
<string name="dialog_abort">No changes.</string>
|
<string name="dialog_abort">No changes.</string>
|
||||||
<string name="message_reset">Enigma reset.</string>
|
<string name="message_reset">Enigma reset.</string>
|
||||||
<string name="message_random">Enigma set to random configuration.</string>
|
<string name="message_random">Enigma set to random configuration.</string>
|
||||||
|
<string name="message_clipboard">Copied to clipboard</string>
|
||||||
|
|
||||||
<string name="button_plug_title">%1$s:%2$s</string>
|
<string translatable="false" name="button_plug_title">%1$s:%2$s</string>
|
||||||
|
|
||||||
<string-array translatable="false" name="rotors_1_3">
|
<string-array translatable="false" name="rotors_1_3">
|
||||||
<item>I</item>
|
<item>I</item>
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<item>K</item>
|
<item>K</item>
|
||||||
<item>Swiss-K</item>
|
<item>Swiss-K</item>
|
||||||
<item>Swiss-K (Airforce)</item>
|
<item>Swiss-K (Airforce)</item>
|
||||||
|
<item>KD</item>
|
||||||
<item>R (\"Rocket\", Railway)</item>
|
<item>R (\"Rocket\", Railway)</item>
|
||||||
<item>T (\"Tirpitz\", Japan)</item>
|
<item>T (\"Tirpitz\", Japan)</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
<item>K</item>
|
<item>K</item>
|
||||||
<item>KS</item>
|
<item>KS</item>
|
||||||
<item>KSA</item>
|
<item>KSA</item>
|
||||||
|
<item>KD</item>
|
||||||
<item>R</item>
|
<item>R</item>
|
||||||
<item>T</item>
|
<item>T</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
Loading…
Reference in a new issue