コード例 #1
0
  private void onQueryComplete(AsyncResult ar) {
    StringBuilder sb = new StringBuilder(getScString());
    sb.append("\n");

    if (ar.exception != null) {
      state = State.FAILED;
      sb.append(getErrorMessage(ar));
    } else {
      int[] ints = (int[]) ar.result;

      if (ints.length != 0) {
        if (ints[0] == 0) {
          sb.append(context.getText(com.android.internal.R.string.serviceDisabled));
        } else if (sc.equals(SC_WAIT)) {
          // Call Waiting includes additional data in the response.
          sb.append(createQueryCallWaitingResultMessage(ints[1]));
        } else if (isServiceCodeCallBarring(sc)) {
          // ints[0] for Call Barring is a bit vector of services
          sb.append(createQueryCallBarringResultMessage(ints[0]));
        } else if (ints[0] == 1) {
          // for all other services, treat it as a boolean
          sb.append(context.getText(com.android.internal.R.string.serviceEnabled));
        } else {
          sb.append(context.getText(com.android.internal.R.string.mmiError));
        }
      } else {
        sb.append(context.getText(com.android.internal.R.string.mmiError));
      }
      state = State.COMPLETE;
    }

    message = sb;
    phone.onMMIDone(this);
  }
コード例 #2
0
 /**
  * This method sends a notification to NotificationManager to display an error dialog indicating
  * low disk space and launch the Installer application
  */
 private final void sendNotification() {
   if (localLOGV) Slog.i(TAG, "Sending low memory notification");
   // log the event to event log with the amount of free storage(in bytes) left on the device
   EventLog.writeEvent(EventLogTags.LOW_STORAGE, mFreeMem);
   //  Pack up the values and broadcast them to everyone
   Intent lowMemIntent =
       new Intent(
           Environment.isExternalStorageEmulated()
               ? Settings.ACTION_INTERNAL_STORAGE_SETTINGS
               : Intent.ACTION_MANAGE_PACKAGE_STORAGE);
   lowMemIntent.putExtra("memory", mFreeMem);
   lowMemIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   NotificationManager mNotificationMgr =
       (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
   CharSequence title =
       mContext.getText(com.android.internal.R.string.low_internal_storage_view_title);
   CharSequence details =
       mContext.getText(com.android.internal.R.string.low_internal_storage_view_text);
   PendingIntent intent =
       PendingIntent.getActivityAsUser(mContext, 0, lowMemIntent, 0, null, UserHandle.CURRENT);
   Notification notification = new Notification();
   notification.icon = com.android.internal.R.drawable.stat_notify_disk_full;
   notification.tickerText = title;
   notification.flags |= Notification.FLAG_NO_CLEAR;
   notification.setLatestEventInfo(mContext, title, details, intent);
   mNotificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification, UserHandle.ALL);
   mContext.sendStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
 }
コード例 #3
0
  public FilenameDialog(Context context) {
    super(context);
    mContext = context;

    // setTitle(context.getText(R.string.menu_edit_tags));
    setButton(context.getText(android.R.string.ok), this);
    setButton2(context.getText(android.R.string.cancel), (OnClickListener) null);
    setIcon(R.drawable.ic_launcher_folder_small);

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.dialog_filename, null);
    setView(view);

    mEditText = (EditText) view.findViewById(R.id.file_path);

    // SharedPreferences pm = PreferenceManager.getDefaultSharedPreferences(this);
    // mEditText.setText(pm.getString(PREFERENCE_FILENAME, DEFAULT_FILENAME));

    ImageButton buttonFileManager = (ImageButton) view.findViewById(R.id.file_manager);

    buttonFileManager.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View arg0) {
            openFileManager();
          }
        });
  }
コード例 #4
0
    public String toString(Context context, boolean showNever) {
      StringBuilder ret = new StringBuilder();

      // no days
      if (mDays == 0) {
        return showNever ? context.getText(R.string.never).toString() : "";
      }

      // every day
      if (mDays == 0x7f) {
        return context.getText(R.string.every_day).toString();
      }

      // count selected days
      int dayCount = 0, days = mDays;
      while (days > 0) {
        if ((days & 1) == 1) dayCount++;
        days >>= 1;
      }

      // short or long form?
      DateFormatSymbols dfs = new DateFormatSymbols();
      String[] dayList = (dayCount > 1) ? dfs.getShortWeekdays() : dfs.getWeekdays();

      // selected days
      for (int i = 0; i < 7; i++) {
        if ((mDays & (1 << i)) != 0) {
          ret.append(dayList[DAY_MAP[i]]);
          dayCount -= 1;
          if (dayCount > 0) ret.append(context.getText(R.string.day_concat));
        }
      }
      return ret.toString();
    }
コード例 #5
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);
  }
コード例 #6
0
 public TimePickerDialog(
     Context context,
     int theme,
     OnTimeSetListener callBack,
     int hourOfDay,
     int minute,
     boolean is24HourView) {
   super(context, theme);
   mCallback = callBack;
   mInitialHourOfDay = hourOfDay;
   mInitialMinute = minute;
   mIs24HourView = is24HourView;
   setIcon(0);
   setTitle(R.string.time_picker_dialog_title);
   Context themeContext = getContext();
   setButton(DialogInterface.BUTTON_POSITIVE, themeContext.getText(R.string.date_time_set), this);
   setButton(
       DialogInterface.BUTTON_NEGATIVE,
       themeContext.getText(android.R.string.cancel),
       (OnClickListener) null);
   View view = LayoutInflater.inflate(themeContext, R.layout.time_picker_dialog);
   setView(view);
   mTimePicker = (TimePicker) view.findViewById(R.id.timePicker);
   mTimePicker.setIs24HourView(mIs24HourView);
   mTimePicker.setCurrentHour(mInitialHourOfDay);
   mTimePicker.setCurrentMinute(mInitialMinute);
   mTimePicker.setOnTimeChangedListener(this);
 }
コード例 #7
0
  public boolean isThisDeviceAlreadyRegisteredWithPrey(boolean notifyUser) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ctx);
    String deviceId = settings.getString(PreyConfig.PREFS_DEVICE_ID, null);

    boolean isVerified = deviceId != null;

    if (notifyUser && !isVerified) {
      String notificationTitle = ctx.getText(R.string.not_verified_device_title).toString();
      NotificationManager nm =
          (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
      Notification notification =
          new Notification(
              R.drawable.ic_stat_notify_exclamation25,
              notificationTitle,
              System.currentTimeMillis());
      notification.flags = Notification.FLAG_AUTO_CANCEL;

      Intent preyMainActivity = new Intent(ctx, WelcomeActivity.class);
      String notificationToShow = ctx.getText(R.string.not_verified_device_msg).toString();
      PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, preyMainActivity, 0);
      notification.contentIntent = contentIntent;
      notification.setLatestEventInfo(
          ctx, ctx.getText(R.string.not_verified_device_title), notificationToShow, contentIntent);

      nm.notify(R.string.preyForAndroid_name, notification);
    }

    return isVerified;
  }
コード例 #8
0
  private static void beginShutdownSequence(Context context) {
    synchronized (sIsStartedGuard) {
      if (sIsStarted) {
        Log.d(TAG, "Shutdown sequence already running, returning.");
        return;
      }
      sIsStarted = true;
    }

    // throw up an indeterminate system dialog to indicate radio is
    // shutting down.
    ProgressDialog pd = new ProgressDialog(context);
    if (mReboot) {
      pd.setTitle(context.getText(com.android.internal.R.string.reboot_system));
      pd.setMessage(context.getText(com.android.internal.R.string.reboot_progress));
    } else {
      pd.setTitle(context.getText(com.android.internal.R.string.power_off));
      pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
    }
    pd.setIndeterminate(true);
    pd.setCancelable(false);
    pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);

    pd.show();

    sInstance.mContext = context;
    sInstance.mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

    // make sure we never fall asleep again
    sInstance.mCpuWakeLock = null;
    try {
      sInstance.mCpuWakeLock =
          sInstance.mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG + "-cpu");
      sInstance.mCpuWakeLock.setReferenceCounted(false);
      sInstance.mCpuWakeLock.acquire();
    } catch (SecurityException e) {
      Log.w(TAG, "No permission to acquire wake lock", e);
      sInstance.mCpuWakeLock = null;
    }

    // also make sure the screen stays on for better user experience
    sInstance.mScreenWakeLock = null;
    if (sInstance.mPowerManager.isScreenOn()) {
      try {
        sInstance.mScreenWakeLock =
            sInstance.mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG + "-screen");
        sInstance.mScreenWakeLock.setReferenceCounted(false);
        sInstance.mScreenWakeLock.acquire();
      } catch (SecurityException e) {
        Log.w(TAG, "No permission to acquire wake lock", e);
        sInstance.mScreenWakeLock = null;
      }
    }

    // start the thread that initiates shutdown
    sInstance.mHandler = new Handler() {};
    sInstance.start();
  }
コード例 #9
0
ファイル: ContextTest.java プロジェクト: rcoscali/cts
  public void testGetText() {
    CharSequence testCharSequence = mContext.getText(R.string.context_test_string2);
    assertEquals("This is test string.", testCharSequence.toString());

    // Test wrong resource id
    try {
      testCharSequence = mContext.getText(0);
      fail("Wrong resource id should not be accepted.");
    } catch (NotFoundException e) {
    }
  }
コード例 #10
0
 @Override
 public CharSequence getPageTitle(int position) {
   switch (position) {
     case 0:
       return mContext.getText(R.string.news);
     case 1:
       return mContext.getText(R.string.info);
     case 2:
       return mContext.getText(R.string.events);
   }
   return "";
 }
コード例 #11
0
  private CharSequence getErrorMessage(AsyncResult ar) {

    if (ar.exception instanceof CommandException) {
      CommandException.Error err = ((CommandException) (ar.exception)).getCommandError();
      if (err == CommandException.Error.FDN_CHECK_FAILURE) {
        Log.i(LOG_TAG, "FDN_CHECK_FAILURE");
        return context.getText(com.android.internal.R.string.mmiFdnError);
      }
    }

    return context.getText(com.android.internal.R.string.mmiError);
  }
コード例 #12
0
  /** one CallForwardInfo + serviceClassMask -> one line of text */
  private CharSequence makeCFQueryResultMessage(CallForwardInfo info, int serviceClassMask) {
    CharSequence template;
    String sources[] = {"{0}", "{1}", "{2}"};
    CharSequence destinations[] = new CharSequence[3];
    boolean needTimeTemplate;

    // CF_REASON_NO_REPLY also has a time value associated with
    // it. All others don't.

    needTimeTemplate = (info.reason == CommandsInterface.CF_REASON_NO_REPLY);

    if (info.status == 1) {
      if (needTimeTemplate) {
        template = context.getText(com.android.internal.R.string.cfTemplateForwardedTime);
      } else {
        template = context.getText(com.android.internal.R.string.cfTemplateForwarded);
      }
    } else if (info.status == 0 && isEmptyOrNull(info.number)) {
      template = context.getText(com.android.internal.R.string.cfTemplateNotForwarded);
    } else {
        /* (info.status == 0) && !isEmptyOrNull(info.number) */
      // A call forward record that is not active but contains
      // a phone number is considered "registered"

      if (needTimeTemplate) {
        template = context.getText(com.android.internal.R.string.cfTemplateRegisteredTime);
      } else {
        template = context.getText(com.android.internal.R.string.cfTemplateRegistered);
      }
    }

    // In the template (from strings.xmls)
    //         {0} is one of "bearerServiceCode*"
    //        {1} is dialing number
    //      {2} is time in seconds

    destinations[0] = serviceClassToCFString(info.serviceClass & serviceClassMask);
    destinations[1] = PhoneNumberUtils.stringFromStringAndTOA(info.number, info.toa);
    destinations[2] = Integer.toString(info.timeSeconds);

    if (info.reason == CommandsInterface.CF_REASON_UNCONDITIONAL
        && (info.serviceClass & serviceClassMask) == CommandsInterface.SERVICE_CLASS_VOICE) {
      boolean cffEnabled = (info.status == 1);
      if (phone.mSIMRecords != null) {
        phone.setCallForwardingPreference(cffEnabled);
        phone.mSIMRecords.setVoiceCallForwardingFlag(1, cffEnabled);
      } else {
        Log.w(LOG_TAG, "setVoiceCallForwardingFlag aborted. sim records is null.");
      }
    }

    return TextUtils.replace(template, sources, destinations);
  }
コード例 #13
0
 @Override
 public CharSequence getPageTitle(int position) {
   switch (position) {
     case 0:
       return mContext.getText(R.string.pulse_events);
     case 1:
       return mContext.getText(R.string.pulse_attendees);
     case 2:
       return mContext.getText(R.string.pulse_circlers);
   }
   return "";
 }
コード例 #14
0
    private void initializeAmount(TransactionUIModel transaction) {
      IconTextView transactionIcon =
          (IconTextView) itemView.findViewById(R.id.transactionTypeImage);

      transactionIcon.setText(
          transaction.isIncome()
              ? context.getText(R.string.basketFill)
              : context.getText(R.string.basketUnFill));

      TextView amountView = (TextView) itemView.findViewById(R.id.transactionAmount);
      amountView.setText(
          CurrencyUtil.formatCurrency(transaction.getAmount(), transaction.getCurrencyType()));
    }
コード例 #15
0
 private static void sendFeedBack(Context context, Hiniid hiniid, String mailAddress) {
   Intent sendIntent = new Intent(Intent.ACTION_SEND);
   final String[] mailto = {mailAddress};
   sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.feedback_subject));
   sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
   sendIntent.setType("message/rfc822");
   try {
     context.startActivity(
         Intent.createChooser(sendIntent, context.getText(R.string.feedback_subject)));
   } catch (ActivityNotFoundException ex) {
     Toast.makeText(context, context.getText(R.string.feedback_error), Toast.LENGTH_SHORT).show();
   }
 }
コード例 #16
0
ファイル: Message.java プロジェクト: hawk081/Conversations
 public String getReadableBody(Context context) {
   if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) {
     return "" + context.getText(R.string.encrypted_message_received);
   } else if ((encryption == ENCRYPTION_OTR) && (type == TYPE_IMAGE)) {
     return "" + context.getText(R.string.encrypted_image_received);
   } else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {
     return "" + context.getText(R.string.decryption_failed);
   } else if (type == TYPE_IMAGE) {
     return "" + context.getText(R.string.image_file);
   } else {
     return body.trim();
   }
 }
コード例 #17
0
  @Override
  public int process(BaseProtocolFrame source) {
    if (source != null && source instanceof RequestSendMessage) {
      RequestSendMessage rsm = (RequestSendMessage) source;
      MessageFrame msg = rsm.getMsgEntity();

      switch (source.getReq()) {
        case BaseProtocolFrame.RESPONSE_TYPE_OKAY:
          break;
        case BaseProtocolFrame.RESPONSE_TYPE_NO_LOGIN:
          Toast.makeText(
                  context, context.getText(R.string.response_error_no_login), Toast.LENGTH_SHORT)
              .show();
          if (preference == null) {
            preference = new Preferences(context);
          }
          preference.setLoginState(false);
          Intent logoutIntent = new Intent();
          logoutIntent.setAction("com.forolder.logout.activity");
          context.sendBroadcast(logoutIntent);
          Intent intent = new Intent(context, LoginActivity.class);
          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          context.startActivity(intent);

          break;
        case BaseProtocolFrame.RESPONSE_TYPE_OTHER_LOGIN:
          Toast.makeText(
                  context,
                  context.getText(R.string.response_error_login_other_phone),
                  Toast.LENGTH_SHORT)
              .show();
          break;
        default:
          break;
      }

      if (msg != null) {
        if (msg.getState() == MessageFrame.SENDSTATE_SENDING) {
          msg.setState(MessageFrame.SENDSTATE_FAULT);
        }
        DatabaseHelper dbHelper = new DatabaseHelper(context);
        ContentValues values = new ContentValues();
        values.put("send_state", msg.getState());
        dbHelper.updateMessage(values, msg.getLoginId(), msg.getDate(), msg.getUserMsgType());
      }
    } else {
      return -100;
    }
    return 0;
  }
コード例 #18
0
ファイル: ArkBaseDialog.java プロジェクト: YLBFDEV/sky-master
 /**
  * Set the positive button resource and it's listener
  *
  * @param positiveButtonText
  * @param listener
  * @return
  */
 public Builder setPositiveButton(
     int positiveButtonRes, int positiveButtonText, OnClickListener listener) {
   this.positiveButtonRes = positiveButtonRes;
   this.positiveButtonText = (String) context.getText(positiveButtonText);
   this.positiveButtonClickListener = listener;
   return this;
 }
コード例 #19
0
ファイル: ArkBaseDialog.java プロジェクト: YLBFDEV/sky-master
 /**
  * Set the negative button resource and it's listener
  *
  * @param negativeButtonText
  * @param listener
  * @return
  */
 public Builder setNegativeButton(
     int negativeButtonRes, int negativeButtonText, OnClickListener listener) {
   this.negativeButtonRes = negativeButtonRes;
   this.negativeButtonText = (String) context.getText(negativeButtonText);
   this.negativeButtonClickListener = listener;
   return this;
 }
コード例 #20
0
  private void updateViews() {
    if (mTitle != null) {
      // Link the title to the entry URL
      SpannableString link = new SpannableString(mTitle);
      if (mUrl != null) {
        int start = 0;
        int end = mTitle.length();
        int flags = 0;
        link.setSpan(new URLSpan(mUrl), start, end, flags);
      }
      mTitleView.setText(link);

      // Show the content, or the summary if no content is available.
      String body =
          !TextUtils.isEmpty(mContent) ? mContent : !TextUtils.isEmpty(mSummary) ? mSummary : "";

      // Show the feed title in the window decorator.
      if (!TextUtils.isEmpty(mTitle)) {
        setTitle(mTitle);
      } else {
        Context context = getContext();
        setTitle(context.getText(R.string.atom_title_entry));
      }

      // Use loadDataWithBaseURL instead of loadData for unsanitized HTML:
      // http://code.google.com/p/android/issues/detail?id=1733
      mContentView.clearView();
      mContentView.loadDataWithBaseURL(null, body, MIME_TYPE, ENCODING, null);
    }
  }
コード例 #21
0
ファイル: CdmaMmiCode.java プロジェクト: BvbKoala/SourceCode
 /** Process a MMI PUK code */
 void processCode() {
   try {
     if (isPukCommand()) {
       // sia = old PUK
       // sib = new PIN
       // sic = new PIN
       String oldPinOrPuk = sia;
       String newPin = sib;
       int pinLen = newPin.length();
       if (isRegister()) {
         if (!newPin.equals(sic)) {
           // password mismatch; return error
           handlePasswordError(com.android.internal.R.string.mismatchPin);
         } else if (pinLen < 4 || pinLen > 8) {
           // invalid length
           handlePasswordError(com.android.internal.R.string.invalidPin);
         } else {
           phone.mCM.supplyIccPuk(oldPinOrPuk, newPin, obtainMessage(EVENT_SET_COMPLETE, this));
         }
       } else {
         throw new RuntimeException("Invalid or Unsupported MMI Code");
       }
     } else {
       throw new RuntimeException("Invalid or Unsupported MMI Code");
     }
   } catch (RuntimeException exc) {
     state = State.FAILED;
     message = context.getText(com.android.internal.R.string.mmiError);
     phone.onMMIDone(this);
   }
 }
コード例 #22
0
 /**
  * Handles speaking the "connect a headset to hear passwords" notification when connecting to a
  * password field.
  *
  * @param view The source view.
  * @param editorInfo The input connection's editor info attribute.
  * @param restarting Whether the connection is being restarted.
  */
 public void onStartInputViewInternal(
     final View view, final EditorInfo editorInfo, final boolean restarting) {
   if (shouldObscureInput(editorInfo)) {
     final CharSequence text = mContext.getText(R.string.spoken_use_headphones);
     announceForAccessibility(view, text);
   }
 }
コード例 #23
0
  /**
   * @param context The context the dialog is to run in.
   * @param theme the theme to apply to this dialog
   * @param callBack How the parent is notified that the date is set.
   * @param year The initial year of the dialog.
   * @param monthOfYear The initial month of the dialog.
   * @param dayOfMonth The initial day of the dialog.
   */
  public DatePickerDialog(
      Context context,
      int theme,
      OnDateSetListener callBack,
      int year,
      int monthOfYear,
      int dayOfMonth) {
    super(context, theme);

    mCallBack = callBack;

    mCalendar = Calendar.getInstance();

    Context themeContext = getContext();
    setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_done), this);
    setIcon(0);

    LayoutInflater inflater =
        (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.date_picker_dialog, null);
    setView(view);
    mDatePicker = (DatePicker) view.findViewById(R.id.datePicker);
    mDatePicker.init(year, monthOfYear, dayOfMonth, this);
    updateTitle(year, monthOfYear, dayOfMonth);
  }
コード例 #24
0
  private void handleIsOpen(final Context mContext, final OpeningStatus openingStatus) {
    final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
    final int[] appWidgetIds =
        appWidgetManager.getAppWidgetIds(new ComponentName(mContext, AnalogWidget.class));
    final RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.analog_widget);
    views.setTextViewText(R.id.appwidget_text, mContext.getText(R.string.refreshing_analog));
    views.setTextColor(
        R.id.appwidget_text, ContextCompat.getColor(mContext, android.R.color.primary_text_dark));
    // Instruct the widget manager to update the widget
    for (int appWidgetId : appWidgetIds) {
      appWidgetManager.updateAppWidget(appWidgetId, views);
    }

    CharSequence widgetText;
    if (openingStatus.open) {
      widgetText = mContext.getString(R.string.widget_open_analog);
      views.setTextColor(R.id.appwidget_text, ContextCompat.getColor(mContext, R.color.openColor));
    } else {
      widgetText = mContext.getString(R.string.widget_closed_analog);
      views.setTextColor(
          R.id.appwidget_text, ContextCompat.getColor(mContext, R.color.closedColor));
    }

    views.setTextViewText(R.id.appwidget_text, widgetText);
    views.setOnClickPendingIntent(R.id.appwidget_text, getPendingSelfIntent(mContext));
    // Instruct the widget manager to update the widget
    for (int appWidgetId : appWidgetIds) {
      appWidgetManager.updateAppWidget(appWidgetId, views);
    }
  }
コード例 #25
0
 public LegacyPhoneNumberListAdapter(Context context) {
   super(context);
   // begin: added by yunzhou.song
   mFragment = null;
   // end: added by yunzhou.song
   mUnknownNameText = context.getText(android.R.string.unknownName);
 }
コード例 #26
0
  /**
   * @param context Parent.
   * @param theme the theme to apply to this dialog
   * @param callBack How parent is notified.
   * @param number The initial number.
   */
  private NumberPickerDialog(
      Context context,
      int theme,
      OnNumberSetListener callBack,
      int number,
      int rangeMin,
      int rangeMax,
      int title,
      int units,
      int dialogId) {
    super(context, theme);
    mCallback = callBack;
    mDialogId = dialogId;

    setTitle(title);

    setButton(DialogInterface.BUTTON_POSITIVE, context.getText(R.string.ok), this);
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.number_picker_dialog, null);
    setView(view);
    mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);

    if (units != 0) {
      TextView unit = (TextView) view.findViewById(R.id.unit);
      unit.setText(units);
      unit.setVisibility(View.VISIBLE);
    }

    // initialize state
    mNumberPicker.setMinValue(rangeMin);
    mNumberPicker.setMaxValue(rangeMax);
    mNumberPicker.setValue(number);
  }
コード例 #27
0
  @Override
  public void vshow(
      final Context context,
      final String message,
      final String tickerText,
      final int id,
      PendingIntent contentIntent) {

    /*
     * If contentIntent is NULL, create valid contentIntent
     */
    if (contentIntent == null)
      contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setTicker(tickerText);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(R.drawable.icon);
    builder.setContentTitle(context.getText(R.string.app_name));
    builder.setContentIntent(contentIntent);
    builder.setContentText(message);
    builder.setAutoCancel(true);

    // unique ID
    notify(context, id, VSHOW_TAG, builder.build());
  }
コード例 #28
0
 private void handlePasswordError(int res) {
   mState = State.FAILED;
   StringBuilder sb = new StringBuilder(getScString());
   sb.append("\n");
   sb.append(mContext.getText(res));
   mMessage = sb;
   mPhone.onMMIDone(this);
 }
コード例 #29
0
 @Override
 public void execute() {
   if (!Variables.isDefined(SCORE_VARIABLE)) {
     Variables.setValue(SCORE_VARIABLE, 0);
   }
   int deltaScore = Integer.parseInt(params.get("value"));
   int resultingScore = addToScore(deltaScore);
   if (resultingScore == 0) {
     GeoQuestApp.showMessage(ctx.getText(R.string.scoreZero));
   } else if (deltaScore > 0) {
     // GeoQuestApp.playAudio(ResourceManager.POSITIVE_SOUND, false);
     GeoQuestApp.showMessage(ctx.getText(R.string.scoreIncreasedBy) + " " + deltaScore);
   } else if (deltaScore < 0) {
     // GeoQuestApp.playAudio(ResourceManager.NEGATIVE_SOUND, false);
     GeoQuestApp.showMessage(ctx.getText(R.string.scoreDecreasedBy) + " " + (-deltaScore));
   }
 }
コード例 #30
0
  /**
   * Called from GSMPhone
   *
   * <p>The radio has reset, and this is still pending
   */
  void onUssdFinishedError() {
    if (state == State.PENDING) {
      state = State.FAILED;
      message = context.getText(com.android.internal.R.string.mmiError);

      phone.onMMIDone(this);
    }
  }