Esempio n. 1
0
  /**
   * Shows a simple native progress dialog<br>
   * Subclass can override below two methods for custom dialogs- <br>
   * 1. showProgressDialog <br>
   * 2. removeProgressDialog
   *
   * @param bodyText
   */
  public void showProgressDialog(String bodyText) {
    if (isFinishing()) {
      return;
    }
    if (mProgressDialog == null) {
      mProgressDialog = new ProgressDialog(BaseActivity.this);
      mProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
      mProgressDialog.setCancelable(false);
      mProgressDialog.setOnKeyListener(
          new Dialog.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
              if (keyCode == KeyEvent.KEYCODE_CAMERA || keyCode == KeyEvent.KEYCODE_SEARCH) {
                return true; //
              }
              return false;
            }
          });
    }

    mProgressDialog.setMessage(bodyText);
    if (!mProgressDialog.isShowing()) {
      mProgressDialog.show();
    }
  }
Esempio n. 2
0
  @Override
  protected Dialog onCreateDialog(int id, Bundle args) {
    final ProgressDialog dialog = new ProgressDialog(this.getParent());
    dialog.setTitle("Please Wait...");
    dialog.setIndeterminate(true);
    dialog.setMessage(String.valueOf(strProgressMessage));
    dialog.setCancelable(true);
    dialog.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          public void onCancel(DialogInterface dialog) {
            Log.i("LOCATOR", "user cancelling authentication");
          }
        });

    dialog.setOnKeyListener(
        new DialogInterface.OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            if (((keyCode == KeyEvent.KEYCODE_SEARCH) || (keyCode == KeyEvent.KEYCODE_MENU))) {
              return true;
            }
            return false;
          }
        });
    mProgressDialog = dialog;
    return dialog;
  }
  public void showContectionProgressDialog() {
    if (progressDialog != null) {
      progressDialog.show();
      progressDialog.setTitle(R.string.articles_pd_title);
      progressDialog.setMessage(this.getString(R.string.articles_pd_msg1));
    } else {
      progressDialog =
          ProgressDialog.show(
              this, getString(R.string.articles_pd_title), getString(R.string.articles_pd_msg1));

      progressDialog.setOnKeyListener(
          new OnKeyListener() {

            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
              if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
                dialog.cancel();
                if (gsdt != null) {
                  gsdt.cancel(false);
                  gsdt = null;
                }
              }
              return true;
            }
          });
    }
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    CharSequence title = getArguments().getCharSequence("title");
    CharSequence message = getArguments().getCharSequence("message");
    String progressNumberFormat = getArguments().getString("number-format");
    NumberFormat progressPercentFormat =
        (NumberFormat) getArguments().getSerializable("percent-format");
    boolean spinner = getArguments().getBoolean("spinner", true);

    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setOnKeyListener(
        new DialogInterface.OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return keyCode == KeyEvent.KEYCODE_SEARCH;
          }
        });
    dialog.setProgressStyle(
        spinner ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL);
    if (progressNumberFormat != null) {
      dialog.setProgressNumberFormat(progressNumberFormat);
    }
    if (progressPercentFormat != null) {
      dialog.setProgressPercentFormat(progressPercentFormat);
    }
    if (message != null) {
      dialog.setMessage(message);
    }
    if (title != null) {
      dialog.setTitle(title);
    }
    return dialog;
  }
Esempio n. 5
0
  private void initView() {
    mGetValidcodeDlg = new ProgressDialog(FindPassWord.this);
    mGetValidcodeDlg.setCanceledOnTouchOutside(false);
    mGetValidcodeDlg.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
              mGetValidCode.setEnabled(true);
              mGetValidCode.setText(R.string.validecode_get);
              count_get_identify_code = COUNT_GET_INDENTIFY_CODE;
              isInterrupt = true;
              mStrValidcode = "";
              mGetValidcode_handler.removeMessages(CHANGE_BUTTON_SEND_MESSAGE);
            }
            return false;
          }
        });
    mEditText_userId = (EditText) findViewById(R.id.user_name);
    mGetValidCode = (Button) findViewById(R.id.next_valide_code);
    mGetValidCode.setOnClickListener(FindPassWord.this);

    ll_register_phone_number = (LinearLayout) findViewById(R.id.ll_register_phone_number);
    mInput_validecode_LinearLayout = (LinearLayout) findViewById(R.id.ll_input_valide);
    ll_register_phone_number.setVisibility(View.VISIBLE);
    mInput_validecode_LinearLayout.setVisibility(View.INVISIBLE);

    mBtn_Next = (Button) findViewById(R.id.btn_valid);
    mBtn_Next.setOnClickListener(FindPassWord.this);

    mEditValidcode = (EditText) findViewById(R.id.et_input_validcode);

    mResource = getResources();

    mEditText_userId.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            Log.d("", "daitm---onTextChanged");
            if (!mGetValidCode.isEnabled()) {
              mGetValidCode.setEnabled(true);
              mGetValidCode.setText(R.string.validecode_get);
              count_get_identify_code = COUNT_GET_INDENTIFY_CODE;
              isInterrupt = true;
            }
          }

          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          @Override
          public void afterTextChanged(Editable arg0) {}
        });
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    mDialog = new ProgressDialog(getActivity());
    if (mBody != null && mBody.length() > 0) {
      mDialog.setMessage(mBody);
    }

    mDialog.setCancelable(false);

    mDialog.setProgressStyle(mStyle);
    if (mStyle != ProgressDialog.STYLE_SPINNER) {
      mDialog.setMax(mProgressMax);
      mDialog.setIndeterminate(false);
      mDialog.setButton(
          DialogInterface.BUTTON_NEGATIVE,
          getString(android.R.string.cancel),
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              if (mListener != null) {
                mListener.onNegativeButtonSelected(getTag());
              }
              dialog.dismiss();
            }
          });
    } else {
      mDialog.setIndeterminate(true);
    }
    mDialog.setProgress(50);
    // Disable the back button
    OnKeyListener keyListener =
        new OnKeyListener() {

          @Override
          public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK) {
              return true;
            }
            return false;
          }
        };
    mDialog.setOnKeyListener(keyListener);
    return mDialog;
  }
 public void showProgress(String msg) {
   if (mProgressDialog == null) {
     mProgressDialog = new ProgressDialog(this);
     mProgressDialog.setMessage(msg);
     mProgressDialog.setIndeterminate(true);
     mProgressDialog.setCancelable(false);
     mProgressDialog.setOnKeyListener(
         new OnKeyListener() {
           @Override
           public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
             mFileSDCardHelper.cancelFindFiles();
             return false;
           }
         });
     mProgressDialog.show();
   }
 }
Esempio n. 8
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    int messageId = getArguments().getInt(ARGS_MESSAGE_ID);
    android.app.ProgressDialog dialog = new android.app.ProgressDialog(getActivity());
    dialog.setMessage(getString(messageId));
    dialog.setIndeterminate(true);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(false);

    DialogInterface.OnKeyListener keyListener =
        new DialogInterface.OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return keyCode == KeyEvent.KEYCODE_BACK;
          }
        };
    dialog.setOnKeyListener(keyListener);

    return dialog;
  }
Esempio n. 9
0
  private void showProgressDialog() {
    progressDialog =
        ProgressDialog.show(
            context,
            context.getResources().getString(R.string.dataLoadingTitle),
            context.getResources().getString(R.string.dataLoadingMsg),
            true);
    progressDialog.setOnKeyListener(
        new DialogInterface.OnKeyListener() {

          @Override
          public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
              dialog.cancel();
              return true;
            }
            return false;
          }
        });
  }
Esempio n. 10
0
  private void startProcessDialog() {
    if (myActivity != null && !myActivity.isFinishing()) {
      mProgress = new ProgressDialog(myActivity);
      mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      mProgress.setIndeterminate(false);
      mProgress.setMessage(myActivity.getResources().getString(R.string.DownloadProcessing));
      mProgress.setCancelable(false);

      mProgress.setOnKeyListener(
          new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
              // TODO Auto-generated method stub
              if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
                jumpToCancel();
                return false;
              }
              return true;
            }
          });
    }
  }
  protected void onCreate(Bundle savedInstanceState) {

    setLayout(R.layout.activity_rfdroid);
    super.onCreate(savedInstanceState);

    registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());

    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);

    deviceFoundDialog =
        ProgressDialog.show(
            RFdroidActivity.this,
            "",
            getResources().getString(R.string.toast_looking_for_rfdroid),
            true);
    deviceFoundDialog.setCancelable(false);
    deviceFoundDialog.setOnKeyListener(
        new DialogInterface.OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
              dialog.dismiss();
              onBackPressed();
              return true;
            }
            return false;
          }
        });

    final ScrollView view = (ScrollView) findViewById(R.id.scrollview);
    view.getViewTreeObserver()
        .addOnScrollChangedListener(
            new ViewTreeObserver.OnScrollChangedListener() {
              @Override
              public void onScrollChanged() {
                if (!openingDrawer) {
                  if (view.getScrollX() == 0 && view.getScrollY() == 0) {
                    discreteSeekBar.showFloater(250);
                  } else {
                    discreteSeekBar.hideFloater(1);
                  }
                }
              }
            });

    sharedpreferences = getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE);
    int dataChartTypeVal =
        sharedpreferences.getInt("dataChartType", DataChartType.RECEPTION_RATE.ordinal());

    if (dataChartTypeVal == DataChartType.PACKET_NUMBER.ordinal()) {
      dataChartType = DataChartType.PACKET_NUMBER;
    }

    tablelayout = (TableLayout) findViewById(R.id.tablelayout);

    altTableRow(2);

    mChart = (BarChart) findViewById(R.id.chart1);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);

    mChart.setDescription("");

    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    mChart.setMaxVisibleValueCount(60);

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    mChart.setDrawGridBackground(false);
    mChart.setDescriptionColor(Color.parseColor("#000000"));

    XAxis xAxis = mChart.getXAxis();
    xAxis.setDrawGridLines(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setSpaceBetweenLabels(0);

    YAxisValueFormatter custom = new DataAxisFormatter("%");

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setValueFormatter(custom);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setValueFormatter(custom);
    rightAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);

    leftAxis.setDrawGridLines(true);
    rightAxis.setDrawGridLines(false);

    mChart.animateY(1000);

    mChart.getLegend().setEnabled(true);

    mChart.setVisibility(View.GONE);

    discreteSeekBar = (DiscreteSeekBar) findViewById(R.id.discrete1);
    discreteSeekBar.keepShowingPopup(true);

    discreteSeekBar.setNumericTransformer(
        new DiscreteSeekBar.NumericTransformer() {
          @Override
          public int transform(int value) {
            return value * 5;
          }
        });

    discreteSeekBar.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              discreteSeekBar.showFloater(250);
            }
          }
        });

    discreteSeekBar.setOnProgressChangeListener(
        new DiscreteSeekBar.OnProgressChangeListener() {

          @Override
          public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {}

          @Override
          public void onStartTrackingTouch(DiscreteSeekBar seekBar) {}

          @Override
          public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
            setAdvertisingInteval();
          }
        });

    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {

      discreteSeekBar.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              setAdvertisingInteval();
            }
          });
    }

    intervalTv = (TextView) findViewById(R.id.interval_head);
    globalReceptionRateTv = (TextView) findViewById(R.id.global_reception_rate);
    lastPacketReceivedTv = (TextView) findViewById(R.id.last_packet_received_value);
    samplingTimeTv = (TextView) findViewById(R.id.sampling_time_value);
    totalPacketReceiveTv = (TextView) findViewById(R.id.total_packet_received_value);
    averagePacketReceivedTv = (TextView) findViewById(R.id.average_packet_received_value);

    initTv();

    if (mBluetoothAdapter.isEnabled()) {
      Intent intent = new Intent(this, BtAnalyzerService.class);
      mBound = bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
    }
  }
  @Override
  protected Dialog onCreateDialog(int id, Bundle bundle) {
    Xlog.i(TAG, "onCreateDialog id, dialog id = " + id);
    Dialog dialog = null;
    switch (id) {
      case DIALOG_INSTALLWARNING: // warning user before install
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.install_sd_title)
                .setMessage(getString(R.string.install_sd_message))
                .setPositiveButton(
                    R.string.btn_install,
                    new DialogInterface.OnClickListener() {

                      public void onClick(DialogInterface dialog, int whichButton) {
                        invalidateOptionsMenu();
                        mDownloadInfo.setActivityID(mActivityOrder);
                        mDownloadInfo.setTargetVer(mVersion);
                        mDownloadInfo.setUpgradeStartedState(true);
                        installPackage(DES_PACKAGE, mVersion);
                      }
                    })
                .setNegativeButton(
                    android.R.string.no,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        Xlog.v(TAG, "Dialog_Install_warning, cancel,finish activity");
                        if (!mDownloadInfo.getIfNeedRefreshMenu()) {

                          if (mDownloadInfo.getActivityID() < 0) {
                            mGoToMainEntry = true;
                            SdPkgInstallActivity.this.startActivity(
                                new Intent(SdPkgInstallActivity.this, MainEntry.class));
                          }
                        }
                        SdPkgInstallActivity.this.finish();
                      }
                    })
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_NOSDCARD: // error occur before unzip update.zip to correct SD card
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.error_sdcard)
                .setMessage(getString(R.string.sdcard_crash_or_unmount))
                .setOnCancelListener(this)
                .setPositiveButton(android.R.string.ok, this)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_NOENOUGHSPACE: // error occur before unzip update.zip to correct SD card
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.insufficient_space_title)
                .setMessage(getString(R.string.install_sd_info))
                .setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                      @Override
                      public void onCancel(DialogInterface dialog) {
                        mDownloadInfo.setUpgradeStartedState(false);
                      }
                    })
                .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {

                        SdPkgInstallActivity.this.finish();
                        Xlog.v(TAG, "Dialog_No_enough_space, OK,finish activity");
                      }
                    })
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_INVALIDATEPACKAGE:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(getString(R.string.package_error_title))
                .setMessage(getString(R.string.package_error_message_invalid))
                .setOnCancelListener(this)
                .setPositiveButton(android.R.string.yes, this)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_UNZIPPING:
        mUnzipProgressDialog = new ProgressDialog(this);
        mUnzipProgressDialog.setIndeterminate(true);
        mUnzipProgressDialog.setCancelable(false);
        mUnzipProgressDialog.setProgressStyle(android.R.attr.progressBarStyleSmall);
        mUnzipProgressDialog.setMessage(getString(R.string.installing_message));
        mUnzipProgressDialog.show();
        sIsUnzip = true;
        mUnzipProgressDialog.setOnKeyListener(
            new DialogInterface.OnKeyListener() {
              public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                  SdPkgInstallActivity.this.finish();
                  Xlog.v(TAG, "DIALOG_UNZIPPING,Keycode_back,finish activity");
                  return true;
                }
                return false;
              }
            });
        mUnzipProgressDialog.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              public void onDismiss(DialogInterface dialog) {
                mUnzipProgressDialog = null;
              }
            });
        return mUnzipProgressDialog;
      case DIALOG_UNKNOWN_ERROR:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.unknown_error)
                .setMessage(getString(R.string.unknown_error_content))
                .setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                      @Override
                      public void onCancel(DialogInterface dialog) {
                        mDownloadInfo.setUpgradeStartedState(false);
                      }
                    })
                .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        Xlog.v(TAG, "Dialog_Unknown_error, ok,finish activity");
                        Util.deleteFile(mUpdatePath);
                        SdPkgInstallActivity.this.finish();
                      }
                    })
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_OTARESULT:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(mOTADialogTitleResId)
                .setMessage(getString(mOTADialogMessageResId))
                .setOnCancelListener(this)
                .setPositiveButton(android.R.string.ok, this)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_SDCARDMOUNTED:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(getString(R.string.error_sdcard))
                .setMessage(getString(R.string.sdcard_inserted))
                .setPositiveButton(
                    android.R.string.yes,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {

                        mGoToMainEntry = true;
                        requeryPackages();
                      }
                    })
                .setNegativeButton(android.R.string.no, null)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_LOW_BATTERY:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(getString(R.string.low_battery))
                .setMessage(getString(R.string.low_battery_warning))
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        SdPkgInstallActivity.this.finish();
                      }
                    })
                .create();
        break;
      default:
        break;
    }
    return dialog;
  }