Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions LaCalculadora/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gradle
/local.properties
/.idea
.DS_Store
/build
*.iml
1 change: 1 addition & 0 deletions LaCalculadora/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions LaCalculadora/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "eboves.c4q.nyc.calculator"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
17 changes: 17 additions & 0 deletions LaCalculadora/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/elvisboves/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package eboves.c4q.nyc.calculator;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
21 changes: 21 additions & 0 deletions LaCalculadora/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eboves.c4q.nyc.calculator" >

<application
android:allowBackup="true"
android:icon="@mipmap/lacal"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added LaCalculadora/app/src/main/Lacal-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
//starts at 0, crash you click del too many times


package eboves.c4q.nyc.calculator;

import android.util.Log;
import android.view.View;
import android.widget.TextView;

/**
* Created by elvisboves on 5/13/15.
*/
public class ButtonOnClickListener implements View.OnClickListener {

TextView textView;

public ButtonOnClickListener(TextView textView) {
this.textView = textView;
}

public void onClick(View view){
String input = textView.getText().toString();
String last = "";

if (input.length() > 0){
last = input.substring(input.length() - 1);}
Log.d("last",last);

int click = view.getId();

switch (click) {

case R.id.but0:
input += "0";
break;
case R.id.but1:
input += "1";
break;
case R.id.but2:
input += "2";
break;
case R.id.but3:
input += "3";
break;
case R.id.but4:
input += "4";
break;
case R.id.but5:
input += "5";
break;
case R.id.but6:
input += "6";
break;
case R.id.but7:
input += "7";
break;
case R.id.but8:
input += "8";
break;
case R.id.but9:
input += "9";
break;

case R.id.butDot://crashes without zero look at iphone cal
if (last.equals(".")){ //prevents dot from being clicked twice in a row
input += "";
}
else if (last.equals("+")){
input+="0.";
}
else if (last.equals("-")){
input+="0.";
}
else if (last.equals("/")){
input+="0.";
}
else if (last.equals("*")) {
input += "0.";
}
else if (input.equals(" ")) {
input += "0.";
}
else {
input += ".";
}
break;
case R.id.butSum:
if (last.equals("+")){
input+="";
}
else if (last.equals("-")){
input+="";
}
else if (last.equals("/")){
input+="";
}
else if (last.equals("*")) {
input += "";
}
else if (input.equals(" ")) {
input += "";
}
else {
input += "+";
}break;

case R.id.butSub:
if (last.equals("+")){
input+="";
}
else if (last.equals("-")){
input+="";
}
else if (last.equals("/")){
input+="";
}
else if (last.equals("*")) {
input += "";
}
else {
input += "-";
}break;

case R.id.butMult:
if (last.equals("+")){
input+="";
}
else if (last.equals("-")){
input+="";
}
else if (last.equals("/")){
input+="";
}
else if (last.equals("*")) {
input += "";
}
else if (input.equals(" ")) {
input += "";
}
else {
input += "*";
}break;

case R.id.butDiv:
if (last.equals("+")){
input+="";
}
else if (last.equals("-")){
input+="";
}
else if (last.equals("/")){
input+="";
}
else if (last.equals("*")) {
input += "";
}
else if (input.equals(" ")) {
input += "";
}
else {
input += "/";
}break;

case R.id.butDelete:
if (input.length() > 1 ) { // 1 not zero or crush
input = input.substring(0, input.length() - 1);
}
else {
input = "";
}
break;
case R.id.butClr:
input = "";
break;
case R.id.butSin:
input += "Sin(";
//TODO
break;
case R.id.butCos:
input += "Cos(";
//TODO
break;
case R.id.butTan:
input += "Tan(";
//TODO
break;
case R.id.butLn:
input += "LN(";
//TODO
break;
case R.id.butLog:
input += "Log(";
//TODO
break;
case R.id.butLeftParent:
input += "(";
break;
case R.id.butRightParent:
input += ")";
break;
case R.id.butExponent:
input += "^";
//TODO
break;
case R.id.butPI:
input += "π";
//TODO
break;
case R.id.butPercent:
input += "%";
//TODO
break;
case R.id.butRadical:
input += "SQRT(";
break;
case R.id.butE:
input += "e";
break;
case R.id.butXPower:
input += ":)";
break;

case R.id.butDegree:
input += "TANRAD";
break;
case R.id.butAns:
input += "Ans";

break;
}
textView.setText(input);
}
}

Loading