Skip to content

Commit de470ca

Browse files
committed
initial commit
1 parent df33822 commit de470ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2116
-0
lines changed

.gitignore

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
*.ab_
5+
6+
# Jar and Aar file
7+
*.jar
8+
*.aar
9+
app/libs/*.aar
10+
app/libs/*.jar
11+
12+
13+
14+
app/src/release/*.json
15+
# Files for the ART/Dalvik VM
16+
*.dex
17+
18+
# Java class files
19+
*.class
20+
21+
# Generated files
22+
bin/
23+
gen/
24+
out/
25+
26+
27+
# Gradle files
28+
.gradle/
29+
build/
30+
31+
32+
# Local configuration file (sdk path, etc)
33+
local.properties
34+
35+
# Proguard folder generated by Eclipse
36+
proguard/
37+
38+
# Log Files
39+
*.log
40+
41+
# Android Studio Navigation editor temp files
42+
.navigation/
43+
44+
# Android Studio captures folder
45+
captures/
46+
47+
# IntelliJ
48+
*.iml
49+
.idea/workspace.xml
50+
.idea/tasks.xml
51+
.idea/gradle.xml
52+
.idea/assetWizardSettings.xml
53+
.idea/dictionaries
54+
.idea/libraries
55+
.idea/caches
56+
.idea/*.*
57+
.idea/*
58+
.idea/
59+
.idea/*.xml
60+
.idea/copyright/
61+
.idea/copyright/*
62+
.idea/copyright/profiles_settings.xml
63+
64+
65+
# Keystore files
66+
# Uncomment the following line if you do not want to check your keystore files in.
67+
*.jks
68+
69+
70+
71+
# External native build folder generated in Android Studio 2.2 and later
72+
.externalNativeBuild
73+
74+
75+
# Google Services (e.g. APIs or Firebase)
76+
google-services.json
77+
*.json
78+
79+
80+
81+
# Freeline
82+
freeline.py
83+
freeline/
84+
freeline_project_description.json
85+
86+
# fastlane
87+
fastlane/report.xml
88+
fastlane/Preview.html
89+
fastlane/screenshots
90+
fastlane/test_output
91+
fastlane/readme.md
92+
93+
94+
# Zip file
95+
*.zip
96+
*.rar
97+
*.gz
98+
*.tz
99+
100+
101+
#heap dump file
102+
*.hprof
103+
*.alloc
104+
105+
# sha file
106+
*.sha
107+
108+

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 31
7+
8+
defaultConfig {
9+
applicationId "io.github.subhamtyagi.quickcalculation"
10+
//multiDexEnabled true
11+
minSdkVersion 16
12+
targetSdkVersion 31
13+
versionCode 1
14+
versionName "1.0"
15+
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
compileOptions {
25+
//coreLibraryDesugaringEnabled true
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
30+
}
31+
32+
dependencies {
33+
implementation 'androidx.appcompat:appcompat:1.4.1'
34+
implementation 'com.google.android.material:material:1.5.0'
35+
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
36+
implementation 'androidx.gridlayout:gridlayout:1.0.0'
37+
38+
//coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
39+
40+
}

app/proguard-rules.pro

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
23+
24+
-repackageclasses
25+
-allowaccessmodification
26+
#-flattenpackagehierarchy
27+
-dontskipnonpubliclibraryclasses

app/src/main/AndroidManifest.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="io.github.subhamtyagi.quickcalculation">
4+
5+
<uses-permission android:name="android.permission.VIBRATE" />
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.QuickCalculation">
13+
<activity android:name=".QuizActivity"
14+
android:theme="@style/Theme.QuickCalculation"
15+
android:exported="true"/>
16+
<activity
17+
android:name=".LaunchActivity"
18+
android:label="@string/app_name"
19+
android:exported="true"
20+
android:theme="@style/Theme.QuickCalculation">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
package io.github.subhamtyagi.quickcalculation;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.view.Menu;
6+
import android.view.MenuItem;
7+
import android.view.View;
8+
import android.widget.AdapterView;
9+
import android.widget.ArrayAdapter;
10+
import android.widget.EditText;
11+
import android.widget.Spinner;
12+
import android.widget.Toast;
13+
14+
import androidx.appcompat.app.AppCompatActivity;
15+
16+
import io.github.subhamtyagi.quickcalculation.utils.Constants;
17+
import io.github.subhamtyagi.quickcalculation.utils.CrashUtils;
18+
19+
20+
public class LaunchActivity extends AppCompatActivity {
21+
22+
private Spinner operationsSpinner, timerSpinner;
23+
private String operationName = "multiply", timer = "30";
24+
private EditText lower1, lower2, upper1, upper2;
25+
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
setContentView(R.layout.activity_launch);
30+
31+
new CrashUtils(getApplicationContext(), "");
32+
33+
operationsSpinner = findViewById(R.id.spinner_operator);
34+
timerSpinner = findViewById(R.id.spinner_timer);
35+
lower1 = findViewById(R.id.et_range1_lower);
36+
lower2 = findViewById(R.id.et_range2_lower);
37+
upper1 = findViewById(R.id.et_range1_upper);
38+
upper2 = findViewById(R.id.et_range2_upper);
39+
40+
setAdapters();
41+
operationsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
42+
@Override
43+
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
44+
switch (position) {
45+
case 0:
46+
operationName = "sum";
47+
break;
48+
case 1:
49+
operationName = "subtract";
50+
break;
51+
case 2:
52+
operationName = "multiply";
53+
break;
54+
default:
55+
operationName = "simplification";
56+
57+
}
58+
}
59+
60+
@Override
61+
public void onNothingSelected(AdapterView<?> adapterView) {
62+
63+
}
64+
});
65+
timerSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
66+
@Override
67+
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
68+
switch (position) {
69+
case 0:
70+
timer = "30";
71+
break;
72+
case 1:
73+
timer = "45";
74+
break;
75+
case 2:
76+
timer = "60";
77+
break;
78+
case 3:
79+
timer = "90";
80+
break;
81+
case 4:
82+
timer = "120";
83+
break;
84+
85+
}
86+
}
87+
88+
@Override
89+
public void onNothingSelected(AdapterView<?> adapterView) {
90+
91+
}
92+
});
93+
94+
findViewById(R.id.btn_start).setOnClickListener(view -> {
95+
Intent i = new Intent(this, QuizActivity.class);
96+
i.putExtra(Constants.OPERATIONS, operationName);
97+
i.putExtra(Constants.TIME, timer);
98+
String l1 = getValueOf(lower1),
99+
l2 = getValueOf(lower2),
100+
u2 = getValueOf(upper2),
101+
u1 = getValueOf(upper1);
102+
103+
if (l1 == null) {
104+
lower1.requestFocus();
105+
} else if (u1 == null) {
106+
upper1.requestFocus();
107+
} else if (l2 == null) {
108+
lower2.requestFocus();
109+
} else if (u2 == null) {
110+
upper2.requestFocus();
111+
} else {
112+
int iL1=Integer.parseInt(l1);
113+
int iL2=Integer.parseInt(l2);
114+
int iU1=Integer.parseInt(u1);
115+
int iU2=Integer.parseInt(u2);
116+
if (iU2 > iL2) {
117+
if (iU1 > iL1) {
118+
i.putExtra(Constants.LOWER_1, iL1);
119+
i.putExtra(Constants.LOWER_2, iL2);
120+
i.putExtra(Constants.UPPER_2, iU2);
121+
i.putExtra(Constants.UPPER_1, iU1);
122+
startActivity(i);
123+
overridePendingTransition(android.R.anim.cycle_interpolator, android.R.anim.fade_out);
124+
} else{
125+
upper1.requestFocus();
126+
Toast.makeText(this, getResources().getString(R.string.upper_value_must_be_greater), Toast.LENGTH_SHORT).show();
127+
}
128+
}else{
129+
upper2.requestFocus();
130+
Toast.makeText(this, getResources().getString(R.string.upper_value_must_be_greater), Toast.LENGTH_SHORT).show();
131+
}
132+
}
133+
});
134+
135+
136+
}
137+
138+
public void setAdapters() {
139+
ArrayAdapter<CharSequence> opAdapter;
140+
opAdapter = ArrayAdapter.createFromResource(this, R.array.Operations, android.R.layout.simple_spinner_item);
141+
opAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
142+
ArrayAdapter<CharSequence> timerAdapter = ArrayAdapter.createFromResource(this, R.array.Timer, android.R.layout.simple_spinner_item);
143+
timerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
144+
operationsSpinner.setAdapter(opAdapter);
145+
timerSpinner.setAdapter(timerAdapter);
146+
}
147+
148+
String getValueOf(EditText editText) {
149+
String string = editText.getText().toString();
150+
if (string.isEmpty())
151+
return null;
152+
else return string;
153+
}
154+
155+
@Override
156+
public boolean onCreateOptionsMenu(Menu menu) {
157+
getMenuInflater().inflate(R.menu.menu_main, menu);
158+
return true;
159+
}
160+
161+
@Override
162+
public boolean onOptionsItemSelected(MenuItem item) {
163+
int id = item.getItemId();
164+
if (id == R.id.action_settings) {
165+
return true;
166+
}
167+
return super.onOptionsItemSelected(item);
168+
}
169+
}

0 commit comments

Comments
 (0)