Example usage for android.widget RemoteViews getLayoutId

List of usage examples for android.widget RemoteViews getLayoutId

Introduction

In this page you can find the example usage for android.widget RemoteViews getLayoutId.

Prototype

public int getLayoutId() 

Source Link

Document

Returns the layout id of the root layout associated with this RemoteViews.

Usage

From source file:Main.java

public static boolean isCustomNotification(RemoteViews remoteViews) {
    if (remoteViews == null) {
        return false;
    } else if (sSystemLayoutResIds.containsKey(remoteViews.getLayoutId())) {
        return false;
    } else {//from  w  w  w  .j av a 2 s .c  o  m
        return true;
    }
}

From source file:com.achep.acdisplay.notifications.OpenNotificationJellyBean.java

/**
 * {@inheritDoc}//  www .  ja  v a  2 s. com
 */
@Override
public boolean hasIdenticalIds(@Nullable OpenNotification n) {
    if (n == null) {
        return false;
    }

    EqualsBuilder builder = new EqualsBuilder();

    RemoteViews cv = getNotification().contentView;
    RemoteViews cv2 = n.getNotification().contentView;
    if (cv != null && cv2 != null) {
        builder.append(cv.getLayoutId(), cv2.getLayoutId());
    }

    return builder.append(getNotification().ledARGB, n.getNotification().ledARGB)
            .append(getPackageName(), n.getPackageName()).append(titleText, n.titleText).isEquals();

}

From source file:me.spadival.podmode.PodNotifyService.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    String notifyPackage = (String) event.getPackageName();

    if (!event.getClassName().equals(NOTIFICATION_CLASS))
        return;/* w  w  w .ja  v  a  2  s  .c o m*/

    if (notifyPackage.equals(SYSTEMUI_PACKAGE) || notifyPackage.equals(THIS_PACKAGE)
            || notifyPackage.equals(ANDROID_PACKAGE))
        return;

    PackageManager pm = getPackageManager();

    String notifyAppName = null;

    try {
        notifyAppName = (String) pm.getApplicationLabel(pm.getApplicationInfo(notifyPackage, 0));
    } catch (NameNotFoundException e1) {
        e1.printStackTrace();
    }

    if (notifyAppName == null)
        return;

    if (notifyPackage.equals(GMAPS_PACKAGE))
        notifyAppName = getString(R.string.nav_appname);

    if (notifyPackage.equals(GNOW_PACKAGE))
        notifyAppName = "Google Now";

    List<CharSequence> textList = event.getText();

    String notifyText = "";

    if (textList.size() > 0)
        notifyText = textList.get(0).toString();

    if (notifyText.equals("") || notifyPackage.equals(GMAIL_PACKAGE)) {
        Notification eventNotification = (Notification) event.getParcelableData();

        RemoteViews notifyView = eventNotification.contentView;
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        ViewGroup localView = null;
        try {
            localView = (ViewGroup) inflater.inflate(notifyView.getLayoutId(), null);
        } catch (Exception e) {
            //      e.printStackTrace();
            return;
        }

        try {

            notifyView.reapply(getApplicationContext(), localView);
        } catch (NotFoundException e) {
            //         e.printStackTrace();
        }

        View tv = localView.findViewById(android.R.id.title);
        if (tv != null && tv instanceof TextView) {
            if (notifyPackage.equals(GNOW_PACKAGE) || notifyPackage.equals(PANDORA_PACKAGE))
                notifyText = ((TextView) tv).getText().toString();
            else
                notifyAppName += ": " + ((TextView) tv).getText().toString();
        }

        if (!notifyPackage.equals(GNOW_PACKAGE)) {

            tv = localView.findViewById(16908358);
            if (tv != null && tv instanceof TextView)
                if (notifyPackage.equals(PANDORA_PACKAGE))
                    notifyAppName += ": " + ((TextView) tv).getText().toString();
                else
                    notifyText = (String) ((TextView) tv).getText().toString();
        }

        if (notifyPackage.equals(GMAIL_PACKAGE)) {
            tv = localView.findViewById(android.R.id.text2);
            if (tv != null && tv instanceof TextView)
                notifyText = (String) ((TextView) tv).getText().toString();
        }
    }

    Intent localIntent = new Intent(PodModeService.NOTIFYACTION);
    localIntent.putExtra("package", notifyPackage);
    localIntent.putExtra("appname", notifyAppName);
    localIntent.putExtra("text", notifyText);

    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);

}

From source file:com.dattasmoon.pebble.plugin.NotificationService.java

private String getExtraData(Notification notification, String existing_text) {
    if (Constants.IS_LOGGABLE) {
        Log.i(Constants.LOG_TAG, "I am running extra data");
    }// w w  w . j a va  2s. co  m
    RemoteViews views = notification.contentView;
    if (views == null) {
        if (Constants.IS_LOGGABLE) {
            Log.i(Constants.LOG_TAG, "ContentView was empty, returning a blank string");
        }
        return "";
    }

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    try {
        ViewGroup localView = (ViewGroup) inflater.inflate(views.getLayoutId(), null);
        views.reapply(getApplicationContext(), localView);
        return dumpViewGroup(0, localView, existing_text);
    } catch (android.content.res.Resources.NotFoundException e) {
        return "";
    } catch (RemoteViews.ActionException e) {
        return "";
    }
}

From source file:com.dattasmoon.pebble.plugin.NotificationService.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private String getExtraBigData(Notification notification, String existing_text) {
    if (Constants.IS_LOGGABLE) {
        Log.i(Constants.LOG_TAG, "I am running extra big data");
    }/*ww  w. j a v  a  2 s.  co  m*/
    RemoteViews views = null;
    try {
        views = notification.bigContentView;
    } catch (NoSuchFieldError e) {
        return getExtraData(notification, existing_text);
    }
    if (views == null) {
        if (Constants.IS_LOGGABLE) {
            Log.i(Constants.LOG_TAG, "bigContentView was empty, running normal");
        }
        return getExtraData(notification, existing_text);
    }
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    try {
        ViewGroup localView = (ViewGroup) inflater.inflate(views.getLayoutId(), null);
        views.reapply(getApplicationContext(), localView);
        return dumpViewGroup(0, localView, existing_text);
    } catch (android.content.res.Resources.NotFoundException e) {
        return "";
    }
}