Merge branch 'master' into dice
This commit is contained in:
commit
f8a5b6f871
|
|
@ -6,5 +6,7 @@ public enum BtnID {
|
||||||
DELETE_BUTTON,
|
DELETE_BUTTON,
|
||||||
NOTES_BUTTON,
|
NOTES_BUTTON,
|
||||||
QUIZ_BUTTON,
|
QUIZ_BUTTON,
|
||||||
DICE_BUTTON
|
DICE_BUTTON,
|
||||||
|
BACKGROUND_BUTTON
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,29 @@ package xyz.r0r5chach.cpsAssist.main;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import xyz.r0r5chach.cpsAssist.BtnID;
|
import xyz.r0r5chach.cpsAssist.BtnID;
|
||||||
import xyz.r0r5chach.cpsAssist.dice.DiceActivity;
|
import xyz.r0r5chach.cpsAssist.dice.DiceActivity;
|
||||||
|
import xyz.r0r5chach.cpsAssist.R;
|
||||||
import xyz.r0r5chach.cpsAssist.quiz.QuizActivity;
|
import xyz.r0r5chach.cpsAssist.quiz.QuizActivity;
|
||||||
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
||||||
|
|
||||||
public class BtnOnClickListener implements View.OnClickListener{
|
public class BtnOnClickListener implements View.OnClickListener{
|
||||||
|
private String backgroundColor;
|
||||||
|
|
||||||
|
public BtnOnClickListener() {
|
||||||
|
backgroundColor = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
LinearLayout l = (LinearLayout) v.getParent();
|
||||||
String id = v.getResources().getResourceName(v.getId()).split("/")[1];
|
String id = v.getResources().getResourceName(v.getId()).split("/")[1];
|
||||||
Intent intent = null;
|
Intent intent = null;
|
||||||
switch(BtnID.valueOf(id.toUpperCase(Locale.ROOT))) {
|
switch(BtnID.valueOf(id.toUpperCase(Locale.ROOT))) {
|
||||||
|
|
@ -25,11 +36,18 @@ public class BtnOnClickListener implements View.OnClickListener{
|
||||||
break;
|
break;
|
||||||
case DICE_BUTTON:
|
case DICE_BUTTON:
|
||||||
intent = new Intent(v.getContext(), DiceActivity.class);
|
intent = new Intent(v.getContext(), DiceActivity.class);
|
||||||
|
case BACKGROUND_BUTTON:
|
||||||
|
Random rand = new Random();
|
||||||
|
backgroundColor = String.format("#%06x", rand.nextInt(0xffffff + 1));
|
||||||
|
l.setBackgroundColor(Color.parseColor(backgroundColor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Activity main = (Activity) v.getContext();
|
Activity main = (Activity) v.getContext();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
intent.putExtra("username", main.getIntent().getStringExtra("username"));
|
intent.putExtra("username", main.getIntent().getStringExtra("username"));
|
||||||
|
if (backgroundColor != null) {
|
||||||
|
intent.putExtra("background", backgroundColor);
|
||||||
|
}
|
||||||
main.startActivity(intent);
|
main.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package xyz.r0r5chach.cpsAssist.main;
|
package xyz.r0r5chach.cpsAssist.main;
|
||||||
|
|
||||||
|
import android.media.MediaDrm;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
@ -22,8 +23,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
} //TODO: Add change background button to layout and add logic to listner
|
} //TODO: Add change background button to layout and add logic to listner
|
||||||
|
|
||||||
private void initButtons() {
|
private void initButtons() {
|
||||||
findViewById(R.id.notes_button).setOnClickListener(new BtnOnClickListener());
|
BtnOnClickListener lstn = new BtnOnClickListener();
|
||||||
findViewById(R.id.quiz_button).setOnClickListener(new BtnOnClickListener());
|
findViewById(R.id.notes_button).setOnClickListener(lstn);
|
||||||
findViewById(R.id.dice_button).setOnClickListener(new BtnOnClickListener());
|
findViewById(R.id.quiz_button).setOnClickListener(lstn);
|
||||||
|
findViewById(R.id.background_button).setOnClickListener(lstn);
|
||||||
|
findViewById(R.id.dice_button).setOnClickListener(lstn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
@ -18,6 +19,9 @@ public class NotesActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_notes);
|
setContentView(R.layout.activity_notes);
|
||||||
initRecycler();
|
initRecycler();
|
||||||
setTitle("Notes- " + getIntent().getStringExtra("username"));
|
setTitle("Notes- " + getIntent().getStringExtra("username"));
|
||||||
|
if (getIntent().hasExtra("background")) {
|
||||||
|
findViewById(R.id.notes_layout).setBackgroundColor(Color.parseColor(getIntent().getStringExtra("background")));
|
||||||
|
}
|
||||||
findViewById(R.id.add_Button).setOnClickListener(new BtnOnClickListener(adapter));
|
findViewById(R.id.add_Button).setOnClickListener(new BtnOnClickListener(adapter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package xyz.r0r5chach.cpsAssist.quiz;
|
package xyz.r0r5chach.cpsAssist.quiz;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
@ -21,6 +22,9 @@ public class QuizActivity extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_quiz);
|
setContentView(R.layout.activity_quiz);
|
||||||
setTitle("Quiz- " + getIntent().getStringExtra("username"));
|
setTitle("Quiz- " + getIntent().getStringExtra("username"));
|
||||||
|
if (getIntent().hasExtra("background")) {
|
||||||
|
findViewById(R.id.quiz_layout).setBackgroundColor(Color.parseColor(getIntent().getStringExtra("background")));
|
||||||
|
}
|
||||||
LinearLayout layout = findViewById(R.id.quiz_layout);
|
LinearLayout layout = findViewById(R.id.quiz_layout);
|
||||||
quiz = new Quiz(getString(R.string.questions), getString(R.string.correct_answers), getString(R.string.incorrect_answers));
|
quiz = new Quiz(getString(R.string.questions), getString(R.string.correct_answers), getString(R.string.incorrect_answers));
|
||||||
initQuestions(layout);
|
initQuestions(layout);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
android:id="@+id/background_button"
|
android:id="@+id/background_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="hello" />
|
android:text="@string/change_background_button_text" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/dice_button"
|
android:id="@+id/dice_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/notes_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.CpsAssist" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.CpsAssist" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
|
|
@ -13,8 +13,4 @@
|
||||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
<style name="edit_dialog">
|
|
||||||
<item name="android:background">@color/white</item>
|
|
||||||
<item name="android:textColor">@color/black</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -20,4 +20,5 @@
|
||||||
<string name="dice_hint">How many sides do you want the dice to have?</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_button_text">Roll</string>
|
||||||
<string name="dice_roller_button_text">Dice Roller</string>
|
<string name="dice_roller_button_text">Dice Roller</string>
|
||||||
|
<string name="change_background_button_text">Change Background</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -19,8 +19,4 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="Theme.CpsAssist.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
<style name="Theme.CpsAssist.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
<style name="Theme.CpsAssist.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
<style name="Theme.CpsAssist.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
<style name="edit_dialog">
|
|
||||||
<item name="android:background">@color/black</item>
|
|
||||||
<item name="android:textColor">@color/white</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue