/** This method handles the theme */ public void themeHandler() { if (gaia.getChosenTheme().equals("Black Theme")) { background.setBackgroundDrawable( getResources().getDrawable(R.drawable.drawerbackground_black)); } if (gaia.getChosenTheme().equals("Blue Theme")) { background.setBackgroundDrawable( getResources().getDrawable(R.drawable.drawerbackground_blue)); } else if (gaia.getChosenTheme().equals("Orange Theme")) { background.setBackgroundDrawable( getResources().getDrawable(R.drawable.drawerbackground_orange)); } else if (gaia.getChosenTheme().equals("Green Theme")) { background.setBackgroundDrawable( getResources().getDrawable(R.drawable.drawerbackground_green)); } else if (gaia.getChosenTheme().equals("Purple Theme")) { background.setBackgroundDrawable( getResources().getDrawable(R.drawable.drawerbackground_purple)); } }
@AfterViews public void listAllAmbassadorsByPagination() { Typeface typeFace = Typeface.createFromAsset(getActivity().getAssets(), "fonts/OpenSans-Regular.ttf"); thousand.setTypeface(null, typeFace.BOLD); hubName.setTypeface(typeFace); ambassadorsTitle.setTypeface(typeFace); eventsButton.setTypeface(typeFace); membersButton.setTypeface(typeFace); newsButton.setTypeface(typeFace); headerHub.getBackground().setAlpha(100); android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); OneHubNewsFragment_ newsFragment = (OneHubNewsFragment_) fragmentManager.findFragmentByTag("news"); OneHubEventsFragment_ eventsFragment = (OneHubEventsFragment_) fragmentManager.findFragmentByTag("events"); OneHubMembersFragment_ membersFragment = (OneHubMembersFragment_) fragmentManager.findFragmentByTag("members"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (newsFragment != null) { fragmentTransaction.detach(newsFragment); } if (eventsFragment != null) { fragmentTransaction.detach(eventsFragment); } if (membersFragment != null) { fragmentTransaction.detach(membersFragment); } fragmentTransaction.add(R.id.realtabcontent, new OneHubNewsFragment_(), "news"); eventsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); membersButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); newsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_selected_407x9)); membersSelected = false; eventsSelected = false; newsSelected = true; fragmentTransaction.commit(); listAllAmbassadorsOfHubService(); }
protected void b() { c = new je(this, a); b = new WindowManager.LayoutParams(); b.width = -1; b.height = -1; b.format = -2; c.setVisibility(8); c.setBackgroundDrawable(null); c.setOnClickListener(new jf(this)); if (e) { g = new jg(this, a, h); c.setGravity(53); LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-2, -2); if ((a instanceof jb)) { Rect localRect1 = ((jb) a).t(); if (localRect1 != null) { Rect localRect2 = new Rect(); ((Activity) a).getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect2); int k = top; height = localRect1.height(); topMargin = (top - k); } } c.addView(g.a(), localLayoutParams); return; } g = new jh(this, a, h); c.setGravity(17); c.addView(g.a()); }
private LinearLayout getTitleView(Context context, AlertType type) { this.context = context; LinearLayout mainLine = new LinearLayout(context); mainLine.setOrientation(LinearLayout.HORIZONTAL); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mainLine.setLayoutParams(layoutParams); mainLine.setPadding( Tool.dip2px(context, 10), Tool.dip2px(context, 10), Tool.dip2px(context, 10), Tool.dip2px(context, 10)); mainLine.setGravity(Gravity.CENTER_VERTICAL); mainLine.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.toast_background)); ImageView imageView = new ImageView(context); if (type == AlertType.ERR) { imageView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.err)); } else if (type == AlertType.INFO) { imageView.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.radio_bt_selected)); } else { imageView.setBackgroundDrawable(null); } mainLine.addView(imageView); textView = new TextView(context); textView.setTextColor(context.getResources().getColor(R.color.white)); textView.setTextSize(16); mainLine.addView(textView); return mainLine; }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { sparseBooleanArray.put((Integer) compoundButton.getTag(), b); LinearLayout ll = (LinearLayout) compoundButton.getParent(); int[] diems = getDims(ll); if (b) { this.callback.itemSelected(sparseBooleanArray); ll.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.list_pressed_holo_light)); ll.setPadding(diems[0], diems[1], diems[2], diems[3]); } else { this.callback.itemDeSelected(sparseBooleanArray); ll.setBackgroundDrawable(null); ll.setPadding(diems[0], diems[1], diems[2], diems[3]); } }
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { WebView webView = new WebView(getActivity()); // TextView text = new TextView(getActivity()); // text.setGravity(Gravity.CENTER); // text.setText(mContent); // text.setTextSize(13 * getResources().getDisplayMetrics().scaledDensity); // text.setPadding(20, 20, 20, 20); // text.setTextColor(getResources().getColor(R.color.colorFuenteAzul)); webView.getSettings().setDefaultFontSize(19); webView.loadDataWithBaseURL(null, mContent, "text/html", "utf-8", null); LinearLayout layout = new LinearLayout(getActivity()); int px = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); layout.setLayoutParams(new LayoutParams(px, LayoutParams.MATCH_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(webView); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { layout.setBackgroundDrawable(getResources().getDrawable(R.drawable.rounded_border)); } else { layout.setBackground(getResources().getDrawable(R.drawable.rounded_border)); } return layout; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); drawpicture(); LinearLayout ll = (LinearLayout) findViewById(R.id.rect); ll.setBackgroundDrawable( new BitmapDrawable(bitmapoverlay(drawpicture(), drawEye(), getSmile()))); }
@SuppressWarnings("deprecation") @Override public View getView(int position, View convertView, ViewGroup parent) { final DialogMenuItem item = contents.get(position); LinearLayout ll_item = new LinearLayout(context); ll_item.setOrientation(LinearLayout.HORIZONTAL); ll_item.setGravity(Gravity.CENTER_VERTICAL); ImageView iv_item = new ImageView(context); iv_item.setPadding(0, 0, dp2px(15), 0); ll_item.addView(iv_item); TextView tv_item = new TextView(context); tv_item.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tv_item.setSingleLine(true); tv_item.setGravity(Gravity.CENTER); tv_item.setTextColor(itemTextColor); tv_item.setTextSize(TypedValue.COMPLEX_UNIT_SP, itemTextSize_SP); tv_item.setHeight(dp2px(itemHeight_DP)); ll_item.addView(tv_item); float radius = dp2px(cornerRadius_DP); if (isTitleShow) { ll_item.setBackgroundDrawable( (CornerUtils.listItemSelector( radius, Color.TRANSPARENT, itemPressColor, position == contents.size() - 1))); } else { ll_item.setBackgroundDrawable( CornerUtils.listItemSelector( radius, Color.TRANSPARENT, itemPressColor, contents.size(), position)); } iv_item.setImageResource(item.resId); tv_item.setText(item.operName); iv_item.setVisibility(item.resId == 0 ? View.GONE : View.VISIBLE); return ll_item; }
public Leaderboard(Context context, String kind, String selectedContest) { super(context, R.style.ThemeBeintoo); setContentView(R.layout.leaderboardlist); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); this.current = this; this.currentContext = context; this.leader_kind = kind; this.codeID = selectedContest; // GETTING DENSITY PIXELS RATIO ratio = (context.getApplicationContext().getResources().getDisplayMetrics().densityDpi / 160d); // SET UP LAYOUTS double pixels = ratio * 40; RelativeLayout beintooBar = (RelativeLayout) findViewById(R.id.beintoobarsmall); beintooBar.setBackgroundDrawable( new BDrawableGradient(0, (int) pixels, BDrawableGradient.BAR_GRADIENT)); listView = (ListView) findViewById(R.id.listView); listView.setVisibility(LinearLayout.GONE); listView.setCacheColorHint(0); LinearLayout content = (LinearLayout) findViewById(R.id.goodcontent); content.addView(progressLoading()); LinearLayout tip = (LinearLayout) findViewById(R.id.tip); tip.setBackgroundDrawable( new BDrawableGradient(0, (int) (ratio * 27), BDrawableGradient.LIGHT_GRAY_GRADIENT)); if (!Beintoo.isLogged( context)) { // IF THE USER IS NOT LOGGED HIDE TIPS FOR CHALLENGE AND SHOW SIGNUP BUTTON tip.setVisibility(LinearLayout.GONE); LinearLayout signup = (LinearLayout) findViewById(R.id.signupPlayer); signup.addView(SignupLayouts.signupRow(context, Beintoo.FEATURE_LEADERBOARD)); signup.setVisibility(View.VISIBLE); } if (leader_kind != null && leader_kind.equals("ALLIANCES")) { findViewById(R.id.tip).setVisibility(View.GONE); findViewById(R.id.spacer).setVisibility(View.GONE); } imageManager = new ImageManager(currentContext); usersExts = new ArrayList<String>(); usersNicks = new ArrayList<String>(); listView.setOnItemClickListener(this); listView.setOnScrollListener(this); this.firstLoading(); }
@SuppressWarnings("deprecation") public void onClickButtonCancel(View v) { isAccept = false; mNextBtnLayout.setSoundEffectsEnabled(false); mFadeOutAnime = AnimationUtils.loadAnimation(this, R.anim.welcome_intro_fade_out); if (mFadeOutAnime != null) { mBottomLayout.startAnimation(mFadeOutAnime); } mBottomLayout.setBackgroundDrawable(null); if (mFadeOutAnime != null) { mFadeOutAnime.setAnimationListener(fadeOutAniListener); } }
public void openPicDialog(int pos) { final Dialog dialog = new Dialog(GalleryActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.custom_gallery_dialog); dialog.show(); LinearLayout lay = (LinearLayout) dialog.findViewById(R.id.custum_gallary_layout); Bitmap bmImg = gallaryArr.get(pos).pic; BitmapDrawable background = new BitmapDrawable(bmImg); lay.setBackgroundDrawable(background); dialog.setCanceledOnTouchOutside(true); }
private void addItem(SwipeMenuItem item, int id) { LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight()); LinearLayout parent = new LinearLayout(getContext()); parent.setId(id); parent.setGravity(Gravity.CENTER); parent.setOrientation(LinearLayout.VERTICAL); parent.setLayoutParams(params); parent.setBackgroundDrawable(item.getBackground()); parent.setOnClickListener(this); addView(parent); if (item.getIcon() != null) { parent.addView(createIcon(item)); } if (!TextUtils.isEmpty(item.getTitle())) { parent.addView(createTitle(item)); } }
/** * * * * @param titleView * @return */ private LinearLayout getView(String titleView) { LinearLayout linearLayout = new LinearLayout(getApplicationContext()); linearLayout.setLayoutParams( new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(400, 400))); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(getTitleView(titleView, R.drawable.detail)); LinearLayout cameraOne = new LinearLayout(getApplicationContext()); cameraOne.setGravity(Gravity.CENTER); cameraOne.setLayoutParams(new LinearLayout.LayoutParams(400, 354)); cameraOne.setBackgroundDrawable( JDrawable.getJDrawable() .drawRoundRect(new float[] {0, 0, 0, 0, 0, 0, 0, 0}, 3, Color.BLACK)); ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageResource(R.drawable.camera_icon); cameraOne.addView(imageView); linearLayout.addView(cameraOne); return linearLayout; }
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.lin_patient_all: lin_patient_all.setBackgroundResource(R.drawable.word_list_selector_selected); lin_patient_my.setBackgroundDrawable(null); cb_all.setVisibility(View.VISIBLE); cb_my.setVisibility(View.INVISIBLE); break; case R.id.lin_patient_my: lin_patient_my.setBackgroundResource(R.drawable.word_list_selector_selected); lin_patient_all.setBackgroundDrawable(null); cb_my.setVisibility(View.VISIBLE); cb_all.setVisibility(View.INVISIBLE); break; case R.id.lin_patient_on: lin_patient_on.setBackgroundResource(R.drawable.word_list_selector_selected); lin_patient_off.setBackgroundDrawable(null); cb_on.setVisibility(View.VISIBLE); cb_off.setVisibility(View.INVISIBLE); break; case R.id.lin_patient_off: lin_patient_off.setBackgroundResource(R.drawable.word_list_selector_selected); lin_patient_on.setBackgroundDrawable(null); cb_off.setVisibility(View.VISIBLE); cb_on.setVisibility(View.INVISIBLE); break; case R.id.lin_offices_surgery: lin_offices_surgery.setBackgroundResource(R.drawable.word_list_selector_selected); lin_offices_gynaecology.setBackgroundDrawable(null); break; case R.id.lin_offices_gynaecology: lin_offices_gynaecology.setBackgroundResource(R.drawable.word_list_selector_selected); lin_offices_surgery.setBackgroundDrawable(null); break; } }
public void createControls() { // 1. Create view groups and controls statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top)); rightStack = new StackWidgetView(view.getContext()); leftStack = new StackWidgetView(view.getContext()); // 2. Preparations Rect topRectPadding = new Rect(); view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding); // for measurement statusBar.addView(backToLocation); STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient); statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); Rect statusBarPadding = new Rect(); statusBar.getBackground().getPadding(statusBarPadding); // 3. put into frame parent layout controls FrameLayout parent = (FrameLayout) view.getParent(); // status bar hides own top part int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom; // we want that status bar lays over map stack controls topMargin -= topRectPadding.top; FrameLayout.LayoutParams flp = new FrameLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT); flp.rightMargin = STATUS_BAR_MARGIN_X; flp.topMargin = topMargin; rightStack.setLayoutParams(flp); flp = new FrameLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP); flp.topMargin = (int) (topMargin + scaleCoefficient * 8); lanesControl.setLayoutParams(flp); flp = new FrameLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.LEFT); flp.leftMargin = STATUS_BAR_MARGIN_X; flp.topMargin = topMargin; leftStack.setLayoutParams(flp); flp = new FrameLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP); flp.leftMargin = STATUS_BAR_MARGIN_X; flp.rightMargin = STATUS_BAR_MARGIN_X; flp.topMargin = -topRectPadding.top; statusBar.setLayoutParams(flp); flp = new FrameLayout.LayoutParams( (int) (78 * scaleCoefficient), (int) (78 * scaleCoefficient), Gravity.RIGHT | Gravity.BOTTOM); flp.rightMargin = (int) (10 * scaleCoefficient); flp.bottomMargin = (int) (85 * scaleCoefficient); alarmControl.setLayoutParams(flp); parent.addView(rightStack); parent.addView(leftStack); parent.addView(statusBar); parent.addView(lanesControl); parent.addView(alarmControl); alarmControl.setVisibility(View.GONE); lanesControl.setVisibility(View.GONE); // update and create controls recreateControls(); }
public void updateColorShadowsOfText(DrawSettings drawSettings) { boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get(); boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode(); boolean following = routeLayer.getHelper().isFollowingMode(); int calcThemeId = (transparent ? 4 : 0) | (nightMode ? 2 : 0) | (following ? 1 : 0); if (themeId != calcThemeId) { themeId = calcThemeId; boolean textBold = following; int textColor = nightMode ? 0xffC8C8C8 : Color.BLACK; int textShadowColor = transparent && !nightMode ? Color.WHITE : Color.TRANSPARENT; int boxTop; int boxTopStack; int boxTopR; int boxTopL; int expand; Drawable boxFree = view.getResources().getDrawable(R.drawable.box_free_simple); if (transparent) { boxTop = R.drawable.box_top_t; boxTopStack = R.drawable.box_top_t_stack; boxTopR = R.drawable.box_top_rt; boxTopL = R.drawable.box_top_lt; expand = R.drawable.box_expand_t; if (nightMode) { boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple); } } else if (nightMode) { boxTop = R.drawable.box_top_n; boxTopStack = R.drawable.box_top_n_stack; boxTopR = R.drawable.box_top_rn; boxTopL = R.drawable.box_top_ln; expand = R.drawable.box_expand_t; boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple); } else { boxTop = R.drawable.box_top; boxTopStack = R.drawable.box_top_stack; boxTopR = R.drawable.box_top_r; boxTopL = R.drawable.box_top_l; expand = R.drawable.box_expand; } lanesControl.setBackgroundDrawable(boxFree); rightStack.setTopDrawable(view.getResources().getDrawable(boxTopR)); rightStack.setStackDrawable(boxTopStack); leftStack.setTopDrawable(view.getResources().getDrawable(boxTopL)); leftStack.setStackDrawable(boxTopStack); leftStack.setExpandImageDrawable(view.getResources().getDrawable(expand)); rightStack.setExpandImageDrawable(view.getResources().getDrawable(expand)); statusBar.setBackgroundDrawable(view.getResources().getDrawable(boxTop)); paintText.setColor(textColor); paintSubText.setColor(textColor); paintSmallText.setColor(textColor); paintSmallSubText.setColor(textColor); topText.setShadowColor(textShadowColor); leftStack.setShadowColor(textShadowColor); rightStack.setShadowColor(textShadowColor); paintText.setFakeBoldText(textBold); paintSubText.setFakeBoldText(textBold); paintSmallText.setFakeBoldText(textBold); paintSmallSubText.setFakeBoldText(textBold); rightStack.invalidate(); leftStack.invalidate(); statusBar.invalidate(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.user_profile); final String username = getIntent().getExtras().getString("username"); /** Gets user info from the server */ userInfo = new UserInfo(); ServerResponse resp = ApiHandler.get(ApiHandler.userInfoURL, this); if (resp.getStatus() == false) { Toast.makeText(this, resp.getError(), Toast.LENGTH_SHORT).show(); return; } else try { userInfo.parseContent(resp.getData()); } catch (JSONException e) { Toast.makeText(this, "Server response format error.", Toast.LENGTH_SHORT).show(); return; } // Get interface elements. messageButton = (Button) findViewById(R.id.usermsgbtn); spellButton = (Button) findViewById(R.id.userspellbtn); challengeButton = (Button) findViewById(R.id.userchalbtn); userInfoLayout = (LinearLayout) findViewById(R.id.usercontainer); userAvatar = (ImageView) findViewById(R.id.useravatar); userLevelImage = (ImageView) findViewById(R.id.userlevelimg); userName = (TextView) findViewById(R.id.username); userPoints = (TextView) findViewById(R.id.userpoints); userRank = (TextView) findViewById(R.id.userrank); userLevel = (TextView) findViewById(R.id.userlevel); userRace = (TextView) findViewById(R.id.userrace); userGroup = (TextView) findViewById(R.id.usergroup); // Set background for main user profile. File sdcard = Environment.getExternalStorageDirectory(); File background = new File( sdcard + File.separator + "awouso" + File.separator + "profiles", userInfo.getRace() + ".png"); Bitmap backgroundBitmap = BitmapFactory.decodeFile(background.toString()); @SuppressWarnings("deprecation") Drawable backgroundImage = new BitmapDrawable(backgroundBitmap); userInfoLayout.setBackgroundDrawable(backgroundImage); // Display user avatar. UserInfo.setAvatar(userAvatar, userInfo.getAvatarUrl()); // Display user name. userName.setText(userInfo.getFirstName() + " " + userInfo.getLastName()); // Display user points. userPoints.setText(userInfo.getPoints() + ""); // Display user rank. userRank.setText("rank: " + "wat?"); // Display user level icon. File iconFile = new File( sdcard + File.separator + "awouso" + File.separator + "levels", userInfo.getRace() + "-level-" + userInfo.getLevelNo() + ".png"); Bitmap iconBitmap = BitmapFactory.decodeFile(iconFile.toString()); userLevelImage.setImageBitmap(iconBitmap); // Display user level. userLevel.setText("Level " + userInfo.getLevelNo()); // Display user race. userRace.setText(userInfo.getRace()); // Display user group. userGroup.setText(userInfo.getGroup()); // TODO Add spell list. // Set buttons listeners. messageButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // TODO add send message action Toast.makeText( getApplicationContext(), "Send a message to " + userInfo.getFirstName() + " " + userInfo.getLastName(), Toast.LENGTH_SHORT) .show(); } }); spellButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // TODO add cast spell action Toast.makeText( getApplicationContext(), "Cast a spell on " + userInfo.getFirstName() + " " + userInfo.getLastName(), Toast.LENGTH_SHORT) .show(); } }); challengeButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { ChallengeHandler.startChallenge(v.getContext(), username); Toast.makeText(getApplicationContext(), "Challenge started!", Toast.LENGTH_SHORT) .show(); } }); }
public void treatments(String tabId) { /** Defining Tab Change Listener event. This is invoked when tab is changed */ android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); OneHubNewsFragment_ newsFragment = (OneHubNewsFragment_) fragmentManager.findFragmentByTag("news"); OneHubEventsFragment_ eventsFragment = (OneHubEventsFragment_) fragmentManager.findFragmentByTag("events"); OneHubMembersFragment_ membersFragment = (OneHubMembersFragment_) fragmentManager.findFragmentByTag("members"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (newsFragment != null) { fragmentTransaction.detach(newsFragment); } if (eventsFragment != null) { fragmentTransaction.detach(eventsFragment); } if (membersFragment != null) { fragmentTransaction.detach(membersFragment); } if (tabId.equalsIgnoreCase("news")) { /** If current tab is Info */ /** Create AndroidFragment and adding to fragmenttransaction */ fragmentTransaction.add(R.id.realtabcontent, new OneHubNewsFragment_(), "news"); eventsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); membersButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); newsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_selected_407x9)); membersSelected = false; eventsSelected = false; newsSelected = true; /** Bring to the front, if already exists in the fragmenttransaction */ } else if (tabId.equalsIgnoreCase("events")) { /** If current tab is Info */ /** Create AndroidFragment and adding to fragmenttransaction */ fragmentTransaction.add(R.id.realtabcontent, new OneHubEventsFragment_(), "events"); eventsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_selected_407x9)); membersButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); newsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); membersSelected = false; eventsSelected = true; newsSelected = false; /** Bring to the front, if already exists in the fragmenttransaction */ } else { /** If current tab is Market */ /** Create AppleFragment and adding to fragmenttransaction */ fragmentTransaction.add( R.id.realtabcontent, new OneHubMembersFragment_().newInstance(hubToDisplay), "members"); eventsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); membersButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_selected_407x9)); newsButtonLight.setBackgroundDrawable( getResources().getDrawable(R.drawable.buttonline_nonselected_407x9)); membersSelected = true; eventsSelected = false; newsSelected = false; /** Bring to the front, if already exists in the fragmenttransaction */ } fragmentTransaction.commit(); }
@SuppressWarnings("deprecation") private View generateView() { LinearLayout rootLayout = new LinearLayout(getContext()); rootLayout.setOrientation(LinearLayout.VERTICAL); rootLayout.setMinimumWidth(DimensionUtility.dp2px(260)); GradientDrawable gradientDrawable = new GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, new int[] {Color.argb(0xCC, 0xFF, 0xFF, 0xFF), Color.argb(0xCC, 0xFF, 0xFF, 0xFF)}); gradientDrawable.setCornerRadius(DimensionUtility.dp2px(6)); gradientDrawable.setStroke(1, Color.parseColor("#CFFFFFFF")); rootLayout.setBackgroundDrawable(gradientDrawable); int padding = DimensionUtility.dp2px(8); rootLayout.setPadding(padding, padding, padding, padding); titleLabel = new TextView(getContext()); titleLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); titleLabel.setGravity(Gravity.CENTER); titleLabel.setTextColor(Color.parseColor("#333333")); LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(fillParent(), wrapContent()); rootLayout.addView(titleLabel, titleParams); messageLabel = new TextView(getContext()); messageLabel.setTextColor(Color.parseColor("#333333")); messageLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); messageLabel.setGravity(Gravity.CENTER); LinearLayout.LayoutParams messageParams = new LinearLayout.LayoutParams(fillParent(), wrapContent()); messageParams.topMargin = DimensionUtility.dp2px(10); rootLayout.addView(messageLabel, messageParams); text = new EditText(getContext()); text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); text.setInputType(InputType.TYPE_CLASS_TEXT); LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(fillParent(), wrapContent()); textParams.topMargin = DimensionUtility.dp2px(8); rootLayout.addView(text, textParams); LinearLayout container = new LinearLayout(getContext()); container.setOrientation(LinearLayout.HORIZONTAL); container.setWeightSum(2); positiveButton = new Button(getContext()); LinearLayout.LayoutParams positiveParams = new LinearLayout.LayoutParams(fillParent(), wrapContent()); positiveParams.weight = 1; container.addView(positiveButton, positiveParams); negativeButton = new Button(getContext()); LinearLayout.LayoutParams negativeParams = new LinearLayout.LayoutParams(fillParent(), wrapContent()); negativeParams.weight = 1; container.addView(negativeButton, negativeParams); positiveButton.setOnClickListener(this); negativeButton.setOnClickListener(this); LinearLayout.LayoutParams ctrParams = new LinearLayout.LayoutParams(fillParent(), wrapContent()); ctrParams.topMargin = DimensionUtility.dp2px(8); rootLayout.addView(container, ctrParams); return rootLayout; }
@SuppressWarnings("deprecation") private void readAttrs(Context context, AttributeSet attrs) { if (null != attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SettingViewItem); if (a.hasValue(R.styleable.SettingViewItem_arrow)) { Drawable drawable = a.getDrawable(R.styleable.SettingViewItem_arrow); if (null != drawable) { mArrow.setImageDrawable(drawable); } else { mArrow.setImageResource(R.drawable.setting_view_arrow); } } if (a.hasValue(R.styleable.SettingViewItem_background)) { Drawable drawable = a.getDrawable(R.styleable.SettingViewItem_background); if (null != drawable) { mItemViewContainer.setBackgroundDrawable(drawable); } else { mItemViewContainer.setBackgroundResource(R.drawable.setting_view_item_selector); } } else { mItemViewContainer.setBackgroundResource(R.drawable.setting_view_item_selector); } if (a.hasValue(R.styleable.SettingViewItem_drawable)) { Drawable drawable = a.getDrawable(R.styleable.SettingViewItem_drawable); if (null != drawable) { mDrawable.setImageDrawable(drawable); } else { mDrawable.setVisibility(View.GONE); } } else { mDrawable.setVisibility(View.GONE); } if (a.hasValue(R.styleable.SettingViewItem_subTitle)) { String subTitle = a.getString(R.styleable.SettingViewItem_subTitle); if (!TextUtils.isEmpty(subTitle)) { mSubTitle.setText(subTitle); } } if (a.hasValue(R.styleable.SettingViewItem_subTitleColor)) { ColorStateList colors = a.getColorStateList(R.styleable.SettingViewItem_subTitleColor); if (null != colors) { mSubTitle.setTextColor(colors); } } if (a.hasValue(R.styleable.SettingViewItem_subTitleSize)) { int textSize = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_PX, a.getDimensionPixelSize(R.styleable.SettingViewItem_subTitleSize, 14), getResources().getDisplayMetrics()); mSubTitle.setTextSize(textSize); } if (a.hasValue(R.styleable.SettingViewItem_title)) { String title = a.getString(R.styleable.SettingViewItem_title); if (!TextUtils.isEmpty(title)) { mTitle.setText(title); } } if (a.hasValue(R.styleable.SettingViewItem_titleColor)) { ColorStateList colors = a.getColorStateList(R.styleable.SettingViewItem_titleColor); if (null != colors) { mTitle.setTextColor(colors); } } if (a.hasValue(R.styleable.SettingViewItem_titleSize)) { int textSize = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_PX, a.getDimensionPixelSize(R.styleable.SettingViewItem_titleSize, 16), getResources().getDisplayMetrics()); mTitle.setTextSize(textSize); } if (a.hasValue(R.styleable.SettingViewItem_clickable)) { mItemViewContainer.setClickable(a.getBoolean(R.styleable.SettingViewItem_clickable, true)); } else { mItemViewContainer.setClickable(true); } a.recycle(); } }
@SuppressWarnings("deprecation") public void fillData(SettingData data) { if (null != data) { if (!TextUtils.isEmpty(data.getTitle())) { mTitle.setText(data.getTitle()); } else { mTitle.setVisibility(View.GONE); } if (!TextUtils.isEmpty(data.getSubTitle())) { mSubTitle.setText(data.getSubTitle()); } else { mSubTitle.setVisibility(View.GONE); } if (null != data.getDrawable()) { mDrawable.setImageDrawable(data.getDrawable()); } else { mDrawable.setVisibility(View.GONE); } if (null != data.getArrow()) { mArrow.setImageDrawable(data.getArrow()); } else { mArrow.setImageResource(R.drawable.setting_view_arrow); } if (null != data.getBackground()) { mItemViewContainer.setBackgroundDrawable(data.getBackground()); } else { mItemViewContainer.setBackgroundResource(R.drawable.setting_view_item_selector); } if (data.getTitleColor() > 0) { mTitle.setTextColor(data.getTitleColor()); } if (data.getSubTitleColor() > 0) { mSubTitle.setTextColor(data.getSubTitleColor()); } if (data.getTitleSize() > 0) { int titleSize = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_PX, data.getTitleSize(), getResources().getDisplayMetrics()); mTitle.setTextSize(titleSize); } if (data.getSubTitleSize() > 0) { int subTitleSize = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_PX, data.getSubTitleSize(), getResources().getDisplayMetrics()); mSubTitle.setTextSize(subTitleSize); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); RelativeLayout root = new RelativeLayout(mActivity); RelativeLayout.LayoutParams rootParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); root.setPadding(30, 0, 30, 0); root.setLayoutParams(rootParams); LinearLayout container = new LinearLayout(mActivity); container.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); containerParams.setMargins(30, 0, 30, 0); container.setLayoutParams(containerParams); container.setPadding(30, 20, 30, 20); TextView descView = new TextView(mActivity); LinearLayout.LayoutParams descViewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); descViewParams.setMargins(0, 20, 0, 20); descView.setLayoutParams(descViewParams); descView.setGravity(Gravity.CENTER); descView.setTextColor(Color.parseColor("#ffffff")); descView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); descView.setText(mActivity.getString(R.string.pg_sdk_edit_quit_edit)); container.addView(descView); ImageView vDivider = new ImageView(mActivity); LinearLayout.LayoutParams vDividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1); vDividerParams.setMargins(0, 20, 0, 0); vDivider.setLayoutParams(vDividerParams); container.addView(vDivider); RelativeLayout buttonContainer = new RelativeLayout(mActivity); RelativeLayout.LayoutParams buttonContainerParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); buttonContainerParams.setMargins(0, 20, 0, 0); buttonContainer.setLayoutParams(buttonContainerParams); float density = mActivity.getResources().getDisplayMetrics().density; int width = mActivity.getResources().getDisplayMetrics().widthPixels; ImageView hDivider = new ImageView(mActivity); RelativeLayout.LayoutParams hDividerParams = new RelativeLayout.LayoutParams(1, Math.round(48 * density)); hDividerParams.addRule(RelativeLayout.CENTER_HORIZONTAL); hDivider.setLayoutParams(hDividerParams); buttonContainer.addView(hDivider); float[] outerR = new float[] {10, 10, 10, 10, 10, 10, 10, 10}; RoundRectShape roundRectShape = new RoundRectShape(outerR, null, null); ShapeDrawable drawable = new ShapeDrawable(roundRectShape); drawable.getPaint().setColor(Color.parseColor("#404040")); drawable.getPaint().setStyle(Paint.Style.FILL); Button confirmButton = new Button(mActivity); RelativeLayout.LayoutParams confirmButtonParams = new RelativeLayout.LayoutParams( (width - Math.round(80 * density)) / 2, ViewGroup.LayoutParams.WRAP_CONTENT); confirmButtonParams.addRule(RelativeLayout.LEFT_OF, hDivider.getId()); confirmButtonParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); confirmButton.setLayoutParams(confirmButtonParams); confirmButton.setGravity(Gravity.CENTER); confirmButton.setTextColor(Color.parseColor("#FFFFFF")); confirmButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); confirmButton.setText(mActivity.getString(R.string.pg_sdk_edit_ok)); confirmButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (null != mListener) { mListener.onQuitDialogConfirm(); } } }); confirmButton.setBackgroundDrawable(drawable); buttonContainer.addView(confirmButton); Button closeButton = new Button(mActivity); RelativeLayout.LayoutParams closeButtonParams = new RelativeLayout.LayoutParams( (width - Math.round(80 * density)) / 2, ViewGroup.LayoutParams.WRAP_CONTENT); closeButtonParams.addRule(RelativeLayout.RIGHT_OF, hDivider.getId()); closeButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); closeButton.setLayoutParams(closeButtonParams); closeButton.setGravity(Gravity.CENTER); closeButton.setTextColor(Color.parseColor("#9f9f9f")); closeButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); closeButton.setText(mActivity.getString(R.string.pg_sdk_edit_quit)); closeButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); closeButton.setBackgroundDrawable(drawable); buttonContainer.addView(closeButton); container.addView(buttonContainer); root.addView(container); outerR = new float[] {20, 20, 20, 20, 20, 20, 20, 20}; roundRectShape = new RoundRectShape(outerR, null, null); drawable = new ShapeDrawable(roundRectShape); drawable.getPaint().setColor(Color.parseColor("#343434")); drawable.getPaint().setStyle(Paint.Style.FILL); container.setBackgroundDrawable(drawable); setContentView(root); getWindow() .setLayout( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); setCanceledOnTouchOutside(false); }
private View setCurrentUserRow() { View header1 = getLayoutInflater().inflate(R.layout.leaderboarditem, null, false); header1 .findViewById(R.id.alliance) .setVisibility(View.GONE); // alliance in user not implemented now TextView p = (TextView) header1.findViewById(R.id.position); p.setTextColor(Color.WHITE); p.setText(currentUser.position); TextView nickname = (TextView) header1.findViewById(R.id.nickname); nickname.setText(currentUser.name); TextView score = (TextView) header1.findViewById(R.id.score); NumberFormat nf = NumberFormat.getInstance(Locale.getDefault()); String formattedScore = nf.format(Double.parseDouble(currentUser.score)); if (currentUser.feed == null) score.setText(currentContext.getString(R.string.leadScore) + "\n" + formattedScore); else score.setText(currentUser.feed + ":\n" + formattedScore); header1.findViewById(R.id.image).setVisibility(LinearLayout.GONE); header1.findViewById(R.id.whiteline).setVisibility(LinearLayout.GONE); try { if (currentUser.imageUrl != null) { ImageView imageView = new ImageView(currentContext); imageView.setTag(currentUser.imageUrl); int size = (int) (50 * currentContext.getResources().getDisplayMetrics().density + 0.5f); imageView.setLayoutParams(new LinearLayout.LayoutParams(size, size)); imageManager.displayImage(currentUser.imageUrl, currentContext, imageView); LinearLayout a = (LinearLayout) header1.findViewById(R.id.item); a.addView(imageView, 0); } else { header1 .findViewById(R.id.item) .setPadding((int) (ratio * 5), (int) (ratio * 5), 0, (int) (ratio * 5)); } } catch (Exception e) { } LinearLayout positionView = (LinearLayout) header1.findViewById(R.id.post); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, (int) (ratio * 35)); params.setMargins(0, 0, (int) (ratio * 10), 0); positionView.setLayoutParams(params); positionView.setPadding((int) (ratio * 5), 0, (int) (ratio * 5), 0); positionView.setMinimumHeight((int) (ratio * 35)); positionView.setMinimumWidth((int) (ratio * 35)); positionView.setBackgroundDrawable( new BDrawableGradient(0, (int) (ratio * 35), BDrawableGradient.HIGH_GRAY_GRADIENT)); header1 .findViewById(R.id.item) .setBackgroundDrawable( new BDrawableGradient(0, (int) (ratio * 60), BDrawableGradient.LIGHT_GRAY_GRADIENT)); LinearLayout spacer = (LinearLayout) header1.findViewById(R.id.space); spacer.setVisibility(LinearLayout.VISIBLE); return header1; }
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Button main_eventos, main_sitios, main_buscar, main_descubre; // debe ser llamado para crear el menú, de lo contrario no aparecerán los items en el actionbar setHasOptionsMenu(true); changeActionBar(); setRetainInstance(true); // setRetainInstance(true) will tell the FragmentManager to keep the fragment around when the // containing Activity is killed and rebuilt for some reason. // It doesn't guarantee that the Fragment instance will stick around after a transaction to add // or replace. // hace referencia al objeto de la clase Main_fragment con todas las propiedades del slidingMenu slidingMenu = Main_FragmentActivity.putReference(); /*codigo de animationDrawable, fondo que cambia en la pantalla principal*/ // animacion asociada al linearLayout (tema 3 de Android - Dibujar en Android - pag 10) main_Layout = (LinearLayout) getActivity().findViewById(R.id.main_bg_layout); animacion_backgrounds = (AnimationDrawable) getActivity().getResources().getDrawable(R.anim.animacion_main_bg); // comprobacion si la version de android en la que se ejecuta es anterior a la // honeycomb(target16) // ya que setBackgroundDrawable es deprecated. if (Build.VERSION.SDK_INT <= 16) main_Layout.setBackgroundDrawable(animacion_backgrounds); else main_Layout.setBackground(animacion_backgrounds); new Handler() .postDelayed( new Runnable() { @Override public void run() { animacion_backgrounds.start(); } }, 500); // cambiar typeface's a los botones de la pantalla principal main_eventos = (Button) getActivity().findViewById(R.id.main_eventos_button); main_eventos.setTypeface(robotoBoldCondensed); main_eventos.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { newContent = new Main_Eventos(); if (newContent != null) { switchFragment(newContent); } } }); main_sitios = (Button) getActivity().findViewById(R.id.main_sitios_visitados_button); main_sitios.setTypeface(robotoBoldCondensed); main_buscar = (Button) getActivity().findViewById(R.id.main_buscar_sitio_button); main_buscar.setTypeface(robotoBoldCondensed); main_buscar.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { ArrayList<LugaresDeInteres_Item> arrayListAllLugares = LugaresDeInteres_Data_Objects.AllTheLugaresDeInteres(getActivity()); Main_FragmentActivity mFragmentActivity = (Main_FragmentActivity) getActivity(); mFragmentActivity.onBuscarSeleccionado(arrayListAllLugares); } }); main_descubre = (Button) getActivity().findViewById(R.id.main_descubre_button); main_descubre.setTypeface(robotoBoldCondensed); main_descubre.setOnClickListener( new OnClickListener() { // abrir el menu con el boton descubre valencia @Override public void onClick(View v) { if (slidingMenu.isShown()) new Handler() .postDelayed( new Runnable() { @Override public void run() { slidingMenu.toggle(); } }, 80); } }); }
// 创建通知详细信息界面 @SuppressLint("NewApi") private View createView(final String title, String message, final String uri) { final LinearLayout linearLayout = new LinearLayout(this); scrollView = new ScrollView(this); // linearLayout.setBackgroundColor(0xffeeeeee); Resources res = getResources(); // 设置背景图 Drawable dw = res.getDrawable(R.drawable.bg3); linearLayout.setBackgroundDrawable(dw); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setPadding(5, 5, 5, 5); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); linearLayout.setLayoutParams(layoutParams); TextView textTitle = new TextView(this); textTitle.setText(title); textTitle.setTextSize(21); // textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); textTitle.setTypeface(Typeface.DEFAULT, Typeface.BOLD); textTitle.setTextColor(0xffffff00); textTitle.setGravity(Gravity.CENTER); titleParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); titleParams.setMargins(5, 5, 5, 10); textTitle.setLayoutParams(titleParams); linearLayout.addView(textTitle); // 首先判断uri,如果uri包含video说明是视频信息,转入视频界面 // 如果是视频信息 if (message.startsWith("传来的是视频")) { Log.i("xiaobingo", "进入视频"); WebView messageDetial = new WebView(this); messageDetial.getSettings().setJavaScriptEnabled(true); messageDetial.getSettings().setAllowFileAccess(true); messageDetial.getSettings().setPluginsEnabled(true); messageDetial.getSettings().setSupportZoom(true); messageDetial.getSettings().setAppCacheEnabled(true); String former = message.split("xiaobingo")[0]; String after = message.split("xiaobingo")[1]; System.out.println("afterString:" + after); int urlStart = former.indexOf("=") + 1; rtmpUrl = former.substring(urlStart); fileName = after; // 视频直播 if (rtmpUrl.contains("live")) { msgEnd = fileName.indexOf(".flv"); fileName = fileName.substring(0, msgEnd); // 直播视频不加后缀 } // 视频点播 else { fileName = "flv:" + fileName; // flv:倒霉熊02.flv } Log.i("xiaobingo", "message是:" + message); Log.i("xiaobingo", "rtmpUrl是:" + rtmpUrl); Log.i("xiaobingo", "fileName:" + fileName); String htmlCode = "<embed " + "type=\"application/x-shockwave-flash\"" + "id=\"player1\" " + "name=\"player1\" " + "src=\"http://push.pkusz.edu.cn" + "/mediaplayer.swf\"" + "width=\"" + mobileWidth + "\"" + " height=\"" + mobileHeight / 2 + "\"" + " flashvars=@FILESRC@" + "allowfullscreen=\"true\"" + "allowscripaccess=\"always\"" + "/> "; Log.i("xiaobingo", "htmlCode:" + htmlCode); bodyHtml = htmlCode; bodyHtml = bodyHtml.replaceAll("@FILESRC@", "\"file=" + fileName + "&streamer=" + rtmpUrl + "\""); messageDetial.loadDataWithBaseURL( "http://127.0.0.1", htmlPre + bodyHtml + htmlPost, "text/html", "UTF-8", null); videoParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); videoParams.setMargins(1, 3, 3, 5); scrollView.setLayoutParams(videoParams); scrollView.addView(messageDetial); } else { TextView textDetails = new TextView(this); textDetails.setText(message); textDetails.setTextSize(17); // textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); textDetails.setTextColor(0xeeffeeee); textDetails.setGravity(Gravity.FILL); contentParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.7)); contentParams.setMargins(5, 3, 5, 5); scrollView.setLayoutParams(contentParams); scrollView.addView(textDetails); } linearLayout.addView(scrollView); // 点击详细按钮,连接到url,这里还须保存通知历史记录 Button okButton = new Button(this); okButton.setText("查看详细"); okButton.setTextSize(16); // okButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD); okButton.setTextColor(0xff6699ff); Drawable dr = res.getDrawable(R.drawable.button3); okButton.setBackgroundDrawable(dr); okButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Intent intent; if (uri != null && uri.length() > 0 && (uri.startsWith("http:") || uri.startsWith("https:") || uri.startsWith("tel:") || uri.startsWith("geo:"))) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); } else { intent = new Intent().setClassName(callbackActivityPackageName, callbackActivityClassName); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); } NotificationDetailsActivity.this.startActivity(intent); NotificationDetailsActivity.this.finish(); } }); // 回复button事件 final Button btn_response = new Button(this); btn_response.setText("我要留言"); btn_response.setTextSize(16); // btn_response.setTypeface(Typeface.DEFAULT, Typeface.BOLD); btn_response.setTextColor(0xff6699ff); btn_response.setBackgroundDrawable(dr); LinearLayout buttonLayout = new LinearLayout(this); buttonLayout.setGravity(Gravity.CENTER); buttonLayout.addView(okButton); // 添加“查看详细”按钮 buttonLayout.addView(btn_response); // 添加“我要留言”按钮 buttonParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); buttonParams.setMargins(3, 3, 3, 3); buttonLayout.setLayoutParams(buttonParams); // innerLayout.setGravity(1); linearLayout.addView(buttonLayout); // 我要留言事件 final EditText responseText = new EditText(this); responseText.setWidth((int) (mobileWidthPix * 0.6)); Button btn_send = new Button(this); btn_send.setText("留言"); btn_send.setTextSize(16); btn_send.setTypeface(Typeface.DEFAULT, Typeface.BOLD); btn_send.setTextColor(0xff6699ff); btn_send.setBackgroundDrawable(dr); responseLayout = new LinearLayout(this); responseLayout.setGravity(Gravity.CENTER); responseLayout.addView(responseText); responseLayout.addView(btn_send); responseParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.12)); responseParams.setMargins(3, 3, 3, 3); responseLayout.setLayoutParams(responseParams); btn_response.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // button点击一次,显示留言区 if (!flag) { contentParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.6)); contentParams.setMargins(5, 3, 5, 5); scrollView.setLayoutParams(contentParams); linearLayout.addView(responseLayout); } // button再点击一次,去除留言区 else { contentParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, (int) (mobileHeightPix * 0.7)); contentParams.setMargins(5, 3, 5, 5); scrollView.setLayoutParams(contentParams); linearLayout.removeView(responseLayout); } flag = !flag; } }); // 发送留言button事件 btn_send.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String myResponse = responseText.getText().toString(); String androidpnURL = "http://219.223.222.232/bbs-api/?"; /*--拼接POST字符串--*/ StringBuilder parameter = new StringBuilder(); parameter.append("action=newreply"); parameter.append("&tid="); Log.d("notificationUri", "notificationUri is:" + notificationUri); parameter.append(notificationUri.substring(notificationUri.indexOf("&tid=") + 5)); parameter.append("&message="); parameter.append(myResponse); parameter.append("&username=admin&password=123"); // androidpnURL += "action=newreply"; // androidpnURL += "&tid=58&message="; // androidpnURL += myResponse; // androidpnURL += "&username=admin&password=123"; // parameter.append("&androidName=admin&"); // parameter.append(originSharedPrefs.getString(Constants.XMPP_USERNAME, // "未知用户")); // parameter.append("&reply="); // parameter.append(myResponse); /*--End--*/ Log.i("LoginActivity", androidpnURL); String resp = GetPostUtil.send("POST", androidpnURL, parameter); Log.i("LoginActivity", "resp:" + resp); responseText.setText(""); // 清空留言区 } }); // linearLayout.setGravity(Gravity.BOTTOM); return linearLayout; }
/** Setup the layout graphical items based on the current theme. */ private void setupLayoutTheme() { if (_debug) Log.v("ThemeView.setupLayoutTheme() _themePackageName: " + _themePackageName); Drawable layoutBackgroundDrawable = null; Drawable rescheduleDrawable = null; Drawable ttsDrawable = null; int notificationCountTextColorID = 0; int headerInfoTextcolorID = 0; int contactNameTextColorID = 0; int contactNumberTextColorID = 0; int bodyTextColorID = 0; int buttonTextColorID = 0; String themeName = null; if (_themePackageName.startsWith(Constants.DARK_TRANSLUCENT_THEME)) { _resources = _context.getResources(); if (_themePackageName.equals(Constants.DARK_TRANSLUCENT_THEME)) { layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel); themeName = _context.getString(R.string.notify_theme) + " - " + _context.getString(R.string.default_v1); } else if (_themePackageName.equals(Constants.DARK_TRANSLUCENT_V2_THEME)) { layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel_v2); themeName = _context.getString(R.string.notify_theme) + " - " + _context.getString(R.string.default_v2); } else if (_themePackageName.equals(Constants.DARK_TRANSLUCENT_V3_THEME)) { layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel_v3); themeName = _context.getString(R.string.notify_theme) + " - " + _context.getString(R.string.default_v3); } rescheduleDrawable = _resources.getDrawable(R.drawable.ic_reschedule); ttsDrawable = _resources.getDrawable(R.drawable.ic_tts); notificationCountTextColorID = _resources.getColor(R.color.notification_count_text_color); headerInfoTextcolorID = _resources.getColor(R.color.header_info_text_color); contactNameTextColorID = _resources.getColor(R.color.contact_name_text_color); contactNumberTextColorID = _resources.getColor(R.color.contact_number_text_color); bodyTextColorID = _resources.getColor(R.color.body_text_color); buttonTextColorID = _resources.getColor(R.color.button_text_color); } else { try { _resources = _context.getPackageManager().getResourcesForApplication(_themePackageName); layoutBackgroundDrawable = _resources.getDrawable( _resources.getIdentifier( _themePackageName + ":drawable/background_panel", null, null)); rescheduleDrawable = _resources.getDrawable( _resources.getIdentifier( _themePackageName + ":drawable/ic_reschedule", null, null)); ttsDrawable = _resources.getDrawable( _resources.getIdentifier(_themePackageName + ":drawable/ic_tts", null, null)); notificationCountTextColorID = _resources.getColor( _resources.getIdentifier( _themePackageName + ":color/notification_count_text_color", null, null)); headerInfoTextcolorID = _resources.getColor( _resources.getIdentifier( _themePackageName + ":color/header_info_text_color", null, null)); contactNameTextColorID = _resources.getColor( _resources.getIdentifier( _themePackageName + ":color/contact_name_text_color", null, null)); contactNumberTextColorID = _resources.getColor( _resources.getIdentifier( _themePackageName + ":color/contact_number_text_color", null, null)); bodyTextColorID = _resources.getColor( _resources.getIdentifier(_themePackageName + ":color/body_text_color", null, null)); buttonTextColorID = _resources.getColor( _resources.getIdentifier( _themePackageName + ":color/button_text_color", null, null)); themeName = _resources.getString( _resources.getIdentifier(_themePackageName + ":string/app_name_desc", null, null)); } catch (NameNotFoundException ex) { Log.e("ThemeView.setupLayoutTheme() Loading Theme Package ERROR: " + ex.toString()); _themePackageName = Constants.DARK_TRANSLUCENT_THEME; _resources = _context.getResources(); layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel); rescheduleDrawable = _resources.getDrawable(R.drawable.ic_reschedule); ttsDrawable = _resources.getDrawable(R.drawable.ic_tts); notificationCountTextColorID = _resources.getColor(R.color.notification_count_text_color); headerInfoTextcolorID = _resources.getColor(R.color.header_info_text_color); contactNameTextColorID = _resources.getColor(R.color.contact_name_text_color); contactNumberTextColorID = _resources.getColor(R.color.contact_number_text_color); bodyTextColorID = _resources.getColor(R.color.body_text_color); buttonTextColorID = _resources.getColor(R.color.button_text_color); themeName = _context.getString(R.string.notify_theme) + " - " + _context.getString(R.string.default_v1); } } _notificationWindowLinearLayout.setBackgroundDrawable(layoutBackgroundDrawable); _notificationCountTextView.setTextColor(notificationCountTextColorID); _notificationInfoTextView.setTextColor(headerInfoTextcolorID); _contactNameTextView.setTextColor(contactNameTextColorID); _contactNumberTextView.setTextColor(contactNumberTextColorID); _notificationDetailsTextView.setTextColor(bodyTextColorID); _notificationDetailsTextView.setLinkTextColor(bodyTextColorID); _mmsLinkTextView.setTextColor(bodyTextColorID); _previousButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NAV_PREV)); _nextButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NAV_NEXT)); _dismissButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _deleteButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _callButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _replyButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _viewButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _dismissButton.setTextColor(buttonTextColorID); _deleteButton.setTextColor(buttonTextColorID); _callButton.setTextColor(buttonTextColorID); _replyButton.setTextColor(buttonTextColorID); _viewButton.setTextColor(buttonTextColorID); _dismissImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _deleteImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _callImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _replyImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _viewImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL)); _rescheduleButton.setImageDrawable(rescheduleDrawable); _ttsButton.setImageDrawable(ttsDrawable); _themeNameTextView.setText(themeName); }
@SuppressWarnings("deprecation") @Override protected void onCreateLayout(boolean firstCreation) { setContentView(R.layout.activity_effects); audioSink = Player.localAudioSinkUsedInEffects; panelControls = (LinearLayout) findViewById(R.id.panelControls); panelControls.setBackgroundDrawable(new ColorDrawable(UI.color_list)); panelEqualizer = (LinearLayout) findViewById(R.id.panelEqualizer); panelSecondary = (ViewGroup) findViewById(R.id.panelSecondary); if (panelSecondary instanceof ScrollView) { panelSecondary.setHorizontalFadingEdgeEnabled(false); panelSecondary.setVerticalFadingEdgeEnabled(false); panelSecondary.setFadingEdgeLength(0); } btnGoBack = (BgButton) findViewById(R.id.btnGoBack); btnGoBack.setOnClickListener(this); btnGoBack.setIcon(UI.ICON_GOBACK); chkEqualizer = (BgButton) findViewById(R.id.chkEqualizer); chkEqualizer.setOnClickListener(this); chkEqualizer.setTextColor(UI.colorState_text_listitem_reactive); chkEqualizer.formatAsLabelledCheckBox(); chkBass = (BgButton) findViewById(R.id.chkBass); chkBass.setOnClickListener(this); chkBass.setTextColor(UI.colorState_text_listitem_reactive); chkBass.formatAsLabelledCheckBox(); chkVirtualizer = (BgButton) findViewById(R.id.chkVirtualizer); chkVirtualizer.setOnClickListener(this); chkVirtualizer.setTextColor(UI.colorState_text_listitem_reactive); chkVirtualizer.formatAsLabelledCheckBox(); btnMenu = (BgButton) findViewById(R.id.btnMenu); btnMenu.setOnClickListener(this); btnMenu.setIcon(UI.ICON_MENU); btnChangeEffect = (BgButton) findViewById(R.id.btnChangeEffect); if (btnChangeEffect != null) { btnChangeEffect.setOnClickListener(this); btnChangeEffect.setCompoundDrawables( new TextIconDrawable( UI.ICON_EQUALIZER, UI.color_text_listitem, UI.defaultControlContentsSize), null, null, null); btnChangeEffect.setMinimumHeight(UI.defaultControlSize); btnChangeEffect.setTextColor(UI.colorState_text_listitem_reactive); } else { UI.isLargeScreen = true; Player.bassBoostMode = false; } barBass = (BgSeekBar) findViewById(R.id.barBass); barBass.setMax(BassBoost.getMaxStrength()); barBass.setValue(BassBoost.getStrength(audioSink)); barBass.setKeyIncrement(BassBoost.getMaxStrength() / 50); barBass.setOnBgSeekBarChangeListener(this); barBass.setInsideList(true); barBass.setAdditionalContentDescription(getText(R.string.bass_boost).toString()); barVirtualizer = (BgSeekBar) findViewById(R.id.barVirtualizer); barVirtualizer.setMax(Virtualizer.getMaxStrength()); barVirtualizer.setValue(Virtualizer.getStrength(audioSink)); barVirtualizer.setKeyIncrement(Virtualizer.getMaxStrength() / 50); barVirtualizer.setOnBgSeekBarChangeListener(this); barVirtualizer.setInsideList(true); barVirtualizer.setAdditionalContentDescription(getText(R.string.virtualization).toString()); LinearLayout.LayoutParams lp; if (!UI.isLargeScreen && UI.isLandscape) { if (btnChangeEffect != null) { lp = (LinearLayout.LayoutParams) btnChangeEffect.getLayoutParams(); lp.topMargin = 0; btnChangeEffect.setLayoutParams(lp); } lp = (LinearLayout.LayoutParams) chkEqualizer.getLayoutParams(); lp.bottomMargin = 0; chkEqualizer.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) chkBass.getLayoutParams(); lp.bottomMargin = 0; chkBass.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) chkVirtualizer.getLayoutParams(); lp.bottomMargin = 0; chkVirtualizer.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) barBass.getLayoutParams(); lp.bottomMargin = UI.controlMargin; barBass.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) barVirtualizer.getLayoutParams(); lp.bottomMargin = UI.controlMargin; barVirtualizer.setLayoutParams(lp); panelControls.setPadding( UI.controlLargeMargin, UI.thickDividerSize, UI.controlLargeMargin, 0); } else if (UI.isLargeScreen) { UI.prepareViewPaddingForLargeScreen( panelControls, 0, (screenNotSoLarge && !UI.isLandscape) ? UI.controlMargin : UI.controlLargeMargin); if (!UI.isLandscape && (panelControls instanceof LinearLayout)) { panelControls.setOrientation(LinearLayout.VERTICAL); panelControls.setWeightSum(0); final int margin = (screenNotSoLarge ? UI.controlMargin : (UI.controlLargeMargin << 1)); lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.leftMargin = margin; lp.topMargin = margin; lp.rightMargin = margin; lp.bottomMargin = margin; panelSecondary.setLayoutParams(lp); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0); lp.weight = 1; lp.leftMargin = margin; lp.topMargin = (screenNotSoLarge ? UI.controlLargeMargin : margin); lp.rightMargin = margin; lp.bottomMargin = margin; panelEqualizer.setLayoutParams(lp); if (screenNotSoLarge) { lp = (LinearLayout.LayoutParams) barBass.getLayoutParams(); lp.bottomMargin = UI.controlLargeMargin; barBass.setLayoutParams(lp); lp = (LinearLayout.LayoutParams) barVirtualizer.getLayoutParams(); lp.bottomMargin = UI.controlLargeMargin; barVirtualizer.setLayoutParams(lp); } } } else { panelControls.setPadding(UI.controlMargin, UI.thickDividerSize, UI.controlMargin, 0); } UI.prepareControlContainer(findViewById(R.id.panelTop), false, true); prepareViewForMode(true); }
/** Formats message as a View suitable for a conversation list */ private View oneMessageToView(ConversationOneMessage oMsg) { final String method = "oneMessageToView"; if (MyLog.isLoggable(this, MyLog.VERBOSE)) { MyLog.v( this, method + ": msgId=" + oMsg.msgId + (oMsg.avatarDrawable != null ? ", avatar=" + oMsg.avatarDrawable.getFileName() : "")); } LayoutInflater inflater = LayoutInflater.from(context); int layoutResource = R.layout.message_conversation; if (!Activity.class.isAssignableFrom(context.getClass())) { MyLog.w(this, "Context should be from an Activity"); } View messageView = inflater.inflate(layoutResource, null); messageView.setOnCreateContextMenuListener(contextMenu); float displayDensity = context.getResources().getDisplayMetrics().density; // See // http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-code int indent0 = (int) (10 * displayDensity); int indentPixels = indent0 * oMsg.indentLevel; LinearLayout messageIndented = (LinearLayout) messageView.findViewById(R.id.message_indented); if (oMsg.msgId == selectedMessageId && oMsgs.size() > 1) { messageIndented.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.message_current_background)); } int viewToTheLeftId = 0; if (oMsg.indentLevel > 0) { View divider = messageView.findViewById(R.id.divider); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1); layoutParams.leftMargin = indentPixels - 4; divider.setLayoutParams(layoutParams); if (MyLog.isLoggable(this, MyLog.VERBOSE)) { MyLog.v(this, "density=" + displayDensity); } viewToTheLeftId = 2; ImageView indentView = new ConversationIndentImageView(context, messageIndented, indentPixels); indentView.setId(viewToTheLeftId); ((ViewGroup) messageIndented.getParent()).addView(indentView); } if (MyPreferences.showAvatars()) { ImageView avatarView = new ImageView(context); int size = Math.round(AvatarDrawable.AVATAR_SIZE_DIP * displayDensity); avatarView.setScaleType(ScaleType.FIT_CENTER); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(size, size); layoutParams.topMargin = 3; if (oMsg.indentLevel > 0) { layoutParams.leftMargin = 1; } if (viewToTheLeftId == 0) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } else { layoutParams.addRule(RelativeLayout.RIGHT_OF, viewToTheLeftId); } avatarView.setLayoutParams(layoutParams); avatarView.setImageDrawable(oMsg.avatarDrawable.getDrawable()); indentPixels += size; ((ViewGroup) messageIndented.getParent()).addView(avatarView); } messageIndented.setPadding(indentPixels + 6, 2, 6, 2); TextView id = (TextView) messageView.findViewById(R.id.id); id.setText(Long.toString(oMsg.msgId)); TextView linkedUserId = (TextView) messageView.findViewById(R.id.linked_user_id); linkedUserId.setText(Long.toString(oMsg.linkedUserId)); TextView author = (TextView) messageView.findViewById(R.id.message_author); TextView body = (TextView) messageView.findViewById(R.id.message_body); TextView details = (TextView) messageView.findViewById(R.id.message_details); author.setText(oMsg.author); TextView number = (TextView) messageView.findViewById(R.id.message_number); number.setText(Integer.toString(oMsg.historyOrder)); if (!TextUtils.isEmpty(oMsg.body)) { body.setLinksClickable(true); body.setMovementMethod(LinkMovementMethod.getInstance()); body.setFocusable(true); body.setFocusableInTouchMode(true); Spanned spanned = Html.fromHtml(oMsg.body); body.setText(spanned); if (!MbMessage.hasUrlSpans(spanned)) { Linkify.addLinks(body, Linkify.ALL); } } // Everything else goes to messageDetails String messageDetails = RelativeTime.getDifference(context, oMsg.createdDate); if (!SharedPreferencesUtil.isEmpty(oMsg.via)) { messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context.getText(R.string.message_source_from).toString(), oMsg.via); } if (oMsg.inReplyToMsgId != 0) { String inReplyToName = oMsg.inReplyToName; if (SharedPreferencesUtil.isEmpty(inReplyToName)) { inReplyToName = "..."; } messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context.getText(R.string.message_source_in_reply_to).toString(), oMsg.inReplyToName) + " (" + msgIdToHistoryOrder(oMsg.inReplyToMsgId) + ")"; } if (!SharedPreferencesUtil.isEmpty(oMsg.rebloggersString) && !oMsg.rebloggersString.equals(oMsg.author)) { if (!SharedPreferencesUtil.isEmpty(oMsg.inReplyToName)) { messageDetails += ";"; } messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context .getText(ma.alternativeTermForResourceId(R.string.reblogged_by)) .toString(), oMsg.rebloggersString); } if (!SharedPreferencesUtil.isEmpty(oMsg.recipientName)) { messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context.getText(R.string.message_source_to).toString(), oMsg.recipientName); } if (MyLog.isLoggable(this, MyLog.VERBOSE)) { messageDetails = messageDetails + " (i" + oMsg.indentLevel + ",r" + oMsg.replyLevel + ")"; } details.setText(messageDetails); ImageView favorited = (ImageView) messageView.findViewById(R.id.message_favorited); favorited.setImageResource( oMsg.favorited ? android.R.drawable.star_on : android.R.drawable.star_off); return messageView; }
private void initComponents() { LinearLayout llRoot = (LinearLayout) this.findViewById(R.id.llRoot); LinearLayout llHeaderBase = (LinearLayout) this.findViewById(R.id.llHeaderBase); LinearLayout llHeaderUserSelector = (LinearLayout) this.findViewById(R.id.llHeaderUserSelector); EditText etFilterName = (EditText) this.findViewById(R.id.etFilterName); Button btnSearch = (Button) findViewById(R.id.btnSearch); btnFollowing = (Button) findViewById(R.id.btnFollowing); btnRecentContact = (Button) findViewById(R.id.btnRecentContact); lvUser = (ListView) this.findViewById(R.id.lvUser); LinearLayout llToolbar = (LinearLayout) this.findViewById(R.id.llToolbar); Button btnConfirm = (Button) this.findViewById(R.id.btnConfirm); Button btnCancel = (Button) this.findViewById(R.id.btnCancel); ThemeUtil.setRootBackground(llRoot); ThemeUtil.setSecondaryHeader(llHeaderBase); llHeaderUserSelector.setBackgroundDrawable(theme.getDrawable("bg_header_corner_search")); int padding6 = theme.dip2px(6); int padding8 = theme.dip2px(8); llHeaderUserSelector.setPadding(padding6, padding8, padding6, padding8); etFilterName.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half")); btnSearch.setBackgroundDrawable(theme.getDrawable("selector_btn_search")); btnFollowing.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_left")); btnFollowing.setPadding(0, 0, 0, 0); ColorStateList selectorBtnTab = theme.getColorStateList("selector_btn_tab"); btnFollowing.setTextColor(selectorBtnTab); btnFollowing.setGravity(Gravity.CENTER); btnRecentContact.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_right")); btnRecentContact.setPadding(0, 0, 0, 0); btnRecentContact.setTextColor(selectorBtnTab); btnRecentContact.setGravity(Gravity.CENTER); ThemeUtil.setListViewStyle(lvUser); llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar")); ThemeUtil.setBtnActionPositive(btnConfirm); ThemeUtil.setBtnActionNegative(btnCancel); TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle); tvTitle.setText(title); selectorAdapter = new UserQuickSelectorListAdapter(this, account, selectMode); showLoadingFooter(); lvUser.setAdapter(selectorAdapter); lvUser.setFastScrollEnabled(yibo.isSliderEnabled()); setBack2Top(lvUser); recyclerListener = new UserSelectorRecyclerListener(); lvUser.setRecyclerListener(recyclerListener); lvUser.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == parent.getCount() - 1) { view.performClick(); } else { CheckBox checkBox = (CheckBox) view.findViewById(R.id.cbUser); checkBox.performClick(); UserQuickSelectorActivity.this.updateButtonState(); } } }); }
public void displayAccounts() { accounts = b2evolution.DB.getAccounts(this); HashMap<?, ?> notificationOptions = b2evolution.DB.getNotificationOptions(this); boolean sound = false, vibrate = false, light = false, taglineValue = false; String tagline = ""; if (notificationOptions != null) { if (notificationOptions.get("sound").toString().equals("1")) { sound = true; } if (notificationOptions.get("vibrate").toString().equals("1")) { vibrate = true; } if (notificationOptions.get("light").toString().equals("1")) { light = true; } if (notificationOptions.get("tagline_flag").toString().equals("1")) { taglineValue = true; } tagline = notificationOptions.get("tagline").toString(); } if (accounts.size() > 0) { ScrollView sv = new ScrollView(this); sv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); sv.setBackgroundColor(Color.parseColor("#FFFFFFFF")); LinearLayout layout = new LinearLayout(this); layout.setPadding(14, 14, 14, 14); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.LEFT); final LinearLayout cbLayout = new LinearLayout(this); cbLayout.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); cbLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams section1Params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); section1Params.setMargins(0, 0, 0, 20); LinearLayout section1 = new LinearLayout(this); section1.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg)); section1.setLayoutParams(section1Params); section1.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams headerParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); headerParams.setMargins(1, 1, 1, 0); TextView textView = new TextView(this); textView.setLayoutParams(headerParams); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setPadding(0, 4, 0, 4); textView.setShadowLayer(1, 0, 2, Color.parseColor("#FFFFFFFF")); textView.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg_header)); textView.setText(" " + getResources().getText(R.string.comment_notifications)); section1.addView(textView); LinearLayout.LayoutParams cbParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); cbParams.setMargins(4, 0, 0, 6); for (int i = 0; i < accounts.size(); i++) { HashMap<?, ?> curHash = (HashMap<?, ?>) accounts.get(i); String curBlogName = curHash.get("blogName").toString(); String accountID = curHash.get("id").toString(); int runService = Integer.valueOf(curHash.get("runService").toString()); accountNames.add(i, curBlogName); final CheckBox checkBox = new CheckBox(this); checkBox.setTextColor(Color.parseColor("#444444")); checkBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); checkBox.setText(EscapeUtils.unescapeHtml(curBlogName)); checkBox.setId(Integer.valueOf(accountID)); checkBox.setLayoutParams(cbParams); if (runService == 1) { checkBox.setChecked(true); } cbLayout.addView(checkBox); } if (cbLayout.getChildCount() > 0) { section1.addView(cbLayout); } // add spinner and buttons TextView textView2 = new TextView(this); LinearLayout.LayoutParams labelParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelParams.setMargins(8, 0, 0, 0); textView2.setLayoutParams(labelParams); textView2.setTextColor(Color.parseColor("#444444")); textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView2.setText(getResources().getText(R.string.notifications_interval)); section1.addView(textView2); final Spinner sInterval = new Spinner(this); LinearLayout.LayoutParams spinnerParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); spinnerParams.setMargins(4, 0, 4, 10); sInterval.setLayoutParams(spinnerParams); ArrayAdapter<Object> sIntervalArrayAdapter = new ArrayAdapter<Object>( this, R.layout.spinner_textview, new String[] { "5 Minutes", "10 Minutes", "15 Minutes", "30 Minutes", "1 Hour", "3 Hours", "6 Hours", "12 Hours", "Daily" }); sIntervalArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sInterval.setAdapter(sIntervalArrayAdapter); String interval = b2evolution.DB.getInterval(this); if (interval != "") { sInterval.setSelection(sIntervalArrayAdapter.getPosition(interval)); } section1.addView(sInterval); final LinearLayout nOptionsLayout = new LinearLayout(this); nOptionsLayout.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); nOptionsLayout.setOrientation(LinearLayout.VERTICAL); CheckBox soundCB = new CheckBox(this); soundCB.setTag("soundCB"); soundCB.setTextColor(Color.parseColor("#444444")); soundCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); soundCB.setText(getResources().getText(R.string.notification_sound)); soundCB.setLayoutParams(cbParams); soundCB.setChecked(sound); nOptionsLayout.addView(soundCB); CheckBox vibrateCB = new CheckBox(this); vibrateCB.setTag("vibrateCB"); vibrateCB.setTextColor(Color.parseColor("#444444")); vibrateCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); vibrateCB.setText(getResources().getText(R.string.notification_vibrate)); vibrateCB.setLayoutParams(cbParams); vibrateCB.setChecked(vibrate); nOptionsLayout.addView(vibrateCB); CheckBox lightCB = new CheckBox(this); lightCB.setTag("lightCB"); lightCB.setTextColor(Color.parseColor("#444444")); lightCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); lightCB.setText(getResources().getText(R.string.notification_blink)); lightCB.setLayoutParams(cbParams); lightCB.setChecked(light); nOptionsLayout.addView(lightCB); section1.addView(nOptionsLayout); layout.addView(section1); final LinearLayout section2 = new LinearLayout(this); section2.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg)); section2.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams section2Params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); section2Params.setMargins(0, 0, 0, 20); section2.setLayoutParams(section2Params); section2.setPadding(0, 0, 0, 10); TextView section2lbl = new TextView(this); section2lbl.setLayoutParams(headerParams); section2lbl.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); section2lbl.setTypeface(Typeface.DEFAULT_BOLD); section2lbl.setShadowLayer(1, 0, 2, Color.parseColor("#FFFFFFFF")); section2lbl.setPadding(0, 4, 0, 4); section2lbl.setText(" " + getResources().getText(R.string.post_signature)); section2lbl.setBackgroundDrawable(getResources().getDrawable(R.drawable.content_bg_header)); section2.addView(section2lbl); CheckBox taglineCB = new CheckBox(this); taglineCB.setTag("taglineCB"); taglineCB.setTextColor(Color.parseColor("#444444")); taglineCB.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); taglineCB.setText(getResources().getText(R.string.add_tagline)); taglineCB.setLayoutParams(cbParams); taglineCB.setChecked(taglineValue); section2.addView(taglineCB); EditText taglineET = new EditText(this); LinearLayout.LayoutParams taglineParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); taglineParams.setMargins(4, 0, 4, 4); taglineET.setLayoutParams(taglineParams); if (tagline != null) { if (tagline.equals("")) { if (BlackBerryUtils.getInstance().isBlackBerry()) taglineET.setText(getResources().getText(R.string.posted_from_blackberry)); else taglineET.setText(getResources().getText(R.string.posted_from)); } else { taglineET.setText(tagline); } } taglineET.setMinLines(2); section2.addView(taglineET); layout.addView(section2); final LinearLayout section3 = new LinearLayout(this); section3.setOrientation(LinearLayout.HORIZONTAL); section3.setGravity(Gravity.RIGHT); LinearLayout.LayoutParams section3Params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); section3Params.setMargins(0, 0, 0, 20); section3.setLayoutParams(section3Params); final Button cancel = new Button(this); LinearLayout.LayoutParams cancelParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); cancelParams.setMargins(0, 0, 10, 0); cancel.setLayoutParams(cancelParams); cancel.setBackgroundDrawable(getResources().getDrawable(R.drawable.b2evo_button_small)); cancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); cancel.setText(getResources().getText(R.string.cancel)); cancel.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { finish(); } }); section3.addView(cancel); final Button save = new Button(this); save.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT)); save.setBackgroundDrawable(getResources().getDrawable(R.drawable.b2evo_button_small)); save.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); save.setText(getResources().getText(R.string.save)); save.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { boolean sound = false, vibrate = false, light = false, tagValue = false; checkCtr = 0; int listItemCount = cbLayout.getChildCount(); for (int i = 0; i < listItemCount; i++) { CheckBox cbox = (CheckBox) cbLayout.getChildAt(i); int id = cbox.getId(); if (cbox.isChecked()) { checkCtr++; b2evolution.DB.updateNotificationFlag(id, true); Log.i("CommentService", "Service enabled for " + cbox.getText()); } else { b2evolution.DB.updateNotificationFlag(id, false); } } int noOptionsItemCount = nOptionsLayout.getChildCount(); for (int i = 0; i < noOptionsItemCount; i++) { CheckBox cbox = (CheckBox) nOptionsLayout.getChildAt(i); if (cbox.getTag().equals("soundCB")) { sound = cbox.isChecked(); } else if (cbox.getTag().equals("vibrateCB")) { vibrate = cbox.isChecked(); } else if (cbox.getTag().equals("lightCB")) { light = cbox.isChecked(); } } CheckBox tagFlag = (CheckBox) section2.getChildAt(1); tagValue = tagFlag.isChecked(); EditText taglineET = (EditText) section2.getChildAt(2); String taglineText = taglineET.getText().toString(); b2evolution.DB.updateNotificationSettings( sInterval.getSelectedItem().toString(), sound, vibrate, light, tagValue, taglineText); if (checkCtr > 0) { String updateInterval = sInterval.getSelectedItem().toString(); int UPDATE_INTERVAL = 3600000; // configure time interval if (updateInterval.equals("5 Minutes")) { UPDATE_INTERVAL = 300000; } else if (updateInterval.equals("10 Minutes")) { UPDATE_INTERVAL = 600000; } else if (updateInterval.equals("15 Minutes")) { UPDATE_INTERVAL = 900000; } else if (updateInterval.equals("30 Minutes")) { UPDATE_INTERVAL = 1800000; } else if (updateInterval.equals("1 Hour")) { UPDATE_INTERVAL = 3600000; } else if (updateInterval.equals("3 Hours")) { UPDATE_INTERVAL = 10800000; } else if (updateInterval.equals("6 Hours")) { UPDATE_INTERVAL = 21600000; } else if (updateInterval.equals("12 Hours")) { UPDATE_INTERVAL = 43200000; } else if (updateInterval.equals("Daily")) { UPDATE_INTERVAL = 86400000; } Intent intent = new Intent(Preferences.this, CommentBroadcastReceiver.class); PendingIntent pIntent = PendingIntent.getBroadcast(Preferences.this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.setRepeating( AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), UPDATE_INTERVAL, pIntent); } else { Intent stopIntent = new Intent(Preferences.this, CommentBroadcastReceiver.class); PendingIntent stopPIntent = PendingIntent.getBroadcast(Preferences.this, 0, stopIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.cancel(stopPIntent); Intent service = new Intent(Preferences.this, CommentService.class); stopService(service); } finish(); } }); section3.addView(save); layout.addView(section3); sv.addView(layout); setContentView(sv); } }