-
Notifications
You must be signed in to change notification settings - Fork 670
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
1 parent
d72e6ec
commit eee9e90
Showing
26 changed files
with
585 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 |
---|---|---|
|
@@ -25,3 +25,7 @@ proguard/ | |
|
||
# Log Files | ||
*.log | ||
|
||
#IDE | ||
.idea/ | ||
*.iml |
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,25 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 21 | ||
buildToolsVersion "21.1.2" | ||
|
||
defaultConfig { | ||
applicationId "com.morristaedt.mirror" | ||
minSdkVersion 18 | ||
targetSdkVersion 21 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:21.0.3' | ||
} |
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,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/HannahMitt/Library/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 *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
app/src/androidTest/java/com/morristaedt/mirror/ApplicationTest.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,13 @@ | ||
package com.morristaedt.mirror; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.morristaedt.mirror"> | ||
|
||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
<uses-permission android:name="ANDROID.PERMISSION.INTERNET"/> | ||
|
||
<application | ||
android:name=".MirrorApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MirrorActivity" | ||
android:label="@string/app_name" | ||
android:launchMode="singleInstance"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<receiver android:name=".receiver.AlarmReceiver" /> | ||
</application> | ||
|
||
</manifest> |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/morristaedt/mirror/MirrorActivity.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,44 @@ | ||
package com.morristaedt.mirror; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.view.View; | ||
import android.view.WindowManager; | ||
import android.widget.TextView; | ||
|
||
import com.morristaedt.mirror.modules.TimeModule; | ||
|
||
public class MirrorActivity extends ActionBarActivity { | ||
|
||
private TextView mMainText; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
getWindow().getDecorView().setSystemUiVisibility( | ||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | ||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | ||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
| View.SYSTEM_UI_FLAG_FULLSCREEN | ||
| View.SYSTEM_UI_FLAG_IMMERSIVE); | ||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | ||
|
||
mMainText = (TextView) findViewById(R.id.main_text); | ||
|
||
setViewState(); | ||
} | ||
|
||
@Override | ||
protected void onNewIntent(Intent intent) { | ||
super.onNewIntent(intent); | ||
setViewState(); | ||
} | ||
|
||
private void setViewState() { | ||
mMainText.setText(TimeModule.getTimeOfDayWelcome(getResources())); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/morristaedt/mirror/MirrorApplication.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,29 @@ | ||
package com.morristaedt.mirror; | ||
|
||
import android.app.AlarmManager; | ||
import android.app.Application; | ||
import android.app.PendingIntent; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.SystemClock; | ||
|
||
import com.morristaedt.mirror.receiver.AlarmReceiver; | ||
|
||
/** | ||
* Created by HannahMitt on 8/22/15. | ||
*/ | ||
public class MirrorApplication extends Application { | ||
|
||
private static final long MINUTES_10 = 10 * 60 * 1000; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); | ||
|
||
Intent intent = new Intent(this, AlarmReceiver.class); | ||
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, intent, 0); | ||
|
||
alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + MINUTES_10, MINUTES_10, alarmIntent); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/morristaedt/mirror/modules/TimeModule.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,33 @@ | ||
package com.morristaedt.mirror.modules; | ||
|
||
import android.content.res.Resources; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.morristaedt.mirror.R; | ||
|
||
import java.util.Calendar; | ||
|
||
/** | ||
* Created by HannahMitt on 8/22/15. | ||
*/ | ||
public class TimeModule { | ||
|
||
public static String getTimeOfDayWelcome(@NonNull Resources resources) { | ||
Calendar now = Calendar.getInstance(); | ||
int hour = now.get(Calendar.HOUR_OF_DAY); | ||
int timeRes; | ||
if (hour < 4) { | ||
timeRes = R.string.late; | ||
} else if (hour < 12) { | ||
timeRes = R.string.good_morning; | ||
} else if (hour < 17) { // 5pm | ||
timeRes = R.string.good_afternoon; | ||
} else if (hour < 22) { // 10pm | ||
timeRes = R.string.good_evening; | ||
} else { // 10pm - midnight is bedtime | ||
timeRes = R.string.bedtime; | ||
} | ||
|
||
return resources.getString(timeRes, resources.getString(R.string.owners)); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/morristaedt/mirror/receiver/AlarmReceiver.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,29 @@ | ||
package com.morristaedt.mirror.receiver; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.PowerManager; | ||
|
||
import com.morristaedt.mirror.MirrorActivity; | ||
|
||
/** | ||
* Created by HannahMitt on 8/22/15. | ||
*/ | ||
public class AlarmReceiver extends BroadcastReceiver { | ||
|
||
private static final String WAKE_LOCK = "HomeMirrorWakeLock"; | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); | ||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK); | ||
wakeLock.acquire(); | ||
|
||
Intent mainActivityIntent = new Intent(context, MirrorActivity.class); | ||
mainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
context.startActivity(mainActivityIntent); | ||
|
||
wakeLock.release(); | ||
} | ||
} |
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,25 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="right" | ||
android:orientation="vertical" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
tools:context=".MainActivity"> | ||
|
||
<DigitalClock | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<TextView | ||
android:id="@+id/main_text" | ||
android:layout_marginTop="@dimen/activity_vertical_margin" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="right" | ||
android:text="@string/default_mirror_mirror" /> | ||
|
||
</LinearLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
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,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
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,15 @@ | ||
<resources> | ||
<string name="app_name">HomeMirror</string> | ||
|
||
<string name="default_mirror_mirror">Mirror, mirror on the wall. Hannah is the prettiest of them all.</string> | ||
|
||
<!-- Owners --> | ||
<string name="owners">Hannah and Andy</string> | ||
|
||
<!-- Time module --> | ||
<string name="good_morning">Good morning, %s</string> | ||
<string name="good_afternoon">Good afternoon, %s</string> | ||
<string name="good_evening">Good evening, %s</string> | ||
<string name="late">You\'re up late, %s</string> | ||
<string name="bedtime">Good evening, %s\n\nIt\'s Hannah\'s bedtime.</string> | ||
</resources> |
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,13 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat"> | ||
<!-- Customize your theme here. --> | ||
<item name="android:background">@android:color/black</item> | ||
<item name="android:windowBackground">@android:color/black</item> | ||
<item name="android:colorBackground">@android:color/black</item> | ||
<item name="android:textSize">24dp</item> | ||
<item name="android:textColor">@android:color/white</item> | ||
</style> | ||
|
||
</resources> |
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,19 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.3.0' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} |
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,18 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
# Default value: -Xmx10248m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true |
Binary file not shown.
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,6 @@ | ||
#Sat Aug 22 21:32:22 EDT 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip |
Oops, something went wrong.