@Override protected void onCreate(Bundle savedInstanceState) { if (EyeRS.PREFERENCES == null) { EyeRS.PREFERENCES = new AndroidPreferences(getSharedPreferences(EyeRS.PREFS_NAME, Context.MODE_PRIVATE)); } super.onCreate(savedInstanceState); SettingUtilities.onActivityCreateSetTheme(this); super.setContentView(R.layout.activity_login); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); this.txtPIN = (EditText) findViewById(R.id.txtPIN); this.loginButton = (Button) findViewById(R.id.btnLogin); this.loginButton.setOnClickListener(this); findViewById(R.id.txtForgotPin).setOnClickListener(this); this.registerButton = (Button) findViewById(R.id.btnRegister); this.registerButton.setOnClickListener(this); /* * Content resolver object */ eyeRSContentResolver = this.getContentResolver(); String[] projection = { UserRegistrationInfo.REG_ID, UserRegistrationInfo.USER_NAME, UserRegistrationInfo.EMAIL_ADD, UserRegistrationInfo.USER_PIN, UserRegistrationInfo.SECURITY_QUESTION, UserRegistrationInfo.SECURITY_RESPONSE }; String whereClause = ""; String[] whereArgs = {}; String sortOrder = ""; try { /* * Content Resolver query */ Cursor cursor = eyeRSContentResolver.query(DBOperations.CONTENT_URI_USER_REG, projection, whereClause, whereArgs, sortOrder); if (!cursor.moveToFirst()) { /* * No user registered so disable the Login button */ this.loginButton.setEnabled(false); } else if (cursor.moveToFirst()) { /* * If a user has been registered already * we need to disable the Register button to follow * the Single-User per Device policy */ this.registerButton.setEnabled(false); cursor.close(); } } catch (Exception ex) { Log.e("Login query", ex.getMessage(), ex); } /*Initialising mediaPlayer*/ welcomeMessage = MediaPlayer.create(LoginActivity.this, R.raw.welcomemsg); }
@Override public Preferences getPreferences(String name) { return new AndroidPreferences(getContext().getSharedPreferences(name, Context.MODE_PRIVATE)); }