package pl.srw.billcalculator.di;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Environment;
import android.preference.PreferenceManager;

import java.io.File;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import pl.srw.billcalculator.R;
import pl.srw.billcalculator.data.settings.prices.PricesRepo;
import pl.srw.billcalculator.data.settings.prices.PricesRepoImpl;
import pl.srw.billcalculator.settings.prices.PgePrices;
import pl.srw.billcalculator.settings.prices.PgnigPrices;
import pl.srw.billcalculator.settings.prices.SharedPrefsPrices;
import pl.srw.billcalculator.settings.prices.TauronPrices;
import pl.srw.billcalculator.type.Provider;

@Module
public class ApplicationModule {

    public static final String GLOBAL_SHARED_PREFS = "global";
    public static final String SHARED_PREFERENCES_FILE = "PreferencesFile";
    //    private static final String DEFAULT_SHARED_PREFS = "default";

    private final Context context;

    public ApplicationModule(Context context) {
        this.context = context;
    }

    @Provides
    @Singleton
//    @Named(DEFAULT_SHARED_PREFS) does not work (with map dependency?)
    SharedPreferences provideDefaultSharedPreferences() {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }

    @Provides(type = Provides.Type.MAP)
    @Singleton
    @DependencyMapProviderKey(Provider.PGE)
    SharedPrefsPrices providePgeSharedPreferencesPrices(SharedPreferences prefs) {
        return new PgePrices(prefs);
    }

    @Provides(type = Provides.Type.MAP)
    @Singleton
    @DependencyMapProviderKey(Provider.PGNIG)
    SharedPrefsPrices providePgnigSharedPreferencesPrices(SharedPreferences prefs) {
        return new PgnigPrices(prefs);
    }

    @Provides(type = Provides.Type.MAP)
    @Singleton
    @DependencyMapProviderKey(Provider.TAURON)
    SharedPrefsPrices provideTauronSharedPreferencesPrices(SharedPreferences prefs) {
        return new TauronPrices(prefs);
    }

    @Provides
    @Singleton
    @Named(GLOBAL_SHARED_PREFS)
    SharedPreferences provideSharedPreferences() {
        return context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
    }

    @Provides
    @Singleton
    Provider[] providerProviders() {
        return Provider.values();
    }

    @Provides
    @Singleton
    String providePrintPathDir() {
        return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + context.getString(R.string.print_dir);
    }

    @Provides
    @Singleton
    Resources provideResources() {
        return context.getResources();
    }

    @Provides
    @Singleton
    PricesRepo providePricesRepo(PricesRepoImpl repo) {
        return repo;
    }
}

@@ -1499,24 +1499,31 @@
 er.PGE)%0A    
+static 
 SharedPrefsP
@@ -1581,32 +1581,32 @@
 rences prefs) %7B%0A
-
         return n
@@ -1734,24 +1734,31 @@
 .PGNIG)%0A    
+static 
 SharedPrefsP
@@ -1974,24 +1974,31 @@
 TAURON)%0A    
+static 
 SharedPrefsP
@@ -2354,20 +2354,27 @@
 ngleton%0A
-
     
+static 
 Provider

Make Dagger module methods static