dice roller completed
This commit is contained in:
parent
d9f2f7c550
commit
c1817fc1ce
|
|
@ -10,7 +10,7 @@
|
||||||
<component name="VisualizationToolProject">
|
<component name="VisualizationToolProject">
|
||||||
<option name="state">
|
<option name="state">
|
||||||
<ProjectState>
|
<ProjectState>
|
||||||
<option name="scale" value="0.22" />
|
<option name="scale" value="0.045764362220058426" />
|
||||||
</ProjectState>
|
</ProjectState>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/title_activity_notes"/>
|
android:label="@string/title_activity_notes"/>
|
||||||
<activity android:name=".main.MainActivity"/>
|
<activity android:name=".main.MainActivity"/>
|
||||||
|
|
||||||
<activity android:name=".quiz.QuizActivity"/>
|
<activity android:name=".quiz.QuizActivity"/>
|
||||||
|
<activity android:name=".dice.DiceActivity"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".login.LoginActivity"
|
android:name=".login.LoginActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,6 @@ public enum BtnID {
|
||||||
EDIT_BUTTON,
|
EDIT_BUTTON,
|
||||||
DELETE_BUTTON,
|
DELETE_BUTTON,
|
||||||
NOTES_BUTTON,
|
NOTES_BUTTON,
|
||||||
QUIZ_BUTTON
|
QUIZ_BUTTON,
|
||||||
|
DICE_BUTTON
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package xyz.r0r5chach.cpsAssist.dice;
|
||||||
|
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import xyz.r0r5chach.cpsAssist.R;
|
||||||
|
|
||||||
|
public class BtnOnClickListener implements View.OnClickListener{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
LinearLayout l = (LinearLayout) v.getParent();
|
||||||
|
Random rand = new Random();
|
||||||
|
TextView output = l.findViewById(R.id.dice_output);
|
||||||
|
EditText input = l.findViewById(R.id.dice_input);
|
||||||
|
output.setText(String.valueOf(rand.nextInt(Integer.parseInt(input.getText().toString()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package xyz.r0r5chach.cpsAssist.dice;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import xyz.r0r5chach.cpsAssist.R;
|
||||||
|
import xyz.r0r5chach.cpsAssist.dice.BtnOnClickListener;
|
||||||
|
|
||||||
|
public class DiceActivity extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_dice);
|
||||||
|
findViewById(R.id.dice_roll_button).setOnClickListener(new BtnOnClickListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import android.view.View;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import xyz.r0r5chach.cpsAssist.BtnID;
|
import xyz.r0r5chach.cpsAssist.BtnID;
|
||||||
|
import xyz.r0r5chach.cpsAssist.dice.DiceActivity;
|
||||||
import xyz.r0r5chach.cpsAssist.quiz.QuizActivity;
|
import xyz.r0r5chach.cpsAssist.quiz.QuizActivity;
|
||||||
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
||||||
|
|
||||||
|
|
@ -22,6 +23,9 @@ public class BtnOnClickListener implements View.OnClickListener{
|
||||||
case QUIZ_BUTTON:
|
case QUIZ_BUTTON:
|
||||||
intent = new Intent(v.getContext(), QuizActivity.class);
|
intent = new Intent(v.getContext(), QuizActivity.class);
|
||||||
break;
|
break;
|
||||||
|
case DICE_BUTTON:
|
||||||
|
intent = new Intent(v.getContext(), DiceActivity.class);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Activity main = (Activity) v.getContext();
|
Activity main = (Activity) v.getContext();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private void initButtons() {
|
private void initButtons() {
|
||||||
findViewById(R.id.notes_button).setOnClickListener(new BtnOnClickListener());
|
findViewById(R.id.notes_button).setOnClickListener(new BtnOnClickListener());
|
||||||
findViewById(R.id.quiz_button).setOnClickListener(new BtnOnClickListener());
|
findViewById(R.id.quiz_button).setOnClickListener(new BtnOnClickListener());
|
||||||
|
findViewById(R.id.dice_button).setOnClickListener(new BtnOnClickListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dice_output"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/dice_input"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="@string/dice_hint"
|
||||||
|
android:inputType="number"
|
||||||
|
android:minHeight="48dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/dice_roll_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dice_button_text" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/main_layout"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -15,4 +16,15 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/quiz_button_text" />
|
android:text="@string/quiz_button_text" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/background_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="hello" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/dice_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dice_roller_button_text"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -17,4 +17,7 @@
|
||||||
<string name="saveButtonText">Save</string>
|
<string name="saveButtonText">Save</string>
|
||||||
<string name="quiz_button_text">Quiz</string>
|
<string name="quiz_button_text">Quiz</string>
|
||||||
<string name="submit_button_text">Submit</string>
|
<string name="submit_button_text">Submit</string>
|
||||||
|
<string name="dice_hint">How many sides do you want the dice to have?</string>
|
||||||
|
<string name="dice_button_text">Roll</string>
|
||||||
|
<string name="dice_roller_button_text">Dice Roller</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue