Search in sources :

Example 1 with KeyboardControlEditText

use of org.qii.weiciyuan.support.lib.KeyboardControlEditText in project weiciyuan by qii.

the class WriteWeiboActivity method buildInterface.

private void buildInterface() {
    setContentView(R.layout.writeweiboactivity_layout);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setTitle(R.string.write_weibo);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    int avatarWidth = getResources().getDimensionPixelSize(R.dimen.timeline_avatar_width);
    int avatarHeight = getResources().getDimensionPixelSize(R.dimen.timeline_avatar_height);
    Bitmap bitmap = ImageUtility.getWriteWeiboRoundedCornerPic(GlobalContext.getInstance().getAccountBean().getInfo().getAvatar_large(), avatarWidth, avatarHeight, FileLocationMethod.avatar_large);
    if (bitmap == null) {
        bitmap = ImageUtility.getWriteWeiboRoundedCornerPic(GlobalContext.getInstance().getAccountBean().getInfo().getProfile_image_url(), avatarWidth, avatarHeight, FileLocationMethod.avatar_small);
    }
    if (bitmap != null) {
        actionBar.setIcon(new BitmapDrawable(getResources(), bitmap));
    }
    View title = getLayoutInflater().inflate(R.layout.writeweiboactivity_title_layout, null);
    TextView contentNumber = (TextView) title.findViewById(R.id.content_number);
    contentNumber.setVisibility(View.GONE);
    haveGPS = (ImageView) title.findViewById(R.id.have_gps);
    final PopupMenu popupMenu = new PopupMenu(this, haveGPS);
    popupMenu.inflate(R.menu.popmenu_gps);
    haveGPS.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            popupMenu.show();
        }
    });
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch(item.getItemId()) {
                case R.id.menu_view:
                    StringBuilder geoUriString = new StringBuilder().append("geo:" + geoBean.getLat() + "," + geoBean.getLon());
                    if (!TextUtils.isEmpty(location)) {
                        geoUriString.append("?q=").append(location);
                    }
                    Uri geoUri = Uri.parse(geoUriString.toString());
                    Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri);
                    if (Utility.isIntentSafe(WriteWeiboActivity.this, mapCall)) {
                        startActivity(mapCall);
                    } else {
                        Toast.makeText(WriteWeiboActivity.this, R.string.your_device_dont_have_any_map_app_to_open_gps_info, Toast.LENGTH_SHORT).show();
                    }
                    break;
                case R.id.menu_delete:
                    haveGPS.setVisibility(View.GONE);
                    geoBean = null;
                    break;
            }
            return true;
        }
    });
    actionBar.setCustomView(title, new ActionBar.LayoutParams(Gravity.RIGHT));
    actionBar.setDisplayShowCustomEnabled(true);
    content = ((KeyboardControlEditText) findViewById(R.id.status_new_content));
    content.addTextChangedListener(new TextNumLimitWatcher((TextView) findViewById(R.id.menu_send), content, this));
    content.setDrawingCacheEnabled(true);
    AutoCompleteAdapter adapter = new AutoCompleteAdapter(this, content, (ProgressBar) title.findViewById(R.id.have_suggest_progressbar));
    content.setAdapter(adapter);
    preview = ViewUtility.findViewById(this, R.id.status_image_preview);
    View.OnClickListener onClickListener = new BottomButtonClickListener();
    findViewById(R.id.menu_at).setOnClickListener(onClickListener);
    findViewById(R.id.menu_emoticon).setOnClickListener(onClickListener);
    findViewById(R.id.menu_add_pic).setOnClickListener(onClickListener);
    findViewById(R.id.menu_send).setOnClickListener(onClickListener);
    CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_at), R.string.at_other);
    CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_emoticon), R.string.add_emoticon);
    CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_add_pic), R.string.add_pic);
    CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_send), R.string.send);
    smiley = (SmileyPicker) findViewById(R.id.smiley_picker);
    smiley.setEditText(WriteWeiboActivity.this, ((LinearLayout) findViewById(R.id.root_layout)), content);
    container = (RelativeLayout) findViewById(R.id.container);
    content.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            hideSmileyPicker(true);
        }
    });
}
Also used : MenuItem(android.view.MenuItem) Intent(android.content.Intent) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) KeyboardControlEditText(org.qii.weiciyuan.support.lib.KeyboardControlEditText) TextView(android.widget.TextView) ActionBar(android.app.ActionBar) LinearLayout(android.widget.LinearLayout) PopupMenu(android.widget.PopupMenu)

Aggregations

ActionBar (android.app.ActionBar)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Uri (android.net.Uri)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 PopupMenu (android.widget.PopupMenu)1 TextView (android.widget.TextView)1 KeyboardControlEditText (org.qii.weiciyuan.support.lib.KeyboardControlEditText)1