diff --git a/app/build.gradle b/app/build.gradle index 3e23cd2..edf9d01 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,19 @@ +buildscript { + repositories { + maven { url 'https://maven.fabric.io/public' } + } + + dependencies { + classpath 'io.fabric.tools:gradle:1.+' + } +} apply plugin: 'com.android.application' +apply plugin: 'io.fabric' + +repositories { + maven { url 'https://maven.fabric.io/public' } +} + android { compileSdkVersion 25 @@ -27,4 +42,7 @@ dependencies { compile 'com.android.support:appcompat-v7:25.1.1' compile 'com.android.support:support-v4:25.1.1' testCompile 'junit:junit:4.12' + compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') { + transitive = true; + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ad5c6bf..2e18459 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,10 @@ + + \ No newline at end of file diff --git a/app/src/main/java/com/wbrawner/numberguess/GameFragment.java b/app/src/main/java/com/wbrawner/numberguess/GameFragment.java index 4c29ba4..f3ef24f 100644 --- a/app/src/main/java/com/wbrawner/numberguess/GameFragment.java +++ b/app/src/main/java/com/wbrawner/numberguess/GameFragment.java @@ -15,6 +15,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; +import android.widget.TextView; import android.widget.Toast; import java.util.Map; @@ -22,7 +23,7 @@ import java.util.Map; public class GameFragment extends Fragment { - private EditText guessInput; + private TextView guessInput; private Button guessButton; private Player user; private NumberGuess ng; @@ -50,7 +51,40 @@ public class GameFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_game, container, false); - guessInput = (EditText) rootView.findViewById(R.id.guessInput); + guessInput = (TextView) rootView.findViewById(R.id.guessInput); + for (int i = 0; i <= 9; i++) { + int buttonId = getActivity().getResources().getIdentifier( + "button_" + i, + "id", + getActivity().getPackageName() + ); + final Button inputBtn = (Button) rootView.findViewById(buttonId); + inputBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (guessInput.length() < 3) + guessInput.append(inputBtn.getText()); + } + }); + } + ((Button) rootView.findViewById(R.id.button_clear)).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + guessInput.setText(""); + } + }); + ((Button) rootView.findViewById(R.id.button_delete)).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (guessInput.getText().length() > 0) + guessInput.setText( + guessInput.getText().toString().substring( + 0, + guessInput.getText().length() - 1 + ) + ); + } + }); guessButton = (Button) rootView.findViewById(R.id.guessButton); guessButton.setOnClickListener(new View.OnClickListener() { @Override @@ -85,7 +119,6 @@ public class GameFragment extends Fragment { public void resetGame() { guessInput.setText("50"); - guessInput.setSelection(2); user = null; ng = null; diff --git a/app/src/main/java/com/wbrawner/numberguess/MainActivity.java b/app/src/main/java/com/wbrawner/numberguess/MainActivity.java index a937f3c..6e7c1ac 100644 --- a/app/src/main/java/com/wbrawner/numberguess/MainActivity.java +++ b/app/src/main/java/com/wbrawner/numberguess/MainActivity.java @@ -3,6 +3,8 @@ package com.wbrawner.numberguess; import android.app.DialogFragment; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import com.crashlytics.android.Crashlytics; +import io.fabric.sdk.android.Fabric; public class MainActivity extends AppCompatActivity implements GameOverDialogFragment.GameOverListener { @@ -12,6 +14,7 @@ public class MainActivity extends AppCompatActivity @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_main); if (savedInstanceState == null) { diff --git a/app/src/main/res/layout-land/fragment_game.xml b/app/src/main/res/layout-land/fragment_game.xml new file mode 100644 index 0000000..19a5ff3 --- /dev/null +++ b/app/src/main/res/layout-land/fragment_game.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + +