BaseNotificationFactory.java 3.95 KB
package com.arellomobile.android.push.utils.notification;

import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.arellomobile.android.push.preference.SoundType;
import com.arellomobile.android.push.preference.VibrateType;

public abstract class BaseNotificationFactory
{
  private Notification a;
  private Context b;
  private Bundle c;
  private String d;
  private String e;
  private SoundType f;
  private VibrateType g;
  
  public BaseNotificationFactory(Context paramContext, Bundle paramBundle, String paramString1, String paramString2, SoundType paramSoundType, VibrateType paramVibrateType)
  {
    this.b = paramContext;
    this.c = paramBundle;
    this.d = paramString1;
    this.e = paramString2;
    this.f = paramSoundType;
    this.g = paramVibrateType;
  }
  
  private static boolean a(Context paramContext)
  {
    PackageManager localPackageManager = paramContext.getPackageManager();
    try
    {
      int i = localPackageManager.checkPermission("android.permission.VIBRATE", paramContext.getPackageName());
      if (i == 0) {
        return true;
      }
    }
    catch (Exception paramContext)
    {
      Log.e("PushWoosh", "error in checking vibrate permission", paramContext);
    }
    return false;
  }
  
  abstract Notification a(Context paramContext, Bundle paramBundle, String paramString1, String paramString2, String paramString3);
  
  public void addCancel()
  {
    Notification localNotification = this.a;
    localNotification.flags |= 0x10;
  }
  
  public void addLED(boolean paramBoolean)
  {
    if (!paramBoolean) {
      return;
    }
    this.a.ledARGB = -1;
    Notification localNotification = this.a;
    localNotification.flags |= 0x1;
    this.a.ledOnMS = 100;
    this.a.ledOffMS = 1000;
  }
  
  public void addSoundAndVibrate()
  {
    Object localObject = (String)this.c.get("s");
    AudioManager localAudioManager = (AudioManager)this.b.getSystemService("audio");
    Notification localNotification;
    if ((this.f == SoundType.ALWAYS) || ((localAudioManager.getRingerMode() == 2) && (this.f == SoundType.DEFAULT_MODE)))
    {
      Context localContext = this.b;
      localNotification = this.a;
      if ((localObject == null) || (((String)localObject).length() == 0)) {
        break label189;
      }
      int i = localContext.getResources().getIdentifier((String)localObject, "raw", localContext.getPackageName());
      if (i == 0) {
        break label189;
      }
      localNotification.sound = Uri.parse("android.resource://" + localContext.getPackageName() + "/" + i);
    }
    for (;;)
    {
      if (((this.g == VibrateType.ALWAYS) || ((localAudioManager.getRingerMode() == 1) && (this.g == VibrateType.DEFAULT_MODE))) && (a(this.b)))
      {
        localObject = this.a;
        ((Notification)localObject).defaults |= 0x2;
      }
      return;
      label189:
      localNotification.defaults |= 0x1;
    }
  }
  
  public void generateNotification()
  {
    int i = getContext().getResources().getIdentifier("new_push_message", "string", getContext().getPackageName());
    if (i != 0)
    {
      String str = getContext().getString(i);
      this.a = a(getContext(), getData(), this.d, this.e, str);
      return;
    }
    this.a = a(getContext(), getData(), this.d, this.e, this.e);
  }
  
  protected Context getContext()
  {
    return this.b;
  }
  
  protected Bundle getData()
  {
    return this.c;
  }
  
  public Notification getNotification()
  {
    return this.a;
  }
  
  protected SoundType getSoundType()
  {
    return this.f;
  }
  
  protected VibrateType getVibrateType()
  {
    return this.g;
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/utils/notification/BaseNotificationFactory.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */