Skip to content

Commit

Permalink
[TIMOB-24629] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Aug 14, 2017
1 parent 15e362b commit 3c311de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-2017 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand All @@ -14,11 +14,13 @@
import org.appcelerator.kroll.KrollDict;

import ti.modules.titanium.android.AndroidModule;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;

import java.util.HashMap;

@Kroll.module(parentModule=AndroidModule.class)
Expand Down Expand Up @@ -78,13 +80,12 @@ public void notify(int id, NotificationProxy notificationProxy)
{
getManager().notify(id, notificationProxy.buildNotification());

HashMap wakeParams = notificationProxy.wakeParams;
HashMap wakeParams = notificationProxy.getWakeParams();
if (wakeParams != null) {
int wakeTime = TiConvert.toInt(wakeParams.get("time"), 3000);
int wakeFlags = TiConvert.toInt(wakeParams.get("flags"), (PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE));
PowerManager pm = (PowerManager) TiApplication.getInstance().getSystemService(TiApplication.getInstance().getApplicationContext().POWER_SERVICE);
boolean isScreenOn = pm.isScreenOn();
if (isScreenOn == false) {
if (pm != null && !pm.isScreenOn()) {
WakeLock wl = pm.newWakeLock(wakeFlags, "TiWakeLock");
wl.acquire(wakeTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import ti.modules.titanium.android.AndroidModule;
import ti.modules.titanium.android.PendingIntentProxy;
import ti.modules.titanium.android.RemoteViewsProxy;

import android.app.Notification;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Builder;

import java.util.HashMap;

@SuppressWarnings("deprecation")
Expand All @@ -41,7 +43,7 @@ public class NotificationProxy extends KrollProxy
private int flags, ledARGB, ledOnMS, ledOffMS;
private Uri sound;
private int audioStreamType;
public HashMap wakeParams;
private HashMap wakeParams;

public NotificationProxy()
{
Expand Down Expand Up @@ -399,6 +401,10 @@ public Notification buildNotification()
return notification;
}

public HashMap getWakeParams() {
return wakeParams;
}

@Override
public String getApiName()
{
Expand Down
5 changes: 5 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public class TiC
*/
public static final String EVENT_DOUBLE_TAP = "doubletap";

/**
* @module.api
*/
public static final String EVENT_DRAGSTART = "dragstart";

/**
* @module.api
*/
Expand Down

0 comments on commit 3c311de

Please sign in to comment.