├── .gitignore ├── .idea ├── assetWizardSettings.xml ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml └── runConfigurations.xml ├── Calculator.apk ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── exp4j-0.4.8.jar │ └── jsr223.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── comtarun_narain │ │ └── github │ │ └── calculator │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── comtarun_narain │ │ │ └── github │ │ │ └── calculator │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── comtarun_narain │ └── github │ └── calculator │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/assetWizardSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tarun-Narain/Android-Calculator/cbf8a5c54eabee0aedf94c7730918c687562b544/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /Calculator.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tarun-Narain/Android-Calculator/cbf8a5c54eabee0aedf94c7730918c687562b544/Calculator.apk -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Calculator 2 | Android Calculator example made in Android Studio with Library exp4j(For Calculations). 3 | Can Solve Mathematical Expressions. 4 | 5 | ![](https://image.ibb.co/c5RVOo/Screenshot_2018_07_30_20_34_14_649_comtarun_narain_github_calculator_1.png) 6 | 7 | Just for example, nothing professional. 8 | 9 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "comtarun_narain.github.calculator" 7 | minSdkVersion 15 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:28.0.0-beta01' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation files('libs/exp4j-0.4.8.jar') 29 | } 30 | -------------------------------------------------------------------------------- /app/libs/exp4j-0.4.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tarun-Narain/Android-Calculator/cbf8a5c54eabee0aedf94c7730918c687562b544/app/libs/exp4j-0.4.8.jar -------------------------------------------------------------------------------- /app/libs/jsr223.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tarun-Narain/Android-Calculator/cbf8a5c54eabee0aedf94c7730918c687562b544/app/libs/jsr223.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/comtarun_narain/github/calculator/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package comtarun_narain.github.calculator; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("comtarun_narain.github.calculator", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/comtarun_narain/github/calculator/MainActivity.java: -------------------------------------------------------------------------------- 1 | package comtarun_narain.github.calculator; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.widget.Button; 6 | import android.widget.TextView; 7 | import android.view.View; 8 | 9 | import net.objecthunter.exp4j.Expression; 10 | import net.objecthunter.exp4j.ExpressionBuilder; 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | } 18 | public void setText(View view) 19 | { 20 | 21 | 22 | TextView tv=findViewById(R.id.Display); 23 | Button b1=findViewById(view.getId()); 24 | String str=(String)tv.getText(); 25 | tv.setText(str+b1.getText()); 26 | 27 | } 28 | public void solve(View view) 29 | { 30 | TextView tv=findViewById(R.id.Display); 31 | String str=(String)tv.getText(); 32 | double result=0; 33 | try { 34 | Expression e = new ExpressionBuilder(str).build(); 35 | result = e.evaluate(); 36 | tv.setText(Double.toString(result)); 37 | } catch(Exception e) 38 | { 39 | tv.setText("ERROR"); 40 | } 41 | 42 | } 43 | public void Delete(View view) 44 | { 45 | TextView tv=findViewById(R.id.Display); 46 | String str=(String)tv.getText(); 47 | try { 48 | int len = str.length(); 49 | StringBuilder br = new StringBuilder(str); 50 | br.deleteCharAt(len - 1); 51 | tv.setText(br); 52 | } 53 | catch(Exception e) 54 | { 55 | tv.setText("OUT OF BOUND"); 56 | } 57 | } 58 | public void Ac(View view) 59 | { 60 | TextView tv=findViewById(R.id.Display); 61 | tv.setText(""); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |