launcher icon / sms / manager on boot
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -19,40 +20,51 @@
|
|||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:scheme="http" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="https" />
|
|
||||||
<data android:host="agrar.zoblak.com" />
|
<data android:scheme="http" />
|
||||||
|
<data android:scheme="https" />
|
||||||
|
<data android:host="agrar.zoblak.com" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".AlarmPollingService"
|
android:name=".AlarmPollingService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".SoundPlayingService"
|
android:name=".SoundPlayingService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="PeriodicalPingReceiver"
|
android:name=".PeriodicalPingReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:name=".SettingsActivity"
|
android:name=".SettingsActivity"
|
||||||
android:label="@string/title_activity_settings"
|
android:label="@string/title_activity_settings"
|
||||||
android:parentActivityName=".MainScreen">
|
android:parentActivityName=".MainScreen"
|
||||||
|
android:screenOrientation="portrait">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="com.zoblak.farmalarm.MainScreen" />
|
android:value="com.zoblak.farmalarm.MainScreen" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".BootBroadcastReceiver"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.zoblak.farmalarm;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
public class BootBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
public BootBroadcastReceiver() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
MainScreen.setupAlarmManager(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,8 +20,7 @@ import java.lang.System;
|
|||||||
|
|
||||||
public class MainScreen extends AppCompatActivity {
|
public class MainScreen extends AppCompatActivity {
|
||||||
|
|
||||||
private AlarmManager alarmMgr;
|
|
||||||
private PendingIntent alarmIntent;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -29,24 +28,25 @@ public class MainScreen extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_main_screen);
|
setContentView(R.layout.activity_main_screen);
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
setupAlarmManager(this);
|
||||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
|
||||||
.setAction("Action", null).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Intent intent = new Intent(this, PeriodicalPingReceiver.class);
|
|
||||||
|
|
||||||
alarmIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
|
|
||||||
|
|
||||||
|
|
||||||
int PERIOD_IN_MS = 5 * 60 * 1000; // 5 minutes
|
|
||||||
|
|
||||||
alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
|
}
|
||||||
|
|
||||||
|
public static void setupAlarmManager(Context context) {
|
||||||
|
AlarmManager alarmMgr;
|
||||||
|
|
||||||
|
PendingIntent alarmIntent;
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, PeriodicalPingReceiver.class);
|
||||||
|
|
||||||
|
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||||
|
|
||||||
|
|
||||||
|
int PERIOD_IN_MS = 2 * 60 * 1000; // 2 minutes
|
||||||
|
|
||||||
|
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||||
// Hopefully your alarm will have a lower frequency than this!
|
// Hopefully your alarm will have a lower frequency than this!
|
||||||
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP,
|
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP,
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
|
|||||||
@@ -23,12 +23,4 @@
|
|||||||
|
|
||||||
<include layout="@layout/content_main_screen" />
|
<include layout="@layout/content_main_screen" />
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/fab"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_margin="@dimen/fab_margin"
|
|
||||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 14 KiB |
@@ -1,7 +1,6 @@
|
|||||||
<template name="alarm">
|
<template name="alarm">
|
||||||
|
|
||||||
<div class="hello">
|
<div class="hello">
|
||||||
<h1> Temperatura </h1>
|
|
||||||
<div class="jumbotron text-center center-block" >
|
<div class="jumbotron text-center center-block" >
|
||||||
{{#with state}}
|
{{#with state}}
|
||||||
{{#if alarmTriggered}}
|
{{#if alarmTriggered}}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.huge_text {
|
.huge_text {
|
||||||
font-size: 3em;
|
font-size: 2.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (orientation: portrait) {
|
@media all and (orientation: portrait) {
|
||||||
@@ -32,14 +32,14 @@
|
|||||||
|
|
||||||
@media all and (orientation: portrait) {
|
@media all and (orientation: portrait) {
|
||||||
#alarm_image {
|
#alarm_image {
|
||||||
width: 90%;
|
width: 70%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (orientation: landscape) {
|
@media all and (orientation: landscape) {
|
||||||
#alarm_image {
|
#alarm_image {
|
||||||
width: 40%;
|
width: 30%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Api.addRoute('sensorData', {
|
|||||||
created_at: new Date()
|
created_at: new Date()
|
||||||
};
|
};
|
||||||
SensorData.insert(sensorObject);
|
SensorData.insert(sensorObject);
|
||||||
|
reactToAlarmData(this.bodyParams.controllerId);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ function saveAlarmSettings(controller_id, minTemperature, maxTemperature, timeou
|
|||||||
'$set': {
|
'$set': {
|
||||||
'config.minTemperature': parseFloat(minTemperature),
|
'config.minTemperature': parseFloat(minTemperature),
|
||||||
'config.maxTemperature': parseFloat(maxTemperature),
|
'config.maxTemperature': parseFloat(maxTemperature),
|
||||||
'config.timeoutBox': parseInt(timeoutBox),
|
'config.timeoutBox': timeoutBox ? parseInt(timeoutBox) : null,
|
||||||
'config.timeoutPhone': parseInt(timeoutPhone),
|
'config.timeoutPhone': timeoutPhone ? parseInt(timeoutPhone) : null,
|
||||||
'config.smsNumbers': smsNumbers,
|
'config.smsNumbers': smsNumbers,
|
||||||
'config.sms1': smsNumbers[0],
|
'config.sms1': smsNumbers[0],
|
||||||
'config.sms2': smsNumbers[1],
|
'config.sms2': smsNumbers[1],
|
||||||
@@ -164,7 +164,7 @@ function saveAlarmSettings(controller_id, minTemperature, maxTemperature, timeou
|
|||||||
SyncedCron.add({
|
SyncedCron.add({
|
||||||
name: jobName,
|
name: jobName,
|
||||||
schedule: function(parser) {
|
schedule: function(parser) {
|
||||||
return parser.text('every 30 seconds');
|
return parser.text('every 10 seconds');
|
||||||
},
|
},
|
||||||
job: function() {
|
job: function() {
|
||||||
reactToAlarmData(controller_id);
|
reactToAlarmData(controller_id);
|
||||||
@@ -252,7 +252,7 @@ function soundTheAlarm(controller_id, tooCold, tooHot, boxSilent, phoneSilent) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var smsSent = !!state.state.alarmSmsSent;
|
var smsSent = !!state.state.alarmSmsSent;
|
||||||
var needsToSendSms = !smsSent; // && (boxSilent || phoneSilent);
|
var needsToSendSms = !smsSent && phoneSilent;
|
||||||
|
|
||||||
var sendSmsPart = needsToSendSms ? { 'state.alarmSmsSent': true } : {};
|
var sendSmsPart = needsToSendSms ? { 'state.alarmSmsSent': true } : {};
|
||||||
|
|
||||||
|
|||||||