diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
new file mode 100644
index 0000000..b966913
Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..30aa626
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 3cd8408..7ac24c7 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -3,9 +3,8 @@
-
+
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 360423f..88c9d2c 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 42231a8..567d194 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,11 +1,12 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 26
+ compileSdkVersion 28
defaultConfig {
+ buildToolsVersion "28.0.3"
applicationId "com.example.pranav.finalcalc"
minSdkVersion 19
- targetSdkVersion 26
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,7 +21,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.android.support:appcompat-v7:26.1.0'
+ implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
diff --git a/app/src/main/java/com/example/pranav/finalcalc/MainActivity.java b/app/src/main/java/com/example/pranav/finalcalc/MainActivity.java
index b437366..c922be3 100644
--- a/app/src/main/java/com/example/pranav/finalcalc/MainActivity.java
+++ b/app/src/main/java/com/example/pranav/finalcalc/MainActivity.java
@@ -30,88 +30,55 @@ protected void onCreate(Bundle savedInstanceState) {
b10=findViewById(R.id.button10);
b11=findViewById(R.id.button11);
b12=findViewById(R.id.button12);
+
edit = findViewById(R.id.Text1);
+
+ //Added b14 findViewById to avoid crash when 0 button is clicked
+ b14 = findViewById(R.id.button14);
}
public void one(View view) {
-
- s=edit.getText().toString();
- sb=b1.getText().toString();
- sb=b1.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b1);
}
public void two(View view) {
-
- s=edit.getText().toString();
- sb=b2.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b2);
}
public void three(View view) {
-
- s=edit.getText().toString();
- sb=b3.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b3);
}
public void four(View view) {
-
- s=edit.getText().toString();
- sb=b5.getText().toString();
- edit.setText(s+sb);
+ setTextFromButton(b5);
}
public void five(View view) {
- s=edit.getText().toString();
- sb=b6.getText().toString();
- edit.setText(s+sb);
+ setTextFromButton(b6);
}
public void six(View view) {
-
- s=edit.getText().toString();
- sb=b7.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b7);
}
public void seven(View view) {
-
- s=edit.getText().toString();
- sb=b9.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b9);
}
public void eight(View view) {
-
- s=edit.getText().toString();
- sb=b10.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b10);
}
public void nine(View view) {
- s=edit.getText().toString();
- sb=b11.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b11);
}
public void zero(View view) {
-
- s=edit.getText().toString();
- sb=b14.getText().toString();
- edit.setText(s+sb);
-
+ setTextFromButton(b14);
}
public void reset(View view) {
@@ -186,4 +153,12 @@ public void result(View view) {
}
}
+
+ /** Get text from button and concatenate with edit**/
+ public void setTextFromButton(Button button)
+ {
+ s = edit.getText().toString();
+ sb = button.getText().toString();
+ edit.setText(s+sb);
+ }
}
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 5885930..0d653f3 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
-