<commit_before>/*
 * Copyright (C) 2011 Pixmob (http://github.com/pixmob)
 *
 * 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.pixmob.droidlink;

import static com.pixmob.droidlink.Constants.ACTION_INIT;
import static com.pixmob.droidlink.Constants.DEVELOPER_MODE;
import static com.pixmob.droidlink.Constants.SHARED_PREFERENCES_FILE;
import static com.pixmob.droidlink.Constants.SP_KEY_IGNORE_MISSED_CALLS;
import static com.pixmob.droidlink.Constants.SP_KEY_IGNORE_RECEIVED_SMS;
import android.content.Intent;
import android.content.SharedPreferences;

import com.pixmob.droidlink.feature.Features;
import com.pixmob.droidlink.feature.SharedPreferencesSaverFeature;
import com.pixmob.droidlink.feature.StrictModeFeature;

/**
 * Application entry point.
 * @author Pixmob
 */
public class Application extends android.app.Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        if (DEVELOPER_MODE) {
            // Enable StrictMode if it's available.
            Features.getFeature(StrictModeFeature.class).enable();
        }
        
        // Make sure a device id is generated for this device.
        startService(new Intent(ACTION_INIT));
        
        // Set default values for preferences.
        final SharedPreferences prefs = getSharedPreferences(SHARED_PREFERENCES_FILE, MODE_PRIVATE);
        final SharedPreferences.Editor prefsEditor = prefs.edit();
        prefsEditor.putBoolean(SP_KEY_IGNORE_MISSED_CALLS, true);
        prefsEditor.putBoolean(SP_KEY_IGNORE_RECEIVED_SMS, true);
        Features.getFeature(SharedPreferencesSaverFeature.class).save(prefsEditor);
    }
}<commit_msg>If there is only one account on the device, select it.<commit_after>/*
 * Copyright (C) 2011 Pixmob (http://github.com/pixmob)
 *
 * 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.pixmob.droidlink;

import static com.pixmob.droidlink.Constants.ACTION_INIT;
import static com.pixmob.droidlink.Constants.DEVELOPER_MODE;
import static com.pixmob.droidlink.Constants.SHARED_PREFERENCES_FILE;
import static com.pixmob.droidlink.Constants.SP_KEY_ACCOUNT;
import static com.pixmob.droidlink.Constants.SP_KEY_IGNORE_MISSED_CALLS;
import static com.pixmob.droidlink.Constants.SP_KEY_IGNORE_RECEIVED_SMS;
import android.accounts.Account;
import android.content.Intent;
import android.content.SharedPreferences;

import com.pixmob.droidlink.feature.Features;
import com.pixmob.droidlink.feature.SharedPreferencesSaverFeature;
import com.pixmob.droidlink.feature.StrictModeFeature;
import com.pixmob.droidlink.util.Accounts;

/**
 * Application entry point.
 * @author Pixmob
 */
public class Application extends android.app.Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        if (DEVELOPER_MODE) {
            // Enable StrictMode if it's available.
            Features.getFeature(StrictModeFeature.class).enable();
        }
        
        // Set default values for preferences.
        final SharedPreferences prefs = getSharedPreferences(SHARED_PREFERENCES_FILE, MODE_PRIVATE);
        final SharedPreferences.Editor prefsEditor = prefs.edit();
        prefsEditor.putBoolean(SP_KEY_IGNORE_MISSED_CALLS, true);
        prefsEditor.putBoolean(SP_KEY_IGNORE_RECEIVED_SMS, true);
        
        // If there is only one account, select it.
        final Account[] accounts = Accounts.list(this);
        if (accounts.length == 1) {
            prefsEditor.putString(SP_KEY_ACCOUNT, accounts[0].name);
        }
        
        Features.getFeature(SharedPreferencesSaverFeature.class).save(prefsEditor);
        
        // Make sure a device id is generated for this device.
        startService(new Intent(ACTION_INIT));
    }
}
{'fraction_non_alphanumeric': 0.08411999160897839, 'fraction_numerical': 0.003775959723096287, 'mean_word_length': 3.6745098039215685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3736076', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1348, 'n_words': 364}