/*
 * ConnectBot: simple, powerful, open-source SSH client for Android
 * Copyright 2010 Kenny Root, Jeffrey Sharkey
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.connectbot.service;

import org.connectbot.util.PreferenceConstants;

import android.annotation.TargetApi;
import android.app.backup.BackupManager;
import android.content.Context;

/**
 * This is only invoked on Froyo and beyond.
 */
@TargetApi(8)
public abstract class BackupWrapper {
	public static BackupWrapper getInstance() {
		if (PreferenceConstants.PRE_FROYO)
			return PreFroyo.Holder.sInstance;
		else
			return FroyoAndBeyond.Holder.sInstance;
	}

	public abstract void onDataChanged(Context context);

	private static class PreFroyo extends BackupWrapper {
		private static class Holder {
			private static final PreFroyo sInstance = new PreFroyo();
		}

		@Override
		public void onDataChanged(Context context) {
			// do nothing for now
		}
	}

	private static class FroyoAndBeyond extends BackupWrapper {
		private static class Holder {
			private static final FroyoAndBeyond sInstance = new FroyoAndBeyond();
		}

		private static BackupManager mBackupManager;

		@Override
		public void onDataChanged(Context context) {
			checkBackupManager(context);
			if (mBackupManager != null) {
				mBackupManager.dataChanged();
			}
		}

		private void checkBackupManager(Context context) {
			if (mBackupManager == null) {
				mBackupManager = new BackupManager(context);
			}
		}
	}
}

@@ -923,344 +923,37 @@
  */%0A
-@TargetApi(8)%0Apublic abstract class BackupWrapper %7B%0A%09public static BackupWrapper getInstance() %7B%0A%09%09if (PreferenceConstants.PRE_FROYO)%0A%09%09%09return PreFroyo.Holder.sInstance;%0A%09%09else%0A%09%09%09return FroyoAndBeyond.Holder.sInstance;%0A%09%7D%0A%0A%09public abstract void onDataChanged(Context context);%0A%0A%09private static class PreFroyo extends BackupWrapper %7B%0A%09
+public class BackupWrapper %7B%0A
 %09pri
@@ -971,33 +971,32 @@
  class Holder %7B%0A
-%09
 %09%09private static
@@ -1002,24 +1002,29 @@
 c final 
-PreFroyo
+BackupWrapper
  sInstan
@@ -1036,289 +1036,136 @@
 new 
-PreFroyo
+BackupWrapper
 ();%0A
-%09
 %09%7D%0A%0A%09
-%09@Override%0A%09%09public void onDataChanged(Context context) %7B%0A%09%09%09// do nothing for now%0A%09%09%7D%0A%09%7D%0A%0A%09private static class FroyoAndBeyond extends BackupWrapper %7B%0A%09%09private static class Holder
+private BackupWrapper() %7B%0A%09%7D%0A%0A%09public static BackupWrapper getInstance()
  %7B%0A%09%09
-%09
-private static final FroyoAndBeyond sInstance = new FroyoAndBeyond()
+return Holder.sInstance
 ;%0A
-%09
 %09%7D%0A%0A
-%09
 %09pri
@@ -1211,21 +1211,8 @@
 r;%0A%0A
-%09%09@Override%0A%09
 %09pub
@@ -1255,17 +1255,16 @@
 xt) %7B%0A%09%09
-%09
 checkBac
@@ -1284,17 +1284,16 @@
 ntext);%0A
-%09
 %09%09if (mB
@@ -1311,33 +1311,32 @@
 r != null) %7B%0A%09%09%09
-%09
 mBackupManager.d
@@ -1353,19 +1353,16 @@
 ();%0A
-%09
 %09%09%7D%0A
-%09
 %09%7D%0A%0A
-%09
 %09pri
@@ -1409,17 +1409,16 @@
 text) %7B%0A
-%09
 %09%09if (mB
@@ -1444,17 +1444,16 @@
 l) %7B%0A%09%09%09
-%09
 mBackupM
@@ -1493,13 +1493,8 @@
 t);%0A
-%09%09%09%7D%0A
 %09%09%7D%0A

remove compat code