GroupAdd.java 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. package kr.co.icontrols.wallpadmain.popup;
  2. import com.artncore.wallpadapi.WallPadAPI;
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.graphics.Color;
  6. import android.util.Log;
  7. import android.view.Gravity;
  8. import android.view.MotionEvent;
  9. import android.view.View;
  10. import android.widget.RelativeLayout;
  11. import com.util.LogUtil;
  12. import kr.co.icontrols.wallpadmain.MainActivity;
  13. import kr.co.icontrols.wallpadmain.PopupActivity;
  14. import kr.co.icontrols.wallpadmain.R;
  15. import kr.co.icontrols.wallpadmain.declare.*;
  16. import kr.co.icontrols.wallpadmain.util.IconManager;
  17. import kr.co.icontrols.wallpadmain.declare.DataClasses.IconInfoTable;
  18. import kr.co.icontrols.wallpadmain.util.POSITION;
  19. import kr.co.icontrols.wallpadsupport.*;
  20. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  21. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  22. public class GroupAdd extends WpadScreen {
  23. String TAG = "GroupAdd";
  24. Context mContext;
  25. WallPadAPI mWallPadAPI;
  26. RelativeLayout mRelativeLayout;
  27. WpadImageView IMG_BACKGROUND;
  28. WpadImageView BTN_PREVIOUS;
  29. WpadImageView BTN_NEXT;
  30. WpadImageView BTN_CLOSE;
  31. WpadImageView [] BTN_SHORTCUT_ICON = new WpadImageView[8];
  32. WpadTextView [] TXT_SHORTCUT_NAME = new WpadTextView[8];
  33. WpadTextView TXT_TITLE;
  34. IconManager mIconManager;
  35. IconInfoTable mIconInfoTable;
  36. IconInfoTable mPopupIconTable;
  37. int nMAXPageNo = 1; // 아이콘 화면 페이지 수
  38. int nCurrentPageNo = 1; // 현재 페이지 번호
  39. int nMAXIconNoOnaPage = 8; // 한 화면에 들어가는 최대 아이콘 개수
  40. private int nLongKeyCnt = 0;
  41. private int nPreviousTargetID = 0;
  42. private int LONGKEY_THRESHOLD = 3;
  43. private int shortcutCnt = 0, shortcutMax = 0;
  44. int nTitleSize = 35;
  45. int nNameSize = 22;
  46. String strTitle = "부가";
  47. private void initInfo() {
  48. try {
  49. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  50. nTitleSize = 45;
  51. nNameSize = 30;
  52. }
  53. else {
  54. nTitleSize = 35;
  55. nNameSize = 22;
  56. }
  57. mPopupIconTable = new IconInfoTable();
  58. } catch (RuntimeException re) {
  59. LogUtil.errorLogInfo("", TAG, re);
  60. }
  61. catch (Exception e) {
  62. Log.e(TAG, "[Exception] initInfo()");
  63. //e.printStackTrace();
  64. LogUtil.errorLogInfo("", TAG, e);
  65. }
  66. }
  67. public GroupAdd(Context context, RelativeLayout layout, WallPadAPI wallpadapi) {
  68. super(context, layout);
  69. try {
  70. mContext = context;
  71. mWallPadAPI = wallpadapi;
  72. mRelativeLayout = layout;
  73. initInfo();
  74. Log.d(TAG, "[GroupAdd] ========== START ==========");
  75. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  76. IMG_BACKGROUND = new WpadImageView(context, TOUCH_KIND.NONE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).H, R.drawable.back_popup_05_1280, 0, ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND);
  77. ViewRegistration(layout, IMG_BACKGROUND, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).Y);
  78. BTN_PREVIOUS = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).H, R.drawable.popup_btn_previous_group_normal_1280, R.drawable.popup_btn_previous_group_pressed_1280, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS);
  79. ViewRegistration(layout, BTN_PREVIOUS, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).Y);
  80. BTN_PREVIOUS.setTouchDelayMs(500);
  81. BTN_PREVIOUS.setVisibility(View.INVISIBLE);
  82. BTN_NEXT = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).H, R.drawable.popup_btn_next_group_normal_1280, R.drawable.popup_btn_next_group_pressed_1280, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT);
  83. ViewRegistration(layout, BTN_NEXT, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).Y);
  84. BTN_NEXT.setTouchDelayMs(500);
  85. BTN_NEXT.setVisibility(View.INVISIBLE);
  86. BTN_CLOSE = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).H, R.drawable.popup_btn_close_group_normal_1280, R.drawable.popup_btn_close_group_pressed_1280, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE);
  87. ViewRegistration(layout, BTN_CLOSE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).Y);
  88. BTN_CLOSE.setTouchDelayMs(500);
  89. TXT_TITLE = new WpadTextView(context, false, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).H, Gravity.CENTER, Color.WHITE, nTitleSize, true, ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE);
  90. ViewRegistration(layout, TXT_TITLE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).Y);
  91. TXT_TITLE.setText(strTitle);
  92. // TXT_TITLE.setBackgroundColor(Color.RED);
  93. }
  94. else {
  95. IMG_BACKGROUND = new WpadImageView(context, TOUCH_KIND.NONE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).H, R.drawable.back_popup_05, 0, ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND);
  96. ViewRegistration(layout, IMG_BACKGROUND, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND).Y);
  97. BTN_PREVIOUS = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).H, R.drawable.popup_btn_previous_group_normal, R.drawable.popup_btn_previous_group_pressed, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS);
  98. ViewRegistration(layout, BTN_PREVIOUS, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS).Y);
  99. BTN_PREVIOUS.setTouchDelayMs(500);
  100. BTN_PREVIOUS.setVisibility(View.INVISIBLE);
  101. BTN_NEXT = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).H, R.drawable.popup_btn_next_group_normal, R.drawable.popup_btn_next_group_pressed, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT);
  102. ViewRegistration(layout, BTN_NEXT, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT).Y);
  103. BTN_NEXT.setTouchDelayMs(500);
  104. BTN_NEXT.setVisibility(View.INVISIBLE);
  105. BTN_CLOSE = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).H, R.drawable.popup_btn_close_group_normal, R.drawable.popup_btn_close_group_pressed, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE);
  106. ViewRegistration(layout, BTN_CLOSE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).Y);
  107. BTN_CLOSE.setTouchDelayMs(500);
  108. BTN_CLOSE = new WpadImageView(context, TOUCH_KIND.BUTTON, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).H, R.drawable.popup_btn_close_group_normal, R.drawable.popup_btn_close_group_pressed, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE);
  109. ViewRegistration(layout, BTN_CLOSE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE).Y);
  110. BTN_CLOSE.setTouchDelayMs(500);
  111. TXT_TITLE = new WpadTextView(context, false, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).H, Gravity.CENTER, Color.WHITE, nTitleSize, true, ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE);
  112. ViewRegistration(layout, TXT_TITLE, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE).Y);
  113. TXT_TITLE.setText(strTitle);
  114. // TXT_TITLE.setBackgroundColor(Color.RED);
  115. }
  116. getAddIcons(layout);
  117. } catch (RuntimeException re) {
  118. LogUtil.errorLogInfo("", TAG, re);
  119. }
  120. catch (Exception e) {
  121. Log.e(TAG, "[Exception] GroupAdd(Context context, RelativeLayout layout)");
  122. //e.printStackTrace();
  123. LogUtil.errorLogInfo("", TAG, e);
  124. }
  125. }
  126. @Override
  127. protected void onClose() {
  128. super.onClose();
  129. try {
  130. Log.d(TAG, "[GroupAdd] ========== onClose ==========");
  131. } catch (RuntimeException re) {
  132. LogUtil.errorLogInfo("", TAG, re);
  133. }
  134. catch (Exception e) {
  135. Log.e(TAG, "[Exception] onClose()");
  136. //e.printStackTrace();
  137. LogUtil.errorLogInfo("", TAG, e);
  138. }
  139. }
  140. @Override
  141. protected void onTouchEvent(View v, MotionEvent event) {
  142. super.onTouchEvent(v, event);
  143. try {
  144. int nTargetID = v.getId();
  145. int nEvent = event.getAction();
  146. if (nEvent == MotionEvent.ACTION_UP) {
  147. nLongKeyCnt = 0;
  148. if (nTargetID == ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE) {
  149. Sound().Play(SND.effect.TOUCH_LATCHED);
  150. super.finish();
  151. }
  152. else if (nTargetID == ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS) {
  153. Sound().Play(SND.effect.TOUCH_LATCHED);
  154. ctrlPageNo(false);
  155. updateScreen(mRelativeLayout);
  156. }
  157. else if (nTargetID == ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT) {
  158. Sound().Play(SND.effect.TOUCH_LATCHED);
  159. ctrlPageNo(true);
  160. updateScreen(mRelativeLayout);
  161. }
  162. else if (ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 <= nTargetID && nTargetID <= ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_08) {
  163. Sound().Play(SND.effect.TOUCH_LATCHED);
  164. int nIndex = (nTargetID - ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01) + ((nCurrentPageNo - 1) * nMAXIconNoOnaPage);
  165. Log.d(TAG, "[onTouchEvent] nIndex [" + nIndex + "]");
  166. int nIconID = mPopupIconTable.getIconInfoByIndex(nIndex).getIconID();
  167. Log.d(TAG, "[onTouchEvent] nIconID [" + nIconID + "]");
  168. setPopupResult(nIconID);
  169. super.finish();
  170. }
  171. }
  172. else if (nEvent == MotionEvent.ACTION_POINTER_DOWN) {
  173. if (ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 <= nTargetID && nTargetID <= ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_08) {
  174. if (nPreviousTargetID == nTargetID) {
  175. nLongKeyCnt++;
  176. Log.v(TAG, "[onTouchEvent] LongKey event [" + nTargetID + "], nLongKeyCnt [" + nLongKeyCnt + "]");
  177. if (nLongKeyCnt > LONGKEY_THRESHOLD) {
  178. nLongKeyCnt = 0;
  179. nPreviousTargetID = 0;
  180. if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  181. shortcutCnt = MainActivity.nShortcutCnt_HS;
  182. shortcutMax = MainActivity.nShortcutMax_HS;
  183. }
  184. else if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  185. shortcutCnt = MainActivity.nShortcutCnt_Metro;
  186. shortcutMax = MainActivity.nShortcutMax_Metro;
  187. }
  188. Log.v(TAG, "[onTouchEvent] shortcutCnt [" + shortcutCnt + "], shortcutMax [" + shortcutMax + "]");
  189. if (shortcutMax > 0) {
  190. if (shortcutCnt >= shortcutMax) {
  191. Log.w(TAG, "[onTouchEvent] No more Shortcuts allowed!!");
  192. ((PopupActivity) mContext).setChangeScreen(ID.POPUPS.POPUP_NOMORESHORTCUT, false);
  193. return;
  194. } else {
  195. addShortcut(nTargetID - ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01);
  196. }
  197. }
  198. }
  199. }
  200. else {
  201. nPreviousTargetID = nTargetID;
  202. nLongKeyCnt = 0;
  203. Log.v(TAG, "[onTouchEvent] LongKey event [" + nTargetID + "]");
  204. }
  205. }
  206. }
  207. } catch (RuntimeException re) {
  208. LogUtil.errorLogInfo("", TAG, re);
  209. }
  210. catch (Exception e) {
  211. Log.e(TAG, "[Exception] onTouchEvent(View v, MotionEvent event)");
  212. //e.printStackTrace();
  213. LogUtil.errorLogInfo("", TAG, e);
  214. }
  215. }
  216. private POSITION getPosition(int nID) {
  217. // LOG("[GetPosition] nID = " + nID);
  218. POSITION position = new POSITION();
  219. position.setGroupPopupPosition(117, 27, 790, 546);
  220. try {
  221. switch (nID) {
  222. case ID.POPUPS.GROUPADD.ELEMENTS.IMAGES.BACKGROUND:
  223. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(145, 60, 990, 680);
  224. else position.setGroupPopupPosition(117, 27, 790, 546);
  225. return position;
  226. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.PREVIOUS:
  227. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(353 , 60, 110, 90);
  228. else position.setGroupPopupPosition(297, 29, 75, 68);
  229. return position;
  230. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.NEXT:
  231. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(813 , 60, 110, 90);
  232. else position.setGroupPopupPosition(652, 29, 75, 68);
  233. return position;
  234. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.CLOSE:
  235. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(1048 , 67, 80, 80);
  236. else position.setGroupPopupPosition(830, 29, 75, 68);
  237. return position;
  238. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01:
  239. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(235, 228, 135, 135);
  240. else position.setGroupPopupPosition(185, 155, 108, 108);
  241. return position;
  242. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_02:
  243. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(460, 228, 135, 135);
  244. else position.setGroupPopupPosition(367, 155, 108, 108);
  245. return position;
  246. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_03:
  247. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(685, 228, 135, 135);
  248. else position.setGroupPopupPosition(549, 155, 108, 108);
  249. return position;
  250. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_04:
  251. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(910, 228, 135, 135);
  252. else position.setGroupPopupPosition(731, 155, 108, 108);
  253. return position;
  254. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_05:
  255. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(235, 457, 135, 135);
  256. else position.setGroupPopupPosition(185, 349, 108, 108);
  257. return position;
  258. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_06:
  259. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(460, 457, 135, 135);
  260. else position.setGroupPopupPosition(367, 349, 108, 108);
  261. return position;
  262. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_07:
  263. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(685, 457, 135, 135);
  264. else position.setGroupPopupPosition(549, 349, 108, 108);
  265. return position;
  266. case ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_08:
  267. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(910, 457, 135, 135);
  268. else position.setGroupPopupPosition(731, 349, 108, 108);
  269. return position;
  270. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.TITLE:
  271. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(463, 60, 350, 90);
  272. else position.setGroupPopupPosition(372, 29, 280, 68);
  273. return position;
  274. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_01:
  275. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(202, 363, 200, 80);
  276. else position.setGroupPopupPosition(149, 262, 180, 80);
  277. return position;
  278. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_02:
  279. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(427, 363, 200, 80);
  280. else position.setGroupPopupPosition(331, 262, 180, 80);
  281. return position;
  282. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_03:
  283. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(652, 363, 200, 80);
  284. else position.setGroupPopupPosition(513, 262, 180, 80);
  285. return position;
  286. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_04:
  287. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(877, 363, 200, 80);
  288. else position.setGroupPopupPosition(695, 262, 180, 80);
  289. return position;
  290. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_05:
  291. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(202, 592, 200, 80);
  292. else position.setGroupPopupPosition(149, 456, 180, 80);
  293. return position;
  294. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_06:
  295. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(427, 592, 200, 80);
  296. else position.setGroupPopupPosition(331, 456, 180, 80);
  297. return position;
  298. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_07:
  299. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(652, 592, 200, 80);
  300. else position.setGroupPopupPosition(513, 456, 180, 80);
  301. return position;
  302. case ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_08:
  303. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) position.setGroupPopupPosition(877, 592, 200, 80);
  304. else position.setGroupPopupPosition(695, 456, 180, 80);
  305. return position;
  306. default:
  307. return position;
  308. }
  309. } catch (RuntimeException re) {
  310. LogUtil.errorLogInfo("", TAG, re);
  311. return position;
  312. }
  313. catch (Exception e) {
  314. Log.e(TAG, "[Exception] getPosition(int nID)");
  315. //e.printStackTrace();
  316. LogUtil.errorLogInfo("", TAG, e);
  317. return position;
  318. }
  319. }
  320. private void getAddIcons(RelativeLayout layout) {
  321. try {
  322. mIconManager = new IconManager(mContext, mWallPadAPI);
  323. if (mIconManager == null) {
  324. Log.w(TAG, "[getAddIcons] mIconManager is null!!");
  325. return;
  326. }
  327. mIconInfoTable = mIconManager.getAvailableIcons();
  328. if (mIconInfoTable == null) {
  329. Log.w(TAG, "[getAddIcons] mIconInfoTable is null!!");
  330. return;
  331. }
  332. // mIconInfoTable.printValue();
  333. int nIconCnt = mIconInfoTable.getCnt();
  334. Log.w(TAG, "[getAddIcons] nIconCnt [" + nIconCnt + "]");
  335. for (int i = 0; i < nIconCnt; i++) {
  336. if ((mIconInfoTable.getIconInfoByIndex(i).getIconID() / 1000) == (ID.ICONS.MENU_ADD / 1000)) {
  337. Log.d(TAG, "[getAddIcons] i [" + i + "], ID [" + mIconInfoTable.getIconInfoByIndex(i).getIconID() + "], Name [" + mIconInfoTable.getIconInfoByIndex(i).getIconName() + "]");
  338. mPopupIconTable.addIconInfo(mIconInfoTable.getIconInfoByIndex(i));
  339. }
  340. }
  341. mPopupIconTable.printValue();
  342. getTotalPageNo();
  343. updateScreen(layout);
  344. } catch (RuntimeException re) {
  345. LogUtil.errorLogInfo("", TAG, re);
  346. }
  347. catch (Exception e) {
  348. Log.e(TAG, "[Exception] getAddIcons(RelativeLayout layout)");
  349. //e.printStackTrace();
  350. LogUtil.errorLogInfo("", TAG, e);
  351. }
  352. }
  353. private void updateScreen(RelativeLayout layout) {
  354. try {
  355. Log.i(TAG, "[updateScreen] nCurrentPageNo [" + nCurrentPageNo + "]");
  356. if (nMAXPageNo > 1) {
  357. strTitle = "부가 " + nCurrentPageNo + "/" + nMAXPageNo;
  358. BTN_PREVIOUS.setVisibility(View.VISIBLE);
  359. BTN_NEXT.setVisibility(View.VISIBLE);
  360. }
  361. else {
  362. strTitle = "부가";
  363. BTN_PREVIOUS.setVisibility(View.INVISIBLE);
  364. BTN_NEXT.setVisibility(View.INVISIBLE);
  365. }
  366. TXT_TITLE.setText(strTitle);
  367. for (int i = 0; i < nMAXIconNoOnaPage; i++) {
  368. if (BTN_SHORTCUT_ICON[i] != null) BTN_SHORTCUT_ICON[i].setVisibility(View.INVISIBLE);
  369. if (TXT_SHORTCUT_NAME[i] != null) TXT_SHORTCUT_NAME[i].setVisibility(View.INVISIBLE);
  370. }
  371. int nIconStartIndex = (nCurrentPageNo * nMAXIconNoOnaPage) - nMAXIconNoOnaPage;
  372. int nCurrentIconCnt = nMAXIconNoOnaPage;
  373. if (nCurrentPageNo >= nMAXPageNo) nCurrentIconCnt = ((mPopupIconTable.getCnt() % nMAXIconNoOnaPage) > 0) ? (mPopupIconTable.getCnt() % nMAXIconNoOnaPage) : nMAXIconNoOnaPage;
  374. else nCurrentIconCnt = nMAXIconNoOnaPage;
  375. int nIconEndIndex = ((nCurrentPageNo * nMAXIconNoOnaPage) - nMAXIconNoOnaPage) + nCurrentIconCnt;
  376. Log.i(TAG, "[updateScreen] nIconStartIndex [" + nIconStartIndex + "], nCurrentIconCnt [" + nCurrentIconCnt + "], nIconEndIndex [" + nIconEndIndex + "]");
  377. int nIndex = nIconStartIndex;
  378. for (int i = 0; i < nMAXIconNoOnaPage; i++) {
  379. Log.i(TAG, "[updateScreen] i [" + i + "], nIndex [" + nIndex + "]");
  380. if (i < nCurrentIconCnt) {
  381. BTN_SHORTCUT_ICON[i] = new WpadImageView(mContext, TOUCH_KIND.BUTTON_LC, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 + i).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 + i).H, mPopupIconTable.getIconInfoByIndex(nIndex).getNormalImage(), mPopupIconTable.getIconInfoByIndex(nIndex).getPressedImage(), ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 + i);
  382. ViewRegistration(layout, BTN_SHORTCUT_ICON[i], getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 + i).X, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 + i).Y);
  383. if(BTN_SHORTCUT_ICON[i]!=null) BTN_SHORTCUT_ICON[i].setTouchDelayMs(500);
  384. if(BTN_SHORTCUT_ICON[i]!=null) BTN_SHORTCUT_ICON[i].setVisibility(View.VISIBLE);
  385. TXT_SHORTCUT_NAME[i] = new WpadTextView(mContext, false, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_01 + i).W, getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_01 + i).H, Gravity.CENTER_HORIZONTAL, Color.WHITE, nNameSize, false, ID.POPUPS.GROUPADD.ELEMENTS.BTNS.ICON_01 + i);
  386. ViewRegistration(layout, TXT_SHORTCUT_NAME[i], getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_01 + i).X , getPosition(ID.POPUPS.GROUPADD.ELEMENTS.TEXTS.ICON_01 + i).Y);
  387. if(TXT_SHORTCUT_NAME[i]!=null) TXT_SHORTCUT_NAME[i].setText(mPopupIconTable.getIconInfoByIndex(nIndex).getIconName());
  388. if(TXT_SHORTCUT_NAME[i]!=null) TXT_SHORTCUT_NAME[i].setVisibility(View.VISIBLE);
  389. }
  390. nIndex++;
  391. }
  392. } catch (RuntimeException re) {
  393. LogUtil.errorLogInfo("", TAG, re);
  394. }
  395. catch (Exception e) {
  396. Log.e(TAG, "[Exception] updateScreen()");
  397. //e.printStackTrace();
  398. LogUtil.errorLogInfo("", TAG, e);
  399. }
  400. }
  401. private void getTotalPageNo() {
  402. try {
  403. Log.i(TAG, "[getTotalPageNo]");
  404. nMAXPageNo = mPopupIconTable.getCnt() / nMAXIconNoOnaPage;
  405. if ((mPopupIconTable.getCnt() % nMAXIconNoOnaPage) > 0) nMAXPageNo++;
  406. Log.i(TAG, "[getTotalPageNo] nMAXPageNo [" + nMAXPageNo + "]");
  407. } catch (RuntimeException re) {
  408. LogUtil.errorLogInfo("", TAG, re);
  409. }
  410. catch (Exception e) {
  411. Log.e(TAG, "[Exception] getTotalPageNo()");
  412. //e.printStackTrace();
  413. LogUtil.errorLogInfo("", TAG, e);
  414. }
  415. }
  416. private void ctrlPageNo(boolean bUp) {
  417. try {
  418. Log.i(TAG, "[ctrlPageNo] bUp: " + bUp);
  419. if (bUp) {
  420. nCurrentPageNo++;
  421. if (nCurrentPageNo > nMAXPageNo) nCurrentPageNo = 1;
  422. }
  423. else {
  424. nCurrentPageNo--;
  425. if (nCurrentPageNo < 1) nCurrentPageNo = nMAXPageNo;
  426. }
  427. } catch (RuntimeException re) {
  428. LogUtil.errorLogInfo("", TAG, re);
  429. }
  430. catch (Exception e) {
  431. Log.e(TAG, "[Exception] ctrlPageNo(boolean bUp)");
  432. //e.printStackTrace();
  433. LogUtil.errorLogInfo("", TAG, e);
  434. }
  435. }
  436. private void setPopupResult(int nIconID) {
  437. try {
  438. Intent intent = new Intent();
  439. intent.putExtra(Common.BR_SENDER_SCREEN, ID.POPUPS.POPUP_GROUP_ADD);
  440. intent.putExtra(Common.BR_RECEIVE_SCREEN, ID.SCREENS.SCREEN_METROUI_GROUP);
  441. intent.putExtra(Common.BR_RUN_WIDGET, true );
  442. intent.putExtra(Common.BR_RUN_WIDGET_ID , nIconID);
  443. super.setPopupResult(intent);
  444. } catch (RuntimeException re) {
  445. LogUtil.errorLogInfo("", TAG, re);
  446. }
  447. catch (Exception e) {
  448. Log.e(TAG, "[Exception] setPopupResult(int nIconID)");
  449. //e.printStackTrace();
  450. LogUtil.errorLogInfo("", TAG, e);
  451. }
  452. }
  453. public void addShortcut(int nTargetID) {
  454. try {
  455. Log.i(TAG, "[addShortcut] nTargetID = " + nTargetID);
  456. int nIndex = nTargetID + (nCurrentPageNo - 1) * nMAXIconNoOnaPage;
  457. Log.d(TAG, "[addShortcut] nIndex [" + nIndex + "]");
  458. int nIconID = mPopupIconTable.getIconInfoByIndex(nIndex).getIconID();
  459. Log.d(TAG, "[addShortcut] nIconID [" + nIconID + "]");
  460. if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  461. for (int i = 0; i < MainActivity.HSScreenShortcutList.size(); i++) {
  462. if (MainActivity.HSScreenShortcutList.get(i).widgetID == nIconID) {
  463. Log.w(TAG, "[addShortcut] Duplicated nShortcutID [" + nIconID + "]");
  464. ((PopupActivity) mContext).setChangeScreen(ID.POPUPS.POPUP_DUPLICATEDSHORTCUT, false);
  465. return;
  466. }
  467. }
  468. }
  469. else if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  470. for (int i = 0; i < MainActivity.MetroScreenShortcutList.size(); i++) {
  471. if (MainActivity.MetroScreenShortcutList.get(i).widgetID == nIconID) {
  472. Log.w(TAG, "[addShortcut] Duplicated nShortcutID [" + nIconID + "]");
  473. ((PopupActivity) mContext).setChangeScreen(ID.POPUPS.POPUP_DUPLICATEDSHORTCUT, false);
  474. return;
  475. }
  476. }
  477. }
  478. Intent mIntent = new Intent();
  479. mIntent.putExtra(Common.WIDGET_SELECTED_ID, nIconID);
  480. ((PopupActivity) mContext).ChangeScreen(ID.POPUPS.POPUP_ADDSHORTCUT, mIntent);
  481. } catch (RuntimeException re) {
  482. LogUtil.errorLogInfo("", TAG, re);
  483. } catch (Exception e) {
  484. Log.e(TAG, "[Exception] addShortcut(int nIndex)");
  485. //e.printStackTrace();
  486. LogUtil.errorLogInfo("", TAG, e);
  487. }
  488. }
  489. }