mirror of
https://github.com/TrianguloY/LightningLauncher.git
synced 2024-12-26 09:58:20 +01:00
Checkbox to enable/disable autoindentation
This commit is contained in:
parent
5b715fc6b4
commit
96c9b3ffef
4 changed files with 31 additions and 4 deletions
|
@ -101,6 +101,7 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
private static final String PREF_LAST_SCRIPT_ID = "se_lsi";
|
||||
private static final String PREF_LAST_SCRIPT_LINE = "se_lsl";
|
||||
private static final String PREF_WORDWRAP = "se_w";
|
||||
private static final String PREF_AUTOINDENT = "se_ind";
|
||||
private static final String PREF_FONT_SIZE = "se_fs";
|
||||
private static final String PREF_DIRECTORY = "se_d";
|
||||
private static final String PREF_SUB_DIRS = "se_sd";
|
||||
|
@ -382,7 +383,6 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
}
|
||||
});
|
||||
mIndentation = new Indentation();
|
||||
mIndentation.register(mScriptText); // TODO: add setting to register/unregister
|
||||
mSearch = new Search(this, mScriptText);
|
||||
|
||||
((TextView)findViewById(R.id.sc_ma)).setText(R.string.sc_ma);
|
||||
|
@ -434,6 +434,8 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
|
||||
boolean wordwrap = mSharedPrefs.getBoolean(PREF_WORDWRAP, true);
|
||||
mScriptText.setWordWrap(wordwrap);
|
||||
boolean autoindent = mSharedPrefs.getBoolean(PREF_AUTOINDENT, true);
|
||||
if(autoindent) mIndentation.register(mScriptText);
|
||||
float text_size = mSharedPrefs.getFloat(PREF_FONT_SIZE, mScriptText.getTextSize() / mScaledDensity);
|
||||
mScriptText.setTextSize(text_size);
|
||||
((TextView)findViewById(R.id.sc_o)).setText(R.string.sc_o);
|
||||
|
@ -441,7 +443,12 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
wordwrap_checkbox.setText(R.string.sc_w);
|
||||
wordwrap_checkbox.setChecked(wordwrap);
|
||||
wordwrap_checkbox.setOnCheckedChangeListener(this);
|
||||
|
||||
CheckBox autoindent_checkbox = findViewById(R.id.sc_ind);
|
||||
autoindent_checkbox.setText(R.string.sc_ind);
|
||||
autoindent_checkbox.setChecked(autoindent);
|
||||
autoindent_checkbox.setOnCheckedChangeListener(this);
|
||||
|
||||
|
||||
TextPosition position = null;
|
||||
int sel_start = 0, sel_end = 0;
|
||||
Intent intent = getIntent();
|
||||
|
@ -849,6 +856,15 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
|
|||
mScriptText.setWordWrap(isChecked);
|
||||
mSharedPrefs.edit().putBoolean(PREF_WORDWRAP, isChecked).commit();
|
||||
break;
|
||||
case R.id.sc_ind:
|
||||
// toggled autoindentation
|
||||
if(isChecked){
|
||||
mIndentation.register(mScriptText);
|
||||
} else {
|
||||
mIndentation.unregister(mScriptText);
|
||||
}
|
||||
mSharedPrefs.edit().putBoolean(PREF_AUTOINDENT, isChecked).commit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,11 @@ public class Indentation {
|
|||
* Unregisters the AutoIndentation on the provided editText (if it was registered before)
|
||||
*/
|
||||
public void unregister(EditText editText){
|
||||
if(mRegistered.containsKey(editText))
|
||||
editText.removeTextChangedListener(mRegistered.get(editText));
|
||||
if(!mRegistered.containsKey(editText))
|
||||
return;
|
||||
|
||||
editText.removeTextChangedListener(mRegistered.get(editText));
|
||||
mRegistered.remove(editText);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -180,6 +180,13 @@
|
|||
android:checked="true"
|
||||
android:text="@string/sc_w"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/sc_ind"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/sc_ind" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sc_a"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1448,6 +1448,7 @@
|
|||
<string name="srch_back">Backwards</string>
|
||||
<string name="srch_regexp">Regexp</string>
|
||||
<string name="srch_case">Match case</string>
|
||||
<string name="sc_ind">Autoindentation</string>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue