Skip to content

Commit

Permalink
New version, revamp add bottom nav bar
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGitro committed Oct 7, 2024
1 parent 623b2e1 commit e00888b
Show file tree
Hide file tree
Showing 17 changed files with 509 additions and 41 deletions.
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ apply plugin: 'com.android.application'

android {

compileSdk 34
compileSdk 35
defaultConfig {
applicationId "net.sourceforge.solitaire_cg_re"
minSdkVersion 23
targetSdkVersion 34
versionCode 4100
versionName "4.1.0"
targetSdkVersion 35
versionCode 5000
versionName "5.0.0"
}

buildTypes {
Expand All @@ -39,7 +39,7 @@ android {
targetCompatibility JavaVersion.VERSION_17
}
dependencies {
implementation('com.google.android.material:material:1.11.0')
implementation('com.google.android.material:material:1.12.0')
}

namespace 'net.sourceforge.solitaire_cg_re'
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
</activity>
<activity android:name=".Help" >
</activity>
<activity android:name=".Modes" >
</activity>
</application>
</manifest>
146 changes: 146 additions & 0 deletions app/src/main/java/net/sourceforge/solitaire_cg_re/Modes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package net.sourceforge.solitaire_cg_re;


import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;

public class Modes extends Activity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.modes);
View modesView = findViewById(R.id.modes_view);
modesView.setFocusable(true);
modesView.setFocusableInTouchMode(true);

SolitaireView view = SolitaireViewManager.getInstance();

Button buttonBlackWidow = modesView.findViewById(R.id.button_blackwidow);
Button buttonBakersGame = modesView.findViewById(R.id.button_bakersgame);
Button buttonFreecell = modesView.findViewById(R.id.button_freecell);
Button buttonFortyThieves = modesView.findViewById(R.id.button_fortythieves);
Button buttonGolf = modesView.findViewById(R.id.button_golf);
Button buttonKlondikeDealOne = modesView.findViewById(R.id.button_klondike_dealone);
Button buttonKlondikeDealThree = modesView.findViewById(R.id.button_klondike_dealthree);
Button buttonSpider = modesView.findViewById(R.id.button_spider);
Button buttonTarantula = modesView.findViewById(R.id.button_tarantula);
Button buttonTripeaks = modesView.findViewById(R.id.button_tripeaks);
Button buttonTripeaksWrapcards = modesView.findViewById(R.id.button_tripeaks_wrapcards);
Button buttonVegasDealOne = modesView.findViewById(R.id.button_vegas_dealone);
Button buttonVegasDealThree = modesView.findViewById(R.id.button_vegas_dealthree);
Button buttonGolfWrapcards = modesView.findViewById(R.id.button_golf_wrapcards);


final SharedPreferences settings = getSharedPreferences("YourPreferences", MODE_PRIVATE);
final SharedPreferences.Editor editor = settings.edit();


buttonBlackWidow.setOnClickListener(v -> {
editor.putInt("SpiderSuits", 1);
editor.apply();
view.resetGameState();
view.InitGame(Rules.SPIDER);
finish();
});

buttonBakersGame.setOnClickListener(v -> {
editor.putBoolean("FreecellBuildBySuit", true);
editor.apply();
view.InitGame(Rules.FREECELL);
finish();
});

buttonFreecell.setOnClickListener(v -> {
editor.putBoolean("FreecellBuildBySuit", false);
editor.apply();
view.InitGame(Rules.FREECELL);
finish();
});

buttonFortyThieves.setOnClickListener(v -> {
view.InitGame(Rules.FORTYTHIEVES);
finish();
});

buttonGolf.setOnClickListener(v -> {
editor.putBoolean("GolfWrapCards", false);
editor.apply();
view.InitGame(Rules.GOLF);
finish();
});

buttonKlondikeDealOne.setOnClickListener(v -> {
editor.putBoolean("KlondikeDealThree", false);
editor.putBoolean("KlondikeStyleNormal", true);
editor.apply();
view.InitGame(Rules.KLONDIKE);
finish();
});

buttonKlondikeDealThree.setOnClickListener(v -> {
editor.putBoolean("KlondikeDealThree", true);
editor.putBoolean("KlondikeStyleNormal", true);
editor.apply();
view.InitGame(Rules.KLONDIKE);
finish();
});

buttonSpider.setOnClickListener(v -> {
editor.putInt("SpiderSuits", 4);
editor.apply();
view.InitGame(Rules.SPIDER);
finish();
});

buttonTarantula.setOnClickListener(v -> {
editor.putInt("SpiderSuits", 2);
editor.apply();
view.InitGame(Rules.SPIDER);
finish();
});

buttonTripeaks.setOnClickListener(v -> {
editor.putBoolean("GolfWrapCards", false);
editor.apply();
view.InitGame(Rules.TRIPEAKS);
finish();
});

buttonTripeaksWrapcards.setOnClickListener(v -> {
editor.putBoolean("GolfWrapCards", true);
editor.apply();
view.InitGame(Rules.TRIPEAKS);
finish();
});

buttonVegasDealOne.setOnClickListener(v -> {
editor.putBoolean("KlondikeDealThree", false);
editor.putBoolean("KlondikeStyleNormal", false);
editor.apply();
view.InitGame(Rules.KLONDIKE);
finish();
});

buttonVegasDealThree.setOnClickListener(v -> {
editor.putBoolean("KlondikeDealThree", true);
editor.putBoolean("KlondikeStyleNormal", false);
editor.apply();
view.InitGame(Rules.KLONDIKE);
finish();
});

buttonGolfWrapcards.setOnClickListener(v -> {
editor.putBoolean("GolfWrapCards", true);
editor.apply();
view.InitGame(Rules.GOLF);
finish();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;

// Base activity class.
public class SolitaireCGRE extends Activity {
Expand Down Expand Up @@ -78,6 +73,7 @@ public class SolitaireCGRE extends Activity {
public void ClearRestoreState() { mRestoreState = ""; }
public String GetRestoreState() { return mRestoreState; }
public void SetRestoreState(String state) { mRestoreState = state; }
private BottomNavigationView bottomNavigationView;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -118,6 +114,32 @@ public void onCreate(Bundle savedInstanceState) {
} catch (NameNotFoundException e) {
Log.e("SolitaireCG.java", e.getMessage());
}

bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(item -> {
switch (item.getItemId()) {
case R.id.nav_new:
mSolitaireView.InitGame(mSettings.getInt("LastType", Rules.KLONDIKE));
return true;
case R.id.nav_modes:
DisplayModes();
return true;
case R.id.nav_options:
DisplayOptions();
return true;
case R.id.nav_stats:
DisplayStats();
return true;
case R.id.nav_help:
DisplayHelp();
return true;
//case R.id.nav_exit:
//finish();
//return true;
default:
return false;
}
});
}

// Entry point for starting the game.
Expand Down Expand Up @@ -149,6 +171,7 @@ private void SplashScreen() {
}
}

/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
Expand Down Expand Up @@ -278,6 +301,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return false;
}
// Alternate Menu
// Invoked with long press and needed on some devices where Android
// options menu is not accessible or available.
Expand Down Expand Up @@ -425,7 +449,7 @@ public boolean onContextItemSelected(MenuItem item) {
return false;
}

*/
@Override
protected void onPause() {
super.onPause();
Expand Down Expand Up @@ -475,6 +499,13 @@ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}

public void DisplayModes(){
mSolitaireView.SetTimePassing(false);
SolitaireViewManager.setInstance(mSolitaireView);
Intent modesActivity = new Intent(this, Modes.class);
startActivity(modesActivity);
}

public void DisplayOptions() {
mSolitaireView.SetTimePassing(false);
Intent settingsActivity = new Intent(this, Preferences.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public SolitaireView(Context context, AttributeSet attrs) {
}

public void InitGame(int gameType) {
resetGameState();
int oldScore = 0;
String oldGameType = "None";

Expand Down Expand Up @@ -948,6 +949,14 @@ public void RefreshOptions() {
mRules.RefreshOptions();
SetDisplayTime(GetSettings().getBoolean("DisplayTime", true));
}

public void resetGameState() {
mMoveHistory.clear();
mWinningScore = 0;
mGameStarted = false;
mElapsed = 0;
mTimePaused = false;
}
}

class RefreshHandler implements Runnable {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.sourceforge.solitaire_cg_re;

public class SolitaireViewManager {
private static SolitaireView instance;

public static void setInstance(SolitaireView view) {
instance = view;
}

public static SolitaireView getInstance() {
return instance;
}
}
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/ic_help.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="800dp"
android:height="800dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,20H12.01"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M7,9C7,7.874 7.372,6.836 8,6C8.912,4.786 10.364,4 12,4C14.761,4 17,6.239 17,9C17,11.421 15.279,13.441 12.994,13.901C12.452,14.01 12,14.448 12,15V15V16"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
</vector>
38 changes: 38 additions & 0 deletions app/src/main/res/drawable/ic_modes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="800dp"
android:height="800dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="M0,0h48v48h-48z"
android:fillColor="#ffffff"
android:fillAlpha="0.01"/>
<path
android:pathData="M18,31H38V5"
android:strokeLineJoin="round"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M30,21H10V43"
android:strokeLineJoin="round"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M44,11L38,5L32,11"
android:strokeLineJoin="round"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M16,37L10,43L4,37"
android:strokeLineJoin="round"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_new.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:fillColor="#FF000000"
android:pathData="m63.98,18.16c-11.73,0 -23.46,4.49 -32.41,13.44 -17.9,17.9 -17.9,46.91 0,64.81 17.9,17.9 46.94,17.9 64.84,0 17.9,-17.9 17.9,-46.91 0,-64.81 -8.95,-8.95 -20.7,-13.44 -32.44,-13.44zM55.58,36.35 L72.39,36.35 72.39,55.6 91.64,55.6 91.64,72.41 72.39,72.41 72.39,91.66 55.58,91.66 55.58,72.41 36.33,72.41 36.33,55.6 55.58,55.6 55.58,36.35z"/>
</vector>
Loading

0 comments on commit e00888b

Please sign in to comment.