@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); rs = getResources(); requestWindowFeature(Window.FEATURE_NO_TITLE); vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE); newgame(); prefs = PreferenceManager.getDefaultSharedPreferences(this); source(); AppRater.app_launched(this); }
/** @see android.app.Activity#onCreate(android.os.Bundle) */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences myPreferences = getApplicationContext().getSharedPreferences("PREFERENCE", MODE_PRIVATE); boolean firstrun = myPreferences.getBoolean("firstrun", true); if (firstrun) { new AlertDialog.Builder(this) .setTitle("Warning") .setMessage( "This app and its developer(s) are not affliated or endorsed by " + "the Port Authority of New York and New Jersey.\n\nThis application obtains your current location " + "and can use it to obtain your three closest stations, then directions to the station you select. To The PATH And Back does not " + "use your location for any other purpose. In addition, neither the location obtained by your device or location " + "you manually entered are stored anywhere by this application.\n\nThe directions provided by this application is obtained from " + "OpenStreetMap via Open MapQuest. The developer(s) of this app, MapQuest and OpenStreetMap, " + "cannot guarentee that the directions given to you are 100% accurate. Use them at your own risk.\n\nFinally, " + "please be aware that the developer(s) cannot guarantee that the station and/or entrance that you want " + "directions for will be open or accurately placed. Again, use the directions and locations provided by this app at your own risk.\n\nAds " + "provided by Google's AdMob/AdSense will be displayed under the tabs in the action bar as well " + "as in the bottom of the screen where you'll select the station you want directions to.") .setNeutralButton("OK", null) .show(); myPreferences.edit().putBoolean("firstrun", false).commit(); myPreferences.edit().putBoolean("imperialUnits", true).commit(); } unitMeasurement = myPreferences.getString("unitMeasurement", ""); if (unitMeasurement.isEmpty()) { myPreferences .edit() .putString("unitMeasurement", "m") .commit(); // Imperial units is the default unit of measurement unitMeasurement = myPreferences.getString("unitMeasurement", ""); } AppRater.app_launched(this); pathStations = new DatabaseHandler(this); getAllStopsAndTrips(); getAppKey(); addTabs(); adView = (AdView) this.findViewById(R.id.adViewMain); AdRequest adRequest = new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build(); // AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final MediaPlayer mp = MediaPlayer.create(this, R.raw.press); mp.setVolume(0.3f, 0.3f); // uiHelper = new UiLifecycleHelper(this, callback); AppRater.app_launched(this); if (savedInstanceState != null) { mCameraFileName = savedInstanceState.getString("mCameraFileName"); } // We create a new AuthSession so that we can use the Dropbox API. AndroidAuthSession session = buildSession(); mApi = new DropboxAPI<AndroidAuthSession>(session); // Basic Android widgets setContentView(R.layout.main); RevMob revmob = RevMob.start(this); // RevMob Media ID configured in the AndroidManifest.xml file RevMobBanner banner = revmob.createBanner(this); ViewGroup view = (ViewGroup) findViewById(R.id.banner); // align bottom view.addView(banner); GridView gridview = (GridView) findViewById(R.id.gridview); myImageAdapter = new ImageAdapter(this); gridview.setAdapter(myImageAdapter); gridview.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { fullscreen.show(); } }); final String ExternalStorageDirectoryPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String targetPath = ExternalStorageDirectoryPath + PHOTO_DIR; Toast.makeText(getApplicationContext(), targetPath, Toast.LENGTH_LONG).show(); File targetDirector = new File(targetPath); File dir = new File(ExternalStorageDirectoryPath + PHOTO_DIR); try { if (dir.mkdir()) { System.out.println("Directory created"); } else { System.out.println("Directory is not created"); } } catch (Exception e) { e.printStackTrace(); } File[] files = targetDirector.listFiles(); for (File file : files) { myImageAdapter.add(file.getAbsolutePath()); gridview.setFocusable(true); } fullscreen = revmob.createFullscreen(this, null); // pre-load it without showing it // ViewGroup view = (ViewGroup) findViewById(R.id.banner); // view.addView(banner); checkAppKeySetup(); final AlphaAnimation alphaDown3, alphaUp3; mSubmit = (Button) findViewById(R.id.auth_button); // set animation alphaDown3 = new AlphaAnimation(1.0f, 0.5f); alphaUp3 = new AlphaAnimation(0.5f, 1.0f); alphaDown3.setDuration(100); alphaUp3.setDuration(100); alphaDown3.setFillAfter(true); alphaUp3.setFillAfter(true); // set OnTouchListener mSubmit.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) mSubmit.startAnimation(alphaDown3); alphaDown3.setFillAfter(false); if (event.getAction() == MotionEvent.ACTION_UP) mSubmit.startAnimation(alphaUp3); alphaUp3.setFillAfter(false); return false; } }); mSubmit = (Button) findViewById(R.id.auth_button); mSubmit.setOnClickListener( new OnClickListener() { public void onClick(View v) { mp.start(); // This logs you out if you're logged in, or vice versa if (mLoggedIn) { logOut(); } } }); final AlphaAnimation alphaDown2, alphaUp2; Gallery = (Button) findViewById(R.id.gall); // set animation alphaDown2 = new AlphaAnimation(1.0f, 0.5f); alphaUp2 = new AlphaAnimation(0.5f, 1.0f); alphaDown2.setDuration(100); alphaUp2.setDuration(100); alphaDown2.setFillAfter(true); alphaUp2.setFillAfter(true); // set OnTouchListener Gallery.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) Gallery.startAnimation(alphaDown2); alphaDown2.setFillAfter(false); if (event.getAction() == MotionEvent.ACTION_UP) Gallery.startAnimation(alphaUp2); alphaUp2.setFillAfter(false); // Gallery.clearAnimation(); return false; } }); Gallery = (Button) findViewById(R.id.gall); Gallery.setOnClickListener( new OnClickListener() { public void onClick(View v) { mp.start(); fullscreen.show(); Intent photoPickerIntent = new Intent(Intent.ACTION_VIEW); photoPickerIntent.setType("image/*"); startActivity(photoPickerIntent); } }); final AlphaAnimation alphaDown, alphaUp; box = (Button) findViewById(R.id.dropbox); // set animation alphaDown = new AlphaAnimation(1.0f, 0.5f); alphaUp = new AlphaAnimation(0.5f, 1.0f); alphaDown.setDuration(100); alphaUp.setDuration(100); alphaDown.setFillAfter(true); alphaUp.setFillAfter(true); // set OnTouchListener box.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) box.startAnimation(alphaDown); alphaDown.setFillAfter(false); if (event.getAction() == MotionEvent.ACTION_UP) box.startAnimation(alphaUp); alphaUp.setFillAfter(false); return false; } }); box = (Button) findViewById(R.id.dropbox); box.setOnClickListener( new OnClickListener() { public void onClick(View v) { mp.start(); Intent intent = new Intent(Intent.CATEGORY_LAUNCHER); // intent.putExtra(Intent.EXTRA_SUBJECT, "Foo bar"); // NB: has no effect! // See if official Facebook app is found boolean facebookAppFound = false; List<ResolveInfo> matches = getPackageManager().queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.toLowerCase().startsWith("com.dropbox.android")) { intent.setPackage(info.activityInfo.packageName); facebookAppFound = true; break; } } // As fallback, launch sharer.php in a browser if (!facebookAppFound) { String sharerUrl = "http://www.dropbox.com"; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); } startActivity(intent); try { PackageManager manager = getPackageManager(); Intent i = manager.getLaunchIntentForPackage("com.dropbox.android"); i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://dropbox.com/"))); } } }); loginbutton = (Button) findViewById(R.id.log_in); loginbutton.setOnClickListener( new OnClickListener() { public void onClick(View v) { mp.start(); // Start the remote authentication mApi.getSession().startAuthentication(CloudCam.this); } }); final AlphaAnimation alphaDown1, alphaUp1; Kill = (Button) findViewById(R.id.Exit); // set animation alphaDown1 = new AlphaAnimation(1.0f, 0.5f); alphaUp1 = new AlphaAnimation(0.5f, 1.0f); alphaDown1.setDuration(100); alphaUp1.setDuration(100); alphaDown1.setFillAfter(true); alphaUp1.setFillAfter(true); // set OnTouchListener Kill.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) Kill.startAnimation(alphaDown1); alphaDown1.setFillAfter(false); if (event.getAction() == MotionEvent.ACTION_UP) Kill.startAnimation(alphaUp1); alphaUp1.setFillAfter(false); return false; } }); Kill = (Button) findViewById(R.id.Exit); Kill.setOnClickListener( new OnClickListener() { public void onClick(View v) { mp.start(); // Create custom dialog object final Dialog dialog = new Dialog(CloudCam.this); // Include dialog.xml file dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog); // Set dialog title // dialog.setTitle(" ✈ Cloud Cam ☁"); TextView text = (TextView) dialog.findViewById(R.id.txt_dia); TextView text2 = (TextView) dialog.findViewById(R.id.lpt2); ImageView image2 = (ImageView) dialog.findViewById(R.id.vix); // text.setText("\n Custom dialog Android example."); ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog); image.setImageResource(R.drawable.cloud); Button buttonl = (Button) dialog.findViewById(R.id.Like); buttonl.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Perform action on click mp.start(); try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/1638346363055062")); startActivity(intent); } catch (Exception e) { startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse( "https://www.facebook.com/pages/Vixel-Interactive/1638346363055062"))); } dialog.dismiss(); } }); ImageView buttonv = (ImageView) dialog.findViewById(R.id.vix); buttonv.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mp.start(); // Perform action on click try { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.vixelinteractive.com")); startActivity(intent); } catch (Exception e) { } dialog.dismiss(); } }); Button button69 = (Button) dialog.findViewById(R.id.insta); button69.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Perform action on click mp.start(); Uri uri = Uri.parse("http://instagram.com/_u/vixel_interactive"); Intent likeIng = new Intent(Intent.ACTION_VIEW, uri); likeIng.setPackage("com.instagram.android"); try { startActivity(likeIng); } catch (ActivityNotFoundException e) { startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("https://instagram.com/vixel_interactive"))); } dialog.dismiss(); } }); Button button = (Button) dialog.findViewById(R.id.Rate); button.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mp.start(); // Perform action on click startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()))); dialog.dismiss(); } }); Button button3 = (Button) dialog.findViewById(R.id.Share); button3.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Perform action on click mp.start(); String urlToShare = "https://play.google.com/store/apps/details?id=" + getPackageName(); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // intent.putExtra(Intent.EXTRA_SUBJECT, "Foo bar"); // NB: has no effect! intent.putExtra(Intent.EXTRA_TEXT, urlToShare); // See if official Facebook app is found boolean facebookAppFound = false; List<ResolveInfo> matches = getPackageManager().queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo .packageName .toLowerCase() .startsWith("com.facebook.katana")) { intent.setPackage(info.activityInfo.packageName); facebookAppFound = true; break; } } // https://play.google.com/store/apps/details?id=" + getPackageName(); // As fallback, launch sharer.php in a browser if (!facebookAppFound) { String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); } startActivity(intent); dialog.dismiss(); } }); // Typecasting the Animation Drawable dialog.show(); } }); mDisplay = (LinearLayout) findViewById(R.id.logged_in_display); Start1 = (TextView) findViewById(R.id.lpt2); asd = (GridView) findViewById(R.id.gridview); dropbox = (Button) findViewById(R.id.dropbox); gallbutton = (Button) findViewById(R.id.gall); vtext = (TextView) findViewById(R.id.tmt1); vmix = (ImageView) findViewById(R.id.tmt2); // Start2 = (TextView)findViewById(R.id.lpt3); Start4 = (ImageView) findViewById(R.id.vix); Start5 = (ImageView) findViewById(R.id.cc); // Dropbox = (Button)findViewById(R.id.dropbox); final AlphaAnimation alphaDown4, alphaUp4; mPhoto = (Button) findViewById(R.id.photo_button); // set animation alphaDown4 = new AlphaAnimation(1.0f, 0.5f); alphaUp4 = new AlphaAnimation(0.5f, 1.0f); alphaDown4.setDuration(100); alphaUp4.setDuration(100); alphaDown4.setFillAfter(true); alphaUp4.setFillAfter(true); // set OnTouchListener mPhoto.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) mPhoto.startAnimation(alphaDown4); alphaDown4.setFillAfter(false); if (event.getAction() == MotionEvent.ACTION_UP) mPhoto.startAnimation(alphaUp4); alphaUp4.setFillAfter(false); return false; } }); // This is where a photo is displayed // mImage = (ImageView)findViewById(R.id.image_view); // This is the button to take a photo mPhoto = (Button) findViewById(R.id.photo_button); mPhoto.bringToFront(); mPhoto.setOnClickListener( new OnClickListener() { public void onClick(View v) { mp.start(); fullscreen.show(); Intent intent = new Intent(); // Picture from camera intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); // This is not the right way to do this, but for some reason, having // it store it in // MediaStore.Images.Media.EXTERNAL_CONTENT_URI isn't working right. Date date = new Date(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd-kk-mm-ss"); String newPicFile = df.format(date) + ".jpg"; String outPath = Environment.getExternalStorageDirectory() + File.separator + "CloudCameraBackup" + File.separator + newPicFile; File outFile = new File(outPath); mCameraFileName = outFile.toString(); Uri outuri = Uri.fromFile(outFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, outuri); Log.i(TAG, "Importing New Picture: " + mCameraFileName); try { startActivityForResult(intent, NEW_PICTURE); } catch (ActivityNotFoundException e) { showToast("There doesn't seem to be a camera."); } } }); // This is the button to take a photo // Display the proper UI state if logged in or not setLoggedIn(mApi.getSession().isLinked()); }