Search in sources :

Example 1 with SightServiceConnector

use of sugar.free.sightparser.handling.SightServiceConnector in project SightRemote by TebbeUbben.

the class SightRemote method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    instance = this;
    Fabric.with(this, new Crashlytics());
    PreferenceManager.setDefaultValues(this, R.xml.settings, true);
    NotificationCenter.setupUpChannels();
    serviceConnector = new SightServiceConnector(this);
    serviceConnector.connectToService();
    ContextCompat.startForegroundService(this, new Intent(this, OngoingNotificationService.class));
    startService(new Intent(this, SightService.class));
    startService(new Intent(this, HistorySyncService.class));
    startService(new Intent(this, AlertService.class));
    if (Preferences.getBooleanPref(Preferences.PREF_BOOLEAN_AUTO_ADJUST_TIME))
        startService(new Intent(this, TimeSynchronizationService.class));
}
Also used : HistorySyncService(sugar.free.sightremote.services.HistorySyncService) AlertService(sugar.free.sightremote.services.AlertService) Intent(android.content.Intent) OngoingNotificationService(sugar.free.sightremote.services.OngoingNotificationService) SightService(sugar.free.sightparser.handling.SightService) Crashlytics(com.crashlytics.android.Crashlytics) SightServiceConnector(sugar.free.sightparser.handling.SightServiceConnector)

Example 2 with SightServiceConnector

use of sugar.free.sightparser.handling.SightServiceConnector in project SightRemote by TebbeUbben.

the class ACLReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    String mac = ((BluetoothDevice) intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE")).getAddress();
    SightServiceConnector serviceConnector = SightRemote.getInstance().getServiceConnector();
    if (serviceConnector.isConnectedToService())
        serviceConnector.aclDisconnect(mac);
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) SightServiceConnector(sugar.free.sightparser.handling.SightServiceConnector)

Example 3 with SightServiceConnector

use of sugar.free.sightparser.handling.SightServiceConnector in project SightRemote by TebbeUbben.

the class HistorySyncService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    if (pendingIntent == null)
        PendingIntent.getBroadcast(this, 0, new Intent(HistoryBroadcast.ACTION_START_SYNC), 0);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "HistorySyncService");
    connector = new SightServiceConnector(this);
    connector.addStatusCallback(this);
    connector.setConnectionCallback(this);
    final IntentFilter intentFilter = new IntentFilter(HistoryBroadcast.ACTION_START_SYNC);
    intentFilter.addAction(HistoryBroadcast.ACTION_START_RESYNC);
    getApplicationContext().registerReceiver(broadcastReceiver, intentFilter);
    if (pendingIntent != null)
        alarmManager.cancel(pendingIntent);
    if (getBooleanPref(PREF_BOOLEAN_BACKGROUND_SYNC_ENABLED)) {
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, AlarmManager.INTERVAL_FIFTEEN_MINUTES, AlarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent);
    }
    return START_STICKY;
}
Also used : IntentFilter(android.content.IntentFilter) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) HistorySendIntent(sugar.free.sightremote.utils.HistorySendIntent) SightServiceConnector(sugar.free.sightparser.handling.SightServiceConnector)

Example 4 with SightServiceConnector

use of sugar.free.sightparser.handling.SightServiceConnector in project SightRemote by TebbeUbben.

the class OngoingNotificationService method onCreate.

@Override
public void onCreate() {
    serviceConnector = new SightServiceConnector(this);
    serviceConnector.setConnectionCallback(new ServiceConnectionCallback() {

        @Override
        public void onServiceConnected() {
            statusChanged(serviceConnector.getStatus());
        }

        @Override
        public void onServiceDisconnected() {
            statusChanged(Status.DISCONNECTED);
        }
    });
    serviceConnector.addStatusCallback(this::statusChanged);
    serviceConnector.connectToService();
}
Also used : ServiceConnectionCallback(sugar.free.sightparser.handling.ServiceConnectionCallback) SightServiceConnector(sugar.free.sightparser.handling.SightServiceConnector)

Example 5 with SightServiceConnector

use of sugar.free.sightparser.handling.SightServiceConnector in project SightRemote by TebbeUbben.

the class SightActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getRootLayout());
    setupToolbar();
    drawerLayout = findViewById(R.id.drawer_layout);
    navigationView = findViewById(R.id.navigation_view);
    contentFrame = findViewById(R.id.content_frame);
    if (useNavigationDrawer() && drawerLayout != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_navigation, R.string.close_navigation);
        drawerLayout.addDrawerListener(actionBarDrawerToggle);
        navigationView.setNavigationItemSelectedListener(this);
        if (getSelectedNavItemID() != 0)
            navigationView.getMenu().findItem(getSelectedNavItemID()).setChecked(true);
    } else if (drawerLayout != null)
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    hideOverlay();
    sightServiceConnector = new SightServiceConnector(this);
    sightServiceConnector.setConnectionCallback(connectionCallback);
    sightServiceConnector.addStatusCallback(statusCallback);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) SightServiceConnector(sugar.free.sightparser.handling.SightServiceConnector)

Aggregations

SightServiceConnector (sugar.free.sightparser.handling.SightServiceConnector)7 Intent (android.content.Intent)2 PendingIntent (android.app.PendingIntent)1 BluetoothDevice (android.bluetooth.BluetoothDevice)1 IntentFilter (android.content.IntentFilter)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 Crashlytics (com.crashlytics.android.Crashlytics)1 ServiceConnectionCallback (sugar.free.sightparser.handling.ServiceConnectionCallback)1 SightService (sugar.free.sightparser.handling.SightService)1 AlertService (sugar.free.sightremote.services.AlertService)1 HistorySyncService (sugar.free.sightremote.services.HistorySyncService)1 OngoingNotificationService (sugar.free.sightremote.services.OngoingNotificationService)1 HistorySendIntent (sugar.free.sightremote.utils.HistorySendIntent)1