Back to project page CheckIt_Android.
The source code is released under:
Apache License
If you think the Android project CheckIt_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright 2014 Bhavyanshu Parasher/*from www . j a v a 2 s . com*/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.pytacular.checkitcloudchecklist; import android.app.Activity; import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; import android.speech.RecognizerIntent; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; import com.parse.ParseException; import com.parse.ParseInstallation; import com.parse.ParseUser; import com.parse.SaveCallback; import com.parse.SignUpCallback; public class RegisterActivity extends SherlockActivity { private EditText mUsernameField; private EditText mPasswordField; private TextView mErrorField; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); mUsernameField = (EditText) findViewById(R.id.register_username); mPasswordField = (EditText) findViewById(R.id.register_password); mErrorField = (TextView) findViewById(R.id.error_messages); if (InternetStatus.getInstance(this).isOnline(this)) { // Pass } else { mErrorField .setText("No internet connection available. Please check your connection settings."); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getSupportMenuInflater().inflate(R.menu.register, menu); return true; } public void register(final View v) { if (mUsernameField.getText().length() == 0 || mPasswordField.getText().length() == 0) { ParseInstallation.getCurrentInstallation().put("user", mUsernameField); return; } v.setEnabled(false); ParseUser user = new ParseUser(); user.setUsername(mUsernameField.getText().toString()); user.setPassword(mPasswordField.getText().toString()); mErrorField.setText(""); user.signUpInBackground(new SignUpCallback() { @Override public void done(ParseException e) { if (e == null) { Intent intent = new Intent(RegisterActivity.this, MainActivity.class); startActivity(intent); finish(); } else { // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong switch (e.getCode()) { case ParseException.USERNAME_TAKEN: mErrorField .setText("Sorry, this username has already been taken."); break; case ParseException.USERNAME_MISSING: mErrorField .setText("Sorry, you must supply a username to register."); break; case ParseException.PASSWORD_MISSING: mErrorField .setText("Sorry, you must supply a password to register."); break; case ParseException.CONNECTION_FAILED: mErrorField .setText("Internet connection was not found. Please see your connection settings."); break; default: mErrorField.setText(e.getLocalizedMessage()); break; } v.setEnabled(true); } } }); ParseInstallation.getCurrentInstallation().saveInBackground( new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Toast toast = Toast.makeText( getApplicationContext(), R.string.alert_dialog_success, Toast.LENGTH_SHORT); toast.show(); } else { e.printStackTrace(); Toast toast = Toast.makeText( getApplicationContext(), R.string.alert_dialog_failed, Toast.LENGTH_SHORT); toast.show(); } } }); } public void showLogin(View v) { Intent intent = new Intent(this, LoginActivity.class); startActivity(intent); finish(); } /** * When an item from a menu is selected */ @Override public boolean onOptionsItemSelected(MenuItem item) { ActionBar menubar = getSupportActionBar(); switch (item.getItemId()) { case R.id.action_settings: /* * Toast.makeText(this, "Settings", Toast.LENGTH_SHORT).show(); Was * using this for debugging */ break; case R.id.action_help: showOverLay(); return true; default: break; } return true; } public void showOverLay() { final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); dialog.setContentView(R.layout.overlay_view); LinearLayout layout = (LinearLayout) dialog .findViewById(R.id.overlayLayout); layout.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.show(); } }