Example usage for android.graphics.drawable Icon createWithBitmap

List of usage examples for android.graphics.drawable Icon createWithBitmap

Introduction

In this page you can find the example usage for android.graphics.drawable Icon createWithBitmap.

Prototype

public static Icon createWithBitmap(Bitmap bits) 

Source Link

Document

Create an Icon pointing to a bitmap in memory.

Usage

From source file:com.abhinavjhanwar.android.egg.neko.NekoShortcuts.java

@TargetApi(Build.VERSION_CODES.N_MR1)
public void updateShortcuts() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = mContext.getSystemService(ShortcutManager.class);

        final PrefState prefs = new PrefState(mContext);
        int currentFoodState = prefs.getFoodState();
        final List<ShortcutInfo> shortcuts = new ArrayList<>();
        final int mFoodCount = mContext.getResources().getStringArray(R.array.food_names).length;

        if (currentFoodState == 0) {
            for (int i = 1; i < mFoodCount; i++) {
                final Food food = new Food(i);

                final Intent action = new Intent(mContext, NekoLand.class).setAction(Intent.ACTION_VIEW)
                        .putExtra("action", NekoLand.SHORTCUT_ACTION_SET_FOOD).putExtra("food", i);

                final ShortcutInfo shortcut = new ShortcutInfo.Builder(mContext, "food" + i)
                        .setShortLabel(food.getName(mContext)).setLongLabel(food.getName(mContext))
                        .setIcon(Icon.createWithBitmap(getDarkIcon(mContext, food.getIcon(mContext))))
                        .setIntent(action).build();
                shortcuts.add(shortcut);
            }// w  w  w  .  ja  va  2 s .  c  om
        } else {
            // Add current
            final Food currentFood = new Food(currentFoodState);
            final Intent currentActionIntent = new Intent(mContext, NekoLand.class)
                    .setAction(Intent.ACTION_VIEW).putExtra("action", NekoLand.SHORTCUT_ACTION_OPEN_SELECTOR);
            final ShortcutInfo currentFoodShortcut = new ShortcutInfo.Builder(mContext, "current")
                    .setShortLabel(currentFood.getName(mContext))
                    .setLongLabel(mContext.getString(R.string.current_dish).replace("%s",
                            currentFood.getName(mContext)))
                    .setIcon(Icon.createWithBitmap(getDarkIcon(mContext, currentFood.getIcon(mContext))))
                    .setIntent(currentActionIntent).build();
            final Intent emptyActionIntent = new Intent(mContext, NekoLand.class).setAction(Intent.ACTION_VIEW)
                    .putExtra("action", NekoLand.SHORTCUT_ACTION_SET_FOOD_EMPTY);
            final ShortcutInfo emptyFoodShortcut = new ShortcutInfo.Builder(mContext, "empty")
                    .setShortLabel(mContext.getResources().getString(R.string.empty_dish))
                    .setLongLabel(mContext.getResources().getString(R.string.empty_dish))
                    .setIcon(Icon.createWithBitmap(getDarkIcon(mContext, R.drawable.food_dish)))
                    .setIntent(emptyActionIntent).build();
            shortcuts.add(emptyFoodShortcut);
            shortcuts.add(currentFoodShortcut);
        }

        shortcutManager.setDynamicShortcuts(shortcuts);
    }
}

From source file:com.metinkale.prayerapp.vakit.WidgetService.java

public static void updateOngoing() {
    extractColors();/*from w  w w.ja v  a2  s .c  om*/
    NotificationManager nm = (NotificationManager) App.getContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);

    for (int i = mOngoing.size() - 1; i >= 0; i--) {
        long id = mOngoing.get(i);
        Times t = Times.getTimes(id);

        if ((t == null) || !t.isOngoingNotificationActive()) {
            nm.cancel(id + "", NotIds.ONGOING);
            mOngoing.remove(i);
        }
    }
    List<Long> ids = Times.getIds();
    for (long id : ids) {

        Times t = Times.getTimes(id);

        if ((t != null) && t.isOngoingNotificationActive() && !mOngoing.contains(id)) {
            mOngoing.add(id);
        }
    }

    LocalDate cal = LocalDate.now();
    String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part);
    for (long id : mOngoing) {

        Times t = Times.getTimes(id);

        String[] dt = { t.getTime(cal, 0), t.getTime(cal, 1), t.getTime(cal, 2), t.getTime(cal, 3),
                t.getTime(cal, 4), t.getTime(cal, 5) };
        boolean icon = Prefs.showOngoingIcon();
        boolean number = Prefs.showOngoingNumber();
        Crashlytics.setBool("showIcon", icon);
        Crashlytics.setBool("showNumber", number);

        Notification noti;
        if (Prefs.getAlternativeOngoing()) {
            RemoteViews views = new RemoteViews(App.getContext().getPackageName(),
                    R.layout.notification_layout);

            int[] timeIds = { R.id.time0, R.id.time1, R.id.time2, R.id.time3, R.id.time4, R.id.time5 };
            int[] vakitIds = { R.id.imsak, R.id.gunes, R.id.ogle, R.id.ikindi, R.id.aksam, R.id.yatsi };

            int next = t.getNext();
            if (Prefs.getVakitIndicator().equals("next"))
                next++;
            for (int i = 0; i < dt.length; i++) {
                if ((next - 1) == i) {
                    views.setTextViewText(timeIds[i],
                            Html.fromHtml("<strong><em>" + Utils.fixTime(dt[i]) + "</em></strong>"));
                } else {
                    views.setTextViewText(timeIds[i], Utils.fixTime(dt[i]));
                }
            }

            for (int i = 0; i < dt.length; i++) {
                if ((next - 1) == i) {
                    views.setTextViewText(vakitIds[i],
                            Html.fromHtml("<strong><em>" + Vakit.getByIndex(i).getString() + "</em></strong>"));
                } else {
                    views.setTextViewText(vakitIds[i], Vakit.getByIndex(i).getString());
                }
            }

            views.setTextViewText(R.id.time, t.getLeft(t.getNext(), false));
            views.setTextViewText(R.id.city, t.getName());

            views.setTextColor(R.id.imsak, COLOR_1ST);
            views.setTextColor(R.id.gunes, COLOR_1ST);
            views.setTextColor(R.id.ogle, COLOR_1ST);
            views.setTextColor(R.id.ikindi, COLOR_1ST);
            views.setTextColor(R.id.aksam, COLOR_1ST);
            views.setTextColor(R.id.yatsi, COLOR_1ST);

            views.setTextColor(R.id.time0, COLOR_1ST);
            views.setTextColor(R.id.time1, COLOR_1ST);
            views.setTextColor(R.id.time2, COLOR_1ST);
            views.setTextColor(R.id.time3, COLOR_1ST);
            views.setTextColor(R.id.time4, COLOR_1ST);
            views.setTextColor(R.id.time5, COLOR_1ST);

            views.setTextColor(R.id.time, COLOR_1ST);
            views.setTextColor(R.id.city, COLOR_1ST);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                long left = t.getLeftMinutes(t.getNext());
                noti = new Notification.Builder(App.getContext()).setContent(views)
                        .setContentIntent(Main.getPendingIntent(t))
                        .setSmallIcon(icon
                                ? (number ? Icon.createWithBitmap(getIconFromMinutes(left))
                                        : Icon.createWithResource(App.getContext(), R.drawable.ic_abicon))
                                : Icon.createWithResource(App.getContext(), R.drawable.ic_placeholder))
                        .setOngoing(true).build();
            } else {
                noti = new NotificationCompat.Builder(App.getContext()).setContent(views)
                        .setContentIntent(Main.getPendingIntent(t))
                        .setSmallIcon(icon ? R.drawable.ic_abicon : R.drawable.ic_placeholder).setOngoing(true)
                        .build();
            }
        } else {
            int n = t.getNext();
            String sum = App.getContext().getString(R.string.leftText, Vakit.getByIndex(n - 1).getString(),
                    left_part[n], t.getLeft().substring(0, 5));

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                long left = t.getLeftMinutes(t.getNext());
                noti = new Notification.InboxStyle(
                        new Notification.Builder(App.getContext())
                                .setContentTitle(t.getName() + " (" + t.getSource() + ")").setContentText("")
                                .setLargeIcon(mAbIcon)
                                .setSmallIcon(icon
                                        ? (number ? Icon.createWithBitmap(getIconFromMinutes(left))
                                                : Icon.createWithResource(App.getContext(),
                                                        R.drawable.ic_abicon))
                                        : Icon.createWithResource(App.getContext(), R.drawable.ic_placeholder))
                                .setContentInfo(sum).setContentIntent(Main.getPendingIntent(t))
                                .setOngoing(true))
                                        .addLine(Vakit.getByIndex(0).getString() + ": " + Utils.fixTime(dt[0]))
                                        .addLine(Vakit.GUNES.getString() + ": " + Utils.fixTime(dt[1]))
                                        .addLine(Vakit.OGLE.getString() + ": " + Utils.fixTime(dt[2]))
                                        .addLine(Vakit.IKINDI.getString() + ": " + Utils.fixTime(dt[3]))
                                        .addLine(Vakit.AKSAM.getString() + ": " + Utils.fixTime(dt[4]))
                                        .addLine(Vakit.YATSI.getString() + ": " + Utils.fixTime(dt[5]))
                                        .setSummaryText("").build();
            } else {
                noti = new NotificationCompat.InboxStyle(new NotificationCompat.Builder(App.getContext())
                        .setContentTitle(t.getName() + " (" + t.getSource() + ")").setContentText("")
                        .setLargeIcon(mAbIcon)
                        .setSmallIcon(icon ? R.drawable.ic_abicon : R.drawable.ic_placeholder)
                        .setContentInfo(sum).setContentIntent(Main.getPendingIntent(t)).setOngoing(true))
                                .addLine(Vakit.getByIndex(0).getString() + ": " + Utils.fixTime(dt[0]))
                                .addLine(Vakit.GUNES.getString() + ": " + Utils.fixTime(dt[1]))
                                .addLine(Vakit.OGLE.getString() + ": " + Utils.fixTime(dt[2]))
                                .addLine(Vakit.IKINDI.getString() + ": " + Utils.fixTime(dt[3]))
                                .addLine(Vakit.AKSAM.getString() + ": " + Utils.fixTime(dt[4]))
                                .addLine(Vakit.YATSI.getString() + ": " + Utils.fixTime(dt[5]))
                                .setSummaryText("").build();
            }

        }

        if (Build.VERSION.SDK_INT >= 16) {
            noti.priority = Notification.PRIORITY_LOW;
        }
        noti.when = icon ? System.currentTimeMillis() : 0;
        try {
            nm.notify(id + "", NotIds.ONGOING, noti);
        } catch (Exception e) {
            Crashlytics.logException(e);
        }

    }

}

From source file:com.abhinavjhanwar.android.egg.neko.Cat.java

@RequiresApi(api = Build.VERSION_CODES.M)
public Icon createLargeIcon(Context context) {
    return Icon.createWithBitmap(createLargeBitmap(context));
}

From source file:com.android.contacts.DynamicShortcuts.java

private void addIconForContact(long id, String lookupKey, String displayName, ShortcutInfo.Builder builder) {
    Bitmap bitmap = getContactPhoto(id);
    if (bitmap == null) {
        bitmap = getFallbackAvatar(displayName, lookupKey);
    }//from  w w  w . ja va2s. c o  m
    final Icon icon;
    if (BuildCompat.isAtLeastO()) {
        icon = Icon.createWithAdaptiveBitmap(bitmap);
    } else {
        icon = Icon.createWithBitmap(bitmap);
    }

    builder.setIcon(icon);
}

From source file:de.gebatzens.sia.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(SIAApp.SIA_APP.school.getTheme());
    super.onCreate(savedInstanceState);
    Log.w("ggvp", "CREATE NEW MAINACTIVITY");
    //Debug.startMethodTracing("sia3");
    SIAApp.SIA_APP.activity = this;
    savedState = savedInstanceState;/* www.  j  a  v  a 2s  .  com*/

    final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments;

    Intent intent = getIntent();
    if (intent != null && intent.getStringExtra("fragment") != null) {
        FragmentData frag = fragments
                .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0);
        SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag));
    }

    if (intent != null && intent.getBooleanExtra("reload", false)) {
        SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex()));
        intent.removeExtra("reload");
    }

    setContentView(R.layout.activity_main);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    mContent = getFragment();
    transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment");
    transaction.commit();

    Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData());
    if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null)
        SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex()));

    if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) {
        ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm);
        summerNavigationPalm.setImageResource(R.drawable.summer_palm);
        ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image);
        summerBackgroundImage.setImageResource(R.drawable.summer_background);
    }

    mToolBar = (Toolbar) findViewById(R.id.toolbar);
    mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {

            switch (menuItem.getItemId()) {
            case R.id.action_refresh:
                ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true);
                SIAApp.SIA_APP.refreshAsync(new Runnable() {
                    @Override
                    public void run() {
                        ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh))
                                .setRefreshing(false);
                    }
                }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex()));
                return true;
            case R.id.action_settings:
                Intent i = new Intent(MainActivity.this, SettingsActivity.class);
                startActivityForResult(i, 1);
                return true;
            case R.id.action_addToCalendar:
                showExamDialog();
                return true;
            case R.id.action_help:
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle(getApplication().getString(R.string.help));
                builder.setMessage(getApplication().getString(R.string.exam_explain));
                builder.setPositiveButton(getApplication().getString(R.string.close),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                builder.create().show();
                return true;
            }

            return false;
        }
    });

    updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    mNavigationHeader = navigationView.getHeaderView(0);
    mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text);
    mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name);
    mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture);
    mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage());
    mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link);
    mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View viewIn) {
            mDrawerLayout.closeDrawers();
            Intent linkIntent = new Intent(Intent.ACTION_VIEW);
            linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website));
            startActivity(linkIntent);
        }
    });

    final Menu menu = navigationView.getMenu();
    menu.clear();
    for (int i = 0; i < fragments.size(); i++) {
        MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name);
        item.setIcon(fragments.get(i).getIconRes());
    }

    menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings);
    menu.setGroupCheckable(R.id.fragments, true, true);
    menu.setGroupCheckable(R.id.settings, false, false);

    final Menu navMenu = navigationView.getMenu();
    selectedItem = SIAApp.SIA_APP.getFragmentIndex();
    if (selectedItem != -1)
        navMenu.getItem(selectedItem).setChecked(true);

    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.settings_item) {
                mDrawerLayout.closeDrawers();
                Intent i = new Intent(MainActivity.this, SettingsActivity.class);
                startActivityForResult(i, 1);
            } else {
                final int index = menuItem.getOrder();
                if (SIAApp.SIA_APP.getFragmentIndex() != index) {
                    SIAApp.SIA_APP.setFragmentIndex(index);
                    menuItem.setChecked(true);
                    updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString());
                    mContent = getFragment();
                    Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out);
                    fadeOut.setAnimationListener(new Animation.AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation animation) {

                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment);
                            contentFrame.setVisibility(View.INVISIBLE);
                            if (fragments.get(index).getData() == null)
                                SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index));

                            //removeAllFragments();

                            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                            transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment");
                            transaction.commit();

                            snowView.updateSnow();
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });
                    FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment);
                    contentFrame.startAnimation(fadeOut);
                    mDrawerLayout.closeDrawers();
                } else {
                    mDrawerLayout.closeDrawers();
                }
            }
            return true;
        }
    });

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
        shortcutManager.removeAllDynamicShortcuts();

        for (int i = 0; i < fragments.size(); i++) {
            Drawable drawable = getDrawable(fragments.get(i).getIconRes());
            Bitmap icon;
            if (drawable instanceof VectorDrawable) {
                icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                        Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas(icon);
                drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
                drawable.draw(canvas);
            } else {
                icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes());
            }

            Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(),
                    Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(connectedIcon);
            Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setColor(Color.parseColor("#f5f5f5"));
            canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint);
            paint.setColorFilter(
                    new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP));
            canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f,
                    icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f),
                    paint);

            Intent newTaskIntent = new Intent(this, MainActivity.class);
            newTaskIntent.setAction(Intent.ACTION_MAIN);
            newTaskIntent.putExtra("fragment", fragments.get(i).type.toString());

            ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name)
                    .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name)
                    .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build();

            shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
        }
    }

    if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) {
        if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) {
            TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3)
                    .show(getSupportFragmentManager(), "upgrade_dialog");
        }

        SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply();
    }

    snowView = (SnowView) findViewById(R.id.snow_view);

    shareToolbar = (Toolbar) findViewById(R.id.share_toolbar);
    shareToolbar.getMenu().clear();
    shareToolbar.inflateMenu(R.menu.share_toolbar_menu);
    shareToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            toggleShareToolbar(false);
            for (Shareable s : MainActivity.this.shared) {
                s.setMarked(false);
            }
            MainActivity.this.shared.clear();

            mContent.updateFragment();
        }
    });

    shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            toggleShareToolbar(false);

            HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>();

            for (Shareable s : MainActivity.this.shared) {
                ArrayList<Shareable> list = dates.get(s.getDate());
                if (list == null) {
                    list = new ArrayList<Shareable>();
                    dates.put(s.getDate(), list);
                }

                list.add(s);

                s.setMarked(false);
            }
            MainActivity.this.shared.clear();

            List<Date> dateList = new ArrayList<Date>(dates.keySet());
            Collections.sort(dateList);
            String content = "";

            for (Date key : dateList) {
                content += SubstListAdapter.translateDay(key) + "\n\n";

                Collections.sort(dates.get(key));
                for (Shareable s : dates.get(key)) {
                    content += s.getShareContent() + "\n";
                }

                content += "\n";
            }

            content = content.substring(0, content.length() - 1);

            mContent.updateFragment();

            if (item.getItemId() == R.id.action_copy) {
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

                ClipData clip = ClipData.newPlainText(getString(R.string.entries), content);
                clipboard.setPrimaryClip(clip);
            } else if (item.getItemId() == R.id.action_share) {
                Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_TEXT, content);
                sendIntent.setType("text/plain");
                startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
            }

            return true;
        }
    });

    if (shared.size() > 0) {
        shareToolbar.setVisibility(View.VISIBLE);
        updateShareToolbarText();
    }

    // if a fragment is opened via a notification or a shortcut reset the shared entries
    // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment
    if (intent != null && intent.hasExtra("fragment")) {
        resetShareToolbar();
        intent.removeExtra("fragment");
    }

}