├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── calc.png
│ │ │ │ ├── key.png
│ │ │ │ ├── back12.jpg
│ │ │ │ ├── background.jpeg
│ │ │ │ ├── background5.jpeg
│ │ │ │ ├── buttonborder.xml
│ │ │ │ └── edittextborder.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
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── layout
│ │ │ │ ├── dialog_magic.xml
│ │ │ │ ├── activity_key_tables.xml
│ │ │ │ ├── dialog_rating.xml
│ │ │ │ ├── item.xml
│ │ │ │ ├── dialog_newkey.xml
│ │ │ │ └── activity_main.xml
│ │ │ └── menu
│ │ │ │ ├── menu1.xml
│ │ │ │ └── menu2.xml
│ │ ├── java
│ │ │ └── cheema
│ │ │ │ └── calculater
│ │ │ │ ├── mymagic
│ │ │ │ ├── pojo_classes
│ │ │ │ │ └── KeylogPojo.java
│ │ │ │ ├── Magic.java
│ │ │ │ ├── adapters
│ │ │ │ │ └── Keytables_list_adapter.java
│ │ │ │ └── KeyTables.java
│ │ │ │ ├── myButtons
│ │ │ │ ├── NumButton.java
│ │ │ │ ├── MyButton.java
│ │ │ │ └── SignButton.java
│ │ │ │ ├── SwipeListener.java
│ │ │ │ ├── CalculatorLib
│ │ │ │ ├── Token.java
│ │ │ │ └── SrbCalculator.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── cheema
│ │ │ └── calculater
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── cheema
│ │ └── calculater
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── screenshots
├── keys.jpeg
├── cheat_code.jpeg
├── normal_menu.jpeg
└── secret_menu.jpeg
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── CONTRIBUTING.md
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/screenshots/keys.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/screenshots/keys.jpeg
--------------------------------------------------------------------------------
/screenshots/cheat_code.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/screenshots/cheat_code.jpeg
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/screenshots/normal_menu.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/screenshots/normal_menu.jpeg
--------------------------------------------------------------------------------
/screenshots/secret_menu.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/screenshots/secret_menu.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/calc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/drawable/calc.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/drawable/key.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/back12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/drawable/back12.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/drawable/background.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background5.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/drawable/background5.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srbcheema1/Magic-Calculator/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jul 08 09:51:24 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_magic.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/buttonborder.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/edittextborder.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | ## Thanks for taking the time to contribute to this project. Before making PRs, please note the following:
4 | - Give the PR a meaningful name.
5 | - For e.g. 'Fixes #(issue-number): PR name, fixing the particular bug' (without commas)
6 | - There should be 1 commit for 1 PR.
7 | - If there are more than 1 commit in a PR, squash them.
8 | - Pull Request details should be descriptive.
9 | - Commit message should meaningful.
10 |
--------------------------------------------------------------------------------
/app/src/test/java/cheema/calculater/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Calculater
3 | History
4 | Rate Our App
5 | About Us
6 | Advance Settings
7 | Toggle dynamic Ans
8 | Calculater is an android application developed during Summer Holidays \n\nThis is just a fun application.\n
9 | \n\nDevelopers:--\nSarbjit Singh
10 | \n\nThank you for using app..!!
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/mymagic/pojo_classes/KeylogPojo.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.mymagic.pojo_classes;
2 |
3 | /**
4 | * Created by srb on 7/7/17.
5 | */
6 |
7 | public class KeylogPojo {
8 |
9 | public KeylogPojo(String key, String ans){
10 | this.key = key;
11 | this.ans = ans;
12 | }
13 |
14 | public String getKey() {
15 | return key;
16 | }
17 |
18 | public String getAns() {
19 | return ans;
20 | }
21 |
22 | public void setKey(String key) {
23 | this.key = key;
24 | }
25 |
26 | public void setAns(String ans) {
27 | this.ans = ans;
28 | }
29 |
30 | //variables
31 | private String key;
32 | private String ans;
33 | }
34 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu1.xml:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cheema/calculater/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater;
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 | * Instrumentation 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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cheema.calculater", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_key_tables.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/srb/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_rating.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
14 |
21 |
22 |
31 |
32 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | applicationId "cheema.calculater"
8 | minSdkVersion 21
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.3.1'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | compile 'de.hdodenhof:circleimageview:1.3.0'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu2.xml:
--------------------------------------------------------------------------------
1 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/myButtons/NumButton.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.myButtons;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.TextView;
7 |
8 | import cheema.calculater.CalculatorLib.Token;
9 | import cheema.calculater.R;
10 |
11 | /**
12 | * Created by srb on 7/10/17.
13 | */
14 |
15 | public class NumButton extends MyButton{
16 |
17 | public NumButton(){
18 | super(null);
19 | myinit();
20 | }
21 |
22 | public NumButton(Context context){
23 | super(context);
24 | myinit();
25 | }
26 |
27 | public NumButton(Context context, AttributeSet attrs){
28 | super(context, attrs);
29 | myinit();
30 | }
31 |
32 | public NumButton(Context context, AttributeSet attrs, int defStyle){
33 | super(context, attrs, defStyle);
34 | myinit();
35 | }
36 |
37 | public void myinit(){
38 | super.myinit();
39 | setOnClickListener(new OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 | String str = getText().toString();
43 | TextView qusTv=(TextView) getRootView().findViewById(R.id.qusTv);
44 | try {
45 | if( Token.lastToken(qusTv.getText().toString()).getVal().compareTo("∞")!=0){
46 | qusTv.append(str);
47 | }
48 | } catch (Exception e) {
49 | e.printStackTrace();
50 | }
51 | }
52 | });
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/mymagic/Magic.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.mymagic;
2 |
3 | import android.database.Cursor;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.widget.Toast;
6 |
7 | import cheema.calculater.CalculatorLib.Token;
8 | import cheema.calculater.MainActivity;
9 |
10 | import static android.content.Context.MODE_PRIVATE;
11 |
12 | /**
13 | * Created by srb on 7/11/17.
14 | */
15 |
16 | public class Magic {
17 | int stage;
18 | String key;
19 | String val;
20 |
21 | public Magic(){
22 | stage=0;
23 | }
24 |
25 | public int verifytoken(String orgstr) {
26 | try {
27 | String str = Token.lastToken(orgstr).getVal().toString();
28 | SQLiteDatabase db = MainActivity.activity.openOrCreateDatabase("data", MODE_PRIVATE, null);
29 | db.execSQL("create table if not exists key (key varchar,ans varchar)");
30 |
31 | Cursor resultSet = db.rawQuery("select * from key where key = '" + str + "'", null);
32 |
33 | if (resultSet.moveToNext() && stage==0) {
34 | key = str;
35 | val = resultSet.getString(1);
36 | stage = 1;
37 | }
38 | else if(stage == 1){
39 | stage=2;
40 | }
41 | else if(stage == 2){
42 | stage=3;
43 | }
44 | else if(stage == 3){
45 | stage=4;
46 | }
47 | else if(stage == 4){
48 | stage=0;
49 | return Integer.parseInt(val);
50 | }
51 | } catch (Exception e){
52 | Toast.makeText(MainActivity.activity,"exc in magic : "+ e.getMessage(),Toast.LENGTH_SHORT).show();
53 | }
54 | return 0;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magic-Calculator
2 |
3 | A calculator with basic functions.
4 |
5 | It has some really cool features.
6 |
7 | - Type 1501 and click on the menu button and explore additional settings.
8 |
9 | - Click on Advanced Settings and create a key value pair where key must be 4 digits long and value must be 8 digits long.
10 |
11 | - As you type the key and press '=' then begin doing calculationsafter 4 = signs pressed calculator will show the result "value you fixed in advance settings"
12 |
13 | To learn trick, watch this [video](https://www.youtube.com/watch?v=hNkF7I1K8oo)
14 |
15 | Contains no ads or unnecessary permissions. It's an opensource project and provides a Dark theme.
16 |
17 | ## Test Screenshots:
18 |
19 |    
20 |
21 | ## Contributing:
22 | Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into `master`! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.
23 |
24 | ## License:
25 | -------
26 |
27 | Licensed under the Apache License, Version 2.0 (the "License");
28 | you may not use this file except in compliance with the License.
29 | You may obtain a copy of the License at
30 |
31 | http://www.apache.org/licenses/LICENSE-2.0
32 |
33 | Unless required by applicable law or agreed to in writing, software
34 | distributed under the License is distributed on an "AS IS" BASIS,
35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 | See the License for the specific language governing permissions and
37 | limitations under the License.
38 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/myButtons/MyButton.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.myButtons;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.PorterDuff;
6 | import android.util.AttributeSet;
7 | import android.view.MotionEvent;
8 | import android.view.View;
9 |
10 | /**
11 | * Created by srb on 7/14/17.
12 | */
13 |
14 | public class MyButton extends android.support.v7.widget.AppCompatButton {
15 | public MyButton(){
16 | super(null);
17 | myinit();
18 | }
19 |
20 | public MyButton(Context context){
21 | super(context);
22 | myinit();
23 | }
24 |
25 | public MyButton(Context context, AttributeSet attrs){
26 | super(context, attrs);
27 | myinit();
28 | }
29 |
30 | public MyButton(Context context, AttributeSet attrs, int defStyle){
31 | super(context, attrs, defStyle);
32 | myinit();
33 | }
34 |
35 | public void myinit(){
36 | setOnTouchListener(new OnTouchListener() {
37 | @Override
38 | public boolean onTouch(View v, MotionEvent event) {
39 | switch (event.getAction()) {
40 | case MotionEvent.ACTION_DOWN: {
41 | // v.getBackground().setColorFilter(0xe0f47521, PorterDuff.Mode.SRC_ATOP);
42 | v.getBackground().setColorFilter(Color.rgb(200,200,200), PorterDuff.Mode.LIGHTEN);
43 | v.invalidate();
44 | break;
45 | }
46 | case MotionEvent.ACTION_UP: {
47 | v.getBackground().clearColorFilter();
48 | v.invalidate();
49 | break;
50 | }
51 | }
52 | return false;
53 | }
54 | });
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
13 |
14 |
19 |
20 |
27 |
28 |
29 |
39 |
40 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/mymagic/adapters/Keytables_list_adapter.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.mymagic.adapters;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.LayoutRes;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.TextView;
12 |
13 | import java.util.ArrayList;
14 |
15 | import cheema.calculater.R;
16 | import cheema.calculater.mymagic.pojo_classes.KeylogPojo;
17 |
18 |
19 | /**
20 | * Created by srb on 7/7/17.
21 | */
22 |
23 | public class Keytables_list_adapter extends ArrayAdapter {
24 | public Keytables_list_adapter(@NonNull Context context, @LayoutRes int resource, ArrayList arrayList) {
25 | super(context, resource);
26 | this.arrayList = arrayList;
27 | }
28 |
29 | @Override
30 | public int getCount() {
31 | return arrayList.size();
32 | }
33 |
34 | @Override
35 | public int getPosition(@Nullable Object item) {
36 | return super.getPosition(item);
37 | }
38 |
39 | @NonNull
40 | @Override
41 | public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
42 | if(convertView==null){
43 | LayoutInflater layoutInflater = (LayoutInflater.from(parent.getContext()));
44 | convertView = layoutInflater.inflate(R.layout.item,parent,false);
45 | }
46 | TextView KeyTv=(TextView) convertView.findViewById(R.id.keyTv);
47 | TextView ansTv = (TextView) convertView.findViewById(R.id.ansTv);
48 |
49 | KeylogPojo obj = arrayList.get(position);
50 | KeyTv.setText(obj.getKey());
51 | ansTv.setText(obj.getAns());
52 |
53 | return convertView;
54 | }
55 |
56 | @Override
57 | public long getItemId(int position) {
58 | return position;
59 | }
60 |
61 | //variables
62 | ArrayList arrayList;
63 | }
64 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_newkey.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
16 |
31 |
45 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/SwipeListener.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater;
2 |
3 | import android.app.Activity;
4 | import android.util.Log;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | /**
10 | * Created by srb on 7/8/17.
11 | */
12 |
13 | public class SwipeListener implements View.OnTouchListener {
14 |
15 | static final String logTag = "ActivitySwipeDetector";
16 | private Activity activity;
17 | static final int MIN_DISTANCE = 10;// TODO change this runtime based on screen resolution. for 1920x1080 is to small the 100 distance
18 | private float downX, downY, upX, upY;
19 |
20 | // private MainActivity mMainActivity;
21 |
22 | public SwipeListener(MainActivity mainActivity) {
23 | activity = mainActivity;
24 | }
25 |
26 | public void onRightToLeftSwipe() {
27 | Log.i(logTag, "RightToLeftSwipe!");
28 | Toast.makeText(activity, "RightToLeftSwipe", Toast.LENGTH_SHORT).show();
29 | // activity.doSomething();
30 | }
31 |
32 | public void onLeftToRightSwipe() {
33 | Log.i(logTag, "LeftToRightSwipe!");
34 | Toast.makeText(activity, "LeftToRightSwipe", Toast.LENGTH_SHORT).show();
35 | // activity.doSomething();
36 | }
37 |
38 | public void onTopToBottomSwipe() {
39 | Log.i(logTag, "onTopToBottomSwipe!");
40 | Toast.makeText(activity, "onTopToBottomSwipe", Toast.LENGTH_SHORT).show();
41 | // activity.doSomething();
42 | }
43 |
44 | public void onBottomToTopSwipe() {
45 | Log.i(logTag, "onBottomToTopSwipe!");
46 | Toast.makeText(activity, "onBottomToTopSwipe", Toast.LENGTH_SHORT).show();
47 | // activity.doSomething();
48 | }
49 |
50 | public boolean onTouch(View v, MotionEvent event) {
51 | int flag=0;
52 | switch (event.getAction()) {
53 | case MotionEvent.ACTION_DOWN: {
54 | downX = event.getX();
55 | downY = event.getY();
56 | return true;
57 | }
58 | case MotionEvent.ACTION_UP: {
59 | upX = event.getX();
60 | upY = event.getY();
61 |
62 | float deltaX = downX - upX;
63 | float deltaY = downY - upY;
64 |
65 | if(Math.abs(deltaX)>Math.abs(deltaY)){
66 | if (Math.abs(deltaX) > MIN_DISTANCE) {
67 | if (deltaX < 0)
68 | this.onLeftToRightSwipe();
69 | if (deltaX > 0)
70 | this.onRightToLeftSwipe();
71 | flag=1;
72 | }
73 | }else{
74 | if (Math.abs(deltaY) > MIN_DISTANCE) {
75 | if (deltaY < 0)
76 | this.onTopToBottomSwipe();
77 | if (deltaY > 0)
78 | this.onBottomToTopSwipe();
79 | flag=1;
80 | }
81 | }
82 |
83 | if(flag==1) return true;
84 | else return false; // no swipe horizontally and no swipe vertically
85 | }// case MotionEvent.ACTION_UP:
86 | }
87 | return false;
88 | }
89 |
90 | }
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/myButtons/SignButton.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.myButtons;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.TextView;
7 | import android.widget.Toast;
8 |
9 | import cheema.calculater.CalculatorLib.Token;
10 | import cheema.calculater.R;
11 |
12 | /**
13 | * Created by srb on 7/10/17.
14 | */
15 |
16 | public class SignButton extends MyButton{
17 | public SignButton(Context context) {
18 | super(context);
19 | myinit();
20 | }
21 |
22 | public SignButton(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | myinit();
25 | }
26 |
27 | public SignButton(Context context, AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | myinit();
30 | }
31 |
32 | public void myinit(){
33 | super.myinit();
34 | setOnClickListener(new OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | String str = getText().toString();
38 | TextView qusTv=(TextView) getRootView().findViewById(R.id.qusTv);
39 | String qusStr = qusTv.getText().toString();
40 | if(qusStr.length()==0) { //length 0
41 | if (str.charAt(0) == '-') {
42 | qusTv.append(str);
43 | }
44 | }
45 | else if(qusStr.length()==1){ // length 1
46 | if(qusStr.charAt(0)!='-' && qusStr.charAt(0)!='.' && qusStr.charAt(0)!='∞'){
47 | qusTv.append(str);
48 | }
49 | }
50 | else{ // length greater than 1
51 | if(Token.isSym(qusStr.charAt(qusStr.length()-1))){//if last digit was symbol
52 | if(Token.isSym(qusStr.charAt(qusStr.length()-2))){//if last second digit was symbol
53 |
54 | }else{//if last second digit was not symbol
55 | if(str.charAt(0)=='-'){
56 | qusTv.append(str);
57 | }
58 | }
59 | }
60 | else{
61 | try {
62 | int i=Token.lastToken(qusStr).getVal().compareTo(".");
63 | int j=Token.lastToken(qusStr).getVal().compareTo("-.");
64 | if(i!=0 && j!=0) {
65 | // Toast.makeText(getContext(), "if "+Token.lastToken(qusStr).getVal()+ " : " + i, Toast.LENGTH_SHORT).show();
66 | qusTv.append(str);
67 | }
68 | else {
69 | // Toast.makeText(getContext(), "else "+Token.lastToken(qusStr).getVal()+ " : " + i, Toast.LENGTH_SHORT).show();
70 |
71 | }
72 | } catch (Exception e) {
73 | Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
74 | }
75 | }
76 | }
77 | }//end method
78 | });
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/CalculatorLib/Token.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.CalculatorLib;
2 |
3 | import android.widget.Toast;
4 |
5 | import cheema.calculater.MainActivity;
6 |
7 | /**
8 | * Created by srb on 7/10/17.
9 | */
10 |
11 | public class Token {
12 | public static final String sym = "symbol";
13 | public static final String num = "number";
14 | public static final String nul = "empty";
15 | public static final String spl = "special";
16 | public String type;
17 | public String val;
18 |
19 | public Token(){
20 | type=nul;
21 | val="0";
22 | }
23 |
24 | public Token(String val,String type){
25 | this.type= type;
26 | this.val=val;
27 | }
28 |
29 | public String getVal() {
30 | return val;
31 | }
32 |
33 | public String getType(){
34 | return type;
35 | }
36 |
37 | public static Token lastToken(String str) throws Exception {
38 | Token temp= new Token();
39 | int lastsym=-1;//stores index of last symbol seen till now
40 | int symcnt=1;
41 | for(int i=0;ilastsym){
45 | lastsym=i;//update index of last sym
46 | }
47 | }
48 | else if(symcnt==1 && str.charAt(i)=='-'){//this symbol is - and is part of number
49 |
50 | }
51 | else{
52 | throw new Exception("wrong use of symbols");
53 | }
54 | symcnt++;
55 | }
56 | else{
57 | symcnt=0;
58 | }
59 | }// end for loop
60 |
61 | if(str.length()==0){//exceptional case where str is of length 0
62 | temp.type=nul;
63 | temp.val="";
64 | return temp;
65 | }
66 | if(str.contains("∞")){
67 | throw new Exception("infinity");
68 | }
69 |
70 | if(lastsym==str.length()-1){
71 | temp.type=sym;
72 | temp.val=str.substring(lastsym,lastsym+1);
73 | }
74 | else{
75 | temp.type=num;
76 | temp.val=str.substring(lastsym+1,str.length());
77 | }
78 |
79 | return temp;
80 | }
81 |
82 | public double parseDouble(){
83 | return parseDouble(this);
84 | }
85 |
86 | public static double parseDouble(Token t){
87 | if (t.getType()==Token.sym || t.getType()==Token.nul)
88 | return 0;
89 | else{//type is num
90 | String str=t.getVal();
91 | if(str.compareTo("-")==0)
92 | str = "-0";
93 | if(str.charAt(0)=='.'){
94 | str = "0"+str;
95 | }
96 | if(str.charAt(str.length()-1)=='.'){
97 | str = str+"0";
98 | }
99 | try {
100 | double d = Double.parseDouble(str);
101 | return d;
102 | }catch (Exception e){
103 | Toast.makeText(MainActivity.activity, "cant parse the token " + str, Toast.LENGTH_SHORT).show();
104 | return 0;
105 | }
106 | }
107 | }
108 |
109 | public int getPrecedence(){
110 | return getPrecedence(this);
111 | }
112 |
113 | public static int getPrecedence(Token temp){
114 | if(temp.getType()==Token.sym){
115 | char ch = temp.getVal().charAt(0);
116 | if(ch=='+'||ch=='-'){
117 | return 1;
118 | }
119 | else if(ch=='×'||ch=='÷'){
120 | return 2;
121 | }
122 | else if(ch=='^'){
123 | return 3;
124 | }
125 | else if(ch=='('){
126 | return 0;
127 | }
128 | }else{
129 | return 0;
130 | }
131 | return 0;
132 | }
133 |
134 | public static boolean isSym(Character ch){
135 | if(ch=='+' || ch=='-' || ch=='×' || ch=='÷' || ch=='^' || ch=='(' || ch==')')
136 | return true;
137 | return false;
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/CalculatorLib/SrbCalculator.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.CalculatorLib;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.ArrayDeque;
5 | import java.util.ArrayList;
6 | import java.util.Deque;
7 | import java.util.List;
8 |
9 |
10 | /**
11 | * Created by srb on 7/8/17.
12 | */
13 |
14 | public abstract class SrbCalculator {
15 |
16 | public static String compute(String expression) throws Exception {
17 | List tokenList = tokenise(expression);
18 | List postFixList = convertPostfix(tokenList);
19 | double result = calculatePostfix(postFixList);
20 |
21 | //trimmer code
22 | String res = (new BigDecimal(result)).setScale(3, BigDecimal.ROUND_HALF_UP).toString();
23 | int cnt=0,ptr=res.length()-1;
24 | while(res.charAt(ptr)=='0') { //trim last zeros
25 | cnt++;
26 | ptr--;
27 | }
28 | if(cnt==3)//trim out decemal also
29 | cnt=4;
30 | res=res.substring(0,res.length()-cnt);
31 |
32 | return res;
33 | //return null;
34 | }
35 |
36 | public static void debugg(List tokenList){
37 | for(int i=0;i tokenise(String str) throws Exception {
44 | List reverseTokenList = new ArrayList<>();
45 | Token temp ;
46 | while(str.length()!=0){
47 | temp = Token.lastToken(str);
48 | reverseTokenList.add(temp);
49 | str = str.substring(0,str.length()-temp.getVal().length());
50 | }
51 | List tokenList = new ArrayList<>();
52 |
53 | //rearrange them upside down
54 | int i = reverseTokenList.size()-1;
55 | while(!reverseTokenList.isEmpty()){
56 | tokenList.add(reverseTokenList.remove(i));
57 | i--;
58 | }
59 | return tokenList;
60 | }
61 |
62 | //arrange list into list of postfix tokens
63 | public static List convertPostfix(List tokenList) throws Exception {
64 | List postfixList = new ArrayList<>();
65 | Deque stack = new ArrayDeque<>();
66 | for(int i = 0; i postfixList) throws Exception {
99 | Deque stack = new ArrayDeque();
100 | for(int i=0;i \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/mymagic/KeyTables.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater.mymagic;
2 |
3 | import android.app.Dialog;
4 | import android.app.ProgressDialog;
5 | import android.content.DialogInterface;
6 | import android.database.Cursor;
7 | import android.database.sqlite.SQLiteDatabase;
8 | import android.os.AsyncTask;
9 | import android.os.Bundle;
10 | import android.support.v7.app.AlertDialog;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.view.View;
13 | import android.widget.AdapterView;
14 | import android.widget.Button;
15 | import android.widget.EditText;
16 | import android.widget.ListView;
17 | import android.widget.Toast;
18 |
19 | import java.util.ArrayList;
20 |
21 | import cheema.calculater.R;
22 | import cheema.calculater.mymagic.adapters.Keytables_list_adapter;
23 | import cheema.calculater.mymagic.pojo_classes.KeylogPojo;
24 |
25 | public class KeyTables extends AppCompatActivity {
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_key_tables);
30 |
31 | myinit();
32 | setListeners();
33 | }
34 |
35 | public void myinit(){
36 | listView = (ListView)findViewById(R.id.listView);
37 | Loader loder = new Loader();
38 | loder.execute();
39 | list_adapter = new Keytables_list_adapter(this,R.layout.item, arrayList);
40 | listView.setAdapter(list_adapter);
41 | newBtn = (Button)findViewById(R.id.newBtn);
42 | }
43 |
44 | public void setListeners(){
45 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
46 | @Override
47 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
48 |
49 | }
50 | });
51 | newBtn.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | d = new Dialog(KeyTables.this);
55 | d.setContentView(R.layout.dialog_newkey);
56 | ansEt = (EditText) d.findViewById(R.id.ansEt);
57 | keyEt = (EditText) d.findViewById(R.id.keyEt);
58 | okBtn = (Button) d.findViewById(R.id.okBtn);
59 | if(okBtn==null){
60 | Toast.makeText(KeyTables.this, "null ok", Toast.LENGTH_SHORT).show();
61 | }
62 | okBtn.setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | String ansStr = ansEt.getText().toString();
66 | String keyStr = keyEt.getText().toString();
67 | if(keyStr.length()!=4 || ansStr.length()!=keyStr.length()*2){
68 | Toast.makeText(KeyTables.this,"key must be 4 characters long and Value must be 8 characters long",Toast.LENGTH_SHORT).show();
69 | return;
70 | }
71 | SQLiteDatabase db = openOrCreateDatabase("data", MODE_PRIVATE, null);
72 | db.execSQL("create table if not exists key (key varchar,ans varchar)");
73 |
74 | Cursor resultSet = db.rawQuery("select * from key where key = '" + keyStr + "'", null);
75 | if (resultSet.moveToNext()) {
76 | Toast.makeText(KeyTables.this, "key already exists", Toast.LENGTH_SHORT).show();
77 | return;
78 | }
79 | try {
80 | db.execSQL("Insert into key values ( '" + keyStr + "','" + ansStr + "')");
81 | Toast.makeText(KeyTables.this, "Successfully inserted", Toast.LENGTH_SHORT).show();
82 | list_adapter.notifyDataSetChanged();
83 | arrayList.add(new KeylogPojo(keyStr,ansStr));
84 | d.dismiss();
85 | } catch (Exception e) {
86 | Toast.makeText(KeyTables.this,e.getMessage(), Toast.LENGTH_SHORT).show();
87 | }
88 | }
89 | });
90 | d.show();
91 | }
92 | });
93 | listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
94 | @Override
95 | public boolean onItemLongClick(AdapterView> parent, View view, final int position, long id) {
96 | AlertDialog.Builder builder = new AlertDialog.Builder(KeyTables.this);
97 | builder.setTitle("Delete key");
98 | builder.setMessage("Are you sure to delete this key");
99 | builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
100 | @Override
101 | public void onClick(DialogInterface dialog, int which) {
102 | String str = "";
103 | str = arrayList.get(position).getKey();
104 | arrayList.remove(position);
105 | SQLiteDatabase db = openOrCreateDatabase("data", MODE_PRIVATE, null);
106 | db.execSQL("delete from key where key = '" + str + "'");
107 | list_adapter.notifyDataSetChanged();
108 | }
109 | });
110 | builder.setIcon(R.drawable.key);
111 | AlertDialog welcomeAlert = builder.create();
112 | welcomeAlert.show();
113 | return false;
114 | }
115 | });
116 | }
117 |
118 | public class Loader extends AsyncTask{
119 | @Override
120 | protected void onPreExecute() {
121 | super.onPreExecute();
122 | dialog.show();
123 | }
124 | @Override
125 | protected Void doInBackground(Void... params) {
126 | String keySt,ansSt;
127 | SQLiteDatabase db = openOrCreateDatabase("data", MODE_PRIVATE, null);
128 | db.execSQL("create table if not exists key (key varchar,ans varchar)");
129 | Cursor resultSet = db.rawQuery("select * from key",null);
130 | if(resultSet.getCount()==0) return null;
131 | while (resultSet.moveToNext()) {
132 | try {
133 | Thread.sleep(0);
134 | } catch (InterruptedException e) {
135 | e.printStackTrace();
136 | }
137 | keySt = resultSet.getString(0);
138 | ansSt = resultSet.getString(1);
139 | arrayList.add(new KeylogPojo(keySt,ansSt));
140 | }
141 | System.out.println("here " + resultSet.getCount());
142 | return null;
143 | }
144 |
145 | @Override
146 | protected void onPostExecute(Void aVoid) {
147 | super.onPostExecute(aVoid);
148 | list_adapter.notifyDataSetChanged();
149 | dialog.dismiss();
150 | }
151 |
152 | //variables
153 | ProgressDialog dialog = ProgressDialog.show(KeyTables.this,"loading","please wait");
154 | }// end class Loader
155 |
156 | //variables
157 | ListView listView;
158 | ArrayList arrayList = new ArrayList<>();
159 | Keytables_list_adapter list_adapter;
160 | Button newBtn,okBtn;
161 | Dialog d;
162 | EditText ansEt,keyEt;
163 | }
164 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
24 |
25 |
31 |
32 |
33 |
45 |
57 |
58 |
59 |
66 |
67 |
72 |
75 |
83 |
91 |
99 |
100 |
103 |
111 |
119 |
127 |
128 |
131 |
139 |
147 |
155 |
156 |
159 |
168 |
176 |
185 |
186 |
187 |
188 |
189 |
196 |
197 |
206 |
214 |
222 |
230 |
238 |
239 |
246 |
247 |
248 |
249 |
250 |
251 |
--------------------------------------------------------------------------------
/app/src/main/java/cheema/calculater/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cheema.calculater;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.app.Dialog;
6 | import android.content.Intent;
7 | import android.graphics.Color;
8 | import android.os.AsyncTask;
9 | import android.os.Build;
10 | import android.os.Bundle;
11 | import android.os.Handler;
12 | import android.support.annotation.RequiresApi;
13 | import android.support.v7.app.AlertDialog;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.support.v7.widget.Toolbar;
16 | import android.text.Editable;
17 | import android.text.TextWatcher;
18 | import android.view.Menu;
19 | import android.view.MenuItem;
20 | import android.view.View;
21 | import android.widget.Button;
22 | import android.widget.LinearLayout;
23 | import android.widget.RatingBar;
24 | import android.widget.RelativeLayout;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import java.util.concurrent.atomic.AtomicBoolean;
29 |
30 | import cheema.calculater.CalculatorLib.SrbCalculator;
31 | import cheema.calculater.CalculatorLib.Token;
32 | import cheema.calculater.mymagic.KeyTables;
33 | import cheema.calculater.mymagic.Magic;
34 |
35 | import static cheema.calculater.CalculatorLib.Token.lastToken;
36 |
37 | public class MainActivity extends AppCompatActivity {
38 |
39 | @RequiresApi(api = Build.VERSION_CODES.M)
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_main);
44 |
45 | myinit();
46 | setListeners();
47 | }
48 |
49 | @RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
50 | public void myinit(){
51 | this.activity=this;
52 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
53 | toolbar.setTitle("RAD");
54 | toolbar.setTitleTextColor(Color.rgb(119,119,119));
55 | setSupportActionBar(toolbar);
56 |
57 | handler = new Handler();
58 |
59 | ansTv = (TextView)findViewById(R.id.ansTv);
60 | qusTv = (TextView)findViewById(R.id.qusTv);
61 |
62 | eqlBtn = (Button)findViewById(R.id.eqlBtn);
63 | delBtn = (Button)findViewById(R.id.delBtn);
64 | decBtn = (Button)findViewById(R.id.decBtn);
65 |
66 | magic = new Magic();
67 |
68 | toggleDynamic = true;
69 |
70 | asyncTask = new AsyncTask() {
71 | @Override
72 | protected Void doInBackground(Void... params) {
73 | try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}
74 | return null;
75 | }
76 |
77 | @Override
78 | protected void onPreExecute() {
79 | super.onPreExecute();
80 | getSupportActionBar().show();
81 | }
82 |
83 | @Override
84 | protected void onPostExecute(Void aVoid) {
85 | super.onPostExecute(aVoid);
86 | getSupportActionBar().hide();
87 | asyncTask=null;
88 | }
89 | };
90 | asyncTask.execute();
91 |
92 | stopWatch = new Thread(new Runnable() {
93 | @Override
94 | public void run() {
95 | for(counter = 0; counter<80; counter++) {
96 | if(lock.get()) {
97 | synchronized(stopWatch) {
98 | try {
99 | stopWatch.wait();
100 | } catch (InterruptedException e) {}
101 | }
102 | }
103 | handler.post(new Runnable() {
104 | @Override
105 | public void run() {
106 | // ansTv.append(Integer.toString(i) + ", ");
107 | }
108 | });
109 | try {
110 | Thread.sleep(50);
111 | } catch (InterruptedException e) {}
112 | }
113 | }
114 | });
115 | }
116 |
117 | @TargetApi(Build.VERSION_CODES.M)
118 | @RequiresApi(api = Build.VERSION_CODES.M)
119 | public void setListeners(){
120 | menuviewListner = new View.OnClickListener() {
121 | @Override
122 | public void onClick(View v) {
123 | if(getSupportActionBar().isShowing()){
124 | getSupportActionBar().hide();
125 | }
126 | else if(asyncTask!=null){
127 | synchronized(stopWatch)
128 | {
129 | counter=0;
130 | getSupportActionBar().show();
131 | }
132 | }
133 | else{
134 | asyncTask = new AsyncTask() {
135 | @Override
136 | protected Void doInBackground(Void... params) {
137 | if(stopWatch.isAlive())
138 | stopWatch.stop();
139 | stopWatch.start();
140 | while (stopWatch.isAlive()){}
141 | return null;
142 | }
143 |
144 | @Override
145 | protected void onPreExecute() {
146 | super.onPreExecute();
147 | getSupportActionBar().show();
148 | }
149 |
150 | @Override
151 | protected void onPostExecute(Void aVoid) {
152 | super.onPostExecute(aVoid);
153 | if(asyncTask==this)
154 | getSupportActionBar().hide();
155 | asyncTask=null;
156 | }
157 | };
158 | asyncTask.execute();
159 | }
160 | }
161 | };
162 | ansTv.setOnClickListener(menuviewListner);
163 | qusTv.setOnClickListener(menuviewListner);
164 | ((RelativeLayout)findViewById(R.id.menuContainerRl)).setOnClickListener(menuviewListner);
165 | morefxnlBtnLl=(LinearLayout)findViewById(R.id.morefxnBtnLl);
166 | morefxnlBtnLl.setOnTouchListener(new SwipeListener(MainActivity.this));
167 | qusTv.addTextChangedListener(new TextWatcher() {
168 | @Override
169 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
170 |
171 | @Override
172 | public void onTextChanged(CharSequence s, int start, int before, int count) {}
173 |
174 | @Override
175 | public void afterTextChanged(Editable s) {
176 | String qus = qusTv.getText().toString();
177 | if(qus.length()>15){
178 | qus = qus.substring(0,15);
179 | qusTv.setText(qus);
180 | }
181 | try {
182 | String str;
183 | Token temp = lastToken(qus);
184 | if(temp.getType()==Token.num ) {
185 | str = SrbCalculator.compute(qus);
186 | //write code to get ans
187 | ansTv.setText(str) ;
188 | }
189 | else if(temp.getType()==Token.nul){
190 | ansTv.setText("");
191 | }
192 | } catch (Exception e) {
193 | if(e.getMessage()=="infinity"){
194 | ansTv.setText("∞");
195 | }
196 | else
197 | Toast.makeText(MainActivity.this,e.getMessage(), Toast.LENGTH_SHORT).show();
198 | }
199 | //set size
200 | setTextSize();
201 | }
202 | });
203 |
204 | delBtn.setOnClickListener(new View.OnClickListener() {
205 | @Override
206 | public void onClick(View v) {
207 | String str = qusTv.getText().toString();
208 | if(str.length()>0)
209 | str = str.substring(0,str.length()-1);
210 | else
211 | str = "";
212 | qusTv.setText(str);
213 | }
214 | });
215 | delBtn.setOnLongClickListener(new View.OnLongClickListener() {
216 | @Override
217 | public boolean onLongClick(View v) {
218 | qusTv.setText("");
219 | return true;
220 | }
221 | });
222 | eqlBtn.setOnClickListener(new View.OnClickListener() {
223 | @Override
224 | public void onClick(View v) {
225 | int reply =magic.verifytoken(qusTv.getText().toString());
226 | if(reply==0)
227 | qusTv.setText(ansTv.getText().toString());
228 | else
229 | qusTv.setText(Integer.toString(reply));
230 | ansTv.setText("");
231 | }
232 | });
233 |
234 | decBtn.setOnClickListener(new View.OnClickListener() {
235 | @Override
236 | public void onClick(View v) {
237 | try {
238 | int deccount=0;
239 | Token lasttoken =Token.lastToken(qusTv.getText().toString());
240 | String str = lasttoken.getVal();
241 | for(int i =0;i asyncTask;
381 | Handler handler;
382 | Thread stopWatch;
383 | AtomicBoolean lock=new AtomicBoolean(false);
384 | int counter;
385 | View.OnClickListener menuviewListner;
386 | LinearLayout morefxnlBtnLl,buttonLl;
387 | Button eqlBtn,delBtn,decBtn;
388 | Boolean toggleDynamic;
389 | public static Activity activity=null;
390 | Magic magic;
391 | }
392 |
--------------------------------------------------------------------------------