package com.olmatix.ui.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.olmatix.service.OlmatixService;

/**
 * Created by Lesjaw on 04/12/2016.
 */

public class SplashActivity extends AppCompatActivity {


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

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
        String mServerURL = sharedPref.getString("server_address", "cloud.olmatix.com");
        Log.d("DEBUG", "Server Address 1: " + mServerURL);
        String mServerPort = sharedPref.getString("server_port", "1883");
        Log.d("DEBUG", "Server Port 1: " + mServerPort);
        String mUserName = sharedPref.getString("user_name", "olmatix1");
        Log.d("DEBUG", "User Name 1: " + mUserName);
        String mPassword = sharedPref.getString("password", "olmatix");
        Log.d("DEBUG", "Password 1: " + mPassword);


        Intent i = new Intent(this, OlmatixService.class);
        startService(i);

        if (mUserName.equals("olmatix1") ) {
            Intent intent = new Intent(this, SettingsActivity.class);
            startActivity(intent);

        } else {
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
        }
        finish();
    }



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

    }
}

@@ -54,125 +54,14 @@
 ent.
-BroadcastReceiver;%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.content.IntentFilter
+Intent
 ;%0Aim
@@ -223,77 +223,8 @@
 ity;
-%0Aimport android.util.Log;%0A%0Aimport com.olmatix.service.OlmatixService;
 %0A%0A/*
@@ -323,16 +323,40 @@
 vity %7B%0A%0A
+    int flagReceiver =0;
 %0A    @Ov
@@ -649,67 +649,8 @@
 %22);%0A
-        Log.d(%22DEBUG%22, %22Server Address 1: %22 + mServerURL);%0A
     
@@ -723,65 +723,8 @@
 %22);%0A
-        Log.d(%22DEBUG%22, %22Server Port 1: %22 + mServerPort);%0A
     
@@ -797,61 +797,8 @@
 %22);%0A
-        Log.d(%22DEBUG%22, %22User Name 1: %22 + mUserName);%0A
     
@@ -861,24 +861,195 @@
 %22olmatix%22);%0A
+        /*Log.d(%22DEBUG%22, %22Server Address 1: %22 + mServerURL);%0A        Log.d(%22DEBUG%22, %22Server Port 1: %22 + mServerPort);%0A        Log.d(%22DEBUG%22, %22User Name 1: %22 + mUserName);%0A
         Log.
@@ -1088,18 +1088,57 @@
 sword);%0A
+*/
 %0A%0A
+        /*if (flagReceiver==0) %7B%0A    
         
@@ -1192,24 +1192,28 @@
 s);%0A        
+    
 startService
@@ -1216,16 +1216,124 @@
 vice(i);
+%0A            flagReceiver =1;%0A            Log.d(%22SplashActivity = %22, %22Starting OlmatixService%22);%0A        %7D*/
 %0A%0A      

remove starting service from this