Example usage for android.view.inputmethod EditorInfo IME_NULL

List of usage examples for android.view.inputmethod EditorInfo IME_NULL

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_NULL.

Prototype

int IME_NULL

To view the source code for android.view.inputmethod EditorInfo IME_NULL.

Click Source Link

Document

Generic unspecified type for #imeOptions .

Usage

From source file:ael.com.loterias.c_login.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Inicializamos valores
    this.pMODO = R.string.st_la_Login;

    // Inicializamos la tarea
    this.ResultTask = null;

    c_logging.getInstance().log(c_logging.LOG_INFO, getString(this.pMODO));

    setTitle(getString(R.string.app_name) + " - " + getString(R.string.st_la_Login));

    setContentView(R.layout.l_login);//from www .j a va2s .co  m

    // Set up the login form.
    mEmailView = (EditText) findViewById(R.id.email);

    // Restauramos el email por defecto en las preferencias
    Context context = getApplicationContext();
    c_preferences appPrefs = new c_preferences(context);
    mEmailView.setText(appPrefs.getUsername(true));

    // Fin preferencias

    mPasswordView = (EditText) findViewById(R.id.password);
    mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {

                try {
                    c_logging.getInstance().log(c_logging.LOG_INFO, getString(R.string.st_la_Sign_in) + ":"
                            + mEmailView.getText() + "/" + mPasswordView.getText());
                    PRC_INTENTAR_LOGIN();
                } catch (IOException e) {
                    c_logging.getInstance().log(c_logging.LOG_ERROR, getString(R.string.st_la_Sign_in)
                            + ": (FAIL)" + mEmailView.getText() + "/" + mPasswordView.getText());
                    e.printStackTrace();
                }
                return true;
            }
            return false;
        }
    });

    // Quitar esto
    mPasswordView.setText(appPrefs.getPassword(true));

    // Botn de login
    findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            c_logging.getInstance().log(c_logging.LOG_INFO, getString(R.string.st_la_Sign_in) + ":"
                    + mEmailView.getText() + "/" + mPasswordView.getText());
            try {
                PRC_INTENTAR_LOGIN();
            } catch (IOException e) {
                c_logging.getInstance().log(c_logging.LOG_ERROR, getString(R.string.st_la_Sign_in) + ": (FAIL)"
                        + mEmail + "/" + mPasswordView.getText());
                e.printStackTrace();
            }
        }
    });

    // Preferncia del check
    mCheckRemenberView = (CheckBox) findViewById(R.id.chk_remember);
    mCheckRemenberView.setChecked(appPrefs.getCheckRemenberPref());

    // Preferncia del login
    mCheckAutoLogin = (CheckBox) findViewById(R.id.chk_auto_login);
    mCheckAutoLogin.setChecked(appPrefs.getAutoLogin());

    // Si esta puesto que se auto-loguee, cargo el login
    if (appPrefs.getAutoLogin()) {
        try {
            PRC_INTENTAR_LOGIN();
        } catch (IOException e) {
            c_logging.getInstance().log(c_logging.LOG_ERROR, getString(R.string.st_la_auto_login) + ": FAIL");
            e.printStackTrace();
        }
    }

    findViewById(R.id.register_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            c_logging.getInstance().log(c_logging.LOG_INFO, getString(R.string.st_la_register) + ":"
                    + mEmailView.getText() + "/" + mPasswordView.getText());
            PRC_INTENTAR_REGISTRO();
        }
    });

    mRetypePasswordView = (EditText) findViewById(R.id.retype_password);
    mRetypePasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {

                c_logging.getInstance().log(c_logging.LOG_INFO, getString(R.string.st_la_register) + ":"
                        + mEmailView.getText() + "/" + mPasswordView.getText());
                PRC_INTENTAR_REGISTRO();
                return true;
            }
            return false;
        }
    });

}

From source file:com.trellmor.berrytubechat.ChatActivity.java

@SuppressLint("NewApi")
@Override/*from w  w  w  . j a  v  a2s .c om*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_chat);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(false);
    }

    mEditChatMsg = (EditText) findViewById(R.id.edit_chat_msg);
    TextView.OnEditorActionListener chatMsgListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                sendChatMsg();
            } else if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP
                    && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                sendChatMsg();
            }
            return true;
        }
    };
    mEditChatMsg.setOnEditorActionListener(chatMsgListener);

    mTextDrinks = (TextView) findViewById(R.id.text_drinks);
    registerForContextMenu(mTextDrinks);

    mCurrentVideo = (TextView) findViewById(R.id.text_video);
    mCurrentVideo.setMovementMethod(LinkMovementMethod.getInstance());

    mTextNick = (TextView) findViewById(R.id.text_nick);
    mTextNick.setText("Anonymous");

    mListChat = (ListView) findViewById(R.id.list_chat);

    Intent intent = getIntent();
    mUsername = intent.getStringExtra(MainActivity.KEY_USERNAME);
    mPassword = intent.getStringExtra(MainActivity.KEY_PASSWORD);

    if (savedInstanceState != null) {
        mDrinkCount = savedInstanceState.getInt(KEY_DRINKCOUT);
        mMyDrinkCount = savedInstanceState.getInt(KEY_MYDRINKCOUNT);
        if (mUsername == null)
            mUsername = savedInstanceState.getString(MainActivity.KEY_USERNAME);
        if (mPassword == null)
            mPassword = savedInstanceState.getString(MainActivity.KEY_PASSWORD);
    }

    startService(new Intent(this, BerryTube.class));
    bindService(new Intent(this, BerryTube.class), mService, BIND_ABOVE_CLIENT);
}

From source file:com.sefford.beauthentic.activities.LoginActivity.java

void configureView() {
    etPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*w  w w .  j av a 2s.c om*/
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });
    btGoogleSign.setSize(SignInButton.SIZE_STANDARD);
}

From source file:com.todoroo.astrid.actfm.TagUpdatesFragment.java

protected void setUpUpdateList() {
    if (getActivity() instanceof TagUpdatesActivity) {
        ActionBar ab = ((AstridActivity) getActivity()).getSupportActionBar();
        String title = (tagData == null) ? getString(R.string.TLA_all_activity)
                : getString(R.string.tag_updates_title, tagData.getValue(TagData.NAME));
        ((TextView) ab.getCustomView().findViewById(R.id.title)).setText(title);
    }/* w  ww  .  ja  va 2 s  .c  o m*/

    final ImageButton commentButton = (ImageButton) getView().findViewById(R.id.commentButton);
    addCommentField = (EditText) getView().findViewById(R.id.commentField);
    addCommentField.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_NULL && addCommentField.getText().length() > 0) {
                addComment();
                return true;
            }
            return false;
        }
    });
    addCommentField.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            commentButton.setVisibility((s.length() > 0) ? View.VISIBLE : View.GONE);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //
        }
    });
    commentButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addComment();
        }
    });

    final ClearImageCallback clearImage = new ClearImageCallback() {
        @Override
        public void clearImage() {
            picture = null;
            resetPictureButton();
        }
    };
    pictureButton = (ImageButton) getView().findViewById(R.id.picture);
    pictureButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (picture != null)
                ActFmCameraModule.showPictureLauncher(TagUpdatesFragment.this, clearImage);
            else
                ActFmCameraModule.showPictureLauncher(TagUpdatesFragment.this, null);
        }
    });

    refreshUpdatesList();
    refreshActivity(false); // start a pull in the background
}

From source file:com.miz.mizuu.fragments.SearchWebMoviesFragment.java

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    super.onViewCreated(v, savedInstanceState);

    mToolbar = (Toolbar) v.findViewById(R.id.toolbar);
    ((MizActivity) getActivity()).setSupportActionBar(mToolbar);

    mProgressBar = (ProgressBar) v.findViewById(R.id.progressBar1);
    v.findViewById(R.id.spinner1).setVisibility(View.GONE);

    mListView = (ListView) v.findViewById(R.id.listView1);
    mListView.setOnItemClickListener(new OnItemClickListener() {
        @Override//from w w  w.ja  va2  s. c o  m
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            showMovie(arg2);
        }
    });
    mListView.setEmptyView(v.findViewById(R.id.no_results));
    v.findViewById(R.id.no_results).setVisibility(View.GONE);

    // Both the ProgressBar and ListView have been set, so let's hide the ProgressBar
    hideProgressBar();

    mSearchField = (EditText) v.findViewById(R.id.editText1);
    mSearchField.setSelection(mSearchField.length());
    mSearchField.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().length() > 0)
                searchForMovies();
            else {
                mSearchTask.cancel(true);
                mResults.clear();
                mAdapter.notifyDataSetChanged();
            }
        }
    });
    mSearchField.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN
                    || actionId == EditorInfo.IME_ACTION_SEARCH)
                searchForMovies();
            return true;
        }
    });
}

From source file:prince.app.ccm.Fragment_Log.java

private void initView(View view) {
    // Set up the login form.
    mUserEditText = (EditText) view.findViewById(R.id.username);
    //   addFocusListener(mUserEditText);

    mPasswordEditText = (EditText) view.findViewById(R.id.password);
    //   addFocusListener(mPasswordEditText);

    mPasswordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from   w  w  w. j ava  2  s.  co m*/
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.user_login || id == EditorInfo.IME_NULL) {
                if (!Tool.getInstance().isConnection())
                    Toast.makeText(getActivity(), "No network connection!", Toast.LENGTH_SHORT).show();
                else {
                    attemptLogin();
                    return true;
                }
            }
            return false;
        }
    });

    mLoginFormView = view.findViewById(R.id.login_form);
    mLoginStatusView = view.findViewById(R.id.login_progress);

    view.findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            attemptLogin();
        }
    });

    mRemind = (CheckBox) view.findViewById(R.id.box_remember);
    if (Tool.getInstance().getBolPref(Util.REMIND)) {
        mRemind.setChecked(true);
        mUserEditText.setText("");
        mPasswordEditText.setText("");
        mUserEditText.append(Tool.getInstance().getStringPref(Util.USER));
        mPasswordEditText.append(Tool.getInstance().getStringPref(Util.PASSWORD));
    }

    mShowPassword = (CheckBox) view.findViewById(R.id.box_reveal);
    mShowPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mPasswordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
            } else {
                mPasswordEditText
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }

            if (mPasswordEditText.hasFocus()) {
                String temp = mPasswordEditText.getText().toString().trim();
                mPasswordEditText.setText("");
                mPasswordEditText.append(temp);
            }

        }

    });
}

From source file:fi.mikuz.boarder.gui.internet.DownloadBoardList.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_download);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mViewPager = (ViewPager) findViewById(R.id.viewPager);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override// www .j a v a 2  s  .  c  o m
        public void onPageSelected(int position) {
            setPageTitle(position + 1);
        }
    });

    setNewViewPager();
    mSearch = (EditText) findViewById(R.id.searchInput);
    mCurrentSearch = "";
    ImageView refresh = (ImageView) findViewById(R.id.refresh);

    Button orderByDate = (Button) findViewById(R.id.orderByDate);
    Button orderByRate = (Button) findViewById(R.id.orderByRate);
    mOrderRule = ORDER_RULE_CHANGE_TIME;
    mOrderDirection = ORDER_DIRECTION_DESCENDING;
    mMaxResults = 40;

    Bundle extras = getIntent().getExtras();
    if (extras.getSerializable(InternetMenu.LOGIN_KEY) != null) {
        @SuppressWarnings("unchecked")
        HashMap<String, String> lastSession = (HashMap<String, String>) extras
                .getSerializable(InternetMenu.LOGIN_KEY);

        mLoggedIn = true;
        mUserId = lastSession.get(InternetMenu.USER_ID_KEY);
        mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY);
    }

    mSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
            String search = mSearch.getText().toString();
            if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN
                    && !search.equals(mCurrentSearch)) {
                mCurrentSearch = search;
                setNewViewPager();
            }
            return true;
        }
    });

    refresh.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            refreshViewPager();
        }
    });

    orderByDate.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mOrderRule.equals(ORDER_RULE_CHANGE_TIME)
                    && mOrderDirection.equals(ORDER_DIRECTION_DESCENDING)) {
                mOrderDirection = ORDER_DIRECTION_ASCENDING;
            } else {
                mOrderRule = ORDER_RULE_CHANGE_TIME;
                mOrderDirection = ORDER_DIRECTION_DESCENDING;
            }
            setNewViewPager();
        }
    });

    orderByRate.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mOrderRule.equals(ORDER_RULE_BOARD_RATING)
                    && mOrderDirection.equals(ORDER_DIRECTION_DESCENDING)) {
                mOrderDirection = ORDER_DIRECTION_ASCENDING;
            } else {
                mOrderRule = ORDER_RULE_BOARD_RATING;
                mOrderDirection = ORDER_DIRECTION_DESCENDING;
            }
            setNewViewPager();
        }
    });

}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

protected void resetContent() {
    comicDef = makeComicDef();/*www.ja  va 2  s.  c om*/
    provider = comicDef.getProvider();
    comicInfo = provider.createEmptyComicInfo();

    //Only hide the title bar if we're running an android less than Android 3.0
    if (VersionHacks.getSdkInt() < 11)
        requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);
    webview = (HackedWebView) findViewById(R.id.viewer);
    title = (TextView) findViewById(R.id.title);
    comicIdSel = (EditText) findViewById(R.id.comicIdSel);

    webview.requestFocus();
    zoom = webview.getZoomControls();

    webview.setClickable(true);
    webview.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!"".equals(comicInfo.getAlt()))
                showDialog(DIALOG_SHOW_HOVER_TEXT);
        }
    });

    title.setText(comicInfo.getTitle());

    comicIdSel.setText(comicInfo.getId());
    if (comicDef.idsAreNumbers())
        comicIdSel.setInputType(InputType.TYPE_CLASS_NUMBER);
    comicIdSel.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String text = comicIdSel.getText().toString();
            if (!text.equals("") && (actionId == EditorInfo.IME_ACTION_GO
                    || (actionId == EditorInfo.IME_NULL && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
                loadComic(createComicUri(text));
                comicIdSel.setText("");
                return true;
            }
            return false;
        }
    });
    comicIdSel.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (hasFocus) {
                comicIdSel.setText("");
                imm.showSoftInput(comicIdSel, InputMethodManager.SHOW_IMPLICIT);
            } else {
                imm.hideSoftInputFromWindow(comicIdSel.getWindowToken(), 0);
            }
        }
    });

    ((Button) findViewById(R.id.firstBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToFirst();
        }
    });

    ((Button) findViewById(R.id.prevBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToPrev();
        }
    });

    ((Button) findViewById(R.id.nextBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToNext();
        }
    });

    ((Button) findViewById(R.id.finalBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToFinal();
        }
    });

    ((ImageView) findViewById(R.id.randomBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToRandom();
        }
    });

    bookmarkBtn = (ImageView) findViewById(R.id.bookmarkBtn);
    bookmarkBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            toggleBookmark();
        }
    });
    refreshBookmarkBtn();
}

From source file:org.tigase.messenger.phone.pro.conversations.chat.ChatItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_chatitem_list, container, false);
    ButterKnife.bind(this, root);

    message.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from  ww  w  . j  a  v  a2s.  com*/
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.send || id == EditorInfo.IME_NULL) {
                send();
                return true;
            }
            return false;
        }
    });
    message.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Container.setVisibility(View.GONE);
            iv_face_checked.setVisibility(View.VISIBLE);
            iv_face_normal.setVisibility(View.GONE);
        }
    });

    iv_face_normal.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Container.setVisibility(View.VISIBLE);
            iv_face_checked.setVisibility(View.VISIBLE);
            iv_face_normal.setVisibility(View.GONE);
            closeIME();
        }
    });
    iv_face_checked.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Container.setVisibility(View.GONE);
            iv_face_normal.setVisibility(View.VISIBLE);
            iv_face_checked.setVisibility(View.GONE);
        }
    });

    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            send();
        }
    });
    message.addTextChangedListener(watcher);

    // recyclerView.addItemDecoration(new
    // DividerItemDecoration(getActivity(),
    // DividerItemDecoration.VERTICAL_LIST));

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    linearLayoutManager.setReverseLayout(true);

    recyclerView.setLayoutManager(linearLayoutManager);
    this.adapter = new MyChatItemRecyclerViewAdapter(getContext(), null, mListener) {
        @Override
        protected void onContentChanged() {
            refreshChatHistory();
        }
    };
    recyclerView.setAdapter(adapter);

    refreshChatHistory();
    return root;
}

From source file:de.uni_koblenz_landau.apow.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Re-attach Tasks.
    TaskActivityReference.getInstance().attach(LoginTask.TASK_ID, this);
    TaskActivityReference.getInstance().attach(SetupTask.TASK_ID, this);
    TaskActivityReference.getInstance().attach(NFCTagReaderTask.TASK_ID, this);
    TaskActivityReference.getInstance().attach(LocationWebTask.TASK_ID, this);

    // Create UI references.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(this.getResources().getColor(R.color.color_primary_dark));
    }// w  ww.  j  a v a 2  s. c  o  m
    setContentView(R.layout.login_activity);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mToolbar != null) {
        setSupportActionBar(mToolbar);
    }

    mSetupLocationView = (Spinner) findViewById(R.id.login_setup_locations);
    mStatusView = findViewById(R.id.login_status);
    mStatusMessageView = (TextView) findViewById(R.id.login_status_message);
    mLoginFormView = findViewById(R.id.login_login);
    mLoginPasswordView = (EditText) findViewById(R.id.login_login_password);
    mLoginPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                login(textView);
                return true;
            }
            return false;
        }
    });
    mLoginNFCText = (TextView) findViewById(R.id.login_login_nfc);
    mSetupFormView = findViewById(R.id.login_setup);
    mSetupNFCText = (TextView) findViewById(R.id.login_setup_nfc);

    mSetupDatabasePasswordView = (EditText) findViewById(R.id.login_setup_database_password);
    mSetupDatabaseConfirmView = (EditText) findViewById(R.id.login_setup_database_password_confirm);
    mSetupServerUsernameView = (EditText) findViewById(R.id.login_login_server_user);
    mSetupServerPasswordView = (EditText) findViewById(R.id.login_login_server_password);

    //mFirstRun = true;
    mFirstRun = getSharedPreferences(Constants.PREFERENCE, MODE_PRIVATE).getBoolean(ARG_FIRST_RUN, true);
    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);

    // Restore UI from saved instance or load data.
    if (savedInstanceState != null) {
        mNFCTag = savedInstanceState.getString(ARG_NFC);
        mNFCTextDrawable = savedInstanceState.getInt(ARG_NFC_STATE);
        mAutoSignOffDismissed = savedInstanceState.getBoolean(ARG_AUTO_SIGN_OFF_DISMISSED);
        mProgress = savedInstanceState.getBoolean(ARG_PROGRESS);
        if (mFirstRun) {
            mLocations = savedInstanceState.getParcelableArrayList(ARG_LOCATIONS);
            if (mLocations != null) {
                ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(this,
                        android.R.layout.simple_spinner_item, mLocations);
                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                mSetupLocationView.setAdapter(adapter);
                mSetupLocationView.setSelection(savedInstanceState.getInt(ARG_LOCATION_SELECTION));
            }
        }
    } else {
        mProgress = false;
        mAutoSignOffDismissed = false;
        mNFCTag = "";
        mNFCTextDrawable = R.drawable.empty;
        if (mFirstRun) {
            loadLocations();
        }
    }
    mLoginNFCText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mNFCTextDrawable, 0);
    mSetupNFCText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mNFCTextDrawable, 0);

    if (mFirstRun) {
        mSetupFormView.setVisibility(View.VISIBLE);
        mLoginFormView.setVisibility(View.GONE);
        this.setTitle(R.string.login_setup_title);
    } else {
        mSetupFormView.setVisibility(View.GONE);
        mLoginFormView.setVisibility(View.VISIBLE);
        this.setTitle(R.string.login_login_title);
    }

    if (getIntent().getBooleanExtra(ARG_AUTO_LOGOUT, false) && !mAutoSignOffDismissed) {
        SignedOffDialog dialog = new SignedOffDialog();
        dialog.show(getSupportFragmentManager(), SIGNED_OFF_DIALOG_ID);
        mAutoSignOffDismissed = true;
    }
    showProgress(mProgress);
    setNFCState();
}