<commit_before>/**
 *    Copyright 2014 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
   
   Class: WidgetService
   Description: This application sets the phone to mute 30 minute intervals.
     This class does all the main processing for the application.
     On initial action: ACTION_SHORTCUT_CLICK, sets phone to quiet mode for 30 minutes
     Other possible actions: 
     * ACTION_TIMER_EXPIRE
         * mute mode expired - need to restore regular notifications
     * ACTION_NOTIFICATION_CANCEL_CLICK
     *   * user manually cancels mute mode from notification drawer
     * ACTION_RINGERMODE_CHANGE
         * user manually changes mode from mute to something else (normal or vibrate)

 */

//3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
//       1         2         3         4         5         6         7         8         9        10        11        12

package ca.nmsasaki.android.mute30;

import java.text.DateFormat;
import java.util.Calendar;

import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;
import android.widget.Toast;

// SuppressLint needed for Settings.Global.MODE_RINGER and force using other newer API calls
// This means that the app will not run on older versions
// Fortunately, a huge amount of people are using API 16 (4.1.x) already 
// http://developer.android.com/about/dashboards/index.html?utm_source=ausdroid.net
 
@SuppressLint("NewApi")
public class WidgetService extends Service implements RingerModeListener.RingerModeListenerHandler {

	private static final String TAG = "Mute30";
	private static final int NOTIFICATION_ID = 1;
	private static final Uri URI_SETTINGS_GLOBAL_RINGERMODE = Settings.Global.getUriFor(Settings.Global.MODE_RINGER);
	
	private static final String PACKAGE_NAME = "ca.nmsasaki.android.mute30";

	public static final String ACTION_SHORTCUT_CLICK = 				PACKAGE_NAME + ".ACTION_SHORTCUT_CLICK";
	public static final String ACTION_RINGERMODE_CHANGE = 			PACKAGE_NAME + ".ACTION_RINGERMODE_CHANGE";
	public static final String ACTION_NOTIFICATION_CANCEL_CLICK = 	PACKAGE_NAME + ".ACTION_NOTIFICATION_CANCEL_CLICK";
	public static final String ACTION_TIMER_EXPIRE = 				PACKAGE_NAME + ".ACTION_TIMER_EXPIRE";

	
	// when testing minimum is 2 minutes because I round seconds down to 00 to
	// timer expires on minute change
	public static final long MUTE_DURATION_MILLISECONDS = 2 * 60 * 1000;
//	public static final long MUTE_DURATION_MILLISECONDS = 30 * 60 * 1000;

	private static final String PREF_NAME = "mute30prefs";<commit_msg>Corrected expiry time.<commit_after>/**
 *    Copyright 2014 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
   
   Class: WidgetService
   Description: This application sets the phone to mute 30 minute intervals.
     This class does all the main processing for the application.
     On initial action: ACTION_SHORTCUT_CLICK, sets phone to quiet mode for 30 minutes
     Other possible actions: 
     * ACTION_TIMER_EXPIRE
         * mute mode expired - need to restore regular notifications
     * ACTION_NOTIFICATION_CANCEL_CLICK
     *   * user manually cancels mute mode from notification drawer
     * ACTION_RINGERMODE_CHANGE
         * user manually changes mode from mute to something else (normal or vibrate)

 */

//3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
//       1         2         3         4         5         6         7         8         9        10        11        12

package ca.nmsasaki.android.mute30;

import java.text.DateFormat;
import java.util.Calendar;

import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;
import android.widget.Toast;

// SuppressLint needed for Settings.Global.MODE_RINGER and force using other newer API calls
// This means that the app will not run on older versions
// Fortunately, a huge amount of people are using API 16 (4.1.x) already 
// http://developer.android.com/about/dashboards/index.html?utm_source=ausdroid.net
 
@SuppressLint("NewApi")
public class WidgetService extends Service implements RingerModeListener.RingerModeListenerHandler {

	private static final String TAG = "Mute30";
	private static final int NOTIFICATION_ID = 1;
	private static final Uri URI_SETTINGS_GLOBAL_RINGERMODE = Settings.Global.getUriFor(Settings.Global.MODE_RINGER);
	
	private static final String PACKAGE_NAME = "ca.nmsasaki.android.mute30";

	public static final String ACTION_SHORTCUT_CLICK = 				PACKAGE_NAME + ".ACTION_SHORTCUT_CLICK";
	public static final String ACTION_RINGERMODE_CHANGE = 			PACKAGE_NAME + ".ACTION_RINGERMODE_CHANGE";
	public static final String ACTION_NOTIFICATION_CANCEL_CLICK = 	PACKAGE_NAME + ".ACTION_NOTIFICATION_CANCEL_CLICK";
	public static final String ACTION_TIMER_EXPIRE = 				PACKAGE_NAME + ".ACTION_TIMER_EXPIRE";

	
	// when testing minimum is 2 minutes because I round seconds down to 00 to
	// timer expires on minute change
//	public static final long MUTE_DURATION_MILLISECONDS = 2 * 60 * 1000;
	public static final long MUTE_DURATION_MILLISECONDS = 30 * 60 * 1000;

	private static final String PREF_NAME = "mute30prefs";
{'fraction_non_alphanumeric': 0.06028815218911736, 'fraction_numerical': 0.04923765561617009, 'mean_word_length': 3.979108635097493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1685268', 'n_tokens_mistral': 2271, 'n_tokens_neox': 1994, 'n_words': 681}