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 .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

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

3 changes: 1 addition & 2 deletions .idea/gradle.xml

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

25 changes: 5 additions & 20 deletions .idea/misc.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/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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'
Expand Down
69 changes: 22 additions & 47 deletions app/src/main/java/com/example/pranav/finalcalc/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip