Skip to content
This repository was archived by the owner on Jan 19, 2020. It is now read-only.

Commit 32060ff

Browse files
committed
init push
1 parent fd11ef1 commit 32060ff

37 files changed

+2860
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.iml
2+
.idea/
3+
.gradle/
4+
build/
5+
local.properties
6+
gradle.properties
7+
gradle/

app/.gitignore

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

app/build.gradle

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.2"
6+
defaultConfig {
7+
applicationId "com.komdosh.pral"
8+
minSdkVersion 16
9+
targetSdkVersion 25
10+
versionCode 1
11+
versionName "0.1"
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.2.0'
28+
testCompile 'junit:junit:4.12'
29+
compile 'com.android.support:design:25.2.0'
30+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in C:\Users\Komdosh\AppData\Local\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+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.komdosh.pral;
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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
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("com.komdosh.pral", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.komdosh.pral">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".Display.MathematicsDisplay">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
<activity android:name=".Display.WordDisplay">
19+
</activity>
20+
<service android:name=".services.myService">
21+
22+
</service>
23+
</application>
24+
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package com.komdosh.pral.Display;
2+
3+
import android.animation.Animator;
4+
import android.animation.AnimatorListenerAdapter;
5+
import android.content.Intent;
6+
import android.graphics.Typeface;
7+
import android.os.Bundle;
8+
import android.os.SystemClock;
9+
import android.support.design.widget.TextInputLayout;
10+
import android.support.v7.app.AppCompatActivity;
11+
import android.util.TypedValue;
12+
import android.view.KeyEvent;
13+
import android.view.View;
14+
import android.view.ViewGroup;
15+
import android.view.inputmethod.EditorInfo;
16+
import android.widget.Button;
17+
import android.widget.Chronometer;
18+
import android.widget.EditText;
19+
import android.widget.RelativeLayout;
20+
import android.widget.TextView;
21+
22+
import com.komdosh.pral.R;
23+
import com.komdosh.pral.System.Math.MathTask;
24+
import com.komdosh.pral.System.Math.Mathematics;
25+
26+
27+
/**
28+
* Created by Komdosh on 24.09.2016.
29+
*/
30+
31+
public class MathematicsDisplay extends AppCompatActivity {
32+
EditText et;
33+
final Mathematics m = new Mathematics();
34+
final MathTask t = m.generateTask();
35+
@Override
36+
protected void onCreate(Bundle savedInstanceState) {
37+
super.onCreate(savedInstanceState);
38+
setContentView(R.layout.math_layout);
39+
et = (EditText) findViewById(R.id.editText);
40+
TextInputLayout v = (TextInputLayout)findViewById(R.id.txt);
41+
v.setHint(getString(R.string.example, t.task[0],t.task[1],t.task[2]));
42+
v.setHintTextAppearance(R.style.InputLayout);
43+
44+
et.setOnKeyListener(new View.OnKeyListener() {
45+
@Override
46+
public boolean onKey(View v, int keyCode, KeyEvent event) {
47+
if(check())
48+
rightAnswer();
49+
return false;
50+
}
51+
});
52+
et.setOnEditorActionListener(new EditText.OnEditorActionListener() {
53+
@Override
54+
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
55+
if(actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.KEYCODE_ENTER)
56+
rightAnswer();
57+
return false;
58+
}
59+
});
60+
}
61+
62+
private void startChronometr(){
63+
final Chronometer mChronometer = (Chronometer) findViewById(R.id.chronometer);
64+
mChronometer.setBase(SystemClock.elapsedRealtime());
65+
mChronometer.start();
66+
mChronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
67+
@Override
68+
public void onChronometerTick(Chronometer chronometer) {
69+
long elapsedMillis = SystemClock.elapsedRealtime() - mChronometer.getBase();
70+
71+
if(elapsedMillis>=60*1000){
72+
nextActivity();
73+
}
74+
75+
/* if (elapsedMillis > 5000) {
76+
String strElapsedMillis = "Прошло больше 5 секунд";
77+
Toast.makeText(getApplicationContext(),
78+
strElapsedMillis, Toast.LENGTH_SHORT)
79+
.show();
80+
}*/
81+
}
82+
});
83+
}
84+
85+
private void nextActivity(){
86+
Intent i = new Intent(this, WordDisplay.class);
87+
finish();
88+
startActivity(i);
89+
}
90+
91+
private boolean check(){
92+
return et.getText().toString().equals(t.answer.toString());
93+
}
94+
95+
private void rightAnswer(){
96+
rightPopup();
97+
t.set(m.generateTask());
98+
et.setText("");
99+
TextInputLayout v = (TextInputLayout)findViewById(R.id.txt);
100+
v.setHint(getString(R.string.example, t.task[0],t.task[1],t.task[2]));
101+
TextView counter = (TextView)findViewById(R.id.counterRight);
102+
counter.setText(""+(Integer.parseInt(counter.getText().toString())+1));
103+
}
104+
105+
public void start(View view){
106+
final RelativeLayout rl = (RelativeLayout)findViewById(R.id.rl);
107+
final Button b = (Button)findViewById(R.id.button);
108+
109+
startChronometr();
110+
111+
rl.animate()
112+
.alpha(0.0f)
113+
.setDuration(600)
114+
.setListener(new AnimatorListenerAdapter() {
115+
@Override
116+
public void onAnimationEnd(Animator animation) {
117+
super.onAnimationEnd(animation);
118+
rl.setVisibility(View.INVISIBLE);
119+
}
120+
});
121+
b.animate()
122+
.alpha(0.0f)
123+
.setDuration(500)
124+
.setListener(new AnimatorListenerAdapter() {
125+
@Override
126+
public void onAnimationEnd(Animator animation) {
127+
super.onAnimationEnd(animation);
128+
b.setVisibility(View.INVISIBLE);
129+
}
130+
});
131+
}
132+
133+
protected void rightPopup(){
134+
TextView rightTextView = new TextView(this);
135+
RelativeLayout.LayoutParams textViewLayoutParams =
136+
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
137+
textViewLayoutParams.setMargins(0, 150, 0, 0); // setMargins(left, top, right, bottom);
138+
textViewLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
139+
rightTextView.setLayoutParams(textViewLayoutParams);
140+
141+
rightTextView.setId(R.id.rightTextView);
142+
rightTextView.setTextColor(0xFF22F74F);
143+
rightTextView.setTypeface(rightTextView.getTypeface(), Typeface.BOLD);
144+
rightTextView.setText("Right!");
145+
rightTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
146+
rightTextView.animate()
147+
.translationY(-50)
148+
.alpha(0.0f)
149+
.setDuration(1500);
150+
RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.activity_main);
151+
relativeLayout.addView(rightTextView);
152+
}
153+
}

0 commit comments

Comments
 (0)