コード例 #1
0
  public static Dialog createMuteAlert(Context context, final long dialog_id) {
    if (context == null) {
      return null;
    }

    BottomSheet.Builder builder = new BottomSheet.Builder(context);
    builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications));
    CharSequence[] items =
        new CharSequence[] {
          LocaleController.formatString(
              "MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 1)),
          LocaleController.formatString(
              "MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 8)),
          LocaleController.formatString(
              "MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Days", 2)),
          LocaleController.getString("MuteDisable", R.string.MuteDisable)
        };
    builder.setItems(
        items,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            int untilTime = ConnectionsManager.getInstance().getCurrentTime();
            if (i == 0) {
              untilTime += 60 * 60;
            } else if (i == 1) {
              untilTime += 60 * 60 * 8;
            } else if (i == 2) {
              untilTime += 60 * 60 * 48;
            } else if (i == 3) {
              untilTime = Integer.MAX_VALUE;
            }

            SharedPreferences preferences =
                ApplicationLoader.applicationContext.getSharedPreferences(
                    "Notifications", Activity.MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            long flags;
            if (i == 3) {
              editor.putInt("notify2_" + dialog_id, 2);
              flags = 1;
            } else {
              editor.putInt("notify2_" + dialog_id, 3);
              editor.putInt("notifyuntil_" + dialog_id, untilTime);
              flags = ((long) untilTime << 32) | 1;
            }
            MessagesStorage.getInstance().setDialogFlags(dialog_id, flags);
            editor.commit();
            TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
            if (dialog != null) {
              dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
              dialog.notify_settings.mute_until = untilTime;
            }
            NotificationsController.updateServerNotificationsSettings(dialog_id);
          }
        });
    return builder.create();
  }
コード例 #2
0
  public void setDocument(MessageObject document, boolean divider) {
    needDivider = divider;
    message = document;
    loaded = false;
    loading = false;

    if (document != null && document.messageOwner.media != null) {
      int idx;
      String name = FileLoader.getDocumentFileName(document.messageOwner.media.document);
      placeholderImabeView.setVisibility(VISIBLE);
      extTextView.setVisibility(VISIBLE);
      placeholderImabeView.setImageResource(
          getThumbForNameOrMime(name, document.messageOwner.media.document.mime_type));
      nameTextView.setText(name);
      extTextView.setText(
          (idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase());
      if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty
          || document.messageOwner.media.document.thumb == null) {
        thumbImageView.setVisibility(INVISIBLE);
        thumbImageView.setImageBitmap(null);
      } else {
        thumbImageView.setVisibility(VISIBLE);
        thumbImageView.setImage(
            document.messageOwner.media.document.thumb.location, "40_40", (Drawable) null);
      }
      long date = (long) document.messageOwner.date * 1000;
      dateTextView.setText(
          String.format(
              "%s, %s",
              AndroidUtilities.formatFileSize(document.messageOwner.media.document.size),
              LocaleController.formatString(
                  "formatDateAtTime",
                  R.string.formatDateAtTime,
                  LocaleController.formatterYear.format(new Date(date)),
                  LocaleController.formatterDay.format(new Date(date)))));
    } else {
      nameTextView.setText("");
      extTextView.setText("");
      dateTextView.setText("");
      placeholderImabeView.setVisibility(VISIBLE);
      extTextView.setVisibility(VISIBLE);
      thumbImageView.setVisibility(INVISIBLE);
      thumbImageView.setImageBitmap(null);
    }

    setWillNotDraw(!needDivider);
    progressView.setProgress(0, false);
    updateFileExistIcon();
  }
コード例 #3
0
 private String getRootSubtitle(String path) {
   try {
     StatFs stat = new StatFs(path);
     long total = (long) stat.getBlockCount() * (long) stat.getBlockSize();
     long free = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
     if (total == 0) {
       return "";
     }
     return LocaleController.formatString(
         "FreeOfTotal",
         R.string.FreeOfTotal,
         AndroidUtilities.formatFileSize(free),
         AndroidUtilities.formatFileSize(total));
   } catch (Exception e) {
     FileLog.e("tmessages", e);
   }
   return path;
 }