<commit_before>package com.indukuri.mtdlive;

import java.util.concurrent.Semaphore;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.model.LatLng;
import com.indukuri.mtdlive.util.SystemUiHider;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 * 
 * @see SystemUiHider
 */
public class FullscreenMapActivity extends Activity {

	private static final boolean AUTO_HIDE = true;
	private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
	private static final boolean TOGGLE_ON_CLICK = true;
	private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
	private SystemUiHider mSystemUiHider;
	private MapView contentView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_fullscreen_map);

		final View controlsView = findViewById(R.id.fullscreen_content_controls);
		contentView = (MapView) findViewById(R.id.fullscreen_content);

		// Set up an instance of SystemUiHider to control the system UI for
		// this activity.
		mSystemUiHider = SystemUiHider.getInstance(this, contentView,
				HIDER_FLAGS);
		mSystemUiHider.setup();
		mSystemUiHider
				.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
					// Cached values.
					int mControlsHeight;
					int mShortAnimTime;

					@Override
					@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
					public void onVisibilityChange(boolean visible) {
						if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
							// If the ViewPropertyAnimator API is available
							// (Honeycomb MR2 and later), use it to animate the
							// in-layout UI controls at the bottom of the
							// screen.
							if (mControlsHeight == 0) {
								mControlsHeight = controlsView.getHeight();
							}
							if (mShortAnimTime == 0) {
								mShortAnimTime = getResources().getInteger(
										android.R.integer.config_shortAnimTime);
							}
							controlsView
									.animate()
									.translationY(visible ? 0 : mControlsHeight)
									.setDuration(mShortAnimTime);
						} else {
							// If the ViewPropertyAnimator APIs aren't
							// available, simply show or hide the in-layout UI
							// controls.
							controlsView.setVisibility(visible ? View.VISIBLE
									: View.GONE);
						}

						if (visible && AUTO_HIDE) {
							// Schedule a hide().
							delayedHide(AUTO_HIDE_DELAY_MILLIS);
						}
					}
				});

		// Set up the user interaction to manually show or hide the system UI.
		contentView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				if (TOGGLE_ON_CLICK) {
					mSystemUiHider.toggle();
				} else {
					mSystemUiHider.show();
				}
			}
		});

		// Upon interacting with UI controls, delay any scheduled hide()
		// operations to prevent the jarring behavior of controls going away
		// while interacting with the UI.
		findViewById(R.id.dummy_button).setOnTouchListener(
				mDelayHideTouchListener);
		sem = new Semaphore(1, true);
		setupLocationTracking();
		startMTDDataPolling();
	}

	// Location Tracking Setup
	// ----------------------------------------------------------------------------------
	private LocationManager locations;
	private MTDThread mtdUpdates;
	private Semaphore sem;
	private GoogleMap map;

	public void startMTDDataPolling() {
		locations = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
		Location loc = locations
				.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
		map = contentView.getMap();
		mtdUpdates = new MTDThread(loc, map);
		mtdUpdates.start();
	}

	public void setupLocationTracking() {
		locations.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10, 5,
				new LocationListener() {
					public void onStatusChanged(String provider, int status,
							Bundle extras) {					}
					public void onProviderEnabled(String provider) {					}
					public void onProviderDisabled(String provider) {					}
					public void onLocationChanged(Location location) {
						map.animateCamera(CameraUpdateFactory
								.newLatLng(new LatLng(location.getLatitude(),
										location.getLongitude())));
						// TODO Move Icon
					}
				});
	}

	// ----------------------------------------------------------------------------------

	// FULL SCREEN RELATED SHIT
	// ----------------------------------------------------------------------------------<commit_msg>removed semaphore<commit_after>package com.indukuri.mtdlive;

import java.util.concurrent.Semaphore;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.model.LatLng;
import com.indukuri.mtdlive.util.SystemUiHider;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 * 
 * @see SystemUiHider
 */
public class FullscreenMapActivity extends Activity {

	private static final boolean AUTO_HIDE = true;
	private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
	private static final boolean TOGGLE_ON_CLICK = true;
	private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
	private SystemUiHider mSystemUiHider;
	private MapView contentView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_fullscreen_map);

		final View controlsView = findViewById(R.id.fullscreen_content_controls);
		contentView = (MapView) findViewById(R.id.fullscreen_content);

		// Set up an instance of SystemUiHider to control the system UI for
		// this activity.
		mSystemUiHider = SystemUiHider.getInstance(this, contentView,
				HIDER_FLAGS);
		mSystemUiHider.setup();
		mSystemUiHider
				.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
					// Cached values.
					int mControlsHeight;
					int mShortAnimTime;

					@Override
					@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
					public void onVisibilityChange(boolean visible) {
						if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
							// If the ViewPropertyAnimator API is available
							// (Honeycomb MR2 and later), use it to animate the
							// in-layout UI controls at the bottom of the
							// screen.
							if (mControlsHeight == 0) {
								mControlsHeight = controlsView.getHeight();
							}
							if (mShortAnimTime == 0) {
								mShortAnimTime = getResources().getInteger(
										android.R.integer.config_shortAnimTime);
							}
							controlsView
									.animate()
									.translationY(visible ? 0 : mControlsHeight)
									.setDuration(mShortAnimTime);
						} else {
							// If the ViewPropertyAnimator APIs aren't
							// available, simply show or hide the in-layout UI
							// controls.
							controlsView.setVisibility(visible ? View.VISIBLE
									: View.GONE);
						}

						if (visible && AUTO_HIDE) {
							// Schedule a hide().
							delayedHide(AUTO_HIDE_DELAY_MILLIS);
						}
					}
				});

		// Set up the user interaction to manually show or hide the system UI.
		contentView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				if (TOGGLE_ON_CLICK) {
					mSystemUiHider.toggle();
				} else {
					mSystemUiHider.show();
				}
			}
		});

		// Upon interacting with UI controls, delay any scheduled hide()
		// operations to prevent the jarring behavior of controls going away
		// while interacting with the UI.
		findViewById(R.id.dummy_button).setOnTouchListener(
				mDelayHideTouchListener);
		setupLocationTracking();
		startMTDDataPolling();
	}

	// Location Tracking Setup
	// ----------------------------------------------------------------------------------
	private LocationManager locations;
	private MTDThread mtdUpdates;
	private GoogleMap map;

	public void startMTDDataPolling() {
		locations = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
		Location loc = locations
				.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
		map = contentView.getMap();
		mtdUpdates = new MTDThread(loc, map);
		mtdUpdates.start();
	}

	public void setupLocationTracking() {
		locations.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10, 5,
				new LocationListener() {
					public void onStatusChanged(String provider, int status,
							Bundle extras) {					}
					public void onProviderEnabled(String provider) {					}
					public void onProviderDisabled(String provider) {					}
					public void onLocationChanged(Location location) {
						map.animateCamera(CameraUpdateFactory
								.newLatLng(new LatLng(location.getLatitude(),
										location.getLongitude())));
						// TODO Move Icon
					}
				});
	}

	// ----------------------------------------------------------------------------------

	// FULL SCREEN RELATED SHIT
	// ----------------------------------------------------------------------------------
{'fraction_non_alphanumeric': 0.13360881542699724, 'fraction_numerical': 0.002656434474616293, 'mean_word_length': 2.9051094890510947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6714714', 'n_tokens_mistral': 3604, 'n_tokens_neox': 2855, 'n_words': 680}