<commit_before>/*
 * Copyright 2013 <NAME> (<EMAIL>)
 * 
 * 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.
 */
package com.kevinquan.android.utils;

import java.util.List;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * Collection of utilities related to preferences
 * @author <NAME> (<EMAIL>)
 *
 */
public class PreferenceUtils {

	/**
	 * Constants to be used for preferences (such as preference keys or preference values)
	 * @author <NAME> (<EMAIL>)
	 *
	 */
	public interface BasePreferences {
		public static final String RATEAPP = "RateApp"; //$NON-NLS-1$
		public static final String CHANGELOG = "ShowChangelog"; //$NON-NLS-1$
		public static final String CHANGELOG_PATH = "file:///android_asset/changelog.html";
		public static final String ABOUT_AUTHOR = "AboutAuthor"; //$NON-NLS-1$
		public static final String ABOUT_AUTHOR_WEBSITE = "http://www.kevinquan.com/"; //$NON-NLS-1$	
	}

	@SuppressWarnings("unused")
	private static final String TAG = PreferenceUtils.class.getSimpleName();

	/**
	 * Checks whether the current device can open an Google Play intent.  If it can, then an intent to open 
	 * the current app will be returned
	 * @param context The context that can identify the current app
	 * @return An intent to open the current app in Google Play if the device supports it, otherwise null
	 */
	public static Intent canHandleGooglePlayIntent(Context context) {
	    if (context == null) return null;
        Intent rateIntent = getGooglePlayIntent(context);
        // Don't show rate-my-app if no Google Play installed
        List<ResolveInfo> marketHandlers = context.getPackageManager().queryIntentActivities(rateIntent, 0);
        if (marketHandlers == null || marketHandlers.isEmpty()) {
        	return null;
        }
        return rateIntent;
	}
	
	/**
	 * Retrieves an intent to open the app that provided the context in Google Play
	 * @param context The context that can identify the current app<commit_msg>Add some more constants<commit_after>/*
 * Copyright 2013 <NAME> (<EMAIL>)
 * 
 * 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.
 */
package com.kevinquan.android.utils;

import java.util.List;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * Collection of utilities related to preferences
 * @author <NAME> (<EMAIL>)
 *
 */
public class PreferenceUtils {

	/**
	 * Constants to be used for preferences (such as preference keys or preference values)
	 * @author <NAME> (<EMAIL>)
	 *
	 */
	public interface BasePreferences {
		public static final String RATEAPP = "RateApp"; //$NON-NLS-1$
		public static final String HAS_RATED = "HasRatedApp"; //$NON-NLS-1$
	    public static final String SHOULD_PROMPT_TO_RATEAPP = "HasPromptedToRateApp"; //$NON-NLS-1$
		
		public static final String CHANGELOG = "ShowChangelog"; //$NON-NLS-1$
		public static final String CHANGELOG_PATH = "file:///android_asset/changelog.html"; //$NON-NLS-1$
		public static final String LICENSES = "ShowLicenses"; //$NON-NLS-1$
		public static final String LICENSES_PATH = "file:///android_asset/licenses.html"; //$NON-NLS-1$
		public static final String ABOUT_AUTHOR = "AboutAuthor"; //$NON-NLS-1$
		public static final String ABOUT_AUTHOR_WEBSITE = "http://www.kevinquan.com/"; //$NON-NLS-1$	
	}

	@SuppressWarnings("unused")
	private static final String TAG = PreferenceUtils.class.getSimpleName();

	/**
	 * Checks whether the current device can open an Google Play intent.  If it can, then an intent to open 
	 * the current app will be returned
	 * @param context The context that can identify the current app
	 * @return An intent to open the current app in Google Play if the device supports it, otherwise null
	 */
	public static Intent canHandleGooglePlayIntent(Context context) {
	    if (context == null) return null;
        Intent rateIntent = getGooglePlayIntent(context);
        // Don't show rate-my-app if no Google Play installed
        List<ResolveInfo> marketHandlers = context.getPackageManager().queryIntentActivities(rateIntent, 0);
        if (marketHandlers == null || marketHandlers.isEmpty()) {
        	return null;
        }
        return rateIntent;
	}
	
	/**
	 * Retrieves an intent to open the app that provided the context in Google Play
	 * @param context The context that can identify the current app
{'fraction_non_alphanumeric': 0.09537166900420757, 'fraction_numerical': 0.005434782608695652, 'mean_word_length': 3.8347457627118646, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3950323', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1572, 'n_words': 601}