2015-09-10 02:56:48 +02:00
|
|
|
package de.vanitasvitae.enigmandroid.enigma.inputPreparer;
|
|
|
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adapter-like connector between text fields and string-outputting-whatever blah
|
|
|
|
* Use this to modify the way strings get displayed without modifying the string itself.
|
|
|
|
*/
|
|
|
|
public abstract class EditTextAdapter
|
|
|
|
{
|
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
|
|
|
EditText editText;
|
|
|
|
String content;
|
2015-09-10 02:56:48 +02:00
|
|
|
|
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
|
|
|
EditTextAdapter(EditText editText)
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
|
|
|
this.editText = editText;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the unmodified text
|
|
|
|
* @return content
|
|
|
|
*/
|
|
|
|
public String getText()
|
|
|
|
{
|
2015-09-12 00:04:58 +02:00
|
|
|
if(editText.getText().length() != 0)
|
|
|
|
return content;
|
|
|
|
else return content = "";
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getModifiedText()
|
|
|
|
{
|
|
|
|
return editText.getText().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the text to both the content and the editText without modifying it
|
|
|
|
* @param text text
|
|
|
|
*/
|
|
|
|
public void setRawText(String text)
|
|
|
|
{
|
|
|
|
this.content = text;
|
|
|
|
this.editText.setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method needs to be overwritten by the programmer.
|
|
|
|
* The coder has to make sure, content gets set to text and also that the editText element
|
|
|
|
* gets updated with the modified text
|
|
|
|
* @param text text
|
|
|
|
*/
|
|
|
|
public abstract void setText(String text);
|
|
|
|
|
|
|
|
public static EditTextAdapter createEditTextAdapter(EditText editText, String type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2015-09-22 21:10:41 +02:00
|
|
|
case "4": return new EditTextAdapterGap(editText, 4);
|
|
|
|
case "5": return new EditTextAdapterGap(editText, 5);
|
|
|
|
case "6": return new EditTextAdapterGap(editText, 6);
|
2015-09-10 02:56:48 +02:00
|
|
|
case "no": return new EditTextAdapterNoGap(editText);
|
|
|
|
default: return new EditTextAdapterNoGap(editText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class EditTextAdapterNoGap extends EditTextAdapter
|
|
|
|
{
|
|
|
|
public EditTextAdapterNoGap(EditText editText)
|
|
|
|
{
|
|
|
|
super(editText);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setText(String text)
|
|
|
|
{
|
|
|
|
this.content = text;
|
|
|
|
this.editText.setText(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-22 21:10:41 +02:00
|
|
|
public static class EditTextAdapterGap extends EditTextAdapter
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
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
|
|
|
int blockSize;
|
2015-10-04 22:51:35 +02:00
|
|
|
public EditTextAdapterGap(EditText editText, int blockSize)
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
|
|
|
super(editText);
|
2015-10-04 22:51:35 +02:00
|
|
|
this.blockSize = blockSize;
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setText(String text)
|
|
|
|
{
|
|
|
|
this.content = text;
|
|
|
|
String out = "";
|
|
|
|
int i;
|
2015-10-04 22:51:35 +02:00
|
|
|
for(i=0; i<text.length()/blockSize; i++)
|
2015-09-10 02:56:48 +02:00
|
|
|
{
|
2015-10-04 22:51:35 +02:00
|
|
|
out = out + text.substring(i*blockSize, (i+1)*blockSize);
|
2015-09-10 02:56:48 +02:00
|
|
|
out = out + " ";
|
|
|
|
}
|
2015-10-04 22:51:35 +02:00
|
|
|
out = out + text.substring(i*blockSize);
|
2015-09-10 02:56:48 +02:00
|
|
|
this.editText.setText(out);
|
|
|
|
}
|
|
|
|
}
|
2015-09-22 21:10:41 +02:00
|
|
|
|
2015-09-10 02:56:48 +02:00
|
|
|
}
|