Пример #1
0
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {

    super.initialize(cordova, webView);

    WindowManager manager =
        ((WindowManager)
            cordova.getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE));

    WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    localLayoutParams.gravity = Gravity.TOP;
    localLayoutParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            |

            // this is to enable the notification to recieve touch events
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            |

            // Draws over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height =
        (int) (30 * cordova.getActivity().getResources().getDisplayMetrics().scaledDensity);
    localLayoutParams.format = PixelFormat.TRANSPARENT;

    CustomViewGroup view = new CustomViewGroup(cordova.getActivity().getApplicationContext());

    manager.addView(view, localLayoutParams);
  }
Пример #2
0
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    Log.i(
        TAG,
        "---------------- initialize"
            + "-"
            + JPushPlugin.openNotificationAlert
            + "-"
            + JPushPlugin.notificationAlert);

    shouldCacheMsg = false;

    // 如果同时缓存了打开事件openNotificationAlert 和 消息事件notificationAlert,只向UI 发 打开事件。
    // 这样做是为了和iOS 统一
    if (JPushPlugin.openNotificationAlert != null) {
      JPushPlugin.notificationAlert = null;
      JPushPlugin.transmitOpen(
          JPushPlugin.openNotificationAlert, JPushPlugin.openNotificationExtras);
    }
    if (JPushPlugin.notificationAlert != null) {
      JPushPlugin.transmitReceive(JPushPlugin.notificationAlert, JPushPlugin.notificationExtras);
    }

    // JPushInterface.init(cordova.getActivity().getApplicationContext());
  }
Пример #3
0
  public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    // Restore preferences
    this.settings = this.cordova.getActivity().getSharedPreferences(SETTINGS_NAME, 0);
    this.lastSessionId = settings.getString("lastSessionId", "");
    this.lastAppId = settings.getString("lastAppId", "");
  }
  /**
   * Initializes the plugin.
   *
   * @param cordova The context of the main Activity
   * @param webView The CordovaWebView Cordova is running in
   */
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    beaconManager = new BeaconManager(this.cordova.getActivity().getApplicationContext());
    currentRegion = new Region("regionId", REGION_ID, null, null);

    packageManager = this.cordova.getActivity().getPackageManager();

    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  }
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   mContext = cordova.getActivity();
   mContentResolver = cordova.getActivity().getContentResolver();
   genIncomingCallBroadcastReceiver();
   cordova
       .getActivity()
       .registerReceiver(
           mIncomingCallBroadcastReceiver, new IntentFilter(ACTION_PHONE_STATE_CHANGED));
 }
Пример #6
0
 @Override
 public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
   safeToFireMessages = false;
   super.initialize(cordova, webView);
   ChromeGcm.webView = webView;
   executorService = cordova.getThreadPool();
   if (cordova.getActivity().getIntent().hasExtra(PAYLOAD_LABEL)) {
     cordova.getActivity().moveTaskToBack(true);
   }
   context = cordova.getActivity().getApplicationContext();
 }
Пример #7
0
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    context = cordova.getActivity();

    locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    if (location != null) {
      onLocationChanged(location);
    }
  }
  @Override
  public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      final Activity activity = cordova.getActivity();
      final Window window = activity.getWindow();

      setTranslucentStatus(window);

      tintManager = new SystemBarTintManager(activity);
    }
  }
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
     mMobileAccessibilityHelper = new KitKatMobileAccessibilityHelper();
   } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     mMobileAccessibilityHelper = new JellyBeanMobileAccessibilityHelper();
   } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
     mMobileAccessibilityHelper = new IceCreamSandwichMobileAccessibilityHelper();
   } else {
     mMobileAccessibilityHelper = new DonutMobileAccessibilityHelper();
   }
   mMobileAccessibilityHelper.initialize(this);
 }
  /**
   * Sets the context of the Command. This can then be used to do things like get file paths
   * associated with the Activity.
   *
   * @param cordova The context of the main Activity.
   * @param webView The CordovaWebView Cordova is running in.
   */
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    initBluetoothListener();
    initEventQueue();
    pauseEventPropagationToDom(); // Before the DOM is loaded we'll just keep collecting the events
                                  // and fire them later.

    initLocationManager();

    debugEnabled = true;

    // TODO AddObserver when page loaded

  }
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // JPushInterface.setDebugMode(true);

    // JPushPlugin.notificationAlert = alert;
    // JPushPlugin.notificationExtras = extras;
    if (JPushPlugin.openNotificationAlert != null) {
      JPushPlugin.transmitOpen(
          JPushPlugin.openNotificationAlert, JPushPlugin.openNotificationExtras);
    }
    if (JPushPlugin.notificationAlert != null) {
      JPushPlugin.transmitReceive(JPushPlugin.notificationAlert, JPushPlugin.notificationExtras);
    }

    // JPushInterface.init(cordova.getActivity().getApplicationContext());
  }
Пример #12
0
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    try {
      java.net.URL.setURLStreamHandlerFactory(
          new java.net.URLStreamHandlerFactory() {
            public java.net.URLStreamHandler createURLStreamHandler(String protocol) {
              Log.d(LOG_TAG, "Asking for stream handler for protocol: '" + protocol + "'");
              if ("icy".equals(protocol)) return new com.spoledge.aacdecoder.IcyURLStreamHandler();
              return null;
            }
          });
    } catch (Throwable t) {
      Log.w(LOG_TAG, "Cannot set the ICY URLStreamHandler - maybe already set ? - " + t);
    }

    if (RadioAAC.multiPlayer == null) RadioAAC.multiPlayer = new MultiPlayer();
  }
Пример #13
0
  /**
   * Sets the context of the Command. This can then be used to do things like get file paths
   * associated with the Activity.
   *
   * @param cordova The context of the main Activity.
   * @param webView The CordovaWebView Cordova is running in.
   */
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.sockMan =
        (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    this.connectionCallbackContext = null;

    // We need to listen to connectivity events to update navigator.connection
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    if (this.receiver == null) {
      this.receiver =
          new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
              // (The null check is for the ARM Emulator, please use Intel Emulator for better
              // results)
              if (NetworkManager.this.webView != null)
                updateConnectionInfo(sockMan.getActiveNetworkInfo());
            }
          };
      webView.getContext().registerReceiver(this.receiver, intentFilter);
    }
  }
Пример #14
0
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   gForeground = true;
 }
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
     super.initialize(cordova, webView);
     // your init code here
 }
Пример #16
0
 /**
  * Sets the context of the Command. This can then be used to do things like get file paths
  * associated with the Activity.
  *
  * @param cordova The context of the main Activity.
  * @param webView The CordovaWebView Cordova is running in.
  */
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   this.myContext = this.cordova.getActivity().getApplicationContext();
 }
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
 }
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   this.sensorManager =
       (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE);
 }
  @Override
  public void initialize(final CordovaInterface cordova, final CordovaWebView webView) {
    super.initialize(cordova, webView);
    am = (AudioManager) cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
    reader = new AudioJackReader(am, true);

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_HEADSET_PLUG);
    cordova
        .getActivity()
        .registerReceiver(
            new BroadcastReceiver() {
              @Override
              public void onReceive(Context context, Intent intent) {

                if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {

                  boolean plugged = (intent.getIntExtra("state", 0) == 1);

                  /* Mute the audio output if the reader is unplugged. */
                  reader.setMute(!plugged);
                  mute = !plugged;
                }
              }
            },
            filter);

    final StringBuffer buffer = new StringBuffer();
    final StringBuffer atrBuffer = new StringBuffer();

    reader.setSleepTimeout(30);

    reader.setOnPiccAtrAvailableListener(
        new AudioJackReader.OnPiccAtrAvailableListener() {
          @Override
          public void onPiccAtrAvailable(AudioJackReader audioJackReader, byte[] bytes) {
            Log.w(TAG, bytesToHex(bytes));

            atrBuffer.append(bytesToHex(bytes));
          }
        });

    reader.setOnPiccResponseApduAvailableListener(
        new AudioJackReader.OnPiccResponseApduAvailableListener() {
          @Override
          public void onPiccResponseApduAvailable(AudioJackReader audioJackReader, byte[] bytes) {
            byte[] resultBytes = new byte[bytes.length - 2];
            byte[] statusBytes = new byte[2];

            System.arraycopy(bytes, 0, resultBytes, 0, bytes.length - 2);
            System.arraycopy(bytes, bytes.length - 2, statusBytes, 0, 2);

            Log.w(TAG, bytesToHex(statusBytes));

            buffer.append(bytesToHex(resultBytes));
            buffer.append("");
          }
        });

    reader.setOnStatusAvailableListener(
        new AudioJackReader.OnStatusAvailableListener() {
          @Override
          public void onStatusAvailable(AudioJackReader audioJackReader, final Status status) {
            timer.cancel();

            cordova
                .getActivity()
                .runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        JSONArray resultArray = new JSONArray();
                        resultArray.put(Integer.toString(status.getBatteryLevel()));
                        resultArray.put(Integer.toString(status.getSleepTimeout()));

                        PluginResult dataResult =
                            new PluginResult(PluginResult.Status.OK, resultArray);
                        callbackContext.sendPluginResult(dataResult);
                      }
                    });
          }
        });

    reader.setOnDeviceIdAvailableListener(
        new AudioJackReader.OnDeviceIdAvailableListener() {
          @Override
          public void onDeviceIdAvailable(AudioJackReader audioJackReader, final byte[] bytes) {
            // reader.sleep();
            timer.cancel();

            cordova
                .getActivity()
                .runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        PluginResult dataResult =
                            new PluginResult(PluginResult.Status.OK, bytesToHex(bytes));
                        callbackContext.sendPluginResult(dataResult);
                      }
                    });
          }
        });

    reader.setOnResultAvailableListener(
        new AudioJackReader.OnResultAvailableListener() {
          @Override
          public void onResultAvailable(AudioJackReader audioJackReader, Result result) {
            // reader.sleep();
            timer.cancel();

            final String stringResult = buffer.toString();
            final String atrResult = atrBuffer.toString();

            Log.i(TAG, "Result Available");
            Log.i(TAG, stringResult);

            cordova
                .getActivity()
                .runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (timedOut) {
                          PluginResult dataResult =
                              new PluginResult(PluginResult.Status.OK, "TIMEDOUT");
                          callbackContext.sendPluginResult(dataResult);
                        } else {
                          JSONArray resultArray = new JSONArray();
                          resultArray.put(stringResult.replaceAll("\\s", ""));
                          resultArray.put(atrResult.replaceAll("\\s", ""));

                          PluginResult dataResult =
                              new PluginResult(PluginResult.Status.OK, resultArray);
                          callbackContext.sendPluginResult(dataResult);
                        }
                      }
                    });
            buffer.delete(0, buffer.length());
            atrBuffer.delete(0, atrBuffer.length());
          }
        });
  }
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   logger = new Logger(cordova, webView);
 }
Пример #21
0
 /**
  * Sets the context of the Command. This can then be used to do things like get file paths
  * associated with the Activity.
  *
  * @param cordova The context of the main Activity.
  * @param webView The CordovaWebView Cordova is running in.
  */
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   this.initTelephonyReceiver();
 }
 /**
  * Sets the context of the Command. This can then be used to do things like get file paths
  * associated with the Activity.
  *
  * @param cordova The context of the main Activity.
  * @param webView The CordovaWebView Cordova is running in.
  */
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   context = cordova.getActivity().getApplicationContext();
   Log.v(TAG, "Init LocalAssets");
 }
Пример #23
0
  /** 插件初始化 */
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    LOG.d(LOG_TAG, "BaiduPush#initialize");

    super.initialize(cordova, webView);
  }
Пример #24
0
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   getBus();
 }
 /**
  * Sets the context of the Command.
  *
  * @param cordova the context of the main Activity.
  * @param webView the associated CordovaWebView.
  */
 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {
   super.initialize(cordova, webView);
   this.view = webView;
 }