change the way video limit is stored

This commit is contained in:
tibbi 2016-11-06 13:09:42 +01:00
parent f634df285b
commit 52190cf797
3 changed files with 46 additions and 9 deletions

View File

@ -64,14 +64,29 @@ public class Config {
private int getOldDefaultResolution() {
final int index = getMaxResolution();
switch (index) {
case 1: return Constants.EIGHT_MPX;
case 2: return 0;
default: return Constants.FIVE_MPX;
case 1:
return Constants.EIGHT_MPX;
case 2:
return 0;
default:
return Constants.FIVE_MPX;
}
}
public int getMaxVideoResolution() {
return mPrefs.getInt(Constants.MAX_VIDEO_RESOLUTION, 1);
int maxRes = mPrefs.getInt(Constants.MAX_VIDEO_RESOLUTION, Constants.P720);
switch (maxRes) {
case 0:
maxRes = Constants.P480;
break;
case 1:
maxRes = Constants.P720;
break;
case 2:
maxRes = Constants.P1080;
break;
}
return maxRes;
}
public void setMaxVideoResolution(int maxRes) {

View File

@ -5,12 +5,14 @@ public class Constants {
public static final int ORIENT_LANDSCAPE_LEFT = 1;
public static final int ORIENT_LANDSCAPE_RIGHT = 2;
public static final String TREE_URI = "tree_uri";
public static final int TWO_MPX = 3000000;
public static final int FIVE_MPX = 6000000;
public static final int EIGHT_MPX = 9000000;
public static final int P480 = 400000;
public static final int P720 = 1000000;
public static final int P1080 = 2100000;
// shared preferences
public static final String PREFS_KEY = "Camera";
public static final String IS_FIRST_RUN = "is_first_run";
@ -23,4 +25,5 @@ public class Constants {
public static final String MAX_RESOLUTION = "max_resolution";
public static final String LAST_USED_CAMERA = "last_used_camera";
public static final String LAST_FLASHLIGHT_STATE = "last_flashlight_state";
public static final String TREE_URI = "tree_uri";
}

View File

@ -154,22 +154,41 @@ class SettingsActivity : SimpleActivity() {
0 -> Constants.TWO_MPX
1 -> Constants.FIVE_MPX
2 -> Constants.EIGHT_MPX
else -> 0
else -> -1
}
}
private fun setupMaxVideoResolution() {
settings_max_video_resolution.setSelection(mConfig.maxVideoResolution)
settings_max_video_resolution.setSelection(getMaxVideoSelection())
settings_max_video_resolution.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
}
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
mConfig.maxVideoResolution = settings_max_video_resolution.selectedItemPosition
mConfig.maxVideoResolution = getMaxVideoPx(settings_max_video_resolution.selectedItemPosition)
}
}
}
private fun getMaxVideoSelection(): Int {
val maxRes = mConfig.maxVideoResolution
return when (maxRes) {
Constants.P480 -> 0
Constants.P720 -> 1
Constants.P1080 -> 2
else -> 3
}
}
private fun getMaxVideoPx(index: Int): Int {
return when (index) {
0 -> Constants.P480
1 -> Constants.P720
2 -> Constants.P1080
else -> -1
}
}
private fun restartActivity() {
TaskStackBuilder.create(applicationContext).addNextIntentWithParentStack(intent).startActivities()
}