use of com.amaze.filemanager.ui.views.preference.PathSwitchPreference in project AmazeFileManager by TeamAmaze.
the class FoldersPref method loadCreateDialog.
private void loadCreateDialog() {
int fab_skin = activity.getColorPreference().getColor(ColorUsage.ACCENT);
LayoutInflater li = LayoutInflater.from(activity);
// TODO: 29/4/2017 make this null not null
final View v = li.inflate(R.layout.dialog_twoedittexts, null);
((TextInputLayout) v.findViewById(R.id.text_input1)).setHint(getString(R.string.name));
((TextInputLayout) v.findViewById(R.id.text_input2)).setHint(getString(R.string.directory));
final AppCompatEditText editText1 = ((AppCompatEditText) v.findViewById(R.id.text1)), editText2 = ((AppCompatEditText) v.findViewById(R.id.text2));
final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.create_shortcut).theme(activity.getAppTheme().getMaterialDialogTheme()).positiveColor(fab_skin).positiveText(R.string.create).negativeColor(fab_skin).negativeText(android.R.string.cancel).customView(v, false).build();
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
disableButtonIfTitleEmpty(editText1, dialog);
disableButtonIfNotPath(editText2, dialog);
dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PathSwitchPreference p = new PathSwitchPreference(getActivity());
p.setTitle(editText1.getText());
p.setSummary(editText2.getText());
p.setOnPreferenceClickListener(FoldersPref.this);
position.put(p, dataUtils.getBooks().size());
getPreferenceScreen().addPreference(p);
String[] values = new String[] { editText1.getText().toString(), editText2.getText().toString() };
dataUtils.addBook(values);
AppConfig.runInBackground(new Runnable() {
@Override
public void run() {
utilsHandler.addBookmark(editText1.getText().toString(), editText2.getText().toString());
}
});
dialog.dismiss();
}
});
dialog.show();
}
use of com.amaze.filemanager.ui.views.preference.PathSwitchPreference in project AmazeFileManager by TeamAmaze.
the class FoldersPref method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activity = (PreferencesActivity) getActivity();
utilsHandler = new UtilsHandler(getActivity());
dataUtils = DataUtils.getInstance();
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.folders_prefs);
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
findPreference(PreferencesConstants.PREFERENCE_SHORTCUT).setOnPreferenceClickListener(this);
for (int i = 0; i < dataUtils.getBooks().size(); i++) {
PathSwitchPreference p = new PathSwitchPreference(getActivity());
p.setTitle(dataUtils.getBooks().get(i)[0]);
p.setSummary(dataUtils.getBooks().get(i)[1]);
p.setOnPreferenceClickListener(this);
position.put(p, i);
getPreferenceScreen().addPreference(p);
}
}
Aggregations