示例#1
0
  public DownloadIconsDialog(final Context context, final boolean changeSettings) {
    super(context);
    mChangeSettingsEnabled = changeSettings;

    setTitle(R.string.msg_download_icons_dialog_title);
    setCancelable(true);
    setIcon(android.R.drawable.ic_dialog_info);

    final TextView message = new TextView(context);
    String str;
    try {
      str = FileUtil.writeToString(context.getResources().openRawResource(R.raw.icons_pack));
    } catch (Exception e) {
      str = e.toString();
    }
    final SpannableString s = new SpannableString(Html.fromHtml(str));
    Linkify.addLinks(s, Linkify.WEB_URLS);
    message.setText(s);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setPadding(5, 5, 5, 5);
    message.setTextColor(context.getResources().getColorStateList(R.color.dialog_text_color));
    message.setLinkTextColor(context.getResources().getColorStateList(R.color.links_color));
    setView(message);

    setButton(AlertDialog.BUTTON_POSITIVE, context.getText(android.R.string.yes), this);
    setButton(AlertDialog.BUTTON_NEGATIVE, context.getText(android.R.string.no), this);
    setOnCancelListener(this);
  }
  public void onCreate(Bundle savedInstanceState) {
    String[] strings = new String[mItems.length];
    for (int i = 0; i < mItems.length; i++) {
      strings[i] = mItems[i].title;
    }
    List<String> list = Arrays.asList(strings);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setListAdapter(new ExamplesAdapter(this, list));

    TextView linkView = (TextView) findViewById(R.id.textView1);
    linkView.setPadding(10, 0, 10, 20);
    linkView.setTextSize(20);
    linkView.setText(getString(R.string.github_url));
    linkView.setTextColor(0xaaffffff);
    linkView.setLinkTextColor(0xaaffffff);

    Linkify.addLinks(linkView, Linkify.WEB_URLS);

    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    linkView.setTypeface(font);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.about);

    TextView tv = (TextView) findViewById(R.id.legal_text);
    tv.setText(readRawTextFile(R.raw.legal));

    tv = (TextView) findViewById(R.id.info_text);
    tv.setText(Html.fromHtml(readRawTextFile(R.raw.info)));
    tv.setLinkTextColor(Color.BLUE);
    Linkify.addLinks(tv, Linkify.ALL);
  }
  /**
   * Constructs a layout for the specified InfoBar. After calling this, be sure to set the message,
   * the buttons, and/or the custom content using setMessage(), setButtons(), and
   * setCustomContent().
   *
   * @param context The context used to render.
   * @param infoBarView InfoBarView that listens to events.
   * @param iconResourceId ID of the icon to use for the InfoBar.
   * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
   * @param message The message to show in the infobar.
   */
  public InfoBarLayout(
      Context context,
      InfoBarView infoBarView,
      int iconResourceId,
      Bitmap iconBitmap,
      CharSequence message) {
    super(context);
    mInfoBarView = infoBarView;

    // Grab the dimensions.
    Resources res = getResources();
    mMargin = res.getDimensionPixelOffset(R.dimen.infobar_margin);
    mIconSize = res.getDimensionPixelSize(R.dimen.infobar_icon_size);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mMargin, mMargin, mMargin, mMargin);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mMargin, -mMargin, -mMargin));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
      mIconView = new ImageView(context);
      if (iconResourceId != 0) {
        mIconView.setImageResource(iconResourceId);
      } else if (iconBitmap != null) {
        mIconView.setImageBitmap(iconBitmap);
      }
      mIconView.setLayoutParams(new LayoutParams(0, 0, mMargin / 2, 0));
      mIconView.getLayoutParams().width = mIconSize;
      mIconView.getLayoutParams().height = mIconSize;
      mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageTextView = (TextView) LayoutInflater.from(context).inflate(R.layout.infobar_text, null);
    mMessageTextView.setText(message, TextView.BufferType.SPANNABLE);
    mMessageTextView.setMovementMethod(LinkMovementMethod.getInstance());
    mMessageTextView.setLinkTextColor(mAccentColor);
    mMessageView = mMessageTextView;
  }
 @Override
 public View getGroupView(
     int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
   View v = convertView;
   IndexItemCategory group = getGroup(groupPosition);
   if (v == null) {
     LayoutInflater inflater = getLayoutInflater();
     v =
         inflater.inflate(
             net.osmand.plus.R.layout.download_index_list_item_category, parent, false);
   }
   final View row = v;
   TextView item = (TextView) row.findViewById(R.id.download_index_category_name);
   item.setText(group.name);
   item.setLinkTextColor(Color.YELLOW);
   adjustIndicator(groupPosition, isExpanded, v);
   return row;
 }
示例#6
0
  /** 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);
  }
示例#7
0
  private void setUpInterface() {
    timerView = commentsBar.findViewById(R.id.timer_container);
    commentButton = commentsBar.findViewById(R.id.commentButton);
    commentField = (EditText) commentsBar.findViewById(R.id.commentField);

    final boolean showTimerShortcut = Preferences.getBoolean(R.string.p_show_timer_shortcut, false);

    if (showTimerShortcut) {
      commentField.setOnFocusChangeListener(
          new OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
              if (hasFocus) {
                timerView.setVisibility(View.GONE);
                commentButton.setVisibility(View.VISIBLE);
              } else {
                timerView.setVisibility(View.VISIBLE);
                commentButton.setVisibility(View.GONE);
              }
            }
          });
    } else {
      timerView.setVisibility(View.GONE);
    }

    commentField.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void afterTextChanged(Editable s) {
            commentButton.setVisibility(
                (s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE : View.GONE);
            if (showTimerShortcut)
              timerView.setVisibility(
                  (s.length() > 0 || pendingCommentPicture != null) ? View.GONE : View.VISIBLE);
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //
          }

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            //
          }
        });

    commentField.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_NULL && commentField.getText().length() > 0) {
              addComment();
              return true;
            }
            return false;
          }
        });
    commentButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            addComment();
          }
        });

    final ClearImageCallback clearImage =
        new ClearImageCallback() {
          @Override
          public void clearImage() {
            pendingCommentPicture = null;
            pictureButton.setImageResource(cameraButton);
          }
        };
    pictureButton = (ImageButton) commentsBar.findViewById(R.id.picture);
    pictureButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (pendingCommentPicture != null)
              ActFmCameraModule.showPictureLauncher(fragment, clearImage);
            else ActFmCameraModule.showPictureLauncher(fragment, null);
            respondToPicture = true;
          }
        });
    if (!TextUtils.isEmpty(task.getValue(Task.NOTES))) {
      TextView notes = new TextView(getContext());
      notes.setLinkTextColor(Color.rgb(100, 160, 255));
      notes.setTextSize(18);
      notes.setText(task.getValue(Task.NOTES));
      notes.setPadding(5, 10, 5, 10);
      Linkify.addLinks(notes, Linkify.ALL);
    }

    if (activity != null) {
      Bitmap bitmap =
          activity.getIntent().getParcelableExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS);
      if (bitmap != null) {
        pendingCommentPicture = bitmap;
        pictureButton.setImageBitmap(pendingCommentPicture);
      }
    }

    // TODO add loading text back in
    //        loadingText = (TextView) findViewById(R.id.loading);
    loadingText = new TextView(getContext());
  }
  @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;
  }