-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.mahiapps.fmath" | ||
minSdk 21 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.10.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.mahiapps.fmath; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.mahiapps.fmath", appContext.getPackageName()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.mahiapps.fmath"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/arithmetic" | ||
android:label="@string/app_name" | ||
android:roundIcon="@drawable/arithmetic" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.FMath"> | ||
<activity | ||
android:name=".Activities.TableActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".Activities.PlayActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".Activities.ArithmeticActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".Activities.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.mahiapps.fmath.Activities; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.os.Bundle; | ||
import android.widget.GridView; | ||
|
||
import com.mahiapps.fmath.Adapters.CourseGVAdapter; | ||
import com.mahiapps.fmath.Model.CourseModel; | ||
import com.mahiapps.fmath.R; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ArithmeticActivity extends AppCompatActivity { | ||
|
||
GridView coursesGV; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_arithmetic); | ||
|
||
coursesGV = findViewById(R.id.idGVcourses); | ||
ArrayList<CourseModel> courseModelArrayList = new ArrayList<CourseModel>(); | ||
|
||
courseModelArrayList.add(new CourseModel("ADDITION", R.drawable.add)); | ||
courseModelArrayList.add(new CourseModel("SUBTRACTION", R.drawable.minus)); | ||
courseModelArrayList.add(new CourseModel("MULTIPLICATION", R.drawable.multiplication)); | ||
// courseModelArrayList.add(new CourseModel("DIVISION", R.drawable.divide)); | ||
|
||
CourseGVAdapter adapter = new CourseGVAdapter(this, courseModelArrayList); | ||
coursesGV.setAdapter(adapter); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.mahiapps.fmath.Activities; | ||
|
||
import static com.mahiapps.fmath.R.color.green; | ||
import static com.mahiapps.fmath.R.color.orange; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
|
||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.view.View; | ||
import android.widget.GridView; | ||
import android.widget.TextView; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.cardview.widget.CardView; | ||
|
||
import com.mahiapps.fmath.Adapters.CourseGVAdapter; | ||
import com.mahiapps.fmath.Model.CourseModel; | ||
import com.mahiapps.fmath.R; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private CardView tableCardView, arithmeticCardView; | ||
private TextView score; | ||
|
||
private int right = 0, wrong = 0; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
score = findViewById(R.id.score); | ||
tableCardView = findViewById(R.id.tableCardView); | ||
arithmeticCardView = findViewById(R.id.arithmeticCardView); | ||
|
||
tableCardView.setOnClickListener(v -> { | ||
Intent intent = new Intent(getApplicationContext(), TableActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(intent); | ||
}); | ||
|
||
arithmeticCardView.setOnClickListener(v -> { | ||
Intent intent = new Intent(getApplicationContext(), ArithmeticActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(intent); | ||
}); | ||
} | ||
|
||
private void placeScoreValue() { | ||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); | ||
|
||
right = preferences.getInt("RIGHT", 0); | ||
wrong = preferences.getInt("WRONG", 0); | ||
int total = right - wrong; | ||
score.setText(String.valueOf(total)); | ||
if(total > 0){ | ||
score.setTextColor(getResources().getColor(green)); | ||
} else{ | ||
score.setTextColor(getResources().getColor(orange)); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); | ||
if(preferences.contains("RIGHT") && preferences.contains("WRONG")){ | ||
placeScoreValue(); | ||
} else{ | ||
SharedPreferences.Editor editor = preferences.edit(); | ||
editor.putInt("RIGHT", 0); | ||
editor.putInt("WRONG", 0); | ||
editor.apply(); | ||
score.setText("0"); | ||
} | ||
} | ||
} |