// Path: library/src/main/java/com/felkertech/channelsurfer/sync/SyncUtils.java
// public class SyncUtils {
//     private static final String TAG = "cumulus:SyncUtils";
//     private static final String CONTENT_AUTHORITY = TvContract.AUTHORITY;
// 
//     public static void setUpPeriodicSync(Context context, String inputId) {
//         inputId = inputId==null?"":inputId;
//         Account account = DummyAccountService.getAccount(context);
//         AccountManager accountManager =
//                 (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
//         if (!accountManager.addAccountExplicitly(account, null, null)) {
//             Log.w(TAG, "Account already exists.");
// //            return;
//         }
//         Log.d(TAG, "Set sync with "+inputId);
//         ContentResolver.setIsSyncable(account, CONTENT_AUTHORITY, 1);
//         ContentResolver.setSyncAutomatically(account, CONTENT_AUTHORITY, true);
//         Bundle bundle = new Bundle();
//         bundle.putString(SyncAdapter.BUNDLE_KEY_INPUT_ID, inputId);
//         ContentResolver.addPeriodicSync(account, CONTENT_AUTHORITY, bundle,
//                 SyncAdapter.SYNC_FREQUENCY_SEC/6); //Sync every hour b/c why not?
//     }
// 
//     public static void requestSync(Context mContext, String inputId) {
//         inputId = inputId==null?"":inputId;
//         Bundle bundle = new Bundle();
//         bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
//         bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
//         bundle.putString(SyncAdapter.BUNDLE_KEY_INPUT_ID, inputId);
//         Log.d(TAG, "Request sync");
//         ContentResolver.requestSync(DummyAccountService.getAccount(mContext), CONTENT_AUTHORITY,
//                 bundle);
//     }
// }


import android.app.Activity;
import android.media.tv.TvInputInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.felkertech.channelsurfer.R;
import com.felkertech.channelsurfer.sync.SyncUtils;
package com.felkertech.channelsurfer.setup;




/**
 * Created by guest1 on 1/6/2016.
 */
public abstract class SetupTvInputProviderActivity extends Activity {
    private String TAG = "SetupTvInputProviderActivity";
    private String info;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        displayLayout();
        Log.d(TAG, "Created me");

        info = "";
        if(getIntent() != null) {
            info = getIntent().getStringExtra(TvInputInfo.EXTRA_INPUT_ID);
            Log.d(TAG, info+"");
        }

// Path: library/src/main/java/com/felkertech/channelsurfer/sync/SyncUtils.java
// public class SyncUtils {
//     private static final String TAG = "cumulus:SyncUtils";
//     private static final String CONTENT_AUTHORITY = TvContract.AUTHORITY;
// 
//     public static void setUpPeriodicSync(Context context, String inputId) {
//         inputId = inputId==null?"":inputId;
//         Account account = DummyAccountService.getAccount(context);
//         AccountManager accountManager =
//                 (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
//         if (!accountManager.addAccountExplicitly(account, null, null)) {
//             Log.w(TAG, "Account already exists.");
// //            return;
//         }
//         Log.d(TAG, "Set sync with "+inputId);
//         ContentResolver.setIsSyncable(account, CONTENT_AUTHORITY, 1);
//         ContentResolver.setSyncAutomatically(account, CONTENT_AUTHORITY, true);
//         Bundle bundle = new Bundle();
//         bundle.putString(SyncAdapter.BUNDLE_KEY_INPUT_ID, inputId);
//         ContentResolver.addPeriodicSync(account, CONTENT_AUTHORITY, bundle,
//                 SyncAdapter.SYNC_FREQUENCY_SEC/6); //Sync every hour b/c why not?
//     }
// 
//     public static void requestSync(Context mContext, String inputId) {
//         inputId = inputId==null?"":inputId;
//         Bundle bundle = new Bundle();
//         bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
//         bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
//         bundle.putString(SyncAdapter.BUNDLE_KEY_INPUT_ID, inputId);
//         Log.d(TAG, "Request sync");
//         ContentResolver.requestSync(DummyAccountService.getAccount(mContext), CONTENT_AUTHORITY,
//                 bundle);
//     }
// }


// Path: library/src/main/java/com/felkertech/channelsurfer/setup/SetupTvInputProviderActivity.java
import android.app.Activity;
import android.media.tv.TvInputInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.felkertech.channelsurfer.R;
import com.felkertech.channelsurfer.sync.SyncUtils;

package com.felkertech.channelsurfer.setup;




/**
 * Created by guest1 on 1/6/2016.
 */
public abstract class SetupTvInputProviderActivity extends Activity {
    private String TAG = "SetupTvInputProviderActivity";
    private String info;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        displayLayout();
        Log.d(TAG, "Created me");

        info = "";
        if(getIntent() != null) {
            info = getIntent().getStringExtra(TvInputInfo.EXTRA_INPUT_ID);
            Log.d(TAG, info+"");
        }

        SyncUtils.setUpPeriodicSync(this, info);