diff options
author | lado <herrlado@gmail.com> | 2013-02-14 23:36:16 +0100 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2013-02-14 23:36:16 +0100 |
commit | 2faeb66f4deda4a9ce1f8172985ac7ada19bade7 (patch) | |
tree | 6db55a10ac4e36ab321b6e9626f5a9147e040ff4 /vdrmanager | |
parent | 253ad54874105bb9a01b1ceaa591013aa5929547 (diff) | |
download | vdr-manager-2faeb66f4deda4a9ce1f8172985ac7ada19bade7.tar.gz vdr-manager-2faeb66f4deda4a9ce1f8172985ac7ada19bade7.tar.bz2 |
Feature #864
Diffstat (limited to 'vdrmanager')
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/data/MacFetchEditTextPreference.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/MacFetchEditTextPreference.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/MacFetchEditTextPreference.java new file mode 100644 index 0000000..3b5ab4f --- /dev/null +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/MacFetchEditTextPreference.java @@ -0,0 +1,94 @@ +package de.bjusystems.vdrmanager.data; + +import android.content.Context; +import android.content.DialogInterface; +import android.preference.DialogPreference; +import android.util.AttributeSet; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageButton; +import de.bjusystems.vdrmanager.R; +import de.bjusystems.vdrmanager.data.VdrSharedPreferences.Editor; + +public class MacFetchEditTextPreference extends DialogPreference { + + private EditText mEditText; + + private String initialValue; + + public String getInitialValue() { + return initialValue; + } + + public void setInitialValue(String initialValue) { + this.initialValue = initialValue; + } + + public EditText getmEditText() { + return mEditText; + } + + public void setEditText(String text) { + this.mEditText.setText(text); + } + + private ImageButton mButton; + + private String mText; + //private CharSequence mCompoundButtonText; + private View.OnClickListener mCompoundButtonCallback; + + public MacFetchEditTextPreference(Context context, AttributeSet attrs, + int defStyle) { + super(context, attrs, defStyle); + setDialogLayoutResource(R.layout.mac_fetch_preference); + } + + public MacFetchEditTextPreference(Context context, AttributeSet attrs) { + super(context, attrs); + setDialogLayoutResource(R.layout.mac_fetch_preference); + } + + @Override + protected View onCreateDialogView() { + View root = super.onCreateDialogView(); + mEditText = (EditText) root.findViewById(R.id.edit); + mButton = (ImageButton) root.findViewById(R.id.button); + return root; + } + + public void setText(String text) { + mText = text; + } + + public String getText() { + return mText; + } + + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case DialogInterface.BUTTON_POSITIVE: // User clicked OK! + mText = mEditText.getText().toString(); + callChangeListener(mText); + Editor editor = (Editor) getEditor(); + editor.putString(getKey(), mText); + editor.commit(); + break; + } + super.onClick(dialog, which); + } + + @Override + protected void onBindDialogView(View view) { + mEditText.setText(mText); + //mButton.setText(mCompoundButtonText); + + // Set a callback to our button. + mButton.setOnClickListener(mCompoundButtonCallback); + } + + public void setCompoundButtonListener(View.OnClickListener callback) { + mCompoundButtonCallback = callback; + } +}
\ No newline at end of file |