Skip to content

Commit

Permalink
Energy boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
quarian committed Oct 1, 2016
1 parent fdce2b7 commit 2d18aa7
Show file tree
Hide file tree
Showing 18 changed files with 164 additions and 23 deletions.
10 changes: 8 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 32 additions & 13 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
Expand All @@ -28,7 +25,7 @@
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
Expand All @@ -50,40 +47,62 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
buildToolsVersion "21.0.0"

defaultConfig {
minSdkVersion 11
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/minu/lifecount2020/app/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public final class Constants {
public static final String POISON = "POISON";
public static final String STARTING_LIFE = "20";
public static final String STARTING_POISON = "0";
public static final String STARTING_ENERGY = "0";
public static final String PICKER_ONE_LIFE = "PICKER_ONE_LIFE";
public static final String PICKER_TWO_LIFE = "PICKER_TWO_LIFE";
public static final String PICKER_ONE_POISON = "PICKER_ONE_POISON";
public static final String PICKER_TWO_POISON = "PICKER_TWO_POISON";
public static final String PICKER_ONE_ENERGY = "PICKER_ONE_ENERGY";
public static final String PICKER_TWO_ENERGY = "PICKER_TWO_ENERGY";
public static final String HISTORY = "HISTORY";
public static final String READ = "READ";
public static final float THROW_ACCELERATION = 13.0f;
Expand Down
61 changes: 61 additions & 0 deletions app/src/main/java/com/minu/lifecount2020/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public class MainActivity extends SensorActivity {
private LinearLayout mLifeLinearLayoutTwo;
private LinearLayout mPoisonLinearLayoutOne;
private LinearLayout mPoisonLinearLayoutTwo;
private LinearLayout mEnergyLinerLayoutOne;
private LinearLayout mEnergyLinerLayoutTwo;
private TextView mLifePickerOne;
private TextView mLifePickerTwo;
private TextView mPoisonPickerOne;
private TextView mPoisonPickerTwo;
private TextView mEnergyPickerOne;
private TextView mEnergyPickerTwo;

private ImageButton mSettingsButton;
private ImageButton mHistoryButton;
Expand All @@ -55,6 +59,7 @@ public class MainActivity extends SensorActivity {
private TextView mRighyUpdateTextView;

private boolean mPoisonShowing;
private boolean mEnergyShowing;

private ArrayList<String> mOptions;

Expand Down Expand Up @@ -139,6 +144,10 @@ private void restoreSettings() {
mPoisonShowing = !mPoisonShowing;
displayPoison();
}
if (mEnergyShowing) {
mEnergyShowing = !mEnergyShowing;
displayEnergy();
}

if (mTimerShowing) {
mTimerShowing = !mTimerShowing;
Expand All @@ -161,12 +170,17 @@ private void restoreFromPreferences() {
String lifeTwo = settings.getString(Constants.PICKER_TWO_LIFE, Constants.STARTING_LIFE);
String poisonOne = settings.getString(Constants.PICKER_ONE_POISON, Constants.STARTING_POISON);
String poisonTwo = settings.getString(Constants.PICKER_TWO_POISON, Constants.STARTING_POISON);
String energyOne = settings.getString(Constants.PICKER_ONE_ENERGY, Constants.STARTING_ENERGY);
String energyTwo = settings.getString(Constants.PICKER_TWO_ENERGY, Constants.STARTING_ENERGY);
mBackgroundColor = BackgroundColor.values()[settings.getInt(Constants.BACKGROUND_WHITE, 0)];
mLifePickerOne.setText(lifeOne);
mLifePickerTwo.setText(lifeTwo);
mPoisonPickerOne.setText(poisonOne);
mPoisonPickerTwo.setText(poisonTwo);
mEnergyPickerOne.setText(energyOne);
mEnergyPickerTwo.setText(energyTwo);
mPoisonShowing = settings.getBoolean(Constants.POISON, false);
mEnergyShowing = settings.getBoolean(Constants.POISON, false);
mStartingLife = settings.getInt(Constants.STARTING_LIFE,
Integer.parseInt(Constants.STARTING_LIFE));
mRoundTime = settings.getInt(Constants.ROUND_TIME, 50);
Expand Down Expand Up @@ -196,6 +210,8 @@ protected void onStop(){
editor.putString(Constants.PICKER_TWO_LIFE, mLifePickerTwo.getText().toString());
editor.putString(Constants.PICKER_ONE_POISON, mPoisonPickerOne.getText().toString());
editor.putString(Constants.PICKER_TWO_POISON, mPoisonPickerTwo.getText().toString());
editor.putString(Constants.PICKER_ONE_ENERGY, mEnergyPickerOne.getText().toString());
editor.putString(Constants.PICKER_TWO_ENERGY, mEnergyPickerTwo.getText().toString());
editor.putInt(Constants.BACKGROUND_WHITE, mBackgroundColor.ordinal());
editor.putBoolean(Constants.POISON, mPoisonShowing);
editor.putInt(Constants.STARTING_LIFE, mStartingLife);
Expand All @@ -213,6 +229,8 @@ public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putString(Constants.PICKER_ONE_POISON, mPoisonPickerOne.getText().toString());
savedInstanceState.putString(Constants.PICKER_TWO_LIFE, mLifePickerTwo.getText().toString());
savedInstanceState.putString(Constants.PICKER_TWO_POISON, mPoisonPickerTwo.getText().toString());
savedInstanceState.putString(Constants.PICKER_ONE_ENERGY, mEnergyPickerOne.getText().toString());
savedInstanceState.putString(Constants.PICKER_TWO_ENERGY, mEnergyPickerTwo.getText().toString());

savedInstanceState.putSerializable(Constants.BACKGROUND_WHITE, mBackgroundColor);
int startingLife;
Expand Down Expand Up @@ -246,12 +264,18 @@ private void bindElements() {
mPoisonLinearLayoutOne = (LinearLayout) findViewById(R.id.first_poison_picker_layout);
mPoisonLinearLayoutTwo = (LinearLayout) findViewById(R.id.second_poison_picker_layout);

mEnergyLinerLayoutOne = (LinearLayout) findViewById(R.id.first_energy_picker_layout);
mEnergyLinerLayoutTwo = (LinearLayout) findViewById(R.id.second_energy_picker_layout);

mLifePickerOne = (TextView) findViewById(R.id.life_picker_1);
mLifePickerTwo = (TextView) findViewById(R.id.life_picker_2);

mPoisonPickerOne = (TextView) findViewById(R.id.poison_picker_1);
mPoisonPickerTwo = (TextView) findViewById(R.id.poison_picker_2);

mEnergyPickerOne = (TextView) findViewById(R.id.energy_picker_1);
mEnergyPickerTwo = (TextView) findViewById(R.id.energy_picker_2);

setInitialColors();

mWrapper = (LinearLayout) findViewById(R.id.wrapper);
Expand Down Expand Up @@ -287,18 +311,32 @@ private void setInitialColors() {
int blue = Color.parseColor(getString(R.string.color_blue));
mLifePickerOne.setTextColor(red);
mPoisonPickerOne.setTextColor(red);
mEnergyPickerOne.setTextColor(red);
mLifePickerTwo.setTextColor(blue);
mPoisonPickerTwo.setTextColor(blue);
mEnergyPickerTwo.setTextColor(blue);
Drawable arrowLeft = getResources().getDrawable(R.drawable.left_arrow);
Drawable arrowRight = getResources().getDrawable(R.drawable.right_arrow);
Drawable energyIconLeft = getResources().getDrawable(R.drawable.energy_icon_left);
Drawable energyIconRight = getResources().getDrawable(R.drawable.energy_icon_right);
if (arrowLeft != null)
arrowLeft.setColorFilter(Color.parseColor(getString(R.string.color_text)),
PorterDuff.Mode.SRC_ATOP);
if (arrowRight != null)
arrowRight.setColorFilter(Color.parseColor(getString(R.string.color_text)),
PorterDuff.Mode.SRC_ATOP);
if (energyIconLeft != null)
energyIconLeft.setColorFilter(red,
PorterDuff.Mode.SRC_ATOP);
if (energyIconRight != null)
energyIconRight.setColorFilter(blue,
PorterDuff.Mode.SRC_ATOP);

((ImageView)findViewById(R.id.update_arrow_left)).setImageDrawable(arrowLeft);
((ImageView)findViewById(R.id.update_arrow_right)).setImageDrawable(arrowRight);

((ImageView)findViewById(R.id.energy_icon_one)).setImageDrawable(energyIconLeft);
((ImageView)findViewById(R.id.energy_icon_two)).setImageDrawable(energyIconRight);
}

private void collapseHistory() {
Expand Down Expand Up @@ -356,14 +394,21 @@ private void initElements() {
setLayoutTouchListener(mLifeLinearLayoutTwo, mLifePickerTwo);
setLayoutTouchListener(mPoisonLinearLayoutOne, mPoisonPickerOne);
setLayoutTouchListener(mPoisonLinearLayoutTwo, mPoisonPickerTwo);
setLayoutTouchListener(mEnergyLinerLayoutOne, mEnergyPickerOne);
setLayoutTouchListener(mEnergyLinerLayoutTwo, mEnergyPickerTwo);
setTextViewOnTouchListener(mLifePickerOne, false);
setTextViewOnTouchListener(mLifePickerTwo, false);
setTextViewOnTouchListener(mPoisonPickerOne, true);
setTextViewOnTouchListener(mPoisonPickerTwo, true);
setTextViewOnTouchListener(mEnergyPickerOne, false);
setTextViewOnTouchListener(mEnergyPickerTwo, false);

mPoisonLinearLayoutOne.setVisibility(View.GONE);
mPoisonLinearLayoutTwo.setVisibility(View.GONE);

mEnergyLinerLayoutOne.setVisibility(View.VISIBLE);
mEnergyLinerLayoutTwo.setVisibility(View.VISIBLE);

instantiateArrayLists();

mStartingLife = 20;
Expand Down Expand Up @@ -562,6 +607,22 @@ private void displayPoison() {
((SettingsListAdapter)mSettingsDrawerList.getAdapter()).notifyDataSetChanged();
}

private void displayEnergy() {
if (mEnergyShowing) {
mEnergyLinerLayoutOne.setVisibility(View.GONE);
mEnergyLinerLayoutTwo.setVisibility(View.GONE);
mEnergyShowing = false;
} else {
mEnergyLinerLayoutOne.setVisibility(View.VISIBLE);
mEnergyLinerLayoutTwo.setVisibility(View.VISIBLE);
mEnergyShowing = true;
}

((SettingsListAdapter)mSettingsDrawerList.getAdapter()).notifyDataSetChanged();

}


protected void checkShake(float x, float y, float z) {
float acceleration = (float) Math.sqrt((double) x*x + y*y + z*z);
if (Math.abs(acceleration - mGravity) > Constants.THROW_ACCELERATION)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2d18aa7

Please sign in to comment.