Repository: HannahMitt/HomeMirror
Branch: master
Commit: 566c03d3388e
Files: 55
Total size: 143.4 KB
Directory structure:
gitextract_5ytlax3m/
├── .gitignore
├── LICENSE
├── README.md
├── app/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── morristaedt/
│ │ └── mirror/
│ │ └── ApplicationTest.java
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── morristaedt/
│ │ └── mirror/
│ │ ├── MirrorActivity.java
│ │ ├── MirrorApplication.java
│ │ ├── SetUpActivity.java
│ │ ├── configuration/
│ │ │ └── ConfigurationSettings.java
│ │ ├── modules/
│ │ │ ├── BirthdayModule.java
│ │ │ ├── CalendarModule.java
│ │ │ ├── ChoresModule.java
│ │ │ ├── CountdownModule.java
│ │ │ ├── DayModule.java
│ │ │ ├── ForecastModule.java
│ │ │ ├── MoodModule.java
│ │ │ ├── NewsModule.java
│ │ │ ├── TimeModule.java
│ │ │ ├── TrainScheduleModule.java
│ │ │ ├── XKCDModule.java
│ │ │ └── YahooFinanceModule.java
│ │ ├── receiver/
│ │ │ └── AlarmReceiver.java
│ │ ├── requests/
│ │ │ ├── ForecastRequest.java
│ │ │ ├── ForecastResponse.java
│ │ │ ├── OpenWeatherRequest.java
│ │ │ ├── OpenWeatherResponse.java
│ │ │ ├── XKCDRequest.java
│ │ │ ├── XKCDResponse.java
│ │ │ ├── YahooFinanceRequest.java
│ │ │ └── YahooStockResponse.java
│ │ └── utils/
│ │ └── WeekUtil.java
│ └── res/
│ ├── drawable/
│ │ ├── apptheme_btn_check_holo_dark.xml
│ │ └── apptheme_btn_radio_holo_dark.xml
│ ├── layout/
│ │ ├── activity_configuration.xml
│ │ ├── activity_mirror.xml
│ │ └── clock.xml
│ ├── layout-v17/
│ │ └── clock.xml
│ ├── values/
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── values-sw600dp/
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── values-v21/
│ └── styles.xml
├── build.gradle
├── design/
│ ├── HomeMirror.sketch
│ └── install_assets.sh
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
/*/build/
# Local configuration file (sdk path, etc)
local.properties
*.DS_Store
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
#IDE
.idea/
*.iml
#Private Keys
app/src/main/res/values/keys.xml
app/fabric.properties
mirror-keystore.jks
signing.properties
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# HomeMirror
Android application powering the mirror in my house
<img src="https://raw.githubusercontent.com/HannahMitt/HomeMirror/master/design/IMG_20151121_183522%20(1).jpg" width="400"/>
### Note: code unmaintained
This was a fun project, and I may pick it back up again one day.
You can still follow the instructions for putting a mirror together, but may need to bring your own light-text-on-dark-background app.
Software
====
* Day, time, and weather display
* Birthday messages
* Chore reminders
* Biking weather recommendation
* Stock price swings
* Today's new XKCD
* Next calendar event
* Top news headline
* Face detection with mood detection
APIs provided by Yahoo Finance, Forecast.io, the BBC, and XKCD
<img src="https://raw.githubusercontent.com/HannahMitt/HomeMirror/master/design/HomeMirror.png" width="400"/>
How to Run
----
1. Clone project
2. Get a [forecast.io api key](https://developer.forecast.io/)
3. Add a keys.xml file under res/values with \<string name="dark_sky_api_key">your_key\</string>
4. Import project to Android Studio and run
When its mirror time, I also recommend turning on the device Developer Option: "Stay Awake - Screen will never sleep while charging"
Making a Mirror
====
[Video walk-through on adafruit (Thank you Becky!)](https://learn.adafruit.com/android-smart-home-mirror)
1. Obtain Android device
----
We had too many. Sad old devices are ideal.
I used a [2012 Nexus 7](http://www.amazon.com/gp/offer-listing/B009X3UW2G/ref=olp_tab_refurbished?ie=UTF8&condition=refurbished&qid=1441327955&sr=8-1).
2. Obtain two-way mirror
---
We did this the old-fashioned way, and quested to [Canal Plastic Center](http://canalplastic.com/). A beautiful and highly recommended establishment.
[Wiki of places to buy two-way mirrors](https://github.com/HannahMitt/HomeMirror/wiki/Places-to-buy-a-two-way-mirror)
Get a mirror at least as large as your Android device. My mirror is 6"x12" with 1/8 thickness.
3. Sticky stuff for mounting
---
Our trickiest problem was figuring out how to mount everything with minimal damage and error.
We eventually discovered [reusable double-sided adhesive](http://www.amazon.com/Command-Assorted-8-Small-4-Medium-4-Large/dp/B0084M68IO/ref=pd_sim_sbs_229_6?ie=UTF8&refRID=1TX12CR5RF0RTP6CKJR7&dpSrc=sims&dpST=_AC_UL320_SR202%2C320_), which is amazing.
We're using it both to mount the mirror to the device, and the device to the wall.
4. Attach black backing
---
We used black construction paper. If your device and mirror are awesomely identical in size, you can skip this.
Note: You want to glue it well, so the backing doesn't tear when the adhesive is holding it.
* Cut a piece of black backing the same size as your mirror
* Decide where you want your device to show through. We did upper right. Leave a border all the way around for adhesive.
* At that location, carefully cut a hole in the backing the same size as your device
* CAREFULLY glue the backing to the mirror. We used spray adhesive, and practiced how we would pick it up and lay it on the mirror a couple times before going for it. We also wore black surgical gloves.
<img src="https://raw.githubusercontent.com/HannahMitt/HomeMirror/master/design/IMG_20150911_110449-2.jpg" height="400"/>
5. Adhesion
---
Fire up the app on the device.
Put the adhesive along the bezel or edges of the device. Line up the mirror and stick it on there.
6. Wall spot
---
You probably want a long usb cable. Find a wall spot where you can keep the device plugged in.
Put a bunch of adhesive on the back of the device, and stick it on there.
<img src="https://raw.githubusercontent.com/HannahMitt/HomeMirror/faed8d927b93ec2c38159d8e3968f8133511ee67/design/thumbs_up_mirror.jpg" width="400"/>
Links
===
At the heart of this project, is 'put a mirror on it'. [Check out alternative mirror projects and feel free to add your own reflections](https://github.com/HannahMitt/HomeMirror/wiki/Other-mirror-projects-with-alternate-technologies)
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle
================================================
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
signingConfigs {
mirror {
}
}
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.morristaedt.mirror"
minSdkVersion 14
targetSdkVersion 22
versionCode 4
versionName "1.3"
}
buildTypes {
debug {
ext.enableCrashlytics = false
applicationIdSuffix '.debug'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.mirror
}
}
}
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.ahorn:android-rss:cf40b89'
compile 'com.google.android.gms:play-services-vision:8.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
}
def signingFile = rootProject.file('signing.properties')
if (signingFile.exists()) {
def props = new Properties()
props.load(new FileInputStream(signingFile))
android.signingConfigs.mirror.storeFile rootProject.file(props.keyStore)
android.signingConfigs.mirror.storePassword props.keyStorePassword
android.signingConfigs.mirror.keyAlias props.keyAlias
android.signingConfigs.mirror.keyPassword props.keyAliasPassword
}
================================================
FILE: app/proguard-rules.pro
================================================
# 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 *;
#}
================================================
FILE: app/src/androidTest/java/com/morristaedt/mirror/ApplicationTest.java
================================================
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);
}
}
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
<?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.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<application
android:name=".MirrorApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".SetUpActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MirrorActivity"
android:launchMode="singleInstance" />
<receiver android:name=".receiver.AlarmReceiver" />
</application>
</manifest>
================================================
FILE: app/src/main/java/com/morristaedt/mirror/MirrorActivity.java
================================================
package com.morristaedt.mirror;
import android.content.Context;
import android.content.Intent;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrixColorFilter;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import com.morristaedt.mirror.modules.BirthdayModule;
import com.morristaedt.mirror.modules.CalendarModule;
import com.morristaedt.mirror.modules.ChoresModule;
import com.morristaedt.mirror.modules.CountdownModule;
import com.morristaedt.mirror.modules.DayModule;
import com.morristaedt.mirror.modules.ForecastModule;
import com.morristaedt.mirror.modules.MoodModule;
import com.morristaedt.mirror.modules.NewsModule;
import com.morristaedt.mirror.modules.XKCDModule;
import com.morristaedt.mirror.modules.YahooFinanceModule;
import com.morristaedt.mirror.receiver.AlarmReceiver;
import com.morristaedt.mirror.requests.YahooStockResponse;
import com.morristaedt.mirror.utils.WeekUtil;
import com.squareup.picasso.Picasso;
import java.lang.ref.WeakReference;
public class MirrorActivity extends ActionBarActivity {
@NonNull
private ConfigurationSettings mConfigSettings;
private TextView mBirthdayText;
private TextView mDayText;
private TextView mWeatherSummary;
private TextView mHelloText;
private TextView mBikeTodayText;
private TextView mStockText;
private TextView mMoodText;
private View mWaterPlants;
private View mGroceryList;
private ImageView mXKCDImage;
private MoodModule mMoodModule;
private TextView mNewsHeadline;
private TextView mCalendarTitleText;
private TextView mCalendarDetailsText;
private TextView mCountdownText;
private XKCDModule.XKCDListener mXKCDListener = new XKCDModule.XKCDListener() {
@Override
public void onNewXKCDToday(String url) {
if (TextUtils.isEmpty(url)) {
mXKCDImage.setVisibility(View.GONE);
} else {
Picasso.with(MirrorActivity.this).load(url).into(mXKCDImage);
mXKCDImage.setVisibility(View.VISIBLE);
}
}
};
private YahooFinanceModule.StockListener mStockListener = new YahooFinanceModule.StockListener() {
@Override
public void onNewStockPrice(YahooStockResponse.YahooQuoteResponse quoteResponse) {
if (quoteResponse == null) {
mStockText.setVisibility(View.GONE);
} else {
mStockText.setVisibility(View.VISIBLE);
mStockText.setText("$" + quoteResponse.symbol + " $" + quoteResponse.LastTradePriceOnly);
}
}
};
private ForecastModule.ForecastListener mForecastListener = new ForecastModule.ForecastListener() {
@Override
public void onWeatherToday(String weatherToday) {
if (!TextUtils.isEmpty(weatherToday)) {
mWeatherSummary.setVisibility(View.VISIBLE);
mWeatherSummary.setText(weatherToday);
}
}
@Override
public void onShouldBike(boolean showToday, boolean shouldBike) {
if (mConfigSettings.showBikingHint()) {
mBikeTodayText.setVisibility(showToday ? View.VISIBLE : View.GONE);
mBikeTodayText.setText(shouldBike ? R.string.bike_today : R.string.no_bike_today);
} else {
mBikeTodayText.setVisibility(View.GONE);
}
}
};
private NewsModule.NewsListener mNewsListener = new NewsModule.NewsListener() {
@Override
public void onNewNews(String headline) {
if (TextUtils.isEmpty(headline)) {
mNewsHeadline.setVisibility(View.GONE);
} else {
mNewsHeadline.setVisibility(View.VISIBLE);
mNewsHeadline.setText(headline);
mNewsHeadline.setSelected(true);
}
}
};
private MoodModule.MoodListener mMoodListener = new MoodModule.MoodListener() {
@Override
public void onShouldGivePositiveAffirmation(final String affirmation) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mMoodText.setVisibility(affirmation == null ? View.GONE : View.VISIBLE);
mMoodText.setText(affirmation);
}
});
}
};
private CalendarModule.CalendarListener mCalendarListener = new CalendarModule.CalendarListener() {
@Override
public void onCalendarUpdate(String title, String details) {
mCalendarTitleText.setVisibility(title != null ? View.VISIBLE : View.GONE);
mCalendarTitleText.setText(title);
mCalendarDetailsText.setVisibility(details != null ? View.VISIBLE : View.GONE);
mCalendarDetailsText.setText(details);
//Make marquee effect work for long text
mCalendarTitleText.setSelected(true);
mCalendarDetailsText.setSelected(true);
}
};
private CountdownModule.CountdownListener mCountdownListener = new CountdownModule.CountdownListener() {
@Override
public void onCountdownUpdate(final String timeLeft) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mCountdownText.setVisibility(View.VISIBLE);
mCountdownText.setText(timeLeft);
}
});
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mirror);
mConfigSettings = new ConfigurationSettings(this);
AlarmReceiver.startMirrorUpdates(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = 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_STICKY
| View.SYSTEM_UI_FLAG_IMMERSIVE;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mBirthdayText = (TextView) findViewById(R.id.birthday_text);
mDayText = (TextView) findViewById(R.id.day_text);
mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
mHelloText = (TextView) findViewById(R.id.hello_text);
mWaterPlants = findViewById(R.id.water_plants);
mGroceryList = findViewById(R.id.grocery_list);
mBikeTodayText = (TextView) findViewById(R.id.can_bike);
mStockText = (TextView) findViewById(R.id.stock_text);
mMoodText = (TextView) findViewById(R.id.mood_text);
mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
mNewsHeadline = (TextView) findViewById(R.id.news_headline);
mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
mCountdownText = (TextView) findViewById(R.id.countdown_text);
if (mConfigSettings.invertXKCD()) {
//Negative of XKCD image
float[] colorMatrixNegative = {
-1.0f, 0, 0, 0, 255, //red
0, -1.0f, 0, 0, 255, //green
0, 0, -1.0f, 0, 255, //blue
0, 0, 0, 1.0f, 0 //alpha
};
ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
mXKCDImage.setColorFilter(colorFilterNegative); // not inverting for now
}
setViewState();
}
@Override
protected void onPause() {
super.onPause();
if (mMoodModule != null) {
mMoodModule.release();
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setViewState();
}
private void colorTextViews(ViewGroup mview){
for (int i = 0; i < mview.getChildCount(); i++) {
View view = mview.getChildAt(i);
if (view instanceof ViewGroup)
colorTextViews((ViewGroup) view);
else if (view instanceof TextView) {
((TextView) view).setTextColor(mConfigSettings.getTextColor());
}
}
}
private void setViewState() {
colorTextViews((ViewGroup) findViewById(R.id.main_layout));
String birthday = BirthdayModule.getBirthday();
if (TextUtils.isEmpty(birthday)) {
mBirthdayText.setVisibility(View.GONE);
} else {
mBirthdayText.setVisibility(View.VISIBLE);
mBirthdayText.setText(getString(R.string.happy_birthday, birthday));
}
mDayText.setText(DayModule.getDay());
// mHelloText.setText(TimeModule.getTimeOfDayWelcome(getResources())); // not in current design
mWaterPlants.setVisibility(ChoresModule.waterPlantsToday() ? View.VISIBLE : View.GONE);
mGroceryList.setVisibility(ChoresModule.makeGroceryListToday() ? View.VISIBLE : View.GONE);
// Get the API key for whichever weather service API key is available
// These should be declared as a string in xml
int forecastApiKeyRes = getResources().getIdentifier("dark_sky_api_key", "string", getPackageName());
int openWeatherApiKeyRes = getResources().getIdentifier("open_weather_api_key", "string", getPackageName());
if (forecastApiKeyRes != 0) {
ForecastModule.getForecastIOHourlyForecast(getString(forecastApiKeyRes), mConfigSettings.getForecastUnits(), mConfigSettings.getLatitude(), mConfigSettings.getLongitude(), mForecastListener);
} else if (openWeatherApiKeyRes != 0) {
ForecastModule.getOpenWeatherForecast(getString(openWeatherApiKeyRes), mConfigSettings.getForecastUnits(), mConfigSettings.getLatitude(), mConfigSettings.getLongitude(), mForecastListener);
}
if (mConfigSettings.showNewsHeadline()) {
NewsModule.getNewsHeadline(mNewsListener);
} else {
mNewsHeadline.setVisibility(View.GONE);
}
if (mConfigSettings.showXKCD()) {
XKCDModule.getXKCDForToday(mXKCDListener);
} else {
mXKCDImage.setVisibility(View.GONE);
}
if (mConfigSettings.showNextCalendarEvent()) {
CalendarModule.getCalendarEvents(this, mCalendarListener);
} else {
mCalendarTitleText.setVisibility(View.GONE);
mCalendarDetailsText.setVisibility(View.GONE);
}
if (mConfigSettings.showStock() && (ConfigurationSettings.isDemoMode() || WeekUtil.isWeekdayAfterFive())) {
YahooFinanceModule.getStockForToday(mConfigSettings.getStockTickerSymbol(), mStockListener);
} else {
mStockText.setVisibility(View.GONE);
}
if (mConfigSettings.showMoodDetection()) {
mMoodModule = new MoodModule(new WeakReference<Context>(this));
mMoodModule.getCurrentMood(mMoodListener);
} else {
mMoodText.setVisibility(View.GONE);
}
if (mConfigSettings.showCountdown()){
CountdownModule.getTimeRemaining(mConfigSettings.getCountdownEnd(), mCountdownListener);
} else {
mCountdownText.setVisibility(View.GONE);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
AlarmReceiver.stopMirrorUpdates(this);
Intent intent = new Intent(this, SetUpActivity.class);
startActivity(intent);
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/MirrorApplication.java
================================================
package com.morristaedt.mirror;
import android.app.Application;
import com.crashlytics.android.Crashlytics;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import io.fabric.sdk.android.Fabric;
/**
* Created by HannahMitt on 8/22/15.
*/
public class MirrorApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if (!ConfigurationSettings.isDebugBuild()) {
Fabric.with(this, new Crashlytics());
}
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/SetUpActivity.java
================================================
package com.morristaedt.mirror;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
public class SetUpActivity extends Activity {
private static final long HOUR_MILLIS = 60 * 60 * 1000;
private static final int METERS_MIN = 500;
@NonNull
private ConfigurationSettings mConfigSettings;
private LocationManager mLocationManager;
@Nullable
private LocationListener mLocationListener;
@Nullable
private Location mLocation;
private RadioGroup mTemperatureChoice;
private CheckBox mBikingCheckbox;
private CheckBox mMoodDetectionCheckbox;
private CheckBox mShowNextCaledarEventCheckbox;
private CheckBox mShowNewsHeadlineCheckbox;
private CheckBox mXKCDCheckbox;
private CheckBox mXKCDInvertCheckbox;
private CheckBox mCountdownCheckbox;
private CheckBox mNewCountdownCheckbox;
private View mNewCountdownView;
private View mLocationView;
private View mColorShowView;
private EditText mLatitude;
private EditText mLongitude;
private EditText mStockTickerSymbol;
private EditText mCountdownDays;
private EditText mCountdownHours;
private EditText mCountdownMins;
private EditText mCountdownSecs;
private SeekBar mColorPickerRed;
private SeekBar mColorPickerGreen;
private SeekBar mColorPickerBlue;
private TextView mColorShowerRed;
private TextView mColorShowerGreen;
private TextView mColorShowerBlue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_configuration);
mConfigSettings = new ConfigurationSettings(this);
mTemperatureChoice = (RadioGroup) findViewById(R.id.temperature_group);
mTemperatureChoice.check(mConfigSettings.getIsCelsius() ? R.id.celsius : R.id.farenheit);
mColorPickerRed = (SeekBar) findViewById(R.id.ColorPickerRed);
mColorPickerRed.setProgress(Color.red(mConfigSettings.getTextColor()));
mColorPickerGreen = (SeekBar) findViewById(R.id.ColorPickerGreen);
mColorPickerGreen.setProgress(Color.green(mConfigSettings.getTextColor()));
mColorPickerBlue = (SeekBar) findViewById(R.id.ColorPickerBlue);
mColorPickerBlue.setProgress(Color.blue(mConfigSettings.getTextColor()));
mColorShowerRed = (TextView) findViewById(R.id.ColorShowerRed);
mColorShowerRed.setText(String.format("%d", Color.red(mConfigSettings.getTextColor())));
mColorShowerGreen = (TextView) findViewById(R.id.ColorShowerGreen);
mColorShowerGreen.setText(String.format("%d", Color.green(mConfigSettings.getTextColor())));
mColorShowerBlue = (TextView) findViewById(R.id.ColorShowerBlue);
mColorShowerBlue.setText(String.format("%d", Color.blue(mConfigSettings.getTextColor())));
mColorShowView = findViewById(R.id.colored_bar);
mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
mColorPickerRed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mConfigSettings.setTextColorRed(progress);
mColorShowerRed.setText(String.format("%d", progress));
mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mColorPickerGreen.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mConfigSettings.setTextColorGreen(progress);
mColorShowerGreen.setText(String.format("%d", progress));
mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
mColorPickerBlue.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mConfigSettings.setTextColorBlue(progress);
mColorShowerBlue.setText(String.format("%d", progress));
mColorShowView.setBackgroundColor(mConfigSettings.getTextColor());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
mBikingCheckbox = (CheckBox) findViewById(R.id.biking_checkbox);
mBikingCheckbox.setChecked(mConfigSettings.showBikingHint());
mMoodDetectionCheckbox = (CheckBox) findViewById(R.id.mood_detection_checkbox);
mMoodDetectionCheckbox.setChecked(mConfigSettings.showMoodDetection());
mShowNextCaledarEventCheckbox = (CheckBox) findViewById(R.id.calendar_checkbox);
mShowNextCaledarEventCheckbox.setChecked(mConfigSettings.showNextCalendarEvent());
mShowNewsHeadlineCheckbox = (CheckBox) findViewById(R.id.headline_checkbox);
mShowNewsHeadlineCheckbox.setChecked(mConfigSettings.showNewsHeadline());
mXKCDCheckbox = (CheckBox) findViewById(R.id.xkcd_checkbox);
mXKCDCheckbox.setChecked(mConfigSettings.showXKCD());
mXKCDInvertCheckbox = (CheckBox) findViewById(R.id.xkcd_invert_checkbox);
mXKCDInvertCheckbox.setChecked(mConfigSettings.invertXKCD());
mLatitude = (EditText) findViewById(R.id.latitude);
mLongitude = (EditText) findViewById(R.id.longitude);
mLatitude.setText(String.valueOf(mConfigSettings.getLatitude()));
mLongitude.setText(String.valueOf(mConfigSettings.getLongitude()));
mLocationView = findViewById(R.id.location_view);
setUpLocationMonitoring();
mStockTickerSymbol = (EditText) findViewById(R.id.stock_name);
mStockTickerSymbol.setText(mConfigSettings.getStockTickerSymbol());
mCountdownCheckbox = (CheckBox) findViewById(R.id.countdown_checkbox);
mCountdownCheckbox.setChecked(mConfigSettings.showCountdown());
mNewCountdownCheckbox = (CheckBox) findViewById(R.id.countdown_new_checkbox);
mNewCountdownCheckbox.setChecked(false);
if (!mConfigSettings.showCountdown()) {
mNewCountdownCheckbox.setVisibility(View.GONE);
}
mNewCountdownView = findViewById(R.id.new_countdown_view);
mNewCountdownView.setVisibility(View.GONE);
mCountdownDays = (EditText) findViewById(R.id.countdown_days);
mCountdownHours = (EditText) findViewById(R.id.countdown_hours);
mCountdownMins = (EditText) findViewById(R.id.countdown_mins);
mCountdownSecs = (EditText) findViewById(R.id.countdown_secs);
mCountdownCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked){
mNewCountdownCheckbox.setVisibility(View.VISIBLE);
} else {
mNewCountdownCheckbox.setChecked(false);
mNewCountdownCheckbox.setVisibility(View.GONE);
mNewCountdownView.setVisibility(View.GONE);
}
}
});
mNewCountdownCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked){
mNewCountdownView.setVisibility(View.VISIBLE);
} else {
mNewCountdownView.setVisibility(View.GONE);
}
}
});
findViewById(R.id.launch_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveFields();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mStockTickerSymbol.getWindowToken(), 0);
Intent intent = new Intent(SetUpActivity.this, MirrorActivity.class);
startActivity(intent);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mLocationManager != null && mLocationListener != null) {
mLocationManager.removeUpdates(mLocationListener);
}
}
private void setUpLocationMonitoring() {
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
String provider = mLocationManager.getBestProvider(criteria, true);
try {
mLocation = mLocationManager.getLastKnownLocation(provider);
if (mLocation == null) {
mLocationView.setVisibility(View.VISIBLE);
mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Toast.makeText(SetUpActivity.this, R.string.found_location, Toast.LENGTH_SHORT).show();
mLocation = location;
mConfigSettings.setLatLon(String.valueOf(mLocation.getLatitude()), String.valueOf(mLocation.getLongitude()));
mLocationManager.removeUpdates(this);
if (mLocationView != null) {
mLocationView.setVisibility(View.GONE);
}
}
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
mLocationManager.requestLocationUpdates(provider, HOUR_MILLIS, METERS_MIN, mLocationListener);
} else {
mLocationView.setVisibility(View.GONE);
}
} catch (IllegalArgumentException e) {
Log.e("SetUpActivity", "Location manager could not use provider", e);
}
}
private void saveFields() {
mConfigSettings.setIsCelsius(mTemperatureChoice.getCheckedRadioButtonId() == R.id.celsius);
mConfigSettings.setShowBikingHint(mBikingCheckbox.isChecked());
mConfigSettings.setShowMoodDetection(mMoodDetectionCheckbox.isChecked());
mConfigSettings.setShowNextCalendarEvent(mShowNextCaledarEventCheckbox.isChecked());
mConfigSettings.setShowNewsHeadline(mShowNewsHeadlineCheckbox.isChecked());
mConfigSettings.setXKCDPreference(mXKCDCheckbox.isChecked(), mXKCDInvertCheckbox.isChecked());
mConfigSettings.setShowCountdown(mCountdownCheckbox.isChecked());
if (mNewCountdownCheckbox.isChecked()){
mConfigSettings.setCountdownTime(
Integer.parseInt("0"+mCountdownDays.getText().toString()),
Integer.parseInt("0"+mCountdownHours.getText().toString()),
Integer.parseInt("0"+mCountdownMins.getText().toString()),
Integer.parseInt("0"+mCountdownSecs.getText().toString()));
mNewCountdownCheckbox.setChecked(false);
mNewCountdownView.setVisibility(View.GONE);
}
if (mLocation == null) {
mConfigSettings.setLatLon(mLatitude.getText().toString(), mLongitude.getText().toString());
} else {
mConfigSettings.setLatLon(String.valueOf(mLocation.getLatitude()), String.valueOf(mLocation.getLongitude()));
}
mConfigSettings.setStockTickerSymbol(mStockTickerSymbol.getText().toString());
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/configuration/ConfigurationSettings.java
================================================
package com.morristaedt.mirror.configuration;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.morristaedt.mirror.BuildConfig;
import com.morristaedt.mirror.requests.ForecastRequest;
import java.util.Date;
/**
* Created by HannahMitt on 9/26/15.
*/
public class ConfigurationSettings {
/**
* Hardcode on to enable features outside of their regularly scheduled hours
*/
private static final boolean DEMO_MODE = false;
private static final String PREFS_MIRROR = "MirrorPrefs";
private static final String FORECAST_UNITS = "forecast_units";
private static final String TEXT_COLOR = "text_color";
private static final String BIKING_HINT = "biking_hint";
private static final String USE_MOOD_DETECTION = "mood_detection";
private static final String SHOW_CALENDAR = "show_calendar";
private static final String SHOW_HEADLINE = "show_headline";
private static final String SHOW_XKCD = "xkcd";
private static final String INVERT_XKCD = "invert_xkcd";
private static final String LAT = "lat";
private static final String LON = "lon";
private static final String STOCK_TICKER = "stock_ticker";
private static final String SHOW_COUNTDOWN = "show_countdown";
private static final String COUNTDOWN_END = "countdown_end";
@NonNull
private SharedPreferences mSharedPrefs;
private String mForecastUnits;
private boolean mShowBikingHint;
private boolean mShowMoodDetection;
private boolean mShowNextCalendarEvent;
private boolean mShowNewsHeadline;
private boolean mShowXKCD;
private boolean mInvertXKCD;
private boolean mShowCountdown;
private long mCountdownEnd;
private String mLatitude;
private String mLongitude;
private String mStockTickerSymbol;
private int mTextColor;
public ConfigurationSettings(Context context) {
mSharedPrefs = context.getSharedPreferences(PREFS_MIRROR, Context.MODE_PRIVATE);
readPrefs();
}
private void readPrefs() {
mForecastUnits = mSharedPrefs.getString(FORECAST_UNITS, ForecastRequest.UNITS_US);
mTextColor = mSharedPrefs.getInt(TEXT_COLOR, Color.WHITE);
mShowBikingHint = mSharedPrefs.getBoolean(BIKING_HINT, false);
mShowMoodDetection = mSharedPrefs.getBoolean(USE_MOOD_DETECTION, false);
mShowNextCalendarEvent = mSharedPrefs.getBoolean(SHOW_CALENDAR, false);
mShowNewsHeadline = mSharedPrefs.getBoolean(SHOW_HEADLINE, false);
mShowXKCD = mSharedPrefs.getBoolean(SHOW_XKCD, false);
mInvertXKCD = mSharedPrefs.getBoolean(INVERT_XKCD, false);
mShowCountdown = mSharedPrefs.getBoolean(SHOW_COUNTDOWN, false);
mCountdownEnd = mSharedPrefs.getLong(COUNTDOWN_END, System.currentTimeMillis());
mLatitude = mSharedPrefs.getString(LAT, "");
mLongitude = mSharedPrefs.getString(LON, "");
mStockTickerSymbol = mSharedPrefs.getString(STOCK_TICKER, "");
}
public void setIsCelsius(boolean isCelsius) {
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putString(FORECAST_UNITS, isCelsius ? ForecastRequest.UNITS_SI : ForecastRequest.UNITS_US);
editor.apply();
}
public void setTextColorRed(int red){
setTextColor(Color.rgb(red, Color.green(mTextColor), Color.blue(mTextColor)));
}
public void setTextColorGreen(int green){
setTextColor(Color.rgb(Color.red(mTextColor), green, Color.blue(mTextColor)));
}
public void setTextColorBlue(int blue){
setTextColor(Color.rgb(Color.red(mTextColor), Color.green(mTextColor), blue));
}
public void setTextColor(int color){
mTextColor = color;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putInt(TEXT_COLOR, color);
editor.apply();
}
public void setShowBikingHint(boolean show) {
mShowBikingHint = show;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(BIKING_HINT, show);
editor.apply();
}
public void setShowMoodDetection(boolean show) {
mShowMoodDetection = show;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(USE_MOOD_DETECTION, show);
editor.apply();
}
public void setShowNextCalendarEvent(boolean show) {
mShowNextCalendarEvent = show;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(SHOW_CALENDAR, show);
editor.apply();
}
public void setShowNewsHeadline(boolean show) {
mShowNewsHeadline = show;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(SHOW_HEADLINE, show);
editor.apply();
}
public void setXKCDPreference(boolean showXKCD, boolean invertXKCDColors) {
mShowXKCD = showXKCD;
mInvertXKCD = invertXKCDColors;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(SHOW_XKCD, showXKCD);
editor.putBoolean(INVERT_XKCD, invertXKCDColors);
editor.apply();
}
public void setLatLon(String latitude, String longitude) {
mLatitude = latitude.trim();
mLongitude = longitude.trim();
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putString(LAT, mLatitude);
editor.putString(LON, mLongitude);
editor.apply();
}
public void setStockTickerSymbol(String tickerSymbol) {
mStockTickerSymbol = tickerSymbol.replace("$", "").trim();
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putString(STOCK_TICKER, mStockTickerSymbol);
editor.apply();
}
public void setShowCountdown(boolean showCountdown){
mShowCountdown = showCountdown;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(SHOW_COUNTDOWN, showCountdown);
editor.apply();
}
public void setCountdownTime(int days, int hours, int mins, int secs){
mCountdownEnd = System.currentTimeMillis();
mCountdownEnd += (((days*24l+hours)*60l+mins)*60l+secs)*1000l;
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putLong(COUNTDOWN_END, mCountdownEnd);
editor.apply();
}
public boolean getIsCelsius() {
return ForecastRequest.UNITS_SI.equals(mForecastUnits);
}
public String getForecastUnits() {
return mForecastUnits;
}
public int getTextColor() {
return mTextColor;
}
public boolean showBikingHint() {
return mShowBikingHint;
}
public boolean showMoodDetection() {
return mShowMoodDetection;
}
public boolean showNextCalendarEvent() {
return mShowNextCalendarEvent;
}
public boolean showNewsHeadline() {
return mShowNewsHeadline;
}
public boolean showXKCD() {
return mShowXKCD;
}
public boolean invertXKCD() {
return mInvertXKCD;
}
public boolean showCountdown(){
return mShowCountdown;
}
public Date getCountdownEnd(){
return new Date(mCountdownEnd);
}
public String getLatitude() {
return mLatitude;
}
public String getLongitude() {
return mLongitude;
}
public boolean showStock() {
return !TextUtils.isEmpty(mStockTickerSymbol);
}
public String getStockTickerSymbol() {
return mStockTickerSymbol;
}
public static boolean isDebugBuild() {
return BuildConfig.DEBUG;
}
/**
* Whether we're ignoring timing rules for features
*
* @return
*/
public static boolean isDemoMode() {
return DEMO_MODE;
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/BirthdayModule.java
================================================
package com.morristaedt.mirror.modules;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
/**
* Created by HannahMitt on 8/23/15.
*/
public class BirthdayModule {
private static HashMap<String, String> mBirthdayMap;
static {
mBirthdayMap = new HashMap<>();
mBirthdayMap.put("01/17", "Hannah");
mBirthdayMap.put("05/8", "Andy");
}
public static String getBirthday() {
//TODO configuration
if (!ConfigurationSettings.isDebugBuild()) {
return "";
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/d", Locale.US);
return mBirthdayMap.get(simpleDateFormat.format(new Date()));
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/CalendarModule.java
================================================
package com.morristaedt.mirror.modules;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.os.AsyncTask;
import android.provider.CalendarContract;
import android.text.TextUtils;
import android.util.Log;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by alex on 12/09/15.
*/
public class CalendarModule {
public interface CalendarListener {
void onCalendarUpdate(String title, String details);
}
public static void getCalendarEvents(final Context context, final CalendarListener calendarListener) {
new AsyncTask<Void, Void, Void>() {
String title = null;
String details = null;
@Override
protected void onPostExecute(Void aVoid) {
calendarListener.onCalendarUpdate(title, details);
}
@Override
protected Void doInBackground(Void... params) {
Cursor cursor;
ContentResolver contentResolver = context.getContentResolver();
final String[] colsToQuery = new String[]{
CalendarContract.EventsEntity.TITLE,
CalendarContract.EventsEntity.DTSTART,
CalendarContract.EventsEntity.DTEND,
CalendarContract.EventsEntity.EVENT_LOCATION};
Calendar now = Calendar.getInstance();
SimpleDateFormat startFormat = new SimpleDateFormat("dd/MM/yy");
String dateString = startFormat.format(now.getTime());
long start = now.getTimeInMillis();
SimpleDateFormat endFormat = new SimpleDateFormat("hh:mm:ss dd/MM/yy");
Calendar endOfDay = Calendar.getInstance();
Date endofDayDate;
try {
endofDayDate = endFormat.parse("23:59:59 " + dateString);
endOfDay.setTime(endofDayDate);
} catch (ParseException e) {
Log.e("CalendarModule", e.toString());
}
cursor = contentResolver.query(CalendarContract.Events.CONTENT_URI, colsToQuery,
"( dtstart >" + start + ") and (dtend <" + endOfDay.getTimeInMillis() + ")",
null, "dtstart ASC");
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
title = cursor.getString(0);
Calendar startTime = Calendar.getInstance();
startTime.setTimeInMillis(cursor.getLong(1));
Calendar endTime = Calendar.getInstance();
endTime.setTimeInMillis(cursor.getLong(2));
DateFormat formatter = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
details = formatter.format(startTime.getTime()) + " - " + formatter.format(endTime.getTime());
if (!TextUtils.isEmpty(cursor.getString(3))) {
details += " ~ " + cursor.getString(3);
}
}
cursor.close();
}
return null;
}
}.execute();
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/ChoresModule.java
================================================
package com.morristaedt.mirror.modules;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import java.util.Calendar;
/**
* Created by HannahMitt on 8/23/15.
*/
public class ChoresModule {
public static boolean waterPlantsToday() {
//TODO configuration
if (!ConfigurationSettings.isDebugBuild()) {
return false;
}
int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
return dayOfWeek == Calendar.TUESDAY || dayOfWeek == Calendar.SATURDAY;
}
public static boolean makeGroceryListToday() {
//TODO configuration
if (!ConfigurationSettings.isDebugBuild()) {
return false;
}
Calendar now = Calendar.getInstance();
int dayOfWeek = now.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.SUNDAY) {
return true;
}
if (dayOfWeek == Calendar.MONDAY && now.get(Calendar.HOUR_OF_DAY) < 15) {
return true;
}
return false;
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/CountdownModule.java
================================================
package com.morristaedt.mirror.modules;
import android.app.Activity;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class CountdownModule {
public interface CountdownListener {
void onCountdownUpdate(String timeLeft);
}
private static Timer timer;
public static void getTimeRemaining(final Date countdownEnd, final CountdownListener listener){
if (timer != null) {
timer.cancel();
}
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
long timeLeft = countdownEnd.getTime() - System.currentTimeMillis();
listener.onCountdownUpdate(formatTime(timeLeft));
}
}, 0, 1000);
}
private static String formatTime(long time) {
String formattedTime = "Time is up!";
time /= 1000; //convert to secs
if (time <= 0){
return formattedTime;
}
formattedTime = time%60 + "s";
time /= 60; //convert to mins
if (time == 0){
return formattedTime;
}
formattedTime = time%60 + "m " + formattedTime;
time /= 60; //convert to hours
if (time == 0) {
return formattedTime;
}
formattedTime = time%60 + "h " + formattedTime;
time /= 24; //convert to days
if (time == 0) {
return formattedTime;
}
formattedTime = time + "d " + formattedTime;
return formattedTime;
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/DayModule.java
================================================
package com.morristaedt.mirror.modules;
import android.text.Html;
import android.text.Spanned;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
/**
* Created by HannahMitt on 8/23/15.
*/
public class DayModule {
public static Spanned getDay() {
SimpleDateFormat formatDayOfMonth = new SimpleDateFormat("EEEE", Locale.US);
Calendar now = Calendar.getInstance();
int dayOfMonth = now.get(Calendar.DAY_OF_MONTH);
return Html.fromHtml(formatDayOfMonth.format(now.getTime()) + " the " + dayOfMonth + "<sup><small>" + getDayOfMonthSuffix(dayOfMonth) + "</small></sup>");
}
private static String getDayOfMonthSuffix(final int n) {
if (n >= 11 && n <= 13) {
return "th";
}
switch (n % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/ForecastModule.java
================================================
package com.morristaedt.mirror.modules;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.util.Log;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import com.morristaedt.mirror.requests.ForecastRequest;
import com.morristaedt.mirror.requests.ForecastResponse;
import com.morristaedt.mirror.requests.OpenWeatherRequest;
import com.morristaedt.mirror.requests.OpenWeatherResponse;
import com.morristaedt.mirror.utils.WeekUtil;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
/**
* Created by HannahMitt on 8/22/15.
*/
public class ForecastModule {
public interface ForecastListener {
void onWeatherToday(String weatherToday);
void onShouldBike(boolean showToday, boolean shouldBike);
}
/**
* @param apiKey The api key for the forecast.io weather api
* @param units
* @param lat
* @param lon
* @param listener
*/
public static void getForecastIOHourlyForecast(final String apiKey, final String units, final String lat, final String lon, final ForecastListener listener) {
new AsyncTask<Void, Void, ForecastResponse>() {
@Override
protected ForecastResponse doInBackground(Void... params) {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("https://api.forecast.io")
.build();
ForecastRequest service = restAdapter.create(ForecastRequest.class);
String excludes = "minutely,daily,flags";
try {
return service.getHourlyForecast(apiKey, lat, lon, excludes, units, Locale.getDefault().getLanguage());
} catch (RetrofitError error) {
Log.w("ForecastModule", "Forecast error: " + error.getMessage());
return null;
}
}
@Override
protected void onPostExecute(ForecastResponse forecastResponse) {
if (forecastResponse != null) {
if (forecastResponse.currently != null) {
listener.onWeatherToday(forecastResponse.currently.getDisplayTemperature() + " " + forecastResponse.currently.summary);
}
if (forecastResponse.hourly != null && forecastResponse.hourly.data != null && (ConfigurationSettings.isDemoMode() || WeekUtil.isWeekdayBeforeFive())) {
listener.onShouldBike(true, shouldBikeToday(forecastResponse.hourly.data));
} else {
listener.onShouldBike(false, true);
}
}
}
private boolean shouldBikeToday(List<ForecastResponse.Hour> hours) {
int dayOfMonthToday = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
for (ForecastResponse.Hour hour : hours) {
Calendar hourCalendar = hour.getCalendar();
// Only check hourly forecast for today
if (hourCalendar.get(Calendar.DAY_OF_MONTH) == dayOfMonthToday) {
int hourOfDay = hourCalendar.get(Calendar.HOUR_OF_DAY);
if (hourOfDay >= 7 && hourOfDay <= 11) {
if (hour.precipProbability >= 0.3) {
return false;
}
} else if (hourOfDay >= 17 && hourOfDay <= 19) {
if (hour.precipProbability >= 0.3) {
return false;
}
}
}
}
return true;
}
}.execute();
}
/**
* @param apiKey The api key for the openweather api
* @param units
* @param lat
* @param lon
* @param listener
*/
public static void getOpenWeatherForecast(final String apiKey, final String units, final String lat, final String lon, final ForecastListener listener) {
new AsyncTask<Void, Void, OpenWeatherResponse>() {
@Override
protected OpenWeatherResponse doInBackground(Void... params) {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://api.openweathermap.org")
.build();
OpenWeatherRequest service = restAdapter.create(OpenWeatherRequest.class);
try {
return service.getCurrentForecast(apiKey, lat, lon, getOpenWeatherUnits(units), Locale.getDefault().getLanguage());
} catch (RetrofitError error) {
Log.w("ForecastModule", "Forecast error: " + error.getMessage());
return null;
}
}
@Override
protected void onPostExecute(OpenWeatherResponse response) {
if (response != null) {
if (response.main != null) {
listener.onWeatherToday(response.main.getDisplayTemperature() + " " + response.getWeatherDescription());
}
}
}
}.execute();
}
@NonNull
private static String getOpenWeatherUnits(String units) {
if (units.equalsIgnoreCase(ForecastRequest.UNITS_SI)) {
return OpenWeatherRequest.UNITS_METRIC;
} else if (units.equalsIgnoreCase(ForecastRequest.UNITS_US)) {
return OpenWeatherRequest.UNITS_IMPERIAL;
}
return units;
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/MoodModule.java
================================================
package com.morristaedt.mirror.modules;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.util.SparseArray;
import com.google.android.gms.vision.CameraSource;
import com.google.android.gms.vision.Detector;
import com.google.android.gms.vision.face.Face;
import com.google.android.gms.vision.face.FaceDetector;
import com.morristaedt.mirror.R;
import java.io.IOException;
import java.lang.ref.WeakReference;
/**
* Created by akodiakson on 9/13/15.
*/
public class MoodModule {
private static final String TAG = "MoodModule";
private WeakReference<Context> mContextWeakReference;
private CameraSource mCameraSource = null;
private MoodListener mCallBacks;
public interface MoodListener {
void onShouldGivePositiveAffirmation(String affirmation);
}
public MoodModule(WeakReference<Context> contextWeakReference) {
mContextWeakReference = contextWeakReference;
}
public void getCurrentMood(MoodListener moodListener) {
createCameraSource();
mCallBacks = moodListener;
}
public void release() {
if (mCameraSource != null) {
mCameraSource.release();
mCameraSource = null;
}
}
/**
* Creates and starts the camera. Note that this uses a higher resolution in comparison
* to other detection examples to enable the barcode detector to detect small barcodes
* at long distances.
*/
private void createCameraSource() {
Context context = mContextWeakReference.get();
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
detector.setProcessor(new Detector.Processor<Face>() {
@Override
public void release() {
}
@Override
public void receiveDetections(final Detector.Detections<Face> detections) {
final SparseArray<Face> detectedItems = detections.getDetectedItems();
if (detectedItems.size() != 0) {
final int key = detectedItems.keyAt(0);
final Face face = detectedItems.get(key);
final float isSmilingProbability = face.getIsSmilingProbability();
String feedback = getFeedbackForSmileProbability(isSmilingProbability);
mCallBacks.onShouldGivePositiveAffirmation(feedback);
}
}
});
if (!detector.isOperational()) {
// Note: The first time that an app using face API is installed on a device, GMS will
// download a native library to the device in order to do detection. Usually this
// completes before the app is run for the first time. But if that download has not yet
// completed, then the above call will not detect any faces.
//
// isOperational() can be used to check if the required native library is currently
// available. The detector will automatically become operational once the library
// download completes on device.
Log.w(TAG, "Face detector dependencies are not yet available.");
}
try {
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
mCameraSource.start();
} catch (IOException | RuntimeException e) {
Log.e(TAG, "Something went horribly wrong, with your face.", e);
}
}
private String getFeedbackForSmileProbability(float isSmilingProbability) {
final boolean isSmiling = isSmilingProbability > 0.5f;
final boolean aFaceIsntDetected = isSmilingProbability <= 0;
String feedback;
if (isSmiling || aFaceIsntDetected) {
return null;
}
final Resources resources = mContextWeakReference.get().getResources();
if (isSmilingProbability < 0.15) {
feedback = resources.getString(R.string.it_gets_better);
} else if (isSmilingProbability < 0.30) {
feedback = resources.getString(R.string.looking_good);
} else {
feedback = resources.getString(R.string.something_special);
}
return feedback;
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/NewsModule.java
================================================
package com.morristaedt.mirror.modules;
import android.os.AsyncTask;
import android.util.Log;
import org.mcsoxford.rss.RSSFeed;
import org.mcsoxford.rss.RSSReader;
import org.mcsoxford.rss.RSSReaderException;
/**
* Created by alex on 21/09/15.
*/
public class NewsModule {
public interface NewsListener {
void onNewNews(String headline);
}
public static void getNewsHeadline(final NewsListener newsListener) {
new AsyncTask<Void, Void, String>() {
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
newsListener.onNewNews(s);
}
@Override
protected String doInBackground(Void... params) {
RSSReader rssReader = new RSSReader();
String url = "http://feeds.bbci.co.uk/news/world/rss.xml?edition=uk";
try {
RSSFeed feed = rssReader.load(url);
String headline = feed.getItems().get(0).getTitle();
for (int i = 1; i < 10; ++i) {
headline += " " + feed.getItems().get(i).getTitle();
}
return headline;
} catch (RSSReaderException e) {
Log.e("NewsModule", "Error parsing RSS");
return null;
} catch (Exception e) {
// not great to catch general exceptions, but this lib is being sketchy
Log.e("NewsModule", "Error parsing RSS");
return null;
}
}
}.execute();
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/TimeModule.java
================================================
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));
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/TrainScheduleModule.java
================================================
package com.morristaedt.mirror.modules;
import java.util.List;
/**
* Created by asm on 8/23/15.
*/
public class TrainScheduleModule {
public int waitingSecondsForNextArrivalWithBufferSeconds(int bufferSeconds) {
/*
earliestArrivalAfterNowWithBufferSeconds(bufferSeconds) - (nowDaySeconds + bufferSeconds);
*/
return 0;
}
public int earliestArrivalAfterNowWithBufferSeconds(int bufferSeconds) {
// earliestArrivalAfterDaySeconds(nowDaySeconds+bufferSeconds);
return 0;
}
public int earliestArrivalAfterDaySeconds (int afterDaySecs) {
/*
nowSchedule.find {
time:
Int =>time >= afterDaySecs
} match {
case Some(time: Int)=>time
case _ =>((60 * 60 * 24) + nowSchedule(0))
}
*/
return 0;
}
public int nowDaySeconds() {
/*
val calendar:Calendar = Calendar.getInstance();
val now:Long = calendar.getTimeInMillis();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
((now - calendar.getTimeInMillis())/1000L).toInt;
*/
return 0;
}
public int stringToDaySeconds(String daySecsString) {
/*
val elements = daySecsString.split(":")
(
(elements(0).toInt * 60 * 60)
+ (elements(1).toInt * 60)
+ elements(2).toInt
) % (60 * 60 * 24)
*/
return 0;
}
public List<Integer> nowSchedule() {
/*
Calendar.getInstance().get(Calendar.DAY_OF_WEEK) match {
case Calendar.SATURDAY => saturdaySchedule
case Calendar.SUNDAY => sundaySchedule
case _ => weekdaySchedule
*/
return null;
}
/**
* Weekday schedule for the F train out of
* station F21N.
*/
/*
val weekdaySchedule:List[Int] = List(
"02:30:30",
"02:50:30",
"03:10:30",
"03:30:30",
"03:50:30",
"04:10:30",
"04:30:30",
"04:50:30",
"05:10:00",
"05:24:00",
"05:38:00",
"05:50:00",
"06:02:00",
"06:14:00",
"06:24:00",
"06:34:00",
"06:44:00",
"06:52:00",
"06:59:00",
"07:05:00",
"07:11:00",
"07:17:00",
"07:23:00",
"07:29:00",
"07:34:00",
"07:39:00",
"07:44:00",
"07:49:00",
"07:53:00",
"07:59:00",
"08:03:30",
"08:08:30",
"08:13:30",
"08:17:30",
"08:21:30",
"08:25:30",
"08:29:30",
"08:33:30",
"08:37:30",
"08:43:00",
"08:48:30",
"08:53:00",
"08:58:00",
"09:03:00",
"09:08:00",
"09:14:00",
"09:20:00",
"09:26:00",
"09:32:00",
"09:37:30",
"09:44:00",
"09:51:00",
"09:58:00",
"10:06:00",
"10:14:00",
"10:20:00",
"10:29:00",
"10:34:30",
"10:42:00",
"10:50:00",
"10:59:00",
"11:04:30",
"11:11:30",
"11:20:00",
"11:27:30",
"11:35:00",
"11:42:00",
"11:50:00",
"11:57:30",
"12:05:00",
"12:12:00",
"12:20:00",
"12:27:30",
"12:35:00",
"12:42:00",
"12:50:00",
"12:57:30",
"13:05:00",
"13:12:00",
"13:20:00",
"13:27:30",
"13:35:00",
"13:42:00",
"13:50:00",
"13:57:30",
"14:05:00",
"14:12:00",
"14:19:30",
"14:25:30",
"14:31:00",
"14:37:00",
"14:42:00",
"14:49:00",
"14:54:00",
"15:01:00",
"15:06:00",
"15:12:00",
"15:18:30",
"15:25:00",
"15:30:00",
"15:37:00",
"15:42:00",
"15:48:30",
"15:53:30",
"15:58:30",
"16:01:30",
"16:08:00",
"16:12:00",
"16:18:00",
"16:23:00",
"16:25:30",
"16:31:00",
"16:34:00",
"16:38:00",
"16:41:00",
"16:46:00",
"16:50:00",
"16:54:00",
"16:57:30",
"17:02:00",
"17:06:00",
"17:10:00",
"17:14:00",
"17:18:00",
"17:22:00",
"17:26:00",
"17:31:00",
"17:35:30",
"17:40:30",
"17:45:30",
"17:51:30",
"17:57:00",
"18:01:30",
"18:06:30",
"18:11:00",
"18:18:00",
"18:22:00",
"18:26:00",
"18:33:00",
"18:38:30",
"18:44:00",
"18:49:00",
"18:53:00",
"18:58:00",
"19:04:00",
"19:09:30",
"19:14:00",
"19:20:30",
"19:25:00",
"19:30:00",
"19:36:00",
"19:42:00",
"19:48:00",
"19:54:00",
"20:00:00",
"20:06:00",
"20:12:00",
"20:18:00",
"20:24:00",
"20:29:00",
"20:36:00",
"20:42:00",
"20:48:00",
"20:54:00",
"21:02:00",
"21:09:30",
"21:17:00",
"21:24:30",
"21:32:00",
"21:39:00",
"21:44:30",
"21:54:00",
"22:04:00",
"22:14:30",
"22:24:30",
"22:35:30",
"22:47:30",
"22:59:30",
"23:11:30",
"23:23:30",
"23:35:30",
"23:47:00",
"23:59:00",
"24:10:30",
"24:22:30",
"24:35:00",
"24:50:30",
"25:10:30",
"25:30:30",
"25:50:30",
"26:10:30"
).map(stringToDaySeconds(_)).sortWith(_ < _)
*/
/**
* Saturday schedule for the F train out of
* station F21N.
*/
/*
val saturdaySchedule:List[Int] = List(
"02:30:30",
"02:50:30",
"03:10:30",
"03:30:30",
"03:50:30",
"04:10:30",
"04:30:30",
"04:50:30",
"05:10:30",
"05:30:30",
"05:50:30",
"06:09:30",
"06:27:00",
"06:44:00",
"06:59:30",
"07:11:30",
"07:24:30",
"07:36:30",
"07:48:30",
"08:00:30",
"08:12:30",
"08:24:30",
"08:35:30",
"08:45:30",
"08:55:30",
"09:05:30",
"09:15:30",
"09:25:30",
"09:35:30",
"09:45:30",
"09:55:30",
"10:05:30",
"10:15:30",
"10:25:30",
"10:35:30",
"10:45:30",
"10:55:30",
"11:05:30",
"11:15:30",
"11:25:30",
"11:35:30",
"11:45:30",
"11:55:30",
"12:05:30",
"12:15:30",
"12:25:30",
"12:35:30",
"12:45:30",
"12:55:30",
"13:05:30",
"13:15:30",
"13:25:30",
"13:35:30",
"13:45:30",
"13:55:30",
"14:05:30",
"14:15:30",
"14:25:30",
"14:35:30",
"14:45:30",
"14:55:30",
"15:05:30",
"15:15:30",
"15:25:30",
"15:35:30",
"15:45:30",
"15:55:30",
"16:05:30",
"16:15:30",
"16:25:30",
"16:35:30",
"16:45:30",
"16:55:30",
"17:05:30",
"17:15:30",
"17:25:30",
"17:35:30",
"17:45:30",
"17:55:30",
"18:05:30",
"18:15:30",
"18:25:30",
"18:35:30",
"18:45:30",
"18:55:30",
"19:05:30",
"19:15:30",
"19:25:30",
"19:35:30",
"19:45:30",
"19:55:30",
"20:05:30",
"20:15:30",
"20:25:30",
"20:35:30",
"20:45:30",
"20:55:30",
"21:05:30",
"21:16:00",
"21:30:00",
"21:41:30",
"21:53:30",
"22:05:30",
"22:17:30",
"22:29:30",
"22:41:00",
"22:53:00",
"23:05:00",
"23:17:00",
"23:29:00",
"23:41:00",
"23:53:00",
"24:05:00",
"24:17:00",
"24:30:30",
"24:50:30",
"25:10:30",
"25:30:30",
"25:50:30",
"26:10:30"
).map(stringToDaySeconds(_)).sortWith(_ < _)
*/
/**
* Sunday schedule for the F train out of
* station F21N.
*/
/*
val sundaySchedule:List[Int] = List(
"02:30:30",
"02:50:30",
"03:10:30",
"03:30:30",
"03:50:30",
"04:10:30",
"04:30:30",
"04:50:30",
"05:10:30",
"05:30:30",
"05:50:30",
"06:10:30",
"06:30:30",
"06:50:30",
"07:10:30",
"07:30:00",
"07:49:00",
"08:04:00",
"08:19:30",
"08:34:30",
"08:49:30",
"09:04:30",
"09:16:30",
"09:28:30",
"09:40:30",
"09:52:30",
"10:04:30",
"10:16:30",
"10:28:30",
"10:38:30",
"10:48:30",
"10:58:30",
"11:08:30",
"11:18:30",
"11:28:30",
"11:38:30",
"11:48:30",
"11:58:30",
"12:08:30",
"12:18:30",
"12:28:30",
"12:38:30",
"12:48:30",
"12:58:30",
"13:08:30",
"13:18:30",
"13:28:30",
"13:38:30",
"13:48:30",
"13:58:30",
"14:08:30",
"14:18:30",
"14:28:30",
"14:38:30",
"14:48:30",
"14:58:30",
"15:08:30",
"15:18:30",
"15:28:30",
"15:38:30",
"15:48:30",
"15:58:30",
"16:08:30",
"16:18:30",
"16:28:30",
"16:38:30",
"16:48:30",
"16:58:30",
"17:08:30",
"17:18:30",
"17:28:30",
"17:38:30",
"17:48:30",
"17:58:30",
"18:08:30",
"18:18:30",
"18:28:30",
"18:38:30",
"18:48:30",
"18:58:30",
"19:08:30",
"19:18:30",
"19:28:30",
"19:38:30",
"19:48:30",
"19:58:30",
"20:08:30",
"20:18:30",
"20:29:30",
"20:41:30",
"20:53:30",
"21:05:30",
"21:17:30",
"21:28:30",
"21:40:30",
"21:52:30",
"22:04:30",
"22:19:00",
"22:34:00",
"22:49:00",
"23:04:00",
"23:19:00",
"23:34:00",
"23:50:30",
"24:10:30",
"24:30:30",
"24:50:30",
"25:10:30",
"25:30:30",
"25:50:30",
"26:10:30"
).map(stringToDaySeconds(_)).sortWith(_ < _)
*/
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/XKCDModule.java
================================================
package com.morristaedt.mirror.modules;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import com.morristaedt.mirror.requests.XKCDRequest;
import com.morristaedt.mirror.requests.XKCDResponse;
import java.util.Calendar;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
/**
* Created by HannahMitt on 8/22/15.
*/
public class XKCDModule {
public interface XKCDListener {
void onNewXKCDToday(String url);
}
/**
* Fetch the the latest xkcd comic, but only show it if its new today
*
* @param listener
*/
public static void getXKCDForToday(final XKCDListener listener) {
new AsyncTask<Void, Void, XKCDResponse>() {
@Override
protected XKCDResponse doInBackground(Void... params) {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://xkcd.com")
.build();
XKCDRequest service = restAdapter.create(XKCDRequest.class);
try {
return service.getLatestXKCD();
} catch (RetrofitError e) {
Log.w("XKCDModule", "Error loading xkcd", e);
return null;
}
}
@Override
protected void onPostExecute(@Nullable XKCDResponse xkcdResponse) {
if (xkcdResponse != null && !TextUtils.isEmpty(xkcdResponse.img)) {
if (ConfigurationSettings.isDemoMode() || isTodaysXKCD(xkcdResponse)) {
listener.onNewXKCDToday(xkcdResponse.img);
return;
}
}
listener.onNewXKCDToday(null);
}
private boolean isTodaysXKCD(@NonNull XKCDResponse xkcdResponse) {
Calendar today = Calendar.getInstance();
return xkcdResponse.day == today.get(Calendar.DAY_OF_MONTH) && xkcdResponse.month == (today.get(Calendar.MONTH) + 1) && xkcdResponse.year == today.get(Calendar.YEAR);
}
}.execute();
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/modules/YahooFinanceModule.java
================================================
package com.morristaedt.mirror.modules;
import android.os.AsyncTask;
import android.support.annotation.Nullable;
import android.util.Log;
import com.morristaedt.mirror.configuration.ConfigurationSettings;
import com.morristaedt.mirror.requests.YahooFinanceRequest;
import com.morristaedt.mirror.requests.YahooStockResponse;
import java.math.BigDecimal;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
/**
* Created by HannahMitt on 8/22/15.
*/
public class YahooFinanceModule {
public interface StockListener {
void onNewStockPrice(YahooStockResponse.YahooQuoteResponse quoteResponse);
}
/**
* Fetch the the latest stock price, but only show it if its a large change
*
* @param listener
*/
public static void getStockForToday(final String stockName, final StockListener listener) {
new AsyncTask<Void, Void, YahooStockResponse>() {
@Override
protected YahooStockResponse doInBackground(Void... params) {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://query.yahooapis.com/v1/public")
.build();
YahooFinanceRequest service = restAdapter.create(YahooFinanceRequest.class);
String query = "select * from yahoo.finance.quotes where symbol in (\"" + stockName + "\")";
String env = "http://datatables.org/alltables.env";
String format = "json";
try {
return service.getStockData(query, env, format);
} catch (RetrofitError error) {
Log.w("YahooFinanceModule", "YahooFinance error: " + error.getMessage());
return null;
}
}
@Override
protected void onPostExecute(@Nullable YahooStockResponse stockResponse) {
if (stockResponse != null && stockResponse.getQuoteResponse() != null) {
YahooStockResponse.YahooQuoteResponse quoteResponse = stockResponse.getQuoteResponse();
if (ConfigurationSettings.isDemoMode() || quoteResponse.getPercentageChange().abs().compareTo(BigDecimal.valueOf(0.03)) >= 0) {
listener.onNewStockPrice(quoteResponse);
return;
}
}
listener.onNewStockPrice(null);
}
}.execute();
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/receiver/AlarmReceiver.java
================================================
package com.morristaedt.mirror.receiver;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.os.SystemClock;
import com.morristaedt.mirror.MirrorActivity;
/**
* Created by HannahMitt on 8/22/15.
*/
public class AlarmReceiver extends BroadcastReceiver {
private static final int REQUEST_CODE = 1001;
private static final String WAKE_LOCK = "HomeMirrorWakeLock";
private static final long MINUTES_10 = 10 * 60 * 1000;
public static void startMirrorUpdates(Context context) {
AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + MINUTES_10, MINUTES_10, alarmIntent);
}
public static void stopMirrorUpdates(Context context) {
AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
alarmMgr.cancel(alarmIntent);
}
@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();
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/ForecastRequest.java
================================================
package com.morristaedt.mirror.requests;
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
/**
* Created by HannahMitt on 8/23/15.
*/
public interface ForecastRequest {
public static final String UNITS_SI = "si";
public static final String UNITS_US = "us";
@GET("/forecast/{apikey}/{lat},{lon}")
ForecastResponse getHourlyForecast(@Path("apikey") String apiKey, @Path("lat") String lat, @Path("lon") String lon, @Query("exclude") String exclude, @Query("units") String units, @Query("lang") String language);
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/ForecastResponse.java
================================================
package com.morristaedt.mirror.requests;
import java.util.ArrayList;
import java.util.Calendar;
/**
* Created by HannahMitt on 8/23/15.
*/
public class ForecastResponse {
float latitude;
float longitude;
public ForecastCurrently currently;
public ForecastHourly hourly;
public class ForecastCurrently {
public String summary;
public float temperature;
public String getDisplayTemperature() {
return String.valueOf(Math.round(temperature)) + (char) 0x00B0;
}
}
public class ForecastHourly {
String summary;
public ArrayList<Hour> data;
}
public class Hour {
public long time; // in seconds
public String summary;
public String precipType;
public float precipProbability;
public float temperature;
public Calendar getCalendar() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time * 1000);
return calendar;
}
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/OpenWeatherRequest.java
================================================
package com.morristaedt.mirror.requests;
import retrofit.http.GET;
import retrofit.http.Query;
/**
*/
public interface OpenWeatherRequest {
String UNITS_METRIC = "metric";
String UNITS_IMPERIAL = "imperial";
@GET("/data/2.5/weather")
OpenWeatherResponse getCurrentForecast(@Query("APPID") String apiKey,
@Query("lat") String lat,
@Query("lon") String lon,
@Query("units") String units,
@Query("lang") String language);
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/OpenWeatherResponse.java
================================================
package com.morristaedt.mirror.requests;
import android.text.TextUtils;
import java.util.ArrayList;
/**
*/
public class OpenWeatherResponse {
public ArrayList<Weather> weather;
public Main main;
public String getWeatherDescription() {
if (weather != null && weather.size() > 0) {
return TextUtils.join(", ", weather);
}
return "";
}
public class Weather {
public String description;
public String getDescription() {
return description;
}
@Override
public String toString() {
return getDescription();
}
}
public class Main {
float temp;
public String getDisplayTemperature() {
return String.valueOf(Math.round(temp)) + (char) 0x00B0;
}
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/XKCDRequest.java
================================================
package com.morristaedt.mirror.requests;
import retrofit.http.GET;
/**
* Created by HannahMitt on 8/22/15.
*/
public interface XKCDRequest {
@GET("/info.0.json")
XKCDResponse getLatestXKCD();
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/XKCDResponse.java
================================================
package com.morristaedt.mirror.requests;
/**
* Created by HannahMitt on 8/22/15.
*/
public class XKCDResponse {
public int day;
public int month;
public int year;
public String img;
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/YahooFinanceRequest.java
================================================
package com.morristaedt.mirror.requests;
import retrofit.http.GET;
import retrofit.http.Query;
/**
* Created by HannahMitt on 8/23/15.
*/
public interface YahooFinanceRequest {
@GET("/yql")
YahooStockResponse getStockData(@Query("q") String query, @Query("env") String env, @Query("format") String format);
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/requests/YahooStockResponse.java
================================================
package com.morristaedt.mirror.requests;
import android.text.TextUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* Created by HannahMitt on 8/23/15.
*/
public class YahooStockResponse {
private YahooQueryResponse query;
private class YahooQueryResponse {
public YahooResultsResponse results;
}
private class YahooResultsResponse {
public YahooQuoteResponse quote;
}
public class YahooQuoteResponse {
public String symbol;
public String PercentChange;
public float LastTradePriceOnly;
public BigDecimal getPercentageChange() {
if (!TextUtils.isEmpty(PercentChange)) {
BigDecimal decimalPercentage = new BigDecimal(PercentChange.trim().replace("%", "")).divide(BigDecimal.valueOf(100), RoundingMode.CEILING);
return decimalPercentage;
} else {
return BigDecimal.valueOf(0);
}
}
}
public YahooQuoteResponse getQuoteResponse() {
if (query != null && query.results != null) {
return query.results.quote;
}
return null;
}
}
================================================
FILE: app/src/main/java/com/morristaedt/mirror/utils/WeekUtil.java
================================================
package com.morristaedt.mirror.utils;
import java.util.Calendar;
/**
* Created by HannahMitt on 8/23/15.
*/
public class WeekUtil {
public static boolean isWeekday() {
int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
return dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY;
}
public static boolean afterFive() {
int hourOfDay = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
return hourOfDay >= 17;
}
public static boolean isWeekdayBeforeFive() {
return isWeekday() && !afterFive();
}
public static boolean isWeekdayAfterFive() {
return isWeekday() && afterFive();
}
}
================================================
FILE: app/src/main/res/drawable/apptheme_btn_check_holo_dark.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Enabled states -->
<item android:state_checked="true" android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_on_holo_dark" />
<item android:state_checked="false" android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_off_holo_dark" />
<item android:state_checked="true" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_on_pressed_holo_dark" />
<item android:state_checked="false" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_off_pressed_holo_dark" />
<item android:state_checked="true" android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_on_focused_holo_dark" />
<item android:state_checked="false" android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_off_focused_holo_dark" />
<item android:state_checked="false"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_off_holo_dark" />
<item android:state_checked="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_check_on_holo_dark" />
<!-- Disabled states -->
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/apptheme_btn_check_on_disabled_holo_dark" />
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/apptheme_btn_check_off_disabled_holo_dark" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/apptheme_btn_check_on_disabled_focused_holo_dark" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/apptheme_btn_check_off_disabled_focused_holo_dark" />
<item android:state_checked="false" android:drawable="@drawable/apptheme_btn_check_off_disabled_holo_dark" />
<item android:state_checked="true" android:drawable="@drawable/apptheme_btn_check_on_disabled_holo_dark" />
</selector>
================================================
FILE: app/src/main/res/drawable/apptheme_btn_radio_holo_dark.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_on_holo_dark" />
<item android:state_checked="false" android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_off_holo_dark" />
<item android:state_checked="true" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_on_pressed_holo_dark" />
<item android:state_checked="false" android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_off_pressed_holo_dark" />
<item android:state_checked="true" android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_on_focused_holo_dark" />
<item android:state_checked="false" android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_off_focused_holo_dark" />
<item android:state_checked="false" android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_off_holo_dark" />
<item android:state_checked="true" android:state_enabled="true"
android:drawable="@drawable/apptheme_btn_radio_on_holo_dark" />
<!-- Disabled states -->
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/apptheme_btn_radio_on_disabled_holo_dark" />
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/apptheme_btn_radio_off_disabled_holo_dark" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/apptheme_btn_radio_on_disabled_focused_holo_dark" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/apptheme_btn_radio_off_disabled_focused_holo_dark" />
<item android:state_checked="false" android:drawable="@drawable/apptheme_btn_radio_off_disabled_holo_dark" />
<item android:state_checked="true" android:drawable="@drawable/apptheme_btn_radio_on_disabled_holo_dark" />
</selector>
================================================
FILE: app/src/main/res/layout/activity_configuration.xml
================================================
<ScrollView 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin"
tools:context=".ConfigurationActivity">
<TextView
style="@style/MirrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_up" />
<TextView
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temperature" />
<RadioGroup
android:id="@+id/temperature_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/item_margin"
android:orientation="horizontal">
<RadioButton
android:id="@+id/celsius"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:text="Celsius" />
<RadioButton
android:id="@+id/farenheit"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/item_margin"
android:layout_marginTop="0dp"
android:text="Farenheit" />
</RadioGroup>
<TextView
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Text Color" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/item_margin"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="R" />
<SeekBar
android:id="@+id/ColorPickerRed"
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="255"/>
<TextView
android:id="@+id/ColorShowerRed"
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="3"
android:text="0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G" />
<SeekBar
android:id="@+id/ColorPickerGreen"
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="255"/>
<TextView
android:id="@+id/ColorShowerGreen"
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="3"
android:text="0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B" />
<SeekBar
android:id="@+id/ColorPickerBlue"
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="255"/>
<TextView
android:id="@+id/ColorShowerBlue"
style="@style/ConfigurationItemText"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="3"
android:text="0" />
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/colored_bar"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
<CheckBox
android:id="@+id/biking_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/biking_hint" />
<CheckBox
android:id="@+id/mood_detection_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/mood_detection_option" />
<TextView
style="@style/ConfigurationDescriptionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mood_explanation" />
<CheckBox
android:id="@+id/calendar_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/show_calendar_event" />
<CheckBox
android:id="@+id/headline_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/show_headline" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/item_margin"
android:orientation="horizontal">
<CheckBox
android:id="@+id/xkcd_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/item_margin"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/show_xkcd" />
<CheckBox
android:id="@+id/xkcd_invert_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/invert_colors" />
</LinearLayout>
<LinearLayout
android:id="@+id/countdown_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<CheckBox
android:id="@+id/countdown_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/show_countdown" />
<CheckBox
android:id="@+id/countdown_new_checkbox"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/new_countdown" />
<LinearLayout
android:id="@+id/new_countdown_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/countdown_days"
style="@style/ConfigurationEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/time_day"
android:inputType="number" />
<TextView
style="@style/ConfigurationEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/time_day_short" />
<EditText
android:id="@+id/countdown_hours"
style="@style/ConfigurationEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/time_hour"
android:maxLength="2"
android:inputType="number" />
<TextView
style="@style/ConfigurationEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/time_hour_short" />
<EditText
android:id="@+id/countdown_mins"
style="@style/ConfigurationEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/time_min"
android:maxLength="2"
android:inputType="number" />
<TextView
style="@style/ConfigurationEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/time_min_short" />
<EditText
android:id="@+id/countdown_secs"
style="@style/ConfigurationEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/time_sec"
android:maxLength="2"
android:inputType="number" />
<TextView
style="@style/ConfigurationEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/time_sec_short" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/location_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/location_title"
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location" />
<TextView
style="@style/ConfigurationDescriptionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/location_title"
android:layout_marginLeft="@dimen/item_margin"
android:layout_toRightOf="@id/location_title"
android:text="Couldn't detect a recent location" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/latitude"
style="@style/ConfigurationEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/item_margin"
android:layout_weight="1"
android:hint="@string/latitude"
android:inputType="numberDecimal|numberSigned" />
<EditText
android:id="@+id/longitude"
style="@style/ConfigurationEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/longitude"
android:inputType="numberDecimal|numberSigned" />
</LinearLayout>
</LinearLayout>
<TextView
style="@style/ConfigurationItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/stock" />
<EditText
android:id="@+id/stock_name"
style="@style/ConfigurationEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/item_margin"
android:hint="@string/ticker_symbol"
android:inputType="textCapCharacters" />
<TextView
style="@style/ConfigurationDescriptionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/stock_description" />
<Button
android:id="@+id/launch_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/item_margin"
android:text="@string/launch"
android:textSize="@dimen/configuration_text_size" />
<TextView
style="@style/ConfigurationDescriptionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/item_margin"
android:text="@string/how_to_stop" />
</LinearLayout>
</ScrollView>
================================================
FILE: app/src/main/res/layout/activity_mirror.xml
================================================
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/birthday_text"
style="@style/MirrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/mirror_birthday_text_size"
android:visibility="gone"
tools:text="Happy Birthday Andy!" />
<TextView
android:id="@+id/day_text"
style="@style/MirrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Sunday the 22nd" />
<include layout="@layout/clock" />
<TextView
android:id="@+id/weather_summary"
style="@style/MirrorText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:includeFontPadding="false"
tools:text="Partly Cloudy" />
<TextView
android:id="@+id/calendar_title"
style="@style/MirrorText"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/mirror_item_spacing"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:includeFontPadding="false"
android:singleLine="true"
tools:text="Very important meeting" />
<TextView
android:id="@+id/calendar_details"
style="@style/MirrorText"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:includeFontPadding="false"
android:singleLine="true"
tools:text="11:00-12:00 ~ 10 Downing Street" />
<ImageView
android:id="@+id/xkcd_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/mirror_item_spacing"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/mirror_item_spacing"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="@+id/hello_text"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:text="Good morning, Andy and Hannah" />
<TextView
android:id="@+id/can_bike"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/bike"
android:visibility="gone"
tools:text="Don't Bike Today"
tools:visibility="visible" />
<TextView
android:id="@+id/water_plants"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/air_plant"
android:text="@string/water_plants"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/grocery_list"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/grocery_bag"
android:text="@string/grocery_list"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/news_headline"
style="@style/MirrorMarqueeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:visibility="gone"
tools:text="A news headline"
tools:visiblity="visible" />
<TextView
android:id="@+id/stock_text"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/stock"
android:visibility="gone"
tools:text="$ETSY $13.46"
tools:visibility="gone" />
<TextView
android:id="@+id/mood_text"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/smile"
android:visibility="gone"
tools:text="Just be happy"
tools:visibility="visible" />
<TextView
android:id="@+id/countdown_text"
style="@style/MirrorListText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:text="Time is up!"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
================================================
FILE: app/src/main/res/layout/clock.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<DigitalClock xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MirrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:format12Hour="h:mm"
android:includeFontPadding="false"
android:padding="0dp"
android:textSize="@dimen/mirror_clock_text_size" />
================================================
FILE: app/src/main/res/layout-v17/clock.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<TextClock xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MirrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:format12Hour="h:mm"
android:includeFontPadding="false"
android:padding="0dp"
android:textSize="@dimen/mirror_clock_text_size" />
================================================
FILE: app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="item_margin">20dp</dimen>
<dimen name="mirror_item_spacing">40dp</dimen>
<dimen name="mirror_text_size">38sp</dimen>
<dimen name="mirror_clock_text_size">80sp</dimen>
<dimen name="mirror_birthday_text_size">48sp</dimen>
<dimen name="configuration_text_size">20sp</dimen>
<dimen name="configuration_description_size">14sp</dimen>
</resources>
================================================
FILE: app/src/main/res/values/strings.xml
================================================
<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>
<!-- Forecast module -->
<string name="bike_today">Bike Today</string>
<string name="no_bike_today">Don\'t Bike Today</string>
<!-- Birthday module -->
<string name="happy_birthday">Happy Birthday, %s!</string>
<!-- Chores module -->
<string name="water_plants">Water Plants</string>
<string name="grocery_list">Grocery List</string>
<!-- Mood module -->
<string name="it_gets_better">Cheer up, bud</string>
<string name="looking_good">Looking flyyy</string>
<string name="something_special">Yay! Hi sunshine.</string>
<!-- Set up -->
<string name="location">Location</string>
<string name="set_up">Set Up</string>
<string name="latitude">Latitude</string>
<string name="longitude">Longitude</string>
<string name="launch">Launch</string>
<string name="mood_detection_option">Show mood detection</string>
<string name="show_xkcd">Show new xkcd</string>
<string name="invert_colors">Invert comic colors</string>
<string name="show_calendar_event">Show next calendar event</string>
<string name="stock">Stock</string>
<string name="ticker_symbol">Ticker symbol, i.e. GOOG</string>
<string name="show_headline">Show BBC headline</string>
<string name="found_location">Found location</string>
<string name="mood_explanation">Uses the front facing camera to read your expression</string>
<string name="stock_description">Displays on weekdays if the stock swings more than 3%</string>
<string name="biking_hint">Show biking weather hint</string>
<string name="how_to_stop">To get back to Set Up and stop mirror updates, swipe up from bottom of launched mirror, and press Back.</string>
<string name="show_countdown">Show countdown</string>
<string name="new_countdown">New countdown</string>
<string name="time_day">day</string>
<string name="time_hour">hour</string>
<string name="time_min">min</string>
<string name="time_sec">sec</string>
<string name="time_day_short">d</string>
<string name="time_hour_short">h</string>
<string name="time_min_short">m</string>
<string name="time_sec_short">s</string>
</resources>
================================================
FILE: app/src/main/res/values/styles.xml
================================================
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- 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">@dimen/mirror_text_size</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:checkboxStyle">@style/CompatCheckboxStyle</item>
<item name="android:radioButtonStyle">@style/CompatRadioButtonStyle</item>
<item name="android:buttonStyle">@android:style/Widget.Holo.Button</item>
</style>
<style name="CompatCheckboxStyle" parent="@android:style/Widget.Holo.CompoundButton.CheckBox">
<item name="android:button">@drawable/apptheme_btn_check_holo_dark</item>
</style>
<style name="CompatRadioButtonStyle" parent="@android:style/Widget.Holo.CompoundButton.RadioButton">
<item name="android:button">@drawable/apptheme_btn_radio_holo_dark</item>
</style>
<style name="MirrorText">
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif-light</item>
<item name="android:gravity">right|center_vertical</item>
<item name="android:drawablePadding">8dp</item>
</style>
<style name="MirrorListText" parent="MirrorText">
<item name="android:paddingBottom">@dimen/item_margin</item>
</style>
<style name="MirrorMarqueeText" parent="MirrorListText">
<item name="android:gravity"/>
</style>
<style name="ConfigurationItemText">
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif</item>
<item name="android:textSize">@dimen/configuration_text_size</item>
<item name="android:layout_marginTop">@dimen/item_margin</item>
</style>
<style name="ConfigurationDescriptionText">
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif</item>
<item name="android:textSize">@dimen/configuration_description_size</item>
</style>
<style name="ConfigurationEditText" parent="Base.Widget.AppCompat.EditText">
<item name="android:textSize">@dimen/configuration_text_size</item>
</style>
</resources>
================================================
FILE: app/src/main/res/values-sw600dp/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="item_margin">20dp</dimen>
<dimen name="mirror_item_spacing">60dp</dimen>
<dimen name="mirror_text_size">48sp</dimen>
<dimen name="mirror_clock_text_size">90sp</dimen>
<dimen name="mirror_birthday_text_size">60sp</dimen>
<dimen name="configuration_text_size">24sp</dimen>
<dimen name="configuration_description_size">18sp</dimen>
</resources>
================================================
FILE: app/src/main/res/values-sw600dp/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Chores module -->
<string name="water_plants">Water Plants Today</string>
<string name="grocery_list">Make Grocery List</string>
</resources>
================================================
FILE: app/src/main/res/values-v21/styles.xml
================================================
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. Removes unneeded compat styles -->
<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">@dimen/mirror_text_size</item>
<item name="android:textColor">@android:color/white</item>
</style>
</resources>
================================================
FILE: build.gradle
================================================
// 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()
}
}
================================================
FILE: design/install_assets.sh
================================================
#!/bin/sh
cd assets
find . -type f -path '*_10.png' | while read l; do F=`echo $l | sed -e "s/_10//"`; cp $l ../../app/src/main/res/drawable-mdpi/$F; done
find . -type f -path '*_15.png' | while read l; do F=`echo $l | sed -e "s/_15//"`; cp $l ../../app/src/main/res/drawable-hdpi/$F; done
find . -type f -path '*_20.png' | while read l; do F=`echo $l | sed -e "s/_20//"`; cp $l ../../app/src/main/res/drawable-xhdpi/$F; done
cd -
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#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
================================================
FILE: gradle.properties
================================================
# 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
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
include ':app'
gitextract_5ytlax3m/ ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── morristaedt/ │ │ └── mirror/ │ │ └── ApplicationTest.java │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── morristaedt/ │ │ └── mirror/ │ │ ├── MirrorActivity.java │ │ ├── MirrorApplication.java │ │ ├── SetUpActivity.java │ │ ├── configuration/ │ │ │ └── ConfigurationSettings.java │ │ ├── modules/ │ │ │ ├── BirthdayModule.java │ │ │ ├── CalendarModule.java │ │ │ ├── ChoresModule.java │ │ │ ├── CountdownModule.java │ │ │ ├── DayModule.java │ │ │ ├── ForecastModule.java │ │ │ ├── MoodModule.java │ │ │ ├── NewsModule.java │ │ │ ├── TimeModule.java │ │ │ ├── TrainScheduleModule.java │ │ │ ├── XKCDModule.java │ │ │ └── YahooFinanceModule.java │ │ ├── receiver/ │ │ │ └── AlarmReceiver.java │ │ ├── requests/ │ │ │ ├── ForecastRequest.java │ │ │ ├── ForecastResponse.java │ │ │ ├── OpenWeatherRequest.java │ │ │ ├── OpenWeatherResponse.java │ │ │ ├── XKCDRequest.java │ │ │ ├── XKCDResponse.java │ │ │ ├── YahooFinanceRequest.java │ │ │ └── YahooStockResponse.java │ │ └── utils/ │ │ └── WeekUtil.java │ └── res/ │ ├── drawable/ │ │ ├── apptheme_btn_check_holo_dark.xml │ │ └── apptheme_btn_radio_holo_dark.xml │ ├── layout/ │ │ ├── activity_configuration.xml │ │ ├── activity_mirror.xml │ │ └── clock.xml │ ├── layout-v17/ │ │ └── clock.xml │ ├── values/ │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-sw600dp/ │ │ ├── dimens.xml │ │ └── strings.xml │ └── values-v21/ │ └── styles.xml ├── build.gradle ├── design/ │ ├── HomeMirror.sketch │ └── install_assets.sh ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle
SYMBOL INDEX (148 symbols across 27 files)
FILE: app/src/androidTest/java/com/morristaedt/mirror/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: app/src/main/java/com/morristaedt/mirror/MirrorActivity.java
class MirrorActivity (line 37) | public class MirrorActivity extends ActionBarActivity {
method onNewXKCDToday (line 59) | @Override
method onNewStockPrice (line 71) | @Override
method onWeatherToday (line 83) | @Override
method onShouldBike (line 91) | @Override
method onNewNews (line 103) | @Override
method onShouldGivePositiveAffirmation (line 116) | @Override
method onCalendarUpdate (line 129) | @Override
method onCountdownUpdate (line 143) | @Override
method onCreate (line 155) | @Override
method onPause (line 211) | @Override
method onNewIntent (line 220) | @Override
method colorTextViews (line 226) | private void colorTextViews(ViewGroup mview){
method setViewState (line 237) | private void setViewState() {
method onBackPressed (line 304) | @Override
FILE: app/src/main/java/com/morristaedt/mirror/MirrorApplication.java
class MirrorApplication (line 13) | public class MirrorApplication extends Application {
method onCreate (line 15) | @Override
FILE: app/src/main/java/com/morristaedt/mirror/SetUpActivity.java
class SetUpActivity (line 27) | public class SetUpActivity extends Activity {
method onCreate (line 69) | @Override
method onDestroy (line 233) | @Override
method setUpLocationMonitoring (line 241) | private void setUpLocationMonitoring() {
method saveFields (line 290) | private void saveFields() {
FILE: app/src/main/java/com/morristaedt/mirror/configuration/ConfigurationSettings.java
class ConfigurationSettings (line 17) | public class ConfigurationSettings {
method ConfigurationSettings (line 62) | public ConfigurationSettings(Context context) {
method readPrefs (line 67) | private void readPrefs() {
method setIsCelsius (line 85) | public void setIsCelsius(boolean isCelsius) {
method setTextColorRed (line 91) | public void setTextColorRed(int red){
method setTextColorGreen (line 95) | public void setTextColorGreen(int green){
method setTextColorBlue (line 99) | public void setTextColorBlue(int blue){
method setTextColor (line 103) | public void setTextColor(int color){
method setShowBikingHint (line 110) | public void setShowBikingHint(boolean show) {
method setShowMoodDetection (line 117) | public void setShowMoodDetection(boolean show) {
method setShowNextCalendarEvent (line 124) | public void setShowNextCalendarEvent(boolean show) {
method setShowNewsHeadline (line 131) | public void setShowNewsHeadline(boolean show) {
method setXKCDPreference (line 138) | public void setXKCDPreference(boolean showXKCD, boolean invertXKCDColo...
method setLatLon (line 147) | public void setLatLon(String latitude, String longitude) {
method setStockTickerSymbol (line 157) | public void setStockTickerSymbol(String tickerSymbol) {
method setShowCountdown (line 165) | public void setShowCountdown(boolean showCountdown){
method setCountdownTime (line 172) | public void setCountdownTime(int days, int hours, int mins, int secs){
method getIsCelsius (line 180) | public boolean getIsCelsius() {
method getForecastUnits (line 184) | public String getForecastUnits() {
method getTextColor (line 188) | public int getTextColor() {
method showBikingHint (line 192) | public boolean showBikingHint() {
method showMoodDetection (line 196) | public boolean showMoodDetection() {
method showNextCalendarEvent (line 200) | public boolean showNextCalendarEvent() {
method showNewsHeadline (line 204) | public boolean showNewsHeadline() {
method showXKCD (line 208) | public boolean showXKCD() {
method invertXKCD (line 212) | public boolean invertXKCD() {
method showCountdown (line 216) | public boolean showCountdown(){
method getCountdownEnd (line 220) | public Date getCountdownEnd(){
method getLatitude (line 224) | public String getLatitude() {
method getLongitude (line 228) | public String getLongitude() {
method showStock (line 232) | public boolean showStock() {
method getStockTickerSymbol (line 236) | public String getStockTickerSymbol() {
method isDebugBuild (line 240) | public static boolean isDebugBuild() {
method isDemoMode (line 249) | public static boolean isDemoMode() {
FILE: app/src/main/java/com/morristaedt/mirror/modules/BirthdayModule.java
class BirthdayModule (line 13) | public class BirthdayModule {
method getBirthday (line 23) | public static String getBirthday() {
FILE: app/src/main/java/com/morristaedt/mirror/modules/CalendarModule.java
class CalendarModule (line 20) | public class CalendarModule {
type CalendarListener (line 21) | public interface CalendarListener {
method onCalendarUpdate (line 22) | void onCalendarUpdate(String title, String details);
method getCalendarEvents (line 25) | public static void getCalendarEvents(final Context context, final Cale...
FILE: app/src/main/java/com/morristaedt/mirror/modules/ChoresModule.java
class ChoresModule (line 10) | public class ChoresModule {
method waterPlantsToday (line 12) | public static boolean waterPlantsToday() {
method makeGroceryListToday (line 22) | public static boolean makeGroceryListToday() {
FILE: app/src/main/java/com/morristaedt/mirror/modules/CountdownModule.java
class CountdownModule (line 9) | public class CountdownModule {
type CountdownListener (line 11) | public interface CountdownListener {
method onCountdownUpdate (line 12) | void onCountdownUpdate(String timeLeft);
method getTimeRemaining (line 17) | public static void getTimeRemaining(final Date countdownEnd, final Cou...
method formatTime (line 32) | private static String formatTime(long time) {
FILE: app/src/main/java/com/morristaedt/mirror/modules/DayModule.java
class DayModule (line 13) | public class DayModule {
method getDay (line 15) | public static Spanned getDay() {
method getDayOfMonthSuffix (line 22) | private static String getDayOfMonthSuffix(final int n) {
FILE: app/src/main/java/com/morristaedt/mirror/modules/ForecastModule.java
class ForecastModule (line 24) | public class ForecastModule {
type ForecastListener (line 26) | public interface ForecastListener {
method onWeatherToday (line 27) | void onWeatherToday(String weatherToday);
method onShouldBike (line 29) | void onShouldBike(boolean showToday, boolean shouldBike);
method getForecastIOHourlyForecast (line 39) | public static void getForecastIOHourlyForecast(final String apiKey, fi...
method getOpenWeatherForecast (line 108) | public static void getOpenWeatherForecast(final String apiKey, final S...
method getOpenWeatherUnits (line 140) | @NonNull
FILE: app/src/main/java/com/morristaedt/mirror/modules/MoodModule.java
class MoodModule (line 20) | public class MoodModule {
type MoodListener (line 27) | public interface MoodListener {
method onShouldGivePositiveAffirmation (line 28) | void onShouldGivePositiveAffirmation(String affirmation);
method MoodModule (line 31) | public MoodModule(WeakReference<Context> contextWeakReference) {
method getCurrentMood (line 35) | public void getCurrentMood(MoodListener moodListener) {
method release (line 40) | public void release() {
method createCameraSource (line 52) | private void createCameraSource() {
method getFeedbackForSmileProbability (line 103) | private String getFeedbackForSmileProbability(float isSmilingProbabili...
FILE: app/src/main/java/com/morristaedt/mirror/modules/NewsModule.java
class NewsModule (line 13) | public class NewsModule {
type NewsListener (line 14) | public interface NewsListener {
method onNewNews (line 15) | void onNewNews(String headline);
method getNewsHeadline (line 18) | public static void getNewsHeadline(final NewsListener newsListener) {
FILE: app/src/main/java/com/morristaedt/mirror/modules/TimeModule.java
class TimeModule (line 13) | public class TimeModule {
method getTimeOfDayWelcome (line 15) | public static String getTimeOfDayWelcome(@NonNull Resources resources) {
FILE: app/src/main/java/com/morristaedt/mirror/modules/TrainScheduleModule.java
class TrainScheduleModule (line 8) | public class TrainScheduleModule {
method waitingSecondsForNextArrivalWithBufferSeconds (line 10) | public int waitingSecondsForNextArrivalWithBufferSeconds(int bufferSec...
method earliestArrivalAfterNowWithBufferSeconds (line 17) | public int earliestArrivalAfterNowWithBufferSeconds(int bufferSeconds) {
method earliestArrivalAfterDaySeconds (line 22) | public int earliestArrivalAfterDaySeconds (int afterDaySecs) {
method nowDaySeconds (line 35) | public int nowDaySeconds() {
method stringToDaySeconds (line 50) | public int stringToDaySeconds(String daySecsString) {
method nowSchedule (line 62) | public List<Integer> nowSchedule() {
FILE: app/src/main/java/com/morristaedt/mirror/modules/XKCDModule.java
class XKCDModule (line 21) | public class XKCDModule {
type XKCDListener (line 23) | public interface XKCDListener {
method onNewXKCDToday (line 24) | void onNewXKCDToday(String url);
method getXKCDForToday (line 32) | public static void getXKCDForToday(final XKCDListener listener) {
FILE: app/src/main/java/com/morristaedt/mirror/modules/YahooFinanceModule.java
class YahooFinanceModule (line 19) | public class YahooFinanceModule {
type StockListener (line 21) | public interface StockListener {
method onNewStockPrice (line 22) | void onNewStockPrice(YahooStockResponse.YahooQuoteResponse quoteResp...
method getStockForToday (line 30) | public static void getStockForToday(final String stockName, final Stoc...
FILE: app/src/main/java/com/morristaedt/mirror/receiver/AlarmReceiver.java
class AlarmReceiver (line 16) | public class AlarmReceiver extends BroadcastReceiver {
method startMirrorUpdates (line 23) | public static void startMirrorUpdates(Context context) {
method stopMirrorUpdates (line 32) | public static void stopMirrorUpdates(Context context) {
method onReceive (line 41) | @Override
FILE: app/src/main/java/com/morristaedt/mirror/requests/ForecastRequest.java
type ForecastRequest (line 10) | public interface ForecastRequest {
method getHourlyForecast (line 15) | @GET("/forecast/{apikey}/{lat},{lon}")
FILE: app/src/main/java/com/morristaedt/mirror/requests/ForecastResponse.java
class ForecastResponse (line 9) | public class ForecastResponse {
class ForecastCurrently (line 17) | public class ForecastCurrently {
method getDisplayTemperature (line 21) | public String getDisplayTemperature() {
class ForecastHourly (line 26) | public class ForecastHourly {
class Hour (line 31) | public class Hour {
method getCalendar (line 38) | public Calendar getCalendar() {
FILE: app/src/main/java/com/morristaedt/mirror/requests/OpenWeatherRequest.java
type OpenWeatherRequest (line 8) | public interface OpenWeatherRequest {
method getCurrentForecast (line 13) | @GET("/data/2.5/weather")
FILE: app/src/main/java/com/morristaedt/mirror/requests/OpenWeatherResponse.java
class OpenWeatherResponse (line 9) | public class OpenWeatherResponse {
method getWeatherDescription (line 14) | public String getWeatherDescription() {
class Weather (line 21) | public class Weather {
method getDescription (line 24) | public String getDescription() {
method toString (line 28) | @Override
class Main (line 34) | public class Main {
method getDisplayTemperature (line 37) | public String getDisplayTemperature() {
FILE: app/src/main/java/com/morristaedt/mirror/requests/XKCDRequest.java
type XKCDRequest (line 8) | public interface XKCDRequest {
method getLatestXKCD (line 10) | @GET("/info.0.json")
FILE: app/src/main/java/com/morristaedt/mirror/requests/XKCDResponse.java
class XKCDResponse (line 6) | public class XKCDResponse {
FILE: app/src/main/java/com/morristaedt/mirror/requests/YahooFinanceRequest.java
type YahooFinanceRequest (line 9) | public interface YahooFinanceRequest {
method getStockData (line 11) | @GET("/yql")
FILE: app/src/main/java/com/morristaedt/mirror/requests/YahooStockResponse.java
class YahooStockResponse (line 11) | public class YahooStockResponse {
class YahooQueryResponse (line 15) | private class YahooQueryResponse {
class YahooResultsResponse (line 19) | private class YahooResultsResponse {
class YahooQuoteResponse (line 23) | public class YahooQuoteResponse {
method getPercentageChange (line 28) | public BigDecimal getPercentageChange() {
method getQuoteResponse (line 39) | public YahooQuoteResponse getQuoteResponse() {
FILE: app/src/main/java/com/morristaedt/mirror/utils/WeekUtil.java
class WeekUtil (line 8) | public class WeekUtil {
method isWeekday (line 10) | public static boolean isWeekday() {
method afterFive (line 15) | public static boolean afterFive() {
method isWeekdayBeforeFive (line 20) | public static boolean isWeekdayBeforeFive() {
method isWeekdayAfterFive (line 24) | public static boolean isWeekdayAfterFive() {
Condensed preview — 55 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (158K chars).
[
{
"path": ".gitignore",
"chars": 438,
"preview": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbi"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 3983,
"preview": "# HomeMirror\nAndroid application powering the mirror in my house\n\n<img src=\"https://raw.githubusercontent.com/HannahMitt"
},
{
"path": "app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "app/build.gradle",
"chars": 1861,
"preview": "buildscript {\n repositories {\n maven { url 'https://maven.fabric.io/public' }\n }\n\n dependencies {\n "
},
{
"path": "app/proguard-rules.pro",
"chars": 668,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "app/src/androidTest/java/com/morristaedt/mirror/ApplicationTest.java",
"chars": 353,
"preview": "package com.morristaedt.mirror;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a hre"
},
{
"path": "app/src/main/AndroidManifest.xml",
"chars": 2003,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "app/src/main/java/com/morristaedt/mirror/MirrorActivity.java",
"chars": 12498,
"preview": "package com.morristaedt.mirror;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.graphics."
},
{
"path": "app/src/main/java/com/morristaedt/mirror/MirrorApplication.java",
"chars": 505,
"preview": "package com.morristaedt.mirror;\n\nimport android.app.Application;\n\nimport com.crashlytics.android.Crashlytics;\nimport com"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/SetUpActivity.java",
"chars": 13282,
"preview": "package com.morristaedt.mirror;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.content.Int"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/configuration/ConfigurationSettings.java",
"chars": 7877,
"preview": "package com.morristaedt.mirror.configuration;\n\nimport android.content.Context;\nimport android.content.SharedPreferences;"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/BirthdayModule.java",
"chars": 820,
"preview": "package com.morristaedt.mirror.modules;\n\nimport com.morristaedt.mirror.configuration.ConfigurationSettings;\n\nimport java"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/CalendarModule.java",
"chars": 3444,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.content.ContentResolver;\nimport android.content.Context;\nimport "
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/ChoresModule.java",
"chars": 1036,
"preview": "package com.morristaedt.mirror.modules;\n\nimport com.morristaedt.mirror.configuration.ConfigurationSettings;\n\nimport java"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/CountdownModule.java",
"chars": 1578,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.app.Activity;\n\nimport java.util.Date;\nimport java.util.Timer;\nim"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/DayModule.java",
"chars": 1023,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.text.Html;\nimport android.text.Spanned;\n\nimport java.text.Simple"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/ForecastModule.java",
"chars": 5714,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.os.AsyncTask;\nimport android.support.annotation.NonNull;\nimport "
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/MoodModule.java",
"chars": 4526,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.content.Context;\nimport android.content.res.Resources;\nimport an"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/NewsModule.java",
"chars": 1665,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.os.AsyncTask;\nimport android.util.Log;\n\nimport org.mcsoxford.rss"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/TimeModule.java",
"chars": 950,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.content.res.Resources;\nimport android.support.annotation.NonNull"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/TrainScheduleModule.java",
"chars": 12569,
"preview": "package com.morristaedt.mirror.modules;\n\nimport java.util.List;\n\n/**\n * Created by asm on 8/23/15.\n */\npublic class Trai"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/XKCDModule.java",
"chars": 2293,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.os.AsyncTask;\nimport android.support.annotation.NonNull;\nimport "
},
{
"path": "app/src/main/java/com/morristaedt/mirror/modules/YahooFinanceModule.java",
"chars": 2476,
"preview": "package com.morristaedt.mirror.modules;\n\nimport android.os.AsyncTask;\nimport android.support.annotation.Nullable;\nimport"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/receiver/AlarmReceiver.java",
"chars": 1986,
"preview": "package com.morristaedt.mirror.receiver;\n\nimport android.app.AlarmManager;\nimport android.app.PendingIntent;\nimport andr"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/ForecastRequest.java",
"chars": 564,
"preview": "package com.morristaedt.mirror.requests;\n\nimport retrofit.http.GET;\nimport retrofit.http.Path;\nimport retrofit.http.Quer"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/ForecastResponse.java",
"chars": 1037,
"preview": "package com.morristaedt.mirror.requests;\n\nimport java.util.ArrayList;\nimport java.util.Calendar;\n\n/**\n * Created by Hann"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/OpenWeatherRequest.java",
"chars": 614,
"preview": "package com.morristaedt.mirror.requests;\n\nimport retrofit.http.GET;\nimport retrofit.http.Query;\n\n/**\n */\npublic interfac"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/OpenWeatherResponse.java",
"chars": 827,
"preview": "package com.morristaedt.mirror.requests;\n\nimport android.text.TextUtils;\n\nimport java.util.ArrayList;\n\n/**\n */\npublic cl"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/XKCDRequest.java",
"chars": 207,
"preview": "package com.morristaedt.mirror.requests;\n\nimport retrofit.http.GET;\n\n/**\n * Created by HannahMitt on 8/22/15.\n */\npublic"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/XKCDResponse.java",
"chars": 205,
"preview": "package com.morristaedt.mirror.requests;\n\n/**\n * Created by HannahMitt on 8/22/15.\n */\npublic class XKCDResponse {\n\n "
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/YahooFinanceRequest.java",
"chars": 322,
"preview": "package com.morristaedt.mirror.requests;\n\nimport retrofit.http.GET;\nimport retrofit.http.Query;\n\n/**\n * Created by Hanna"
},
{
"path": "app/src/main/java/com/morristaedt/mirror/requests/YahooStockResponse.java",
"chars": 1165,
"preview": "package com.morristaedt.mirror.requests;\n\nimport android.text.TextUtils;\n\nimport java.math.BigDecimal;\nimport java.math."
},
{
"path": "app/src/main/java/com/morristaedt/mirror/utils/WeekUtil.java",
"chars": 691,
"preview": "package com.morristaedt.mirror.utils;\n\nimport java.util.Calendar;\n\n/**\n * Created by HannahMitt on 8/23/15.\n */\npublic c"
},
{
"path": "app/src/main/res/drawable/apptheme_btn_check_holo_dark.xml",
"chars": 3141,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2011 The Android Open Source Project\n\n Licensed under the "
},
{
"path": "app/src/main/res/drawable/apptheme_btn_radio_holo_dark.xml",
"chars": 3092,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2011 The Android Open Source Project\n\n Licensed under the "
},
{
"path": "app/src/main/res/layout/activity_configuration.xml",
"chars": 17087,
"preview": "<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tools"
},
{
"path": "app/src/main/res/layout/activity_mirror.xml",
"chars": 5570,
"preview": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/too"
},
{
"path": "app/src/main/res/layout/clock.xml",
"chars": 375,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<DigitalClock xmlns:android=\"http://schemas.android.com/apk/res/android\"\n styl"
},
{
"path": "app/src/main/res/layout-v17/clock.xml",
"chars": 372,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<TextClock xmlns:android=\"http://schemas.android.com/apk/res/android\"\n style=\""
},
{
"path": "app/src/main/res/values/dimens.xml",
"chars": 582,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "app/src/main/res/values/strings.xml",
"chars": 2767,
"preview": "<resources>\n <string name=\"app_name\">HomeMirror</string>\n\n <string name=\"default_mirror_mirror\">Mirror, mirror on "
},
{
"path": "app/src/main/res/values/styles.xml",
"chars": 2413,
"preview": "<resources xmlns:tools=\"http://schemas.android.com/tools\">\n\n <!-- Base application theme. -->\n <style name=\"AppThe"
},
{
"path": "app/src/main/res/values-sw600dp/dimens.xml",
"chars": 582,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "app/src/main/res/values-sw600dp/strings.xml",
"chars": 211,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <!-- Chores module -->\n <string name=\"water_plants\">Water Pla"
},
{
"path": "app/src/main/res/values-v21/styles.xml",
"chars": 603,
"preview": "<resources xmlns:tools=\"http://schemas.android.com/tools\">\n\n <!-- Base application theme. Removes unneeded compat sty"
},
{
"path": "build.gradle",
"chars": 436,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "design/install_assets.sh",
"chars": 432,
"preview": "#!/bin/sh\n\ncd assets\nfind . -type f -path '*_10.png' | while read l; do F=`echo $l | sed -e \"s/_10//\"`; cp $l ../../app/"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Sat Aug 22 21:32:22 EDT 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 5080,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2404,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
},
{
"path": "settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
}
]
// ... and 2 more files (download for full content)
About this extraction
This page contains the full source code of the HannahMitt/HomeMirror GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 55 files (143.4 KB), approximately 34.9k tokens, and a symbol index with 148 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.