// Path: app/src/main/java/link/standen/michael/fatesheets/util/DiceClickListener.java
// public final class DiceClickListener implements View.OnClickListener {
// 
// 	private final Resources resources;
// 	private final Random random;
// 
// 	/**
// 	 * A shared list of rolls for persistence.
// 	 */
// 	private static List<int[]> rolls = new ArrayList<>();
// 
// 	public DiceClickListener(Resources resources){
// 		this.resources = resources;
// 		this.random = new Random();
// 	}
// 
// 	@Override
// 	public void onClick(View view) {
// 		// Roll dice
// 		int[] roll = new int[4];
// 		int total = 0;
// 		StringBuilder bob = new StringBuilder("[");
// 		for (int i = 0; i < roll.length; i++) {
// 			roll[i] = random.nextInt(3) - 1;
// 			total += roll[i];
// 			// Display string
// 			if (i > 0){
// 				bob.append(" ");
// 			}
// 			bob.append(formatRoll(roll[i]));
// 		}
// 		bob.append("]");
// 		rolls.add(roll);
// 
// 		Snackbar.make(view, resources.getString(R.string.toast_rolled, formatRoll(total),
// 				ladderResult(total), bob.toString()), Snackbar.LENGTH_INDEFINITE)
// 				.setAction("Action", null).show();
// 	}
// 
// 	/**
// 	 * Convert the integer to a string for display purposes.
// 	 */
// 	private String formatRoll(int roll){
// 		if (roll > 0){
// 			return "+"+roll;
// 		}
// 		return ""+roll;
// 	}
// 
// 	private String[] ladder;
// 
// 	/**
// 	 * Get the ladder string result from the roll.
// 	 */
// 	private String ladderResult(int roll){
// 		// Init ladder
// 		if (ladder == null){
// 			ladder = resources.getStringArray(R.array.roll_ladder);
// 		}
// 		// Convert roll to array index location
// 		roll += 2;
// 		if (roll < 0){
// 			// Lowest result
// 			roll = 0;
// 		} else if (roll >= ladder.length){
// 			// Highest result
// 			roll = ladder.length - 1;
// 		}
// 		return ladder[roll];
// 	}
// }


import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import link.standen.michael.fatesheets.R;
import link.standen.michael.fatesheets.util.DiceClickListener;
package link.standen.michael.fatesheets.activity;



/**
 * An abstract class that handles the menu items shared across activities.
 */
public abstract class SharedMenuActivity extends AppCompatActivity {

	private static final long FOCUS_PAUSE = 500;

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu_shared_activity, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();

		//noinspection SimplifiableIfStatement
		if (id == R.id.action_credits) {
			startActivity(new Intent(this, CreditsActivity.class));
			return true;
		} else if (id == R.id.action_docs) {
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://fate-srd.com/")));
			return true;
		} else if (id == R.id.action_edit_skills) {
			startActivity(new Intent(this, EditSkillsActivity.class));
			return true;
		}

		return super.onOptionsItemSelected(item);
	}

	protected void setupDiceFAB() {
		FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.dice_fab);
// Path: app/src/main/java/link/standen/michael/fatesheets/util/DiceClickListener.java
// public final class DiceClickListener implements View.OnClickListener {
// 
// 	private final Resources resources;
// 	private final Random random;
// 
// 	/**
// 	 * A shared list of rolls for persistence.
// 	 */
// 	private static List<int[]> rolls = new ArrayList<>();
// 
// 	public DiceClickListener(Resources resources){
// 		this.resources = resources;
// 		this.random = new Random();
// 	}
// 
// 	@Override
// 	public void onClick(View view) {
// 		// Roll dice
// 		int[] roll = new int[4];
// 		int total = 0;
// 		StringBuilder bob = new StringBuilder("[");
// 		for (int i = 0; i < roll.length; i++) {
// 			roll[i] = random.nextInt(3) - 1;
// 			total += roll[i];
// 			// Display string
// 			if (i > 0){
// 				bob.append(" ");
// 			}
// 			bob.append(formatRoll(roll[i]));
// 		}
// 		bob.append("]");
// 		rolls.add(roll);
// 
// 		Snackbar.make(view, resources.getString(R.string.toast_rolled, formatRoll(total),
// 				ladderResult(total), bob.toString()), Snackbar.LENGTH_INDEFINITE)
// 				.setAction("Action", null).show();
// 	}
// 
// 	/**
// 	 * Convert the integer to a string for display purposes.
// 	 */
// 	private String formatRoll(int roll){
// 		if (roll > 0){
// 			return "+"+roll;
// 		}
// 		return ""+roll;
// 	}
// 
// 	private String[] ladder;
// 
// 	/**
// 	 * Get the ladder string result from the roll.
// 	 */
// 	private String ladderResult(int roll){
// 		// Init ladder
// 		if (ladder == null){
// 			ladder = resources.getStringArray(R.array.roll_ladder);
// 		}
// 		// Convert roll to array index location
// 		roll += 2;
// 		if (roll < 0){
// 			// Lowest result
// 			roll = 0;
// 		} else if (roll >= ladder.length){
// 			// Highest result
// 			roll = ladder.length - 1;
// 		}
// 		return ladder[roll];
// 	}
// }


// Path: app/src/main/java/link/standen/michael/fatesheets/activity/SharedMenuActivity.java
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import link.standen.michael.fatesheets.R;
import link.standen.michael.fatesheets.util.DiceClickListener;

package link.standen.michael.fatesheets.activity;



/**
 * An abstract class that handles the menu items shared across activities.
 */
public abstract class SharedMenuActivity extends AppCompatActivity {

	private static final long FOCUS_PAUSE = 500;

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu_shared_activity, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();

		//noinspection SimplifiableIfStatement
		if (id == R.id.action_credits) {
			startActivity(new Intent(this, CreditsActivity.class));
			return true;
		} else if (id == R.id.action_docs) {
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://fate-srd.com/")));
			return true;
		} else if (id == R.id.action_edit_skills) {
			startActivity(new Intent(this, EditSkillsActivity.class));
			return true;
		}

		return super.onOptionsItemSelected(item);
	}

	protected void setupDiceFAB() {
		FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.dice_fab);
		fab.setOnClickListener(new DiceClickListener(getResources()));