<commit_before>package com.bytemesoftware.wear.faces.binary;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.wearable.view.WatchViewStub;
import android.util.Log;
import android.view.View;

import com.bytemesoftware.wear.faces.binary.time.Minutes;
import com.bytemesoftware.wear.faces.binary.time.Hours;
import com.bytemesoftware.wear.faces.binary.time.Seconds;

import java.util.Calendar;

public class WatchFaceActivity extends Activity {

    private int TICK_INTERVAL = 950;

    private Handler mHandler;

    private View rootView;

    private IntentFilter filter;
    private IntentFilter dotColorChangedIntentfilter;

    private BroadcastReceiver timeUpdateReceiver;
    private BroadcastReceiver dotColorChangedReceiver;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_watch_face);

        // get the watch face stud. This is loaded asynchronously.
        final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
        stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
            @Override
            public void onLayoutInflated(WatchViewStub stub) {
                rootView = stub.getRootView(); // set the root view of the face
                setBright(); // set the mode to bright
                startRepeatingTask(); // start the seconds animation
            }
        });

        // create te handler for the seconds animation
        mHandler = new Handler(Looper.getMainLooper());

        // create the needed receivers
        initReceivers();
    }

    private void initReceivers() {
        // create the intent filter for the time tick action
        filter = new IntentFilter(Intent.ACTION_TIME_TICK);

        // create the reciever
        timeUpdateReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
                    updateCompleteTime();

                    // if we are not dimmed, then restart the seconds animation
                    if (!isDimmed()) {
                        restartRepeatingTask();
                    }
                }
            }
        };

        // create the intent filter for the time tick action
        dotColorChangedIntentfilter = new IntentFilter(Constants.DOT_COLOR_RECIEVED_ACTION);

        // create the receiver
        dotColorChangedReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (Constants.DOT_COLOR_RECIEVED_ACTION.equals(intent.getAction())) {
                    updateCompleteTime();
                    startRepeatingTask();
                }
            }
        };
    }

    @Override
    protected void onStart() {
        super.onStart();

        // attach the time receiver to listen for time ticks.
        this.registerReceiver(timeUpdateReceiver, filter);
        this.registerReceiver(dotColorChangedReceiver, dotColorChangedIntentfilter);
    }

    @Override
    protected void onResume() {
        super.onResume();

        // wWen we resume, we are going to a bright state.
        // There is state where there is not a watch face does not have a view yet.
        // The guard prevents trying to update views that do not exist.
        if (rootView != null) {
            setBright();
        }<commit_msg>the time change receiver can now respond to time set and time zone changes.<commit_after>package com.bytemesoftware.wear.faces.binary;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.wearable.view.WatchViewStub;
import android.util.Log;
import android.view.View;

import com.bytemesoftware.wear.faces.binary.time.Minutes;
import com.bytemesoftware.wear.faces.binary.time.Hours;
import com.bytemesoftware.wear.faces.binary.time.Seconds;

import java.util.Calendar;

public class WatchFaceActivity extends Activity {

    private int TICK_INTERVAL = 950;

    private Handler mHandler;

    private View rootView;

    private IntentFilter timeTickFilter;
    private IntentFilter timeChangedFilter;
    private IntentFilter timeZoneChnagedFilter;
    private IntentFilter dotColorChangedIntentFilter;

    private BroadcastReceiver timeUpdateReceiver;
    private BroadcastReceiver dotColorChangedReceiver;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_watch_face);

        // get the watch face stud. This is loaded asynchronously.
        final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
        stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
            @Override
            public void onLayoutInflated(WatchViewStub stub) {
                rootView = stub.getRootView(); // set the root view of the face
                setBright(); // set the mode to bright
                startRepeatingTask(); // start the seconds animation
            }
        });

        // create te handler for the seconds animation
        mHandler = new Handler(Looper.getMainLooper());

        // create the needed receivers
        initReceivers();
    }

    private void initReceivers() {
        // create the intent filter for the time tick action
        timeTickFilter = new IntentFilter(Intent.ACTION_TIME_TICK);
        timeChangedFilter = new IntentFilter(Intent.ACTION_TIME_CHANGED);
        timeZoneChnagedFilter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);

        // create the reciever
        timeUpdateReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
                    updateCompleteTime();

                    // if we are not dimmed, then restart the seconds animation
                    if (!isDimmed()) {
                        restartRepeatingTask();
                    }
                }
            }
        };

        // create the intent filter for the time tick action
        dotColorChangedIntentFilter = new IntentFilter(Constants.DOT_COLOR_RECIEVED_ACTION);

        // create the receiver
        dotColorChangedReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (Constants.DOT_COLOR_RECIEVED_ACTION.equals(intent.getAction())) {
                    updateCompleteTime();
                    startRepeatingTask();
                }
            }
        };
    }

    @Override
    protected void onStart() {
        super.onStart();

        // attach the time receiver to listen for time ticks.
        this.registerReceiver(timeUpdateReceiver, timeTickFilter);
        this.registerReceiver(timeUpdateReceiver, timeChangedFilter);
        this.registerReceiver(timeUpdateReceiver, timeZoneChnagedFilter);
        this.registerReceiver(dotColorChangedReceiver, dotColorChangedIntentFilter);
    }

    @Override
    protected void onResume() {
        super.onResume();

        // wWen we resume, we are going to a bright state.
        // There is state where there is not a watch face does not have a view yet.
        // The guard prevents trying to update views that do not exist.
        if (rootView != null) {
            setBright();
        }
{'fraction_non_alphanumeric': 0.07440290108790797, 'fraction_numerical': 0.0007502813555083156, 'mean_word_length': 2.4474137931034483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6349098', 'n_tokens_mistral': 2052, 'n_tokens_neox': 1971, 'n_words': 547}