package com.android.busolo.apps.wardrobe.engine;

import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;

import com.android.busolo.apps.wardrobe.sync.SyncHelper;
import com.android.busolo.apps.wardrobe.utils.AccountUtils;
import com.android.busolo.apps.wardrobe.utils.LogUtils;
import com.android.busolo.apps.wardrobe.utils.PrefUtils;
import com.android.busolo.apps.wardrobe.utils.UIUtils;

import static com.android.busolo.apps.wardrobe.utils.LogUtils.makeLogTag;

public class BaseActivity extends ActionBarActivity {
    private static final String TAG = makeLogTag(BaseActivity.class);

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

        //TODO check logged-in status

        if (!AccountUtils.isAuthenticated(this) || !PrefUtils.isSetupDone(this)) {
            LogUtils.LOGE(TAG, "exiting:"
                    + " isAuthenticated=" + AccountUtils.isAuthenticated(this)
                    + " isSetupDone=" + PrefUtils.isSetupDone(this));
            AccountUtils.startAuthenticationFlow(this, getIntent());//IF NO auth DO
            finish();
        }
    }

    protected void setHasTabs() {
        if (!UIUtils.isTablet(this)
                && getResources().getConfiguration().orientation
                != Configuration.ORIENTATION_LANDSCAPE) {
            // Only show the tab bar's shadow
            getSupportActionBar().setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(R.color.accent_1)));
        }
    }

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

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
    }
}
