public void setEmailRequired(boolean emailRequired) {
   this.emailRequired = emailRequired;
   final AutoCompleteTextView emailText = (AutoCompleteTextView) findViewById(R.id.email);
   if (emailRequired) {
     emailText.setHint(R.string.apptentive_edittext_hint_email_required);
   } else {
     emailText.setHint(R.string.apptentive_edittext_hint_email);
   }
 }
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.button2) {
      EditStart.setText("");
      EditEnd.setText("");
      displayDate.setText("");
      displayStartTime.setText("");
      displayArrivalTime.setText("");
      eventId = "";
      groupId = "";
      btnSelectEvent.setEnabled(true);
      btnSelectGroup.setEnabled(true);
      EditStart.setHint("");
      EditEnd.setHint("");
      FromCurrentLocation.setChecked(false);
      ToCurrentLocation.setChecked(false);
      FromCurrentLocation.setEnabled(true);
      ToCurrentLocation.setEnabled(true);
    }
    if (v.getId() == R.id.buttonEvent) {
      selectEvent();
    }
    if (v.getId() == R.id.buttonGroup) {
      selectGroup();
    }
    if (v.getId() == R.id.current1 || v.getId() == R.id.current2) {
      getGps();
      checkGps();
      if (isCancelled) {
        System.out.println("isCancelled is cancelled");
        FromCurrentLocation.setChecked(false);
        ToCurrentLocation.setChecked(false);
        ToCurrentLocation.setEnabled(false);
        FromCurrentLocation.setEnabled(false);
      }
      if (!isCancelled) {
        System.out.println("isCancelled is on ");
        reverseAddress(OfferRide.this);
      }
    }

    if (v.getId() == R.id.button1) {
      offerRide(v);
    }
    if (v.getId() == R.id.setDateButton) {
      setDate(v);
    }
    if (v.getId() == R.id.setStartTimeButton) {
      setStartTime(v);
    }
    if (v.getId() == R.id.setEndTimeButton) {
      setArrivalTime(v);
    }
  }
Ejemplo n.º 3
0
  private void setLanguage() {
    // set language to english
    if (MyConstants.LANGUAGE == 1) {
      acTv.setHint(R.string.search_hint_en);
      btnSearch.setText(R.string.search_btn_en);
      tvSearchTitle.setText(R.string.search_title_en);
      tvSearchDesc.setText(R.string.search_description_en);
    }
    // set language to french
    else {
      acTv.setHint(R.string.search_hint_fr);
      btnSearch.setText(R.string.search_btn_fr);
      tvSearchTitle.setText(R.string.search_title_fr);
      tvSearchDesc.setText(R.string.search_description_fr);
    }

    // update list language if list initialized
    if (values != null) {
      setAutoCompleteAdapter();
    }
  }
Ejemplo n.º 4
0
  private void init(final Context context) {
    LayoutInflater mInflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mInflater.inflate(R.layout.jdb_expand_editext_layout, this);
    mProgressBar = (ProgressBar) findViewById(R.id.progress);
    mRightView = (ImageView) findViewById(R.id.icon_right);
    checkStatusOfIcon(mRightView, rightIconVisiable);
    mLeftView = (ImageView) findViewById(R.id.icon_left);
    checkStatusOfIcon(mLeftView, leftIconVisiable);
    mRightView.setOnClickListener(this);
    mTextView = (AutoCompleteTextView) findViewById(R.id.edittext);
    mTextView.setHint(this.hint);
    mTextView.setFocusableInTouchMode(enabled);
    if (this.password)
      mTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mTextView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (withProgress) {
              if (mCanLoad) {
                if (charSequence.length() >= threshold) {
                  if (onEditCompleted != null)
                    onEditCompleted.startSearch(ExpandEditText.this, charSequence.toString());
                } else {
                  if (onEditCompleted != null) onEditCompleted.endSearch(ExpandEditText.this);
                }
              } else {
                mCanLoad = !mCanLoad;
              }
            } else {
              // 有内容显示
              if (charSequence.length() >= 1) mRightView.setVisibility(View.VISIBLE);
              else mRightView.setVisibility(View.GONE);
            }
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
  }
Ejemplo n.º 5
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the help for this fragment
    //        if(view == null)
    Log.d("init", "search fragment onCreateView");
    if (true) view = inflater.inflate(R.layout.fragment_search, container, false);
    if (true) {
      textView = (AutoCompleteTextView) view.findViewById(R.id.autocomplete_search);
      textView.setThreshold(1);

      if (mType == t_type.GROUP) {
        textView.setOnClickListener(this);
        textView.setOnItemClickListener(this);

        textView.setHint(R.string.group_search_placeholder);

        adapter =
            new ArrayAdapter<String>(
                getActivity(), R.layout.text_layout, StaticStorage.m_listGroupsName);
        textView.setAdapter(adapter);
        adapter.setNotifyOnChange(true);

        ListView list = (ListView) view.findViewById(R.id.recentList);
        final ArrayAdapter recent_adapter =
            new ArrayAdapter(
                inflater.getContext(),
                R.layout.detailed_item_list_item,
                new ArrayList(StaticStorage.m_recentGroups.values())) {
              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
                View holder;
                Group group = (Group) getItem(position);
                if (convertView == null) {
                  // You should fetch the LayoutInflater once in your constructor
                  holder =
                      LayoutInflater.from(parent.getContext())
                          .inflate(R.layout.detailed_item_list_item, parent, false);
                } else {
                  holder = convertView;
                }

                TextView v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text1);
                v.setText(group.m_info.m_name);
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text2);
                v.setText(group.m_info.m_faculty.m_abbr);
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text3);
                v.setText(group.m_info.m_spec);
                return holder;
              }
            };
        list.setAdapter(recent_adapter);
        // ListView Item Click Listener
        list.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Group group = (Group) recent_adapter.getItem(position);

                Log.d("init", group.toString());
                if (((NavigationView) getActivity().findViewById(R.id.nav_view))
                    .getMenu()
                    .getItem(0)
                    .isChecked()) {
                  ((MainNavigationDrawer) getActivity()).createTree(group);
                  //                            new CreateFiles(getActivity(), group).execute();
                } else {
                  ((MainNavigationDrawer) getActivity())
                      .switchContent(TimeTableFragment.newInstance(group));
                  StaticStorage.m_recentGroups.put(group.m_info.m_id, group);
                }
              }
            });

        Button btn = (Button) view.findViewById(R.id.primat_list);
        btn.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (!((MainNavigationDrawer) getActivity()).isOnline()) {
                  ((MainNavigationDrawer) getActivity()).askForInternet();
                  return;
                }
                if (StaticStorage.m_primatGroupsName.isEmpty()) {
                  new AlertDialog.Builder(getActivity())
                      .setTitle(getResources().getString(R.string.error))
                      .setMessage(getResources().getString(R.string.not_loaded))
                      .setPositiveButton(android.R.string.ok, null) // dismisses by default
                      .create()
                      .show();
                  return;
                }

                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(getResources().getString(R.string.str_depth));
                builder.setIcon(R.drawable.logo_amd_mod);
                //                        ListView modeList = new ListView(getActivity());
                final ArrayAdapter<String> modeAdapter =
                    new ArrayAdapter<String>(
                        getActivity(),
                        android.R.layout.simple_list_item_1,
                        android.R.id.text1,
                        StaticStorage.m_primatGroupsName);
                builder.setAdapter(
                    modeAdapter,
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        GroupInfo tmpGroup = StaticStorage.m_primatGroups.get(which);
                        new ServerGetTable(tmpGroup, getActivity()).execute();
                      }
                    });
                final Dialog dialog = builder.create();
                dialog.show();
              }
            });
        if (StaticStorage.m_listGroupsName.isEmpty()) {
          if (!((MainNavigationDrawer) getActivity()).isOnline())
            ((MainNavigationDrawer) getActivity()).askForInternet();
          else startDownloadListFaculties((ArrayAdapter<String>) textView.getAdapter());
        }

      } else {
        if (!((MainNavigationDrawer) getActivity()).isOnline())
          ((MainNavigationDrawer) getActivity()).askForInternet();
        textView.setOnItemClickListener(this);
        textView.setHint(R.string.lecturer_search_placeholder);
        adapter =
            new ArrayAdapter<String>(
                getActivity(), R.layout.text_layout, StaticStorage.m_listLecturerName);
        adapter.setNotifyOnChange(true);
        textView.setAdapter(adapter);
        textView.addTextChangedListener(this);

        ListView list = (ListView) view.findViewById(R.id.recentList);
        final ArrayAdapter recent_adapter =
            new ArrayAdapter(
                inflater.getContext(),
                R.layout.detailed_item_list_item,
                new ArrayList(StaticStorage.m_recentLecturers.values())) {
              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
                View holder;
                Lecturer group = (Lecturer) getItem(position);
                if (convertView == null) {
                  // You should fetch the LayoutInflater once in your constructor
                  holder =
                      LayoutInflater.from(parent.getContext())
                          .inflate(R.layout.detailed_item_list_item, parent, false);
                } else {
                  holder = convertView;
                }

                TextView v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text1);
                v.setText(group.m_info.m_fio);
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text2);
                v.setText("");
                v = (TextView) holder.findViewById(R.id.detailed_item_list_item_text3);
                v.setText(group.m_info.m_chair);
                return holder;
              }
            };
        list.setAdapter(recent_adapter);
        // ListView Item Click Listener
        list.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Lecturer lect = (Lecturer) recent_adapter.getItem(position);

                Log.d("init", lect.toString());
                if (((NavigationView) getActivity().findViewById(R.id.nav_view))
                    .getMenu()
                    .getItem(0)
                    .isChecked()) {
                  ((MainNavigationDrawer) getActivity()).createTree(lect);
                  //                            new CreateFiles(getActivity(), lect).execute();
                } else {
                  ((MainNavigationDrawer) getActivity())
                      .switchContent(TimeTableFragment.newInstance(lect));
                  StaticStorage.m_recentLecturers.put(lect.m_info.m_id, lect);
                }
              }
            });
        /*
        Button btn = (Button) view.findViewById(R.id.primat_list);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(getResources().getString(R.string.str_depth));

                ListView modeList = new ListView(getActivity());
                ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(getActivity(),
                        android.R.help.simple_list_item_1, android.R.id.text1,
                        StaticStorage.m_primatLecturerName);
                modeList.setAdapter(modeAdapter);

                builder.setView(modeList);
                final Dialog dialog = builder.create();

                dialog.show();
            }
        });
        */
        Button btn = (Button) view.findViewById(R.id.primat_list);
        btn.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (!((MainNavigationDrawer) getActivity()).isOnline())
                  ((MainNavigationDrawer) getActivity()).askForInternet();
                else new ServerGetPrimatLecturers(getActivity(), true).execute();
              }
            });
      }
    }

    //
    // ((CollapsingToolbarLayout)getActivity().findViewById(R.id.collapsing_toolbar_layout)).setTitle(getResources().getString(R.string.search));
    //
    // ((Toolbar)getActivity().findViewById(R.id.toolbar)).setTitle(getResources().getString(R.string.search));

    if (((NavigationView) getActivity().findViewById(R.id.nav_view))
        .getMenu()
        .getItem(0)
        .isChecked()) {
      if (mType == t_type.GROUP) {
        ((AppCompatActivity) getActivity())
            .getSupportActionBar()
            .setTitle(getResources().getString(R.string.choose_group));
      } else {
        ((AppCompatActivity) getActivity())
            .getSupportActionBar()
            .setTitle(getResources().getString(R.string.choose_lectname));
      }
    } else {
      ((AppCompatActivity) getActivity())
          .getSupportActionBar()
          .setTitle(getResources().getString(R.string.search));
    }

    return view;
  }
Ejemplo n.º 6
0
 /**
  * 设置提示内容
  *
  * @param resid 内容id
  */
 public final void setHint(int resid) {
   if (mTextView != null) mTextView.setHint(context.getResources().getString(resid));
 }
Ejemplo n.º 7
0
 /**
  * 设置提示内容
  *
  * @param hint
  */
 public final void setHint(String hint) {
   if (mTextView != null) mTextView.setHint(hint);
 }
  @Override
  public void show(final Activity activity) {
    super.show(activity);
    activity.setContentView(R.layout.apptentive_feedback_dialog_interaction);

    // Legacy support: We can remove this when we switch over to 100% interaction based Message
    // Center.
    SharedPreferences prefs =
        activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
    prefs
        .edit()
        .putBoolean(Constants.PREF_KEY_MESSAGE_CENTER_SHOULD_SHOW_INTRO_DIALOG, false)
        .commit();

    if (!thankYouDialogVisible) {
      if (!feedbackDialogVisible) {
        EngagementModule.engageInternal(activity, interaction.getType().name(), CODE_POINT_LAUNCH);
      }

      String title = interaction.getTitle();
      final AutoCompleteTextView emailView =
          (AutoCompleteTextView) activity.findViewById(R.id.email);
      EditText messageView = (EditText) activity.findViewById(R.id.message);
      Button noButton = (Button) activity.findViewById(R.id.decline);
      final Button sendButton = (Button) activity.findViewById(R.id.submit);

      // Title
      if (title != null) {
        TextView titleView = (TextView) activity.findViewById(R.id.title);
        titleView.setText(title);
      }

      // Body
      String body = interaction.getBody(activity);
      TextView bodyView = (TextView) activity.findViewById(R.id.body);
      bodyView.setText(body);

      // Email
      String personEnteredEmail = PersonManager.loadPersonEmail(activity);
      if (!interaction.isAskForEmail()) {
        emailView.setVisibility(View.GONE);
      } else if (!Util.isEmpty(personEnteredEmail)) {
        emailView.setVisibility(View.GONE);
        email = personEnteredEmail;
      } else {
        String personInitialEmail = PersonManager.loadInitialPersonEmail(activity);
        if (!Util.isEmpty(personInitialEmail)) {
          emailView.setText(personInitialEmail);
          email = personInitialEmail;
        }

        String emailHintText = interaction.getEmailHintText();
        if (emailHintText != null) {
          emailView.setHint(emailHintText);
        } else if (interaction.isEmailRequired()) {
          emailView.setHint(R.string.apptentive_edittext_hint_email_required);
        }

        // Pre-populate a list of possible emails based on those pulled from the phone.
        ArrayAdapter<String> emailAdapter =
            new ArrayAdapter<String>(
                activity,
                android.R.layout.simple_dropdown_item_1line,
                Util.getAllUserAccountEmailAddresses(activity));
        emailView.setAdapter(emailAdapter);
        emailView.setOnTouchListener(
            new View.OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                emailView.showDropDown();
                return false;
              }
            });
        emailView.addTextChangedListener(
            new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                email = charSequence;
                validateForm(sendButton);
              }

              @Override
              public void afterTextChanged(Editable editable) {}
            });
      }

      // Message
      String messageHintText = interaction.getMessageHintText();
      if (messageHintText != null) {
        messageView.setHint(messageHintText);
      }
      messageView.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
              message = charSequence;
              validateForm(sendButton);
            }

            @Override
            public void afterTextChanged(Editable editable) {}
          });

      // No
      String no = interaction.getDeclineText();
      if (no != null) {
        noButton.setText(no);
      }
      noButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              cleanup();
              EngagementModule.engageInternal(
                  activity, interaction.getType().name(), CODE_POINT_DECLINE);
              activity.finish();
            }
          });

      // Send
      String send = interaction.getSubmitText();
      if (send != null) {
        sendButton.setText(send);
      }
      sendButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              if (email != null && email.length() != 0 && !Util.isEmailValid(email.toString())) {
                EmailValidationFailedDialog dialog = new EmailValidationFailedDialog(activity);
                dialog.show();
                return;
              }

              // Before we send this message, send an auto message.
              createMessageCenterAutoMessage(activity);

              sendMessage(activity);

              EngagementModule.engageInternal(
                  activity, interaction.getType().name(), CODE_POINT_SUBMIT);
              thankYouDialogVisible = true;
              feedbackDialogVisible = false;
              activity.findViewById(R.id.feedback_dialog).setVisibility(View.GONE);
              activity.findViewById(R.id.thank_you_dialog).setVisibility(View.VISIBLE);
            }
          });
    } else {
      activity.findViewById(R.id.feedback_dialog).setVisibility(View.GONE);
      activity.findViewById(R.id.thank_you_dialog).setVisibility(View.VISIBLE);
    }

    // Thank You Title
    TextView thankYouTitleView = (TextView) activity.findViewById(R.id.thank_you_title);
    String thankYouTitle = interaction.getThankYouTitle();
    if (thankYouTitle != null) {
      thankYouTitleView.setText(thankYouTitle);
    }

    // Thank You Body
    TextView thankYouBodyView = (TextView) activity.findViewById(R.id.thank_you_body);
    String thankYouBody = interaction.getThankYouBody();
    if (thankYouBody != null) {
      thankYouBodyView.setText(thankYouBody);
    }

    // Thank You Close Button
    Button thankYouCloseButton = (Button) activity.findViewById(R.id.thank_you_close);
    String thankYouCloseText = interaction.getThankYouCloseText();
    if (thankYouCloseText != null) {
      thankYouCloseButton.setText(thankYouCloseText);
    }
    thankYouCloseButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            cleanup();
            EngagementModule.engageInternal(
                activity, interaction.getType().name(), CODE_POINT_SKIP_VIEW_MESSAGES);
            activity.finish();
          }
        });

    // Thank You View Messages Button
    Button thankYouViewMessagesButton =
        (Button) activity.findViewById(R.id.thank_you_view_messages);
    String thankYouViewMessages = interaction.getThankYouViewMessagesText();
    if (thankYouViewMessages != null) {
      thankYouViewMessagesButton.setText(thankYouViewMessages);
    }
    thankYouViewMessagesButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            cleanup();
            EngagementModule.engageInternal(
                activity, interaction.getType().name(), CODE_POINT_VIEW_MESSAGES);
            activity.finish();
          }
        });
    feedbackDialogVisible = true;
  }
  private void setUpParseLoginAndSignup() {
    parseLogin.setVisibility(View.VISIBLE);

    if (config.isParseLoginEmailAsUsername()) {
      usernameField.setHint(R.string.com_parse_ui_email_input_hint);
      usernameField.setInputType(
          InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    }

    if (config.getParseLoginButtonText() != null) {
      parseLoginButton.setText(config.getParseLoginButtonText());
    }

    parseLoginButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String username = usernameField.getText().toString();
            String password = passwordField.getText().toString();

            if (username.length() == 0) {
              showToast(R.string.com_parse_ui_no_username_toast);
            } else if (password.length() == 0) {
              showToast(R.string.com_parse_ui_no_password_toast);
            } else {
              loadingStart(true);
              ParseUser.logInInBackground(
                  username,
                  password,
                  new LogInCallback() {
                    @Override
                    public void done(ParseUser user, ParseException e) {
                      if (isActivityDestroyed()) {
                        return;
                      }

                      if (user != null) {
                        loadingFinish();
                        loginSuccess();
                      } else {
                        loadingFinish();
                        if (e != null) {
                          debugLog(
                              getString(R.string.com_parse_ui_login_warning_parse_login_failed)
                                  + e.toString());
                          if (e.getCode() == ParseException.OBJECT_NOT_FOUND) {
                            if (config.getParseLoginInvalidCredentialsToastText() != null) {
                              showToast(config.getParseLoginInvalidCredentialsToastText());
                            } else {
                              showToast(
                                  R.string.com_parse_ui_parse_login_invalid_credentials_toast);
                            }
                            passwordField.selectAll();
                            passwordField.requestFocus();
                          } else {
                            showToast(R.string.com_parse_ui_parse_login_failed_unknown_toast);
                          }
                        }
                      }
                    }
                  });
            }
          }
        });

    if (config.getParseSignupButtonText() != null) {
      parseSignupButton.setText(config.getParseSignupButtonText());
    }

    parseSignupButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            String username = usernameField.getText().toString();
            String password = passwordField.getText().toString();

            loginFragmentListener.onSignUpClicked(username, password);
          }
        });

    if (config.getParseLoginHelpText() != null) {
      parseLoginHelpButton.setText(config.getParseLoginHelpText());
    }

    parseLoginHelpButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            loginFragmentListener.onLoginHelpClicked();
          }
        });
  }