<commit_before>package net.somethingdreadful.MAL;

import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;

import net.somethingdreadful.MAL.account.AccountService;
import net.somethingdreadful.MAL.dialog.SyncDialogFragment;

import org.holoeverywhere.preference.PreferenceActivity;
import org.holoeverywhere.preference.PreferenceManager;

import java.util.Locale;

public class Settings extends PreferenceActivity implements OnSharedPreferenceChangeListener {
    Context context;
    PrefManager Prefs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setTitle(R.string.title_activity_settings);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        context = getApplicationContext();
        Prefs = new PrefManager(context);
        PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);

        addPreferencesFromResource(R.xml.settings);

        NfcHelper.disableBeam(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        String Auth = AccountService.getauth(context);
        Bundle bundle = new Bundle();
        int interval = Prefs.getsync_time() * 60;
        if (key.equals("synchronisation_time")) {
            ContentResolver.removePeriodicSync(AccountService.getAccount(context), Auth, bundle);
            ContentResolver.addPeriodicSync(AccountService.getAccount(context), Auth, bundle, interval);
        } else if (key.equals("synchronisation")) {
            if (Prefs.getsynchronisationEnabled()) {
                ContentResolver.addPeriodicSync(AccountService.getAccount(context), Auth, bundle, interval);
                FragmentManager fm = getSupportFragmentManager();
                SyncDialogFragment sdf = new SyncDialogFragment();
                sdf.show(fm, "fragment_Sync");
            } else {
                ContentResolver.removePeriodicSync(AccountService.getAccount(context), Auth, bundle);
            }
        } else if (key.equals("locale")) {
            Locale locale = Prefs.getLocale();

            // apply it until the app remains cached
            Locale.setDefault(locale);
            Configuration newConfig = new Configuration();
            newConfig.locale = locale;
            getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
        }
    }
}<commit_msg>Restart app after language change to apply it (Language)<commit_after>package net.somethingdreadful.MAL;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;

import net.somethingdreadful.MAL.account.AccountService;
import net.somethingdreadful.MAL.dialog.SyncDialogFragment;

import org.holoeverywhere.preference.PreferenceActivity;
import org.holoeverywhere.preference.PreferenceManager;

public class Settings extends PreferenceActivity implements OnSharedPreferenceChangeListener {
    Context context;
    PrefManager Prefs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setTitle(R.string.title_activity_settings);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        context = getApplicationContext();
        Prefs = new PrefManager(context);
        PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);

        addPreferencesFromResource(R.xml.settings);

        NfcHelper.disableBeam(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        String Auth = AccountService.getauth(context);
        Bundle bundle = new Bundle();
        int interval = Prefs.getsync_time() * 60;
        if (key.equals("synchronisation_time")) {
            ContentResolver.removePeriodicSync(AccountService.getAccount(context), Auth, bundle);
            ContentResolver.addPeriodicSync(AccountService.getAccount(context), Auth, bundle, interval);
        } else if (key.equals("synchronisation")) {
            if (Prefs.getsynchronisationEnabled()) {
                ContentResolver.addPeriodicSync(AccountService.getAccount(context), Auth, bundle, interval);
                FragmentManager fm = getSupportFragmentManager();
                SyncDialogFragment sdf = new SyncDialogFragment();
                sdf.show(fm, "fragment_Sync");
            } else {
                ContentResolver.removePeriodicSync(AccountService.getAccount(context), Auth, bundle);
            }
        } else if (key.equals("locale")) {
            sharedPreferences.edit().commit();
            Intent Home = new Intent(context, Home.class);
            startActivity(Home);
            System.exit(0);
        }
    }
}
{'fraction_non_alphanumeric': 0.0892991710625471, 'fraction_numerical': 0.0013187641296156744, 'mean_word_length': 3.604509973980919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5708245', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1292, 'n_words': 243}