Exemplo n.º 1
0
  @Override
  public void setBackgroundColor(int color) {
    super.setBackgroundColor(color);

    if (this.childView != null) {
      this.childView.setBackgroundColor(color);
    }
  }
Exemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    profilePictures = new ArrayList<MLRoundedImageView>();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    myInflater = inflater;
    scroller = new ScrollView(getActivity().getApplicationContext());
    layout = new LinearLayout(getActivity().getApplicationContext());
    layout.setPadding(0, 5, 0, 5);
    layout.setOrientation(LinearLayout.VERTICAL);

    scroller.addView(layout);
    scroller.setBackgroundColor(Color.parseColor(Utils.BACKGROUND_COLOR));

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }
    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }

    return scroller;
  }
Exemplo n.º 3
0
 public void setText(String name, String text) {
   if (!mConformanceMode) {
     if (null == mScrollText) {
       mScrollText = new ScrollView(mContext);
       mScrollText.setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
       addView(
           mScrollText,
           new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0));
       if (DEBUG) {
         mScrollText.setBackgroundColor(0xFF00FF00);
       }
     }
     if (null == mTextView) {
       mTextView = new TextView(mContext);
       mTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
       mScrollText.addView(mTextView);
     }
     mScrollText.requestFocus();
   }
   mTextView.setVisibility(View.VISIBLE);
   mTextView.setText(text);
 }
  @Override
  public View onCreateView(
      final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_settings, container, false);

    shp = getActivity().getSharedPreferences("wallpaper", Context.MODE_PRIVATE);
    ed = shp.edit();

    baseColor = getResources().getColor(R.color.primary);
    final ActorStyle style = ActorSDK.sharedActor().style;
    final UserVM userModel = users().get(myUid());

    final TextView nameView = (TextView) view.findViewById(R.id.name);
    nameView.setShadowLayer(1, 1, 1, style.getDividerColor());
    nameView.setTextColor(style.getProfileTitleColor());
    bind(nameView, userModel.getName());

    view.findViewById(R.id.notifications)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(getActivity(), NotificationsActivity.class));
              }
            });

    view.findViewById(R.id.helpSettings)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(getActivity(), HelpActivity.class));
              }
            });

    final LinearLayout nickContainer = (LinearLayout) view.findViewById(R.id.nickContainer);
    final LinearLayout contactsContainer = (LinearLayout) view.findViewById(R.id.phoneContainer);
    final FrameLayout about = (FrameLayout) view.findViewById(R.id.about);

    // TODO: Move bindings to onResume
    bind(
        userModel.getNick(),
        new ValueChangedListener<String>() {
          @Override
          public void onChanged(final String val, Value<String> Value) {
            final View recordView = inflater.inflate(R.layout.contact_record, nickContainer, false);
            recordView
                .findViewById(R.id.divider)
                .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
            TintImageView nickIcon = (TintImageView) recordView.findViewById(R.id.recordIcon);
            nickIcon.setTint(ActorSDK.sharedActor().style.getSettingsCategoryTextColor());
            nickIcon.setResource(R.drawable.ic_star_white_36dp);

            String value =
                (val != null && !val.isEmpty()) ? val : getString(R.string.nickname_empty);
            String title = getString(R.string.nickname);

            TextView nickValue = (TextView) recordView.findViewById(R.id.value);
            nickValue.setText(value);
            nickValue.setTextColor(style.getTextPrimaryColor());
            TextView nickTitle = (TextView) recordView.findViewById(R.id.title);
            nickTitle.setText(title);
            nickTitle.setTextColor(style.getTextSecondaryColor());
            nickContainer.removeAllViews();
            nickContainer.addView(
                recordView,
                new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(72)));

            recordView.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    getActivity().startActivity(Intents.editUserNick(getActivity()));
                  }
                });
          }
        });

    final TextView aboutTitle = (TextView) about.findViewById(R.id.value);
    TintImageView aboutIcon = (TintImageView) about.findViewById(R.id.recordIcon);
    aboutIcon.setTint(ActorSDK.sharedActor().style.getSettingsCategoryTextColor());
    aboutIcon.setResource(R.drawable.ic_editor_format_quote_36dp);
    TextView aboutValue = (TextView) about.findViewById(R.id.title);
    aboutTitle.setTextColor(style.getTextPrimaryColor());
    aboutValue.setTextColor(style.getTextSecondaryColor());
    aboutValue.setText(getString(R.string.about_user_me));
    aboutTitle.setEllipsize(TextUtils.TruncateAt.END);
    about
        .findViewById(R.id.divider)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    about.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            getActivity().startActivity(Intents.editUserAbout(getActivity()));
          }
        });

    bind(
        userModel.getAbout(),
        new ValueChangedListener<String>() {
          @Override
          public void onChanged(String val, Value<String> valueModel) {
            if (val != null && !val.isEmpty()) {
              aboutTitle.setText(val);
            } else {
              aboutTitle.setText(getString(R.string.edit_about_edittext_hint));
            }
          }
        });

    bind(
        userModel.getPhones(),
        new ValueChangedListener<ArrayListUserPhone>() {
          @Override
          public void onChanged(ArrayListUserPhone val, Value<ArrayListUserPhone> Value) {
            if (val.size() == 0) {
              noPhones = true;
            } else {
              contactsContainer.setVisibility(View.VISIBLE);
              for (int i = 0; i < val.size(); i++) {
                final UserPhone record = val.get(i);
                View recordView =
                    inflater.inflate(R.layout.contact_record, contactsContainer, false);
                TintImageView tintImageView =
                    (TintImageView) recordView.findViewById(R.id.recordIcon);
                tintImageView.setTint(ActorSDK.sharedActor().style.getSettingsCategoryTextColor());
                if (i == 0) {
                  tintImageView.setResource(R.drawable.ic_call_white_36dp);
                  tintImageView.setVisibility(View.VISIBLE);
                } else {
                  tintImageView.setVisibility(View.INVISIBLE);
                }

                View divider = recordView.findViewById(R.id.divider);
                if (i == val.size() - 1
                    && (userModel.getEmails().get() == null
                        || userModel.getEmails().get().isEmpty())) {
                  divider.setVisibility(View.GONE);
                } else {
                  divider.setVisibility(View.VISIBLE);
                }
                divider.setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());

                String _phoneNumber;
                try {
                  Phonenumber.PhoneNumber number =
                      PhoneNumberUtil.getInstance().parse("+" + record.getPhone(), "us");
                  _phoneNumber =
                      PhoneNumberUtil.getInstance()
                          .format(number, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL);
                } catch (NumberParseException e) {
                  e.printStackTrace();
                  _phoneNumber = "+" + record.getPhone();
                }
                final String phoneNumber = _phoneNumber;

                TextView value = (TextView) recordView.findViewById(R.id.value);
                value.setTextColor(style.getTextPrimaryColor());
                value.setText(phoneNumber);
                TextView title = (TextView) recordView.findViewById(R.id.title);
                title.setTextColor(style.getTextSecondaryColor());
                title.setText(record.getTitle());
                contactsContainer.addView(
                    recordView,
                    new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(72)));

                recordView.setOnClickListener(
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        new AlertDialog.Builder(getActivity())
                            .setItems(
                                new CharSequence[] {
                                  getString(R.string.phone_menu_call).replace("{0}", phoneNumber),
                                  getString(R.string.phone_menu_sms).replace("{0}", phoneNumber),
                                  getString(R.string.phone_menu_share).replace("{0}", phoneNumber),
                                  getString(R.string.phone_menu_copy)
                                },
                                new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialog, int which) {
                                    if (which == 0) {
                                      startActivity(
                                          new Intent(Intent.ACTION_DIAL)
                                              .setData(Uri.parse("tel:+" + record.getPhone())));
                                    } else if (which == 1) {
                                      startActivity(
                                          new Intent(Intent.ACTION_VIEW)
                                              .setData(Uri.parse("sms:+" + record.getPhone())));
                                    } else if (which == 2) {
                                      startActivity(
                                          new Intent(Intent.ACTION_SEND)
                                              .setType("text/plain")
                                              .putExtra(
                                                  Intent.EXTRA_TEXT,
                                                  getString(R.string.settings_share_text)
                                                      .replace("{0}", phoneNumber)
                                                      .replace("{1}", userModel.getName().get())));
                                    } else if (which == 3) {
                                      ClipboardManager clipboard =
                                          (ClipboardManager)
                                              getActivity()
                                                  .getSystemService(Context.CLIPBOARD_SERVICE);
                                      ClipData clip =
                                          ClipData.newPlainText("Phone number", phoneNumber);
                                      clipboard.setPrimaryClip(clip);
                                      Toast.makeText(
                                              getActivity(),
                                              R.string.toast_phone_copied,
                                              Toast.LENGTH_SHORT)
                                          .show();
                                    }
                                  }
                                })
                            .show()
                            .setCanceledOnTouchOutside(true);
                      }
                    });
                recordView.setOnLongClickListener(
                    new View.OnLongClickListener() {
                      @Override
                      public boolean onLongClick(View v) {
                        ClipboardManager clipboard =
                            (ClipboardManager)
                                getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                        ClipData clip =
                            ClipData.newPlainText("Phone number", "+" + record.getPhone());
                        clipboard.setPrimaryClip(clip);
                        Toast.makeText(
                                getActivity(), R.string.toast_phone_copied, Toast.LENGTH_SHORT)
                            .show();
                        return true;
                      }
                    });
              }
            }
          }
        });

    bind(
        userModel.getEmails(),
        new ValueChangedListener<ArrayListUserEmail>() {
          @Override
          public void onChanged(ArrayListUserEmail val, Value<ArrayListUserEmail> Value) {
            if (val.size() == 0) {
              noEmails = true;
            } else {
              contactsContainer.setVisibility(View.VISIBLE);
              for (int i = 0; i < val.size(); i++) {
                final UserEmail record = val.get(i);
                View recordView =
                    inflater.inflate(R.layout.contact_record, contactsContainer, false);
                TintImageView tintImageView =
                    (TintImageView) recordView.findViewById(R.id.recordIcon);
                tintImageView.setTint(ActorSDK.sharedActor().style.getSettingsCategoryTextColor());
                if (i == 0) {
                  tintImageView.setResource(R.drawable.ic_email_white_36dp);
                  tintImageView.setVisibility(View.VISIBLE);
                } else {
                  tintImageView.setVisibility(View.INVISIBLE);
                }

                View divider = recordView.findViewById(R.id.divider);
                if (i != val.size() - 1) {
                  divider.setVisibility(View.VISIBLE);
                } else {
                  divider.setVisibility(View.GONE);
                }
                divider.setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());

                final String email = record.getEmail();

                TextView value = (TextView) recordView.findViewById(R.id.value);
                value.setTextColor(style.getTextPrimaryColor());
                value.setText(email);
                TextView title = (TextView) recordView.findViewById(R.id.title);
                title.setTextColor(style.getTextSecondaryColor());
                title.setText(record.getTitle());
                contactsContainer.addView(
                    recordView,
                    new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(72)));

                recordView.setOnClickListener(
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        new AlertDialog.Builder(getActivity())
                            .setItems(
                                new CharSequence[] {
                                  getString(R.string.email_menu_email).replace("{0}", email),
                                  getString(R.string.phone_menu_copy)
                                },
                                new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialog, int which) {
                                    if (which == 0) {
                                      startActivity(
                                          new Intent(
                                              Intent.ACTION_SENDTO,
                                              Uri.fromParts("mailto", record.getEmail(), null)));
                                    } else if (which == 1) {
                                      ClipboardManager clipboard =
                                          (ClipboardManager)
                                              getActivity()
                                                  .getSystemService(Context.CLIPBOARD_SERVICE);
                                      ClipData clip = ClipData.newPlainText("Email", email);
                                      clipboard.setPrimaryClip(clip);
                                      Toast.makeText(
                                              getActivity(),
                                              R.string.toast_email_copied,
                                              Toast.LENGTH_SHORT)
                                          .show();
                                    }
                                  }
                                })
                            .show()
                            .setCanceledOnTouchOutside(true);
                      }
                    });
                recordView.setOnLongClickListener(
                    new View.OnLongClickListener() {
                      @Override
                      public boolean onLongClick(View v) {
                        ClipboardManager clipboard =
                            (ClipboardManager)
                                getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                        ClipData clip = ClipData.newPlainText("Email", "+" + record.getEmail());
                        clipboard.setPrimaryClip(clip);
                        Toast.makeText(
                                getActivity(), R.string.toast_email_copied, Toast.LENGTH_SHORT)
                            .show();
                        return true;
                      }
                    });
              }
            }
          }
        });

    if (noEmails && noPhones) {
      contactsContainer.setVisibility(View.GONE);
      about.findViewById(R.id.divider).setVisibility(View.INVISIBLE);
    }

    view.findViewById(R.id.chatSettings)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(getActivity(), ChatSettingsActivity.class));
              }
            });

    view.findViewById(R.id.encryption)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(getActivity(), SecuritySettingsActivity.class));
              }
            });

    view.findViewById(R.id.askQuestion)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                execute(
                    messenger().findUsers("75551234567"),
                    R.string.progress_common,
                    new CommandCallback<UserVM[]>() {
                      @Override
                      public void onResult(UserVM[] res) {
                        if (res.length >= 1) {
                          startActivity(
                              Intents.openPrivateDialog(res[0].getId(), true, getActivity()));
                        }
                      }

                      @Override
                      public void onError(Exception e) {}
                    });
              }
            });

    TextView settingsHeaderText = (TextView) view.findViewById(R.id.settings_header_text);
    settingsHeaderText.setTextColor(ActorSDK.sharedActor().style.getSettingsCategoryTextColor());

    TextView settingsNotificationsTitle =
        (TextView) view.findViewById(R.id.settings_notifications_title);
    settingsNotificationsTitle.setTextColor(ActorSDK.sharedActor().style.getSettingsTitleColor());

    TextView settingsChatTitle = (TextView) view.findViewById(R.id.settings_chat_title);
    settingsChatTitle.setTextColor(ActorSDK.sharedActor().style.getSettingsTitleColor());

    TextView securityTitle = (TextView) view.findViewById(R.id.settings_security_title);
    securityTitle.setTextColor(ActorSDK.sharedActor().style.getSettingsTitleColor());

    TintImageView securityIcon = (TintImageView) view.findViewById(R.id.settings_security_icon);
    securityIcon.setTint(style.getSettingsIconColor());

    TextView helpTitle = (TextView) view.findViewById(R.id.settings_help_title);
    helpTitle.setTextColor(ActorSDK.sharedActor().style.getSettingsTitleColor());

    TintImageView helpIcon = (TintImageView) view.findViewById(R.id.settings_help_icon);
    helpIcon.setTint(style.getSettingsIconColor());

    TextView askTitle = (TextView) view.findViewById(R.id.settings_ask_title);
    askTitle.setTextColor(ActorSDK.sharedActor().style.getSettingsTitleColor());

    TintImageView askIcon = (TintImageView) view.findViewById(R.id.settings_ask_icon);
    askIcon.setTint(style.getSettingsIconColor());

    TintImageView notificationsSettingsIcon =
        (TintImageView) view.findViewById(R.id.settings_notification_icon);
    notificationsSettingsIcon.setTint(style.getSettingsIconColor());

    TintImageView chatSettingsIcon = (TintImageView) view.findViewById(R.id.settings_chat_icon);
    chatSettingsIcon.setTint(style.getSettingsIconColor());

    view.findViewById(R.id.after_phone_divider)
        .setBackgroundColor(ActorSDK.sharedActor().style.getBackyardBackgroundColor());
    view.findViewById(R.id.bottom_divider)
        .setBackgroundColor(ActorSDK.sharedActor().style.getBackyardBackgroundColor());

    view.findViewById(R.id.divider1)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    view.findViewById(R.id.divider2)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    view.findViewById(R.id.divider3)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    view.findViewById(R.id.divider4)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());

    if (getBeforeNickSettingsView() != null) {
      FrameLayout beforeNick = (FrameLayout) view.findViewById(R.id.before_nick_container);
      beforeNick.addView(
          getBeforeNickSettingsView(),
          FrameLayout.LayoutParams.MATCH_PARENT,
          FrameLayout.LayoutParams.WRAP_CONTENT);
    }
    if (getBeforeNickSettingsView() != null) {
      FrameLayout afterPhone = (FrameLayout) view.findViewById(R.id.after_phone_container);
      afterPhone.addView(
          getAfterPhoneSettingsView(),
          FrameLayout.LayoutParams.MATCH_PARENT,
          FrameLayout.LayoutParams.WRAP_CONTENT);
    }
    if (getSettingsTopView() != null) {
      FrameLayout settingsTop = (FrameLayout) view.findViewById(R.id.settings_top_container);
      settingsTop.addView(
          getSettingsTopView(),
          FrameLayout.LayoutParams.MATCH_PARENT,
          FrameLayout.LayoutParams.WRAP_CONTENT);
    }
    if (getSettingsBottomView() != null) {
      FrameLayout settingsBot = (FrameLayout) view.findViewById(R.id.settings_bottom_container);
      settingsBot.addView(
          getSettingsBottomView(),
          FrameLayout.LayoutParams.MATCH_PARENT,
          FrameLayout.LayoutParams.WRAP_CONTENT);
    }

    if (getBeforeSettingsCategories() != null) {
      LinearLayout beforeSettings =
          (LinearLayout) view.findViewById(R.id.before_settings_container);
      addCategories(beforeSettings, getBeforeSettingsCategories(), inflater);
    }

    if (getAfterSettingsCategories() != null) {
      LinearLayout afterSettings = (LinearLayout) view.findViewById(R.id.after_settings_container);
      addCategories(afterSettings, getAfterSettingsCategories(), inflater);
    }

    avatarView = (CoverAvatarView) view.findViewById(R.id.avatar);
    ImageView avatarBkgrnd = (ImageView) view.findViewById(R.id.avatar_bgrnd);
    avatarBkgrnd.setBackgroundColor(ActorSDK.sharedActor().style.getAvatarBackgroundColor());
    avatarView.setBkgrnd(avatarBkgrnd);

    bind(avatarView, users().get(myUid()).getAvatar());

    // Wallpaper
    LinearLayout wallpaperContainer = (LinearLayout) view.findViewById(R.id.background_container);
    wallpaperContainer.setBackgroundColor(style.getMainBackgroundColor());
    ((TextView) view.findViewById(R.id.settings_wallpaper_title))
        .setTextColor(style.getSettingsCategoryTextColor());
    view.findViewById(R.id.wallpaperDivider).setBackgroundColor(style.getBackyardBackgroundColor());
    View.OnClickListener ocl =
        new View.OnClickListener() {

          @Override
          public void onClick(final View v) {
            Intent i = new Intent(getActivity(), PickWallpaperActivity.class);
            int j = 0;
            Object tag = v.getTag();
            if (tag != null && tag instanceof Integer) {
              j = (int) tag;
            }
            i.putExtra("EXTRA_ID", j);
            startActivity(i);
          }
        };
    int previewSize = 80;
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(Screen.dp(previewSize), Screen.dp(previewSize));
    for (int i = 0; i < 3; i++) {
      FrameLayout frame = new FrameLayout(getActivity());
      BackgroundPreviewView bckgrnd = new BackgroundPreviewView(getActivity());
      bckgrnd.init(Screen.dp(previewSize), Screen.dp(previewSize));
      bckgrnd.bind(i);
      // bckgrnd.setPadding(Screen.dp(5), Screen.dp(10), Screen.dp(5), Screen.dp(20));
      frame.setTag(i);
      frame.setOnClickListener(ocl);
      frame.addView(bckgrnd);
      wallpaperContainer.addView(frame, params);
    }
    TintImageView next = new TintImageView(getActivity());
    next.setResource(R.drawable.ic_keyboard_arrow_right_white_36dp);
    next.setTint(style.getSettingsIconColor());
    next.setOnClickListener(ocl);
    next.setTag(-1);
    wallpaperContainer.addView(
        next, new LinearLayout.LayoutParams(Screen.dp(40), Screen.dp(previewSize)));

    view.findViewById(R.id.avatar)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(ViewAvatarActivity.viewAvatar(myUid(), getActivity()));
              }
            });

    final ScrollView scrollView = ((ScrollView) view.findViewById(R.id.scrollContainer));
    scrollView.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    scrollView
        .getViewTreeObserver()
        .addOnScrollChangedListener(
            new ViewTreeObserver.OnScrollChangedListener() {
              @Override
              public void onScrollChanged() {
                updateActionBar(scrollView.getScrollY());
              }
            });

    updateActionBar(scrollView.getScrollY());

    return view;
  }
Exemplo n.º 5
0
  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);
    }
  }
  private void initView() {
    scroll = (ScrollView) findViewById(R.id.scroll);
    cateGoryData = getCategory();
    grid = (GridView) findViewById(R.id.grid);
    title = (TextView) findViewById(R.id.title);
    text = (TextView) findViewById(R.id.text);
    mAdapter = new NewActionAdapter(this, goodsList);
    grid.setAdapter(mAdapter);
    grid.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Goods goods = new Goods();
            goods = goodsList.getGoods(arg2);
            startActivity(
                new Intent(NewActionDetailActivity.this, GoodsDetailActivity.class)
                    .putExtra("goods", goods));
          }
        });
    grid.setOnScrollListener(
        new OnScrollListener() {

          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
              isScolling = false;
              NetImageView.setIsAutoLoadImage(true);
              ArrayList<NetImageView> imageLists = mAdapter.getImageList();
              for (int i = 0, len = imageLists.size(); i < len; i++) {
                if (isScolling == false) {
                  imageLists.get(i).updateImage();
                }
              }
            } else if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
              isScolling = true;
              NetImageView.setIsAutoLoadImage(false);
            }
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            //				if (firstVisibleItem + visibleItemCount >= totalItemCount - 1
            //						&& totalItemCount > 0) {
            //					if (!isLoading && !isLoaddone) {
            //						new LoadDataAsync().execute();
            //					}
            //				}
          }
        });
    drawer = (SlidingDrawer) findViewById(R.id.sliding);
    category = (ListView) findViewById(R.id.category_list);
    if (cateGoryData != null) {
      MyListAdapter adapter = new MyListAdapter();
      category.setAdapter(adapter);
      category.setOnItemClickListener(
          new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
              if (cateGoryData.length() >= arg2) {
                JSONObject o;
                try {
                  o = cateGoryData.getJSONObject(arg2);
                  int categoryID = o.optInt("CategoryID");
                  String name = o.optString("Name");
                  ((TextView) findViewById(R.id.slide_btn)).setText(name);
                  mcids = categoryID + "";
                  goodsList.clearGoodsList();
                  drawer.close();
                  new LoadDataAsync().execute();
                } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            }
          });
    }
    background = (LinearLayout) findViewById(R.id.background);
    ((TextView) findViewById(R.id.slide_btn)).setOnClickListener(this);
    ((Button) findViewById(R.id.back)).setOnClickListener(this);
    orderby = this.getIntent().getIntExtra("TYPE", NEW);
    switch (orderby) {
      case NEW:
        title.setText(getString(R.string.new_good));
        scroll.setBackgroundColor(Color.argb(255, 99, 181, 50));
        break;
      case HOT:
        title.setText(getString(R.string.hot_good));
        scroll.setBackgroundColor(Color.argb(255, 229, 71, 29));
        break;
      case REBATE:
        title.setText(getString(R.string.rebate_good));
        scroll.setBackgroundColor(Color.argb(255, 244, 155, 0));
        break;

      default:
        break;
    }
  }