@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webCall = new WebCallService(); alert = new AlertDialogManager(); cd = new ConnectionDetector(getApplicationContext()); // retrieve any saved user login details getSharedPref(); // if the user is logged in then continue to main menu if (isLoggedIn == true) { Intent i = new Intent(getApplicationContext(), LoggedInActivity.class); startActivity(i); } // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog( LoginActivity.this, "Internet Connection Error", "Please connect to WiFi or 3g to use EasyOrder", false); } }
@Override protected void onCreate(Bundle savedInstanceState) { String gps_status = getBaseContext().getString(R.string.gps_status); String gps_inform = getBaseContext().getString(R.string.gps_inform); // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.single_place); Intent i = getIntent(); // Place referece id String reference = i.getStringExtra(KEY_REFERENCE); // Calling a Async Background thread new LoadSinglePlaceDetails().execute(reference); gps = new GPSTracker(this); if (gps.canGetLocation()) { Log.d( "Your Location", "latitude:" + gps.getLatitude() + ", longitude: " + gps.getLongitude()); } else { // Can't get user's current location alert.showAlertDialog(SinglePlaceActivity.this, gps_status, gps_inform, false); // stop executing code by returno return; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_screen); cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog( MainScreenActivity.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } Intent i = getIntent(); name = i.getStringExtra("name"); email = i.getStringExtra("email"); // Make sure the device has the proper dependencies. GCMRegistrar.checkDevice(this); // Make sure the manifest was properly set - comment out this line // while developing the app, then uncomment it when it's ready. GCMRegistrar.checkManifest(this); lblMessage = (TextView) findViewById(R.id.lblMessage); registerReceiver(mHandleMessageReceiver, new IntentFilter(DISPLAY_MESSAGE_ACTION)); // Get GCM registration id final String regId = GCMRegistrar.getRegistrationId(this); // Check if regid already presents if (regId.equals("")) { // Registration is not present, register now with GCM GCMRegistrar.register(this, SENDER_ID); } else { // Device is already registered on GCM if (GCMRegistrar.isRegisteredOnServer(this)) { // Skips registration. Toast.makeText( getApplicationContext(), "Registration with server is verified!", Toast.LENGTH_LONG) .show(); } else { // Try to register again, but not in the UI thread. // It's also necessary to cancel the thread onDestroy(), // hence the use of AsyncTask instead of a raw thread. final Context context = this; mRegisterTask = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { // Register on our server // On server creates a new user ServerUtilities.register(context, name, email, regId); return null; } @Override protected void onPostExecute(Void result) { mRegisterTask = null; } }; mRegisterTask.execute(null, null, null); } } File folder = new File(Environment.getExternalStorageDirectory() + "/itmpdf"); if (!folder.exists()) { success = folder.mkdirs(); if (success) { Log.i("directory created", "directory created"); } else { Log.i("directory not created", "directory not created"); } } else { Log.i("Directorylog", "Directory ALready Exists"); } // Buttons btnViewResults = (ImageButton) findViewById(R.id.btnViewResults); btnViewEvents = (ImageButton) findViewById(R.id.btnViewNotices); btnViewAnnounce = (ImageButton) findViewById(R.id.btnViewAnnounce); btntt = (ImageButton) findViewById(R.id.btntt); btntalky = (ImageButton) findViewById(R.id.btntalky); btnabt = (ImageButton) findViewById(R.id.btnabt); dwnmanager = (ImageButton) findViewById(R.id.dwnmanager); ImageButton ratemyapp = (ImageButton) findViewById(R.id.ratemyapp); btnViewResults.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), AllResultsActivity.class); startActivity(i); } }); btnViewEvents.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), AllEventsActivity.class); startActivity(i); } }); btnViewAnnounce.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), AllAnnActivity.class); startActivity(i); } }); btntt.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), TimetableActivity.class); startActivity(i); } }); btntalky.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), TalkyLaunchActivity.class); startActivity(i); } }); btnabt.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), AllAbtActivity.class); startActivity(i); } }); dwnmanager.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(), ScanPdf.class); startActivity(i); } }); ratemyapp.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("market://details?id=" + getPackageName()); Log.i("URI", uri.toString()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(getBaseContext(), "Couldn't launch the market", Toast.LENGTH_LONG) .show(); } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog( MainActivity.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } // Getting name, email from intent Intent i = getIntent(); name = i.getStringExtra("name"); email = i.getStringExtra("email"); // Make sure the device has the proper dependencies. GCMRegistrar.checkDevice(this); // Make sure the manifest was properly set - comment out this line // while developing the app, then uncomment it when it's ready. GCMRegistrar.checkManifest(this); lblMessage = (TextView) findViewById(R.id.lblMessage); // mainWebView = (WebView) findViewById(R.id.webView1); registerReceiver(mHandleMessageReceiver, new IntentFilter(DISPLAY_MESSAGE_ACTION)); // Get GCM registration id final String regId = GCMRegistrar.getRegistrationId(this); // Check if regid already presents if (regId.equals("")) { // Registration is not present, register now with GCM GCMRegistrar.register(this, SENDER_ID); } else { // Device is already registered on GCM /*if (GCMRegistrar.isRegisteredOnServer(this)) { // Skips registration. Toast.makeText(getApplicationContext(), "Already registered with GCM", Toast.LENGTH_LONG).show(); } else {*/ // Try to register again, but not in the UI thread. // It's also necessary to cancel the thread onDestroy(), // hence the use of AsyncTask instead of a raw thread. final Context context = this; mRegisterTask = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { // Register on our server // On server creates a new user ServerUtilities.register(context, name, email, regId); return null; } @Override protected void onPostExecute(Void result) { mRegisterTask = null; } }; mRegisterTask.execute(null, null, null); // } } }
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate!"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); if (savedInstanceState == null) { getSupportFragmentManager() .beginTransaction() .add(R.id.login_activitycontainer, new LoginActivityFragment()) .commit(); } // GOOGLE mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); // FACEBOOK uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); // TWITTER // Check if twitter keys are set if (TWITTER_CONSUMER_KEY.trim().length() == 0 || TWITTER_CONSUMER_SECRET.trim().length() == 0) { // Internet Connection is not present alert.showAlertDialog( LoginActivity.this, "Twitter oAuth tokens", "Please set your twitter oauth tokens first!", false); // stop executing code by return return; } // TODO: please us threads correctly! if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } // Check if Internet present cd = new ConnectionDetector(getApplicationContext()); if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog( LoginActivity.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } // Shared Preferences mSharedPreferences = getApplicationContext().getSharedPreferences("AndroidSocialTemplate", 0); /** * This if conditions is tested once is redirected from twitter page. Parse the uri to get oAuth * Verifier */ if (!isTwitterLoggedInAlready()) { Uri uri = getIntent().getData(); if (uri != null && uri.toString().startsWith(TWITTER_CALLBACK_URL)) { // oAuth verifier String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER); try { // Get the access token AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier); // Shared Preferences Editor e = mSharedPreferences.edit(); // After getting access token, access token secret // store them in application preferences e.putString(PREF_KEY_OAUTH_TOKEN, accessToken.getToken()); e.putString(PREF_KEY_OAUTH_SECRET, accessToken.getTokenSecret()); // Store login status - true e.putBoolean(PREF_KEY_TWITTER_LOGIN, true); e.commit(); // save changes Log.d("Twitter OAuth Token", "> " + accessToken.getToken()); Intent i = new Intent(LoginActivity.this, MainActivity.class); startActivityForResult(i, REQUEST_CODE_TWITTER_LOGIN); } catch (Exception e) { // Check log for login errors Log.e("Twitter Login Error", "> " + e.getMessage()); } } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gcm); cd = new ConnectionDetector(getApplicationContext()); if (!cd.isConnectingToInternet()) { alert.showAlertDialog( ActivityGCM.this, "Internet Connection Error", "Please connect to working Internet connection", false); return; } Intent i = getIntent(); name = i.getStringExtra("name"); email = i.getStringExtra("email"); GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); lblMessage = (TextView) findViewById(R.id.lblMessage); registerReceiver(mHandleMessageReceiver, new IntentFilter(DISPLAY_MESSAGE_ACTION)); final String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { GCMRegistrar.register(this, SENDER_ID); } else { if (GCMRegistrar.isRegisteredOnServer(this)) { Toast.makeText(getApplicationContext(), "Already registered with GCM", Toast.LENGTH_LONG) .show(); } else { final Context context = this; mRegisterTask = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { ServerUtilities.register(context, name, email, regId); return null; } @Override protected void onPostExecute(Void result) { mRegisterTask = null; } }; mRegisterTask.execute(null, null, null); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog( RegisterActivity.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } // Check if GCM configuration is set if (SERVER_URL == null || SENDER_ID == null || SERVER_URL.length() == 0 || SENDER_ID.length() == 0) { // GCM sernder id / server url is missing alert.showAlertDialog( RegisterActivity.this, "Configuration Error!", "Please set your Server URL and GCM Sender ID", false); // stop executing code by return return; } // Make sure the device has the proper dependencies. GCMRegistrar.checkDevice(this); // Make sure the manifest was properly set - comment out this line // while developing the app, then uncomment it when it's ready. GCMRegistrar.checkManifest(this); String reg_id = GCMRegistrar.getRegistrationId(this); // Check if regid already presents if (!reg_id.equals("")) { Intent i = new Intent(getApplicationContext(), MainActivity.class); startActivity(i); finish(); } txtName = (EditText) findViewById(R.id.txtName); txtEmail = (EditText) findViewById(R.id.txtEmail); btnRegister = (Button) findViewById(R.id.btnRegister); /* * Click event on Register button * */ btnRegister.setOnClickListener( new View.OnClickListener() { public void onClick(View arg0) { // Read EditText dat String name = txtName.getText().toString(); String email = txtEmail.getText().toString(); // Check if user filled the form if (name.trim().length() > 0 && email.trim().length() > 0) { // Launch Main Activity Intent i = new Intent(getApplicationContext(), MainActivity.class); // Registering user on our server // Sending registraiton details to MainActivity i.putExtra("name", name); i.putExtra("email", email); startActivity(i); finish(); } else { // user doen't filled that data // ask him to fill the form alert.showAlertDialog( RegisterActivity.this, "Registration Error!", "Please enter your details", false); } } }); }
@SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.twitter); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().hide(); } cd = new ConnectionDetector(getApplicationContext()); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog( twitter.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } // Check if twitter keys are set if (TWITTER_CONSUMER_KEY.trim().length() == 0 || TWITTER_CONSUMER_SECRET.trim().length() == 0) { // Internet Connection is not present alert.showAlertDialog( twitter.this, "Twitter oAuth tokens", "Please set your twitter oauth tokens first!", false); // stop executing code by return return; } // All UI elements btnLoginTwitter = (Button) findViewById(R.id.btnLoginTwitter); btnUpdateStatus = (Button) findViewById(R.id.btnUpdateStatus); btnLogoutTwitter = (Button) findViewById(R.id.btnLogoutTwitter); txtUpdate = (EditText) findViewById(R.id.txtUpdateStatus); lblUpdate = (TextView) findViewById(R.id.lblUpdate); lblUserName = (TextView) findViewById(R.id.lblUserName); // Shared Preferences mSharedPreferences = getApplicationContext().getSharedPreferences("MyPref", 0); /** Twitter login button click event will call loginToTwitter() function */ btnLoginTwitter.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { // Call login twitter function } }); /** Button click event to Update Status, will call updateTwitterStatus() function */ btnUpdateStatus.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Call update status function // Get the status from EditText loginToTwitter(); } }); /** Button click event for logout from twitter */ btnLogoutTwitter.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { // Call logout twitter function logoutFromTwitter(); } }); /** * This if conditions is tested once is redirected from twitter page. Parse the uri to get oAuth * Verifier */ if (!isTwitterLoggedInAlready()) { Uri uri = getIntent().getData(); if (uri != null && uri.toString().startsWith(TWITTER_CALLBACK_URL)) { // oAuth verifier String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER); try { // Get the access token AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier); // Shared Preferences Editor e = mSharedPreferences.edit(); // After getting access token, access token secret // store them in application preferences e.putString(PREF_KEY_OAUTH_TOKEN, accessToken.getToken()); e.putString(PREF_KEY_OAUTH_SECRET, accessToken.getTokenSecret()); // Store login status - true e.putBoolean(PREF_KEY_TWITTER_LOGIN, true); e.commit(); // save changes Log.e("Twitter OAuth Token", "> " + accessToken.getToken()); // Hide login button btnLoginTwitter.setVisibility(View.GONE); // Show Update Twitter lblUpdate.setVisibility(View.VISIBLE); txtUpdate.setVisibility(View.VISIBLE); btnUpdateStatus.setVisibility(View.VISIBLE); btnLogoutTwitter.setVisibility(View.VISIBLE); // Getting user details from twitter // For now i am getting his name only long userID = accessToken.getUserId(); User user = twitter.showUser(userID); String username = user.getName(); // Displaying in xml ui lblUserName.setText(Html.fromHtml("<b>Welcome " + username + "</b>")); } catch (Exception e) { // Check log for login errors Log.e("Twitter Login Error", "> " + e.getMessage()); } } } }