/* When Sign Up button is clicked register user in database and go to LoginActivity */
  public void signUpButton(View view) {
    // Get data
    EditText editUsername = (EditText) findViewById(R.id.registerUsername);
    EditText editPassword = (EditText) findViewById(R.id.registerPassword);
    // Convert data to strings
    final String stringUsername = editUsername.getText().toString();
    final String stringPassword = editPassword.getText().toString();

    // If fields empty do not continue, set red to alert user
    if (stringUsername.isEmpty() || stringPassword.isEmpty()) {
      editUsername.setHintTextColor(Color.RED);
      editPassword.setHintTextColor(Color.RED);
      return;
    }

    // Async work on the player
    final PlayerController player = new PlayerController();
    new AsyncTask<Void, Void, JsonObject>() {
      @Override
      protected JsonObject doInBackground(Void... params) {
        return player.getByUsername(stringUsername);
      }

      @Override
      protected void onPostExecute(JsonObject user) {
        if (user != null) {
          showSignupFailure();
        } else {
          completeRegistration(stringUsername, stringPassword);
        }
      }
    }.execute();
  }
  /**
   * Check if is form is valid.
   *
   * @return true if form is valid, else false.
   */
  private boolean isFormValid() {
    List<String> errors = new ArrayList<>();

    if (StringUtils.isNotBlank(etTitle.getText())) {
      etTitle.setHintTextColor(color(android.R.color.white));
    } else {
      etTitle.setHintTextColor(color(android.R.color.holo_red_light));
      errors.add(getString(R.string.invalid_form_event));
    }

    if (this.isDateValid()) {
      ViewHelper.setTextViewColor(
          color(android.R.color.white),
          btDatePickerStart,
          btDatePickerEnd,
          btTimePickerStart,
          btTimePickerEnd);
    } else {
      ViewHelper.setTextViewColor(
          color(android.R.color.holo_red_light),
          btDatePickerStart,
          btDatePickerEnd,
          btTimePickerStart,
          btTimePickerEnd);
      errors.add(getString(R.string.invalid_form_date));
    }

    boolean isValid = errors.isEmpty();
    if (!isValid) {
      Toast.makeText(this, StringUtils.join(errors, "\n"), Toast.LENGTH_SHORT).show();
    }
    return isValid;
  }
예제 #3
0
  @AfterViews
  void afterViews() {
    mPhoneNoEdit.setHintTextColor(Color.WHITE);
    mPasswordEdit.setHintTextColor(Color.WHITE);

    mPhoneNoEdit.setText(UserAccountManager.restoreUserNo(this));
    mPasswordEdit.setText(UserAccountManager.restoreUserPwd(this));
    initRememberPwdToggleBtnStatus();

    if (mIsLoginExpire) {
      showExpireDialog();
    }
  }
예제 #4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_name_garage);
   overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
   EditText edtx = (EditText) (findViewById(R.id.garagename));
   edtx.setHintTextColor(getResources().getColor(R.color.white));
 }
예제 #5
0
 @Override
 public void onClick(View arg0) {
   otherSearchEditTextRemover();
   linkToRadioButton.setChecked(true);
   otherSearchEditTextInflater(linkToTableRow);
   otherSearchEditText.setHint("www.example.com");
   otherSearchEditText.setHintTextColor(Color.BLACK);
 }
예제 #6
0
  // controlla l'input del dialog
  private boolean validateRetrieveFields() {
    boolean isValid = true;
    String email = retrieveEditText.getText().toString();
    if (email.length() == 0 || !Utils.checkEmail(email)) {
      retrieveEditText.setHintTextColor(Color.RED);
      retrieveEditText.setTextColor(Color.RED);
      isValid = false;
    }

    return isValid;
  }
예제 #7
0
 public void setTheme(int theme) {
   if (theme == THEME_LIGHT) {
     if (mStyle == STYLE_CLASSIC) {
       mBackImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
       mVoiceImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
       mEmptyImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_light_icon));
     }
     mSeparatorView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_separator));
     mSuggestionsRecyclerView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mCardView.setCardBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mSearchEditText.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_light_background));
     mSearchEditText.setTextColor(ContextCompat.getColor(mContext, R.color.search_light_text));
     mSearchEditText.setHintTextColor(
         ContextCompat.getColor(mContext, R.color.search_light_text_hint));
   }
   if (theme == THEME_DARK) {
     if (mStyle == STYLE_CLASSIC) {
       mBackImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
       mVoiceImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
       mEmptyImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.search_dark_icon));
     }
     mSeparatorView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_separator));
     mSuggestionsRecyclerView.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mCardView.setCardBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mSearchEditText.setBackgroundColor(
         ContextCompat.getColor(mContext, R.color.search_dark_background));
     mSearchEditText.setTextColor(ContextCompat.getColor(mContext, R.color.search_dark_text));
     mSearchEditText.setHintTextColor(
         ContextCompat.getColor(mContext, R.color.search_dark_text_hint));
   }
 }
  private void layout_Add_Rows_Bolt_Torque_Function() {
    // TODO Auto-generated method stub
    int rows = 240;
    int count = rows;
    if (count >= 1) {
      for (int i = 1; i <= count; i++) {

        LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
        view_Bolt_Torque = inflater.inflate(R.layout.simplerow_bolt_torque, null);

        String number = null;
        number = String.valueOf(i);

        EditText et_item = (EditText) view_Bolt_Torque.findViewById(R.id.et_item);
        if (number != null) et_item.setText(number);
        et_item.setHintTextColor(getResources().getColor(R.color.hint_text_color));

        EditText et_initial_torque =
            (EditText) view_Bolt_Torque.findViewById(R.id.et_initial_torque);
        et_initial_torque.setHintTextColor(getResources().getColor(R.color.hint_text_color));

        EditText et_nut_angle = (EditText) view_Bolt_Torque.findViewById(R.id.et_nut_angle);
        et_nut_angle.setHintTextColor(getResources().getColor(R.color.hint_text_color));

        EditText et_final_torque = (EditText) view_Bolt_Torque.findViewById(R.id.et_final_torque);
        et_final_torque.setHintTextColor(getResources().getColor(R.color.hint_text_color));

        ll_Addrows_Bolt_Torque.addView(view_Bolt_Torque);

        if (i == rows) {
          ll_Addrows_Bolt_Torque.removeView(view_Bolt_Torque);
          ll_Addrows_Bolt_Torque.addView(view_Bolt_Torque);
        }
      }
    }
  }
  public void login(View view) {
    EditText usernameView = (EditText) findViewById(R.id.login_username);
    EditText passwordView = (EditText) findViewById(R.id.login_password);
    String username = usernameView.getText().toString();
    String password = passwordView.getText().toString();

    // Make sure text boxes are not blank
    boolean isEmpty = false;
    if (username.trim().isEmpty()) {
      usernameView.setText("");
      usernameView.setHintTextColor(Color.RED);
      isEmpty = true;
    }

    if (password.trim().isEmpty()) {
      passwordView.setText("");
      passwordView.setHintTextColor(Color.RED);
      isEmpty = true;
    }

    if (isEmpty) {
      return;
    }

    Map<String, String> params = new HashMap<>();
    params.put("username", username);
    params.put("password", password);

    CookieRequest loginRequest =
        new CookieRequest(
            Request.Method.POST,
            "http://www.morteam.com",
            "/login",
            params,
            preferences,
            new Response.Listener<String>() {
              @Override
              public void onResponse(String response) {
                try {
                  JSONObject userObject = new JSONObject(response);

                  // Put user data in local storage and intent
                  Intent intent = new Intent();
                  SharedPreferences.Editor editor = preferences.edit();
                  for (String data : userData) {
                    editor.putString(data, userObject.getString(data));
                    intent.putExtra(data, userObject.getString(data));
                  }
                  editor.apply();

                  if (userObject.getJSONArray("teams").length() != 0) {
                    preferences.edit().putBoolean("isOnTeam", true).apply();

                    intent.setClass(LoginActivity.this, MainActivity.class);
                  } else {
                    preferences.edit().putBoolean("isOnTeam", false).apply();

                    intent.setClass(LoginActivity.this, JoinTeamActivity.class);
                  }

                  startActivity(intent);
                  finish();
                } catch (JSONException e) {
                  e.printStackTrace();
                  AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                  builder.setTitle("Login Error");
                  builder.setMessage("You entered an incorrect username or password.");
                  builder.setPositiveButton("Okay", null);
                  builder.create().show();
                }
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
              }
            });
    queue.add(loginRequest);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getSupportActionBar().setDisplayShowHomeEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setDisplayShowCustomEnabled(false);
    getSupportActionBar().setTitle(R.string.add_contact_title);

    helper = new KeyboardHelper(this);

    setContentView(R.layout.activity_add);
    findViewById(R.id.container)
        .setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());

    searchQuery = (EditText) findViewById(R.id.searchField);
    searchQuery.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    searchQuery.setHintTextColor(ActorSDK.sharedActor().style.getTextHintColor());
    findViewById(R.id.dividerTop)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    findViewById(R.id.dividerBot)
        .setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());

    ((TextView) findViewById(R.id.cancel))
        .setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    findViewById(R.id.cancel)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                finish();
              }
            });
    ((TextView) findViewById(R.id.ok))
        .setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    findViewById(R.id.ok)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                final String query = searchQuery.getText().toString();
                if (query.length() == 0) {
                  return;
                }
                execute(
                    messenger().findUsers(query),
                    R.string.progress_common,
                    new CommandCallback<UserVM[]>() {
                      @Override
                      public void onResult(final UserVM[] res) {
                        if (res.length == 0) {
                          new AlertDialog.Builder(AddContactActivity.this)
                              .setMessage(
                                  getString(R.string.alert_invite_text).replace("{0}", query))
                              .setPositiveButton(
                                  R.string.alert_invite_yes,
                                  new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {
                                      String inviteMessage = getString(R.string.invite_message);
                                      Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                                      sendIntent.setData(Uri.parse("sms:" + query));
                                      sendIntent.putExtra("sms_body", inviteMessage);
                                      startActivity(sendIntent);
                                      finish();
                                    }
                                  })
                              .setNegativeButton(R.string.dialog_cancel, null)
                              .show()
                              .setCanceledOnTouchOutside(true);
                        } else {
                          execute(
                              messenger().addContact(res[0].getId()),
                              R.string.progress_common,
                              new CommandCallback<Boolean>() {
                                @Override
                                public void onResult(Boolean res2) {
                                  startActivity(
                                      Intents.openPrivateDialog(
                                          res[0].getId(), true, AddContactActivity.this));
                                  finish();
                                }

                                @Override
                                public void onError(Exception e) {
                                  startActivity(
                                      Intents.openPrivateDialog(
                                          res[0].getId(), true, AddContactActivity.this));
                                  finish();
                                }
                              });
                        }
                      }

                      @Override
                      public void onError(Exception e) {
                        // Never happens
                      }
                    });
              }
            });
  }
예제 #11
0
 // 设置hint的颜色
 public void setHintTextColor(int color) {
   mEdt.setHintTextColor(color);
 }
예제 #12
0
 @Override
 public void setContentHintColor(int color) {
   mEtItemContent.setHintTextColor(color);
 }
 public void setHintTextColor(int color) {
   mSearchSrcTextView.setHintTextColor(color);
 }
예제 #14
0
  @Override
  public View createView(LayoutInflater inflater) {
    if (fragmentView == null) {
      searching = false;
      searchWas = false;

      actionBar.setBackButtonImage(R.drawable.ic_ab_back);
      actionBar.setAllowOverlayTitle(true);
      if (isAlwaysShare) {
        actionBar.setTitle(
            LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
      } else if (isNeverShare) {
        actionBar.setTitle(
            LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
      } else {
        actionBar.setTitle(
            isBroadcast
                ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)
                : LocaleController.getString("NewGroup", R.string.NewGroup));
        actionBar.setSubtitle(
            LocaleController.formatString(
                "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
      }

      actionBar.setActionBarMenuOnItemClick(
          new ActionBar.ActionBarMenuOnItemClick() {
            @Override
            public void onItemClick(int id) {
              if (id == -1) {
                finishFragment();
              } else if (id == done_button) {
                if (selectedContacts.isEmpty()) {
                  return;
                }
                ArrayList<Integer> result = new ArrayList<>();
                result.addAll(selectedContacts.keySet());
                if (isAlwaysShare || isNeverShare) {
                  if (delegate != null) {
                    delegate.didSelectUsers(result);
                  }
                  finishFragment();
                } else {
                  Bundle args = new Bundle();
                  args.putIntegerArrayList("result", result);
                  args.putBoolean("broadcast", isBroadcast);
                  presentFragment(new GroupCreateFinalActivity(args));
                }
              }
            }
          });
      ActionBarMenu menu = actionBar.createMenu();
      menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

      searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
      searchListViewAdapter.setCheckedMap(selectedContacts);
      searchListViewAdapter.setUseUserCell(true);
      listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
      listViewAdapter.setCheckedMap(selectedContacts);

      fragmentView = new LinearLayout(getParentActivity());
      LinearLayout linearLayout = (LinearLayout) fragmentView;
      linearLayout.setOrientation(LinearLayout.VERTICAL);

      FrameLayout frameLayout = new FrameLayout(getParentActivity());
      linearLayout.addView(frameLayout);
      LinearLayout.LayoutParams layoutParams =
          (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
      layoutParams.gravity = Gravity.TOP;
      frameLayout.setLayoutParams(layoutParams);

      userSelectEditText = new EditText(getParentActivity());
      userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      userSelectEditText.setHintTextColor(0xff979797);
      userSelectEditText.setTextColor(0xff212121);
      userSelectEditText.setInputType(
          InputType.TYPE_TEXT_VARIATION_FILTER
              | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
              | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
      userSelectEditText.setMinimumHeight(AndroidUtilities.dp(54));
      userSelectEditText.setSingleLine(false);
      userSelectEditText.setLines(2);
      userSelectEditText.setMaxLines(2);
      userSelectEditText.setVerticalScrollBarEnabled(true);
      userSelectEditText.setHorizontalScrollBarEnabled(false);
      userSelectEditText.setPadding(0, 0, 0, 0);
      userSelectEditText.setImeOptions(
          EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
      userSelectEditText.setGravity(
          (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
      AndroidUtilities.clearCursorDrawable(userSelectEditText);
      frameLayout.addView(userSelectEditText);
      FrameLayout.LayoutParams layoutParams1 =
          (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams();
      layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
      layoutParams1.leftMargin = AndroidUtilities.dp(10);
      layoutParams1.rightMargin = AndroidUtilities.dp(10);
      layoutParams1.gravity = Gravity.TOP;
      userSelectEditText.setLayoutParams(layoutParams1);

      if (isAlwaysShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "AlwaysShareWithPlaceholder", R.string.AlwaysShareWithPlaceholder));
      } else if (isNeverShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "NeverShareWithPlaceholder", R.string.NeverShareWithPlaceholder));
      } else {
        userSelectEditText.setHint(
            LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
      }
      if (Build.VERSION.SDK_INT >= 11) {
        userSelectEditText.setTextIsSelectable(false);
      }
      userSelectEditText.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(
                CharSequence charSequence, int start, int count, int after) {
              if (!ignoreChange) {
                beforeChangeIndex = userSelectEditText.getSelectionStart();
                changeString = new SpannableString(charSequence);
              }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (!ignoreChange) {
                boolean search = false;
                int afterChangeIndex = userSelectEditText.getSelectionEnd();
                if (editable.toString().length() < changeString.toString().length()) {
                  String deletedString = "";
                  try {
                    deletedString =
                        changeString.toString().substring(afterChangeIndex, beforeChangeIndex);
                  } catch (Exception e) {
                    FileLog.e("tmessages", e);
                  }
                  if (deletedString.length() > 0) {
                    if (searching && searchWas) {
                      search = true;
                    }
                    Spannable span = userSelectEditText.getText();
                    for (int a = 0; a < allSpans.size(); a++) {
                      XImageSpan sp = allSpans.get(a);
                      if (span.getSpanStart(sp) == -1) {
                        allSpans.remove(sp);
                        selectedContacts.remove(sp.uid);
                      }
                    }
                    if (!isAlwaysShare && !isNeverShare) {
                      actionBar.setSubtitle(
                          LocaleController.formatString(
                              "MembersCount",
                              R.string.MembersCount,
                              selectedContacts.size(),
                              maxCount));
                    }
                    listView.invalidateViews();
                  } else {
                    search = true;
                  }
                } else {
                  search = true;
                }
                if (search) {
                  String text = userSelectEditText.getText().toString().replace("<", "");
                  if (text.length() != 0) {
                    searching = true;
                    searchWas = true;
                    if (listView != null) {
                      listView.setAdapter(searchListViewAdapter);
                      searchListViewAdapter.notifyDataSetChanged();
                      if (android.os.Build.VERSION.SDK_INT >= 11) {
                        listView.setFastScrollAlwaysVisible(false);
                      }
                      listView.setFastScrollEnabled(false);
                      listView.setVerticalScrollBarEnabled(true);
                    }
                    if (emptyTextView != null) {
                      emptyTextView.setText(
                          LocaleController.getString("NoResult", R.string.NoResult));
                    }
                    searchListViewAdapter.searchDialogs(text);
                  } else {
                    searchListViewAdapter.searchDialogs(null);
                    searching = false;
                    searchWas = false;
                    listView.setAdapter(listViewAdapter);
                    listViewAdapter.notifyDataSetChanged();
                    if (android.os.Build.VERSION.SDK_INT >= 11) {
                      listView.setFastScrollAlwaysVisible(true);
                    }
                    listView.setFastScrollEnabled(true);
                    listView.setVerticalScrollBarEnabled(false);
                    emptyTextView.setText(
                        LocaleController.getString("NoContacts", R.string.NoContacts));
                  }
                }
              }
            }
          });

      LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
      emptyTextLayout.setVisibility(View.INVISIBLE);
      emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
      linearLayout.addView(emptyTextLayout);
      layoutParams = (LinearLayout.LayoutParams) emptyTextLayout.getLayoutParams();
      layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
      emptyTextLayout.setLayoutParams(layoutParams);
      emptyTextLayout.setOnTouchListener(
          new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              return true;
            }
          });

      emptyTextView = new TextView(getParentActivity());
      emptyTextView.setTextColor(0xff808080);
      emptyTextView.setTextSize(20);
      emptyTextView.setGravity(Gravity.CENTER);
      emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
      emptyTextLayout.addView(emptyTextView);
      layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      emptyTextView.setLayoutParams(layoutParams);

      FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
      emptyTextLayout.addView(frameLayout2);
      layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      frameLayout2.setLayoutParams(layoutParams);

      listView = new LetterSectionsListView(getParentActivity());
      listView.setEmptyView(emptyTextLayout);
      listView.setVerticalScrollBarEnabled(false);
      listView.setDivider(null);
      listView.setDividerHeight(0);
      listView.setFastScrollEnabled(true);
      listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
      listView.setAdapter(listViewAdapter);
      if (Build.VERSION.SDK_INT >= 11) {
        listView.setFastScrollAlwaysVisible(true);
        listView.setVerticalScrollbarPosition(
            LocaleController.isRTL
                ? ListView.SCROLLBAR_POSITION_LEFT
                : ListView.SCROLLBAR_POSITION_RIGHT);
      }
      linearLayout.addView(listView);
      layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      listView.setLayoutParams(layoutParams);
      listView.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
              TLRPC.User user = null;
              if (searching && searchWas) {
                user = searchListViewAdapter.getItem(i);
              } else {
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (row < 0 || section < 0) {
                  return;
                }
                user = (TLRPC.User) listViewAdapter.getItem(section, row);
              }
              if (user == null) {
                return;
              }

              boolean check = true;
              if (selectedContacts.containsKey(user.id)) {
                check = false;
                try {
                  XImageSpan span = selectedContacts.get(user.id);
                  selectedContacts.remove(user.id);
                  SpannableStringBuilder text =
                      new SpannableStringBuilder(userSelectEditText.getText());
                  text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                  allSpans.remove(span);
                  ignoreChange = true;
                  userSelectEditText.setText(text);
                  userSelectEditText.setSelection(text.length());
                  ignoreChange = false;
                } catch (Exception e) {
                  FileLog.e("tmessages", e);
                }
              } else {
                if (selectedContacts.size() == maxCount) {
                  return;
                }
                ignoreChange = true;
                XImageSpan span = createAndPutChipForUser(user);
                span.uid = user.id;
                ignoreChange = false;
              }
              if (!isAlwaysShare && !isNeverShare) {
                actionBar.setSubtitle(
                    LocaleController.formatString(
                        "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
              }
              if (searching || searchWas) {
                ignoreChange = true;
                SpannableStringBuilder ssb = new SpannableStringBuilder("");
                for (ImageSpan sp : allSpans) {
                  ssb.append("<<");
                  ssb.setSpan(
                      sp,
                      ssb.length() - 2,
                      ssb.length(),
                      SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                userSelectEditText.setText(ssb);
                userSelectEditText.setSelection(ssb.length());
                ignoreChange = false;

                searchListViewAdapter.searchDialogs(null);
                searching = false;
                searchWas = false;
                listView.setAdapter(listViewAdapter);
                listViewAdapter.notifyDataSetChanged();
                if (android.os.Build.VERSION.SDK_INT >= 11) {
                  listView.setFastScrollAlwaysVisible(true);
                }
                listView.setFastScrollEnabled(true);
                listView.setVerticalScrollBarEnabled(false);
                emptyTextView.setText(
                    LocaleController.getString("NoContacts", R.string.NoContacts));
              } else {
                if (view instanceof UserCell) {
                  ((UserCell) view).setChecked(check, true);
                }
              }
            }
          });
      listView.setOnScrollListener(
          new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
              if (i == SCROLL_STATE_TOUCH_SCROLL) {
                AndroidUtilities.hideKeyboard(userSelectEditText);
              }
              if (listViewAdapter != null) {
                listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE);
              }
            }

            @Override
            public void onScroll(
                AbsListView absListView,
                int firstVisibleItem,
                int visibleItemCount,
                int totalItemCount) {
              if (absListView.isFastScrollEnabled()) {
                AndroidUtilities.clearDrawableAnimation(absListView);
              }
            }
          });
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
예제 #15
0
 @Override
 public void onTextChanged(CharSequence s, int start, int before, int count) {
   // TODO Auto-generated method stub
   et.setHintTextColor(0xff888888);
 }
예제 #16
0
  @Override
  public View createView(Context context, LayoutInflater inflater) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            } else if (id == done_button) {
              if (firstNameField.getText().length() != 0) {
                saveName();
                finishFragment();
              }
            }
          }
        });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
    if (user == null) {
      user = UserConfig.getCurrentUser();
    }

    fragmentView = new LinearLayout(context);
    fragmentView.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    firstNameField = new EditText(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    firstNameField.setHintTextColor(0xff979797);
    firstNameField.setTextColor(0xff212121);
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(
        InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
    AndroidUtilities.clearCursorDrawable(firstNameField);
    ((LinearLayout) fragmentView).addView(firstNameField);
    LinearLayout.LayoutParams layoutParams =
        (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
    layoutParams.topMargin = AndroidUtilities.dp(24);
    layoutParams.height = AndroidUtilities.dp(36);
    layoutParams.leftMargin = AndroidUtilities.dp(24);
    layoutParams.rightMargin = AndroidUtilities.dp(24);
    layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    firstNameField.setLayoutParams(layoutParams);
    firstNameField.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_NEXT) {
              lastNameField.requestFocus();
              lastNameField.setSelection(lastNameField.length());
              return true;
            }
            return false;
          }
        });

    lastNameField = new EditText(context);
    lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    lastNameField.setHintTextColor(0xff979797);
    lastNameField.setTextColor(0xff212121);
    lastNameField.setMaxLines(1);
    lastNameField.setLines(1);
    lastNameField.setSingleLine(true);
    lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    lastNameField.setInputType(
        InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
    AndroidUtilities.clearCursorDrawable(lastNameField);
    ((LinearLayout) fragmentView).addView(lastNameField);
    layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
    layoutParams.topMargin = AndroidUtilities.dp(16);
    layoutParams.height = AndroidUtilities.dp(36);
    layoutParams.leftMargin = AndroidUtilities.dp(24);
    layoutParams.rightMargin = AndroidUtilities.dp(24);
    layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    lastNameField.setLayoutParams(layoutParams);
    lastNameField.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
              doneButton.performClick();
              return true;
            }
            return false;
          }
        });

    if (user != null) {
      firstNameField.setText(user.first_name);
      firstNameField.setSelection(firstNameField.length());
      lastNameField.setText(user.last_name);
    }

    return fragmentView;
  }