1 |
|
|
2 |
|
package pl.magot.vetch.ancal; |
3 |
|
|
4 |
|
|
5 |
|
import java.util.Calendar; |
6 |
|
|
7 |
|
import android.content.*; |
8 |
|
import android.content.pm.PackageInfo; |
9 |
|
import android.content.pm.PackageManager.NameNotFoundException; |
10 |
|
import android.view.View; |
11 |
|
import android.view.animation.AlphaAnimation; |
12 |
|
import android.view.animation.TranslateAnimation; |
13 |
|
import android.app.AlertDialog; |
14 |
|
|
15 |
|
|
|
|
| 53,8% |
Uncovered Elements: 30 (65) |
Complexity: 18 |
Complexity Density: 0,43 |
|
16 |
|
public class Utils |
17 |
|
{ |
18 |
|
private Context ctx = null; |
19 |
|
|
20 |
|
public static int ANIM_ALPHA_DURATION = 100; |
21 |
|
public static int ANIM_TRANSLATE_DURATION = 30; |
22 |
|
|
23 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
24 |
32
|
public Utils(Context context) {... |
25 |
32
|
ctx = context; |
26 |
|
} |
27 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
28 |
181
|
public String GetResStr(int id)... |
29 |
|
{ |
30 |
181
|
return ctx.getResources().getString(id); |
31 |
|
} |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
33 |
0
|
public void alert(String msg)... |
34 |
|
{ |
35 |
0
|
int iconId = 0; |
36 |
0
|
AlertDialog.Builder dlg = new AlertDialog.Builder(ctx); |
37 |
0
|
dlg.setMessage(msg); |
38 |
0
|
dlg.setPositiveButton(GetResStr(R.string.msgBoxButtonOk), null); |
39 |
0
|
dlg.setTitle(ctx.getClass().getName().toString()); |
40 |
0
|
dlg.setIcon(iconId); |
41 |
0
|
dlg.create(); |
42 |
0
|
dlg.show(); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
45 |
0
|
public void alert(int i)... |
46 |
|
{ |
47 |
0
|
Integer ii = i; |
48 |
0
|
alert(ii.toString()); |
49 |
|
} |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
51 |
0
|
public void ShowMsgResStr(int i, MessageType msgType)... |
52 |
|
{ |
53 |
0
|
AlertDialog.Builder dlg = new AlertDialog.Builder(ctx); |
54 |
0
|
dlg.setMessage(GetResStr(i)); |
55 |
0
|
dlg.setPositiveButton(GetResStr(R.string.msgBoxButtonOk), null); |
56 |
0
|
dlg.setTitle(msgType.getTitle()); |
57 |
0
|
dlg.setIcon(msgType.getIcon()); |
58 |
0
|
dlg.create(); |
59 |
0
|
dlg.show(); |
60 |
|
} |
61 |
|
|
|
|
| 81,8% |
Uncovered Elements: 2 (11) |
Complexity: 4 |
Complexity Density: 0,8 |
|
62 |
10
|
public static boolean YearDaysEqual(Calendar calDate, Calendar calDateTo)... |
63 |
|
{ |
64 |
10
|
if (calDate.get(Calendar.YEAR) == calDateTo.get(Calendar.YEAR)) |
65 |
9
|
if (calDate.get(Calendar.MONTH) == calDateTo.get(Calendar.MONTH)) |
66 |
9
|
if (calDate.get(Calendar.DAY_OF_MONTH) == calDateTo.get(Calendar.DAY_OF_MONTH)) |
67 |
9
|
return true; |
68 |
1
|
return false; |
69 |
|
} |
70 |
|
|
|
|
| 81,8% |
Uncovered Elements: 2 (11) |
Complexity: 4 |
Complexity Density: 0,8 |
|
71 |
6
|
public static boolean YearDaysGreater(Calendar calDate, Calendar calDateTo)... |
72 |
|
{ |
73 |
6
|
if (calDate.get(Calendar.YEAR) >= calDateTo.get(Calendar.YEAR)) |
74 |
3
|
if (calDate.get(Calendar.MONTH) >= calDateTo.get(Calendar.MONTH)) |
75 |
3
|
if (calDate.get(Calendar.DAY_OF_MONTH) >= calDateTo.get(Calendar.DAY_OF_MONTH)) |
76 |
3
|
return true; |
77 |
3
|
return false; |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
9
|
public static String CapitalizeFirstLetter(String sText)... |
81 |
|
{ |
82 |
9
|
return sText.substring(0,1).toUpperCase() + sText.substring(1, sText.length()).toLowerCase(); |
83 |
|
} |
84 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
|
85 |
1
|
public static String getAppVersionName(Context ctx)... |
86 |
|
{ |
87 |
1
|
try |
88 |
|
{ |
89 |
1
|
PackageInfo pi = ctx.getPackageManager().getPackageInfo("pl.magot.vetch.ancal", 0); |
90 |
1
|
return pi.versionName; |
91 |
|
} catch (NameNotFoundException e) { |
92 |
|
} |
93 |
0
|
return ""; |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
96 |
26
|
public static void startAlphaAnimIn(View view)... |
97 |
|
{ |
98 |
26
|
AlphaAnimation anim = new AlphaAnimation(0.5F, 1); |
99 |
26
|
anim.setDuration(ANIM_ALPHA_DURATION); |
100 |
26
|
anim.startNow(); |
101 |
26
|
view.startAnimation(anim); |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
104 |
0
|
public static void startTranslateAnimIn(View view)... |
105 |
|
{ |
106 |
0
|
TranslateAnimation anim = new TranslateAnimation(0, 0, - view.getHeight(), 0); |
107 |
0
|
anim.setDuration(ANIM_TRANSLATE_DURATION); |
108 |
0
|
anim.startNow(); |
109 |
0
|
view.startAnimation(anim); |
110 |
|
} |
111 |
|
|
112 |
|
} |