List of usage examples for android.view Gravity END
int END
To view the source code for android.view Gravity END.
Click Source Link
From source file:com.wanderingcan.persistentsearch.PersistentSearchView.java
@SuppressWarnings("deprecation") private void initialize(Context context, AttributeSet attrs, int defStyleAttr) { mNavIcon = new ImageButton(context); mEndIcon = new ImageButton(context); mSearchText = new EditText(context); mSearchMenuView = new SearchMenuView(context); mDivider = new View(context); mDivider.setVisibility(GONE);// w w w . jav a2 s . c o m mPresenter = new SearchMenuPresenter(context, new SearchMenuListener()); mSearchMenuView.setAdapter(mPresenter.mAdapter); mSearchMenuView.addItemDecoration(new DividerItemDecoration(context, attrs)); int[] attr = { android.R.attr.listDivider }; TypedArray ta = context.obtainStyledAttributes(attr); Drawable divider = ta.getDrawable(0); ta.recycle(); mOpened = false; mShowClearDrawable = false; mShowMenu = true; //Set up CardView setUseCompatPadding(true); setFocusable(true); setFocusableInTouchMode(true); //Set up TextView if (Build.VERSION.SDK_INT >= 16) { mSearchText.setBackground(null); mNavIcon.setBackground(null); mEndIcon.setBackground(null); mDivider.setBackground(divider); } else { mSearchText.setBackgroundDrawable(null); mNavIcon.setBackgroundDrawable(null); mEndIcon.setBackgroundDrawable(null); mDivider.setBackgroundDrawable(divider); } mSearchText.setSingleLine(); mHintVisible = false; mSearchText.setOnFocusChangeListener(new SearchFocusListener()); mSearchText.setOnEditorActionListener(new EditTextEditorAction()); mSearchText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); mSearchText.addTextChangedListener(new EditTextTextWatcher()); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PersistentSearchView, defStyleAttr, 0); Drawable drawable = a.getDrawable(R.styleable.PersistentSearchView_navSrc); setNavigationDrawable(drawable); mNavIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); mNavIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mIconListener != null) { mIconListener.OnNavigationIconClick(); } } }); drawable = a.getDrawable(R.styleable.PersistentSearchView_endSrc); setEndDrawable(drawable); mClearDrawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_action_cancel); mEndIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); mEndIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mShowClearDrawable) { //Clears the text mSearchText.setText(EMPTY); } else { if (mIconListener != null) { mIconListener.OnEndIconClick(); } } } }); mHint = a.getText(R.styleable.PersistentSearchView_hint); mHintAlwaysVisible = a.getBoolean(R.styleable.PersistentSearchView_hintAlwaysActive, false); if (mHintAlwaysVisible) { mSearchText.setHint(mHint); } a.recycle(); Resources res = context.getResources(); int imageDimen = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_dimen); mImageMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_side_margin); int imageTopMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_top_margin); //Sets all of the locations of the views CardView.LayoutParams lpNav = generateDefaultLayoutParams(); lpNav.width = lpNav.height = imageDimen; CardView.LayoutParams lpEnd = (LayoutParams) generateLayoutParams(lpNav); lpNav.gravity = Gravity.START; lpEnd.gravity = Gravity.END; if (Build.VERSION.SDK_INT >= 17) { mNavIcon.setPaddingRelative(mImageMargin, imageTopMargin, mImageMargin / 2, imageTopMargin); mEndIcon.setPaddingRelative(mImageMargin / 2, imageTopMargin, mImageMargin, imageTopMargin); } else { mNavIcon.setPadding(mImageMargin, imageTopMargin, mImageMargin / 2, imageTopMargin); mEndIcon.setPadding(mImageMargin / 2, imageTopMargin, mImageMargin, imageTopMargin); } CardView.LayoutParams lpText = generateDefaultLayoutParams(); lpText.gravity = Gravity.TOP; lpText.height = lpNav.topMargin + lpNav.height; mTextMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_text_margin); if (Build.VERSION.SDK_INT >= 17) { lpText.setMarginStart(mTextMargin); lpText.setMarginEnd(mTextMargin); } else { lpText.leftMargin = lpText.rightMargin = mTextMargin; } lpText = setupSearchTextMargin(lpText); CardView.LayoutParams lpMenu = generateDefaultLayoutParams(); lpMenu.topMargin = lpNav.topMargin + lpNav.height; lpMenu.height = RecyclerView.LayoutParams.WRAP_CONTENT; CardView.LayoutParams lpDivider = generateDefaultLayoutParams(); if (divider != null) { lpDivider.height = divider.getIntrinsicHeight(); } lpDivider.topMargin = lpNav.topMargin + lpNav.height; //Adds the views to the PersistentSearchView addView(mNavIcon, lpNav); addView(mEndIcon, lpEnd); addView(mSearchText, lpText); addView(mSearchMenuView, lpMenu); addView(mDivider, lpDivider); }
From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_ticker: mDrawerLayout.openDrawer(Gravity.END); }/*from www . j a va 2 s . c om*/ return super.onOptionsItemSelected(item); }
From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java
public boolean isRightVisible() { return layout.isDrawerVisible(Gravity.END); }
From source file:android.support.transition.Slide.java
/** * Change the edge that Views appear and disappear from. * * @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of * {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP}, * {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM}, * {@link android.view.Gravity#START}, {@link android.view.Gravity#END}. *//* ww w . j a v a 2 s .c om*/ public void setSlideEdge(@GravityFlag int slideEdge) { switch (slideEdge) { case Gravity.LEFT: mSlideCalculator = sCalculateLeft; break; case Gravity.TOP: mSlideCalculator = sCalculateTop; break; case Gravity.RIGHT: mSlideCalculator = sCalculateRight; break; case Gravity.BOTTOM: mSlideCalculator = sCalculateBottom; break; case Gravity.START: mSlideCalculator = sCalculateStart; break; case Gravity.END: mSlideCalculator = sCalculateEnd; break; default: throw new IllegalArgumentException("Invalid slide direction"); } mSlideEdge = slideEdge; SidePropagation propagation = new SidePropagation(); propagation.setSide(slideEdge); setPropagation(propagation); }
From source file:io.palaima.debugdrawer.DebugWidgetsFrame.java
/** * helper to extend the layoutParams of the drawer *///from w ww .j ava 2 s . c o m private DrawerLayout.LayoutParams processDrawerLayoutParams(DrawerLayout.LayoutParams params) { if (params != null) { if (drawerGravity != 0 && (drawerGravity == Gravity.RIGHT || drawerGravity == Gravity.END)) { params.rightMargin = 0; if (Build.VERSION.SDK_INT >= 17) { params.setMarginEnd(0); } params.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.dd_debug_drawer_margin); if (Build.VERSION.SDK_INT >= 17) { params.setMarginEnd( activity.getResources().getDimensionPixelSize(R.dimen.dd_debug_drawer_margin)); } } params.width = UIUtils.getOptimalDrawerWidth(activity); } return params; }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public void setUpDrawer(int number, final String actName) { int currentAccount = sharedPrefs.getInt("current_account", 1); for (int i = 0; i < TimelinePagerAdapter.MAX_EXTRA_PAGES; i++) { String pageIdentifier = "account_" + currentAccount + "_page_" + (i + 1); int type = sharedPrefs.getInt(pageIdentifier, AppSettings.PAGE_TYPE_NONE); if (type != AppSettings.PAGE_TYPE_NONE) { number++;//from w w w. j a v a2 s . c o m } } try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } actionBar = getActionBar(); adapter = new MainDrawerArrayAdapter(context); MainDrawerArrayAdapter.setCurrent(context, number); TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button }); openMailResource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button }); closedMailResource = a.getResourceId(0, 0); a.recycle(); mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name); HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name); backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image); profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact); final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options); final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout); final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton); drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list); notificationList = (EnhancedListView) findViewById(R.id.notificationList); try { mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ) { public void onDrawerClosed(View view) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (logoutVisible) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); logoutLayout.setVisibility(View.GONE); drawerList.setVisibility(View.VISIBLE); logoutVisible = false; } if (MainDrawerArrayAdapter.current > adapter.pageTypes.size()) { actionBar.setTitle(actName); } else { int position = mViewPager.getCurrentItem(); String title = ""; try { title = "" + mSectionsPagerAdapter.getPageTitle(position); } catch (NullPointerException e) { title = ""; } actionBar.setTitle(title); } try { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.new_interactions))) { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); } } catch (Exception e) { // don't have Test pull on } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { actionBar.setTitle(getResources().getString(R.string.app_name)); actionBar.setIcon(R.mipmap.ic_launcher); try { notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(settings.currentAccount)); notificationList.setAdapter(notificationAdapter); notificationList.enableSwipeToDismiss(); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); sharedPrefs.edit().putBoolean("new_notification", false).commit(); } catch (Exception e) { // don't have Test pull on } invalidateOptionsMenu(); } public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (!actionBar.isShowing()) { actionBar.show(); } if (translucent) { statusBar.setVisibility(View.VISIBLE); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); } catch (Exception e) { // landscape mode } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); showMoreDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logoutLayout.getVisibility() == View.GONE) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = true; } else { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = false; } } }); logoutDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoutFromTwitter(); } }); final String sName = settings.myName; final String sScreenName = settings.myScreenName; final String backgroundUrl = settings.myBackgroundUrl; final String profilePicUrl = settings.myProfilePicUrl; final BitmapLruCache mCache = App.getInstance(context).getProfileCache(); if (!backgroundUrl.equals("")) { backgroundPic.loadImage(backgroundUrl, false, null); //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache); } else { backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background)); } backgroundPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { } }, 400); } }); backgroundPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } return false; } }); try { name.setText(sName); screenName.setText("@" + sScreenName); name.setTextSize(15); screenName.setTextSize(15); } catch (Exception e) { // 7 inch tablet in portrait } try { if (settings.roundContactImages) { //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache); } else { profilePic.loadImage(profilePicUrl, false, null); ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache); } } catch (Exception e) { // empty path again } drawerList.setAdapter(adapter); drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager)); // set up for the second account int count = 0; // number of accounts logged in if (sharedPrefs.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPrefs.getBoolean("is_logged_in_2", false)) { count++; } RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile); HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2); HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2); NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2); name2.setTextSize(15); screenname2.setTextSize(15); final int current = sharedPrefs.getInt("current_account", 1); // make a second account if (count == 1) { name2.setText(getResources().getString(R.string.new_account)); screenname2.setText(getResources().getString(R.string.tap_to_setup)); secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { if (current == 1) { sharedPrefs.edit().putInt("current_account", 2).commit(); } else { sharedPrefs.edit().putInt("current_account", 1).commit(); } context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION")); Intent login = new Intent(context, LoginActivity.class); AppSettings.invalidate(); finish(); startActivity(login); } } }); } else { // switch accounts if (current == 1) { name2.setText(sharedPrefs.getString("twitter_users_name_2", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); // we want to wait a second so that the mark position broadcast will work new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 2).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } else { name2.setText(sharedPrefs.getString("twitter_users_name_1", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 1).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } } statusBar = findViewById(R.id.activity_status_bar); statusBarHeight = Utils.getStatusBarHeight(context); navBarHeight = Utils.getNavBarHeight(context); try { RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception e) { try { LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception x) { // in the trends } } View navBarSeperater = findViewById(R.id.nav_bar_seperator); if (translucent && Utils.hasNavBar(context)) { try { RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception e) { try { LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception x) { // in the trends } } } if (translucent) { if (Utils.hasNavBar(context)) { View footer = new View(context); footer.setOnClickListener(null); footer.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); footer.setLayoutParams(params); drawerList.addFooterView(footer); drawerList.setFooterDividersEnabled(false); } View drawerStatusBar = findViewById(R.id.drawer_status_bar); LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); statusBar.setVisibility(View.VISIBLE); drawerStatusBar = findViewById(R.id.drawer_status_bar_2); status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) { actionBar.setDisplayHomeAsUpEnabled(false); } if (!settings.pushNotifications || !settings.useInteractionDrawer) { try { mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END); } catch (Exception e) { // no drawer? } } else { mDrawerLayout.setDrawerRightEdgeSize(this, .1f); try { if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) { View viewHeader2 = context.getLayoutInflater().inflate(R.layout.ab_header, null); notificationList.addHeaderView(viewHeader2, null, false); notificationList.setHeaderDividersEnabled(false); } } catch (Exception e) { // i don't know why it does this to be honest... } notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context) .getUnreadCursor(DrawerActivity.settings.currentAccount)); try { notificationList.setAdapter(notificationAdapter); } catch (Exception e) { } View viewHeader = context.getLayoutInflater().inflate(R.layout.interactions_footer_1, null); notificationList.addFooterView(viewHeader, null, false); oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text); readButton = (ImageView) findViewById(R.id.read_button); LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.old_interactions))) { oldInteractions.setText(getResources().getString(R.string.new_interactions)); readButton.setImageResource(closedMailResource); notificationList.disableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getCursor(DrawerActivity.settings.currentAccount)); } else { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); } notificationList.setAdapter(notificationAdapter); } }); if (DrawerActivity.translucent) { if (Utils.hasNavBar(context)) { View nav = new View(context); nav.setOnClickListener(null); nav.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); nav.setLayoutParams(params); notificationList.addFooterView(nav); notificationList.setFooterDividersEnabled(false); } } notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) { Log.v("Test_interactions_delete", "position to delete: " + position); InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markRead(settings.currentAccount, position); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); if (notificationAdapter.getCount() == 0) { setNotificationFilled(false); } return null; } }); notificationList.enableSwipeToDismiss(); notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START); notificationList .setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager)); } }
From source file:com.klinker.android.twitter.ui.drawer_activities.DrawerActivity.java
public void setUpDrawer(int number, final String actName) { try {//from w ww .j a v a2 s. c o m ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } actionBar = getActionBar(); MainDrawerArrayAdapter.current = number; TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button }); openMailResource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button }); closedMailResource = a.getResourceId(0, 0); a.recycle(); mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name); HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name); backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image); profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact); final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options); final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout); final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton); drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list); notificationList = (EnhancedListView) findViewById(R.id.notificationList); try { mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ) { public void onDrawerClosed(View view) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (logoutVisible) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); logoutLayout.setVisibility(View.GONE); drawerList.setVisibility(View.VISIBLE); logoutVisible = false; } if (MainDrawerArrayAdapter.current > 2) { actionBar.setTitle(actName); } else { int position = mViewPager.getCurrentItem(); String title = ""; try { title = "" + mSectionsPagerAdapter.getPageTitle(position); } catch (NullPointerException e) { title = ""; } actionBar.setTitle(title); } try { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.new_interactions))) { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); } } catch (Exception e) { // don't have talon pull on } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { actionBar.setTitle(getResources().getString(R.string.app_name)); actionBar.setIcon(R.mipmap.ic_launcher); try { notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(settings.currentAccount)); notificationList.setAdapter(notificationAdapter); notificationList.enableSwipeToDismiss(); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); sharedPrefs.edit().putBoolean("new_notification", false).commit(); } catch (Exception e) { // don't have talon pull on } invalidateOptionsMenu(); } public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (!actionBar.isShowing()) { actionBar.show(); } if (translucent) { statusBar.setVisibility(View.VISIBLE); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); } catch (Exception e) { // landscape mode } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); showMoreDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logoutLayout.getVisibility() == View.GONE) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = true; } else { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = false; } } }); logoutDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoutFromTwitter(); } }); final String sName = settings.myName; final String sScreenName = settings.myScreenName; final String backgroundUrl = settings.myBackgroundUrl; final String profilePicUrl = settings.myProfilePicUrl; final BitmapLruCache mCache = App.getInstance(context).getProfileCache(); if (!backgroundUrl.equals("")) { backgroundPic.loadImage(backgroundUrl, false, null); //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache); } else { backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background)); } backgroundPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", sName); viewProfile.putExtra("screenname", sScreenName); viewProfile.putExtra("proPic", profilePicUrl); viewProfile.putExtra("tweetid", 0); viewProfile.putExtra("retweet", false); viewProfile.putExtra("long_click", false); context.startActivity(viewProfile); } }, 400); } }); backgroundPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", sName); viewProfile.putExtra("screenname", sScreenName); viewProfile.putExtra("proPic", profilePicUrl); viewProfile.putExtra("tweetid", 0); viewProfile.putExtra("retweet", false); viewProfile.putExtra("long_click", true); context.startActivity(viewProfile); } }, 400); return false; } }); try { name.setText(sName); screenName.setText("@" + sScreenName); name.setTextSize(15); screenName.setTextSize(15); } catch (Exception e) { // 7 inch tablet in portrait } try { if (settings.roundContactImages) { //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache); } else { profilePic.loadImage(profilePicUrl, false, null); ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache); } } catch (Exception e) { // empty path again } MainDrawerArrayAdapter adapter = new MainDrawerArrayAdapter(context, new ArrayList<String>(Arrays.asList(MainDrawerArrayAdapter.getItems(context)))); drawerList.setAdapter(adapter); drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager)); // set up for the second account int count = 0; // number of accounts logged in if (sharedPrefs.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPrefs.getBoolean("is_logged_in_2", false)) { count++; } RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile); HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2); HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2); NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2); name2.setTextSize(15); screenname2.setTextSize(15); final int current = sharedPrefs.getInt("current_account", 1); // make a second account if (count == 1) { name2.setText(getResources().getString(R.string.new_account)); screenname2.setText(getResources().getString(R.string.tap_to_setup)); secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { if (current == 1) { sharedPrefs.edit().putInt("current_account", 2).commit(); } else { sharedPrefs.edit().putInt("current_account", 1).commit(); } context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION")); Intent login = new Intent(context, LoginActivity.class); AppSettings.invalidate(); finish(); startActivity(login); } } }); } else { // switch accounts if (current == 1) { name2.setText(sharedPrefs.getString("twitter_users_name_2", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); // we want to wait a second so that the mark position broadcast will work new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 2).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } else { name2.setText(sharedPrefs.getString("twitter_users_name_1", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 1).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } } statusBar = findViewById(R.id.activity_status_bar); statusBarHeight = Utils.getStatusBarHeight(context); navBarHeight = Utils.getNavBarHeight(context); try { RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception e) { try { LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception x) { // in the trends } } View navBarSeperater = findViewById(R.id.nav_bar_seperator); if (translucent && Utils.hasNavBar(context)) { try { RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception e) { try { LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception x) { // in the trends } } } if (translucent) { if (Utils.hasNavBar(context)) { View footer = new View(context); footer.setOnClickListener(null); footer.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); footer.setLayoutParams(params); drawerList.addFooterView(footer); drawerList.setFooterDividersEnabled(false); } View drawerStatusBar = findViewById(R.id.drawer_status_bar); LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); statusBar.setVisibility(View.VISIBLE); drawerStatusBar = findViewById(R.id.drawer_status_bar_2); status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) { actionBar.setDisplayHomeAsUpEnabled(false); } if (!settings.pushNotifications) { try { mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END); } catch (Exception e) { // no drawer? } } else { try { if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) { View viewHeader2 = ((Activity) context).getLayoutInflater().inflate(R.layout.ab_header, null); notificationList.addHeaderView(viewHeader2, null, false); notificationList.setHeaderDividersEnabled(false); } } catch (Exception e) { // i don't know why it does this to be honest... } notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context) .getUnreadCursor(DrawerActivity.settings.currentAccount)); try { notificationList.setAdapter(notificationAdapter); } catch (Exception e) { } View viewHeader = ((Activity) context).getLayoutInflater().inflate(R.layout.interactions_footer_1, null); notificationList.addFooterView(viewHeader, null, false); oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text); readButton = (ImageView) findViewById(R.id.read_button); LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.old_interactions))) { oldInteractions.setText(getResources().getString(R.string.new_interactions)); readButton.setImageResource(closedMailResource); notificationList.disableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getCursor(DrawerActivity.settings.currentAccount)); } else { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); } notificationList.setAdapter(notificationAdapter); } }); if (DrawerActivity.translucent) { if (Utils.hasNavBar(context)) { View nav = new View(context); nav.setOnClickListener(null); nav.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); nav.setLayoutParams(params); notificationList.addFooterView(nav); notificationList.setFooterDividersEnabled(false); } } notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) { Log.v("talon_interactions_delete", "position to delete: " + position); InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markRead(settings.currentAccount, position); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); if (notificationAdapter.getCount() == 0) { setNotificationFilled(false); } return null; } }); notificationList.enableSwipeToDismiss(); notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START); notificationList .setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager)); } }
From source file:com.klinker.android.twitter.activities.drawer_activities.DrawerActivity.java
public void setUpDrawer(int number, final String actName) { int currentAccount = sharedPrefs.getInt("current_account", 1); for (int i = 0; i < TimelinePagerAdapter.MAX_EXTRA_PAGES; i++) { String pageIdentifier = "account_" + currentAccount + "_page_" + (i + 1); int type = sharedPrefs.getInt(pageIdentifier, AppSettings.PAGE_TYPE_NONE); if (type != AppSettings.PAGE_TYPE_NONE) { number++;//w w w .j av a 2s .c o m } } try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } actionBar = getActionBar(); adapter = new MainDrawerArrayAdapter(context); MainDrawerArrayAdapter.setCurrent(context, number); TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button }); openMailResource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button }); closedMailResource = a.getResourceId(0, 0); a.recycle(); mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name); HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name); backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image); profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact); final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options); final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout); final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton); drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list); notificationList = (EnhancedListView) findViewById(R.id.notificationList); try { mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ) { public void onDrawerClosed(View view) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (logoutVisible) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); logoutLayout.setVisibility(View.GONE); drawerList.setVisibility(View.VISIBLE); logoutVisible = false; } if (MainDrawerArrayAdapter.current > adapter.pageTypes.size()) { actionBar.setTitle(actName); } else { int position = mViewPager.getCurrentItem(); String title = ""; try { title = "" + mSectionsPagerAdapter.getPageTitle(position); } catch (NullPointerException e) { title = ""; } actionBar.setTitle(title); } try { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.new_interactions))) { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); } } catch (Exception e) { // don't have talon pull on } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { actionBar.setTitle(getResources().getString(R.string.app_name)); actionBar.setIcon(R.mipmap.ic_launcher); try { notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(settings.currentAccount)); notificationList.setAdapter(notificationAdapter); notificationList.enableSwipeToDismiss(); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); sharedPrefs.edit().putBoolean("new_notification", false).commit(); } catch (Exception e) { // don't have talon pull on } invalidateOptionsMenu(); } public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (!actionBar.isShowing()) { actionBar.show(); } if (translucent) { statusBar.setVisibility(View.VISIBLE); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); } catch (Exception e) { // landscape mode } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); showMoreDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logoutLayout.getVisibility() == View.GONE) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = true; } else { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = false; } } }); logoutDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoutFromTwitter(); } }); final String sName = settings.myName; final String sScreenName = settings.myScreenName; final String backgroundUrl = settings.myBackgroundUrl; final String profilePicUrl = settings.myProfilePicUrl; final BitmapLruCache mCache = App.getInstance(context).getProfileCache(); if (!backgroundUrl.equals("")) { backgroundPic.loadImage(backgroundUrl, false, null); //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache); } else { backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background)); } backgroundPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", sName); viewProfile.putExtra("screenname", sScreenName); viewProfile.putExtra("proPic", profilePicUrl); viewProfile.putExtra("tweetid", 0); viewProfile.putExtra("retweet", false); viewProfile.putExtra("long_click", false); context.startActivity(viewProfile); } }, 400); } }); backgroundPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", sName); viewProfile.putExtra("screenname", sScreenName); viewProfile.putExtra("proPic", profilePicUrl); viewProfile.putExtra("tweetid", 0); viewProfile.putExtra("retweet", false); viewProfile.putExtra("long_click", true); context.startActivity(viewProfile); } }, 400); return false; } }); try { name.setText(sName); screenName.setText("@" + sScreenName); name.setTextSize(15); screenName.setTextSize(15); } catch (Exception e) { // 7 inch tablet in portrait } try { if (settings.roundContactImages) { //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache); } else { profilePic.loadImage(profilePicUrl, false, null); ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache); } } catch (Exception e) { // empty path again } drawerList.setAdapter(adapter); drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager)); // set up for the second account int count = 0; // number of accounts logged in if (sharedPrefs.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPrefs.getBoolean("is_logged_in_2", false)) { count++; } RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile); HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2); HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2); NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2); name2.setTextSize(15); screenname2.setTextSize(15); final int current = sharedPrefs.getInt("current_account", 1); // make a second account if (count == 1) { name2.setText(getResources().getString(R.string.new_account)); screenname2.setText(getResources().getString(R.string.tap_to_setup)); secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { if (current == 1) { sharedPrefs.edit().putInt("current_account", 2).commit(); } else { sharedPrefs.edit().putInt("current_account", 1).commit(); } context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION")); Intent login = new Intent(context, LoginActivity.class); AppSettings.invalidate(); finish(); startActivity(login); } } }); } else { // switch accounts if (current == 1) { name2.setText(sharedPrefs.getString("twitter_users_name_2", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); // we want to wait a second so that the mark position broadcast will work new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 2).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } else { name2.setText(sharedPrefs.getString("twitter_users_name_1", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 1).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } } statusBar = findViewById(R.id.activity_status_bar); statusBarHeight = Utils.getStatusBarHeight(context); navBarHeight = Utils.getNavBarHeight(context); try { RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception e) { try { LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception x) { // in the trends } } View navBarSeperater = findViewById(R.id.nav_bar_seperator); if (translucent && Utils.hasNavBar(context)) { try { RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception e) { try { LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception x) { // in the trends } } } if (translucent) { if (Utils.hasNavBar(context)) { View footer = new View(context); footer.setOnClickListener(null); footer.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); footer.setLayoutParams(params); drawerList.addFooterView(footer); drawerList.setFooterDividersEnabled(false); } View drawerStatusBar = findViewById(R.id.drawer_status_bar); LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); statusBar.setVisibility(View.VISIBLE); drawerStatusBar = findViewById(R.id.drawer_status_bar_2); status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) { actionBar.setDisplayHomeAsUpEnabled(false); } if (!settings.pushNotifications || !settings.useInteractionDrawer) { try { mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END); } catch (Exception e) { // no drawer? } } else { mDrawerLayout.setDrawerRightEdgeSize(this, .1f); try { if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) { View viewHeader2 = ((Activity) context).getLayoutInflater().inflate(R.layout.ab_header, null); notificationList.addHeaderView(viewHeader2, null, false); notificationList.setHeaderDividersEnabled(false); } } catch (Exception e) { // i don't know why it does this to be honest... } notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context) .getUnreadCursor(DrawerActivity.settings.currentAccount)); try { notificationList.setAdapter(notificationAdapter); } catch (Exception e) { } View viewHeader = ((Activity) context).getLayoutInflater().inflate(R.layout.interactions_footer_1, null); notificationList.addFooterView(viewHeader, null, false); oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text); readButton = (ImageView) findViewById(R.id.read_button); LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.old_interactions))) { oldInteractions.setText(getResources().getString(R.string.new_interactions)); readButton.setImageResource(closedMailResource); notificationList.disableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getCursor(DrawerActivity.settings.currentAccount)); } else { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); } notificationList.setAdapter(notificationAdapter); } }); if (DrawerActivity.translucent) { if (Utils.hasNavBar(context)) { View nav = new View(context); nav.setOnClickListener(null); nav.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); nav.setLayoutParams(params); notificationList.addFooterView(nav); notificationList.setFooterDividersEnabled(false); } } notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) { Log.v("talon_interactions_delete", "position to delete: " + position); InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markRead(settings.currentAccount, position); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); if (notificationAdapter.getCount() == 0) { setNotificationFilled(false); } return null; } }); notificationList.enableSwipeToDismiss(); notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START); notificationList .setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager)); } }
From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java
private PointF calculePopupLocation() { PointF location = new PointF(); final RectF anchorRect = calculeAnchorRect(); final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY()); switch (mGravity) { case Gravity.START: location.x = anchorRect.left - mPopupWindow.getContentView().getWidth() - mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break;/*from ww w . ja va2 s .co m*/ case Gravity.END: location.x = anchorRect.right + mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break; case Gravity.TOP: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.top - mPopupWindow.getContentView().getHeight() - mMargin; break; case Gravity.BOTTOM: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.bottom + mMargin; break; default: throw new IllegalArgumentException("Gravity must have be START, END, TOP or BOTTOM."); } return location; }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
@Override protected void onFinishInflate() { super.onFinishInflate(); editMessageBackgroundView = ViewUtils.getView(this, R.id.fl__edit_message__background); cursorToolbarFrame = ViewUtils.getView(this, R.id.cal__cursor); newCursorEditText = ViewUtils.getView(this, R.id.cet__cursor); shieldViewWithBanner = ViewUtils.getView(this, R.id.svwb); mainToolbar = ViewUtils.getView(this, R.id.c__cursor__main); secondaryToolbar = ViewUtils.getView(this, R.id.c__cursor__secondary); editMessageCursorToolbar = ViewUtils.getView(this, R.id.emct__edit_message__toolbar); topBorder = ViewUtils.getView(this, R.id.v__top_bar__cursor); tooltip = ViewUtils.getView(this, R.id.ctv__cursor); hintView = ViewUtils.getView(this, R.id.ttv__cursor_hint); dividerView = ViewUtils.getView(this, R.id.v__cursor__divider); FrameLayout emojiButtonContainer = ViewUtils.getView(this, R.id.fl__cursor__emoji_container); FrameLayout sendButtonContainer = ViewUtils.getView(this, R.id.fl__cursor__send_button_container); mainToolbar.setCursorItems(mainCursorItems); secondaryToolbar.setCursorItems(secondaryCursorItems); editMessageCursorToolbar.setVisibility(GONE); editMessageCursorToolbar.setCallback(this); cursorHeight = getResources().getDimensionPixelSize(R.dimen.new_cursor_height); secondaryToolbar.setTranslationY(2 * cursorHeight); cursorToolbarAnimationDuration = getResources().getInteger(R.integer.wire__animation__delay__regular); tooltip.setVisibility(View.GONE); connectEditText();// w ww.ja v a 2s.com editMessageBackgroundView.setVisibility(GONE); defaultEditTextColor = newCursorEditText.getCurrentTextColor(); ColorDrawable dividerBg = (ColorDrawable) dividerView.getBackground(); defaultDividerColor = dividerBg.getColor(); // Emoji button LayoutInflater inflater = LayoutInflater.from(getContext()); emojiButton = (CursorIconButton) inflater.inflate(R.layout.cursor__item, this, false); emojiButton.setText(R.string.glyph__emoji); emojiButton.setPressedBackgroundColor(ContextCompat.getColor(getContext(), R.color.light_graphite)); int buttonWidth = getResources().getDimensionPixelSize(R.dimen.cursor__menu_button__diameter); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(buttonWidth, buttonWidth); params.gravity = Gravity.END | Gravity.CENTER_VERTICAL; params.setMarginEnd(getResources().getDimensionPixelSize(R.dimen.chathead__margin)); emojiButtonContainer.addView(emojiButton, params); emojiButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (cursorCallback == null) { return; } mainToolbar.unselectItems(); if (getContext().getString(R.string.glyph__emoji).equals(emojiButton.getText())) { emojiButton.setText(R.string.glyph__keyboard); cursorCallback.onEmojiButtonClicked(true); } else { emojiButton.setText(R.string.glyph__emoji); cursorCallback.onEmojiButtonClicked(false); } } }); // Send button sendButton = (CursorIconButton) inflater.inflate(R.layout.cursor__item, this, false); sendButton.setText(R.string.glyph__send); if (!ThemeUtils.isDarkTheme(getContext())) { sendButton.setTextColor(ContextCompat.getColor(getContext(), R.color.text__primary_dark)); } else { sendButton.setTextColor(ContextCompat.getColor(getContext(), R.color.text__primary_light)); } sendButtonContainer.addView(sendButton, new FrameLayout.LayoutParams(buttonWidth, buttonWidth)); sendButton.setVisibility(View.INVISIBLE); }