@Override
  public Dialog onCreateDialog(final Bundle savedInstanceState) {
    Activity activity = getActivity();
    Bundle arguments = getArguments();

    final AlertDialog dialog = createDialog();
    dialog.setButton(BUTTON_NEGATIVE, activity.getString(R.string.cancel), this);
    dialog.setButton(BUTTON_NEUTRAL, activity.getString(R.string.clear), this);

    LayoutInflater inflater = activity.getLayoutInflater();

    ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
    view.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onClick(dialog, position);
          }
        });

    ArrayList<Milestone> choices = getChoices();
    int selected = arguments.getInt(ARG_SELECTED_CHOICE);
    MilestoneListAdapter adapter =
        new MilestoneListAdapter(
            inflater, choices.toArray(new Milestone[choices.size()]), selected);
    view.setAdapter(adapter);
    if (selected >= 0) view.setSelection(selected);
    dialog.setView(view);

    return dialog;
  }
Esempio n. 2
0
  /**
   * 显示征询“确认�?以及“取消�?的对话框
   *
   * @param activity 显示此对话框的Activity对象
   * @param title 对话框的标题
   * @param text 对话框显示的内容
   * @param listener 用户选择的监听器
   */
  public static void showOptionWindow(
      Activity activity, String title, String text, OnOptionListener listener) {
    AlertDialog dialog = new AlertDialog.Builder(activity).create();
    if (title != null) {
      dialog.setTitle(title);
    }

    if (text != null) {
      dialog.setMessage(text);
    }

    final OnOptionListener oListener = listener;
    dialog.setButton(
        AlertDialog.BUTTON_POSITIVE,
        activity.getString(R.string.renren_sdk_submit),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            oListener.onOK();
          }
        });
    dialog.setButton(
        AlertDialog.BUTTON_NEGATIVE,
        activity.getString(R.string.renren_sdk_cancel),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            oListener.onCancel();
          }
        });
    dialog.show();
  }
  @Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    // General ListView optimization code.
    if (view == null) {
      view = mInflator.inflate(R.layout.list_item_device, null);
      viewHolder = new ViewHolder();
      viewHolder.deviceAddress = (TextView) view.findViewById(R.id.device_address);
      viewHolder.deviceName = (TextView) view.findViewById(R.id.device_name);
      viewHolder.deviceRssi = (TextView) view.findViewById(R.id.device_rssi);
      viewHolder.deviceLastUpdated = (TextView) view.findViewById(R.id.device_last_update);
      viewHolder.ibeaconMajor = (TextView) view.findViewById(R.id.ibeacon_major);
      viewHolder.ibeaconMinor = (TextView) view.findViewById(R.id.ibeacon_minor);
      viewHolder.ibeaconDistance = (TextView) view.findViewById(R.id.ibeacon_distance);
      viewHolder.ibeaconUUID = (TextView) view.findViewById(R.id.ibeacon_uuid);
      viewHolder.ibeaconTxPower = (TextView) view.findViewById(R.id.ibeacon_tx_power);
      viewHolder.ibeaconSection = view.findViewById(R.id.ibeacon_section);
      viewHolder.ibeaconDistanceDescriptor =
          (TextView) view.findViewById(R.id.ibeacon_distance_descriptor);
      view.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) view.getTag();
    }

    final BluetoothLeDevice device = getCursor().getItem(i);
    final String deviceName = device.getName();
    final double rssi = device.getRssi();

    if (deviceName != null && deviceName.length() > 0) {
      viewHolder.deviceName.setText(deviceName);
    } else {
      viewHolder.deviceName.setText(R.string.unknown_device);
    }

    if (IBeaconUtils.isThisAnIBeacon(device)) {
      final IBeaconDevice iBeacon = new IBeaconDevice(device);
      final String accuracy = Constants.DOUBLE_TWO_DIGIT_ACCURACY.format(iBeacon.getAccuracy());

      viewHolder.ibeaconSection.setVisibility(View.VISIBLE);
      viewHolder.ibeaconMajor.setText(String.valueOf(iBeacon.getMajor()));
      viewHolder.ibeaconMinor.setText(String.valueOf(iBeacon.getMinor()));
      viewHolder.ibeaconTxPower.setText(String.valueOf(iBeacon.getCalibratedTxPower()));
      viewHolder.ibeaconUUID.setText(iBeacon.getUUID());
      viewHolder.ibeaconDistance.setText(mActivity.getString(R.string.formatter_meters, accuracy));
      viewHolder.ibeaconDistanceDescriptor.setText(iBeacon.getDistanceDescriptor().toString());
    } else {
      viewHolder.ibeaconSection.setVisibility(View.GONE);
    }

    final String rssiString = mActivity.getString(R.string.formatter_db, String.valueOf(rssi));
    final String runningAverageRssiString =
        mActivity.getString(R.string.formatter_db, String.valueOf(device.getRunningAverageRssi()));

    viewHolder.deviceLastUpdated.setText(
        android.text.format.DateFormat.format(
            Constants.TIME_FORMAT, new java.util.Date(device.getTimestamp())));
    viewHolder.deviceAddress.setText(device.getAddress());
    viewHolder.deviceRssi.setText(rssiString + " / " + runningAverageRssiString);
    return view;
  }
Esempio n. 4
0
    @Override
    public void onClick(View v) {
      String label = ((Button) v).getText().toString();
      String positive = activity.getString(R.string.alert_pos);
      if (label.equals(positive)) {
        String recipient = activity.getString(R.string.email);
        String subject = activity.getString(R.string.subject);
        String type = activity.getString(R.string.type);

        // get stacktrace as string
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String body = sw.toString();

        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType(type);
        i.putExtra(Intent.EXTRA_EMAIL, new String[] {recipient});
        i.putExtra(Intent.EXTRA_SUBJECT, subject);
        i.putExtra(Intent.EXTRA_TEXT, body);

        try {
          activity.startActivity(Intent.createChooser(i, "Send email"));
        } catch (android.content.ActivityNotFoundException ex) {
        }
      }

      dialog.dismiss();
    }
  private void handlePopupMenu(MenuItem item, Score score) {
    switch (item.getItemId()) {
      case R.id.action_share:
        String subject =
            mActivity.getString(
                R.string.content_share_subject, score.getHomeName(), score.getAwayName());
        String message =
            score.getHomeGoals() >= 0
                ? mActivity.getString(
                    R.string.content_share_message_result,
                    score.getHomeName(),
                    score.getHomeGoals(),
                    score.getAwayName(),
                    score.getAwayGoals())
                : mActivity.getString(
                    R.string.content_share_message_upcoming,
                    score.getMatchDay(),
                    score.getTime(),
                    ScoreUtils.getLeague(mActivity, score.getLeagueId(), false));

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
        intent.putExtra(Intent.EXTRA_TEXT, message);

        mActivity.startActivity(
            Intent.createChooser(intent, mActivity.getString(R.string.content_share_app)));
        break;
    }
  }
  public static void dlg_register_main(Activity actv) {
    /*----------------------------
    * Steps
    * 1. Get a dialog
    * 2. List view
    * 3. Set listener => list
    * 9. Show dialog
    ----------------------------*/

    Dialog dlg =
        dlg_template_cancel(
            actv,
            R.layout.dlg_register_main,
            R.string.generic_register,
            R.id.dlg_register_main_btn_cancel,
            Methods.DialogButtonTags.dlg_generic_dismiss);

    /*----------------------------
    * 2. List view
    * 		1. Get view
    * 		2. Prepare list data
    * 		3. Prepare adapter
    * 		4. Set adapter
    ----------------------------*/
    ListView lv = (ListView) dlg.findViewById(R.id.dlg_register_main_lv_list);

    /*----------------------------
    * 2.2. Prepare list data
    ----------------------------*/
    List<String> registerItems = new ArrayList<String>();

    registerItems.add(actv.getString(R.string.dlg_register_main_items));
    registerItems.add(actv.getString(R.string.dlg_register_main_stores));
    registerItems.add(actv.getString(R.string.dlg_register_main_genres));

    /** ******************************* 2.3. Prepare adapter ******************************* */
    ArrayAdapter<String> adp =
        new ArrayAdapter<String>(
            actv,
            android.R.layout.simple_list_item_1,
            //				R.layout.list_row_dlg_register_main,
            registerItems);

    /*----------------------------
    * 2.4. Set adapter
    ----------------------------*/
    lv.setAdapter(adp);

    lv.setTag(Methods.DialogItemTags.dlg_register_main);

    /*----------------------------
    * 3. Set listener => list
    ----------------------------*/
    lv.setOnItemClickListener(new DialogOnItemClickListener(actv, dlg));

    /*----------------------------
    * 9. Show dialog
    ----------------------------*/
    dlg.show();
  } // public static void dlg_register_main(Activity actv)
 @Override
 public void onResponse(BaseResponse baseResp) {
   // TODO Auto-generated method stub
   switch (baseResp.errCode) {
     case WBConstants.ErrorCode.ERR_OK:
       Toast.makeText(
               act, act.getString(R.string.weibosdk_demo_toast_share_success), Toast.LENGTH_LONG)
           .show();
       break;
     case WBConstants.ErrorCode.ERR_CANCEL:
       Toast.makeText(
               act, act.getString(R.string.weibosdk_demo_toast_share_canceled), Toast.LENGTH_LONG)
           .show();
       break;
     case WBConstants.ErrorCode.ERR_FAIL:
       Toast.makeText(
               act,
               act.getString(R.string.weibosdk_demo_toast_share_failed)
                   + "Error Message: "
                   + baseResp.errMsg,
               Toast.LENGTH_LONG)
           .show();
       break;
   }
 }
 @Override
 public boolean onMenuItemClick(MenuItem popMenuItem) {
   final String itemId;
   switch (popMenuItem.getItemId()) {
     case R.id.editEvent:
       item = eventItemList.get(currentPosition);
       itemId = item.getObjectId();
       openForm(itemId);
       return true;
     case R.id.deleteEvent:
       item = eventItemList.get(currentPosition);
       itemId = item.getObjectId();
       new DialogBox()
           .dialog(
               activity,
               activity.getString(R.string.delete_item_title),
               activity.getString(R.string.delete_item_message),
               new DialogBox.CallBack() {
                 @Override
                 public void onFinished() {
                   delete(itemId);
                 }
               });
       return true;
     case R.id.bidItem:
       new ItemBidHandler(activity, eventItemList, currentPosition).bidItem();
       return true;
     default:
       return false;
   }
 }
  public AlgorithmNames(Activity context) {
    super();
    this.mActivity = context;

    mEncryptionNames.put(PGPEncryptedData.AES_128, "AES-128");
    mEncryptionNames.put(PGPEncryptedData.AES_192, "AES-192");
    mEncryptionNames.put(PGPEncryptedData.AES_256, "AES-256");
    mEncryptionNames.put(PGPEncryptedData.BLOWFISH, "Blowfish");
    mEncryptionNames.put(PGPEncryptedData.TWOFISH, "Twofish");
    mEncryptionNames.put(PGPEncryptedData.CAST5, "CAST5");
    mEncryptionNames.put(PGPEncryptedData.DES, "DES");
    mEncryptionNames.put(PGPEncryptedData.TRIPLE_DES, "Triple DES");
    mEncryptionNames.put(PGPEncryptedData.IDEA, "IDEA");

    mHashNames.put(HashAlgorithmTags.MD5, "MD5");
    mHashNames.put(HashAlgorithmTags.RIPEMD160, "RIPEMD-160");
    mHashNames.put(HashAlgorithmTags.SHA1, "SHA-1");
    mHashNames.put(HashAlgorithmTags.SHA224, "SHA-224");
    mHashNames.put(HashAlgorithmTags.SHA256, "SHA-256");
    mHashNames.put(HashAlgorithmTags.SHA384, "SHA-384");
    mHashNames.put(HashAlgorithmTags.SHA512, "SHA-512");

    mCompressionNames.put(
        Id.choice.compression.none,
        mActivity.getString(R.string.choice_none)
            + " ("
            + mActivity.getString(R.string.fast)
            + ")");
    mCompressionNames.put(
        Id.choice.compression.zip, "ZIP (" + mActivity.getString(R.string.fast) + ")");
    mCompressionNames.put(
        Id.choice.compression.zlib, "ZLIB (" + mActivity.getString(R.string.fast) + ")");
    mCompressionNames.put(
        Id.choice.compression.bzip2, "BZIP2 (" + mActivity.getString(R.string.very_slow) + ")");
  }
Esempio n. 10
0
 @Override
 protected void onPreExecute() {
   progress_dialog.setTitle(activity.getString(R.string.preparing_pass));
   progress_dialog.setMessage(activity.getString(R.string.please_wait));
   progress_dialog.show();
   super.onPreExecute();
 }
Esempio n. 11
0
 @Override
 protected void onPostExecute(final ConfInfo[] possibleRecip) {
   mDialog.dismiss();
   if (possibleRecip == null || possibleRecip.length == 0) {
     final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
     builder.setTitle(mActivity.getString(R.string.im_no_such_recipient) + mRecip);
     builder.setPositiveButton(mActivity.getString(R.string.alert_dialog_ok), null);
     builder.create().show();
   } else if (possibleRecip.length == 1) {
     if (mRunnable != null) {
       mRunnable.run(possibleRecip[0]);
     }
   } else {
     final String[] items = new String[possibleRecip.length];
     for (int i = 0; i < items.length; ++i) {
       items[i] = possibleRecip[i].getNameString();
     }
     final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
     builder.setTitle(mActivity.getString(R.string.pick_a_name));
     builder.setSingleChoiceItems(
         items,
         -1,
         new DialogInterface.OnClickListener() {
           public void onClick(final DialogInterface dialog, final int item) {
             dialog.dismiss();
             if (mRunnable != null) {
               mRunnable.run(possibleRecip[item]);
             }
           }
         });
     builder.create().show();
   }
 }
    @Override
    public View getGroupView(
        int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        view =
            mActivity
                .getLayoutInflater()
                .inflate(android.R.layout.simple_expandable_list_item_1, parent, false);
      }

      ClassicSector sector = (ClassicSector) getGroup(groupPosition);
      String sectorIndexString = Integer.toHexString(sector.getIndex());

      TextView textView = (TextView) view.findViewById(android.R.id.text1);
      if (sector instanceof UnauthorizedClassicSector) {
        textView.setText(
            mActivity.getString(R.string.unauthorized_sector_title_format, sectorIndexString));
      } else if (sector instanceof InvalidClassicSector) {
        textView.setText(
            mActivity.getString(
                R.string.invalid_sector_title_format,
                sectorIndexString,
                ((InvalidClassicSector) sector).getError()));
      } else {
        textView.setText(mActivity.getString(R.string.sector_title_format, sectorIndexString));
      }

      return view;
    }
Esempio n. 13
0
  private void doUpload() {
    statusMessage = activity.getString(R.string.error_sending_to_docs);
    success = false;

    try {

      // Transmit info via GData feed:
      // -------------------------------

      Log.d(LOG_TAG, "Uploading to spreadsheet");
      success = uploadToDocs();
      if (success) {
        statusMessage = activity.getString(R.string.status_have_been_uploaded_to_docs);
      } else {
        statusMessage = activity.getString(R.string.error_sending_to_docs);
      }
      SettingsActivity.getInstance()
          .getAndSetProgressValue(100 - SettingsActivity.getInstance().getProgressValue());
      Log.d(LOG_TAG, "Done.");
    } finally {
      if (onCompletion != null) {
        activity.runOnUiThread(onCompletion);
      }
    }
  }
Esempio n. 14
0
  /**
   * calling this function will share the screenshot of the webView along with the text at the top
   * and a caption text to all social network platforms by calling the system's intent.
   *
   * @param text : heading of the image with the webView's screenshot.
   * @param caption : intent caption
   */
  @JavascriptInterface
  public void share(String text, String caption) {
    FileOutputStream fos = null;
    File cardShareImageFile = null;
    Activity mContext = weakActivity.get();
    if (mContext != null) {
      try {
        if (TextUtils.isEmpty(text)) {
          text = mContext.getString(R.string.cardShareHeading); // fallback
        }

        cardShareImageFile =
            new File(mContext.getExternalCacheDir(), System.currentTimeMillis() + ".jpg");
        fos = new FileOutputStream(cardShareImageFile);
        View share =
            LayoutInflater.from(mContext).inflate(com.bsb.hike.R.layout.web_card_share, null);
        // set card image
        ImageView image = (ImageView) share.findViewById(com.bsb.hike.R.id.image);
        Bitmap b = Utils.viewToBitmap(mWebView);
        image.setImageBitmap(b);

        // set heading here
        TextView heading = (TextView) share.findViewById(R.id.heading);
        heading.setText(text);

        // set description text
        TextView tv = (TextView) share.findViewById(com.bsb.hike.R.id.description);
        tv.setText(Html.fromHtml(mContext.getString(com.bsb.hike.R.string.cardShareDescription)));

        Bitmap shB = Utils.undrawnViewToBitmap(share);
        Logger.i(
            tag,
            " width height of layout to share " + share.getWidth() + " , " + share.getHeight());
        shB.compress(Bitmap.CompressFormat.JPEG, 100, fos);
        fos.flush();
        Logger.i(tag, "share webview card " + cardShareImageFile.getAbsolutePath());
        Utils.startShareImageIntent(
            "image/jpeg",
            "file://" + cardShareImageFile.getAbsolutePath(),
            TextUtils.isEmpty(caption)
                ? mContext.getString(com.bsb.hike.R.string.cardShareCaption)
                : caption);
      } catch (Exception e) {
        e.printStackTrace();
        showToast(mContext.getString(com.bsb.hike.R.string.error_card_sharing));
      } finally {
        if (fos != null) {
          try {
            fos.close();
          } catch (IOException e) {
            // Do nothing
            e.printStackTrace();
          }
        }
      }
      if (cardShareImageFile != null && cardShareImageFile.exists()) {
        cardShareImageFile.deleteOnExit();
      }
    }
  }
 @Override
 protected void onPostExecute(String ayah) {
   Activity activity = getActivity();
   if (ayah != null && activity != null) {
     ayah =
         "("
             + ayah
             + ")"
             + " "
             + "["
             + QuranInfo.getSuraName(activity, this.sura, true)
             + " : "
             + this.ayah
             + "]"
             + activity.getString(R.string.via_string);
     if (copy) {
       ClipboardManager cm =
           (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
       cm.setText(ayah);
       Toast.makeText(
               activity, activity.getString(R.string.ayah_copied_popup), Toast.LENGTH_SHORT)
           .show();
     } else {
       final Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/plain");
       intent.putExtra(Intent.EXTRA_TEXT, ayah);
       startActivity(Intent.createChooser(intent, activity.getString(R.string.share_ayah)));
     }
   }
   mCurrentTask = null;
 }
Esempio n. 16
0
  public PostListAdapter(Activity value) {
    mContext = value;

    post_item = mContext.getString(R.string.post_item);
    // post_author = mContext.getString(R.string.post_author);
    // post_floor = mContext.getString(R.string.post_floor);
    post_content = mContext.getString(R.string.post_content);
    post_datetime = mContext.getString(R.string.post_datetime);
    post_comment = mContext.getString(R.string.post_comment);
    post_subtitle = mContext.getString(R.string.post_subtitle);
    post_comment_author = mContext.getString(R.string.post_comment_author);
    post_comment_content = mContext.getString(R.string.post_comment_content);
    post_user_info1 = mContext.getString(R.string.post_user_info1);
    post_user_info2 = mContext.getString(R.string.post_user_info2);
    post_user_info3 = mContext.getString(R.string.post_user_info3);
    post_user_info4 = mContext.getString(R.string.post_user_info4);

    keyword_url = mContext.getString(R.string.keyword_url);

    pageinfoList = new ArrayList<PageInfo>();
    postInfoList = new ArrayList<PostInfo>();

    tempInfo = new HashMap<String, String>();
    randKey = new Random();

    title = (TextView) mContext.getLayoutInflater().inflate(R.layout.post_list_title, null);
  }
Esempio n. 17
0
  protected void initializeAlertDialog() {
    alertDialog = new AlertDialog.Builder(act);
    alertDialog.setCancelable(false);
    // Setting Dialog Title
    alertDialog.setTitle(act.getString(R.string.conex));

    // Setting Dialog Message
    alertDialog.setMessage(act.getString(R.string.conex_question));
    // Setting Icon to Dialog
    // alertDialog.setIcon(R.drawable.delete);

    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton(
        act.getString(R.string.yes),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            act.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            dialog.cancel();
          }
        });

    // Setting Negative "NO" Button
    alertDialog.setNegativeButton(
        act.getString(R.string.no),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            act.finish();
          }
        });
  }
Esempio n. 18
0
  @Override
  protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);

    if (!activity.isFinishing() && progress_dialog.isShowing()) {
      progress_dialog.dismiss();
    }

    if (passExporter.exception != null) {
      App.component()
          .tracker()
          .trackException("passExporterException", passExporter.exception, false);
      Toast.makeText(activity, "could not export pass " + passExporter.exception, Toast.LENGTH_LONG)
          .show();
      return;
    }

    if (share_after_export) {
      final Intent it = new Intent(Intent.ACTION_SEND);
      it.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.passbook_is_shared_subject));
      it.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + passExporter.fullZipFileName));
      it.setType("application/vnd.apple.pkpass");
      activity.startActivity(
          Intent.createChooser(it, activity.getString(R.string.passbook_share_chooser_title)));
    }
  }
  public ProKeypadHelper(Activity activity) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
    vibrateFeedback = sharedPref.getBoolean(activity.getString(R.string.to_vibrate), false);

    if (sharedPref.getBoolean(activity.getString(R.string.to_sound), false)) {
      audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
    }
  }
Esempio n. 20
0
 /**
  * 显示正在分享进度框
  *
  * @param context
  * @return
  */
 public ProgressDialog showProgressDialog() {
   return ProgressDialog.show(
       activity,
       activity.getString(R.string.wait),
       activity.getString(R.string.sharing),
       true,
       true);
 }
Esempio n. 21
0
  // read from this apps SharedPrefs
  public static String readStringFromSharedPrefs(
      Activity activity, int keyFromRes, int defKeyFromRes) {
    SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
    String defaultValue = activity.getString(defKeyFromRes);
    String value = sharedPref.getString(activity.getString(keyFromRes), defaultValue);

    return value;
  }
Esempio n. 22
0
 public static Builder showAlertBuilder(final Activity activity, int msgId, int titleId) {
   Builder builder =
       new AlertDialog.Builder(activity)
           .setMessage(activity.getString(msgId).toString())
           .setTitle(activity.getString(titleId).toString())
           .setCancelable(false);
   return builder;
 }
    public void show() {
      PackageInfo versionInfo = getPackageInfo();

      // the eulaKey changes every time you increment the version number
      // in the AndroidManifest.xml
      final String eulaKey = EULA_PREFIX + versionInfo.versionCode;
      final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
      boolean hasBeenShown = prefs.getBoolean(eulaKey, false);
      if (!hasBeenShown) {

        // Show the Eula
        String title = mActivity.getString(R.string.app_name) + " v" + versionInfo.versionName;

        // Includes the updates as well so users know what changed.

        String message =
            Html.fromHtml(mActivity.getString(R.string.eula_updates_text))
                + "\n\n"
                + Html.fromHtml(mActivity.getString(R.string.eula_license_text));

        AlertDialog.Builder builder =
            new AlertDialog.Builder(mActivity)
                .setTitle(title)
                .setMessage(message)
                .setPositiveButton(
                    "Agree",
                    new Dialog.OnClickListener() {

                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
                        // Mark this version as read.
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.putBoolean(eulaKey, true);
                        editor.commit();
                        dialogInterface.dismiss();
                        Intent splashIntent = new Intent(mActivity, SplashActivity.class);
                        startActivity(splashIntent);
                        finish();
                      }
                    })
                .setNegativeButton(
                    "Disagree",
                    new Dialog.OnClickListener() {

                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        // Close the activity as they have
                        // declined the EULA
                        mActivity.finish();
                      }
                    });
        builder.create().show();
      } else {
        Intent splashIntent = new Intent(mActivity, SplashActivity.class);
        startActivity(splashIntent);
        finish();
      }
    }
Esempio n. 24
0
  @Override
  public void readFromTask(Task task) {
    this.myTask = task;
    Metadata metadata = ProducteevDataService.getInstance().getTaskMetadata(myTask.getId());
    if (metadata == null) metadata = ProducteevTask.newMetadata();

    // Fill the dashboard-spinner and set the current dashboard
    long dashboardId = ProducteevUtilities.INSTANCE.getDefaultDashboard();
    if (metadata.containsNonNullValue(ProducteevTask.DASHBOARD_ID))
      dashboardId = metadata.getValue(ProducteevTask.DASHBOARD_ID);

    StoreObject[] dashboardsData = ProducteevDataService.getInstance().getDashboards();
    dashboards = new ArrayList<ProducteevDashboard>(dashboardsData.length);
    ProducteevDashboard ownerDashboard = null;
    int dashboardSpinnerIndex = -1;

    int i = 0;
    for (i = 0; i < dashboardsData.length; i++) {
      ProducteevDashboard dashboard = new ProducteevDashboard(dashboardsData[i]);
      dashboards.add(dashboard);
      if (dashboard.getId() == dashboardId) {
        ownerDashboard = dashboard;
        dashboardSpinnerIndex = i;
      }
    }

    // dashboard to not sync as first spinner-entry
    dashboards.add(
        0,
        new ProducteevDashboard(
            ProducteevUtilities.DASHBOARD_NO_SYNC,
            activity.getString(R.string.producteev_no_dashboard),
            null));
    // dummy entry for adding a new dashboard
    dashboards.add(
        new ProducteevDashboard(
            ProducteevUtilities.DASHBOARD_CREATE,
            activity.getString(R.string.producteev_create_dashboard),
            null));

    ArrayAdapter<ProducteevDashboard> dashAdapter =
        new ArrayAdapter<ProducteevDashboard>(
            activity, android.R.layout.simple_spinner_item, dashboards);
    dashAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    dashboardSelector.setAdapter(dashAdapter);
    dashboardSelector.setSelection(dashboardSpinnerIndex + 1);

    if (ownerDashboard == null
        || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_NO_SYNC
        || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_CREATE) {
      responsibleSelector.setEnabled(false);
      responsibleSelector.setAdapter(null);
      view.findViewById(R.id.producteev_TEA_task_assign_label).setVisibility(View.GONE);
      return;
    }

    refreshResponsibleSpinner(ownerDashboard.getUsers());
  }
 public static boolean isLoggedIn(Activity act) {
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(act.getBaseContext());
   String username = prefs.getString(act.getString(R.string.prefs_username), "");
   String apiKey = prefs.getString(act.getString(R.string.prefs_api_key), "");
   if (username.trim().equals("") || apiKey.trim().equals("")) {
     return false;
   } else {
     return true;
   }
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater layoutInflater = context.getLayoutInflater();
      convertView = layoutInflater.inflate(R.layout.list_row_notificacao, null);
    }

    Notificacao notificacao = lista.get(position);

    TextView titulo = (TextView) convertView.findViewById(R.id.titulo);
    TextView mensagem = (TextView) convertView.findViewById(R.id.mensagem);
    ImageView imagem = (ImageView) convertView.findViewById(R.id.imagem);
    TextView duracao = (TextView) convertView.findViewById(R.id.duration);

    titulo.setText(notificacao.getNomeDoUltimoNotificador());
    switch (notificacao.getTipoDeNotificacao()) {
      case 1:
        mensagem.setText(
            notificacao.getNomeDoUltimoNotificador()
                + " "
                + context.getString(R.string.NOTIFICACAO_COMENTARIO));
        break;
      case 2:
        mensagem.setText(
            notificacao.getNomeDoUltimoNotificador()
                + " "
                + context.getString(R.string.NOTIFICACAO_RESPOSTA));
        break;
    }

    Calendar date = Calendar.getInstance();
    Date data = new Date(notificacao.getDataDaUltimaAtualizacao());
    date.setTime(data);
    int hora = date.get(Calendar.HOUR);
    int min = date.get(Calendar.MINUTE);
    duracao.setText(hora + ":" + min);

    if (!notificacao.getNomeDaImagemDoUltimoNotificador().equals("foto_defaul.png")) {
      Picasso.with(getContext())
          .load(
              ConstantesDeCaminhos.CAMINHO_IMAGENS
                  + notificacao.getNomeDaImagemDoUltimoNotificador())
          .error(android.R.drawable.stat_notify_error)
          .into(imagem);
    }
    if (!notificacao.isLido()) {
      ((RelativeLayout) convertView.findViewById(R.id.layoutNotificacao))
          .setBackgroundResource(R.drawable.list_selector_nao_visualizado);
    } else {
      ((RelativeLayout) convertView.findViewById(R.id.layoutNotificacao))
          .setBackgroundResource(R.drawable.list_selector);
    }

    return convertView;
  }
Esempio n. 27
0
 public static void handleSQLiteError(Context context, final SQLiteException e) {
   if (context instanceof Activity) {
     Activity activity = (Activity) context;
     DialogUtilities.okDialog(
         activity,
         activity.getString(R.string.DB_corrupted_title),
         0,
         activity.getString(R.string.DB_corrupted_body));
   }
   e.printStackTrace();
 }
 /**
  * @param exception
  * @return
  */
 private String getRetryMessage(Throwable exception) {
   String retryMsg = context.getString(com.twapime.app.R.string.try_again);
   //
   if (getFailureStringId() != -1) {
     retryMsg = context.getString(getFailureStringId()) + " " + retryMsg;
   } else {
     retryMsg = context.getString(UIUtil.getMessageId(exception)) + " " + retryMsg;
   }
   //
   return retryMsg;
 }
Esempio n. 29
0
 public void sendFeedbackEmail() {
   Intent i = new Intent(Intent.ACTION_SEND);
   i.setType("message/rfc822");
   i.putExtra(Intent.EXTRA_EMAIL, new String[] {FEEDBACK_EMAIL_ADDRESS});
   i.putExtra(Intent.EXTRA_SUBJECT, FEEDBACK_SUBJECT + hostActivity.getString(R.string.app_name));
   i.putExtra(Intent.EXTRA_TEXT, "");
   try {
     hostActivity.startActivity(
         Intent.createChooser(i, hostActivity.getString(R.string.send_mail)));
   } catch (android.content.ActivityNotFoundException ex) {
   }
 }
Esempio n. 30
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // fragment has options menu
    setHasOptionsMenu(true);

    // get activity and application contexts
    mActivity = getActivity();
    mApplication = mActivity.getApplication();

    // get notification message
    mSleepTimerNotificationMessage = mActivity.getString(R.string.snackbar_message_timer_set) + " ";

    // initiate sleep timer service
    mSleepTimerService = new SleepTimerService();

    // set list state null
    mListState = null;

    // initialize id of currently selected station
    mStationIDSelected = 0;

    // initialize temporary station image id
    mTempStationID = -1;

    // initialize two pane
    mTwoPane = false;

    // load playback state
    loadAppState(mActivity);

    // get collection folder
    StorageHelper storageHelper = new StorageHelper(mActivity);
    mFolder = storageHelper.getCollectionDirectory();
    if (mFolder == null) {
      Toast.makeText(
              mActivity,
              mActivity.getString(R.string.toastalert_no_external_storage),
              Toast.LENGTH_LONG)
          .show();
      mActivity.finish();
    }
    mFolderSize = mFolder.listFiles().length;

    // create collection adapter
    if (mCollectionAdapter == null) {
      mCollectionAdapter = new CollectionAdapter(mActivity, mFolder);
    }

    // initialize broadcast receivers
    initializeBroadcastReceivers();
  }