Add options to select between 720p and 1080p resolutions along with 30 fps and 60 fps

This commit is contained in:
Cameron Gutman 2013-12-19 05:14:39 -05:00
parent 934e234b74
commit 163ee74e98
3 changed files with 93 additions and 2 deletions

View File

@ -38,8 +38,13 @@ or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>na
public static final int hostTextView=0x7f080000; public static final int hostTextView=0x7f080000;
public static final int imageQualityCheckbox=0x7f080002; public static final int imageQualityCheckbox=0x7f080002;
public static final int pairButton=0x7f080003; public static final int pairButton=0x7f080003;
public static final int res1080pSelected=0x7f080006;
public static final int res720pSelected=0x7f080005;
public static final int resolutionGroup=0x7f080004;
public static final int rr30Selected=0x7f080007;
public static final int rr60Selected=0x7f080008;
public static final int statusButton=0x7f080001; public static final int statusButton=0x7f080001;
public static final int surfaceView=0x7f080004; public static final int surfaceView=0x7f080009;
} }
public static final class layout { public static final class layout {
public static final int activity_connection=0x7f030000; public static final int activity_connection=0x7f030000;

View File

@ -48,4 +48,36 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:text="Pair with PC" /> android:text="Pair with PC" />
<RadioGroup android:id="@+id/resolutionGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/imageQualityCheckbox"
android:orientation="horizontal">
<RadioButton android:id="@+id/res720pSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="720p"/>
<RadioButton android:id="@+id/res1080pSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1080p (may increase lag)"/>
</RadioGroup>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/resolutionGroup"
android:orientation="horizontal">
<RadioButton android:id="@+id/rr30Selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30 FPS"/>
<RadioButton android:id="@+id/rr60Selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="60 FPS"/>
</RadioGroup>
</RelativeLayout> </RelativeLayout>

View File

@ -19,6 +19,7 @@ import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.app.Activity; import android.app.Activity;
@ -31,6 +32,7 @@ public class Connection extends Activity {
private TextView hostText; private TextView hostText;
private SharedPreferences prefs; private SharedPreferences prefs;
private CheckBox qualityCheckbox; private CheckBox qualityCheckbox;
private RadioButton rbutton720p, rbutton1080p, rbutton30fps, rbutton60fps;
private static final String DEFAULT_HOST = ""; private static final String DEFAULT_HOST = "";
public static final String HOST_KEY = "hostText"; public static final String HOST_KEY = "hostText";
@ -55,11 +57,63 @@ public class Connection extends Activity {
this.pairButton = (Button) findViewById(R.id.pairButton); this.pairButton = (Button) findViewById(R.id.pairButton);
this.hostText = (TextView) findViewById(R.id.hostTextView); this.hostText = (TextView) findViewById(R.id.hostTextView);
this.qualityCheckbox = (CheckBox) findViewById(R.id.imageQualityCheckbox); this.qualityCheckbox = (CheckBox) findViewById(R.id.imageQualityCheckbox);
this.rbutton720p = (RadioButton) findViewById(R.id.res720pSelected);
this.rbutton1080p = (RadioButton) findViewById(R.id.res1080pSelected);
this.rbutton30fps = (RadioButton) findViewById(R.id.rr30Selected);
this.rbutton60fps = (RadioButton) findViewById(R.id.rr60Selected);
prefs = getSharedPreferences(Game.PREFS_FILE_NAME, Context.MODE_MULTI_PROCESS); prefs = getSharedPreferences(Game.PREFS_FILE_NAME, Context.MODE_MULTI_PROCESS);
this.hostText.setText(prefs.getString(Connection.HOST_KEY, Connection.DEFAULT_HOST)); this.hostText.setText(prefs.getString(Connection.HOST_KEY, Connection.DEFAULT_HOST));
this.qualityCheckbox.setChecked(prefs.getBoolean(Game.QUALITY_PREF_STRING, false)); this.qualityCheckbox.setChecked(prefs.getBoolean(Game.QUALITY_PREF_STRING, false));
if (prefs.getInt(Game.HEIGHT_PREF_STRING, Game.DEFAULT_HEIGHT) == 720) {
rbutton720p.setChecked(true);
rbutton1080p.setChecked(false);
}
else {
rbutton1080p.setChecked(true);
rbutton720p.setChecked(false);
}
if (prefs.getInt(Game.REFRESH_RATE_PREF_STRING, Game.DEFAULT_REFRESH_RATE) == 30) {
rbutton30fps.setChecked(true);
rbutton60fps.setChecked(false);
}
else {
rbutton60fps.setChecked(true);
rbutton30fps.setChecked(false);
}
OnCheckedChangeListener occl = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (!isChecked) {
// Ignore non-checked buttons
return;
}
if (buttonView == rbutton30fps) {
prefs.edit().putInt(Game.REFRESH_RATE_PREF_STRING, 30).commit();
}
else if (buttonView == rbutton60fps) {
prefs.edit().putInt(Game.REFRESH_RATE_PREF_STRING, 60).commit();
}
else if (buttonView == rbutton720p) {
prefs.edit().putInt(Game.WIDTH_PREF_STRING, 1280).
putInt(Game.HEIGHT_PREF_STRING, 720).commit();
}
else if (buttonView == rbutton1080p) {
prefs.edit().putInt(Game.WIDTH_PREF_STRING, 1920).
putInt(Game.HEIGHT_PREF_STRING, 1080).commit();
}
}
};
rbutton720p.setOnCheckedChangeListener(occl);
rbutton1080p.setOnCheckedChangeListener(occl);
rbutton30fps.setOnCheckedChangeListener(occl);
rbutton60fps.setOnCheckedChangeListener(occl);
this.qualityCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { this.qualityCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {