-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 486084a
Showing
46 changed files
with
848 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
.idea | ||
/local.properties | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.2" | ||
defaultConfig { | ||
applicationId "ua.kpi.comsys.io8227.jackshen" | ||
minSdkVersion 15 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.appcompat:appcompat:1.0.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation 'com.google.android.material:material:1.0.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
27 changes: 27 additions & 0 deletions
27
app/src/androidTest/java/ua/kpi/comsys/io8227/jackshen/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ua.kpi.comsys.io8227.jackshen; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.jupiter.api.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("ua.kpi.comsys.io8227.jackshen", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ua.kpi.comsys.io8227.jackshen"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity" | ||
android:theme="@style/Theme.AppCompat.NoActionBar" | ||
android:windowSoftInputMode="stateHidden|adjustPan" | ||
android:configChanges="orientation|screenSize"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions
93
app/src/main/java/ua/kpi/comsys/io8227/jackshen/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package ua.kpi.comsys.io8227.jackshen; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
import android.widget.Button; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
ImageView imageView; | ||
TextView textView, startText; | ||
int count = 0; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
setContentView(R.layout.activity_main); | ||
|
||
imageView = findViewById(R.id.imageView); | ||
textView = findViewById(R.id.textView); | ||
startText = findViewById(R.id.textViewStart); | ||
|
||
imageView.setOnTouchListener(new OnSwipeTouchListener(getApplicationContext()) { | ||
public void onSwipeRight() { | ||
if (count == 0) { | ||
imageView.setImageResource(R.drawable.dark); | ||
|
||
startText.setText("Good "); | ||
textView.setText("Night"); | ||
|
||
|
||
textView.setTextSize(26); | ||
startText.setTextSize(26); | ||
|
||
count = 1; | ||
} else { | ||
imageView.setImageResource(R.drawable.light); | ||
|
||
startText.setText("Good "); | ||
textView.setText("Morning"); | ||
|
||
textView.setTextSize(26); | ||
startText.setTextSize(26); | ||
|
||
count = 0; | ||
} | ||
} | ||
|
||
public void onSwipeLeft() { | ||
if (count == 0) { | ||
imageView.setImageResource(R.drawable.dark); | ||
|
||
startText.setText("Good "); | ||
textView.setText("Night"); | ||
|
||
textView.setTextSize(26); | ||
startText.setTextSize(26); | ||
|
||
count = 1; | ||
} else { | ||
imageView.setImageResource(R.drawable.light); | ||
|
||
startText.setText("Good "); | ||
textView.setText("Morning"); | ||
|
||
textView.setTextSize(26); | ||
startText.setTextSize(26); | ||
|
||
count = 0; | ||
} | ||
} | ||
|
||
}); | ||
|
||
Button button = findViewById(R.id.openPortfolio); | ||
button.setOnClickListener(new View.OnClickListener(){ | ||
@Override | ||
public void onClick(View view) { | ||
Intent openSite = new Intent(Intent.ACTION_VIEW, Uri.parse("https://jackshen.herokuapp.com/")); | ||
startActivity(openSite); | ||
} | ||
}); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
app/src/main/java/ua/kpi/comsys/io8227/jackshen/OnSwipeTouchListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package ua.kpi.comsys.io8227.jackshen; | ||
|
||
import android.content.Context; | ||
import android.view.GestureDetector; | ||
import android.view.GestureDetector.SimpleOnGestureListener; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.View.OnTouchListener; | ||
|
||
public class OnSwipeTouchListener implements OnTouchListener { | ||
|
||
private final GestureDetector gestureDetector; | ||
|
||
OnSwipeTouchListener(Context ctx){ | ||
gestureDetector = new GestureDetector(ctx, new GestureListener()); | ||
} | ||
|
||
@Override | ||
public boolean onTouch(View v, MotionEvent event) { | ||
return gestureDetector.onTouchEvent(event); | ||
} | ||
|
||
private final class GestureListener extends SimpleOnGestureListener { | ||
|
||
private static final int SWIPE_THRESHOLD = 100; | ||
private static final int SWIPE_VELOCITY_THRESHOLD = 100; | ||
|
||
@Override | ||
public boolean onDown(MotionEvent e) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { | ||
boolean result = false; | ||
try { | ||
float diffY = e2.getY() - e1.getY(); | ||
float diffX = e2.getX() - e1.getX(); | ||
if (Math.abs(diffX) > Math.abs(diffY)) { | ||
if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { | ||
if (diffX > 0) { | ||
onSwipeRight(); | ||
} else { | ||
onSwipeLeft(); | ||
} | ||
result = true; | ||
} | ||
} | ||
else if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) { | ||
if (diffY > 0) { | ||
onSwipeBottom(); | ||
} else { | ||
onSwipeTop(); | ||
} | ||
result = true; | ||
} | ||
} catch (Exception exception) { | ||
exception.printStackTrace(); | ||
} | ||
return result; | ||
} | ||
} | ||
|
||
public void onSwipeRight() { | ||
} | ||
|
||
public void onSwipeLeft() { | ||
} | ||
|
||
public void onSwipeTop() { | ||
} | ||
|
||
public void onSwipeBottom() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item> | ||
<shape android:shape="rectangle"> | ||
<corners android:radius="8dp" /> | ||
<solid android:color="@android:color/transparent"/> | ||
<stroke android:color="#96ffffff" | ||
android:width="2dp"/> | ||
</shape> | ||
</item> | ||
</selector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#96ffffff" | ||
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?><vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#96ffffff" | ||
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.