<commit_before>/*******************************************************************************
 * Copyright (c) 2013 See AUTHORS file.
 * 
 * This file is part of SleepFighter.
 * 
 * SleepFighter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * SleepFighter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SleepFighter. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package se.chalmers.dat255.sleepfighter.android.preference;

import android.content.Context;
import android.net.Uri;
import android.preference.RingtonePreference;
import android.util.AttributeSet;

/**
 * InitializableRingtonePreference provides {@link #setInitialUri(Uri)}.
 *
 * @author Centril<<EMAIL>> / <NAME>.
 * @version 1.0
 * @since Sep 27, 2013
 */
public class InitializableRingtonePreference extends RingtonePreference {
	private Uri initialUri;

	/**
	 * Sets the initial URI to use upon inflation.
	 *
	 * @param uri the initial URI.
	 */
	public void setInitialUri( Uri uri ) {
		this.initialUri = uri;
	}

	@Override
	protected Uri onRestoreRingtone() {
		return this.initialUri;
	}

	/**
	 * @see RingtonePreference#RingtonePreference(Context)
	 */
	public InitializableRingtonePreference( Context context ) {
		super( context );
	}

	/**
	 * @see RingtonePreference#RingtonePreference(Context, AttributeSet)
	 */
	public InitializableRingtonePreference( Context context, AttributeSet attrs ) {
		super( context, attrs );
	}

	/**
	 * @see RingtonePreference#RingtonePreference(Context, AttributeSet, int)
	 */
	public InitializableRingtonePreference( Context context, AttributeSet attrs, int defStyle ) {
		super( context, attrs, defStyle );
	}
}
<commit_msg>Changed memory cards to big letters.<commit_after>/*******************************************************************************
 * Copyright (c) 2013 See AUTHORS file.
 * 
 * This file is part of SleepFighter.
 * 
 * SleepFighter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * SleepFighter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SleepFighter. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package se.chalmers.dat255.sleepfighter.android.preference;

import se.chalmers.dat255.sleepfighter.utils.debug.Debug;
import android.content.Context;
import android.database.Cursor;
import android.media.RingtoneManager;
import android.net.Uri;
import android.preference.RingtonePreference;
import android.provider.Settings;
import android.util.AttributeSet;

/**
 * InitializableRingtonePreference provides {@link #setInitialUri(Uri)}.
 *
 * @author Centril<<EMAIL>> / <NAME>.
 * @version 1.0
 * @since Sep 27, 2013
 */
public class InitializableRingtonePreference extends RingtonePreference {
	private Uri initialUri;

	/**
	 * Sets the initial URI to use upon inflation.
	 *
	 * @param uri the initial URI.
	 */
	public void setInitialUri( Uri uri ) {
		this.initialUri = uri;
	}

	Uri[] getAllRingtones() {
		
		RingtoneManager ringtoneMgr = new RingtoneManager(this.getContext());
		ringtoneMgr.setType(RingtoneManager.TYPE_ALL);
		Cursor alarmsCursor = ringtoneMgr.getCursor();
		int alarmsCount = alarmsCursor.getCount();
		if (alarmsCount == 0 && !alarmsCursor.moveToFirst()) {
			return null;
		}
		Uri[] alarms = new Uri[alarmsCount];
		while(!alarmsCursor.isAfterLast() && alarmsCursor.moveToNext()) {
			int currentPosition = alarmsCursor.getPosition();
			alarms[currentPosition] = ringtoneMgr.getRingtoneUri(currentPosition);
			//Debug.d("sound uri " +alarms[currentPosition]);
			
			Debug.d("compare: " + Settings.System.DEFAULT_ALARM_ALERT_URI.compareTo(alarms[currentPosition]));
		}
		alarmsCursor.close();
		return alarms;
	}

	@Override
	protected Uri onRestoreRingtone() {
		
		//Debug.d("current uri " + this.initialUri);
		
		//getAllRingtones();
		
		return this.initialUri;

	}

	/**
	 * @see RingtonePreference#RingtonePreference(Context)
	 */
	public InitializableRingtonePreference( Context context ) {
		super( context );
	}

	/**
	 * @see RingtonePreference#RingtonePreference(Context, AttributeSet)
	 */
	public InitializableRingtonePreference( Context context, AttributeSet attrs ) {
		super( context, attrs );
	}

	/**
	 * @see RingtonePreference#RingtonePreference(Context, AttributeSet, int)
	 */
	public InitializableRingtonePreference( Context context, AttributeSet attrs, int defStyle ) {
		super( context, attrs, defStyle );
	}
}

{'fraction_non_alphanumeric': 0.1512682836511757, 'fraction_numerical': 0.0066654323273467875, 'mean_word_length': 4.686315789473684, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4235893', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1455, 'n_words': 459}