Skip to content

Commit

Permalink
default bet amount setting
Browse files Browse the repository at this point in the history
  • Loading branch information
MIPPL committed Sep 8, 2020
1 parent 3aa8e4e commit fa1646c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 4 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId = 'com.wagerrwallet'
minSdkVersion 23
targetSdkVersion 28
versionCode 282
versionName "282"
versionCode 283
versionName "283"
multiDexEnabled true

// Similar to other properties in the defaultConfig block,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import android.support.v7.widget.AppCompatCheckBox;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckedTextView;
Expand Down Expand Up @@ -44,6 +46,7 @@ public class BetSettings extends BRActivity {
private Switch chkDisplayAmerican;
private static BetSettings app;
private ImageButton mBackButton;
private EditText mDefaultBet;

public static BetSettings getApp() {
return app;
Expand All @@ -57,6 +60,7 @@ protected void onSaveInstanceState(Bundle outState) {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_betsettings);
app = this;

chkDisplayOdds = findViewById(R.id.chk_displayodds);
chkDisplayOdds.setChecked(BRSharedPrefs.getFeatureEnabled(this, FEATURE_DISPLAY_ODDS, false));
Expand All @@ -76,6 +80,31 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});

mDefaultBet = (EditText) findViewById(R.id.editDefBet);
int min = this.getResources().getInteger(R.integer.min_bet_amount);
int def = BRSharedPrefs.getDefaultBetAmount(app);
if ( def==0 ) def = min;
mDefaultBet.setText("" + def);
mDefaultBet.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
mDefaultBet.clearFocus();
InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

int newVal = Integer.parseInt( mDefaultBet.getText().toString() );
if ( newVal < min ) {
newVal = min;
mDefaultBet.setText("" + newVal);
}
BRSharedPrefs.putDefaultBetAmount(app, newVal );
return true;
}
return false;
}
});

mBackButton = findViewById(R.id.back_button);

mBackButton.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ public void onClick(View v) {
getContext().getResources().getInteger(R.integer.max_bet_amount));
seekBar.setMax(max-min);

updateSeekBar(getContext().getResources().getInteger(R.integer.min_bet_amount), 0);
int defVal = Math.min( BRSharedPrefs.getDefaultBetAmount(getContext()), max );
mTxAmount.setText("" + defVal);
updateSeekBar(defVal, 0);
seekBar.setProgress( defVal - min);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,17 @@ public static boolean wasBchDialogShown(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return prefs.getBoolean("bchDialogShown", false);
}

public static int getDefaultBetAmount(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
return settingsToGet.getInt("defaultBet", 0);
}

public static void putDefaultBetAmount(Context context, int defValue) {
if (context == null) return;
SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("defaultBet", defValue);
editor.apply();
}
}
45 changes: 44 additions & 1 deletion app/src/main/res/layout/activity_betsettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</LinearLayout>
</LinearLayout>

</android.support.v7.widget.Toolbar>

Expand Down Expand Up @@ -76,5 +76,48 @@
app:layout_constraintLeft_toLeftOf="@+id/toolbar"
app:layout_constraintTop_toBottomOf="@+id/chk_displayodds"/>

<com.wagerrwallet.presenter.customviews.BRText
android:id="@+id/labelDefBet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:lineSpacingMultiplier="1.3"
android:text="Default bet amount"
android:textSize="16sp"
android:textColor="@color/black"
app:customTFont="CircularPro-Book.otf"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/chk_displayamerican" />

<com.wagerrwallet.presenter.customviews.BRText
android:id="@+id/labelCurrency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:lineSpacingMultiplier="1.3"
android:text="WGR"
android:textSize="16sp"
app:customTFont="CircularPro-Bold.otf"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/chk_displayamerican" />

<EditText
android:id="@+id/editDefBet"
android:layout_width="80dp"
android:layout_height="44dp"
android:ems="10"
android:gravity="right"
android:text="25"
android:inputType="number"
app:layout_constraintRight_toLeftOf="@id/labelCurrency"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@id/chk_displayamerican"
/>


</android.support.constraint.ConstraintLayout>

0 comments on commit fa1646c

Please sign in to comment.