EMMA Coverage Report (generated Fri Jul 31 17:53:12 CEST 2015)
[all classes][net.mandaria.tippytipper.activities]

COVERAGE SUMMARY FOR SOURCE FILE [Total.java]

nameclass, %method, %block, %line, %
Total.java100% (8/8)88%  (30/34)93%  (825/888)93%  (182,8/197)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Total$4100% (1/1)50%  (2/4)45%  (9/20)43%  (3/7)
onStartTrackingTouch (SeekBar): void 0%   (0/1)0%   (0/1)0%   (0/1)
onStopTrackingTouch (SeekBar): void 0%   (0/1)0%   (0/4)0%   (0/2)
onProgressChanged (SeekBar, int, boolean): void 100% (1/1)33%  (3/9)67%  (2/3)
Total$4 (Total): void 100% (1/1)100% (6/6)100% (1/1)
     
class Total100% (1/1)89%  (16/18)93%  (681/733)94%  (147,8/158)
access$400 (Total): void 0%   (0/1)0%   (0/3)0%   (0/1)
tipPercentageSliderOnStopTouch (): void 0%   (0/1)0%   (0/47)0%   (0/9)
onOptionsItemSelected (MenuItem): boolean 100% (1/1)93%  (25/27)88%  (7/8)
Total (): void 100% (1/1)100% (3/3)100% (1/1)
access$000 (Total): void 100% (1/1)100% (3/3)100% (1/1)
access$100 (Total): void 100% (1/1)100% (3/3)100% (1/1)
access$200 (Total): void 100% (1/1)100% (3/3)100% (1/1)
access$300 (Total, Double): void 100% (1/1)100% (4/4)100% (1/1)
bindData (): void 100% (1/1)100% (165/165)100% (34/34)
calculateTip (Double): void 100% (1/1)100% (30/30)100% (8/8)
onCreate (Bundle): void 100% (1/1)100% (58/58)100% (13/13)
onCreateOptionsMenu (Menu): boolean 100% (1/1)100% (15/15)100% (5/5)
onStart (): void 100% (1/1)100% (106/106)100% (20/20)
onStop (): void 100% (1/1)100% (5/5)100% (3/3)
refreshBillAmount (): void 100% (1/1)100% (45/45)100% (12/12)
roundDown (): void 100% (1/1)100% (74/74)100% (16/16)
roundUp (): void 100% (1/1)100% (74/74)100% (16/16)
splitBillWithDefaultNumberOfPeople (): void 100% (1/1)100% (68/68)100% (13/13)
     
class Total$1100% (1/1)100% (2/2)100% (22/22)100% (5/5)
Total$1 (Total): void 100% (1/1)100% (6/6)100% (1/1)
onClick (View): void 100% (1/1)100% (16/16)100% (4/4)
     
class Total$2100% (1/1)100% (2/2)100% (10/10)100% (3/3)
Total$2 (Total): void 100% (1/1)100% (6/6)100% (1/1)
onClick (View): void 100% (1/1)100% (4/4)100% (2/2)
     
class Total$3100% (1/1)100% (2/2)100% (10/10)100% (3/3)
Total$3 (Total): void 100% (1/1)100% (6/6)100% (1/1)
onClick (View): void 100% (1/1)100% (4/4)100% (2/2)
     
class Total$5100% (1/1)100% (2/2)100% (31/31)100% (7/7)
Total$5 (Total): void 100% (1/1)100% (6/6)100% (1/1)
onClick (View): void 100% (1/1)100% (25/25)100% (6/6)
     
class Total$6100% (1/1)100% (2/2)100% (31/31)100% (7/7)
Total$6 (Total): void 100% (1/1)100% (6/6)100% (1/1)
onClick (View): void 100% (1/1)100% (25/25)100% (6/6)
     
class Total$7100% (1/1)100% (2/2)100% (31/31)100% (7/7)
Total$7 (Total): void 100% (1/1)100% (6/6)100% (1/1)
onClick (View): void 100% (1/1)100% (25/25)100% (6/6)

1package net.mandaria.tippytipper.activities;
2 
3import java.util.HashMap;
4import java.util.Map;
5 
6import com.flurry.android.FlurryAgent;
7 
8import net.mandaria.tippytipper.R;
9import net.mandaria.tippytipper.TippyTipperApplication;
10import android.app.Activity;
11import android.content.Intent;
12import android.os.Bundle;
13import android.view.*;
14import android.view.View.OnClickListener;
15import android.widget.*;
16import android.widget.SeekBar.OnSeekBarChangeListener;
17 
18public class Total extends Activity {
19 
20        /** Called when the activity is first created. */
21    @Override
22    public void onCreate(Bundle savedInstanceState) {
23        super.onCreate(savedInstanceState);
24        setContentView(R.layout.total);
25        
26        TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
27        
28        calculateTip(appState.service.getTipPercentageAsDouble());
29        
30        View btn_SplitBill = findViewById(R.id.btn_SplitBill);
31        btn_SplitBill.setOnClickListener(new OnClickListener() 
32                {
33                    public void onClick(View v) 
34                    {
35                            splitBillWithDefaultNumberOfPeople();
36                            
37                            Intent i = new Intent(getBaseContext(), SplitBill.class);
38                            startActivity(i);
39                    }
40            });
41//        Drawable d_SplitBill = findViewById(R.id.btn_SplitBill).getBackground();
42//        int green = Color.parseColor("#216C2A");
43//        PorterDuffColorFilter filter_green = new PorterDuffColorFilter(green, PorterDuff.Mode.SRC_ATOP);
44//        d_SplitBill.setColorFilter(filter_green);
45                
46        View btn_round_down = findViewById(R.id.btn_round_down);
47        btn_round_down.setOnClickListener(new OnClickListener() 
48                {
49                    public void onClick(View v) 
50                    {
51                            roundDown();
52                    }
53            });
54        
55        View btn_round_up = findViewById(R.id.btn_round_up);
56        btn_round_up.setOnClickListener(new OnClickListener() 
57                {
58                    public void onClick(View v) 
59                    {
60                            roundUp();
61                    }
62            });
63                
64                SeekBar seek_tip_percentage = (SeekBar)findViewById(R.id.seek_tip_percentage);
65                seek_tip_percentage.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
66                        {        
67                                @Override
68                                public void onProgressChanged(SeekBar seekBar, int progress,
69                                                boolean fromUser)
70                                {
71                                        if(fromUser)
72                                        {
73                                                calculateTip((double)progress);
74                                        }
75                                }
76 
77                                @Override
78                                public void onStartTrackingTouch(SeekBar seekBar)
79                                {
80                                        // TODO Auto-generated method stub
81                                        
82                                }
83 
84                                @Override
85                                public void onStopTrackingTouch(SeekBar seekBar)
86                                {
87                                        tipPercentageSliderOnStopTouch();
88                                }
89                        });
90                
91    }
92    
93    /* Called after onCreate or onRestart */
94        @Override
95        public void onStart()
96        {
97                super.onStart();
98                boolean enableErrorLogging = Settings.getEnableErrorLogging(getBaseContext());
99        String API = getString(R.string.flurrykey);
100        if(!API.equals("") && enableErrorLogging == true)
101                {
102                        FlurryAgent.setContinueSessionMillis(30000);
103                        FlurryAgent.onStartSession(this, API);
104                }
105                
106                refreshBillAmount();
107                
108                Button btn_TipAmount1 = (Button)findViewById(R.id.btn_TipAmount1);
109        double tipPercentagePresetOne = Settings.getTipPercentagePresetOne(getBaseContext());
110        btn_TipAmount1.setText((int)tipPercentagePresetOne + "%");
111        btn_TipAmount1.setOnClickListener(new OnClickListener() 
112            {
113                public void onClick(View v) 
114                {
115                        double tipPercentagePresetOne = Settings.getTipPercentagePresetOne(getBaseContext());
116                        calculateTip(tipPercentagePresetOne);
117                        
118                        Map<String, String> params = new HashMap<String, String>();
119                        params.put("Tip Percentage Preset", String.valueOf(tipPercentagePresetOne));
120                        FlurryAgent.onEvent("Tip Preset One Button", params);
121                }
122        });
123        
124        Button btn_TipAmount2 = (Button)findViewById(R.id.btn_TipAmount2);
125        double tipPercentagePresetTwo = Settings.getTipPercentagePresetTwo(getBaseContext());
126        btn_TipAmount2.setText((int)tipPercentagePresetTwo + "%");
127        btn_TipAmount2.setOnClickListener(new OnClickListener() 
128            {
129                public void onClick(View v) 
130                {
131                        double tipPercentagePresetTwo = Settings.getTipPercentagePresetTwo(getBaseContext());
132                        calculateTip(tipPercentagePresetTwo);
133                        
134                        Map<String, String> params = new HashMap<String, String>();
135                        params.put("Tip Percentage Preset", String.valueOf(tipPercentagePresetTwo));
136                        FlurryAgent.onEvent("Tip Preset Two Button", params);
137                }
138        });
139        
140        Button btn_TipAmount3 = (Button)findViewById(R.id.btn_TipAmount3);
141        double tipPercentagePresetThree = Settings.getTipPercentagePresetThree(getBaseContext());
142        btn_TipAmount3.setText((int)tipPercentagePresetThree + "%");
143        btn_TipAmount3.setOnClickListener(new OnClickListener() 
144            {
145                public void onClick(View v) 
146                {
147                        double tipPercentagePresetThree = Settings.getTipPercentagePresetThree(getBaseContext());
148                        calculateTip(tipPercentagePresetThree);
149                        
150                        Map<String, String> params = new HashMap<String, String>();
151                        params.put("Tip Percentage Preset", String.valueOf(tipPercentagePresetThree));
152                        FlurryAgent.onEvent("Tip Preset Three Button", params);
153                }
154        });
155        }
156        
157         @Override
158        public void onStop()
159    {
160       super.onStop();
161       FlurryAgent.onEndSession(this);
162    }
163    
164    @Override
165          public boolean onCreateOptionsMenu(Menu menu)
166          {
167                  super.onCreateOptionsMenu(menu);
168                  MenuInflater inflater = getMenuInflater();
169                  inflater.inflate(R.menu.menu, menu);
170                  FlurryAgent.onEvent("Menu Button");
171                  return true;
172          }
173 
174          @Override
175          public boolean onOptionsItemSelected(MenuItem item)
176          {
177                  switch(item.getItemId())
178                  {
179                          case R.id.settings:
180                                  startActivity(new Intent(this, Settings.class));
181                                  FlurryAgent.onEvent("Settings Button");
182                                  return true;
183                          case R.id.about:
184                                  startActivity(new Intent(this, About.class));
185                                  FlurryAgent.onEvent("About Button");
186                                return true;
187                  }
188                  return false;
189          }
190          
191          private void tipPercentageSliderOnStopTouch()
192          {
193                  TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
194                Map<String, String> params = new HashMap<String, String>();
195                params.put("Bill Amount", appState.service.getBillAmount());
196                params.put("Tax Amount", appState.service.getTaxAmount());
197                params.put("Tip Amount", appState.service.getTipAmount());
198                params.put("Tip Percentage", appState.service.getTipPercentage());
199                params.put("Tax Percentage", appState.service.getTaxPercentage());
200                
201                FlurryAgent.onEvent("Tip Percentage Slider", params);
202          }
203          
204          private void splitBillWithDefaultNumberOfPeople()
205          {
206                  TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
207                  int numberOfPeople = Settings.getDefaultNumberOfPeopleToSplitBill(getBaseContext());
208                  
209                  Map<String, String> params = new HashMap<String, String>();
210                params.put("Default Number Of People", String.valueOf(numberOfPeople));
211                params.put("Bill Amount", appState.service.getBillAmount());
212                params.put("Tax Amount", appState.service.getTaxAmount());
213                params.put("Tip Amount", appState.service.getTipAmount());
214                params.put("Total Amount", appState.service.getTotalAmount());
215                params.put("Tip Percentage", appState.service.getTipPercentage());
216                params.put("Tax Percentage", appState.service.getTaxPercentage());
217                FlurryAgent.onEvent("Split Bill Button", params);
218                
219                appState.service.splitBill(numberOfPeople);
220          }
221    
222    private void calculateTip(Double percent)
223    {
224                TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
225                float excludeTaxRate = Settings.getExcludeTaxRate(getBaseContext());
226                boolean enableExcludeTaxRate = Settings.getEnableExcludeTaxRate(getBaseContext());
227                if(enableExcludeTaxRate == false)
228                        excludeTaxRate = 0;
229                
230                //appState.service.CalculateTip(percent/100.0);
231                appState.service.calculateTip(percent/100.0, excludeTaxRate/100.0);
232 
233                bindData();
234    }
235    
236    private void roundDown()
237    {
238            TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
239            boolean roundTip = Settings.isSetToRoundByTip(getBaseContext());
240            
241            String preRoundTipAmount = appState.service.getTipAmount();
242            String preRoundTotalAmount = appState.service.getTotalAmount();
243            
244            appState.service.roundDown(roundTip);
245            
246            Map<String, String> params = new HashMap<String, String>();
247                params.put("Round Tip", String.valueOf(roundTip));
248                params.put("Pre Round Tip Amount", preRoundTipAmount);
249                params.put("Pre Round Total Amount", preRoundTotalAmount);
250                params.put("Bill Amount", appState.service.getBillAmount());
251                params.put("Tax Amount", appState.service.getTaxAmount());
252                params.put("Tip Amount", appState.service.getTipAmount());
253                params.put("Total Amount", appState.service.getTotalAmount());
254            FlurryAgent.onEvent("Round Down Button", params);
255            
256            bindData();
257    }
258    
259    private void roundUp()
260    {
261            TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
262            boolean roundTip = Settings.isSetToRoundByTip(getBaseContext());
263            
264            String preRoundTipAmount = appState.service.getTipAmount();
265            String preRoundTotalAmount = appState.service.getTotalAmount();
266            
267            appState.service.roundUp(roundTip);
268            
269            Map<String, String> params = new HashMap<String, String>();
270                params.put("Round Tip", String.valueOf(roundTip));
271                params.put("Pre Round Tip Amount", preRoundTipAmount);
272                params.put("Pre Round Total Amount", preRoundTotalAmount);
273                params.put("Bill Amount", appState.service.getBillAmount());
274                params.put("Tax Amount", appState.service.getTaxAmount());
275                params.put("Tip Amount", appState.service.getTipAmount());
276                params.put("Total Amount", appState.service.getTotalAmount());
277            FlurryAgent.onEvent("Round Up Button", params);
278            
279            bindData();
280    }
281    
282    public void refreshBillAmount()
283    {
284            TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
285                double tipPercent = appState.service.getTipPercentageAsDouble();
286                float excludeTaxRate = Settings.getExcludeTaxRate(getBaseContext());
287                boolean enableExcludeTaxRate = Settings.getEnableExcludeTaxRate(getBaseContext());
288                if(enableExcludeTaxRate == false)
289                        excludeTaxRate = 0;
290                
291                if(excludeTaxRate == 0)
292                {
293                        appState.service.refreshBillAmount();
294                        appState.service.calculateTip(appState.service.getTipPercentageAsDouble()/100.0, excludeTaxRate);
295                        bindData();
296                }
297                else
298                        calculateTip(tipPercent);
299    }
300    
301    private void bindData()
302    {
303            TippyTipperApplication appState = ((TippyTipperApplication)this.getApplication());
304            
305            TextView lbl_bill_amount = (TextView)findViewById(R.id.lbl_bill_amount);
306                TextView lbl_tip_amount = (TextView)findViewById(R.id.lbl_tip_amount);
307                TextView lbl_total_amount = (TextView)findViewById(R.id.lbl_total_amount);
308                //TextView lbl_tip_percentage = (TextView)findViewById(R.id.lbl_tip_percentage);
309                SeekBar seek_tip_percentage = (SeekBar)findViewById(R.id.seek_tip_percentage);
310                View inflated_excludetax = findViewById(R.id.inflated_excludeTax);
311                TextView lbl_tip_text = (TextView)findViewById(R.id.lbl_tip_text);
312                
313                float excludeTaxRate = Settings.getExcludeTaxRate(getBaseContext());
314                boolean enableExcludeTaxRate = Settings.getEnableExcludeTaxRate(getBaseContext());
315                if(enableExcludeTaxRate == false)
316                        excludeTaxRate = 0;
317                
318                if(excludeTaxRate != 0)
319                {
320                        ViewStub stub_excludeTax = (ViewStub)findViewById(R.id.stub_excludeTax);
321                        if(stub_excludeTax != null)
322                                stub_excludeTax.setVisibility(View.VISIBLE);
323                        else if(inflated_excludetax != null)
324                                inflated_excludetax.setVisibility(View.VISIBLE);
325                        TextView lbl_tax_amount = (TextView)findViewById(R.id.lbl_tax_amount);
326                        lbl_tax_amount.setText(appState.service.getTaxAmount());
327                        
328                        // Add (tax%): to label
329                        TextView lbl_tax_text = (TextView)findViewById(R.id.lbl_tax_text);
330                        String tax_text = lbl_tax_text.getText().toString();
331                        if(!tax_text.contains(appState.service.getTaxPercentage()))
332                                lbl_tax_text.setText(this.getString(R.string.tax).replace(":", " (" + appState.service.getTaxPercentage() + "):"));
333                }
334                else
335                {
336                        if(inflated_excludetax != null)
337                                inflated_excludetax.setVisibility(View.GONE);
338                }
339 
340                // Add (tip%): to label
341                String tip_text = lbl_tip_text.getText().toString();
342                if(!tip_text.contains(appState.service.getTipPercentage()))
343                        lbl_tip_text.setText(this.getString(R.string.tip).replace(":", " (" + appState.service.getTipPercentage() + "):"));
344                
345                //lbl_tip_percentage.setText(appState.service.GetTipPercentage());
346                lbl_bill_amount.setText(appState.service.getBillAmount());
347                lbl_tip_amount.setText(appState.service.getTipAmount());
348                lbl_total_amount.setText(appState.service.getTotalAmount());
349                seek_tip_percentage.setProgress(appState.service.getTipPercentageRounded());
350    }
351}

[all classes][net.mandaria.tippytipper.activities]
EMMA 2.0.5312 (C) Vladimir Roubtsov