2019-01-04 20:40:11 +01:00
|
|
|
/**
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2015-09-10 02:56:48 +02:00
|
|
|
package de.vanitasvitae.enigmandroid.layout;
|
|
|
|
|
2015-09-15 02:06:47 +02:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
2015-09-10 02:56:48 +02:00
|
|
|
import android.widget.Spinner;
|
|
|
|
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
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
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
2015-09-10 02:56:48 +02:00
|
|
|
import de.vanitasvitae.enigmandroid.R;
|
|
|
|
import de.vanitasvitae.enigmandroid.enigma.EnigmaStateBundle;
|
|
|
|
import de.vanitasvitae.enigmandroid.enigma.Enigma_D;
|
|
|
|
|
|
|
|
/**
|
2015-09-16 14:38:46 +02:00
|
|
|
* Concrete LayoutContainer for the D layout.
|
2015-09-10 02:56:48 +02:00
|
|
|
* This class contains the layout and controls the layout elements such as spinners and stuff
|
|
|
|
* Copyright (C) 2015 Paul Schaub
|
|
|
|
*/
|
|
|
|
public class LayoutContainer_D extends LayoutContainer
|
|
|
|
{
|
|
|
|
private Enigma_D enigma;
|
|
|
|
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
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
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
private Spinner rotor1PositionView;
|
|
|
|
private Spinner rotor2PositionView;
|
|
|
|
private Spinner rotor3PositionView;
|
|
|
|
private Spinner reflectorPositionView;
|
2015-09-10 02:56:48 +02:00
|
|
|
|
|
|
|
public LayoutContainer_D()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
main.setTitle("D - EnigmAndroid");
|
|
|
|
this.resetLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
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
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
protected void setEnigmaLayout()
|
|
|
|
{
|
|
|
|
MainActivity.ActivitySingleton.getInstance().getActivity().setContentView(R.layout.activity_main_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void assembleLayout()
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
|
|
|
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);
|
2015-09-15 02:06:47 +02:00
|
|
|
Button reflectorWiring = (Button) main.findViewById(R.id.button_reflector);
|
|
|
|
reflectorWiring.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-09-30 14:25:49 +02:00
|
|
|
new PluggableDialogBuilder(getEnigma().getState()).showDialogReflector();
|
2015-09-15 02:06:47 +02:00
|
|
|
}
|
|
|
|
});
|
2015-09-10 02:56:48 +02:00
|
|
|
|
|
|
|
Character[] rotorPositionArray = new Character[26];
|
2015-09-26 16:51:19 +02:00
|
|
|
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
|
2015-09-10 02:56:48 +02:00
|
|
|
|
2015-09-26 16:51:19 +02:00
|
|
|
prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
|
|
|
|
prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
|
|
|
|
prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
|
|
|
|
prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resetLayout()
|
|
|
|
{
|
|
|
|
enigma = new Enigma_D();
|
|
|
|
setLayoutState(enigma.getState());
|
2015-09-12 00:04:58 +02:00
|
|
|
output.setText("");
|
|
|
|
input.setText("");
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-26 16:04:02 +02:00
|
|
|
public void setLayoutState(EnigmaStateBundle state)
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
|
|
|
this.rotor1PositionView.setSelection(state.getRotationRotor1());
|
|
|
|
this.rotor2PositionView.setSelection(state.getRotationRotor2());
|
|
|
|
this.rotor3PositionView.setSelection(state.getRotationRotor3());
|
|
|
|
this.reflectorPositionView.setSelection(state.getRotationReflector());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:25:49 +02:00
|
|
|
public void syncStateFromLayoutToEnigma()
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
2015-09-30 14:25:49 +02:00
|
|
|
EnigmaStateBundle state = getEnigma().getState();
|
2015-09-10 02:56:48 +02:00
|
|
|
state.setRotationRotor1(rotor1PositionView.getSelectedItemPosition());
|
|
|
|
state.setRotationRotor2(rotor2PositionView.getSelectedItemPosition());
|
|
|
|
state.setRotationRotor3(rotor3PositionView.getSelectedItemPosition());
|
|
|
|
state.setRotationReflector(reflectorPositionView.getSelectedItemPosition());
|
2015-09-30 14:25:49 +02:00
|
|
|
getEnigma().setState(state);
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Enigma_D getEnigma()
|
|
|
|
{
|
|
|
|
return this.enigma;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void showRingSettingsDialog()
|
|
|
|
{
|
|
|
|
new RingSettingsDialogBuilder.RingSettingsDialogBuilderRotRotRotRef().
|
2015-09-30 14:25:49 +02:00
|
|
|
createRingSettingsDialog(getEnigma().getState());
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|
|
|
|
}
|