Beispiel #1
0
  public static void SetFileExplorerLink(
      TextView txtFilename, Spanned htmlString, final String pathToLinkTo, final Context context) {

    final Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + pathToLinkTo), "resource/folder");
    intent.setAction(Intent.ACTION_VIEW);

    if (intent.resolveActivity(context.getPackageManager()) != null) {
      txtFilename.setLinksClickable(true);
      txtFilename.setClickable(true);
      txtFilename.setMovementMethod(LinkMovementMethod.getInstance());
      txtFilename.setSelectAllOnFocus(false);
      txtFilename.setTextIsSelectable(false);
      txtFilename.setText(htmlString);

      txtFilename.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              context.startActivity(intent);
            }
          });
    }
  }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_info);

    TextView mInfoAck = (TextView) findViewById(R.id.infoAckText);
    mInfoAck.setLinksClickable(true);
  }
 @Override
 public void run() {
   View btn = findViewById(R.id.button1);
   TextView tv = (TextView) findViewById(R.id.textView1);
   if (content == "") content = getResources().getString(R.string.message_error);
   tv.setText(Html.fromHtml(content));
   tv.setMovementMethod(LinkMovementMethod.getInstance());
   tv.setLinksClickable(true);
   btn.setEnabled(true);
   setTitle(title);
 }
Beispiel #4
0
  public BookView(Context context, AttributeSet attributes) {
    super(context, attributes);

    this.listeners = new HashSet<BookViewListener>();

    this.childView =
        new TextView(context) {

          protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);
            restorePosition();

            int tableWidth = (int) (this.getWidth() * 0.9);
            tableHandler.setTableWidth(tableWidth);
          }

          public boolean dispatchKeyEvent(KeyEvent event) {
            return BookView.this.dispatchKeyEvent(event);
          }

          @Override
          protected void onSelectionChanged(int selStart, int selEnd) {
            // TODO Auto-generated method stub
            super.onSelectionChanged(selStart, selEnd);

            LOG.debug("Got text selection from " + selStart + " to " + selEnd);
          }
        };

    childView.setCursorVisible(false);
    childView.setLongClickable(true);
    this.setVerticalFadingEdgeEnabled(false);
    childView.setFocusable(true);
    childView.setLinksClickable(true);
    childView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    MovementMethod m = childView.getMovementMethod();
    if ((m == null) || !(m instanceof LinkMovementMethod)) {
      if (childView.getLinksClickable()) {
        childView.setMovementMethod(LinkMovementMethod.getInstance());
      }
    }

    this.setSmoothScrollingEnabled(false);
    this.addView(childView);

    this.anchors = new HashMap<String, Integer>();
    this.tableHandler = new TableHandler();
  }
  @Override
  public void onSuccess(Object result) {
    try {
      if (getActivity() != null) {
        if (result instanceof DescriptionResult) {
          resultData = (DescriptionResult) result;
          setUpVisibility(View.GONE, View.VISIBLE);
          btnBuy.setVisibility(View.VISIBLE);
          btnSell.setVisibility(View.VISIBLE);
          if (((DescriptionResult) result).getAssetClass() == null) {
            linearAssetName.setVisibility(View.GONE);
            viewAssetClass.setVisibility(View.GONE);
          } else {
            tvAssetClass.setText(((DescriptionResult) result).getAssetClass());
          }
          if (((DescriptionResult) result).getDescription() == null) {
            linearDescription.setVisibility(View.GONE);
            viewDescription.setVisibility(View.GONE);
          } else {
            tvDescription.setText(((DescriptionResult) result).getDescription());
          }

          if (((DescriptionResult) result).getIssuerName() == null) {
            linearIssuerName.setVisibility(View.GONE);
            viewIssuerName.setVisibility(View.GONE);
          } else {
            tvIssuerName.setText(((DescriptionResult) result).getIssuerName());
          }
          if (((DescriptionResult) result).getNumberOfCoins() == null) {
            linearNumberOfCoins.setVisibility(View.GONE);
            viewNumberOfCoins.setVisibility(View.GONE);
          } else {
            tvNumberOfCoins.setText(((DescriptionResult) result).getNumberOfCoins());
          }
          if (((DescriptionResult) result).getMarketCapitalization() == null) {
            linearMarketCapitalization.setVisibility(View.GONE);
            viewMarketCapitalization.setVisibility(View.GONE);
          } else {
            tvMarketCapitalization.setText(((DescriptionResult) result).getMarketCapitalization());
          }
          if (((DescriptionResult) result).getAssetDescriptionUrl() == null) {
            linearDescriptionUrl.setVisibility(View.GONE);
            viewDescriptionUrl.setVisibility(View.GONE);
          } else {

            Spannable s =
                (Spannable) Html.fromHtml(((DescriptionResult) result).getAssetDescriptionUrl());
            for (URLSpan u : s.getSpans(0, s.length(), URLSpan.class)) {
              s.setSpan(
                  new UnderlineSpan() {
                    public void updateDrawState(TextPaint tp) {
                      tp.setUnderlineText(false);
                    }
                  },
                  s.getSpanStart(u),
                  s.getSpanEnd(u),
                  0);
            }

            tvDescriptionUrl.setMovementMethod(LinkMovementMethod.getInstance());
            tvDescriptionUrl.setLinksClickable(true);
            tvDescriptionUrl.setText(s);
          }
          Resources r = getResources();
          float px =
              TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, r.getDisplayMetrics());
          float pxMargin =
              TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, r.getDisplayMetrics());
          linearPop.removeAllViews();

          for (int i = 0; i < Integer.parseInt(((DescriptionResult) result).getPopIndex()); i++) {
            ImageView imageView = new ImageView(getActivity());
            imageView.setImageResource(R.drawable.star);
            LinearLayout.LayoutParams lp =
                new LinearLayout.LayoutParams(Math.round(px), Math.round(px));
            lp.setMargins(Math.round(pxMargin), 0, Math.round(pxMargin), 0);
            imageView.setLayoutParams(lp);

            linearPop.addView(imageView);
          }

          if (Integer.parseInt(((DescriptionResult) result).getPopIndex()) == 0) {
            linearPopularity.setVisibility(View.GONE);
          }
          handler.post(run);
        } else if (result instanceof RateResult) {
          if (((RateResult) result).getRate() != null
              && ((RateResult) result).getRate().getAsk() != null
              && getActivity() != null) {
            price = BigDecimal.valueOf(((RateResult) result).getRate().getAsk());
            if (assetPair.getInverted()) {
              price = BigDecimal.ONE.divide(price, accurancy, RoundingMode.HALF_EVEN);
            }
            btnBuy.setText(
                String.format(getString(R.string.buy_rate), mainName, subName)
                    + " "
                    + LykkeUtils.getStriped(accurancy, price));
          }
          if (((RateResult) result).getRate() != null
              && ((RateResult) result).getRate().getBid() != null
              && getActivity() != null) {
            bid = BigDecimal.valueOf(((RateResult) result).getRate().getBid());
            if (assetPair.getInverted()) {
              bid = BigDecimal.ONE.divide(bid, accurancy, RoundingMode.HALF_EVEN);
            }
            btnSell.setText(
                String.format(getString(R.string.sell_at_price), mainName, subName)
                    + " "
                    + LykkeUtils.getStriped(accurancy, bid));
          }
        }
      }
    } catch (NullPointerException ex) {

    }
  }
  protected void buildRow(
      final View view,
      Drawable icon,
      final String text,
      final String textPrefix,
      int textColor,
      boolean isWiki,
      boolean isText,
      boolean needLinks) {
    boolean light = app.getSettings().isLightContent();

    if (!isFirstRow()) {
      buildRowDivider(view, false);
    }

    final String txt;
    if (!Algorithms.isEmpty(textPrefix)) {
      txt = textPrefix + ": " + text;
    } else {
      txt = text;
    }

    LinearLayout ll = new LinearLayout(view.getContext());
    ll.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams llParams =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    ll.setLayoutParams(llParams);
    ll.setBackgroundResource(
        resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
    ll.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            copyToClipboard(txt, view.getContext());
            return true;
          }
        });

    // Icon
    LinearLayout llIcon = new LinearLayout(view.getContext());
    llIcon.setOrientation(LinearLayout.HORIZONTAL);
    llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), dpToPx(48f)));
    llIcon.setGravity(Gravity.CENTER_VERTICAL);
    ll.addView(llIcon);

    ImageView iconView = new ImageView(view.getContext());
    LinearLayout.LayoutParams llIconParams =
        new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
    llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
    llIconParams.gravity = Gravity.CENTER_VERTICAL;
    iconView.setLayoutParams(llIconParams);
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    iconView.setImageDrawable(icon);
    llIcon.addView(iconView);

    // Text
    LinearLayout llText = new LinearLayout(view.getContext());
    llText.setOrientation(LinearLayout.VERTICAL);
    ll.addView(llText);

    TextView textView = new TextView(view.getContext());
    LinearLayout.LayoutParams llTextParams =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    llTextParams.setMargins(0, dpToPx(8f), 0, dpToPx(8f));
    textView.setLayoutParams(llTextParams);
    textView.setTextSize(16);
    textView.setTextColor(
        app.getResources()
            .getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));

    if (needLinks) {
      textView.setAutoLinkMask(Linkify.ALL);
      textView.setLinksClickable(true);
    }
    textView.setEllipsize(TextUtils.TruncateAt.END);
    if (isWiki) {
      textView.setMinLines(1);
      textView.setMaxLines(15);
    } else if (isText) {
      textView.setMinLines(1);
      textView.setMaxLines(10);
    }
    textView.setText(txt);
    if (textColor > 0) {
      textView.setTextColor(view.getResources().getColor(textColor));
    }

    LinearLayout.LayoutParams llTextViewParams =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
    llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
    llText.setLayoutParams(llTextViewParams);
    llText.addView(textView);

    ((LinearLayout) view).addView(ll);

    if (isWiki) {
      ll.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
            }
          });
    } else if (isText && text.length() > 200) {
      ll.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              POIMapLayer.showDescriptionDialog(view.getContext(), app, text, textPrefix);
            }
          });
    }

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

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            }
          }
        });

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

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

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

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

    TextView textView = new TextView(context);
    textView.setTextColor(0xff7f7f7f);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLinksClickable(true);
    textView.setClickable(true);
    textView.setMovementMethod(new LinkMovementMethodMy());
    // textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(0xff316f9f);
    textView.setGravity(Gravity.CENTER);
    frameLayout.addView(
        textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

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

    return fragmentView;
  }
  @SuppressWarnings("unchecked")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Global.logd(TAG + " on create called ");

    setContentView(R.layout.activity_settings);
    mLanguageManager = LanguageManager.getInstance();

    SlidingMenu menu = new SlidingMenu(this);
    menu.setShadowWidthRes(R.dimen.shadow_res);
    menu.setFadeDegree(0.35f);

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.layout_left_menu, null);

    setBehindContentView(view);

    // changes as on 2nd Jan 2014
    StartActivity.currentIntent = getIntent();
    // changes end here

    getSlidingMenu().setFadeEnabled(true);
    getSlidingMenu().setFadeDegree(0.35f);
    getSlidingMenu().setSlidingEnabled(true);
    getSlidingMenu().setSelectorEnabled(true);
    getSlidingMenu().setSelected(true);
    getSlidingMenu().setShadowDrawable(R.drawable.drop_shadow_for_menu);
    getSlidingMenu().setBehindOffset((int) getWidth() / 3);
    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);

    // registerReceiver(SettingsFragment.this);

    if (getIntent().getExtras() != null) {
      if (getIntent().getStringExtra(Global.FROM_ACTIVITY) != null) {
        mFrom = getIntent().getStringExtra(Global.FROM_ACTIVITY);
      }

      if (getIntent().getStringExtra(Global.TIME_STAMP) != null) {
        mTimestamp = getIntent().getStringExtra(Global.TIME_STAMP);
      }

      if (getIntent().getStringExtra(Global.PREVIOUS) != null) {
        previousValue = getIntent().getStringExtra(Global.PREVIOUS);
      }

      if (getIntent().getStringExtra(Global.TABLE_ID) != null) {
        mTableId = getIntent().getStringExtra(Global.TABLE_ID);
      }

      if (getIntent().getStringExtra(Global.TABLE_NUMBER) != null) {
        mTableNumber = getIntent().getStringExtra(Global.TABLE_NUMBER);
      }
    }

    txtHeader = (TextView) findViewById(R.id.txtHeader);
    txtSectionSelection = (TextView) findViewById(R.id.txtSectionSelection);
    txtLanguage = (TextView) findViewById(R.id.txtLanguage);
    txtConfigureSettings = (TextView) findViewById(R.id.txtConfigureSettings);
    txtForceSync = (TextView) findViewById(R.id.txtForceSync);
    txtSyncMenu = (TextView) findViewById(R.id.txtSyncMenu);
    txtSendLog = (TextView) findViewById(R.id.txtSendLog);
    txtLogout = (TextView) findViewById(R.id.txtLogout);
    lnrSectionBox = (LinearLayout) findViewById(R.id.lnrSectionSelection);
    mTxtNotificationsEnabled = (TextView) findViewById(R.id.txtNotificationSettings);
    lnrLanguageBox = (LinearLayout) findViewById(R.id.lnrLanguage);
    mTxtNotificationCount = (TextView) findViewById(R.id.txtNotificationNumber);
    mRelNotificationCentre = (RelativeLayout) findViewById(R.id.relNotificationCentre);

    // changes as on 16th july 2013
    mTxtLeftMenuWaiterName = (TextView) view.findViewById(R.id.txtWaiterName);
    mTxtLeftMenuOrders = (TextView) view.findViewById(R.id.txtOrdersLeftMenu);
    mTxtLeftMenuSettings = (TextView) view.findViewById(R.id.txtSettingsLeftMenu);
    mTxtLeftMenuLink = (TextView) view.findViewById(R.id.txtLeftMenuLink);
    mTxtLeftMenuNotifications = (TextView) view.findViewById(R.id.txtNotificationsLeftMenu);
    mTxtLeftMenuTables = (TextView) view.findViewById(R.id.txtTablesLeftMenu);
    mBtnLockLeftMenu = (Button) view.findViewById(R.id.btnLeftMenuLock);
    mBtnWaiterChangeLeftMenu = (Button) view.findViewById(R.id.btnLeftMenuWaiterChange);
    mBtnPlaceOrderLeftMenu = (Button) view.findViewById(R.id.btnPlaceOrderLeftMenu);
    imageMenuIcon = (ImageButton) findViewById(R.id.menuIcon);

    // changes as on 6th December 2013
    mSwitchForNotifications = (Switch) findViewById(R.id.switchForNotifications);

    if (Prefs.getKey_boolean_with_default_true(this, Prefs.ARE_NOTIFICATIONS_ENABLED)) {
      mSwitchForNotifications.setChecked(true);
    } else {
      mSwitchForNotifications.setChecked(false);
    }

    mSwitchForNotifications.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Log.i("dhara", "isChecked : " + isChecked);

            Prefs.addKey(SettingsActivity.this, Prefs.ARE_NOTIFICATIONS_ENABLED, isChecked);
          }
        });

    mSwitchForNotifications.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View view) {
            // do nothing
          }
        });
    // changes end here

    mTxtLeftMenuLink.setMovementMethod(LinkMovementMethod.getInstance());
    mTxtLeftMenuLink.setLinksClickable(true);

    mTxtLeftMenuOrders.setOnClickListener(this);
    mTxtLeftMenuSettings.setOnClickListener(this);
    mTxtLeftMenuNotifications.setOnClickListener(this);
    mTxtLeftMenuTables.setOnClickListener(this);
    mBtnPlaceOrderLeftMenu.setOnClickListener(this);
    mBtnLockLeftMenu.setOnClickListener(this);
    mBtnWaiterChangeLeftMenu.setOnClickListener(this);
    imageMenuIcon.setOnClickListener(this);
    mTxtLeftMenuLink.setOnClickListener(this);
    mRelNotificationCentre.setOnClickListener(this);

    sectionCache = SectionManager.getInstance().getSectionCache();
    mUtils = new Utils(SettingsActivity.this);
    sectionId = Prefs.getKey(Prefs.SECTION_ID);
    sectionName = Prefs.getKey(Prefs.SECTION_NAME);
    waiterName = Prefs.getKey(Prefs.WAITER_NAME);

    mTxtLeftMenuWaiterName.setText(waiterName);

    // Get the language selection value from shared preferences
    // show it on the screen
    langSelection = Prefs.getKey(Prefs.LANGUAGE_SELECTED);

    // Gets the list of languages
    mLanguageList =
        (List<String>) LanguageManager.getInstance().getLanguageCache().get(Global.LANGUAGES);

    Log.i(TAG, "value of mLanguageList " + mLanguageList);

    if (mLanguageList != null && mLanguageList.size() > 0) {
      // set the first value
      if (langSelection != null && langSelection.trim().length() > 0) {
        // Get the language xml file to set the values of the GUI
        String language = mLanguageManager.getStartNode();

        if (!langSelection.equalsIgnoreCase(language)) {
          getLanguageXmlAsyncTask =
              new GetLanguageXmlAsyncTask(SettingsActivity.this, langSelection);
          getLanguageXmlAsyncTask.execute();
        } else {
          setGuiLabels();
        }
      }
    }

    if (sectionId != null && sectionId.trim().length() > 0) {
      if (Prefs.getKey(Prefs.SECTION_NAME) != null
          && Prefs.getKey(Prefs.SECTION_NAME).trim().length() > 0) {
        txtSectionSelection.setText(mLanguageManager.getSelectedSection() + ": " + sectionName);
      }
    }

    txtHeader.setText(mLanguageManager.getSettings());

    txtSectionSelection.setOnClickListener(SettingsActivity.this);
    txtLanguage.setOnClickListener(SettingsActivity.this);
    txtConfigureSettings.setOnClickListener(SettingsActivity.this);
    txtForceSync.setOnClickListener(SettingsActivity.this);
    txtSyncMenu.setOnClickListener(SettingsActivity.this);
    txtSendLog.setOnClickListener(SettingsActivity.this);
    txtLogout.setOnClickListener(SettingsActivity.this);
    lnrLanguageBox.setOnClickListener(SettingsActivity.this);
    lnrSectionBox.setOnClickListener(SettingsActivity.this);

    Prefs.addKey(SettingsActivity.this, Prefs.MENU_SELECTED, Global.SETTINGS);
    mTxtLeftMenuSettings.setPressed(true);

    setGuiLabels();
  }
  /** 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;
  }