Browse Source

Initial open source release

merge-requests/1/head
Trevor Slocum 6 years ago
commit
43d5d6d9e8
869 changed files with 24998 additions and 0 deletions
  1. +42
    -0
      .gitignore
  2. +1
    -0
      MeditationAssistant/.gitignore
  3. +1
    -0
      MeditationAssistant/google-services.json
  4. +4
    -0
      MeditationAssistant/lint.xml
  5. +216
    -0
      MeditationAssistant/proguard-project.txt
  6. +187
    -0
      MeditationAssistant/src/main/AndroidManifest.xml
  7. +157
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/AboutActivity.java
  8. +304
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/CalendarFragment.java
  9. +421
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/CompleteActivity.java
  10. +123
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/Crypt.java
  11. +163
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/DailyNotification.java
  12. +374
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/DatabaseHandler.java
  13. +27
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/FadeOutAnimationListener.java
  14. +503
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/FileUtils.java
  15. +47
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/JavaScriptInterface.java
  16. +5
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/JavascriptCallback.java
  17. +309
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/ListPreferenceSound.java
  18. +2546
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MainActivity.java
  19. +417
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MediNET.java
  20. +566
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MediNETActivity.java
  21. +479
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MediNETTask.java
  22. +1497
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationAssistant.java
  23. +87
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationProvider.java
  24. +5
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationProvider1.java
  25. +5
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationProvider2.java
  26. +5
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationProvider3.java
  27. +76
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationService.java
  28. +30
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationSession.java
  29. +45
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationSounds.java
  30. +17
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MonthAdapter.java
  31. +303
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MonthAdapterMA.java
  32. +94
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/NumToWord.java
  33. +2642
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/NumberPicker.java
  34. +42
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/Preset.java
  35. +811
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/ProgressActivity.java
  36. +495
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/Scroller.java
  37. +84
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/SessionAdapter.java
  38. +42
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/SessionSQL.java
  39. +273
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/SessionsFragment.java
  40. +745
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/SettingsActivity.java
  41. +149
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/StatsFragment.java
  42. +551
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/TimePicker.java
  43. +157
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/TimePickerDialog.java
  44. +114
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/TimePreference.java
  45. +36
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/WakeLocker.java
  46. +55
    -0
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/WearListenerService.java
  47. +11
    -0
      MeditationAssistant/src/main/res/anim/fadeinma.xml
  48. +11
    -0
      MeditationAssistant/src/main/res/anim/fadeoutma.xml
  49. +73
    -0
      MeditationAssistant/src/main/res/anim/spin.xml
  50. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/ab_bottom_solid_buddhism.9.png
  51. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/ab_solid_buddhism.9.png
  52. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/ab_stacked_solid_buddhism.9.png
  53. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/ab_texture_tile_buddhism.png
  54. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/ab_transparent_buddhism.9.png
  55. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/btn_cab_done_default_buddhism.9.png
  56. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/btn_cab_done_focused_buddhism.9.png
  57. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/btn_cab_done_pressed_buddhism.9.png
  58. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_off_disabled_focused_holo_light.png
  59. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_off_disabled_holo_light.png
  60. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_off_focused_holo_light.png
  61. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_off_holo_light.png
  62. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_off_pressed_holo_light.png
  63. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_on_disabled_focused_holo_light.png
  64. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_on_disabled_holo_light.png
  65. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_on_focused_holo_light.png
  66. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_on_holo_light.png
  67. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_check_on_pressed_holo_light.png
  68. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_default_disabled_focused_holo_light.9.png
  69. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_default_disabled_holo_light.9.png
  70. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_default_focused_holo_light.9.png
  71. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_default_normal_holo_light.9.png
  72. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_default_pressed_holo_light.9.png
  73. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_off_disabled_focused_holo_light.png
  74. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_off_disabled_holo_light.png
  75. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_off_focused_holo_light.png
  76. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_off_holo_light.png
  77. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_off_pressed_holo_light.png
  78. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_on_disabled_focused_holo_light.png
  79. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_on_disabled_holo_light.png
  80. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_on_focused_holo_light.png
  81. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_on_holo_light.png
  82. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_radio_on_pressed_holo_light.png
  83. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_off_disabled_focused_holo_light.9.png
  84. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_off_disabled_holo_light.9.png
  85. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_off_focused_holo_light.9.png
  86. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_off_normal_holo_light.9.png
  87. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_off_pressed_holo_light.9.png
  88. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_on_disabled_focused_holo_light.9.png
  89. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_on_disabled_holo_light.9.png
  90. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_on_focused_holo_light.9.png
  91. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_on_normal_holo_light.9.png
  92. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_btn_toggle_on_pressed_holo_light.9.png
  93. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_fastscroll_thumb_default_holo.png
  94. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_fastscroll_thumb_pressed_holo.png
  95. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_ic_navigation_drawer.png
  96. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_list_activated_holo.9.png
  97. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_list_focused_holo.9.png
  98. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_list_longpressed_holo.9.png
  99. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_list_pressed_holo_light.9.png
  100. BIN
      MeditationAssistant/src/main/res/drawable-hdpi/buddhism_list_selector_disabled_holo_light.9.png

+ 42
- 0
.gitignore View File

@ -0,0 +1,42 @@
build/
captures/
*/captures/
# built application files
*.apk
*.ap_
*.bar
*.wrn
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Android Studio
.idea/
.gradle
/*/local.properties
/*/out
/*/*/build
*/build
/*/*/production
*.iml
*.iws
*.ipr
*~
*.swp

+ 1
- 0
MeditationAssistant/.gitignore View File

@ -0,0 +1 @@
/build

+ 1
- 0
MeditationAssistant/google-services.json View File

@ -0,0 +1 @@
{"project_info":{"project_id":"api-project-163346957857","project_number":"163346957857","name":"Meditation Assistant Free"},"client":[{"client_info":{"client_id":"android:sh.ftp.rocketninelabs.meditationassistant","client_type":1,"android_client_info":{"package_name":"sh.ftp.rocketninelabs.meditationassistant"}},"oauth_client":[{"client_id":"163346957857.apps.googleusercontent.com","client_type":1,"android_info":{"package_name":"sh.ftp.rocketninelabs.meditationassistant","certificate_hash":"f5f29854d4bac9d7ccf5d98a8a4b88f3beca47ff"}}],"services":{"analytics_service":{"status":2,"analytics_property":{"tracking_id":"UA-71983-51"}},"cloud_messaging_service":{"status":1,"apns_config":[]},"appinvite_service":{"status":2,"other_platform_oauth_client":[]},"google_signin_service":{"status":2},"ads_service":{"status":1}}}],"ARTIFACT_VERSION":"1"}

+ 4
- 0
MeditationAssistant/lint.xml View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<ignore path="build/**" />
</lint>

+ 216
- 0
MeditationAssistant/proguard-project.txt View File

@ -0,0 +1,216 @@
-verbose
# Begin optimizeproguard-optimize.txt:
-optimizations !code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 25
-allowaccessmodification
-dontpreverify
-dontwarn android.webkit.**
-keep class com.google.android.gms.analytics.**
-keep class com.google.analytics.tracking.**
-dontwarn com.google.android.gms.analytics.**
-dontwarn com.google.analytics.tracking.**
-dontwarn com.google.android.gms.**
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keep class com.actionbarsherlock.** {*;}
-keep class org.holoeverywhere.** {*;}
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
<init>(android.app.Activity, int);
}
# Keep line numbers to alleviate debugging stack traces
# -renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
# End optimize
-keepattributes JavascriptInterface
-overloadaggressively
-allowaccessmodification
-keep public class sh.ftp.rocketninelabs.meditationassistant.JavascriptCallback
-keep public class * implements sh.ftp.rocketninelabs.meditationassistant.JavascriptCallback
-keepclassmembers class * implements sh.ftp.rocketninelabs.meditationassistant.JavascriptCallback {
<methods>;
}
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keep public class com.crittercism.**
-keepclassmembers public class com.crittercism.* { *; }
# HoloEverywhere
-keep,allowshrinking,allowoptimization public class * extends ListView
-keep,allowoptimization class org.holoeverywhere.** {
public *;
protected *;
}
-keepclasseswithmembernames class org.holoeverywhere.internal.** {
public *;
protected *;
}
-keepclasseswithmembernames class org.holoeverywhere.internal.AlertController
-keep public class org.holoeverywhere.internal.AlertController.RecycleListView { *; }
-keep,allowshrinking,allowoptimization class org.holoeverywhere.** { *; }
-keep,allowshrinking,allowoptimization interface org.holoeverywhere.** { *; }
-keep,allowshrinking,allowoptimization public class * extends android.app.Application
-keep,allowshrinking,allowoptimization public class * extends android.app.Service
-keep,allowshrinking,allowoptimization public class * extends android.content.BroadcastReceiver
-keep,allowshrinking,allowoptimization public class * extends android.content.ContentProvider
-keep,allowshrinking,allowoptimization public class * extends android.app.backup.BackupAgentHelper
-keep,allowshrinking,allowoptimization public class * extends android.preference.Preference
-keep,allowshrinking,allowoptimization public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep,allowshrinking,allowoptimization class * { <methods>; }
-keepclasseswithmembernames,allowshrinking class * {
native <methods>;
}
-keepclasseswithmembers,allowshrinking class * {
public <init>(android.content.Context,android.util.AttributeSet);
public <init>(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembers class * {
public <init>(android.content.Context,android.util.AttributeSet);
public <init>(android.content.Context,android.util.AttributeSet,int);
}
# Google API Client
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
# Needed by google-http-client-android when linking against an older platform version
-dontwarn com.google.api.client.extensions.android.**
# Needed by google-api-client-android when linking against an older platform version
-dontwarn com.google.api.client.googleapis.extensions.android.**
# End Google API Client

+ 187
- 0
MeditationAssistant/src/main/AndroidManifest.xml View File

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="sh.ftp.rocketninelabs.meditationassistant"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:name="sh.ftp.rocketninelabs.meditationassistant.MeditationAssistant"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/appName"
android:theme="@style/MeditationDarkTheme">
<!-- Comment both when releasing full -->
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIqq_HCa56eFzfQpNSwYUIIytAyO6bh4fFUFUcYA"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<!-- DON'T COMMENT BELOW -->
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/analytics"/>
<!-- Services -->
<service android:name="sh.ftp.rocketninelabs.meditationassistant.MeditationService"></service>
<!-- Receivers -->
<receiver
android:name="sh.ftp.rocketninelabs.meditationassistant.DailyNotification"
android:exported="true">
<intent-filter>
<action android:name="sh.ftp.rocketninelabs.meditationassistant.DAILY_NOTIFICATION"></action>
<action android:name="sh.ftp.rocketninelabs.meditationassistant.DAILY_NOTIFICATION_UPDATED"></action>
<action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<data
android:path="sh.ftp.rocketninelabs.meditationassistant"
android:scheme="package"/>
</intent-filter>
</receiver>
<!-- Register AnalyticsReceiver and AnalyticsService to support background dispatching on non-Google Play devices -->
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true"
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
<!-- Register Wear data layer service -->
<service android:name=".WearListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER"/>
</intent-filter>
</service>
<!-- Widgets -->
<!--
<receiver
android:name="sh.ftp.rocketninelabs.meditationassistant.MeditationProvider1"
android:label="@string/widget1x1" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_1" />
</receiver>
<receiver
android:name="sh.ftp.rocketninelabs.meditationassistant.MeditationProvider2"
android:label="@string/widget2x1" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_2" />
</receiver>
<receiver
android:name="sh.ftp.rocketninelabs.meditationassistant.MeditationProvider3"
android:label="@string/widget3x1" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_3" />
</receiver>
-->
<!-- Activities -->
<activity
android:name="sh.ftp.rocketninelabs.meditationassistant.MainActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|orientation"
android:label="@string/appNameShort"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="sh.ftp.rocketninelabs.meditationassistant.ALARM"></action>
</intent-filter>
</activity>
<activity
android:name="sh.ftp.rocketninelabs.meditationassistant.SettingsActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|orientation"
android:label="@string/settings"
android:launchMode="singleTop"
android:parentActivityName="sh.ftp.rocketninelabs.meditationassistant.MainActivity"
tools:ignore="UnusedAttribute">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sh.ftp.rocketninelabs.meditationassistant.MainActivity"/>
</activity>
<activity
android:name="sh.ftp.rocketninelabs.meditationassistant.MediNETActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|orientation"
android:label=""
android:launchMode="singleTop">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sh.ftp.rocketninelabs.meditationassistant.MainActivity"/>
</activity>
<activity
android:name="sh.ftp.rocketninelabs.meditationassistant.CompleteActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|orientation"
android:label="@string/sessioncomplete">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sh.ftp.rocketninelabs.meditationassistant.MainActivity"/>
</activity>
<activity
android:name="sh.ftp.rocketninelabs.meditationassistant.AboutActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|orientation"
android:label="@string/about">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sh.ftp.rocketninelabs.meditationassistant.MainActivity"/>
</activity>
<activity
android:name="sh.ftp.rocketninelabs.meditationassistant.ProgressActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|orientation"
android:label="@string/progress">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sh.ftp.rocketninelabs.meditationassistant.MainActivity"/>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"/>
</application>
</manifest>

+ 157
- 0
MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/AboutActivity.java View File

@ -0,0 +1,157 @@
package sh.ftp.rocketninelabs.meditationassistant;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.appinvite.AppInviteInvitation;
public class AboutActivity extends Activity {
public String license = "";
private MeditationAssistant ma = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(getMeditationAssistant().getMATheme());
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_about);
TextView txtAboutAppName = (TextView) findViewById(R.id.txtAboutAppName);
TextView txtAboutAppVersion = (TextView) findViewById(R.id.txtAboutAppVersion);
if (getPackageName().equals(
"sh.ftp.rocketninelabs.meditationassistant")) {
txtAboutAppName.setText(getString(R.string.appName));
} else {
txtAboutAppName.setText(getString(R.string.appNameShort));
}
PackageInfo pInfo;
try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
txtAboutAppVersion.setText(String.format(getString(R.string.version), pInfo.versionName));
} catch (PackageManager.NameNotFoundException e) {
txtAboutAppVersion.setVisibility(View.GONE);
e.printStackTrace();
}
LinearLayout layAbout = (LinearLayout) findViewById(R.id.layAbout);
layAbout.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
ImageView charis = (ImageView) findViewById(R.id.charis);
charis.setVisibility(View.VISIBLE);
charis.startAnimation(AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.spin));
return true;
}
});
if (getMeditationAssistant().sendUsageReports()) {
getMeditationAssistant().getTracker(MeditationAssistant.TrackerName.APP_TRACKER);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.about, menu);
if (getMeditationAssistant().getIsBB() || !MeditationAssistant.getMarketName().equals("google")) {
MenuItem share = menu.findItem(R.id.action_share_app);
share.setVisible(false);
invalidateOptionsMenu();
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int i = item.getItemId();
if (i == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
} else if (i == R.id.action_share_app) {
Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.appNameShort))
.setMessage(getString(R.string.invitationBlurb))
.build();
startActivityForResult(intent, 1337);
} else if (i == R.id.action_rate) {
getMeditationAssistant().askToRateApp();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onStart() {
super.onStart();
if (getMeditationAssistant().sendUsageReports()) {
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
}
@Override
protected void onStop() {
super.onStop();
if (getMeditationAssistant().sendUsageReports()) {
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
}
public void sendMeEmail(View view) {
Log.d("MeditationAssistant", "Open about");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL,
new String[]{"tslocum@gmail.com"});
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(
getPackageName(), 0);
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.appNameShort) + " "
+ pInfo.versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.appNameShort));
}
intent.putExtra(android.content.Intent.EXTRA_TEXT, "");
startActivity(Intent.createChooser(intent, getString(R.string.sendEmail)));
}
public void openHowToMeditate(View view) {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://medinet.ftp.sh/howtomeditate")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
public void openTranslate(View view) {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://medinet.ftp.sh/translate")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
public MeditationAssistant getMeditationAssistant() {
if (ma == null) {
ma = (MeditationAssistant) this.getApplication();
}
return ma;
}
}

+ 304
- 0
MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/CalendarFragment.java View File

@ -0,0 +1,304 @@
package sh.ftp.rocketninelabs.meditationassistant;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TextView;
import java.util.Calendar;
import java.util.Locale;
public class CalendarFragment extends Fragment {
GridView gridCalendar = null;
TextView txtCurrentMonth = null;
TextView txtCurrentYear = null;
MonthAdapter monthadapter = null;
Calendar mCalendar = null;
ImageButton nextMonth = null;
private MeditationAssistant ma = null;
SharedPreferences.OnSharedPreferenceChangeListener sharedPrefslistener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (key.equals("sessionsupdate")) {
Log.d("MeditationAssistant", "Got sessions update, refreshing CalendarFragment");
refreshMonthDisplay();
}
}
};
public MeditationAssistant getMeditationAssistant() {
if (ma == null) {
ma = (MeditationAssistant) getActivity().getApplication();
}
return ma;
}
private MonthAdapter getMonthAdapter() {
final DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay()
.getMetrics(metrics);
updatecurrentDate();
return new MonthAdapter(getActivity(), mCalendar.get(Calendar.MONTH),
mCalendar.get(Calendar.YEAR), metrics, (ProgressActivity) getActivity(), getMeditationAssistant());
}
public void refreshMonthDisplay() {
gridCalendar.setAdapter(getMonthAdapter());
}
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getMeditationAssistant().getPrefs().registerOnSharedPreferenceChangeListener(sharedPrefslistener);
int color_primary = getResources().getColor(getMeditationAssistant().getMATextColor(true));
int color_primary_disabled = getResources().getColor(getMeditationAssistant().getMATextColor(false));
/* Getting resource not found errors here */
try {
color_primary = getResources().getColor(
getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant().getMATheme(),
new int[]{android.R.attr.textColorPrimary})
.getResourceId(0, 0)
);
color_primary_disabled = getResources()
.getColor(
getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant()
.getMATheme(),
new int[]{android.R.attr.textColorPrimaryDisableOnly}
)
.getResourceId(0, 0)
);
} catch (Exception e) {
Log.d("MeditationAssistant", "Unable to get color resources in CalendarFragment:");
e.printStackTrace();
}
txtCurrentMonth = new TextView(getActivity());
txtCurrentYear = new TextView(getActivity());
mCalendar = Calendar.getInstance();
txtCurrentMonth.setTextSize(22);
txtCurrentYear.setTextSize(12);
txtCurrentMonth.setTextColor(color_primary);
txtCurrentMonth
.setTextColor(color_primary_disabled);
txtCurrentMonth.setSingleLine(true);
txtCurrentMonth.setEllipsize(TextUtils.TruncateAt.END);
txtCurrentYear.setSingleLine(true);
txtCurrentYear.setEllipsize(TextUtils.TruncateAt.END);
gridCalendar = new GridView(getActivity());
gridCalendar.setNumColumns(7);
gridCalendar.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
gridCalendar.setVerticalSpacing(2);
gridCalendar.setHorizontalSpacing(2);
gridCalendar.setAdapter(getMonthAdapter());
}
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Context ctx = getActivity().getApplicationContext();
LinearLayout lcontainer = new LinearLayout(ctx);
lcontainer.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
lcontainer.setOrientation(LinearLayout.VERTICAL);
LinearLayout lmain = new LinearLayout(ctx);
lmain.setOrientation(LinearLayout.VERTICAL);
lmain.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
lmain.setWeightSum(0.5f);
LinearLayout lhoriz = new LinearLayout(ctx);
lhoriz.setOrientation(LinearLayout.HORIZONTAL);
lhoriz.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
lmain.addView(gridCalendar);
ImageButton prevMonth = new ImageButton(getActivity());
prevMonth.setImageDrawable(getResources().getDrawable(
getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant().getMATheme(),
new int[]{R.attr.actionIconPreviousItem})
.getResourceId(0, 0)
));
nextMonth = new ImageButton(getActivity());
nextMonth.setImageDrawable(getResources().getDrawable(
getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant().getMATheme(),
new int[]{R.attr.actionIconNextItem})
.getResourceId(0, 0)
));
/*TableLayout.LayoutParams monthbuttonslp = new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1f);*/
TableLayout.LayoutParams monthbuttonslp = new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f);
monthbuttonslp.setMargins(0, MeditationAssistant.dpToPixels(7, ctx), 0,
MeditationAssistant.dpToPixels(7, ctx));
prevMonth.setLayoutParams(monthbuttonslp);
nextMonth.setLayoutParams(monthbuttonslp);
prevMonth.setBackgroundColor(getActivity().getResources().getColor(
android.R.color.transparent));
nextMonth.setBackgroundColor(getActivity().getResources().getColor(
android.R.color.transparent));
prevMonth.setBackgroundResource(getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant().getMATheme(),
new int[]{android.R.attr.selectableItemBackground})
.getResourceId(0, 0));
nextMonth.setBackgroundResource(getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant().getMATheme(),
new int[]{android.R.attr.selectableItemBackground})
.getResourceId(0, 0));
prevMonth.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mCalendar.add(Calendar.MONTH, -1);
gridCalendar.setAdapter(getMonthAdapter());
updateMonthScroll();
}
});
nextMonth.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mCalendar.add(Calendar.MONTH, 1);
gridCalendar.setAdapter(getMonthAdapter());
updateMonthScroll();
}
});
LinearLayout ldate = new LinearLayout(ctx);
ldate.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams lp_horiz = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1f);
prevMonth.setLayoutParams(lp_horiz);
ldate.setLayoutParams(lp_horiz);
nextMonth.setLayoutParams(lp_horiz);
ldate.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);
txtCurrentMonth.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);
txtCurrentYear.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);
ldate.addView(txtCurrentMonth);
ldate.addView(txtCurrentYear);
lhoriz.setMinimumHeight(MeditationAssistant.dpToPixels(48, ctx));
lhoriz.addView(prevMonth);
lhoriz.addView(ldate);
lhoriz.addView(nextMonth);
LinearLayout lbottom = new LinearLayout(ctx);
lmain.setOrientation(LinearLayout.VERTICAL);
lbottom.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
lbottom.setWeightSum(0.5f);
lbottom.setMinimumHeight(MeditationAssistant.dpToPixels(48, ctx));
lbottom.addView(lhoriz);
lmain.setGravity(Gravity.BOTTOM);
View divBottom = new View(ctx);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,
MeditationAssistant.dpToPixels(1, ctx));
lp.setMargins(MeditationAssistant.dpToPixels(7, ctx), 0,
MeditationAssistant.dpToPixels(7, ctx), 0);
divBottom.setLayoutParams(lp);
divBottom.setPadding(7, 0, 7, 0);
divBottom.setBackgroundDrawable(getResources().getDrawable(
getMeditationAssistant()
.getTheme()
.obtainStyledAttributes(
getMeditationAssistant().getMATheme(),
new int[]{android.R.attr.listDividerAlertDialog})
.getResourceId(0, 0)
));
lcontainer.addView(lbottom);
lcontainer.addView(divBottom);
lcontainer.addView(lmain);
updateMonthScroll();
return lcontainer;
}
public void updatecurrentDate() {
txtCurrentMonth.setText(String.format(Locale.getDefault(), "%tB", mCalendar));
txtCurrentYear.setText(String.format(Locale.getDefault(), "%tY", mCalendar));
}
private void updateMonthScroll() {
Calendar nowCalendar = Calendar.getInstance();
if (mCalendar.get(Calendar.MONTH) == nowCalendar.get(Calendar.MONTH)
&& mCalendar.get(Calendar.YEAR) == nowCalendar
.get(Calendar.YEAR)) {
nextMonth.setClickable(false);
nextMonth.setVisibility(View.INVISIBLE);
} else {
nextMonth.setClickable(true);
nextMonth.setVisibility(View.VISIBLE);
}
}
@Override
public void onPause() {
getMeditationAssistant().getPrefs().unregisterOnSharedPreferenceChangeListener(sharedPrefslistener);
super.onPause();
}
@Override
public void onResume() {
getMeditationAssistant().getPrefs().registerOnSharedPreferenceChangeListener(sharedPrefslistener);
super.onResume();
}
}

+ 421
- 0
MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/CompleteActivity.java View File

@ -0,0 +1,421 @@
package sh.ftp.rocketninelabs.meditationassistant;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.GoogleAnalytics;
public class CompleteActivity extends Activity {
private AdView av = null;
private MediaPlayer mMediaPlayer;
private MeditationAssistant ma;
private Handler handler = new Handler();
private Runnable runnable = new Runnable() {
@Override
public void run() {
handler.removeCallbacks(this);
if (getMeditationAssistant().getMediNET().result.equals("posted")) {
getMeditationAssistant()
.shortToast(getString(R.string.sessionPosted));
finish();
} else if (getMeditationAssistant().getMediNET().result
.equals("alreadyposted")) {
getMeditationAssistant().longToast(getString(R.string.sessionAlreadyPosted));
} else if (getMeditationAssistant().getMediNET().status
.equals("failure")
&& getMeditationAssistant().getMediNET().result
.equals("corrupt")) {
getMeditationAssistant()
.longToast(
getString(R.string.sessionNotPosted));
} else {
handler.postDelayed(this, 2000);
}
}
};
private Runnable clearWakeLock = new Runnable() {
public void run() {
handler.removeCallbacks(clearWakeLock);
WakeLocker.release();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(getMeditationAssistant().getMATheme());
setContentView(R.layout.activity_complete);
getMeditationAssistant().hideNotification(); // Called twice because it seems to help
long timestamp = System.currentTimeMillis() / 1000;
if (getMeditationAssistant().getTimeStartMeditate() == 0
|| (timestamp - getMeditationAssistant().getTimeStartMeditate()) <= 0) {
// Reset timestamps for current session
getMeditationAssistant().setTimeStartMeditate(0);
getMeditationAssistant().setTimeToStopMeditate(0);
finish();
return;
}
setTheme(getMeditationAssistant().getMATheme());
/*if (getMeditationAssistant().getMATheme() != R.style.MADark) {
getWindow().setBackgroundDrawable(
getResources().getDrawable(
android.R.drawable.screen_background_light));
}*/
setContentView(R.layout.activity_complete);
getWindow().setWindowAnimations(0);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
);
Boolean manual = false;
if (getIntent().hasExtra("manual")) {
if (getIntent().getBooleanExtra("manual", false)) {
manual = true;
}
}
getMeditationAssistant().unsetNotificationControl();
getMeditationAssistant().hideNotification(); // Called twice because it seems to help
if (getPackageName().equals("sh.ftp.rocketninelabs.meditationassistant")) {
Log.d("MeditationAssistant", "Fetching ad");
av = (AdView) findViewById(R.id.adViewSessionComplete);
av.setVisibility(View.VISIBLE);
com.google.android.gms.ads.AdRequest adRequest = new com.google.android.gms.ads.AdRequest.Builder()
.addTestDevice(com.google.android.gms.ads.AdRequest.DEVICE_ID_EMULATOR)
.build();
av.loadAd(adRequest);
}
EditText editSessionMessage = (EditText) findViewById(R.id.editSessionMessage);
if (editSessionMessage.getText().toString().equals("")
&& getMeditationAssistant().getPrefs().getBoolean("pref_remembermessage", false)) {
editSessionMessage.setText(getMeditationAssistant().getPrefs().getString("lastmessage", ""));
}
editSessionMessage
.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
EditText editSessionMessage = (EditText) findViewById(R.id.editSessionMessage);
TextView editSessionMessageInfo = (TextView) findViewById(R.id.editSessionMessageInfo);
if (hasFocus) {
editSessionMessageInfo.setText(String
.valueOf(editSessionMessage.getText()
.length())
+ " / 160");
editSessionMessageInfo.setVisibility(View.VISIBLE);
} else {
editSessionMessageInfo.setVisibility(View.GONE);
}
}
});
editSessionMessage.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
TextView editSessionMessageInfo = (TextView) findViewById(R.id.editSessionMessageInfo);
editSessionMessageInfo.setText(String.valueOf(s.length())
+ " / 160");
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
});
if (getMeditationAssistant()
.getTimeStartMeditate() == 0) {
/* Getting null pointers on getTimeStartMeditate() */
Log.d("MeditationAssistant", "getTimeStartMeditate() was 0! Exiting AlarmReceiverActivity...");
finish();
return;
}
// Meditation Session
getMeditationAssistant().getMediNET().resetSession();
getMeditationAssistant().getMediNET().session.started = getMeditationAssistant()
.getTimeStartMeditate();
if (getMeditationAssistant().getTimerMode().equals("endat")) {
Log.d("MeditationAssistant", String.valueOf(Math.min(timestamp, getMeditationAssistant().getTimeToStopMeditate())) + " - "
+ String.valueOf(getMeditationAssistant().getTimeStartMeditate()) + " - " + String.valueOf(getMeditationAssistant().pausetime));
getMeditationAssistant().getMediNET().session.length = Math.min(timestamp, getMeditationAssistant().getTimeToStopMeditate())
- getMeditationAssistant().getTimeStartMeditate() - getMeditationAssistant().pausetime;
} else {
Log.d("MeditationAssistant", String.valueOf(timestamp) + " - "
+ String.valueOf(getMeditationAssistant().getTimeStartMeditate()) + " - " + String.valueOf(getMeditationAssistant().pausetime));
getMeditationAssistant().getMediNET().session.length = timestamp
- getMeditationAssistant().getTimeStartMeditate() - getMeditationAssistant().pausetime;
}
getMeditationAssistant().getMediNET().session.length += 7; // Add seven seconds to account for slow wake-ups
getMeditationAssistant().getMediNET().session.completed = timestamp;
// Reset timestamps for current session
getMeditationAssistant().setTimeStartMeditate(0);
getMeditationAssistant().setTimeToStopMeditate(0);
Log.d("MeditationAssistant",
"Session length: "
+ String.valueOf(getMeditationAssistant().getMediNET().session.length)
);
if (getMeditationAssistant().getMediNET().session.length > 0) {
TextView txtDuration = (TextView) findViewById(R.id.txtDuration);
txtDuration.setText(MediNET
.durationToTimerString(getMeditationAssistant()
.getMediNET().session.length, false));
String text_size = getMeditationAssistant().getPrefs().getString("pref_text_size", "normal");
if (text_size.equals("tiny")) {
txtDuration.setTextSize(85);
} else if (text_size.equals("small")) {
txtDuration.setTextSize(115);
} else if (text_size.equals("large")) {
txtDuration.setTextSize(175);
} else if (text_size.equals("extralarge")) {
txtDuration.setTextSize(200);
} else { // Normal
txtDuration.setTextSize(153);
}
if (!manual
&& !getMeditationAssistant().getPrefs().getString("pref_meditation_sound_finish", "")
.equals("none")) {
mMediaPlayer = null;
if (getMeditationAssistant().getPrefs().getString("pref_meditation_sound_finish", "").equals(
"custom")) {
String soundpath = getMeditationAssistant().getPrefs().getString(
"pref_meditation_sound_finish_custom", "");
if (!soundpath.equals("")) {
try {
mMediaPlayer = MediaPlayer.create(this,
Uri.parse(soundpath));
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
mMediaPlayer = MediaPlayer.create(this, MeditationSounds
.getMeditationSound(getMeditationAssistant().getPrefs().getString(
"pref_meditation_sound_finish", "")));
}
if (mMediaPlayer != null) {
mMediaPlayer
.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
WakeLocker.release();
mp.release();
}
});
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer
.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(
MediaPlayer mp) {
mp.start();
}
});
//mMediaPlayer.prepareAsync();
} else {
handler.postDelayed(clearWakeLock, 5000);
}
}
}
if (getMeditationAssistant().sendUsageReports()) {
getMeditationAssistant().getTracker(MeditationAssistant.TrackerName.APP_TRACKER);
}
if (!manual) {
getMeditationAssistant().vibrateDevice();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.complete, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
if (item.getItemId() == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void askDismiss() {
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(getString(R.string.askDiscardText))
.setPositiveButton(getString(R.string.discard),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
finish();
}
}
).setNegativeButton(getString(R.string.cancel), null)
.show();
}
public void dismiss(View view) {
if (getMeditationAssistant().getPrefs().getBoolean("pref_askdismiss", true)) {
askDismiss();
} else {
finish();
}
}
public MeditationAssistant getMeditationAssistant() {
if (ma == null) {
ma = (MeditationAssistant) this.getApplication();
}
return ma;
}
private String getSessionMessage() {
EditText editSessionMessage = (EditText) findViewById(R.id.editSessionMessage);
return editSessionMessage.getText().toString().trim();
}
@Override
public void onBackPressed() {
if (getMeditationAssistant().getPrefs().getBoolean("pref_askdismiss", true)) {
askDismiss();
} else {
super.onBackPressed();
}
}
@Override
public void onDestroy() {
if (av != null) {
av.destroy();
}
if (mMediaPlayer != null) {
try {
mMediaPlayer.release();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
WakeLocker.release();
} catch (Exception e) {
e.printStackTrace();
}
handler.removeCallbacks(runnable);
super.onDestroy();
}
@Override
public void onPause() {
if (av != null) {
av.pause();
}
super.onPause();
}
@Override
public void onResume() {
super.onResume();
if (av != null) {
av.resume();
}
}
@Override
public void onStart() {
super.onStart();
if (getMeditationAssistant().sendUsageReports()) {
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
}
@Override
protected void onStop() {
super.onStop();
if (getMeditationAssistant().sendUsageReports()) {
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
}
public void postMediNET(View view) {
if (getMeditationAssistant().getMediNETKey() == "") {
getMeditationAssistant().showSignInDialog(this);
return;
}
saveLastMessage();
getMeditationAssistant().shortToast(getString(R.string.sessionPosting));
getMeditationAssistant().getMediNET().session.message = getSessionMessage();
getMeditationAssistant().getMediNET().postSession();
handler.removeCallbacks(runnable);
handler.postDelayed(runnable, 5);
}
private void saveLastMessage() {
SharedPreferences.Editor editor = getMeditationAssistant().getPrefs().edit();
editor.putString("lastmessage", getSessionMessage());
editor.apply();
}
public void saveMediNET(View view) {
saveLastMessage();
getMeditationAssistant().getMediNET().session.message = getSessionMessage();
getMeditationAssistant().getMediNET().saveSession(false, false);
getMeditationAssistant().shortToast(getString(R.string.sessionSaved));
finish();
}
}

+ 123
- 0
MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/Crypt.java View File

@ -0,0 +1,123 @@
package sh.ftp.rocketninelabs.meditationassistant;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
//import org.apache.commons.codec.binary.Base64;
public class Crypt {
private IvParameterSpec ivspec;
private SecretKeySpec keyspec;
private Cipher cipher;
public Crypt() {
ivspec = new IvParameterSpec("fzsznzsjh2asdr7e".getBytes());
keyspec = new SecretKeySpec("jqx82h4ad6fzb4dk".getBytes(), "AES");
try {
cipher = Cipher.getInstance("AES/CBC/NoPadding");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
}
}
public static String bytesToHex(byte[] data) {
if (data == null) {
return null;
}
int len = data.length;
String str = "";
for (int i = 0; i < len; i++) {
if ((data[i] & 0xFF) < 16)
str = str + "0" + java.lang.Integer.toHexString(data[i] & 0xFF);
else
str = str + java.lang.Integer.toHexString(data[i] & 0xFF);
}
return str;
}
public static byte[] hexToBytes(String str) {
if (str == null) {
return null;
} else if (str.length() < 2) {
return null;
} else {
int len = str.length() / 2;
byte[] buffer = new byte[len];
for (int i = 0; i < len; i++) {
buffer[i] = (byte) Integer.parseInt(
str.substring(i * 2, i * 2 + 2), 16);
}
return buffer;
}
}
private static String padString(String source) {
char paddingChar = ' ';
int size = 16;
int x = source.length() % size;
int padLength = size - x;
for (int i = 0; i < padLength; i++) {
source += paddingChar;
}
return source;
}
public byte[] decrypt(String code) throws Exception {
if (code == null || code.length() == 0)
throw new Exception("Empty string");
byte[] decrypted = null;
try {
cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);
decrypted = cipher.doFinal(hexToBytes(code));
} catch (Exception e) {
throw new Exception("[decrypt] " + e.getMessage());
}
return decrypted;
}
public String decryptToString(String code) throws Exception {
if (code == null || code.length() == 0)
throw new Exception("Empty string");
String decryptedstr = null;
try {
decryptedstr = new String(decrypt(code)).trim();
} catch (Exception e) {
throw new Exception("[decrypt] " + e.getMessage());
}
return decryptedstr;
}
public byte[] encrypt(String text) throws Exception {
if (text == null || text.length() == 0)
throw new Exception("Empty string");
byte[] encrypted = null;
try {
cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
encrypted = cipher.doFinal(padString(text).getBytes());
} catch (Exception e) {
throw new Exception("[encrypt] " + e.getMessage());
}
return encrypted;
}
}

+ 163
- 0
MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/DailyNotification.java View File

@ -0,0 +1,163 @@
package sh.ftp.rocketninelabs.meditationassistant;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
public class DailyNotification extends BroadcastReceiver {
MeditationAssistant ma = null;
@Override
public void onReceive(Context context, Intent intent) {
try {
ma = (MeditationAssistant) context.getApplicationContext();
} catch (Exception e) {
e.printStackTrace();
return;
}
if (!getMeditationAssistant().getPrefs().getBoolean("pref_daily_reminder", false)) {
cancelReminder(context);
return; // The user has not enabled the daily reminder
}
Log.d("MeditationAssistant", "onReceive in DailyNotification");
if (intent != null && intent.getAction() != null && intent.getAction().equals(MeditationAssistant.ACTION_REMINDER)) { // otherwise, it was just an update
Log.d("MeditationAssistant", "Daily notification intent!");
SimpleDateFormat sdf = new SimpleDateFormat("d-M-yyyy", Locale.US);
if (getMeditationAssistant().getTimeToStopMeditate() != 0) {
Log.d("MeditationAssistant", "Skipping daily notification today, session in progress...");
} else if (getMeditationAssistant().db.numSessionsByDate(sdf.format(Calendar.getInstance().getTime())) > 0) {
Log.d("MeditationAssistant", "Skipping daily notification today, there has already been a session recorded...");
} else {
long last_reminder = getMeditationAssistant().getPrefs().getLong("last_reminder", 0);
if (last_reminder == 0 || getMeditationAssistant().getTimestamp() - last_reminder > 120) {
getMeditationAssistant().getPrefs().edit().putLong("last_reminder", getMeditationAssistant().getTimestamp()).apply();
String reminderText = getMeditationAssistant().getPrefs().getString("pref_daily_reminder_text", "").trim();
if (reminderText.equals("")) {
reminderText = context.getString(R.string.reminderText);
}
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(context.getString(R.string.meditate))
.setContentText(reminderText)
.setTicker(reminderText)
.setAutoCancel(true);
if (getMeditationAssistant().getPrefs().getBoolean("pref_vibrate_reminder", true)) {
long[] vibrationPattern = {0, 200, 500, 200, 500};
notificationBuilder.setVibrate(vibrationPattern);
} else {
long[] vibrationPattern = {0, 0};
notificationBuilder.setVibrate(vibrationPattern);
}
if (getMeditationAssistant().getPrefs().getBoolean("pref_sound_reminder", true)) {
notificationBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
}
Intent notificationIntent = new Intent(context, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(notificationIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
//Intent launchMain = new Intent(context, MainActivity.class);
//PendingIntent launchNotification = PendingIntent.getActivity(context, 1008, launchMain, PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.setContentIntent(resultPendingIntent);
Notification notification = notificationBuilder.build();
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1946, notification);
}
}
}
String reminderTime = ma.getPrefs().getString("pref_daily_reminder_time", "19:00");
String[] reminderTimeSplit = ((reminderTime != null && reminderTime != "") ? reminderTime : "19:00").split(":");
Integer reminderHour = Integer.valueOf(reminderTimeSplit[0]);
Integer reminderMinute = Integer.valueOf(reminderTimeSplit[1]);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, reminderHour);
calendar.set(Calendar.MINUTE, reminderMinute);
calendar.set(Calendar.SECOND, 0);
if (Calendar.getInstance().getTimeInMillis() > calendar.getTimeInMillis()) {
calendar.add(Calendar.DATE, 1); // Tomorrow
}
cancelReminder(context);
getMeditationAssistant().reminderPendingIntent = PendingIntent
.getBroadcast(
context,
1946,
new Intent(
MeditationAssistant.ACTION_REMINDER),
PendingIntent.FLAG_CANCEL_CURRENT
);
if (Build.VERSION.SDK_INT >= 19) {
getMeditationAssistant().reminderAlarmManager.setExact(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(),
getMeditationAssistant().reminderPendingIntent);
} else {
getMeditationAssistant().reminderAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), 1000,
getMeditationAssistant().reminderPendingIntent);
}
Log.d("MeditationAssistant", "Set daily reminder alarm for " + calendar.toString());
}
private void cancelReminder(Context context) {
if (getMeditationAssistant().reminderPendingIntent != null) {
try {