-
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,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
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.
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,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '26.0.2' | ||
defaultConfig { | ||
applicationId "com.kekec_apps.funfacts" | ||
minSdkVersion 23 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.3.1' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.2' | ||
testCompile 'junit:junit:4.12' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Users\janko\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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.kekec_apps.funfacts; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation 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() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.kekec_apps.funfacts", appContext.getPackageName()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.kekec_apps.funfacts"> | ||
|
||
<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=".FunFactsActivity"> | ||
<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,32 @@ | ||
package com.kekec_apps.funfacts; | ||
|
||
import android.graphics.Color; | ||
|
||
import java.util.Random; | ||
|
||
public class ColorWheel { | ||
private final String[] colors = new String[]{ | ||
"#39add1", // light blue | ||
"#3079ab", // dark blue | ||
"#c25975", // mauve | ||
"#e15258", // red | ||
"#f9845b", // orange | ||
"#838cc7", // lavender | ||
"#7d669e", // purple | ||
"#53bbb4", // aqua | ||
"#51b46d", // green | ||
"#e0ab18", // mustard | ||
"#637a91", // dark gray | ||
"#f092b0", // pink | ||
"#b7c0c7" // light gray | ||
}; | ||
|
||
// Mehtods | ||
int getColor() { | ||
// rendomly select fact | ||
Random randomGenerator = new Random(); | ||
int randomNumber = randomGenerator.nextInt(colors.length); | ||
int color = Color.parseColor(colors[randomNumber]); | ||
return color; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.kekec_apps.funfacts; | ||
|
||
import java.util.Random; | ||
|
||
class FactBook { | ||
// fields member variables | ||
private final String[] facts = new String[]{ | ||
"Ants stretch when they wake up in the morning.", | ||
"Ostriches can run faster than horses.", | ||
"Olympic gold medals are actually made mostly of silver.", | ||
"You are born with 300 bones; by the time you are an adult you will have 206.", | ||
"It takes about 8 minutes for light from the Sun to reach Earth.", | ||
"Some bamboo plants can grow almost a meter in just one day.", | ||
"The state of Florida is bigger than England.", | ||
"Some penguins can leap 2-3 meters out of the water.", | ||
"On average, it takes 66 days to form a new habit.", | ||
"Mammoths still walked the earth when the Great Pyramid was being built.", | ||
"Treehouse is not actually in a tree." | ||
}; | ||
|
||
// Mehtods | ||
String getFact() { | ||
// randomly select fact | ||
Random randomGenerator = new Random(); | ||
int randomNumber = randomGenerator.nextInt(facts.length); | ||
return facts[randomNumber]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.kekec_apps.funfacts; | ||
|
||
import android.graphics.Color; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import java.util.Random; | ||
|
||
public class FunFactsActivity extends AppCompatActivity { | ||
public static final String TAG = FunFactsActivity.class.getSimpleName(); | ||
private FactBook factBook = new FactBook(); | ||
private ColorWheel colorWheel = new ColorWheel(); | ||
// fields for views | ||
private TextView factTextView; | ||
private Button showFactButton; | ||
private RelativeLayout relativeLayout; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_fun_facts); | ||
|
||
// Assign the Views from the layout file to the corresponding variables | ||
factTextView = (TextView) findViewById(R.id.factTextView); | ||
showFactButton = (Button) findViewById(R.id.showFactButton); | ||
relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout); | ||
|
||
// click listener | ||
View.OnClickListener listener = new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Log.d(TAG, "The showFactButton was clicked."); | ||
String fact = factBook.getFact(); | ||
// update the screen with our new fact | ||
factTextView.setText(fact); | ||
|
||
int color = colorWheel.getColor(); | ||
relativeLayout.setBackgroundColor(color); | ||
showFactButton.setTextColor(color); | ||
} | ||
}; | ||
showFactButton.setOnClickListener(listener); | ||
Log.d(TAG, "This is the log from onCreate method"); | ||
// Toast.makeText(this, "Yay! Our Activity is created", Toast.LENGTH_SHORT).show(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:id="@+id/relativeLayout" | ||
android:background="#51b46d" | ||
android:padding="50dp" | ||
tools:context="com.kekec_apps.funfacts.FunFactsActivity"> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="10dp" | ||
android:layout_marginTop="20dp" | ||
android:text="@string/fact_title" | ||
android:textColor="@android:color/white" | ||
android:textSize="20sp" /> | ||
|
||
<TextView | ||
android:id="@+id/factTextView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" | ||
android:text="@string/fun_fact" | ||
android:textColor="#FFFFFF" | ||
android:textSize="24sp" /> | ||
|
||
<Button | ||
android:id="@+id/showFactButton" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:background="#FFFFFF" | ||
android:textColor="#51b46d" | ||
android:text="show anotehr fact" /> | ||
|
||
</RelativeLayout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |