(Android) start of a custom key config panel

This commit is contained in:
ToadKing 2013-01-27 16:54:32 -05:00
parent 9372e26cf3
commit e517dd96da
4 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/key_bind_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="@string/key_bind_title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/key_bind_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/key_bind_title"
android:layout_below="@+id/key_bind_title"
android:text="_"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/key_bind_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/key_bind_value"
android:layout_centerHorizontal="true"
android:text="@string/key_bind_clear" />
</RelativeLayout>

View File

@ -13,5 +13,7 @@
<string name="cores_guide">Cores Guide</string>
<string name="overlay_guide">Overlay How-to Guide</string>
<string name="shader_pack">Shader Pack</string>
<string name="key_bind_title">Press the button to use</string>
<string name="key_bind_clear">Clear</string>
</resources>

View File

@ -188,6 +188,11 @@
android:targetPackage="org.retroarch" />
</Preference>
</PreferenceCategory>
<PreferenceCategory android:title="Button Binds" >
<org.retroarch.browser.KeyBindPreference
android:key="testKey"
android:title="A Button" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>

View File

@ -0,0 +1,55 @@
package org.retroarch.browser;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import org.retroarch.R;
class KeyBindPreference extends DialogPreference implements View.OnKeyListener {
private int key_bind_code;
TextView keyText;
public KeyBindPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
}
@Override
protected View onCreateDialogView()
{
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.key_bind_dialog, null);
keyText = (TextView) view.findViewById(R.id.key_bind_value);
view.setOnKeyListener(this);
return view;
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
// deal with persisting your values here
}
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
Log.i("RetroArch", "Key event!");
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
key_bind_code = keyCode;
keyText.setText(String.valueOf(key_bind_code));
}
return false;
}
}