mirror of
https://github.com/vanitasvitae/EnigmAndroid.git
synced 2024-12-22 10:57:59 +01:00
First ever commit of all projectfiles
This commit is contained in:
commit
f678a239ed
44 changed files with 1723 additions and 0 deletions
1
.idea/.name
Normal file
1
.idea/.name
Normal file
|
@ -0,0 +1 @@
|
|||
EnigmAndroid
|
23
.idea/compiler.xml
Normal file
23
.idea/compiler.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
|
3
.idea/copyright/profiles_settings.xml
Normal file
3
.idea/copyright/profiles_settings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
7
.idea/dictionaries/vanitas.xml
Normal file
7
.idea/dictionaries/vanitas.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="vanitas">
|
||||
<words>
|
||||
<w>plugboard</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
5
.idea/encodings.xml
Normal file
5
.idea/encodings.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||
</project>
|
||||
|
18
.idea/gradle.xml
Normal file
18
.idea/gradle.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
26
.idea/misc.xml
Normal file
26
.idea/misc.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>Android API 19 Platform</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
||||
|
10
.idea/modules.xml
Normal file
10
.idea/modules.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/EnigmAndroid.iml" filepath="$PROJECT_DIR$/EnigmAndroid.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
5
.idea/scopes/scope_settings.xml
Normal file
5
.idea/scopes/scope_settings.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<state>
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</state>
|
||||
</component>
|
8
.idea/vcs.xml
Normal file
8
.idea/vcs.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
19
EnigmAndroid.iml
Normal file
19
EnigmAndroid.iml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
BIN
app/app-release.apk
Normal file
BIN
app/app-release.apk
Normal file
Binary file not shown.
66
app/app.iml
Normal file
66
app/app.iml
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="EnigmAndroid" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
||||
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
24
app/build.gradle
Normal file
24
app/build.gradle
Normal file
|
@ -0,0 +1,24 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 20
|
||||
buildToolsVersion "20.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.vanitasvitae.enigmandroid"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 20
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
BIN
app/enigmandroid.apk
Normal file
BIN
app/enigmandroid.apk
Normal file
Binary file not shown.
17
app/proguard-rules.pro
vendored
Normal file
17
app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /media/Daten/android-studio/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -0,0 +1,13 @@
|
|||
package de.vanitasvitae.enigmandroid;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
23
app/src/main/AndroidManifest.xml
Normal file
23
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.vanitasvitae.enigmandroid"
|
||||
android:versionCode="00001"
|
||||
android:versionName="04.02.2015-beta">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
330
app/src/main/java/de/vanitasvitae/enigmandroid/Enigma.java
Normal file
330
app/src/main/java/de/vanitasvitae/enigmandroid/Enigma.java
Normal file
|
@ -0,0 +1,330 @@
|
|||
package de.vanitasvitae.enigmandroid;
|
||||
|
||||
|
||||
/**
|
||||
* Enigma-machine
|
||||
* @author vanitasvitae
|
||||
*
|
||||
*/
|
||||
public class Enigma
|
||||
{
|
||||
private Plugboard plugboard;
|
||||
|
||||
private Rotor r1;
|
||||
private Rotor r2;
|
||||
private Rotor r3;
|
||||
|
||||
private Rotor ukw;
|
||||
|
||||
private static final int[] STANDARD_CONFIGURATION = {1,2,3,1,1,1,1};
|
||||
private boolean showSteps;
|
||||
private boolean verbose = false;
|
||||
private String output = null;
|
||||
|
||||
/**
|
||||
* @param pbconf two-dimensional Array with plugs, that need to be switched
|
||||
* @param conf Configuration of the enigma
|
||||
*/
|
||||
public Enigma(char[][] pbconf, int[] conf) throws Plugboard.PlugAlreadyUsedException
|
||||
{
|
||||
if(conf!=null) konfiguration(conf);
|
||||
else konfiguration(Enigma.STANDARD_CONFIGURATION);
|
||||
|
||||
this.setPlugboard(pbconf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts / Decrypts a given String
|
||||
* @param w Text to decrypt/encrypt
|
||||
* @return
|
||||
*/
|
||||
public String encrypt(String w)
|
||||
{
|
||||
String k=w;
|
||||
String c = "";
|
||||
//for each char x in k
|
||||
for(int i=0; i<k.length(); i++)
|
||||
{
|
||||
char x = k.charAt(i);
|
||||
c = c + this.encryptChar(x);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verschlüssele den übergebenen char k.
|
||||
* Zähle danach Konfiguration hoch.
|
||||
* @param k zu verschlüsselnder char
|
||||
* @return verschlüsselter char
|
||||
*/
|
||||
public char encryptChar(char k)
|
||||
{
|
||||
//Move rotors
|
||||
r1.incrementCounter();
|
||||
if(r1.getCounter() == r1.getRingsetting()) {
|
||||
r2.incrementCounter();
|
||||
if (r2.getCounter() == r2.getRingsetting()) {
|
||||
r3.incrementCounter();
|
||||
}
|
||||
}
|
||||
int x = (int) k;
|
||||
x = x-65; //Remove Unicode Offset (A=65 in Unicode.)
|
||||
|
||||
//Encryption
|
||||
//forward direction
|
||||
x = plugboard.encrypt(x);
|
||||
x =(x + r1.getCounter())%26;
|
||||
x = r1.encryptForward(x);
|
||||
x = (x + r2.getCounter()- r1.getCounter())%26;
|
||||
x = r2.encryptForward(x);
|
||||
x = (x + r3.getCounter()- r2.getCounter())%26;
|
||||
x = r3.encryptForward(x);
|
||||
x = (26 + x - r3.getCounter())%26;
|
||||
//backward direction
|
||||
x = ukw.encryptForward(x);
|
||||
x = (26 + x + r3.getCounter())%26;
|
||||
x = r3.encryptBackward(x);
|
||||
x = (26 + x - r3.getCounter()+ r2.getCounter())%26;
|
||||
x = r2.encryptBackward(x);
|
||||
x = (26 + x - r2.getCounter()+ r1.getCounter())%26;
|
||||
x = r1.encryptBackward(x);
|
||||
x = (26 + x - r1.getCounter())%26;
|
||||
x = plugboard.encrypt(x);
|
||||
|
||||
return (char) (x+65); //Add Offset
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare String for encryption via enigma
|
||||
* Replace . , ! ? : with X
|
||||
* Remove all other chars that are not A..Z
|
||||
* @param word string
|
||||
* @return prepared string
|
||||
*/
|
||||
public static String prepare(String word)
|
||||
{
|
||||
String w = word.toUpperCase();
|
||||
String c = "";
|
||||
for(int i=0; i<w.length(); i++)
|
||||
{
|
||||
char x = w.charAt(i);
|
||||
if(x>=65 && x<=90) //If x in [A..Z]
|
||||
{
|
||||
c = c + x; //Append to String
|
||||
}
|
||||
//if x is special symbol
|
||||
else
|
||||
{
|
||||
if(x == '.' || x == ',' || x == '!' || x == '?' || x == ':')
|
||||
{
|
||||
//replace x with X and encrypt
|
||||
c = c + 'X';
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Plugboard configuration from String.
|
||||
* String must be in format XY:AZ and so on.
|
||||
* X and Y are plugs, that will be switched over.
|
||||
* Dont do things such as AA or AB:CA. This will cause Exceptions
|
||||
* @param p String
|
||||
* @return Array
|
||||
*/
|
||||
public static char[][] parsePlugs(String p) throws InvalidPlugboardConfigurationFormatException
|
||||
{
|
||||
if(p.length()==0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String[] in = p.toUpperCase().split(",");
|
||||
|
||||
if(in.length!=(p.length()+1)/3)
|
||||
{
|
||||
throw new InvalidPlugboardConfigurationFormatException("Fehler beim Parsen der Plugs: Fehlercode 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
char[][] plugs = new char[(p.length()+1)/3][2];
|
||||
int i=0;
|
||||
for(String x:in)
|
||||
{
|
||||
if(x.length()!=2)
|
||||
{
|
||||
throw new InvalidPlugboardConfigurationFormatException("Fehler beim Parsen der Plugs: Fehlercode 2");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugs[i] = x.toCharArray();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return plugs;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlugboard(char[][] c) throws Plugboard.PlugAlreadyUsedException
|
||||
{
|
||||
plugboard = new Plugboard();
|
||||
if(c!=null)
|
||||
{
|
||||
for(int i=0; i<c.length; i++)
|
||||
{
|
||||
plugboard.setPlug(c[i][0], c[i][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config of the enigma
|
||||
* @param conf configuration
|
||||
*/
|
||||
public void konfiguration(int[] conf)
|
||||
{
|
||||
if(conf.length!=7)
|
||||
{
|
||||
konfiguration(Enigma.STANDARD_CONFIGURATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
int ro1 = conf[0];
|
||||
int ro2 = conf[1];
|
||||
int ro3 = conf[2];
|
||||
int ukwN = conf[3];
|
||||
int r1stand = 26+conf[4]-1;
|
||||
int r2stand = 26+conf[5]-1;
|
||||
int r3stand = 26+conf[6]-1;
|
||||
|
||||
//Lege erste Walze fest
|
||||
switch(ro1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
r1 = new Rotor('1',(r1stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
r1 = new Rotor('2',(r1stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
r1 = new Rotor('3',(r1stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
r1 = new Rotor('4',(r1stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
r1 = new Rotor('5',(r1stand)%26,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Lege zweite Walze fest
|
||||
switch(ro2)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
r2 = new Rotor('1',(r2stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
r2 = new Rotor('2',(r2stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
r2 = new Rotor('3',(r2stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
r2 = new Rotor('4',(r2stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
r2 = new Rotor('5',(r2stand)%26,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Lege dritte Walze fest
|
||||
switch(ro3)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
r3 = new Rotor('1',(r3stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
r3 = new Rotor('2',(r3stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
r3 = new Rotor('3',(r3stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
r3 = new Rotor('4',(r3stand)%26,0);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
r3 = new Rotor('5',(r3stand)%26,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Lege Umkehrwalze fest
|
||||
switch(ukwN)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ukw = new Rotor('A',0,0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ukw = new Rotor('B',0,0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ukw = new Rotor('C',0,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public int[] getKonfiguration()
|
||||
{
|
||||
int[] c = new int[7];
|
||||
{
|
||||
c[0] = r1.getType();
|
||||
c[1] = r2.getType();
|
||||
c[2] = r3.getType();
|
||||
c[3] = ukw.getType();
|
||||
c[4] = r1.getCounter();
|
||||
c[5] = r2.getCounter();
|
||||
c[6] = r3.getCounter();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static class InvalidPlugboardConfigurationFormatException extends Exception
|
||||
{
|
||||
public InvalidPlugboardConfigurationFormatException(String m)
|
||||
{
|
||||
super(m);
|
||||
}
|
||||
}
|
||||
}
|
188
app/src/main/java/de/vanitasvitae/enigmandroid/MainActivity.java
Normal file
188
app/src/main/java/de/vanitasvitae/enigmandroid/MainActivity.java
Normal file
|
@ -0,0 +1,188 @@
|
|||
package de.vanitasvitae.enigmandroid;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
private Spinner w1;
|
||||
private Spinner w2;
|
||||
private Spinner w3;
|
||||
private Spinner reversingRotor;
|
||||
private Spinner w1pos;
|
||||
private Spinner w2pos;
|
||||
private Spinner w3pos;
|
||||
private EditText plugboard;
|
||||
private EditText input;
|
||||
private EditText output;
|
||||
|
||||
private Enigma enigma;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
this.initLayout();
|
||||
this.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_version)
|
||||
{
|
||||
Toast.makeText(getApplicationContext(), R.string.version,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.action_reset)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void setEnigma(View v)
|
||||
{
|
||||
int[] conf = new int[7];
|
||||
conf[0] = w1.getSelectedItemPosition()+1;
|
||||
conf[1] = w2.getSelectedItemPosition()+1;
|
||||
conf[2] = w3.getSelectedItemPosition()+1;
|
||||
conf[3] = reversingRotor.getSelectedItemPosition()+1;
|
||||
conf[4] = w1pos.getSelectedItemPosition()+1;
|
||||
conf[5] = w2pos.getSelectedItemPosition()+1;
|
||||
conf[6] = w3pos.getSelectedItemPosition()+1;
|
||||
|
||||
try
|
||||
{
|
||||
enigma = new Enigma(null,null);
|
||||
}
|
||||
catch(Plugboard.PlugAlreadyUsedException e)
|
||||
{}
|
||||
|
||||
char[][] pbconf = null;
|
||||
try
|
||||
{
|
||||
pbconf = Enigma.parsePlugs(plugboard.getText().toString());
|
||||
}
|
||||
catch(Enigma.InvalidPlugboardConfigurationFormatException e)
|
||||
{
|
||||
String error = this.getResources().getString(R.string.error_parsing_plugs)+": "+e.getMessage();
|
||||
Toast.makeText(getApplicationContext(), error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
try
|
||||
{
|
||||
enigma.konfiguration(conf);
|
||||
enigma.setPlugboard(pbconf);
|
||||
|
||||
}
|
||||
catch(Plugboard.PlugAlreadyUsedException e)
|
||||
{
|
||||
Toast.makeText(this.getApplicationContext(), e.getMessage(),
|
||||
Toast.LENGTH_SHORT).show();;
|
||||
}
|
||||
}
|
||||
|
||||
public void crypto(View v)
|
||||
{
|
||||
setEnigma(null);
|
||||
String m = input.getText().toString();
|
||||
m = Enigma.prepare(m);
|
||||
input.setText(m);
|
||||
output.setText(enigma.encrypt(m));
|
||||
updateSpinner(enigma.getKonfiguration());
|
||||
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
w1.setSelection(0);
|
||||
w2.setSelection(1);
|
||||
w3.setSelection(2);
|
||||
reversingRotor.setSelection(0);
|
||||
w1pos.setSelection(0);
|
||||
w2pos.setSelection(0);
|
||||
w3pos.setSelection(0);
|
||||
plugboard.setText("");
|
||||
input.setText("");
|
||||
output.setText("");
|
||||
}
|
||||
|
||||
private void initLayout()
|
||||
{
|
||||
w1 = (Spinner) findViewById(R.id.w1);
|
||||
ArrayAdapter<CharSequence> w1adapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.enigma_walzen, android.R.layout.simple_spinner_item);
|
||||
w1adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
w1.setAdapter(w1adapter);
|
||||
|
||||
|
||||
w2 = (Spinner) findViewById(R.id.w2);
|
||||
ArrayAdapter<CharSequence> w2adapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.enigma_walzen, android.R.layout.simple_spinner_item);
|
||||
w2adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
w2.setAdapter(w2adapter);
|
||||
|
||||
w3 = (Spinner) findViewById(R.id.w3);
|
||||
ArrayAdapter<CharSequence> w3adapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.enigma_walzen, android.R.layout.simple_spinner_item);
|
||||
w3adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
w3.setAdapter(w3adapter);
|
||||
|
||||
reversingRotor = (Spinner) findViewById(R.id.ukw);
|
||||
ArrayAdapter<CharSequence> ukwadapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.enigma_ukw, android.R.layout.simple_spinner_item);
|
||||
ukwadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
reversingRotor.setAdapter(ukwadapter);
|
||||
|
||||
w1pos = (Spinner) findViewById(R.id.w1pos);
|
||||
ArrayAdapter<CharSequence> w1posadapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.positions, android.R.layout.simple_spinner_item);
|
||||
w1posadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
w1pos.setAdapter(w1posadapter);
|
||||
|
||||
w2pos = (Spinner) findViewById(R.id.w2pos);
|
||||
ArrayAdapter<CharSequence> w2posadapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.positions, android.R.layout.simple_spinner_item);
|
||||
w2posadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
w2pos.setAdapter(w2posadapter);
|
||||
|
||||
w3pos = (Spinner) findViewById(R.id.w3pos);
|
||||
ArrayAdapter<CharSequence> w3posadapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.positions, android.R.layout.simple_spinner_item);
|
||||
w3posadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
w3pos.setAdapter(w3posadapter);
|
||||
|
||||
plugboard = (EditText) findViewById(R.id.plugboard);
|
||||
input = (EditText) findViewById(R.id.input);
|
||||
output = (EditText) findViewById(R.id.output);
|
||||
}
|
||||
|
||||
public void updateSpinner(int[] c)
|
||||
{
|
||||
w1.setSelection(c[0]-1);
|
||||
w2.setSelection(c[1]-1);
|
||||
w3.setSelection(c[2]-1);
|
||||
w1pos.setSelection(c[4]);
|
||||
w2pos.setSelection(c[5]);
|
||||
w3pos.setSelection(c[6]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package de.vanitasvitae.enigmandroid;
|
||||
|
||||
/**
|
||||
* Klasse für das Steckerbrett der Enigma
|
||||
* @author vanitas
|
||||
*
|
||||
*/
|
||||
public class Plugboard
|
||||
{
|
||||
//Plugboard
|
||||
// Q W E R T Z U I O
|
||||
// A S D F G H J K
|
||||
// P Y X C V B N M L
|
||||
|
||||
//Array für die Steckerverbindungen
|
||||
int[] pb;
|
||||
//Vergleichsarray (Keine Stecker)
|
||||
public static final int[] ref = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
|
||||
/**
|
||||
* Erzeuge neues Plugboard ohne Steckverbindungen
|
||||
*/
|
||||
public Plugboard()
|
||||
{
|
||||
pb = new int[26];
|
||||
resetPlugboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verschlüssele den gegebenen Buchstaben, den Regeln des Plugboard folgend
|
||||
* @param x zu verschlüsselndes Zeichen
|
||||
* @return Verschlüsseltes Zeichen
|
||||
*/
|
||||
public int encrypt(int x)
|
||||
{
|
||||
return pb[x];
|
||||
}
|
||||
|
||||
/**
|
||||
* Setze das Plugboard in den Standardzustand (Keine Stecker)
|
||||
*/
|
||||
public void resetPlugboard()
|
||||
{
|
||||
pb = new int[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
|
||||
}
|
||||
|
||||
public void setPlugs(char[][] p) throws PlugAlreadyUsedException
|
||||
{
|
||||
for(int i=0; i<p.length; i++)
|
||||
{
|
||||
if(p[i]!=null)
|
||||
{
|
||||
this.setPlug(p[i][0], p[i][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Steckere Buchstaben a und b auf dem Plugboard
|
||||
* @param a first Plug
|
||||
* @param b second Plug
|
||||
*/
|
||||
public void setPlug(char a, char b) throws PlugAlreadyUsedException
|
||||
{
|
||||
//Verhindere, dass Buchstabe mit sich selbst gesteckert wird
|
||||
if(a==b)
|
||||
{
|
||||
throw new PlugAlreadyUsedException("Unable to plug "+a +" to " +a);
|
||||
}
|
||||
int x = a-65;
|
||||
int y = b-65;
|
||||
//Check, if plugs already steckered
|
||||
if(pb[x]!=ref[x])
|
||||
{
|
||||
throw new PlugAlreadyUsedException("Plug " + a + " used twice!");
|
||||
}
|
||||
else if(pb[y]!=ref[y])
|
||||
{
|
||||
throw new PlugAlreadyUsedException("Plug " + b + " used twice!");
|
||||
}
|
||||
else //Steckere um
|
||||
{
|
||||
int c =pb[x];
|
||||
pb[x] = pb[y];
|
||||
pb[y] = c;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlugAlreadyUsedException extends Exception
|
||||
{
|
||||
public PlugAlreadyUsedException(String m)
|
||||
{
|
||||
super(m);
|
||||
}
|
||||
}
|
||||
}
|
194
app/src/main/java/de/vanitasvitae/enigmandroid/Rotor.java
Normal file
194
app/src/main/java/de/vanitasvitae/enigmandroid/Rotor.java
Normal file
|
@ -0,0 +1,194 @@
|
|||
package de.vanitasvitae.enigmandroid;
|
||||
|
||||
/**
|
||||
* Klasse, die eine Walze der Enigmamaschine representiert (I-V,A-C)
|
||||
* @author vanitas
|
||||
*
|
||||
*/
|
||||
public class Rotor
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
||||
//ABC: 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
||||
//Rotor1: 'E','K','M','F','L','G','D','Q','V','Z','N','T','O','W','Y','H','X','U','S','P','A','I','B','R','C','J'
|
||||
//Rotor2: 'A','J','D','K','S','I','R','U','X','B','L','H','W','T','M','C','Q','G','Z','N','P','Y','F','V','O','E'
|
||||
//Rotor3: 'B','D','F','H','J','L','C','P','R','T','X','V','Z','N','Y','E','I','W','G','A','K','M','U','S','Q','O'
|
||||
//Rotor4: 'E','S','O','V','P','Z','J','A','Y','Q','U','I','R','H','X','L','N','F','T','G','K','D','C','M','W','B'
|
||||
//Rotor5: 'V','Z','B','R','G','I','T','Y','U','P','S','D','N','H','L','X','A','W','M','J','Q','O','F','E','C','K'
|
||||
//Reversing Rotor A: AE BJ CM DZ FL GY HX IV KW NR OQ PU ST
|
||||
//Reversing Rotor B: AY BR CU DH EQ FS GL IP JX KN MO TZ VW
|
||||
//Reversing Rotor C: AF BV CP DJ EI GO HY KR LZ MX NW QT SU
|
||||
|
||||
//Original rotors
|
||||
public static final Integer[] rotor1 = {4,10,12,5,11,6,3,16,21,25,13,19,14,22,24,7,23,20,18,15,0,8,1,17,2,9};
|
||||
public static final Integer[] rotor2 = {0,9,3,10,18,8,17,20,23,1,11,7,22,19,12,2,16,6,25,13,15,24,5,21,14,4};
|
||||
public static final Integer[] rotor3 = {1,3,5,7,9,11,2,15,17,19,23,21,25,13,24,4,8,22,6,0,10,12,20,18,16,14};
|
||||
public static final Integer[] rotor4 = {4,18,14,21,15,25,9,0,24,16,20,8,17,7,23,11,13,5,19,6,10,3,2,12,22,1};
|
||||
public static final Integer[] rotor5 = {21,25,1,17,6,8,19,24,20,15,18,3,13,7,11,23,0,22,12,9,16,14,5,4,2,10};
|
||||
//Original rotors backwards direction
|
||||
public static final Integer[] backwardsRotor1 = {20,22,24,6,0,3,5,15,21,25,1,4,2,10,12,19,7,23,18,11,17,8,13,16,14,9};
|
||||
public static final Integer[] backwardsRotor2 = {0,9,15,2,25,22,17,11,5,1,3,10,14,19,24,20,16,6,4,13,7,23,12,8,21,18};
|
||||
public static final Integer[] backwardsRotor3 = {19,0,6,1,15,2,18,3,16,4,20,5,21,13,25,7,24,8,23,9,22,11,17,10,14,12};
|
||||
public static final Integer[] backwardsRotor4 = {7,25,22,21,0,17,19,13,11,6,20,15,23,16,2,4,9,12,1,18,10,3,24,14,8,5};
|
||||
public static final Integer[] backwardsRotor5 = {16,2,24,11,23,22,4,13,5,19,25,14,18,12,21,9,20,3,10,6,8,0,17,15,7,1};
|
||||
|
||||
//Original reversing rotors A,B,C, D, E,F, G, H, I, J,K, L,M,N, O, P, Q, R, S, T, U, V,W, X,Y,Z
|
||||
public static final Integer[] reversingRotorA = {4,9,12,25,0,11,24,23,21,1,22,5,2,17,16,20,14,13,19,18,15,8,10,7,6,3};
|
||||
public static final Integer[] reversingRotorB = {24,17,20,7,16,18,11,3,15,23,13,6,14,10,12,8,4,1,5,25,2,22,21,9,0,19};
|
||||
public static final Integer[] reversingRotorC = {5,21,15,9,8,0,14,24,4,3,17,25,23,22,6,2,19,10,20,16,18,1,13,12,7,11};
|
||||
|
||||
private Integer[] rotor; //choose one of rotor1-5
|
||||
private Integer[] rrotor; //choose one of backwardsRotor1-5
|
||||
private int ringsetting;
|
||||
private int counter;
|
||||
private String name;
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* Create new Rotor (1 - 5 = normal rotor, -1 - -3 = reversing rotor)
|
||||
* @param type integer determines type
|
||||
* @param setting setting (rotation) of the rotor
|
||||
*/
|
||||
public Rotor(char type, int setting, int ring)
|
||||
{
|
||||
this.ringsetting = ring%26;
|
||||
switch(type)
|
||||
{
|
||||
case '1':
|
||||
{
|
||||
this.rotor = rotor1;
|
||||
this.rrotor = backwardsRotor1;
|
||||
this.counter = setting;
|
||||
this.name="I";
|
||||
this.type = 1;
|
||||
break;
|
||||
}
|
||||
case '2':
|
||||
{
|
||||
this.rotor = rotor2;
|
||||
this.rrotor = backwardsRotor2;
|
||||
this.counter = setting;
|
||||
this.name="II";
|
||||
this.type = 2;
|
||||
break;
|
||||
}
|
||||
case '3':
|
||||
{
|
||||
this.rotor = rotor3;
|
||||
this.rrotor = backwardsRotor3;
|
||||
this.counter = setting;
|
||||
this.name="III";
|
||||
this.type = 3;
|
||||
break;
|
||||
}
|
||||
case '4':
|
||||
{
|
||||
this.rotor = rotor4;
|
||||
this.rrotor = backwardsRotor4;
|
||||
this.counter = setting;
|
||||
this.name="IV";
|
||||
this.type = 4;
|
||||
break;
|
||||
}
|
||||
case '5':
|
||||
{
|
||||
this.rotor = rotor5;
|
||||
this.rrotor = backwardsRotor5;
|
||||
this.counter = setting;
|
||||
this.name="V";
|
||||
this.type = 5;
|
||||
break;
|
||||
}
|
||||
case 'A':
|
||||
{
|
||||
this.rotor = reversingRotorA;
|
||||
this.rrotor = null;
|
||||
this.counter = 0;
|
||||
this.name="A";
|
||||
this.type = 1;
|
||||
break;
|
||||
}
|
||||
case 'B':
|
||||
{
|
||||
this.rotor = reversingRotorB;
|
||||
this.rrotor = null;
|
||||
this.counter = 0;
|
||||
this.name="B";
|
||||
this.type = 2;
|
||||
break;
|
||||
}
|
||||
case 'C':
|
||||
{
|
||||
this.rotor = reversingRotorC;
|
||||
this.rrotor = null;
|
||||
this.counter = 0;
|
||||
this.name="C";
|
||||
this.type = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* encrypt in forward direction (forward means first half of the cycle through the rotors)
|
||||
* @param x incoming character
|
||||
* @return encrypted character
|
||||
*/
|
||||
public int encryptForward(int x)
|
||||
{
|
||||
return this.rotor[(26+x)%26];
|
||||
}
|
||||
|
||||
/**encrypt in backward direction (coming from the reversing rotor)
|
||||
* @param x incoming character
|
||||
* @return encrypted character
|
||||
*/
|
||||
public int encryptBackward(int x)
|
||||
{
|
||||
if(this.rrotor ==null) return this.rotor[(26+x)%26];
|
||||
else return this.rrotor[(26+x)%26];
|
||||
}
|
||||
|
||||
/**
|
||||
* return rotation of the rotor
|
||||
* @return rotation
|
||||
*/
|
||||
public int getCounter()
|
||||
{
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* increment rotation of the rotor by one.
|
||||
*/
|
||||
public void incrementCounter()
|
||||
{
|
||||
this.counter = (this.counter+1)%26;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the rotor
|
||||
* @return name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ringsettings of the rotor (TODO: Find out, how ringsetting was implemented in original enigma. Wikipedia is not enough :/
|
||||
* @return ringsetting
|
||||
*/
|
||||
public int getRingsetting()
|
||||
{
|
||||
return this.ringsetting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer, which was used to create this rotor. TODO: This is too resource hungry.
|
||||
* @return
|
||||
*/
|
||||
public int getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/ic_launcher-web.png
Normal file
BIN
app/src/main/res/ic_launcher-web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
187
app/src/main/res/layout/activity_main.xml
Normal file
187
app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,187 @@
|
|||
<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=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_ukw"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_w3"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_w2"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_w1"/>
|
||||
</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=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/ukw">
|
||||
</Spinner>
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/w3">
|
||||
</Spinner>
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/w2">
|
||||
</Spinner>
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/w1">
|
||||
</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">
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".125"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_w3pos"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_w2pos"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hint_w1pos"/>
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".125"
|
||||
android:layout_height="wrap_content" />
|
||||
</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">
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".125"
|
||||
android:layout_height="wrap_content" />
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/w3pos">
|
||||
</Spinner>
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/w2pos">
|
||||
</Spinner>
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".25"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/w1pos">
|
||||
</Spinner>
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".125"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30pt"
|
||||
android:id="@+id/plugboard"
|
||||
android:hint="@string/hint_enigma_plugboard"
|
||||
android:layout_below="@+id/lin_lay_2"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/plugboard"
|
||||
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:hint="@string/hint_enigma_usertype" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight=".50"
|
||||
android:layout_height="match_parent"
|
||||
android:editable="false"
|
||||
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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/text_layer"
|
||||
android:id="@+id/button_crypt"
|
||||
android:onClick="crypto"
|
||||
android:text="@string/button_crypt"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
13
app/src/main/res/menu/main.xml
Normal file
13
app/src/main/res/menu/main.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
<item android:id="@+id/action_version"
|
||||
android:title="@string/action_version"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never" />
|
||||
<item android:id="@+id/action_reset"
|
||||
android:orderInCategory="99"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/action_reset" />
|
||||
</menu>
|
58
app/src/main/res/values-de/strings.xml
Normal file
58
app/src/main/res/values-de/strings.xml
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EnigmAndroid</string>
|
||||
<string name="action_settings">Version</string>
|
||||
<string name="hint_enigma_usertype">Hier Tippen</string>
|
||||
<string name="hint_enigma_code">Enigma-Code</string>
|
||||
<string name="hint_enigma_plugboard">Steckerbrett (AZ,BE...)</string>
|
||||
<string name="hint_w1">Walze 1</string>
|
||||
<string name="hint_w2">Walze 2</string>
|
||||
<string name="hint_w3">Walze 3</string>
|
||||
<string name="hint_ukw">Umkehr-\nWalze</string>
|
||||
<string name="hint_w1pos">Position\nWalze 1</string>
|
||||
<string name="hint_w2pos">Position\nWalze 2</string>
|
||||
<string name="hint_w3pos">Position\nWalze 3</string>
|
||||
<string name="button_crypt">Ver-/Entschlüsseln</string>
|
||||
|
||||
<string-array name="enigma_walzen">
|
||||
<item>I</item>
|
||||
<item>II</item>
|
||||
<item>III</item>
|
||||
<item>IV</item>
|
||||
<item>V</item>
|
||||
</string-array>
|
||||
<string-array name="enigma_ukw">
|
||||
<item>A</item>
|
||||
<item>B</item>
|
||||
<item>C</item>
|
||||
</string-array>
|
||||
<string-array name="positions">
|
||||
<item>A</item>
|
||||
<item>B</item>
|
||||
<item>C</item>
|
||||
<item>D</item>
|
||||
<item>E</item>
|
||||
<item>F</item>
|
||||
<item>G</item>
|
||||
<item>H</item>
|
||||
<item>I</item>
|
||||
<item>J</item>
|
||||
<item>K</item>
|
||||
<item>L</item>
|
||||
<item>M</item>
|
||||
<item>N</item>
|
||||
<item>O</item>
|
||||
<item>P</item>
|
||||
<item>Q</item>
|
||||
<item>R</item>
|
||||
<item>S</item>
|
||||
<item>T</item>
|
||||
<item>U</item>
|
||||
<item>V</item>
|
||||
<item>W</item>
|
||||
<item>X</item>
|
||||
<item>Y</item>
|
||||
<item>Z</item>
|
||||
</string-array>
|
||||
</resources>
|
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
5
app/src/main/res/values/dimens.xml
Normal file
5
app/src/main/res/values/dimens.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
63
app/src/main/res/values/strings.xml
Normal file
63
app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="version" translatable="false">0.1-04.02.2015</string>
|
||||
<string name="app_name">EnigmAndroid</string>
|
||||
<string name="action_version">Version</string>
|
||||
<string name="action_reset">Reset</string>
|
||||
<string name="hint_enigma_usertype">Type here</string>
|
||||
<string name="hint_enigma_code">EnigmaCode</string>
|
||||
<string name="hint_enigma_plugboard">Plugboard (AZ,BE...)</string>
|
||||
<string name="hint_w1">R1</string>
|
||||
<string name="hint_w2">R2</string>
|
||||
<string name="hint_w3">R3</string>
|
||||
<string name="hint_ukw">RR</string>
|
||||
<string name="hint_w1pos">PosR1</string>
|
||||
<string name="hint_w2pos">PosR2</string>
|
||||
<string name="hint_w3pos">PosR3</string>
|
||||
<string name="button_crypt">En-/Decrypt!</string>
|
||||
<string name="error_parsing_plugs">Error: Can\'t interpret Plugboard Input.</string>
|
||||
<string name="error_unable_to_plug_a_b">Unable to plug </string>
|
||||
<string name="error_plug_already_in_use">Error: One or more of these Plugs are already in use: </string>
|
||||
|
||||
<string-array name="enigma_walzen">
|
||||
<item>I</item>
|
||||
<item>II</item>
|
||||
<item>III</item>
|
||||
<item>IV</item>
|
||||
<item>V</item>
|
||||
</string-array>
|
||||
<string-array name="enigma_ukw">
|
||||
<item>A</item>
|
||||
<item>B</item>
|
||||
<item>C</item>
|
||||
</string-array>
|
||||
<string-array name="positions">
|
||||
<item>A</item>
|
||||
<item>B</item>
|
||||
<item>C</item>
|
||||
<item>D</item>
|
||||
<item>E</item>
|
||||
<item>F</item>
|
||||
<item>G</item>
|
||||
<item>H</item>
|
||||
<item>I</item>
|
||||
<item>J</item>
|
||||
<item>K</item>
|
||||
<item>L</item>
|
||||
<item>M</item>
|
||||
<item>N</item>
|
||||
<item>O</item>
|
||||
<item>P</item>
|
||||
<item>Q</item>
|
||||
<item>R</item>
|
||||
<item>S</item>
|
||||
<item>T</item>
|
||||
<item>U</item>
|
||||
<item>V</item>
|
||||
<item>W</item>
|
||||
<item>X</item>
|
||||
<item>Y</item>
|
||||
<item>Z</item>
|
||||
</string-array>
|
||||
</resources>
|
8
app/src/main/res/values/styles.xml
Normal file
8
app/src/main/res/values/styles.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
19
build.gradle
Normal file
19
build.gradle
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.12.+'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
BIN
build/intermediates/model_data.bin
Normal file
BIN
build/intermediates/model_data.bin
Normal file
Binary file not shown.
18
gradle.properties
Normal file
18
gradle.properties
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Settings specified in this file will override any Gradle settings
|
||||
# configured through the IDE.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
164
gradlew
vendored
Executable file
164
gradlew
vendored
Executable file
|
@ -0,0 +1,164 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
10
local.properties
Normal file
10
local.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file should *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
sdk.dir=/media/Daten/android-studio/sdk
|
1
settings.gradle
Normal file
1
settings.gradle
Normal file
|
@ -0,0 +1 @@
|
|||
include ':app'
|
Loading…
Reference in a new issue