<commit_before>package io.puzzlebox.jigsaw.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.ColorInt;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.ImageButton;

import io.puzzlebox.jigsaw.R;

public class JoystickFragment extends Fragment {

	private final static String TAG = JoystickFragment.class.getSimpleName();


	// Reference: http://gimx.fr/wiki/index.php?title=Controller_Maps

	public final int joystick_axis_x_minimum_dualshock4 = -128;
	public final int joystick_axis_x_maximum_dualshock4 = 127;
	public final int joystick_axis_y_minimum_dualshock4 = -128;
	public final int joystick_axis_y_maximum_dualshock4 = 127;

	public final int joystick_axis_x_minimum_xboxonepad = -32768;
	public final int joystick_axis_x_maximum_xboxonepad= 32767;
	public final int joystick_axis_y_minimum_xboxonepad = -32768;
	public final int joystick_axis_y_maximum_xboxonepad = 32767;


	private JoystickView joystickView;


	private OnFragmentInteractionListener mListener;

	public JoystickFragment() {
		// Required empty public constructor
	}

	public interface OnFragmentLoadListener {
		void loadFragment(String backStackName);
	}

	public static JoystickFragment newInstance(String param1, String param2) {
		JoystickFragment fragment = new JoystickFragment();
		Bundle args = new Bundle();
//		args.putString(ARG_PARAM1, param1);
//		args.putString(ARG_PARAM2, param2);
		fragment.setArguments(args);
		return fragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (getArguments() != null) {
//			mParam1 = getArguments().getString(ARG_PARAM1);
//			mParam2 = getArguments().getString(ARG_PARAM2);
		}

	}

	public String moveDualShock4(int angle, int strength) {

		int x = 0;
		int y = 0;

		// Reference: https://github.com/controlwear/virtual-joystick-android/blob/master/misc/virtual-joystick.png?raw=true

		// TODO: Correct calulation based on drawing a line from the center values at a certain angle for a certain percentage towards the edge of the matrix of possible values
//		switch (angle) {
//			case 0-90:
//				// Upper Right
//				break;
//			case 91-180:
//				// Upper Left
//				break;
//			case 181-240:
//				// Lower Left
//				break;
//			case 241-359:
//				// Lower Right
//				break;
//			default:
//				break;
//		}


		if (((angle >= 0) && (angle <= 45)) || ((angle <= 360) && (angle >= 315))) {
			// Right
			if (strength >= 75) {
				x = joystick_axis_x_maximum_dualshock4;
			} else if (strength >= 50) {
				x = joystick_axis_x_maximum_dualshock4 / 2;
			} else if (strength >= 25) {
				x = joystick_axis_x_maximum_dualshock4 / 4;
			}
		} else if ((angle >= 45) && (angle <= 135)) {
			// Up
			if (strength >= 75) {
				y = joystick_axis_y_maximum_dualshock4;
			} else if (strength >= 50) {
				y = joystick_axis_y_maximum_dualshock4 / 2;
			} else if (strength >= 25) {
				y = joystick_axis_y_maximum_dualshock4 / 4;
			}
		} else if ((angle >= 135) && (angle <= 225)) {
			// Left
			if (strength >= 75) {
				x = joystick_axis_x_minimum_dualshock4;
			} else if (strength >= 50) {
				x = joystick_axis_x_minimum_dualshock4 / 2;
			} else if (strength >= 25) {
				x = joystick_axis_x_minimum_dualshock4 / 4;
			}
		} else if ((angle >= 225) && (angle <= 315)) {
			// Down
			if (strength >= 75) {
				y = joystick_axis_y_minimum_dualshock4;
			} else if (strength >= 50) {
				y = joystick_axis_y_minimum_dualshock4 / 2;
			} else if (strength >= 25) {
				y = joystick_axis_y_minimum_dualshock4 / 4;
			}
		}





		switch (angle) {
			case 0-45:
				// Upper Right
				break;
			case 91-180:
				// Upper Left
				break;
			case 181-240:
				// Lower Left
				break;
			case 241-359:
				// Lower Right
				break;
			default:
				break;
		}


		return "ls: " + x + ", " + y;

	}


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
									 Bundle savedInstanceState) {


		getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

<commit_msg>- comment cleanup<commit_after>package io.puzzlebox.jigsaw.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.ColorInt;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.ImageButton;

import io.puzzlebox.jigsaw.R;

public class JoystickFragment extends Fragment {

	private final static String TAG = JoystickFragment.class.getSimpleName();


	// Reference: http://gimx.fr/wiki/index.php?title=Controller_Maps

	public final int joystick_axis_x_minimum_dualshock4 = -128;
	public final int joystick_axis_x_maximum_dualshock4 = 127;
	public final int joystick_axis_y_minimum_dualshock4 = -128;
	public final int joystick_axis_y_maximum_dualshock4 = 127;

	public final int joystick_axis_x_minimum_xboxonepad = -32768;
	public final int joystick_axis_x_maximum_xboxonepad= 32767;
	public final int joystick_axis_y_minimum_xboxonepad = -32768;
	public final int joystick_axis_y_maximum_xboxonepad = 32767;


	private JoystickView joystickView;


	private OnFragmentInteractionListener mListener;

	public JoystickFragment() {
		// Required empty public constructor
	}

	public interface OnFragmentLoadListener {
		void loadFragment(String backStackName);
	}

	public static JoystickFragment newInstance(String param1, String param2) {
		JoystickFragment fragment = new JoystickFragment();
		Bundle args = new Bundle();
//		args.putString(ARG_PARAM1, param1);
//		args.putString(ARG_PARAM2, param2);
		fragment.setArguments(args);
		return fragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (getArguments() != null) {
//			mParam1 = getArguments().getString(ARG_PARAM1);
//			mParam2 = getArguments().getString(ARG_PARAM2);
		}

	}

	public String moveDualShock4(int angle, int strength) {

		int x = 0;
		int y = 0;

		// Reference: https://github.com/controlwear/virtual-joystick-android/blob/master/misc/virtual-joystick.png?raw=true

		// TODO: Correct calulation based on drawing a line from the center values at a certain angle for a certain percentage towards the edge of the matrix of possible values
//		switch (angle) {
//			case 0-90:
//				// Upper Right
//				break;
//			case 91-180:
//				// Upper Left
//				break;
//			case 181-240:
//				// Lower Left
//				break;
//			case 241-359:
//				// Lower Right
//				break;
//			default:
//				break;
//		}


		if (((angle >= 0) && (angle <= 45)) || ((angle <= 360) && (angle >= 315))) {
			// Right
			if (strength >= 75) {
				x = joystick_axis_x_maximum_dualshock4;
			} else if (strength >= 50) {
				x = joystick_axis_x_maximum_dualshock4 / 2;
			} else if (strength >= 25) {
				x = joystick_axis_x_maximum_dualshock4 / 4;
			}
		} else if ((angle >= 45) && (angle <= 135)) {
			// Up
			if (strength >= 75) {
				y = joystick_axis_y_maximum_dualshock4;
			} else if (strength >= 50) {
				y = joystick_axis_y_maximum_dualshock4 / 2;
			} else if (strength >= 25) {
				y = joystick_axis_y_maximum_dualshock4 / 4;
			}
		} else if ((angle >= 135) && (angle <= 225)) {
			// Left
			if (strength >= 75) {
				x = joystick_axis_x_minimum_dualshock4;
			} else if (strength >= 50) {
				x = joystick_axis_x_minimum_dualshock4 / 2;
			} else if (strength >= 25) {
				x = joystick_axis_x_minimum_dualshock4 / 4;
			}
		} else if ((angle >= 225) && (angle <= 315)) {
			// Down
			if (strength >= 75) {
				y = joystick_axis_y_minimum_dualshock4;
			} else if (strength >= 50) {
				y = joystick_axis_y_minimum_dualshock4 / 2;
			} else if (strength >= 25) {
				y = joystick_axis_y_minimum_dualshock4 / 4;
			}
		}

//		switch (angle) {
//			case 0-45:
//				// Upper Right
//				break;
//			case 91-180:
//				// Upper Left
//				break;
//			case 181-240:
//				// Lower Left
//				break;
//			case 241-359:
//				// Lower Right
//				break;
//			default:
//				break;
//		}

		return "ls: " + x + ", " + y;

	}


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
									 Bundle savedInstanceState) {


		getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);


{'fraction_non_alphanumeric': 0.11615572292351756, 'fraction_numerical': 0.03436936459106821, 'mean_word_length': 3.530514175876982, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '4332795', 'n_tokens_mistral': 3946, 'n_tokens_neox': 3175, 'n_words': 738}