diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index ca34746..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-Calculator
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 97626ba..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 827ba1e..7ac24c7 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -3,16 +3,15 @@
diff --git a/.idea/modules.xml b/.idea/modules.xml
index dcdca1a..297565b 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 6564d52..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DrStrangeCalculator.iml b/DrStrangeCalculator.iml
new file mode 100644
index 0000000..a9d917f
--- /dev/null
+++ b/DrStrangeCalculator.iml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/app.iml b/app/app.iml
index 9a3b8a1..0044d44 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -12,10 +12,7 @@
-
-
- generateDebugAndroidTestSources
generateDebugSources
@@ -28,7 +25,7 @@
-
+
@@ -50,6 +47,13 @@
+
+
+
+
+
+
+
@@ -57,6 +61,13 @@
+
+
+
+
+
+
+
@@ -65,32 +76,29 @@
-
-
+
-
-
-
-
-
-
+
-
+
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
index ccf7d1f..30e0f4a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -22,4 +22,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
+ compile 'io.apisense:rhino-android:1.0'
+
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 641488f..aea096b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,20 +1,32 @@
+ package="com.example.android.calculator">
+
+
+ android:theme="@style/AppTheme"
+ >
+ android:label="@string/title_activity_main">
-
-
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/android/calculator/MainActivity.java b/app/src/main/java/com/example/android/calculator/MainActivity.java
index 54143e2..63eb9a9 100644
--- a/app/src/main/java/com/example/android/calculator/MainActivity.java
+++ b/app/src/main/java/com/example/android/calculator/MainActivity.java
@@ -1,27 +1,59 @@
package com.example.android.calculator;
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
-import android.widget.EditText;
+
import android.widget.TextView;
-import android.widget.Toast;
-import org.w3c.dom.Text;
+
+
+
+
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+
+
public class MainActivity extends AppCompatActivity {
+ private SensorManager mSensorManager;
+ private Sensor mAccelerometer;
+ private ShakerMethod mShakeDetector;
Button plus,minus,multiply,divide;
-TextView input_et;
-TextView result_tv;
-double a=0,res=0;
- boolean set=false;
-char operation='0';
+public static TextView input_et;
+public static TextView result_tv;
+ double res=0,a=0,previousAnswer=0;
+ // boolean set=false;
+public static char operation='0';
+ public static String expression;
+
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
+ mAccelerometer = mSensorManager
+ .getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+ mShakeDetector = new ShakerMethod();
+ mShakeDetector.setOnShakeListener(new ShakerMethod.OnShakeListener() {
+
+ @Override
+ public void onShake(int count) {
+ handleShakeEvent(count);
+ }
+ });
+ expression="";
setContentView(R.layout.activity_main);
plus=(Button)findViewById(R.id.add);
minus=(Button)findViewById(R.id.subtract);
@@ -30,6 +62,11 @@ protected void onCreate(Bundle savedInstanceState) {
input_et=(TextView)findViewById(R.id.input_et);
result_tv=(TextView)findViewById(R.id.result_tv);
}
+ public void handleShakeEvent(int count){
+ input_et.setText("0.0");
+ result_tv.setText("0.0");
+ expression="";
+ }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@@ -52,7 +89,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
- public void display(View view) {
+ public void display(View view) throws ScriptException {
switch(operation){
case '+':
res+=a;
@@ -66,116 +103,224 @@ public void display(View view) {
case '/':
res/=a;
break;
+ case '^':
+ res=Math.pow(res,a);
default:
break;
}
- a=res;
- result_tv.setText(""+res);
+
+ try {
+
+ ScriptEngine engine = new ScriptEngineManager().getEngineByName("rhino");
+ res = (double) engine.eval(correctString(expression));
+ a = res;
+ result_tv.setText("" + res);
+ input_et.setText("0.0");
+ expression="";
+ }
+ catch (Exception e){
+ return;
+ }
+ }
+ public String correctString(String modifiedExpression){
+ for(int i=0;i SHAKE_THRESHOLD_GRAVITY) {
+ final long now = System.currentTimeMillis();
+ if (mShakeTimestamp + SHAKE_SLOP_TIME_MS > now) {
+ return;
+ }
+
+ if (mShakeTimestamp + SHAKE_COUNT_RESET_TIME_MS < now) {
+ mShakeCount = 0;
+ }
+
+ mShakeTimestamp = now;
+ mShakeCount++;
+
+ mListener.onShake(mShakeCount);
+ }
+ }
+ }
+
+}
+
+
diff --git a/app/src/main/res/drawable-nodpi/example_appwidget_preview.png b/app/src/main/res/drawable-nodpi/example_appwidget_preview.png
new file mode 100644
index 0000000..894b069
Binary files /dev/null and b/app/src/main/res/drawable-nodpi/example_appwidget_preview.png differ
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 40b3bec..5df92d1 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,6 +1,11 @@
-
+
+
+
+
+ android:onClick="value9"
+ android:id="@+id/button2" />
+
+
+
+
+
+
+
+
+
+ android:onClick="clear"
+ android:id="@+id/button" />
+ android:onClick="addToMemory"
+ />
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-v14/dimens.xml b/app/src/main/res/values-v14/dimens.xml
new file mode 100644
index 0000000..4db8c59
--- /dev/null
+++ b/app/src/main/res/values-v14/dimens.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ 0dp
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 47c8224..fb6e235 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -2,4 +2,10 @@
16dp
16dp
+
+
+ 8dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d1b611f..a29d054 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4,4 +4,7 @@
Hello world!
Settings
+ EXAMPLE
+ Configure
+ Add widget