| 1 | package net.mandaria.tippytipper.activities; |
| 2 | |
| 3 | import com.flurry.android.FlurryAgent; |
| 4 | |
| 5 | import net.mandaria.tippytipper.R; |
| 6 | import android.os.Bundle; |
| 7 | import android.preference.*; |
| 8 | import android.content.Context; |
| 9 | |
| 10 | public class Settings extends PreferenceActivity |
| 11 | { |
| 12 | |
| 13 | @Override |
| 14 | protected void onCreate(Bundle savedInstanceState) |
| 15 | { |
| 16 | super.onCreate(savedInstanceState); |
| 17 | addPreferencesFromResource(R.xml.settings); |
| 18 | } |
| 19 | |
| 20 | @Override |
| 21 | public void onStart() |
| 22 | { |
| 23 | super.onStart(); |
| 24 | boolean enableErrorLogging = Settings.getEnableErrorLogging(getBaseContext()); |
| 25 | String API = getString(R.string.flurrykey); |
| 26 | if(!API.equals("") && enableErrorLogging == true) |
| 27 | { |
| 28 | FlurryAgent.setContinueSessionMillis(30000); |
| 29 | FlurryAgent.onStartSession(this, API); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public void onStop() |
| 35 | { |
| 36 | super.onStop(); |
| 37 | FlurryAgent.onEndSession(this); |
| 38 | } |
| 39 | |
| 40 | public static int getDefaultTipPercentage(Context context) |
| 41 | { |
| 42 | return PreferenceManager.getDefaultSharedPreferences(context).getInt("default_tip_percentage", 15); |
| 43 | } |
| 44 | |
| 45 | public static int getTipPercentagePresetOne(Context context) |
| 46 | { |
| 47 | return PreferenceManager.getDefaultSharedPreferences(context).getInt("tip_percentage_one", 10); |
| 48 | } |
| 49 | |
| 50 | public static int getTipPercentagePresetTwo(Context context) |
| 51 | { |
| 52 | return PreferenceManager.getDefaultSharedPreferences(context).getInt("tip_percentage_two", 15); |
| 53 | } |
| 54 | |
| 55 | public static int getTipPercentagePresetThree(Context context) |
| 56 | { |
| 57 | return PreferenceManager.getDefaultSharedPreferences(context).getInt("tip_percentage_three", 20); |
| 58 | } |
| 59 | |
| 60 | public static int getDefaultNumberOfPeopleToSplitBill(Context context) |
| 61 | { |
| 62 | return PreferenceManager.getDefaultSharedPreferences(context).getInt("default_number_of_people", 2); |
| 63 | } |
| 64 | |
| 65 | public static boolean getEnableErrorLogging(Context context) |
| 66 | { |
| 67 | return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_error_logging", true); |
| 68 | } |
| 69 | |
| 70 | public static boolean getEnableExcludeTaxRate(Context context) |
| 71 | { |
| 72 | return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_exclude_tax_rate", false); |
| 73 | } |
| 74 | |
| 75 | public static boolean isSetToRoundByTip(Context context) |
| 76 | { |
| 77 | String RoundType = PreferenceManager.getDefaultSharedPreferences(context).getString("round_type", "round_total"); |
| 78 | if(RoundType.equals("round_tip")) |
| 79 | { |
| 80 | return true; |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | return false; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | public static float getExcludeTaxRate(Context context) |
| 89 | { |
| 90 | return PreferenceManager.getDefaultSharedPreferences(context).getFloat("exclude_tax", 0); |
| 91 | } |
| 92 | } |