Beispiel #1
0
  public void showUpdateDialog() {
    final Dialog dialog = new Dialog(getActivity());
    dialog.setContentView(R.layout.edit_user_info);
    dialog.setCancelable(true);

    updateProfileTV = (TextView) dialog.findViewById(R.id.udpateProfileTV);
    phoneNumberUpd = (TextView) dialog.findViewById(R.id.phoneNumberUpd);
    errorTxtUpt = (TextView) dialog.findViewById(R.id.errorTxtUpt);
    nameUpd = (EditText) dialog.findViewById(R.id.nameUpd);
    eMailUpd = (EditText) dialog.findViewById(R.id.eMailUpd);
    addressETUpd = (EditText) dialog.findViewById(R.id.addressETUpd);
    save = (Button) dialog.findViewById(R.id.saveUpt);

    phoneNumberUpd.setText(databaseHandler.getUser(1).getMsisdn());
    nameUpd.setText(databaseHandler.getUser(1).getName());
    eMailUpd.setText(databaseHandler.getUser(1).getEmail());
    addressETUpd.setText(databaseHandler.getRegister(1).getAddress());
    save.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Hit here to update
            if (carFunctions.isConnectingToInternet()) {
              new UpdateProfile(
                      databaseHandler.getUser(1).getMsisdn(),
                      eMailUpd.getText().toString(),
                      nameUpd.getText().toString(),
                      addressETUpd.getText().toString())
                  .execute();
              // getActivity().finish();
              // Intent intent = new Intent(getActivity(), getActivity()
              // .getClass());
              // intent.putExtra("fragNum", "0");
              // getActivity().startActivity(intent);
            } else {
              Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG)
                  .show();
            }
            dialog.dismiss();
          }
        });

    if (setting.getDuration() == 1) {
      dialog.setTitle(getResources().getString(R.string.update_profile_ar));
      updateProfileTV.setText(getResources().getString(R.string.update_profile_ar));
      save.setText(getResources().getString(R.string.save_ar));
    } else {
      dialog.setTitle(getResources().getString(R.string.update_profile_en));
      updateProfileTV.setText(getResources().getString(R.string.update_profile_en));
    }

    dialog.show();
  }
Beispiel #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    databaseHandler = new DataBaseHandler(getActivity());
    setting = databaseHandler.getSetting();
    carFunctions = new CarFunctions(getActivity());

    View view = inflater.inflate(R.layout.settings, container, false);
    settingsTV = (TextView) view.findViewById(R.id.settingsTV);
    logOut = (Button) view.findViewById(R.id.logOut);
    updateUserInfo = (Button) view.findViewById(R.id.updateInfo);

    if (setting.getDuration() == 1) {
      settingsTV.setText(getResources().getString(R.string.settings_ar));
      updateUserInfo.setText(getResources().getString(R.string.update_user_info_ar));
      logOut.setText(getResources().getString(R.string.log_out_ar));
    } else {
      settingsTV.setText(getResources().getString(R.string.settings_en));
      updateUserInfo.setText(getResources().getString(R.string.update_user_info_en));
      logOut.setText(getResources().getString(R.string.log_out_en));
    }

    logOut.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            showAlertDialog();
          }
        });
    updateUserInfo.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            showUpdateDialog();
          }
        });
    return view;
  }
Beispiel #3
0
  public void showAlertDialog() {
    final TextView input = new TextView(getActivity());
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
    alertDialogBuilder.setTitle("Log Out?");

    if (setting.getDuration() == 1) {
      alertDialogBuilder
          .setCancelable(false)
          .setPositiveButton(
              getResources().getString(R.string.yes_ar),
              new DialogInterface.OnClickListener() {
                @SuppressLint("DefaultLocale")
                public void onClick(DialogInterface dialog, int id) {
                  databaseHandler.deleteAllUsers();
                  databaseHandler.deleteAllCars();
                  Intent i = new Intent(getActivity(), smart.services.start.SignIn.class);
                  startActivity(i);
                  getActivity().overridePendingTransition(R.anim.slide_up, R.anim.slide_down);
                  getActivity().finish();
                }
              })
          .setNegativeButton(
              getResources().getString(R.string.cancel_ar),
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  dialog.cancel();
                }
              });

      // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      input.setText(getResources().getString(R.string.sure_ar));
      input.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
      input.setTextSize(20);
      input.setLayoutParams(lp);
      alertDialog.setView(input);
      alertDialog.show();
    } else {
      alertDialogBuilder
          .setCancelable(false)
          .setPositiveButton(
              "Ok",
              new DialogInterface.OnClickListener() {
                @SuppressLint("DefaultLocale")
                public void onClick(DialogInterface dialog, int id) {
                  databaseHandler.deleteAllUsers();
                  databaseHandler.deleteAllCars();
                  Intent i = new Intent(getActivity(), smart.services.start.SignIn.class);
                  startActivity(i);
                  getActivity().overridePendingTransition(R.anim.slide_up, R.anim.slide_down);
                  getActivity().finish();
                }
              })
          .setNegativeButton(
              "Cancel",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  dialog.cancel();
                }
              });

      // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      input.setText("Are you sure?");
      input.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
      input.setTextSize(20);
      input.setLayoutParams(lp);
      alertDialog.setView(input);
      alertDialog.show();
    }
  }