Android Open Source - SmartNotify Global State






From Project

Back to project page SmartNotify.

License

The source code is released under:

Copyright (c) 2014, Sergey Parshin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project SmartNotify listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (c) 2014, Sergey Parshin, quarck@gmail.com
 * All rights reserved./*  w  ww .j  ava 2 s  .  c  o  m*/
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of developer (Sergey Parshin) nor the
 *       names of other project contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


package com.github.quarck.smartnotify;

import android.app.Application;
import android.content.Context;

public class GlobalState extends Application
{
  private static GlobalState _instance = null;
  
  public static GlobalState instance(Context ctx)
  {
    if (_instance == null)
    {
      synchronized(GlobalState.class)
      {
        if (_instance == null)
          _instance = (GlobalState) ctx.getApplicationContext();
      }
    }
    
    return _instance;
  }
  

  private boolean isOnCall = false;
  
  public void setIsOnCall(boolean val)
  {
    isOnCall = val;
  }
  
  public boolean getIsOnCall()
  {
    return isOnCall;
  }
  
  
  public static void setIsOnCall(Context ctx, boolean val)
  {
    instance(ctx).isOnCall = val;
  }
  
  public static boolean getIsOnCall(Context ctx)
  {
    return instance(ctx).isOnCall;
  }

  
  private boolean isMuted = false;
  
  public static void setIsMuted(Context ctx, boolean val)
  {
    instance(ctx).isMuted = val;
  }
  
  public static boolean getIsMuted(Context ctx)
  {
    return instance(ctx).isMuted;
  }

  private int lastCountHandledNotifications = -1;

  public static int getLastCountHandledNotifications(Context ctx)
  {
    return instance(ctx).lastCountHandledNotifications;
  }

  public static void setLastCountHandledNotifications(Context ctx, int lastCountHandledNotifications)
  {
    instance(ctx).lastCountHandledNotifications = lastCountHandledNotifications;
  }
  
  
  private long lastFireTime = 0;

  public static long getLastFireTime(Context ctx)
  {
    return instance(ctx).lastFireTime;
  }

  public static void setLastFireTime(Context ctx, long lastFireTime)
  {
    instance(ctx).lastFireTime = lastFireTime;
  }
  
  
  private long currentRemindInterval = 0;
  
  public static void setCurrentRemindInterval(Context ctx, long val)
  {
    instance(ctx).currentRemindInterval = val;
  }
  
  public static long getCurrentRemindInterval(Context ctx)
  {
    return instance(ctx).currentRemindInterval;
  }
}




Java Source Code List

com.github.quarck.smartnotify.Alarm.java
com.github.quarck.smartnotify.AppUpdatedBroadcastReceiver.java
com.github.quarck.smartnotify.CallStateTracker.java
com.github.quarck.smartnotify.CommonAppsRegistry.java
com.github.quarck.smartnotify.Consts.java
com.github.quarck.smartnotify.EditApplicationsActivity.java
com.github.quarck.smartnotify.GlobalState.java
com.github.quarck.smartnotify.InitialPopulate.java
com.github.quarck.smartnotify.Lw.java
com.github.quarck.smartnotify.MainActivity.java
com.github.quarck.smartnotify.NotificationReceiverService.java
com.github.quarck.smartnotify.OngoingNotificationManager.java
com.github.quarck.smartnotify.PackageSettings.java
com.github.quarck.smartnotify.ServiceClient.java
com.github.quarck.smartnotify.SettingsActivity.java
com.github.quarck.smartnotify.Settings.java
com.github.quarck.smartnotify.SilentPeriodManager.java
com.github.quarck.smartnotify.ToggleMuteBroadcastReceiver.java
com.github.quarck.smartnotify.prefs.TimePickerPreference.java
com.github.quarck.smartnotify.prefs.VibrationPatternPreference.java