示例#1
0
 /**
  * Setup the view buttons for SMS & MMS notifications.
  *
  * @param usingImageButtons - True if the user wants to use buttons with icons only.
  * @param notificationType - The notification type.
  */
 private void setupViewSMSButtons(boolean usingImageButtons, int notificationType) {
   if (_debug) Log.v("ThemeView.setupViewSMSButtons()");
   try {
     if (usingImageButtons) {
       // Dismiss Button
       if (_preferences.getBoolean(Constants.SMS_DISPLAY_DISMISS_BUTTON_KEY, true)) {
         _dismissImageButton.setVisibility(View.VISIBLE);
       } else {
         _dismissImageButton.setVisibility(View.GONE);
       }
       // Delete Button
       if (_preferences.getBoolean(Constants.SMS_DISPLAY_DELETE_BUTTON_KEY, true)) {
         _deleteImageButton.setVisibility(View.VISIBLE);
       } else {
         _deleteImageButton.setVisibility(View.GONE);
       }
       // Reply Button;
       if (_preferences.getBoolean(Constants.SMS_DISPLAY_REPLY_BUTTON_KEY, true)) {
         _replyImageButton.setVisibility(View.VISIBLE);
       } else {
         _replyImageButton.setVisibility(View.GONE);
       }
     } else {
       // Dismiss Button
       if (_preferences.getBoolean(Constants.SMS_DISPLAY_DISMISS_BUTTON_KEY, true)) {
         _dismissButton.setVisibility(View.VISIBLE);
       } else {
         _dismissButton.setVisibility(View.GONE);
       }
       // Delete Button
       if (_preferences.getBoolean(Constants.SMS_DISPLAY_DELETE_BUTTON_KEY, true)) {
         _deleteButton.setVisibility(View.VISIBLE);
       } else {
         _deleteButton.setVisibility(View.GONE);
       }
       // Reply Button
       if (_preferences.getBoolean(Constants.SMS_DISPLAY_REPLY_BUTTON_KEY, true)) {
         _replyButton.setVisibility(View.VISIBLE);
       } else {
         _replyButton.setVisibility(View.GONE);
       }
     }
   } catch (Exception ex) {
     Log.e("ThemeView.setupViewSMSButtons() ERROR: " + ex.toString());
   }
 }
示例#2
0
 /**
  * Sets up the ThemeView's buttons.
  *
  * @param notification - This View's Notification.
  */
 private void setupViewButtons() {
   if (_debug) Log.v("ThemeView.setupViewButtons()");
   try {
     boolean usingImageButtons = false;
     String buttonDisplayStyle =
         _preferences.getString(
             Constants.BUTTON_DISPLAY_STYLE_KEY, Constants.BUTTON_DISPLAY_STYLE_DEFAULT);
     // Show the LinearLayout of the specified button style (ImageButton vs Button)
     if (buttonDisplayStyle.equals(Constants.BUTTON_DISPLAY_ICON_ONLY)) {
       usingImageButtons = true;
       _buttonLinearLayout.setVisibility(View.GONE);
       _imageButtonLinearLayout.setVisibility(View.VISIBLE);
     } else {
       usingImageButtons = false;
       _buttonLinearLayout.setVisibility(View.VISIBLE);
       _imageButtonLinearLayout.setVisibility(View.GONE);
     }
     // Default all buttons to be hidden.
     _dismissButton.setVisibility(View.GONE);
     _deleteButton.setVisibility(View.GONE);
     _callButton.setVisibility(View.GONE);
     _replyButton.setVisibility(View.GONE);
     _viewButton.setVisibility(View.GONE);
     _dismissImageButton.setVisibility(View.GONE);
     _deleteImageButton.setVisibility(View.GONE);
     _callImageButton.setVisibility(View.GONE);
     _replyImageButton.setVisibility(View.GONE);
     _viewImageButton.setVisibility(View.GONE);
     // Set button font size.
     float buttonTextSize =
         Float.parseFloat(
             _preferences.getString(
                 Constants.BUTTON_FONT_SIZE_KEY, Constants.BUTTON_FONT_SIZE_DEFAULT));
     _dismissButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, buttonTextSize);
     _deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, buttonTextSize);
     _callButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, buttonTextSize);
     _replyButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, buttonTextSize);
     _viewButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, buttonTextSize);
     // Setup the views buttons based on the notification type.
     setupViewSMSButtons(usingImageButtons, _notificationType);
     setupButtonIcons(usingImageButtons, _notificationType, buttonDisplayStyle);
   } catch (Exception ex) {
     Log.e("ThemeView.setupViewButtons() ERROR: " + ex.toString());
   }
 }
示例#3
0
 /** Setup and load the notification specific button icons. */
 private void setupButtonIcons(
     boolean usingImageButtons, int notificationType, String buttonDisplayStyle) {
   if (_debug) Log.v("ThemeView.setupButtonIcons()");
   try {
     if (buttonDisplayStyle.equals(Constants.BUTTON_DISPLAY_TEXT_ONLY)) {
       return;
     }
     Drawable dismissButtonIcon = null;
     Drawable deleteButtonIcon = null;
     Drawable replySMSButtonIcon = null;
     // Load the theme specific icons.
     if (_themePackageName.startsWith(Constants.DARK_TRANSLUCENT_THEME)) {
       dismissButtonIcon = _resources.getDrawable(R.drawable.ic_dismiss);
       deleteButtonIcon = _resources.getDrawable(R.drawable.ic_delete);
       replySMSButtonIcon = _resources.getDrawable(R.drawable.ic_conversation);
     } else {
       dismissButtonIcon =
           _resources.getDrawable(
               _resources.getIdentifier(_themePackageName + ":drawable/ic_dismiss", null, null));
       deleteButtonIcon =
           _resources.getDrawable(
               _resources.getIdentifier(_themePackageName + ":drawable/ic_delete", null, null));
       replySMSButtonIcon =
           _resources.getDrawable(
               _resources.getIdentifier(
                   _themePackageName + ":drawable/ic_conversation", null, null));
     }
     if (usingImageButtons) {
       _dismissImageButton.setImageDrawable(dismissButtonIcon);
       _deleteImageButton.setImageDrawable(deleteButtonIcon);
       _replyImageButton.setImageDrawable(replySMSButtonIcon);
     } else {
       _dismissButton.setCompoundDrawablesWithIntrinsicBounds(dismissButtonIcon, null, null, null);
       _deleteButton.setCompoundDrawablesWithIntrinsicBounds(deleteButtonIcon, null, null, null);
       _replyButton.setCompoundDrawablesWithIntrinsicBounds(replySMSButtonIcon, null, null, null);
     }
   } catch (Exception ex) {
     Log.e("ThemeView.setupButtonIcons() ERROR: " + ex.toString());
   }
 }
示例#4
0
 private void setupViewHeaderButtons() {
   if (_debug) Log.v("ThemeView.setupViewHeaderButtons()");
   try {
     // Previous Button
     _previousButton.setVisibility(View.VISIBLE);
     _previousButton.setOnClickListener(
         new OnClickListener() {
           public void onClick(View view) {
             if (_debug) Log.v("Previous Button Clicked()");
             _themeViewFlipper.showPrevious();
           }
         });
     // Next Button
     _nextButton.setVisibility(View.VISIBLE);
     _nextButton.setOnClickListener(
         new OnClickListener() {
           public void onClick(View view) {
             if (_debug) Log.v("Next Button Clicked()");
             _themeViewFlipper.showNext();
           }
         });
     // TTS Button
     if (_preferences.getBoolean(Constants.DISPLAY_TEXT_TO_SPEECH_KEY, true)) {
       _ttsButton.setVisibility(View.VISIBLE);
     } else {
       _ttsButton.setVisibility(View.GONE);
     }
     // Reschedule Button
     if (_preferences.getBoolean(Constants.DISPLAY_RESCHEDULE_BUTTON_KEY, true)) {
       _rescheduleButton.setVisibility(View.VISIBLE);
     } else {
       _rescheduleButton.setVisibility(View.GONE);
     }
   } catch (Exception ex) {
     Log.e("ThemeView.setupViewHeaderButtons() ERROR: " + ex.toString());
   }
 }
 /** Display the dialog window that allows the user to set the quiet time hours. */
 private void showQuietTimePeriodDialog() {
   LayoutInflater inflater =
       (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   View view = inflater.inflate(R.layout.quiet_time_period_dialog, null);
   final TimePicker startTimePicker = (TimePicker) view.findViewById(R.id.start_time_picker);
   final TimePicker stopTimePicker = (TimePicker) view.findViewById(R.id.stop_time_picker);
   // Sets the view format based on the users time format preference.
   if (_preferences
       .getString(Constants.TIME_FORMAT_KEY, Constants.TIME_FORMAT_DEFAULT)
       .equals(Constants.TIME_FORMAT_24_HOUR)) {
     startTimePicker.setIs24HourView(true);
     stopTimePicker.setIs24HourView(true);
   } else {
     startTimePicker.setIs24HourView(false);
     stopTimePicker.setIs24HourView(false);
   }
   // Initialize the TimePickers
   String startTime = _preferences.getString(Constants.QUIET_TIME_START_TIME_KEY, "");
   String stopTime = _preferences.getString(Constants.QUIET_TIME_STOP_TIME_KEY, "");
   if (!startTime.equals("")) {
     String[] startTimeArray = startTime.split("-");
     if (startTimeArray.length == 2) {
       startTimePicker.setCurrentHour(Integer.parseInt(startTimeArray[0]));
       startTimePicker.setCurrentMinute(Integer.parseInt(startTimeArray[1]));
     } else {
       Log.e(_context, "QuietTimePreferenceActivity() Quiet Time StartTime ERROR: " + startTime);
     }
   }
   if (!stopTime.equals("")) {
     String[] stopTimeArray = stopTime.split("-");
     if (stopTimeArray.length == 2) {
       stopTimePicker.setCurrentHour(Integer.parseInt(stopTimeArray[0]));
       stopTimePicker.setCurrentMinute(Integer.parseInt(stopTimeArray[1]));
     } else {
       Log.e(_context, "QuietTimePreferenceActivity() Quiet Time StopTime ERROR: " + stopTime);
     }
   }
   // Build & Display Dialog
   AlertDialog.Builder quietTimePeriodAlertBuilder = new AlertDialog.Builder(_context);
   try {
     quietTimePeriodAlertBuilder.setIcon(android.R.drawable.ic_dialog_info);
   } catch (Exception ex) {
     // Don't set the icon if this fails.
   }
   quietTimePeriodAlertBuilder.setTitle(R.string.preference_quiet_time_quiet_period_title);
   quietTimePeriodAlertBuilder.setView(view);
   quietTimePeriodAlertBuilder.setPositiveButton(
       android.R.string.ok,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int whichButton) {
           SharedPreferences.Editor editor = _preferences.edit();
           editor.putString(
               Constants.QUIET_TIME_START_TIME_KEY,
               startTimePicker.getCurrentHour() + "-" + startTimePicker.getCurrentMinute());
           editor.putString(
               Constants.QUIET_TIME_STOP_TIME_KEY,
               stopTimePicker.getCurrentHour() + "-" + stopTimePicker.getCurrentMinute());
           editor.commit();
           Toast.makeText(
                   _context,
                   _context.getString(R.string.preference_quiet_time_period_set),
                   Toast.LENGTH_LONG)
               .show();
         }
       });
   quietTimePeriodAlertBuilder.show();
 }
示例#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);
  }