Example usage for android.widget LinearLayout setBackgroundColor

List of usage examples for android.widget LinearLayout setBackgroundColor

Introduction

In this page you can find the example usage for android.widget LinearLayout setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:net.ustyugov.jtalk.activity.vcard.SetVcardActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);
    setContentView(R.layout.paged_activity);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle("vCard");

    LinearLayout linear = (LinearLayout) findViewById(R.id.linear);
    linear.setBackgroundColor(Colors.BACKGROUND);

    account = getIntent().getStringExtra("account");
    vcard = service.getVCard(account);//from   w w  w  .  ja  va 2s .c o m
    if (vcard == null) {
        VCard vCard = new VCard();
        try {
            vCard.load(service.getConnection(account), account);
        } catch (XMPPException ignored) {
        }
        service.setVCard(account, vCard);
    }

    LayoutInflater inflater = LayoutInflater.from(this);
    View aboutPage = inflater.inflate(R.layout.set_vcard_about, null);
    View homePage = inflater.inflate(R.layout.set_vcard_home, null);
    View workPage = inflater.inflate(R.layout.set_vcard_work, null);
    View photoPage = inflater.inflate(R.layout.set_vcard_avatar, null);

    first = (EditText) aboutPage.findViewById(R.id.firstname);
    middle = (EditText) aboutPage.findViewById(R.id.middlename);
    last = (EditText) aboutPage.findViewById(R.id.lastname);
    nick = (EditText) aboutPage.findViewById(R.id.nickname);
    bday = (EditText) aboutPage.findViewById(R.id.bday);
    url = (EditText) aboutPage.findViewById(R.id.url);
    about = (EditText) aboutPage.findViewById(R.id.desc);

    ctry = (EditText) homePage.findViewById(R.id.ctry);
    locality = (EditText) homePage.findViewById(R.id.locality);
    street = (EditText) homePage.findViewById(R.id.street);
    emailHome = (EditText) homePage.findViewById(R.id.homemail);
    phoneHome = (EditText) homePage.findViewById(R.id.homephone);

    org = (EditText) workPage.findViewById(R.id.org);
    unit = (EditText) workPage.findViewById(R.id.unit);
    role = (EditText) workPage.findViewById(R.id.role);
    emailWork = (EditText) workPage.findViewById(R.id.workmail);
    phoneWork = (EditText) workPage.findViewById(R.id.workphone);

    av = (ImageView) photoPage.findViewById(R.id.av);
    load = (Button) photoPage.findViewById(R.id.load_button);
    load.setOnClickListener(this);
    clear = (Button) photoPage.findViewById(R.id.clear_button);
    clear.setOnClickListener(this);

    aboutPage.setTag(getString(R.string.About));
    homePage.setTag(getString(R.string.Home));
    workPage.setTag(getString(R.string.Work));
    photoPage.setTag(getString(R.string.Photo));

    ArrayList<View> mPages = new ArrayList<View>();
    mPages.add(aboutPage);
    mPages.add(homePage);
    mPages.add(workPage);
    mPages.add(photoPage);

    MainPageAdapter adapter = new MainPageAdapter(mPages);
    ViewPager mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(adapter);
    mPager.setCurrentItem(0);

    TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
    mTitleIndicator.setTextColor(0xFF555555);
    mTitleIndicator.setViewPager(mPager);
    mTitleIndicator.setCurrentItem(0);

    update();
}

From source file:net.ustyugov.jtalk.activity.muc.Bookmarks.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    service = JTalkService.getInstance();
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);
    setTitle(R.string.Bookmarks);/*w  w w  .  j av a2 s.  com*/
    getActionBar().setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.paged_activity);

    LinearLayout linear = (LinearLayout) findViewById(R.id.linear);
    linear.setBackgroundColor(Colors.BACKGROUND);

    LayoutInflater inflater = LayoutInflater.from(this);
    MainPageAdapter adapter = new MainPageAdapter(mPages);

    Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null,
            AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null);
    if (cursor != null && cursor.getCount() > 0) {
        cursor.moveToFirst();
        do {
            final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim();

            View bookPage = inflater.inflate(R.layout.list_activity, null);
            bookPage.setTag(account);
            mPages.add(bookPage);

            ListView list = (ListView) bookPage.findViewById(R.id.list);
            list.setDividerHeight(0);
            list.setCacheColorHint(0x00000000);
            list.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                    RosterItem item = (RosterItem) parent.getItemAtPosition(position);
                    BookmarkedConference bc = (BookmarkedConference) item.getObject();
                    String account = item.getAccount();
                    String jid = bc.getJid();
                    String pass = bc.getPassword();
                    String nick = service.getDerivedNick(service.getConnection(account).getUser(), bc);
                    if (!service.getJoinedConferences().containsKey(jid)) {
                        Toast.makeText(Bookmarks.this, "Attempt joining to " + jid, Toast.LENGTH_SHORT).show();
                        service.joinRoom(account, jid, nick, pass);
                    }
                }
            });

            list.setOnItemLongClickListener(new OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
                    final RosterItem item = (RosterItem) parent.getItemAtPosition(position);
                    CharSequence[] items = new CharSequence[3];
                    items[0] = getString(R.string.Users);
                    items[1] = getString(R.string.Edit);
                    items[2] = getString(R.string.Remove);

                    AlertDialog.Builder builder = new AlertDialog.Builder(Bookmarks.this);
                    builder.setTitle(R.string.Actions);
                    builder.setItems(items, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            switch (which) {
                            case 0:
                                MucDialogs.showUsersDialog(Bookmarks.this, account,
                                        (BookmarkedConference) item.getObject());
                                break;
                            case 1:
                                BookmarksDialogs.EditDialog(Bookmarks.this, account,
                                        (BookmarkedConference) item.getObject());
                                break;
                            case 2:
                                try {
                                    BookmarkedConference bc = (BookmarkedConference) item.getObject();
                                    BookmarkManager bm = BookmarkManager
                                            .getBookmarkManager(service.getConnection(account));
                                    bm.removeBookmarkedConference(bc.getJid());
                                } catch (Exception e) {
                                    Log.e("Remove", e.getLocalizedMessage());
                                }
                                updateBookmarks();
                                break;
                            }
                        }
                    });
                    builder.create().show();
                    return true;
                }
            });

        } while (cursor.moveToNext());
        cursor.close();
    }

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(adapter);
    mPager.setCurrentItem(0);

    TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
    mTitleIndicator.setTextColor(0xFF555555);
    mTitleIndicator.setViewPager(mPager);
}

From source file:org.telegram.ui.IdenticonActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from  w  w  w. j ava 2 s.c om
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new LinearLayout(context);
    LinearLayout linearLayout = (LinearLayout) fragmentView;
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setWeightSum(100);
    linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20),
            AndroidUtilities.dp(20));
    linearLayout.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    ImageView identiconView = new ImageView(context);
    identiconView.setScaleType(ImageView.ScaleType.FIT_XY);
    frameLayout.addView(identiconView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background));
    frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10));
    linearLayout.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    TextView textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLinksClickable(true);
    textView.setClickable(true);
    textView.setMovementMethod(new LinkMovementMethodMy());
    //textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR);
    textView.setGravity(Gravity.CENTER);
    frameLayout.addView(textView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
    if (encryptedChat != null) {
        IdenticonDrawable drawable = new IdenticonDrawable();
        identiconView.setImageDrawable(drawable);
        drawable.setEncryptedChat(encryptedChat);
        TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
        SpannableStringBuilder hash = new SpannableStringBuilder();
        if (encryptedChat.key_hash.length > 16) {
            String hex = Utilities.bytesToHex(encryptedChat.key_hash);
            for (int a = 0; a < 32; a++) {
                if (a != 0) {
                    if (a % 8 == 0) {
                        hash.append('\n');
                    } else if (a % 4 == 0) {
                        hash.append(' ');
                    }
                }
                hash.append(hex.substring(a * 2, a * 2 + 2));
                hash.append(' ');
            }
            hash.append("\n\n");
        }
        hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription",
                R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
        final String url = "telegram.org";
        int index = hash.toString().indexOf(url);
        if (index != -1) {
            hash.setSpan(
                    new URLSpanReplacement(
                            LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)),
                    index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        textView.setText(hash);
    }

    return fragmentView;
}

From source file:org.onebusaway.android.report.ui.SimpleArrivalListFragment.java

private void loadArrivalList(ObaArrivalInfo[] info, final ObaReferences refs, long currentTime) {
    LinearLayout contentLayout = (LinearLayout) getActivity().findViewById(R.id.simple_arrival_content);
    contentLayout.removeAllViews();//from   w  w w  .  j  a va  2 s  .  c o m

    ArrayList<ArrivalInfo> arrivalInfos = ArrivalInfoUtils.convertObaArrivalInfo(getActivity(), info,
            new ArrayList<String>(), currentTime, false);

    for (ArrivalInfo stopInfo : arrivalInfos) {

        final ObaArrivalInfo arrivalInfo = stopInfo.getInfo();

        LayoutInflater inflater = LayoutInflater.from(getActivity());
        LinearLayout view = (LinearLayout) inflater.inflate(R.layout.arrivals_list_item, null, false);
        view.setBackgroundColor(getResources().getColor(R.color.material_background));
        TextView route = (TextView) view.findViewById(R.id.route);
        TextView destination = (TextView) view.findViewById(R.id.destination);
        TextView time = (TextView) view.findViewById(R.id.time);
        TextView status = (TextView) view.findViewById(R.id.status);
        TextView etaView = (TextView) view.findViewById(R.id.eta);
        TextView minView = (TextView) view.findViewById(R.id.eta_min);
        ViewGroup realtimeView = (ViewGroup) view.findViewById(R.id.eta_realtime_indicator);

        view.findViewById(R.id.more_horizontal).setVisibility(View.INVISIBLE);
        view.findViewById(R.id.route_favorite).setVisibility(View.INVISIBLE);

        String routeShortName = arrivalInfo.getShortName();
        route.setText(routeShortName);
        UIUtils.maybeShrinkRouteName(getActivity(), route, routeShortName);

        destination.setText(UIUtils.formatDisplayText(arrivalInfo.getHeadsign()));
        status.setText(stopInfo.getStatusText());

        long eta = stopInfo.getEta();
        if (eta == 0) {
            etaView.setText(R.string.stop_info_eta_now);
            minView.setVisibility(View.GONE);
        } else {
            etaView.setText(String.valueOf(eta));
            minView.setVisibility(View.VISIBLE);
        }

        status.setBackgroundResource(R.drawable.round_corners_style_b_status);
        GradientDrawable d = (GradientDrawable) status.getBackground();

        Integer colorCode = stopInfo.getColor();
        int color = getActivity().getResources().getColor(colorCode);
        if (stopInfo.getPredicted()) {
            // Show real-time indicator
            UIUtils.setRealtimeIndicatorColorByResourceCode(realtimeView, colorCode,
                    android.R.color.transparent);
            realtimeView.setVisibility(View.VISIBLE);
        } else {
            realtimeView.setVisibility(View.INVISIBLE);
        }

        etaView.setTextColor(color);
        minView.setTextColor(color);
        d.setColor(color);

        // Set padding on status view
        int pSides = UIUtils.dpToPixels(getActivity(), 5);
        int pTopBottom = UIUtils.dpToPixels(getActivity(), 2);
        status.setPadding(pSides, pTopBottom, pSides, pTopBottom);

        time.setText(DateUtils.formatDateTime(getActivity(), stopInfo.getDisplayTime(),
                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT));
        View reminder = view.findViewById(R.id.reminder);
        reminder.setVisibility(View.GONE);

        contentLayout.addView(view);

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String agencyName = findAgencyNameByRouteId(refs, arrivalInfo.getRouteId());
                mCallback.onArrivalItemClicked(arrivalInfo, agencyName);
            }
        });
    }
}

From source file:com.cw.litenote.note_add.Note_addText.java

void UI_init_text() {
    titleEditText = (EditText) findViewById(R.id.edit_title);
    bodyEditText = (EditText) findViewById(R.id.edit_body);
    linkEditText = (EditText) findViewById(R.id.edit_link);

    int focusFolder_tableId = Pref.getPref_focusView_folder_tableId(this);
    DB_folder db = new DB_folder(MainAct.mAct, focusFolder_tableId);
    int style = db.getPageStyle(TabsHost.getFocus_tabPos(), true);

    LinearLayout block = (LinearLayout) findViewById(R.id.edit_title_block);
    if (block != null)
        block.setBackgroundColor(ColorSet.mBG_ColorArray[style]);

    //set title color
    titleEditText.setTextColor(ColorSet.mText_ColorArray[style]);
    titleEditText.setBackgroundColor(ColorSet.mBG_ColorArray[style]);

    //set body color
    bodyEditText.setTextColor(ColorSet.mText_ColorArray[style]);
    bodyEditText.setBackgroundColor(ColorSet.mBG_ColorArray[style]);

    //set link color
    linkEditText.setTextColor(ColorSet.mText_ColorArray[style]);
    linkEditText.setBackgroundColor(ColorSet.mBG_ColorArray[style]);
}

From source file:com.sentaroh.android.Utilities.Dialog.ProgressSpinDialogFragment.java

private void initViewWidget() {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "initViewWidget");

    mDialog.setContentView(R.layout.progress_spin_dlg_fragment);

    mThemeColorList = ThemeUtil.getThemeColorList(getActivity());

    LinearLayout title_view = (LinearLayout) mDialog.findViewById(R.id.progress_spin_dlg_fragment_ll_title);
    title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color);

    LinearLayout dlg_view = (LinearLayout) mDialog.findViewById(R.id.progress_spin_dlg_fragment);
    dlg_view.setBackgroundColor(mThemeColorList.dialog_msg_background_color);

    TextView tv_title = (TextView) mDialog.findViewById(R.id.progress_spin_dlg_fragment_title);
    tv_title.setTextColor(mThemeColorList.text_color_dialog_title);
    tv_title.setText(mDialogTitle);//from ww w .j  av a2s  . c om

    TextView tv_msg = (TextView) mDialog.findViewById(R.id.progress_spin_dlg_fragment_msg);
    tv_msg.setText(mDialogMsgText);

    final Button btnCancel = (Button) mDialog.findViewById(R.id.progress_spin_dlg_fragment_btn_cancel);

    //      CommonDialog.setDlgBoxSizeCompact(mDialog);

    // CANCEL?
    btnCancel.setText(mDialogCanTitleInit);
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mDialogCancelBtnEnabled = false;
            btnCancel.setEnabled(false);
            btnCancel.setText(mDialogCanTitlePressed);
            if (mNotifyEvent != null)
                mNotifyEvent.notifyToListener(false, new Object[] { mFragment });
        }
    });
}

From source file:uguess.qucai.com.merchant.business.common.ui.PictureViewPagerActivity.java

/**
 * ?ActionBar/* w  w w.  j av a2  s.  com*/
 */
private void initActionBar() {
    //?actionbar??
    QCActionBar actionBar = (QCActionBar) findViewById(R.id.action_bar);
    ImageView back = (ImageView) actionBar.findViewById(R.id.bar_left);
    LinearLayout iconLayout = (LinearLayout) actionBar.findViewById(R.id.iconLinear);
    LinearLayout operationLayout = (LinearLayout) actionBar.findViewById(R.id.operatorLinear);
    back.setImageResource(R.drawable.ic_common_back);
    actionBar.setTitle(null);
    actionBar.setBackground(getResources().getColor(R.color.transparent));
    iconLayout.setBackgroundColor(getResources().getColor(R.color.transparent));
    actionBar.showSystemBar();
    //
    iconLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    operationLayout.setVisibility(View.INVISIBLE);
}

From source file:com.sentaroh.android.Utilities.Dialog.ProgressBarDialogFragment.java

private void initViewWidget() {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "initViewWidget");

    mDialog.setContentView(R.layout.progress_bar_dlg_fragment);

    mThemeColorList = ThemeUtil.getThemeColorList(getActivity());

    LinearLayout title_view = (LinearLayout) mDialog.findViewById(R.id.progress_bar_dlg_fragment_ll_title);
    title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color);

    LinearLayout dlg_view = (LinearLayout) mDialog.findViewById(R.id.progress_bar_dlg_fragment);
    dlg_view.setBackgroundColor(mThemeColorList.dialog_msg_background_color);

    TextView tv_title = (TextView) mDialog.findViewById(R.id.progress_bar_dlg_fragment_title);
    tv_title.setTextColor(mThemeColorList.text_color_dialog_title);
    tv_title.setText(mDialogTitle);//from   w  ww . ja v a  2s . co  m

    TextView tv_msg = (TextView) mDialog.findViewById(R.id.progress_bar_dlg_fragment_msg);
    if (mDialogMsgText.equals("")) {
        tv_msg.setVisibility(TextView.GONE);
    } else {
        tv_msg.setVisibility(TextView.VISIBLE);
        tv_msg.setText(mDialogMsgText);
    }

    final Button btnCancel = (Button) mDialog.findViewById(R.id.progress_bar_dlg_fragment_btn_cancel);

    btnCancel.setText(mDialogCanTitleInit);

    //      CommonDialog.setDlgBoxSizeCompact(mDialog);

    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mDialogCancelBtnEnabled = false;
            btnCancel.setEnabled(false);
            btnCancel.setText(mDialogCanTitlePressed);
            if (mNotifyEvent != null)
                mNotifyEvent.notifyToListener(false, new Object[] { mFragment });
        }
    });
}

From source file:com.farmerbb.notepad.activity.NoteEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_note_edit);

    // Apply theme
    SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    LinearLayout noteViewEdit = findViewById(R.id.noteViewEdit);

    if (theme.contains("light"))
        noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background));

    if (theme.contains("dark"))
        noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));

    // Set action bar elevation
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation));

    if (!(getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment)) {
        // Handle intents
        Intent intent = getIntent();//from www  . j  av  a 2  s  . co m
        String action = intent.getAction();
        String type = intent.getType();

        // Intent sent through an external application
        if (Intent.ACTION_SEND.equals(action) && type != null) {
            if ("text/plain".equals(type)) {
                external = getExternalContent();
                if (external != null) {
                    newNote();
                } else {
                    showToast(R.string.loading_external_file);
                    finish();
                }
            } else {
                showToast(R.string.loading_external_file);
                finish();
            }

            // Intent sent through Google Now "note to self"
        } else if ("com.google.android.gm.action.AUTO_SEND".equals(action) && type != null) {
            if ("text/plain".equals(type)) {
                external = getExternalContent();
                if (external != null) {
                    try {
                        // Write note to disk
                        FileOutputStream output = openFileOutput(String.valueOf(System.currentTimeMillis()),
                                Context.MODE_PRIVATE);
                        output.write(external.getBytes());
                        output.close();

                        // Show toast notification and finish
                        showToast(R.string.note_saved);
                        finish();
                    } catch (IOException e) {
                        // Show error message as toast if file fails to save
                        showToast(R.string.failed_to_save);
                        finish();
                    }
                }
            }
        } else if (Intent.ACTION_EDIT.equals(action) && "text/plain".equals(type)) {
            external = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (external != null) {
                newNote();
                return;
            }
            finish();
        } else if (Intent.ACTION_VIEW.equals(action) && "text/plain".equals(type)) {
            try {
                InputStream in = getContentResolver().openInputStream(intent.getData());
                Reader rd = new InputStreamReader(in, "UTF-8");
                char[] buffer = new char[4096];
                int len;
                StringBuilder sb = new StringBuilder();
                while ((len = rd.read(buffer)) != -1) {
                    sb.append(buffer, 0, len);
                }
                rd.close();
                in.close();
                external = sb.toString();
            } catch (Exception e) {
                // show msg error loading data?
            }
            if (external != null) {
                newNote();
                return;
            }
            finish();
        } else
            newNote();
    }
}

From source file:com.sentaroh.android.Utilities.Dialog.MessageDialogFragment.java

private void initViewWidget() {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "initViewWidget");

    mDialog.setContentView(R.layout.common_dialog);

    ImageView title_icon = (ImageView) mDialog.findViewById(R.id.common_dialog_icon);
    TextView title = (TextView) mDialog.findViewById(R.id.common_dialog_title);
    LinearLayout title_view = (LinearLayout) mDialog.findViewById(R.id.common_dialog_title_view);
    title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color);
    ScrollView msg_view = (ScrollView) mDialog.findViewById(R.id.common_dialog_msg_view);
    msg_view.setBackgroundColor(mThemeColorList.dialog_msg_background_color);

    LinearLayout btn_view = (LinearLayout) mDialog.findViewById(R.id.common_dialog_btn_view);
    btn_view.setBackgroundColor(mThemeColorList.dialog_msg_background_color);

    if (mDialogTitleType.equals("I")) {
        title_icon.setImageResource(R.drawable.dialog_information);
        title.setTextColor(mThemeColorList.text_color_info);
    } else if (mDialogTitleType.equals("W")) {
        title_icon.setImageResource(R.drawable.dialog_warning);
        //         title.setTextColor(Color.YELLOW);
    } else if (mDialogTitleType.equals("E")) {
        title_icon.setImageResource(R.drawable.dialog_error);
        //         title.setTextColor(mThemeColorList.text_color_error);
    }//  w  w  w.j  a v a2 s .  c  om
    title.setTextColor(mThemeColorList.text_color_info);
    title.setText(mDialogTitle);
    TextView msg_text = (TextView) mDialog.findViewById(R.id.common_dialog_msg);
    if (mDialogMsgText.equals(""))
        msg_text.setVisibility(View.GONE);
    else {
        msg_text.setText(mDialogMsgText);
        msg_text.setTextColor(mThemeColorList.text_color_primary);
        msg_text.setBackgroundColor(mThemeColorList.dialog_msg_background_color);
    }

    final Button btnOk = (Button) mDialog.findViewById(R.id.common_dialog_btn_ok);
    final Button btnCancel = (Button) mDialog.findViewById(R.id.common_dialog_btn_cancel);
    if (mDialogTypeNegative)
        btnCancel.setVisibility(View.VISIBLE);
    else
        btnCancel.setVisibility(View.GONE);

    if (Build.VERSION.SDK_INT <= 10 && mThemeColorList.theme_is_light) {
        btnOk.setTextColor(mThemeColorList.text_color_info);
        btnCancel.setTextColor(mThemeColorList.text_color_info);
    }

    //      CommonDialog.setDlgBoxSizeCompact(mDialog);

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //            mDialog.dismiss();
            mFragment.dismiss();
            if (mNotifyEvent != null)
                mNotifyEvent.notifyToListener(true, null);
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //            mDialog.dismiss();
            mFragment.dismiss();
            if (mNotifyEvent != null)
                mNotifyEvent.notifyToListener(false, null);
        }
    });
}