Merge lp:~trb143/openlp/android_dev into lp:openlp/android
- android_dev
- Merge into trunk
Proposed by
Tim Bentley
Status: | Merged |
---|---|
Merged at revision: | 50 |
Proposed branch: | lp:~trb143/openlp/android_dev |
Merge into: | lp:openlp/android |
Diff against target: |
4597 lines (+2154/-2181) 20 files modified
src/org/openlp/android/OpenLP.java (+61/-61) src/org/openlp/android/activity/DefaultActivity.java (+20/-20) src/org/openlp/android/activity/OpenLPNavigate.java (+36/-34) src/org/openlp/android/activity/PagerActivity.java (+35/-35) src/org/openlp/android/activity/Search.java (+2/-2) src/org/openlp/android/activity/SearchService.java (+3/-3) src/org/openlp/android/activity/SearchableActivity.java (+235/-238) src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java (+331/-331) src/org/openlp/android/activity/preference/Preferences.java (+95/-94) src/org/openlp/android/api/Api.java (+36/-28) src/org/openlp/android/data/Poll.java (+95/-95) src/org/openlp/android/data/SlideItem.java (+42/-42) src/org/openlp/android/service/PingIntent.java (+55/-55) src/org/openlp/android/utility/GroupExpandableListAdapter.java (+87/-88) src/org/openlp/android/utility/JSONHandler.java (+128/-135) src/org/openlp/android/utility/OpenLPController.java (+548/-567) src/org/openlp/android/utility/OpenLPHttpClient.java (+154/-154) src/org/openlp/android/utility/SlideAdapter.java (+94/-95) src/org/openlp/android/utility/StringHelper.java (+20/-23) src/org/openlp/android/utility/WebCallReturningAsyncTask.java (+77/-81) |
To merge this branch: | bzr merge lp:~trb143/openlp/android_dev |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Johan Mynhardt | Approve | ||
Review via email: mp+167382@code.launchpad.net |
Commit message
Description of the change
Code style cleanup only using Intelij
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/org/openlp/android/OpenLP.java' | |||
2 | --- src/org/openlp/android/OpenLP.java 2013-04-06 13:44:51 +0000 | |||
3 | +++ src/org/openlp/android/OpenLP.java 2013-06-04 19:32:29 +0000 | |||
4 | @@ -37,65 +37,65 @@ | |||
5 | 37 | */ | 37 | */ |
6 | 38 | public class OpenLP extends DefaultActivity { | 38 | public class OpenLP extends DefaultActivity { |
7 | 39 | 39 | ||
69 | 40 | /** | 40 | /** |
70 | 41 | * Called when the activity is first created. | 41 | * Called when the activity is first created. |
71 | 42 | */ | 42 | */ |
72 | 43 | @Override | 43 | @Override |
73 | 44 | public void onCreate(Bundle savedInstanceState) { | 44 | public void onCreate(Bundle savedInstanceState) { |
74 | 45 | super.onCreate(savedInstanceState); | 45 | super.onCreate(savedInstanceState); |
75 | 46 | setContentView(R.layout.main); | 46 | setContentView(R.layout.main); |
76 | 47 | 47 | ||
77 | 48 | doPreferenceCheck(); | 48 | doPreferenceCheck(); |
78 | 49 | setOnClickListenerPagerForButtons(); | 49 | setOnClickListenerPagerForButtons(); |
79 | 50 | } | 50 | } |
80 | 51 | 51 | ||
81 | 52 | private View.OnClickListener onClickListenerPager = | 52 | private View.OnClickListener onClickListenerPager = |
82 | 53 | new View.OnClickListener() { | 53 | new View.OnClickListener() { |
83 | 54 | @Override | 54 | @Override |
84 | 55 | public void onClick(View view) { | 55 | public void onClick(View view) { |
85 | 56 | Intent pager = new Intent(OpenLP.this, PagerActivity.class); | 56 | Intent pager = new Intent(OpenLP.this, PagerActivity.class); |
86 | 57 | pager.putExtra(OpenLPController.PAGE_KEY, getPageForButton(view)); | 57 | pager.putExtra(OpenLPController.PAGE_KEY, getPageForButton(view)); |
87 | 58 | startActivity(pager); | 58 | startActivity(pager); |
88 | 59 | } | 59 | } |
89 | 60 | }; | 60 | }; |
90 | 61 | 61 | ||
91 | 62 | private void doPreferenceCheck() { | 62 | private void doPreferenceCheck() { |
92 | 63 | if (getSharedPreferences(getString(R.string.keySharedPreferences), | 63 | if (getSharedPreferences(getString(R.string.keySharedPreferences), |
93 | 64 | Context.MODE_PRIVATE).getString(getString(R.string.keyHost), | 64 | Context.MODE_PRIVATE).getString(getString(R.string.keyHost), |
94 | 65 | "NONE").equals("NONE") | 65 | "NONE").equals("NONE") |
95 | 66 | || getSharedPreferences( | 66 | || getSharedPreferences( |
96 | 67 | getString(R.string.keySharedPreferences), | 67 | getString(R.string.keySharedPreferences), |
97 | 68 | Context.MODE_PRIVATE).getString( | 68 | Context.MODE_PRIVATE).getString( |
98 | 69 | getString(R.string.keyHost), null).equals(null)) { | 69 | getString(R.string.keyHost), null).equals(null)) { |
99 | 70 | Log.d(LOG_TAG, | 70 | Log.d(LOG_TAG, |
100 | 71 | "URL preference not set. Starting preference activity..."); | 71 | "URL preference not set. Starting preference activity..."); |
101 | 72 | Intent preferenceIntent = new Intent(this, Preferences.class); | 72 | Intent preferenceIntent = new Intent(this, Preferences.class); |
102 | 73 | startActivity(preferenceIntent); | 73 | startActivity(preferenceIntent); |
103 | 74 | } | 74 | } |
104 | 75 | } | 75 | } |
105 | 76 | 76 | ||
106 | 77 | private void setOnClickListenerPagerForButtons() { | 77 | private void setOnClickListenerPagerForButtons() { |
107 | 78 | findViewById(R.id.buttonService) | 78 | findViewById(R.id.buttonService) |
108 | 79 | .setOnClickListener(onClickListenerPager); | 79 | .setOnClickListener(onClickListenerPager); |
109 | 80 | findViewById(R.id.buttonLive) | 80 | findViewById(R.id.buttonLive) |
110 | 81 | .setOnClickListener(onClickListenerPager); | 81 | .setOnClickListener(onClickListenerPager); |
111 | 82 | findViewById(R.id.buttonDisplay) | 82 | findViewById(R.id.buttonDisplay) |
112 | 83 | .setOnClickListener(onClickListenerPager); | 83 | .setOnClickListener(onClickListenerPager); |
113 | 84 | findViewById(R.id.buttonAlert) | 84 | findViewById(R.id.buttonAlert) |
114 | 85 | .setOnClickListener(onClickListenerPager); | 85 | .setOnClickListener(onClickListenerPager); |
115 | 86 | findViewById(R.id.buttonStage) | 86 | findViewById(R.id.buttonStage) |
116 | 87 | .setOnClickListener(onClickListenerPager); | 87 | .setOnClickListener(onClickListenerPager); |
117 | 88 | findViewById(R.id.buttonSearch) | 88 | findViewById(R.id.buttonSearch) |
118 | 89 | .setOnClickListener(onClickListenerSearch); | 89 | .setOnClickListener(onClickListenerSearch); |
119 | 90 | } | 90 | } |
120 | 91 | 91 | ||
121 | 92 | private View.OnClickListener onClickListenerSearch = | 92 | private View.OnClickListener onClickListenerSearch = |
122 | 93 | new View.OnClickListener() { | 93 | new View.OnClickListener() { |
123 | 94 | @Override | 94 | @Override |
124 | 95 | public void onClick(View view) { | 95 | public void onClick(View view) { |
125 | 96 | onSearchRequested(); | 96 | onSearchRequested(); |
126 | 97 | } | 97 | } |
127 | 98 | }; | 98 | }; |
128 | 99 | 99 | ||
129 | 100 | private final String LOG_TAG = OpenLP.class.getName(); | 100 | private final String LOG_TAG = OpenLP.class.getName(); |
130 | 101 | } | 101 | } |
131 | 102 | 102 | ||
132 | === modified file 'src/org/openlp/android/activity/DefaultActivity.java' | |||
133 | --- src/org/openlp/android/activity/DefaultActivity.java 2013-04-06 13:44:51 +0000 | |||
134 | +++ src/org/openlp/android/activity/DefaultActivity.java 2013-06-04 19:32:29 +0000 | |||
135 | @@ -31,25 +31,25 @@ | |||
136 | 31 | 31 | ||
137 | 32 | 32 | ||
138 | 33 | public abstract class DefaultActivity extends Activity implements Api { | 33 | public abstract class DefaultActivity extends Activity implements Api { |
145 | 34 | @Override | 34 | @Override |
146 | 35 | public boolean onCreateOptionsMenu(Menu menu) { | 35 | public boolean onCreateOptionsMenu(Menu menu) { |
147 | 36 | MenuInflater inflater = getMenuInflater(); | 36 | MenuInflater inflater = getMenuInflater(); |
148 | 37 | inflater.inflate(R.menu.menu, menu); | 37 | inflater.inflate(R.menu.menu, menu); |
149 | 38 | return true; | 38 | return true; |
150 | 39 | } | 39 | } |
151 | 40 | 40 | ||
166 | 41 | @Override | 41 | @Override |
167 | 42 | public boolean onOptionsItemSelected(MenuItem item) { | 42 | public boolean onOptionsItemSelected(MenuItem item) { |
168 | 43 | // Handle item selection | 43 | // Handle item selection |
169 | 44 | switch (item.getItemId()) { | 44 | switch (item.getItemId()) { |
170 | 45 | case R.id.preferences: | 45 | case R.id.preferences: |
171 | 46 | startActivity(new Intent(this, Preferences.class)); | 46 | startActivity(new Intent(this, Preferences.class)); |
172 | 47 | return true; | 47 | return true; |
173 | 48 | case R.id.menuSearch: | 48 | case R.id.menuSearch: |
174 | 49 | onSearchRequested(); | 49 | onSearchRequested(); |
175 | 50 | return true; | 50 | return true; |
176 | 51 | default: | 51 | default: |
177 | 52 | return super.onOptionsItemSelected(item); | 52 | return super.onOptionsItemSelected(item); |
178 | 53 | } | 53 | } |
179 | 54 | } | 54 | } |
180 | 55 | } | 55 | } |
181 | 56 | 56 | ||
182 | === modified file 'src/org/openlp/android/activity/OpenLPNavigate.java' | |||
183 | --- src/org/openlp/android/activity/OpenLPNavigate.java 2013-04-06 13:44:51 +0000 | |||
184 | +++ src/org/openlp/android/activity/OpenLPNavigate.java 2013-06-04 19:32:29 +0000 | |||
185 | @@ -27,38 +27,40 @@ | |||
186 | 27 | */ | 27 | */ |
187 | 28 | public interface OpenLPNavigate extends Api { | 28 | public interface OpenLPNavigate extends Api { |
188 | 29 | 29 | ||
223 | 30 | public final String NAVIGATE_PREVIOUS = "previous"; | 30 | public final String NAVIGATE_PREVIOUS = "previous"; |
224 | 31 | public final String NAVIGATE_NEXT = "next"; | 31 | public final String NAVIGATE_NEXT = "next"; |
225 | 32 | public final String HIDE_SCREEN = "blank"; | 32 | public final String HIDE_SCREEN = "blank"; |
226 | 33 | public final String HIDE_THEME = "theme"; | 33 | public final String HIDE_THEME = "theme"; |
227 | 34 | public final String HIDE_DESKTOP = "desktop"; | 34 | public final String HIDE_DESKTOP = "desktop"; |
228 | 35 | public final String DISPLAY_SHOW = "show"; | 35 | public final String DISPLAY_SHOW = "show"; |
229 | 36 | 36 | ||
230 | 37 | /** | 37 | /** |
231 | 38 | * Call to the service changing service/slides. | 38 | * Call to the service changing service/slides. |
232 | 39 | * | 39 | * |
233 | 40 | * @param direction A direction constant from {@link org.openlp.android.api.Api}. | 40 | * @param direction A direction constant from {@link org.openlp.android.api.Api}. |
234 | 41 | * Eg.: {@link org.openlp.android.api.Api#LIVE_NEXT} | 41 | * Eg.: {@link org.openlp.android.api.Api#LIVE_NEXT} |
235 | 42 | * or {@link org.openlp.android.api.Api#SERVICE_BASE} + previous/next. | 42 | * or {@link org.openlp.android.api.Api#SERVICE_BASE} + previous/next. |
236 | 43 | */ | 43 | */ |
237 | 44 | void navigate(String direction); | 44 | void navigate(String direction); |
238 | 45 | 45 | ||
239 | 46 | /** | 46 | /** |
240 | 47 | * Call to the service changing data for Service or Live | 47 | * Call to the service changing data for Service or Live |
241 | 48 | * | 48 | * |
242 | 49 | * @param apiPart An {@link org.openlp.android.api.Api} part for which to set data. | 49 | * @param apiPart An {@link org.openlp.android.api.Api} part for which to set data. |
243 | 50 | * Eg.: {@link org.openlp.android.api.Api#LIVE_SET} | 50 | * Eg.: {@link org.openlp.android.api.Api#LIVE_SET} |
244 | 51 | * or {@link org.openlp.android.api.Api#SERVICE_SET} | 51 | * or {@link org.openlp.android.api.Api#SERVICE_SET} |
245 | 52 | * @param id Id of the item selected. | 52 | * @param id Id of the item selected. |
246 | 53 | */ | 53 | */ |
247 | 54 | void setData(String apiPart, int id); | 54 | void setData(String apiPart, int id); |
248 | 55 | 55 | ||
249 | 56 | void setDisplay(String displayRequest); | 56 | void setDisplay(String displayRequest); |
250 | 57 | void poll(); | 57 | |
251 | 58 | 58 | void poll(); | |
252 | 59 | /** | 59 | |
253 | 60 | * Replaces what we previously had as FetchItemsTask which basically ran in the UI | 60 | /** |
254 | 61 | * @param apiPart Items to fetch, eg.: {@link Api#LIVE_TEXT} or {@link Api#SERVICE_LIST} | 61 | * Replaces what we previously had as FetchItemsTask which basically ran in the UI |
255 | 62 | */ | 62 | * |
256 | 63 | void fetchItems(String apiPart); | 63 | * @param apiPart Items to fetch, eg.: {@link Api#LIVE_TEXT} or {@link Api#SERVICE_LIST} |
257 | 64 | */ | ||
258 | 65 | void fetchItems(String apiPart); | ||
259 | 64 | } | 66 | } |
260 | 65 | 67 | ||
261 | === modified file 'src/org/openlp/android/activity/PagerActivity.java' | |||
262 | --- src/org/openlp/android/activity/PagerActivity.java 2013-04-06 13:44:51 +0000 | |||
263 | +++ src/org/openlp/android/activity/PagerActivity.java 2013-06-04 19:32:29 +0000 | |||
264 | @@ -28,39 +28,39 @@ | |||
265 | 28 | import org.openlp.android.utility.OpenLPController; | 28 | import org.openlp.android.utility.OpenLPController; |
266 | 29 | 29 | ||
267 | 30 | public class PagerActivity extends DefaultActivity { | 30 | public class PagerActivity extends DefaultActivity { |
303 | 31 | private ViewPager pager; | 31 | private ViewPager pager; |
304 | 32 | private OpenLPController controller; | 32 | private OpenLPController controller; |
305 | 33 | 33 | ||
306 | 34 | @Override | 34 | @Override |
307 | 35 | protected void onCreate(Bundle savedInstanceState) { | 35 | protected void onCreate(Bundle savedInstanceState) { |
308 | 36 | super.onCreate(savedInstanceState); | 36 | super.onCreate(savedInstanceState); |
309 | 37 | Log.i(LOG_TAG, "onCreate"); | 37 | Log.i(LOG_TAG, "onCreate"); |
310 | 38 | 38 | ||
311 | 39 | setContentView(R.layout.view_pager_layout); | 39 | setContentView(R.layout.view_pager_layout); |
312 | 40 | 40 | ||
313 | 41 | controller = new OpenLPController(this); | 41 | controller = new OpenLPController(this); |
314 | 42 | pager = (ViewPager) findViewById(R.id.myViewPager); | 42 | pager = (ViewPager) findViewById(R.id.myViewPager); |
315 | 43 | pager.setAdapter(controller); | 43 | pager.setAdapter(controller); |
316 | 44 | 44 | ||
317 | 45 | Intent intent = getIntent(); | 45 | Intent intent = getIntent(); |
318 | 46 | int selectedPage = intent.getIntExtra(OpenLPController.PAGE_KEY, 0); | 46 | int selectedPage = intent.getIntExtra(OpenLPController.PAGE_KEY, 0); |
319 | 47 | Log.v(LOG_TAG, "Setting Page number: " + selectedPage); | 47 | Log.v(LOG_TAG, "Setting Page number: " + selectedPage); |
320 | 48 | pager.setOnPageChangeListener(controller.onPageChangeListener); | 48 | pager.setOnPageChangeListener(controller.onPageChangeListener); |
321 | 49 | pager.setCurrentItem(selectedPage, true); | 49 | pager.setCurrentItem(selectedPage, true); |
322 | 50 | controller.onPageChangeListener.onPageSelected(selectedPage); | 50 | controller.onPageChangeListener.onPageSelected(selectedPage); |
323 | 51 | } | 51 | } |
324 | 52 | 52 | ||
325 | 53 | public void setCurrentPage(int page) { | 53 | public void setCurrentPage(int page) { |
326 | 54 | pager.setCurrentItem(page, true); | 54 | pager.setCurrentItem(page, true); |
327 | 55 | } | 55 | } |
328 | 56 | 56 | ||
329 | 57 | @Override | 57 | @Override |
330 | 58 | protected void onDestroy() { | 58 | protected void onDestroy() { |
331 | 59 | super.onDestroy(); | 59 | super.onDestroy(); |
332 | 60 | Log.v(LOG_TAG, "Destroying pagerActivity..."); | 60 | Log.v(LOG_TAG, "Destroying pagerActivity..."); |
333 | 61 | unregisterReceiver(controller.apiCallReceiver); | 61 | unregisterReceiver(controller.apiCallReceiver); |
334 | 62 | stopService(controller.pingIntent); | 62 | stopService(controller.pingIntent); |
335 | 63 | } | 63 | } |
336 | 64 | 64 | ||
337 | 65 | private final String LOG_TAG = PagerActivity.class.getName(); | 65 | private final String LOG_TAG = PagerActivity.class.getName(); |
338 | 66 | } | 66 | } |
339 | 67 | 67 | ||
340 | === modified file 'src/org/openlp/android/activity/Search.java' | |||
341 | --- src/org/openlp/android/activity/Search.java 2013-04-06 13:44:51 +0000 | |||
342 | +++ src/org/openlp/android/activity/Search.java 2013-06-04 19:32:29 +0000 | |||
343 | @@ -21,7 +21,7 @@ | |||
344 | 21 | package org.openlp.android.activity; | 21 | package org.openlp.android.activity; |
345 | 22 | 22 | ||
346 | 23 | public interface Search { | 23 | public interface Search { |
348 | 24 | public final String ACTION = Search.class.getName().concat(".Action"); | 24 | public final String ACTION = Search.class.getName().concat(".Action"); |
349 | 25 | 25 | ||
351 | 26 | public void searchPluginCall(String apiBase, String apiData); | 26 | public void searchPluginCall(String apiBase, String apiData); |
352 | 27 | } | 27 | } |
353 | 28 | 28 | ||
354 | === modified file 'src/org/openlp/android/activity/SearchService.java' | |||
355 | --- src/org/openlp/android/activity/SearchService.java 2013-04-06 13:44:51 +0000 | |||
356 | +++ src/org/openlp/android/activity/SearchService.java 2013-06-04 19:32:29 +0000 | |||
357 | @@ -27,7 +27,7 @@ | |||
358 | 27 | import java.net.URISyntaxException; | 27 | import java.net.URISyntaxException; |
359 | 28 | 28 | ||
360 | 29 | public interface SearchService { | 29 | public interface SearchService { |
364 | 30 | public Intent getSearchPluginIntent(String apiBase, String apiData) | 30 | public Intent getSearchPluginIntent(String apiBase, String apiData) |
365 | 31 | throws JSONHandler.JSONHandlerException, IOException, | 31 | throws JSONHandler.JSONHandlerException, IOException, |
366 | 32 | URISyntaxException; | 32 | URISyntaxException; |
367 | 33 | } | 33 | } |
368 | 34 | 34 | ||
369 | === modified file 'src/org/openlp/android/activity/SearchableActivity.java' | |||
370 | --- src/org/openlp/android/activity/SearchableActivity.java 2013-04-06 13:44:51 +0000 | |||
371 | +++ src/org/openlp/android/activity/SearchableActivity.java 2013-06-04 19:32:29 +0000 | |||
372 | @@ -52,242 +52,239 @@ | |||
373 | 52 | import java.util.Map; | 52 | import java.util.Map; |
374 | 53 | 53 | ||
375 | 54 | public class SearchableActivity extends Activity implements Api { | 54 | public class SearchableActivity extends Activity implements Api { |
614 | 55 | private ExpandableListView listView; | 55 | private ExpandableListView listView; |
615 | 56 | private final int DIALOG_ITEM_OPTIONS = 0; | 56 | private final int DIALOG_ITEM_OPTIONS = 0; |
616 | 57 | private Object dialogKey; | 57 | private Object dialogKey; |
617 | 58 | private JSONArray dialogValue; | 58 | private JSONArray dialogValue; |
618 | 59 | 59 | ||
619 | 60 | private Search controller = new Search() { | 60 | private Search controller = new Search() { |
620 | 61 | @Override | 61 | @Override |
621 | 62 | public void searchPluginCall(String apiBase, String apiData) { | 62 | public void searchPluginCall(String apiBase, String apiData) { |
622 | 63 | Intent apiCallIntent = | 63 | Intent apiCallIntent = |
623 | 64 | new Intent(SearchableActivity.this, ApiCallIntent.class); | 64 | new Intent(SearchableActivity.this, ApiCallIntent.class); |
624 | 65 | apiCallIntent.putExtra(apiBase, apiData); | 65 | apiCallIntent.putExtra(apiBase, apiData); |
625 | 66 | startService(apiCallIntent); | 66 | startService(apiCallIntent); |
626 | 67 | } | 67 | } |
627 | 68 | }; | 68 | }; |
628 | 69 | 69 | ||
629 | 70 | BroadcastReceiver apiCallReceiver = new BroadcastReceiver() { | 70 | BroadcastReceiver apiCallReceiver = new BroadcastReceiver() { |
630 | 71 | @Override | 71 | @Override |
631 | 72 | public void onReceive(Context context, Intent intent) { | 72 | public void onReceive(Context context, Intent intent) { |
632 | 73 | Log.d(LOG_TAG, String.format( | 73 | Log.d(LOG_TAG, String.format( |
633 | 74 | "Search broadcast received: context(%s), intent(%s, %s)", | 74 | "Search broadcast received: context(%s), intent(%s, %s)", |
634 | 75 | context, intent, intent.getExtras())); | 75 | context, intent, intent.getExtras())); |
635 | 76 | } | 76 | } |
636 | 77 | }; | 77 | }; |
637 | 78 | 78 | ||
638 | 79 | @Override | 79 | @Override |
639 | 80 | protected void onCreate(Bundle savedInstanceState) { | 80 | protected void onCreate(Bundle savedInstanceState) { |
640 | 81 | super.onCreate(savedInstanceState); | 81 | super.onCreate(savedInstanceState); |
641 | 82 | setContentView(R.layout.search); | 82 | setContentView(R.layout.search); |
642 | 83 | listView = (ExpandableListView) findViewById(R.id.list); | 83 | listView = (ExpandableListView) findViewById(R.id.list); |
643 | 84 | listView.setOnChildClickListener(onChildClickListener); | 84 | listView.setOnChildClickListener(onChildClickListener); |
644 | 85 | 85 | ||
645 | 86 | IntentFilter apiCallFilter = new IntentFilter(Search.ACTION); | 86 | IntentFilter apiCallFilter = new IntentFilter(Search.ACTION); |
646 | 87 | apiCallFilter.addCategory(Intent.CATEGORY_DEFAULT); | 87 | apiCallFilter.addCategory(Intent.CATEGORY_DEFAULT); |
647 | 88 | 88 | ||
648 | 89 | registerReceiver(apiCallReceiver, apiCallFilter); | 89 | registerReceiver(apiCallReceiver, apiCallFilter); |
649 | 90 | 90 | ||
650 | 91 | Intent intent = getIntent(); | 91 | Intent intent = getIntent(); |
651 | 92 | if (Intent.ACTION_SEARCH.equals(intent.getAction())) { | 92 | if (Intent.ACTION_SEARCH.equals(intent.getAction())) { |
652 | 93 | String query = intent.getStringExtra(SearchManager.QUERY); | 93 | String query = intent.getStringExtra(SearchManager.QUERY); |
653 | 94 | doSearch(query); | 94 | doSearch(query); |
654 | 95 | } | 95 | } |
655 | 96 | } | 96 | } |
656 | 97 | 97 | ||
657 | 98 | private ExpandableListView.OnChildClickListener onChildClickListener = | 98 | private ExpandableListView.OnChildClickListener onChildClickListener = |
658 | 99 | new ExpandableListView.OnChildClickListener() { | 99 | new ExpandableListView.OnChildClickListener() { |
659 | 100 | @Override | 100 | @Override |
660 | 101 | public boolean onChildClick(ExpandableListView expandableListView, | 101 | public boolean onChildClick(ExpandableListView expandableListView, |
661 | 102 | View view, int parent, int childPosition, long l) { | 102 | View view, int parent, int childPosition, long l) { |
662 | 103 | @SuppressWarnings("unchecked") Map<String, JSONArray> child = | 103 | @SuppressWarnings("unchecked") Map<String, JSONArray> child = |
663 | 104 | (Map<String, JSONArray>) listView.getExpandableListAdapter() | 104 | (Map<String, JSONArray>) listView.getExpandableListAdapter() |
664 | 105 | .getChild(parent, childPosition); | 105 | .getChild(parent, childPosition); |
665 | 106 | dialogKey = null; | 106 | dialogKey = null; |
666 | 107 | dialogValue = null; | 107 | dialogValue = null; |
667 | 108 | dialogKey = | 108 | dialogKey = |
668 | 109 | listView.getExpandableListAdapter().getGroup(parent); | 109 | listView.getExpandableListAdapter().getGroup(parent); |
669 | 110 | dialogValue = child.get(dialogKey.toString()); | 110 | dialogValue = child.get(dialogKey.toString()); |
670 | 111 | showDialog(DIALOG_ITEM_OPTIONS); | 111 | showDialog(DIALOG_ITEM_OPTIONS); |
671 | 112 | return false; | 112 | return false; |
672 | 113 | } | 113 | } |
673 | 114 | }; | 114 | }; |
674 | 115 | 115 | ||
675 | 116 | @Override | 116 | @Override |
676 | 117 | protected Dialog onCreateDialog(int id) { | 117 | protected Dialog onCreateDialog(int id) { |
677 | 118 | switch (id) { | 118 | switch (id) { |
678 | 119 | case DIALOG_ITEM_OPTIONS: | 119 | case DIALOG_ITEM_OPTIONS: |
679 | 120 | AlertDialog.Builder dialogBuilder = | 120 | AlertDialog.Builder dialogBuilder = |
680 | 121 | new AlertDialog.Builder(SearchableActivity.this); | 121 | new AlertDialog.Builder(SearchableActivity.this); |
681 | 122 | dialogBuilder | 122 | dialogBuilder |
682 | 123 | .setTitle(getString(R.string.dialogTitleItemOptions)); | 123 | .setTitle(getString(R.string.dialogTitleItemOptions)); |
683 | 124 | dialogBuilder.setNegativeButton( | 124 | dialogBuilder.setNegativeButton( |
684 | 125 | getString(R.string.dialogNegativeSendLive), | 125 | getString(R.string.dialogNegativeSendLive), |
685 | 126 | onClickListenerDialogSendLive); | 126 | onClickListenerDialogSendLive); |
686 | 127 | dialogBuilder.setPositiveButton( | 127 | dialogBuilder.setPositiveButton( |
687 | 128 | getString(R.string.dialogPositiveAddToService), | 128 | getString(R.string.dialogPositiveAddToService), |
688 | 129 | onClickListenerDialogAddToService); | 129 | onClickListenerDialogAddToService); |
689 | 130 | return dialogBuilder.create(); | 130 | return dialogBuilder.create(); |
690 | 131 | default: | 131 | default: |
691 | 132 | return null; | 132 | return null; |
692 | 133 | } | 133 | } |
693 | 134 | } | 134 | } |
694 | 135 | 135 | ||
695 | 136 | DialogInterface.OnClickListener onClickListenerDialogSendLive = | 136 | DialogInterface.OnClickListener onClickListenerDialogSendLive = |
696 | 137 | new DialogInterface.OnClickListener() { | 137 | new DialogInterface.OnClickListener() { |
697 | 138 | @Override | 138 | @Override |
698 | 139 | public void onClick(DialogInterface dialogInterface, int i) { | 139 | public void onClick(DialogInterface dialogInterface, int i) { |
699 | 140 | controller.searchPluginCall( | 140 | controller.searchPluginCall( |
700 | 141 | String.format(SEARCH_PLUGIN_LIVE, dialogKey), | 141 | String.format(SEARCH_PLUGIN_LIVE, dialogKey), |
701 | 142 | getDialogValue()); | 142 | getDialogValue()); |
702 | 143 | } | 143 | } |
703 | 144 | }; | 144 | }; |
704 | 145 | 145 | ||
705 | 146 | DialogInterface.OnClickListener onClickListenerDialogAddToService = | 146 | DialogInterface.OnClickListener onClickListenerDialogAddToService = |
706 | 147 | new DialogInterface.OnClickListener() { | 147 | new DialogInterface.OnClickListener() { |
707 | 148 | @Override | 148 | @Override |
708 | 149 | public void onClick(DialogInterface dialogInterface, int i) { | 149 | public void onClick(DialogInterface dialogInterface, int i) { |
709 | 150 | controller.searchPluginCall( | 150 | controller.searchPluginCall( |
710 | 151 | String.format(SEARCH_PLUGIN_ADD, dialogKey), | 151 | String.format(SEARCH_PLUGIN_ADD, dialogKey), |
711 | 152 | getDialogValue()); | 152 | getDialogValue()); |
712 | 153 | dialogInterface.cancel(); | 153 | dialogInterface.cancel(); |
713 | 154 | } | 154 | } |
714 | 155 | }; | 155 | }; |
715 | 156 | 156 | ||
716 | 157 | private String getDialogValue() { | 157 | private String getDialogValue() { |
717 | 158 | try { | 158 | try { |
718 | 159 | return String.valueOf(dialogValue.get(0)); | 159 | return String.valueOf(dialogValue.get(0)); |
719 | 160 | } | 160 | } catch (JSONException e) { |
720 | 161 | catch (JSONException e) { | 161 | Log.e(LOG_TAG, "Could not get dialogValue: " + e.getMessage()); |
721 | 162 | Log.e(LOG_TAG, "Could not get dialogValue: " + e.getMessage()); | 162 | Toast.makeText(SearchableActivity.this, e.getMessage(), |
722 | 163 | Toast.makeText(SearchableActivity.this, e.getMessage(), | 163 | Toast.LENGTH_LONG).show(); |
723 | 164 | Toast.LENGTH_LONG).show(); | 164 | return null; |
724 | 165 | return null; | 165 | } |
725 | 166 | } | 166 | } |
726 | 167 | } | 167 | |
727 | 168 | 168 | @Override | |
728 | 169 | @Override | 169 | protected void onPrepareDialog(int id, Dialog dialog) { |
729 | 170 | protected void onPrepareDialog(int id, Dialog dialog) { | 170 | try { |
730 | 171 | try { | 171 | dialog.setTitle(dialogValue.get(1).toString()); |
731 | 172 | dialog.setTitle(dialogValue.get(1).toString()); | 172 | } catch (JSONException e) { |
732 | 173 | } | 173 | e.printStackTrace(); |
733 | 174 | catch (JSONException e) { | 174 | } |
734 | 175 | e.printStackTrace(); | 175 | } |
735 | 176 | } | 176 | |
736 | 177 | } | 177 | public void doSearch(String search) { |
737 | 178 | 178 | new SearchAsync().execute(search); | |
738 | 179 | public void doSearch(String search) { | 179 | } |
739 | 180 | new SearchAsync().execute(search); | 180 | |
740 | 181 | } | 181 | @Override |
741 | 182 | 182 | protected void onDestroy() { | |
742 | 183 | @Override | 183 | super.onDestroy(); |
743 | 184 | protected void onDestroy() { | 184 | unregisterReceiver(apiCallReceiver); |
744 | 185 | super.onDestroy(); | 185 | } |
745 | 186 | unregisterReceiver(apiCallReceiver); | 186 | |
746 | 187 | } | 187 | class SearchAsync extends AsyncTask<String, Void, SearchResults> { |
747 | 188 | 188 | ProgressDialog progressDialog; | |
748 | 189 | class SearchAsync extends AsyncTask<String, Void, SearchResults> { | 189 | String query; |
749 | 190 | ProgressDialog progressDialog; | 190 | |
750 | 191 | String query; | 191 | @Override |
751 | 192 | 192 | protected SearchResults doInBackground(String... strings) { | |
752 | 193 | @Override | 193 | query = strings[0]; |
753 | 194 | protected SearchResults doInBackground(String... strings) { | 194 | List<String> groups = new ArrayList<String>(); |
754 | 195 | query = strings[0]; | 195 | List<List<Map<String, JSONArray>>> children = |
755 | 196 | List<String> groups = new ArrayList<String>(); | 196 | new ArrayList<List<Map<String, JSONArray>>>(); |
756 | 197 | List<List<Map<String, JSONArray>>> children = | 197 | AsyncTask<String, Void, String> call = |
757 | 198 | new ArrayList<List<Map<String, JSONArray>>>(); | 198 | new WebCallReturningAsyncTask(SearchableActivity.this) |
758 | 199 | AsyncTask<String, Void, String> call = | 199 | .execute(SEARCHABLE_PLUGINS); |
759 | 200 | new WebCallReturningAsyncTask(SearchableActivity.this) | 200 | |
760 | 201 | .execute(SEARCHABLE_PLUGINS); | 201 | try { |
761 | 202 | 202 | JSONArray array = | |
762 | 203 | try { | 203 | new JSONObject(call.get()).getJSONObject("results") |
763 | 204 | JSONArray array = | 204 | .getJSONArray("items"); |
764 | 205 | new JSONObject(call.get()).getJSONObject("results") | 205 | |
765 | 206 | .getJSONArray("items"); | 206 | for (int i = 0; i < array.length(); i++) { |
766 | 207 | 207 | String pluginString = | |
767 | 208 | for (int i = 0; i < array.length(); i++) { | 208 | ((JSONArray) array.get(i)).get(0).toString(); |
768 | 209 | String pluginString = | 209 | groups.add(pluginString); |
769 | 210 | ((JSONArray) array.get(i)).get(0).toString(); | 210 | |
770 | 211 | groups.add(pluginString); | 211 | JSONArray resultArray = null; |
771 | 212 | 212 | ||
772 | 213 | JSONArray resultArray = null; | 213 | AsyncTask<String, Void, String> pluginResults = |
773 | 214 | 214 | new WebCallReturningAsyncTask(SearchableActivity.this, | |
774 | 215 | AsyncTask<String, Void, String> pluginResults = | 215 | String |
775 | 216 | new WebCallReturningAsyncTask(SearchableActivity.this, | 216 | .format(SEARCH_PLUGIN_FORMATTED, pluginString)) |
776 | 217 | String | 217 | .execute( |
777 | 218 | .format(SEARCH_PLUGIN_FORMATTED, pluginString)) | 218 | JSONHandler.createRequestJSON("text", query)); |
778 | 219 | .execute( | 219 | |
779 | 220 | JSONHandler.createRequestJSON("text", query)); | 220 | List<Map<String, JSONArray>> list = |
780 | 221 | 221 | new ArrayList<Map<String, JSONArray>>(); | |
781 | 222 | List<Map<String, JSONArray>> list = | 222 | if (pluginResults.get() != null && |
782 | 223 | new ArrayList<Map<String, JSONArray>>(); | 223 | pluginResults.get().trim().length() > 0) { |
783 | 224 | if (pluginResults.get() != null && | 224 | resultArray = new JSONObject(pluginResults.get()) |
784 | 225 | pluginResults.get().trim().length() > 0) { | 225 | .getJSONObject("results").getJSONArray("items"); |
785 | 226 | resultArray = new JSONObject(pluginResults.get()) | 226 | for (int j = 0; j < resultArray.length(); j++) { |
786 | 227 | .getJSONObject("results").getJSONArray("items"); | 227 | Map<String, JSONArray> item = |
787 | 228 | for (int j = 0; j < resultArray.length(); j++) { | 228 | new HashMap<String, JSONArray>(); |
788 | 229 | Map<String, JSONArray> item = | 229 | item.put(pluginString, |
789 | 230 | new HashMap<String, JSONArray>(); | 230 | (JSONArray) resultArray.get(j)); |
790 | 231 | item.put(pluginString, | 231 | list.add(item); |
791 | 232 | (JSONArray) resultArray.get(j)); | 232 | } |
792 | 233 | list.add(item); | 233 | } |
793 | 234 | } | 234 | children.add(list); |
794 | 235 | } | 235 | } |
795 | 236 | children.add(list); | 236 | } catch (Exception e) { |
796 | 237 | } | 237 | Log.e(LOG_TAG, e.toString()); |
797 | 238 | } | 238 | Toast.makeText(SearchableActivity.this, e.getMessage(), |
798 | 239 | catch (Exception e) { | 239 | Toast.LENGTH_LONG).show(); |
799 | 240 | Log.e(LOG_TAG, e.toString()); | 240 | } |
800 | 241 | Toast.makeText(SearchableActivity.this, e.getMessage(), | 241 | |
801 | 242 | Toast.LENGTH_LONG).show(); | 242 | SearchResults results = new SearchResults(); |
802 | 243 | } | 243 | results.setGroups(groups); |
803 | 244 | 244 | results.setChildren(children); | |
804 | 245 | SearchResults results = new SearchResults(); | 245 | return results; |
805 | 246 | results.setGroups(groups); | 246 | } |
806 | 247 | results.setChildren(children); | 247 | |
807 | 248 | return results; | 248 | @Override |
808 | 249 | } | 249 | protected void onPreExecute() { |
809 | 250 | 250 | super.onPreExecute(); | |
810 | 251 | @Override | 251 | progressDialog = ProgressDialog.show(SearchableActivity.this, null, |
811 | 252 | protected void onPreExecute() { | 252 | getString(R.string.searching)); |
812 | 253 | super.onPreExecute(); | 253 | } |
813 | 254 | progressDialog = ProgressDialog.show(SearchableActivity.this, null, | 254 | |
814 | 255 | getString(R.string.searching)); | 255 | @Override |
815 | 256 | } | 256 | protected void onPostExecute(SearchResults results) { |
816 | 257 | 257 | super.onPostExecute(results); | |
817 | 258 | @Override | 258 | listView.setAdapter( |
818 | 259 | protected void onPostExecute(SearchResults results) { | 259 | new GroupExpandableListAdapter(SearchableActivity.this, |
819 | 260 | super.onPostExecute(results); | 260 | results.getGroups(), results.getChildren())); |
820 | 261 | listView.setAdapter( | 261 | progressDialog.dismiss(); |
821 | 262 | new GroupExpandableListAdapter(SearchableActivity.this, | 262 | Toast.makeText(SearchableActivity.this, |
822 | 263 | results.getGroups(), results.getChildren())); | 263 | String.format(getString(R.string.showingResults), query), |
823 | 264 | progressDialog.dismiss(); | 264 | Toast.LENGTH_SHORT).show(); |
824 | 265 | Toast.makeText(SearchableActivity.this, | 265 | } |
825 | 266 | String.format(getString(R.string.showingResults), query), | 266 | } |
826 | 267 | Toast.LENGTH_SHORT).show(); | 267 | |
827 | 268 | } | 268 | class SearchResults { |
828 | 269 | } | 269 | List<String> groups; |
829 | 270 | 270 | List<List<Map<String, JSONArray>>> children; | |
830 | 271 | class SearchResults { | 271 | |
831 | 272 | List<String> groups; | 272 | public List<String> getGroups() { |
832 | 273 | List<List<Map<String, JSONArray>>> children; | 273 | return groups; |
833 | 274 | 274 | } | |
834 | 275 | public List<String> getGroups() { | 275 | |
835 | 276 | return groups; | 276 | public void setGroups(List<String> groups) { |
836 | 277 | } | 277 | this.groups = groups; |
837 | 278 | 278 | } | |
838 | 279 | public void setGroups(List<String> groups) { | 279 | |
839 | 280 | this.groups = groups; | 280 | public List<List<Map<String, JSONArray>>> getChildren() { |
840 | 281 | } | 281 | return children; |
841 | 282 | 282 | } | |
842 | 283 | public List<List<Map<String, JSONArray>>> getChildren() { | 283 | |
843 | 284 | return children; | 284 | public void setChildren(List<List<Map<String, JSONArray>>> children) { |
844 | 285 | } | 285 | this.children = children; |
845 | 286 | 286 | } | |
846 | 287 | public void setChildren(List<List<Map<String, JSONArray>>> children) { | 287 | } |
847 | 288 | this.children = children; | 288 | |
848 | 289 | } | 289 | private final String LOG_TAG = this.getClass().getName(); |
611 | 290 | } | ||
612 | 291 | |||
613 | 292 | private final String LOG_TAG = this.getClass().getName(); | ||
849 | 293 | } | 290 | } |
850 | 294 | 291 | ||
851 | === modified file 'src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java' | |||
852 | --- src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java 2013-04-07 12:24:38 +0000 | |||
853 | +++ src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java 2013-06-04 19:32:29 +0000 | |||
854 | @@ -43,162 +43,162 @@ | |||
855 | 43 | import org.openlp.android.R; | 43 | import org.openlp.android.R; |
856 | 44 | 44 | ||
857 | 45 | public class ConnectionPreferenceActivity extends PreferenceActivity { | 45 | public class ConnectionPreferenceActivity extends PreferenceActivity { |
1014 | 46 | private final String KEY_PREFERENCE_DISPLAY = "preferenceDisplay"; | 46 | private final String KEY_PREFERENCE_DISPLAY = "preferenceDisplay"; |
1015 | 47 | private final String KEY_SERVER_ID = "keyServerId"; | 47 | private final String KEY_SERVER_ID = "keyServerId"; |
1016 | 48 | private final String PREFERENCE_DISPLAY_SERVER = "displayServer"; | 48 | private final String PREFERENCE_DISPLAY_SERVER = "displayServer"; |
1017 | 49 | private final String LOG_TAG = ConnectionPreferenceActivity.class.getName(); | 49 | private final String LOG_TAG = ConnectionPreferenceActivity.class.getName(); |
1018 | 50 | 50 | ||
1019 | 51 | private PreferenceScreen preferenceScreen = null; | 51 | private PreferenceScreen preferenceScreen = null; |
1020 | 52 | private boolean resume = true; | 52 | private boolean resume = true; |
1021 | 53 | 53 | ||
1022 | 54 | @Override | 54 | @Override |
1023 | 55 | protected void onCreate(Bundle savedInstanceState) { | 55 | protected void onCreate(Bundle savedInstanceState) { |
1024 | 56 | super.onCreate(savedInstanceState); | 56 | super.onCreate(savedInstanceState); |
1025 | 57 | addPreferencesFromResource(R.xml.empty_preferences); | 57 | addPreferencesFromResource(R.xml.empty_preferences); |
1026 | 58 | getPreferenceManager() | 58 | getPreferenceManager() |
1027 | 59 | .setSharedPreferencesName(getString(R.string.keySharedPreferences)); | 59 | .setSharedPreferencesName(getString(R.string.keySharedPreferences)); |
1028 | 60 | preferenceScreen = getPreferenceScreen() == null | 60 | preferenceScreen = getPreferenceScreen() == null |
1029 | 61 | ? getPreferenceManager().createPreferenceScreen(this) | 61 | ? getPreferenceManager().createPreferenceScreen(this) |
1030 | 62 | : getPreferenceScreen(); | 62 | : getPreferenceScreen(); |
1031 | 63 | preferenceScreen.removeAll(); | 63 | preferenceScreen.removeAll(); |
1032 | 64 | String preferenceDisplay = getIntent().getStringExtra(KEY_PREFERENCE_DISPLAY); | 64 | String preferenceDisplay = getIntent().getStringExtra(KEY_PREFERENCE_DISPLAY); |
1033 | 65 | if (preferenceDisplay != null | 65 | if (preferenceDisplay != null |
1034 | 66 | && preferenceDisplay.equalsIgnoreCase(PREFERENCE_DISPLAY_SERVER)) { | 66 | && preferenceDisplay.equalsIgnoreCase(PREFERENCE_DISPLAY_SERVER)) { |
1035 | 67 | constructServerView(getIntent().getIntExtra(KEY_SERVER_ID, 1)); | 67 | constructServerView(getIntent().getIntExtra(KEY_SERVER_ID, 1)); |
1036 | 68 | } else { | 68 | } else { |
1037 | 69 | resume = false; | 69 | resume = false; |
1038 | 70 | constructOverviewScreen(); | 70 | constructOverviewScreen(); |
1039 | 71 | } | 71 | } |
1040 | 72 | } | 72 | } |
1041 | 73 | 73 | ||
1042 | 74 | private void constructOverviewScreen() { | 74 | private void constructOverviewScreen() { |
1043 | 75 | getPreferenceScreen().removeAll(); | 75 | getPreferenceScreen().removeAll(); |
1044 | 76 | Log.i(LOG_TAG, "constructOverviewScreen"); | 76 | Log.i(LOG_TAG, "constructOverviewScreen"); |
1045 | 77 | Preference configPref = new Preference(this); | 77 | Preference configPref = new Preference(this); |
1046 | 78 | configPref.setTitle(getString(R.string.connection_available_configurations)); | 78 | configPref.setTitle(getString(R.string.connection_available_configurations)); |
1047 | 79 | configPref.setSummary(getString(R.string.connection_add_by_menu)); | 79 | configPref.setSummary(getString(R.string.connection_add_by_menu)); |
1048 | 80 | configPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { | 80 | configPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { |
1049 | 81 | @Override | 81 | @Override |
1050 | 82 | public boolean onPreferenceClick(Preference preference) { | 82 | public boolean onPreferenceClick(Preference preference) { |
1051 | 83 | int nextId = getNextPrefId( | 83 | int nextId = getNextPrefId( |
1052 | 84 | getHostConfigMap( | 84 | getHostConfigMap( |
1053 | 85 | getPreferenceManager() | 85 | getPreferenceManager() |
1054 | 86 | .getSharedPreferences().getAll() | 86 | .getSharedPreferences().getAll() |
1055 | 87 | ) | 87 | ) |
1056 | 88 | ); | 88 | ); |
1057 | 89 | Preference newPreference = simpleClickablePreferenceFromHostConfig( | 89 | Preference newPreference = simpleClickablePreferenceFromHostConfig( |
1058 | 90 | new HostConfig( | 90 | new HostConfig( |
1059 | 91 | getString(R.string.connection_profile_server), | 91 | getString(R.string.connection_profile_server), |
1060 | 92 | nextId)); | 92 | nextId)); |
1061 | 93 | newPreference.setTitle(getString(R.string.connection_profile_new_server)); | 93 | newPreference.setTitle(getString(R.string.connection_profile_new_server)); |
1062 | 94 | newPreference.setSummary(getString(R.string.connection_profile_not_saved)); | 94 | newPreference.setSummary(getString(R.string.connection_profile_not_saved)); |
1063 | 95 | preferenceScreen.addPreference(newPreference); | 95 | preferenceScreen.addPreference(newPreference); |
1064 | 96 | return true; | 96 | return true; |
1065 | 97 | } | 97 | } |
1066 | 98 | }); | 98 | }); |
1067 | 99 | preferenceScreen.addPreference(configPref); | 99 | preferenceScreen.addPreference(configPref); |
1068 | 100 | List<HostConfig> hostConfigs = getHostConfigs(); | 100 | List<HostConfig> hostConfigs = getHostConfigs(); |
1069 | 101 | if (!hostConfigs.isEmpty()) { | 101 | if (!hostConfigs.isEmpty()) { |
1070 | 102 | for (final HostConfig config : getHostConfigs()) { | 102 | for (final HostConfig config : getHostConfigs()) { |
1071 | 103 | preferenceScreen.addPreference( | 103 | preferenceScreen.addPreference( |
1072 | 104 | simpleClickablePreferenceFromHostConfig(config)); | 104 | simpleClickablePreferenceFromHostConfig(config)); |
1073 | 105 | } | 105 | } |
1074 | 106 | } | 106 | } |
1075 | 107 | } | 107 | } |
1076 | 108 | 108 | ||
1077 | 109 | private void constructServerView(int hostId) { | 109 | private void constructServerView(int hostId) { |
1078 | 110 | HostConfig hostConfig = hostConfigFromPreferencesForHostId( | 110 | HostConfig hostConfig = hostConfigFromPreferencesForHostId( |
1079 | 111 | hostId, | 111 | hostId, |
1080 | 112 | getHostConfigMap( | 112 | getHostConfigMap( |
1081 | 113 | getPreferenceManager() | 113 | getPreferenceManager() |
1082 | 114 | .getSharedPreferences() | 114 | .getSharedPreferences() |
1083 | 115 | .getAll() | 115 | .getAll() |
1084 | 116 | ) | 116 | ) |
1085 | 117 | ); | 117 | ); |
1086 | 118 | addPreferenceCategory(preferenceScreen, hostConfig); | 118 | addPreferenceCategory(preferenceScreen, hostConfig); |
1087 | 119 | } | 119 | } |
1088 | 120 | 120 | ||
1089 | 121 | private Preference simpleClickablePreferenceFromHostConfig(final HostConfig config) { | 121 | private Preference simpleClickablePreferenceFromHostConfig(final HostConfig config) { |
1090 | 122 | final Preference serverConfig = new Preference(this); | 122 | final Preference serverConfig = new Preference(this); |
1091 | 123 | serverConfig.setTitle(config.title.getSummary()); | 123 | serverConfig.setTitle(config.title.getSummary()); |
1092 | 124 | 124 | ||
1093 | 125 | Boolean useSsl = getPreferenceManager() | 125 | Boolean useSsl = getPreferenceManager() |
1094 | 126 | .getSharedPreferences() | 126 | .getSharedPreferences() |
1095 | 127 | .getBoolean(config.useSsl.getKey(), false); | 127 | .getBoolean(config.useSsl.getKey(), false); |
1096 | 128 | 128 | ||
1097 | 129 | serverConfig.setSummary(String.format( | 129 | serverConfig.setSummary(String.format( |
1098 | 130 | "%s:%s %s", | 130 | "%s:%s %s", |
1099 | 131 | config.hostAddress.getText(), | 131 | config.hostAddress.getText(), |
1100 | 132 | config.hostPort.getText(), | 132 | config.hostPort.getText(), |
1101 | 133 | useSsl ? "(SSL)" : "") | 133 | useSsl ? "(SSL)" : "") |
1102 | 134 | ); | 134 | ); |
1103 | 135 | serverConfig.setOnPreferenceClickListener( | 135 | serverConfig.setOnPreferenceClickListener( |
1104 | 136 | new Preference.OnPreferenceClickListener() { | 136 | new Preference.OnPreferenceClickListener() { |
1105 | 137 | @Override | 137 | @Override |
1106 | 138 | public boolean onPreferenceClick(Preference preference) { | 138 | public boolean onPreferenceClick(Preference preference) { |
1107 | 139 | Intent serverConfigIntent = new Intent( | 139 | Intent serverConfigIntent = new Intent( |
1108 | 140 | ConnectionPreferenceActivity.this, | 140 | ConnectionPreferenceActivity.this, |
1109 | 141 | ConnectionPreferenceActivity.class | 141 | ConnectionPreferenceActivity.class |
1110 | 142 | ); | 142 | ); |
1111 | 143 | serverConfigIntent.putExtra(KEY_PREFERENCE_DISPLAY, | 143 | serverConfigIntent.putExtra(KEY_PREFERENCE_DISPLAY, |
1112 | 144 | PREFERENCE_DISPLAY_SERVER); | 144 | PREFERENCE_DISPLAY_SERVER); |
1113 | 145 | serverConfigIntent.putExtra(KEY_SERVER_ID, config.id); | 145 | serverConfigIntent.putExtra(KEY_SERVER_ID, config.id); |
1114 | 146 | startActivity(serverConfigIntent); | 146 | startActivity(serverConfigIntent); |
1115 | 147 | return true; | 147 | return true; |
1116 | 148 | } | 148 | } |
1117 | 149 | }); | 149 | }); |
1118 | 150 | return serverConfig; | 150 | return serverConfig; |
1119 | 151 | } | 151 | } |
1120 | 152 | 152 | ||
1121 | 153 | private List<HostConfig> getHostConfigs() { | 153 | private List<HostConfig> getHostConfigs() { |
1122 | 154 | return hostConfigsFromPreferences( | 154 | return hostConfigsFromPreferences( |
1123 | 155 | getHostConfigMap( | 155 | getHostConfigMap( |
1124 | 156 | getPreferenceManager() | 156 | getPreferenceManager() |
1125 | 157 | .getSharedPreferences() | 157 | .getSharedPreferences() |
1126 | 158 | .getAll() | 158 | .getAll() |
1127 | 159 | ) | 159 | ) |
1128 | 160 | ); | 160 | ); |
1129 | 161 | } | 161 | } |
1130 | 162 | 162 | ||
1131 | 163 | private Map<String, ?> getHostConfigMap(Map<String, ?> preferences) { | 163 | private Map<String, ?> getHostConfigMap(Map<String, ?> preferences) { |
1132 | 164 | Map<String, Object> configMap = new TreeMap<String, Object>(); | 164 | Map<String, Object> configMap = new TreeMap<String, Object>(); |
1133 | 165 | 165 | ||
1134 | 166 | List<String> sortedKeys = new ArrayList<String>(preferences.keySet()); | 166 | List<String> sortedKeys = new ArrayList<String>(preferences.keySet()); |
1135 | 167 | Collections.sort(sortedKeys); | 167 | Collections.sort(sortedKeys); |
1136 | 168 | for (String key : sortedKeys) { | 168 | for (String key : sortedKeys) { |
1137 | 169 | if (key.startsWith(HostConfig.KEY_PREFIX)) { | 169 | if (key.startsWith(HostConfig.KEY_PREFIX)) { |
1138 | 170 | configMap.put(key, preferences.get(key)); | 170 | configMap.put(key, preferences.get(key)); |
1139 | 171 | } | 171 | } |
1140 | 172 | } | 172 | } |
1141 | 173 | return configMap; | 173 | return configMap; |
1142 | 174 | } | 174 | } |
1143 | 175 | 175 | ||
1144 | 176 | private List<HostConfig> hostConfigsFromPreferences(Map<String, ?> preferences) { | 176 | private List<HostConfig> hostConfigsFromPreferences(Map<String, ?> preferences) { |
1145 | 177 | List<Integer> hostIds = getHostIds(preferences); | 177 | List<Integer> hostIds = getHostIds(preferences); |
1146 | 178 | List<HostConfig> hostConfigs = new ArrayList<HostConfig>(); | 178 | List<HostConfig> hostConfigs = new ArrayList<HostConfig>(); |
1147 | 179 | for (Integer id : hostIds) { | 179 | for (Integer id : hostIds) { |
1148 | 180 | hostConfigs.add(hostConfigFromPreferencesForHostId(id, preferences)); | 180 | hostConfigs.add(hostConfigFromPreferencesForHostId(id, preferences)); |
1149 | 181 | } | 181 | } |
1150 | 182 | return hostConfigs; | 182 | return hostConfigs; |
1151 | 183 | } | 183 | } |
1152 | 184 | 184 | ||
1153 | 185 | private HostConfig hostConfigFromPreferencesForHostId(int hostId, Map<String, ?> preferences) { | 185 | private HostConfig hostConfigFromPreferencesForHostId(int hostId, Map<String, ?> preferences) { |
1154 | 186 | Object titleValue = preferences.get(getHostConfigTitleKey(hostId)); | 186 | Object titleValue = preferences.get(getHostConfigTitleKey(hostId)); |
1155 | 187 | String hostTitle = titleValue == null ? getString(R.string.connection_profile_server) : titleValue.toString(); | 187 | String hostTitle = titleValue == null ? getString(R.string.connection_profile_server) : titleValue.toString(); |
1156 | 188 | HostConfig hostConfig = new HostConfig( | 188 | HostConfig hostConfig = new HostConfig( |
1157 | 189 | hostTitle, hostId | 189 | hostTitle, hostId |
1158 | 190 | ); | 190 | ); |
1159 | 191 | Object hostValueObject = preferences.get(hostConfig.hostAddress.getKey()); | 191 | Object hostValueObject = preferences.get(hostConfig.hostAddress.getKey()); |
1160 | 192 | String hostValue = hostValueObject == null | 192 | String hostValue = hostValueObject == null |
1161 | 193 | ? getString(R.string.hostDefaultValue) : hostValueObject.toString(); | 193 | ? getString(R.string.hostDefaultValue) : hostValueObject.toString(); |
1162 | 194 | hostConfig.hostAddress.setText(hostValue); | 194 | hostConfig.hostAddress.setText(hostValue); |
1163 | 195 | hostConfig.hostAddress.setSummary(hostValue); | 195 | hostConfig.hostAddress.setSummary(hostValue); |
1164 | 196 | 196 | ||
1165 | 197 | Object portValueObject = preferences.get(hostConfig.hostPort.getKey()); | 197 | Object portValueObject = preferences.get(hostConfig.hostPort.getKey()); |
1166 | 198 | String portValue = portValueObject == null | 198 | String portValue = portValueObject == null |
1167 | 199 | ? getString(R.string.portDefaultValue) : portValueObject.toString(); | 199 | ? getString(R.string.portDefaultValue) : portValueObject.toString(); |
1168 | 200 | hostConfig.hostPort.setText(portValue); | 200 | hostConfig.hostPort.setText(portValue); |
1169 | 201 | hostConfig.hostPort.setSummary(portValue); | 201 | hostConfig.hostPort.setSummary(portValue); |
1170 | 202 | 202 | ||
1171 | 203 | Object useridValueObject = preferences.get(hostConfig.userid.getKey()); | 203 | Object useridValueObject = preferences.get(hostConfig.userid.getKey()); |
1172 | 204 | String useridValue = useridValueObject == null | 204 | String useridValue = useridValueObject == null |
1173 | @@ -211,106 +211,106 @@ | |||
1174 | 211 | ? getString(R.string.passwordDefaultValue) : passwordValueObject.toString(); | 211 | ? getString(R.string.passwordDefaultValue) : passwordValueObject.toString(); |
1175 | 212 | hostConfig.password.setText(passwordValue); | 212 | hostConfig.password.setText(passwordValue); |
1176 | 213 | hostConfig.password.setSummary(passwordValue); | 213 | hostConfig.password.setSummary(passwordValue); |
1209 | 214 | return hostConfig; | 214 | return hostConfig; |
1210 | 215 | } | 215 | } |
1211 | 216 | 216 | ||
1212 | 217 | private int getNextPrefId(Map<String, ?> preferences) { | 217 | private int getNextPrefId(Map<String, ?> preferences) { |
1213 | 218 | int max = 0; | 218 | int max = 0; |
1214 | 219 | for (String key : preferences.keySet()) { | 219 | for (String key : preferences.keySet()) { |
1215 | 220 | int prefValue = Integer.valueOf(key.split("\\.")[2]); | 220 | int prefValue = Integer.valueOf(key.split("\\.")[2]); |
1216 | 221 | max = prefValue > max ? prefValue : max; | 221 | max = prefValue > max ? prefValue : max; |
1217 | 222 | } | 222 | } |
1218 | 223 | return max + 1; | 223 | return max + 1; |
1219 | 224 | } | 224 | } |
1220 | 225 | 225 | ||
1221 | 226 | private List<Integer> getHostIds(Map<String, ?> preferences) { | 226 | private List<Integer> getHostIds(Map<String, ?> preferences) { |
1222 | 227 | Set<Integer> hashSet = new HashSet<Integer>(); | 227 | Set<Integer> hashSet = new HashSet<Integer>(); |
1223 | 228 | for (String key : preferences.keySet()) { | 228 | for (String key : preferences.keySet()) { |
1224 | 229 | hashSet.add(Integer.valueOf(key.split("\\.")[2])); | 229 | hashSet.add(Integer.valueOf(key.split("\\.")[2])); |
1225 | 230 | } | 230 | } |
1226 | 231 | List<Integer> hostIds = new ArrayList<Integer>(hashSet); | 231 | List<Integer> hostIds = new ArrayList<Integer>(hashSet); |
1227 | 232 | Collections.sort(hostIds); | 232 | Collections.sort(hostIds); |
1228 | 233 | Log.i(LOG_TAG, "Got HostIds: " + hostIds); | 233 | Log.i(LOG_TAG, "Got HostIds: " + hostIds); |
1229 | 234 | return hostIds; | 234 | return hostIds; |
1230 | 235 | } | 235 | } |
1231 | 236 | 236 | ||
1232 | 237 | private boolean addPreferenceCategory(PreferenceScreen preferenceScreen, HostConfig hostConfig) { | 237 | private boolean addPreferenceCategory(PreferenceScreen preferenceScreen, HostConfig hostConfig) { |
1233 | 238 | PreferenceCategory preferenceCategory = new PreferenceCategory(this); | 238 | PreferenceCategory preferenceCategory = new PreferenceCategory(this); |
1234 | 239 | preferenceCategory.setTitle(hostConfig.title.getSummary()); | 239 | preferenceCategory.setTitle(hostConfig.title.getSummary()); |
1235 | 240 | preferenceCategory.setKey("key.preference.category"); | 240 | preferenceCategory.setKey("key.preference.category"); |
1236 | 241 | preferenceScreen.addPreference(preferenceCategory); | 241 | preferenceScreen.addPreference(preferenceCategory); |
1237 | 242 | preferenceCategory.addPreference(hostConfig.title); | 242 | preferenceCategory.addPreference(hostConfig.title); |
1238 | 243 | preferenceCategory.addPreference(hostConfig.hostAddress); | 243 | preferenceCategory.addPreference(hostConfig.hostAddress); |
1239 | 244 | preferenceCategory.addPreference(hostConfig.hostPort); | 244 | preferenceCategory.addPreference(hostConfig.hostPort); |
1240 | 245 | preferenceCategory.addPreference(hostConfig.useSsl); | 245 | preferenceCategory.addPreference(hostConfig.useSsl); |
1241 | 246 | preferenceCategory.addPreference(hostConfig.userid); | 246 | preferenceCategory.addPreference(hostConfig.userid); |
1242 | 247 | preferenceCategory.addPreference(hostConfig.password); | 247 | preferenceCategory.addPreference(hostConfig.password); |
1270 | 248 | preferenceCategory.addPreference(hostConfig.remove); | 248 | preferenceCategory.addPreference(hostConfig.remove); |
1271 | 249 | preferenceCategory.addPreference(hostConfig.activate); | 249 | preferenceCategory.addPreference(hostConfig.activate); |
1272 | 250 | return true; | 250 | return true; |
1273 | 251 | } | 251 | } |
1274 | 252 | 252 | ||
1275 | 253 | @Override | 253 | @Override |
1276 | 254 | protected void onResume() { | 254 | protected void onResume() { |
1277 | 255 | super.onResume(); | 255 | super.onResume(); |
1278 | 256 | if (resume) { | 256 | if (resume) { |
1279 | 257 | Log.i(LOG_TAG, "Resuming..."); | 257 | Log.i(LOG_TAG, "Resuming..."); |
1280 | 258 | } else { | 258 | } else { |
1281 | 259 | constructOverviewScreen(); | 259 | constructOverviewScreen(); |
1282 | 260 | Log.i(LOG_TAG, "Not resuming..."); | 260 | Log.i(LOG_TAG, "Not resuming..."); |
1283 | 261 | } | 261 | } |
1284 | 262 | } | 262 | } |
1285 | 263 | 263 | ||
1286 | 264 | private static String getHostConfigTitleKey(int id) { | 264 | private static String getHostConfigTitleKey(int id) { |
1287 | 265 | return HostConfig.KEY_PREFIX + id + ".title"; | 265 | return HostConfig.KEY_PREFIX + id + ".title"; |
1288 | 266 | } | 266 | } |
1289 | 267 | 267 | ||
1290 | 268 | private class HostConfig { | 268 | private class HostConfig { |
1291 | 269 | static final String KEY_PREFIX = "host.config."; | 269 | static final String KEY_PREFIX = "host.config."; |
1292 | 270 | final int id; | 270 | final int id; |
1293 | 271 | final EditTextPreference title; | 271 | final EditTextPreference title; |
1294 | 272 | final EditTextPreference hostAddress; | 272 | final EditTextPreference hostAddress; |
1295 | 273 | final EditTextPreference hostPort; | 273 | final EditTextPreference hostPort; |
1296 | 274 | final CheckBoxPreference useSsl; | 274 | final CheckBoxPreference useSsl; |
1297 | 275 | final EditTextPreference userid; | 275 | final EditTextPreference userid; |
1298 | 276 | final EditTextPreference password; | 276 | final EditTextPreference password; |
1336 | 277 | final Preference remove; | 277 | final Preference remove; |
1337 | 278 | final Preference activate; | 278 | final Preference activate; |
1338 | 279 | 279 | ||
1339 | 280 | HostConfig(String sTitle, int id) { | 280 | HostConfig(String sTitle, int id) { |
1340 | 281 | this.id = id; | 281 | this.id = id; |
1341 | 282 | title = new EditTextPreference(ConnectionPreferenceActivity.this); | 282 | title = new EditTextPreference(ConnectionPreferenceActivity.this); |
1342 | 283 | title.setSummary(getString(R.string.url)); | 283 | title.setSummary(getString(R.string.url)); |
1343 | 284 | title.getEditText().setHint(getString(R.string.url)); | 284 | title.getEditText().setHint(getString(R.string.url)); |
1344 | 285 | title.setTitle(getString(R.string.connection_profile_title)); | 285 | title.setTitle(getString(R.string.connection_profile_title)); |
1345 | 286 | title.setKey(KEY_PREFIX + id + ".title"); | 286 | title.setKey(KEY_PREFIX + id + ".title"); |
1346 | 287 | title.setDefaultValue(getString(R.string.url)); | 287 | title.setDefaultValue(getString(R.string.url)); |
1347 | 288 | title.setSummary(sTitle); | 288 | title.setSummary(sTitle); |
1348 | 289 | title.setDialogTitle(getString(R.string.connection_profile_title)); | 289 | title.setDialogTitle(getString(R.string.connection_profile_title)); |
1349 | 290 | title.setOnPreferenceChangeListener(onPreferenceChangeListener); | 290 | title.setOnPreferenceChangeListener(onPreferenceChangeListener); |
1350 | 291 | 291 | ||
1351 | 292 | hostAddress = new EditTextPreference(ConnectionPreferenceActivity.this); | 292 | hostAddress = new EditTextPreference(ConnectionPreferenceActivity.this); |
1352 | 293 | hostAddress.setTitle(getString(R.string.urlHint)); | 293 | hostAddress.setTitle(getString(R.string.urlHint)); |
1353 | 294 | hostAddress.setKey(KEY_PREFIX + id + ".address"); | 294 | hostAddress.setKey(KEY_PREFIX + id + ".address"); |
1354 | 295 | hostAddress.getEditText().setHint(R.string.urlHint); | 295 | hostAddress.getEditText().setHint(R.string.urlHint); |
1355 | 296 | hostAddress.setSummary(getString(R.string.urlHint)); | 296 | hostAddress.setSummary(getString(R.string.urlHint)); |
1356 | 297 | hostAddress.setDialogTitle(getString(R.string.urlHint)); | 297 | hostAddress.setDialogTitle(getString(R.string.urlHint)); |
1357 | 298 | hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI); | 298 | hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI); |
1358 | 299 | hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener); | 299 | hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener); |
1359 | 300 | 300 | ||
1360 | 301 | hostPort = new EditTextPreference(ConnectionPreferenceActivity.this); | 301 | hostPort = new EditTextPreference(ConnectionPreferenceActivity.this); |
1361 | 302 | hostPort.setTitle(getString(R.string.port)); | 302 | hostPort.setTitle(getString(R.string.port)); |
1362 | 303 | hostPort.setKey(KEY_PREFIX + id + ".port"); | 303 | hostPort.setKey(KEY_PREFIX + id + ".port"); |
1363 | 304 | hostPort.setSummary(getString(R.string.port)); | 304 | hostPort.setSummary(getString(R.string.port)); |
1364 | 305 | hostPort.setDialogTitle(getString(R.string.port)); | 305 | hostPort.setDialogTitle(getString(R.string.port)); |
1365 | 306 | hostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); | 306 | hostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); |
1366 | 307 | hostPort.setDefaultValue(getString(R.string.portDefaultValue)); | 307 | hostPort.setDefaultValue(getString(R.string.portDefaultValue)); |
1367 | 308 | hostPort.setOnPreferenceChangeListener(onPreferenceChangeListener); | 308 | hostPort.setOnPreferenceChangeListener(onPreferenceChangeListener); |
1368 | 309 | 309 | ||
1369 | 310 | useSsl = new CheckBoxPreference(ConnectionPreferenceActivity.this); | 310 | useSsl = new CheckBoxPreference(ConnectionPreferenceActivity.this); |
1370 | 311 | useSsl.setTitle(getString(R.string.connection_profile_ssl_use)); | 311 | useSsl.setTitle(getString(R.string.connection_profile_ssl_use)); |
1371 | 312 | useSsl.setSummary(getString(R.string.connection_profile_ssl_summary)); | 312 | useSsl.setSummary(getString(R.string.connection_profile_ssl_summary)); |
1372 | 313 | useSsl.setKey(KEY_PREFIX + id + ".usessl"); | 313 | useSsl.setKey(KEY_PREFIX + id + ".usessl"); |
1373 | 314 | 314 | ||
1374 | 315 | userid = new EditTextPreference(ConnectionPreferenceActivity.this); | 315 | userid = new EditTextPreference(ConnectionPreferenceActivity.this); |
1375 | 316 | userid.setSummary(getString(R.string.connection_userid)); | 316 | userid.setSummary(getString(R.string.connection_userid)); |
1376 | @@ -332,92 +332,92 @@ | |||
1377 | 332 | password.setDialogTitle(getString(R.string.connection_password)); | 332 | password.setDialogTitle(getString(R.string.connection_password)); |
1378 | 333 | password.setOnPreferenceChangeListener(onPreferenceChangeListener); | 333 | password.setOnPreferenceChangeListener(onPreferenceChangeListener); |
1379 | 334 | 334 | ||
1392 | 335 | remove = new Preference(ConnectionPreferenceActivity.this); | 335 | remove = new Preference(ConnectionPreferenceActivity.this); |
1393 | 336 | remove.setTitle(getString(R.string.connection_profile_remove)); | 336 | remove.setTitle(getString(R.string.connection_profile_remove)); |
1394 | 337 | remove.setSummary(getString(R.string.connection_profile_remove_summary)); | 337 | remove.setSummary(getString(R.string.connection_profile_remove_summary)); |
1395 | 338 | remove.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { | 338 | remove.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { |
1396 | 339 | @Override | 339 | @Override |
1397 | 340 | public boolean onPreferenceClick(Preference preference) { | 340 | public boolean onPreferenceClick(Preference preference) { |
1398 | 341 | SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); | 341 | SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); |
1399 | 342 | SharedPreferences.Editor editor = prefs.edit(); | 342 | SharedPreferences.Editor editor = prefs.edit(); |
1400 | 343 | editor.remove(hostAddress.getKey()); | 343 | editor.remove(hostAddress.getKey()); |
1401 | 344 | editor.remove(hostPort.getKey()); | 344 | editor.remove(hostPort.getKey()); |
1402 | 345 | editor.remove(title.getKey()); | 345 | editor.remove(title.getKey()); |
1403 | 346 | editor.remove(useSsl.getKey()); | 346 | editor.remove(useSsl.getKey()); |
1404 | 347 | editor.remove(userid.getKey()); | 347 | editor.remove(userid.getKey()); |
1405 | 348 | editor.remove(password.getKey()); | 348 | editor.remove(password.getKey()); |
1411 | 349 | editor.commit(); | 349 | editor.commit(); |
1412 | 350 | ConnectionPreferenceActivity.this.onBackPressed(); | 350 | ConnectionPreferenceActivity.this.onBackPressed(); |
1413 | 351 | return false; | 351 | return false; |
1414 | 352 | } | 352 | } |
1415 | 353 | }); | 353 | }); |
1416 | 354 | 354 | ||
1433 | 355 | activate = new Preference(ConnectionPreferenceActivity.this); | 355 | activate = new Preference(ConnectionPreferenceActivity.this); |
1434 | 356 | activate.setTitle(getString(R.string.connection_profile_activate)); | 356 | activate.setTitle(getString(R.string.connection_profile_activate)); |
1435 | 357 | activate.setSummary(getString(R.string.connection_profile_summary_activate)); | 357 | activate.setSummary(getString(R.string.connection_profile_summary_activate)); |
1436 | 358 | activate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { | 358 | activate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { |
1437 | 359 | @Override | 359 | @Override |
1438 | 360 | public boolean onPreferenceClick(Preference preference) { | 360 | public boolean onPreferenceClick(Preference preference) { |
1439 | 361 | SharedPreferences preferences = getPreferenceManager().getSharedPreferences(); | 361 | SharedPreferences preferences = getPreferenceManager().getSharedPreferences(); |
1440 | 362 | SharedPreferences.Editor editor = preferences.edit(); | 362 | SharedPreferences.Editor editor = preferences.edit(); |
1441 | 363 | String host = preferences.getString(hostAddress.getKey(), | 363 | String host = preferences.getString(hostAddress.getKey(), |
1442 | 364 | getString(R.string.hostDefaultValue)); | 364 | getString(R.string.hostDefaultValue)); |
1443 | 365 | editor.putString(getString(R.string.keyHost), host); | 365 | editor.putString(getString(R.string.keyHost), host); |
1444 | 366 | String port = preferences.getString(hostPort.getKey(), | 366 | String port = preferences.getString(hostPort.getKey(), |
1445 | 367 | getString(R.string.portDefaultValue)); | 367 | getString(R.string.portDefaultValue)); |
1446 | 368 | editor.putString(getString(R.string.keyPort), port); | 368 | editor.putString(getString(R.string.keyPort), port); |
1447 | 369 | Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false); | 369 | Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false); |
1448 | 370 | editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl); | 370 | editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl); |
1449 | 371 | String suserid = preferences.getString(userid.getKey(), getString(R.string.useridDefaultValue)); | 371 | String suserid = preferences.getString(userid.getKey(), getString(R.string.useridDefaultValue)); |
1450 | 372 | editor.putString(getString(R.string.key_userid), suserid); | 372 | editor.putString(getString(R.string.key_userid), suserid); |
1451 | 373 | String spassword = preferences.getString(password.getKey(), | 373 | String spassword = preferences.getString(password.getKey(), |
1452 | 374 | getString(R.string.passwordDefaultValue)); | 374 | getString(R.string.passwordDefaultValue)); |
1453 | 375 | editor.putString(getString(R.string.key_password), spassword); | 375 | editor.putString(getString(R.string.key_password), spassword); |
1454 | 376 | 376 | ||
1501 | 377 | editor.putString( | 377 | editor.putString( |
1502 | 378 | getString(R.string.key_profile_selected_title), | 378 | getString(R.string.key_profile_selected_title), |
1503 | 379 | preferences.getString( | 379 | preferences.getString( |
1504 | 380 | title.getKey(), | 380 | title.getKey(), |
1505 | 381 | getString(R.string.url))); | 381 | getString(R.string.url))); |
1506 | 382 | 382 | ||
1507 | 383 | editor.commit(); | 383 | editor.commit(); |
1508 | 384 | Toast.makeText(ConnectionPreferenceActivity.this, | 384 | Toast.makeText(ConnectionPreferenceActivity.this, |
1509 | 385 | String.format( | 385 | String.format( |
1510 | 386 | "%s: %s\n[%s:%s] %s", | 386 | "%s: %s\n[%s:%s] %s", |
1511 | 387 | getString(R.string.connection_profile_active_toast), | 387 | getString(R.string.connection_profile_active_toast), |
1512 | 388 | HostConfig.this.title.getText(), | 388 | HostConfig.this.title.getText(), |
1513 | 389 | host, | 389 | host, |
1514 | 390 | port, | 390 | port, |
1515 | 391 | useSsl.isChecked() ? "(SSL)" : "" | 391 | useSsl.isChecked() ? "(SSL)" : "" |
1516 | 392 | ), | 392 | ), |
1517 | 393 | Toast.LENGTH_LONG).show(); | 393 | Toast.LENGTH_LONG).show(); |
1518 | 394 | return false; | 394 | return false; |
1519 | 395 | } | 395 | } |
1520 | 396 | }); | 396 | }); |
1521 | 397 | } | 397 | } |
1522 | 398 | 398 | ||
1523 | 399 | @Override | 399 | @Override |
1524 | 400 | public String toString() { | 400 | public String toString() { |
1525 | 401 | return "HostConfig{" + | 401 | return "HostConfig{" + |
1526 | 402 | "id=" + id + | 402 | "id=" + id + |
1527 | 403 | ", title='" + title + '\'' + | 403 | ", title='" + title + '\'' + |
1528 | 404 | ", hostAddress=" + hostAddress.getKey() + | 404 | ", hostAddress=" + hostAddress.getKey() + |
1529 | 405 | ", hostPort=" + hostPort.getKey() + | 405 | ", hostPort=" + hostPort.getKey() + |
1530 | 406 | '}'; | 406 | '}'; |
1531 | 407 | } | 407 | } |
1532 | 408 | 408 | ||
1533 | 409 | Preference.OnPreferenceChangeListener onPreferenceChangeListener = | 409 | Preference.OnPreferenceChangeListener onPreferenceChangeListener = |
1534 | 410 | new Preference.OnPreferenceChangeListener() { | 410 | new Preference.OnPreferenceChangeListener() { |
1535 | 411 | @Override | 411 | @Override |
1536 | 412 | public boolean onPreferenceChange(Preference preference, Object o) { | 412 | public boolean onPreferenceChange(Preference preference, Object o) { |
1537 | 413 | preference.setSummary("" + o); | 413 | preference.setSummary("" + o); |
1538 | 414 | if (preference.getKey().endsWith(".title")) { | 414 | if (preference.getKey().endsWith(".title")) { |
1539 | 415 | preferenceScreen | 415 | preferenceScreen |
1540 | 416 | .findPreference("key.preference.category") | 416 | .findPreference("key.preference.category") |
1541 | 417 | .setTitle("" + o); | 417 | .setTitle("" + o); |
1542 | 418 | } | 418 | } |
1543 | 419 | return true; | 419 | return true; |
1544 | 420 | } | 420 | } |
1545 | 421 | }; | 421 | }; |
1546 | 422 | } | 422 | } |
1547 | 423 | } | 423 | } |
1548 | 424 | 424 | ||
1549 | === modified file 'src/org/openlp/android/activity/preference/Preferences.java' | |||
1550 | --- src/org/openlp/android/activity/preference/Preferences.java 2013-04-06 13:44:51 +0000 | |||
1551 | +++ src/org/openlp/android/activity/preference/Preferences.java 2013-06-04 19:32:29 +0000 | |||
1552 | @@ -50,99 +50,100 @@ | |||
1553 | 50 | buildPreferences(); | 50 | buildPreferences(); |
1554 | 51 | } | 51 | } |
1555 | 52 | 52 | ||
1637 | 53 | private void buildPreferences() { | 53 | private void buildPreferences() { |
1638 | 54 | if (getPreferenceScreen() != null) getPreferenceScreen().removeAll(); | 54 | if (getPreferenceScreen() != null) getPreferenceScreen().removeAll(); |
1639 | 55 | 55 | ||
1640 | 56 | getPreferenceManager() | 56 | getPreferenceManager() |
1641 | 57 | .setSharedPreferencesName(getString(R.string.keySharedPreferences)); | 57 | .setSharedPreferencesName(getString(R.string.keySharedPreferences)); |
1642 | 58 | 58 | ||
1643 | 59 | addPreferencesFromResource(R.xml.preferences); | 59 | addPreferencesFromResource(R.xml.preferences); |
1644 | 60 | final SharedPreferences sharedPreferences = getPreferenceManager() | 60 | final SharedPreferences sharedPreferences = getPreferenceManager() |
1645 | 61 | .getSharedPreferences(); | 61 | .getSharedPreferences(); |
1646 | 62 | 62 | ||
1647 | 63 | StringBuilder stringBuilder = new StringBuilder(); | 63 | StringBuilder stringBuilder = new StringBuilder(); |
1648 | 64 | stringBuilder.append(sharedPreferences.getString( | 64 | stringBuilder.append(sharedPreferences.getString( |
1649 | 65 | getString(R.string.keyHost), | 65 | getString(R.string.keyHost), |
1650 | 66 | getString(R.string.notSet))); | 66 | getString(R.string.notSet))); |
1651 | 67 | stringBuilder.append(":"); | 67 | stringBuilder.append(":"); |
1652 | 68 | 68 | ||
1653 | 69 | Boolean useSsl = sharedPreferences.getBoolean( | 69 | Boolean useSsl = sharedPreferences.getBoolean( |
1654 | 70 | getString(R.string.key_ssl_use), false); | 70 | getString(R.string.key_ssl_use), false); |
1655 | 71 | stringBuilder.append( | 71 | stringBuilder.append( |
1656 | 72 | String.format("%s %s", | 72 | String.format("%s %s", |
1657 | 73 | sharedPreferences.getString( | 73 | sharedPreferences.getString( |
1658 | 74 | getString(R.string.keyPort), | 74 | getString(R.string.keyPort), |
1659 | 75 | getString(R.string.notSet)), useSsl ? "(SSL)" : "")); | 75 | getString(R.string.notSet)), useSsl ? "(SSL)" : "")); |
1660 | 76 | 76 | ||
1661 | 77 | final Preference hostPreference = findPreference(getString(R.string.keyHost)); | 77 | final Preference hostPreference = findPreference(getString(R.string.keyHost)); |
1662 | 78 | hostPreference.setTitle( | 78 | hostPreference.setTitle( |
1663 | 79 | getPreferenceManager().getSharedPreferences() | 79 | getPreferenceManager().getSharedPreferences() |
1664 | 80 | .getString( | 80 | .getString( |
1665 | 81 | getString(R.string.key_profile_selected_title), | 81 | getString(R.string.key_profile_selected_title), |
1666 | 82 | getString(R.string.url) | 82 | getString(R.string.url) |
1667 | 83 | ) | 83 | ) |
1668 | 84 | ); | 84 | ); |
1669 | 85 | hostPreference.setSummary(stringBuilder.toString()); | 85 | hostPreference.setSummary(stringBuilder.toString()); |
1670 | 86 | 86 | ||
1671 | 87 | PackageManager manager = this.getPackageManager(); | 87 | PackageManager manager = this.getPackageManager(); |
1672 | 88 | String version = ""; | 88 | String version = ""; |
1673 | 89 | try { | 89 | try { |
1674 | 90 | PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0); | 90 | PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0); |
1675 | 91 | version = info.versionName; | 91 | version = info.versionName; |
1676 | 92 | } catch (PackageManager.NameNotFoundException ignored) {} | 92 | } catch (PackageManager.NameNotFoundException ignored) { |
1677 | 93 | 93 | } | |
1678 | 94 | String date = new SimpleDateFormat("yyyy").format(new Date()); | 94 | |
1679 | 95 | 95 | String date = new SimpleDateFormat("yyyy").format(new Date()); | |
1680 | 96 | //Preferences time! (we build the preferences) | 96 | |
1681 | 97 | Preference about = getPreference(getString(R.string.about_text), version, null); | 97 | //Preferences time! (we build the preferences) |
1682 | 98 | about.setSelectable(false); | 98 | Preference about = getPreference(getString(R.string.about_text), version, null); |
1683 | 99 | Preference openlpLink = getPreference( | 99 | about.setSelectable(false); |
1684 | 100 | getString(R.string.about_display_3), | 100 | Preference openlpLink = getPreference( |
1685 | 101 | getString(R.string.about_display_1), | 101 | getString(R.string.about_display_3), |
1686 | 102 | new Intent(Intent.ACTION_VIEW, Uri.parse("http://openlp.org/"))); | 102 | getString(R.string.about_display_1), |
1687 | 103 | 103 | new Intent(Intent.ACTION_VIEW, Uri.parse("http://openlp.org/"))); | |
1688 | 104 | StringBuilder html = new StringBuilder(); | 104 | |
1689 | 105 | html.append(getString(R.string.about_display_4)); | 105 | StringBuilder html = new StringBuilder(); |
1690 | 106 | html.append(" © 2004-").append(date).append(" Raoul Snyman\n"); | 106 | html.append(getString(R.string.about_display_4)); |
1691 | 107 | html.append(getString(R.string.about_display_5)); | 107 | html.append(" © 2004-").append(date).append(" Raoul Snyman\n"); |
1692 | 108 | html.append(" © 2004-").append(date); | 108 | html.append(getString(R.string.about_display_5)); |
1693 | 109 | html.append("\nTim Bentley, Johan Mynhardt, Samuel Sjöbergsson"); | 109 | html.append(" © 2004-").append(date); |
1694 | 110 | 110 | html.append("\nTim Bentley, Johan Mynhardt, Samuel Sjöbergsson"); | |
1695 | 111 | Preference copyright = getPreference( | 111 | |
1696 | 112 | getString(R.string.about_display_4), | 112 | Preference copyright = getPreference( |
1697 | 113 | html.toString(), null); | 113 | getString(R.string.about_display_4), |
1698 | 114 | copyright.setSelectable(false); | 114 | html.toString(), null); |
1699 | 115 | 115 | copyright.setSelectable(false); | |
1700 | 116 | DialogPreference license = new MyDialogPreference( | 116 | |
1701 | 117 | this, | 117 | DialogPreference license = new MyDialogPreference( |
1702 | 118 | getString(R.string.about_display_6), | 118 | this, |
1703 | 119 | String.format( | 119 | getString(R.string.about_display_6), |
1704 | 120 | "%s\n%s", | 120 | String.format( |
1705 | 121 | getString(R.string.about_display_7), | 121 | "%s\n%s", |
1706 | 122 | getString(R.string.about_display_8) | 122 | getString(R.string.about_display_7), |
1707 | 123 | ) | 123 | getString(R.string.about_display_8) |
1708 | 124 | ); | 124 | ) |
1709 | 125 | 125 | ); | |
1710 | 126 | 126 | ||
1711 | 127 | PreferenceScreen preferenceScreen = getPreferenceScreen(); | 127 | |
1712 | 128 | addPreferenceCategory(preferenceScreen,getString(R.string.about), | 128 | PreferenceScreen preferenceScreen = getPreferenceScreen(); |
1713 | 129 | about, openlpLink, copyright, license); | 129 | addPreferenceCategory(preferenceScreen, getString(R.string.about), |
1714 | 130 | 130 | about, openlpLink, copyright, license); | |
1715 | 131 | Preference preference = findPreference(getString(R.string.keyHost)); | 131 | |
1716 | 132 | preference.setIntent(new Intent(this, ConnectionPreferenceActivity.class)); | 132 | Preference preference = findPreference(getString(R.string.keyHost)); |
1717 | 133 | } | 133 | preference.setIntent(new Intent(this, ConnectionPreferenceActivity.class)); |
1718 | 134 | } | ||
1719 | 134 | 135 | ||
1720 | 135 | private boolean addPreferenceCategory(PreferenceScreen preferenceScreen, | 136 | private boolean addPreferenceCategory(PreferenceScreen preferenceScreen, |
1726 | 136 | String titleCategory, Preference... preferences) { | 137 | String titleCategory, Preference... preferences) { |
1727 | 137 | 138 | ||
1728 | 138 | boolean addPreference = false; | 139 | boolean addPreference = false; |
1729 | 139 | 140 | ||
1730 | 140 | for (Preference preference : preferences) { | 141 | for (Preference preference : preferences) { |
1731 | 141 | if (preference != null) | 142 | if (preference != null) |
1732 | 142 | addPreference = true; | 143 | addPreference = true; |
1733 | 143 | } | 144 | } |
1734 | 144 | 145 | ||
1736 | 145 | if (addPreference) { | 146 | if (addPreference) { |
1737 | 146 | PreferenceCategory preferenceCategory = new PreferenceCategory(this); | 147 | PreferenceCategory preferenceCategory = new PreferenceCategory(this); |
1738 | 147 | preferenceCategory.setTitle(titleCategory); | 148 | preferenceCategory.setTitle(titleCategory); |
1739 | 148 | preferenceScreen.addPreference(preferenceCategory); | 149 | preferenceScreen.addPreference(preferenceCategory); |
1740 | @@ -178,12 +179,12 @@ | |||
1741 | 178 | Log.d(LOG_TAG, "Destroying preferences"); | 179 | Log.d(LOG_TAG, "Destroying preferences"); |
1742 | 179 | } | 180 | } |
1743 | 180 | 181 | ||
1750 | 181 | @Override | 182 | @Override |
1751 | 182 | protected void onResume() { | 183 | protected void onResume() { |
1752 | 183 | super.onResume(); | 184 | super.onResume(); |
1753 | 184 | Log.i(LOG_TAG, "Resuming Preferences..."); | 185 | Log.i(LOG_TAG, "Resuming Preferences..."); |
1754 | 185 | buildPreferences(); | 186 | buildPreferences(); |
1755 | 186 | } | 187 | } |
1756 | 187 | 188 | ||
1758 | 188 | private final String LOG_TAG = Preferences.class.getName(); | 189 | private final String LOG_TAG = Preferences.class.getName(); |
1759 | 189 | } | 190 | } |
1760 | 190 | 191 | ||
1761 | === modified file 'src/org/openlp/android/api/Api.java' | |||
1762 | --- src/org/openlp/android/api/Api.java 2013-04-06 13:44:51 +0000 | |||
1763 | +++ src/org/openlp/android/api/Api.java 2013-06-04 19:32:29 +0000 | |||
1764 | @@ -91,32 +91,40 @@ | |||
1765 | 91 | 91 | ||
1766 | 92 | public interface Api { | 92 | public interface Api { |
1767 | 93 | 93 | ||
1796 | 94 | public final String LIVE_BASE = "/api/controller/live/"; | 94 | public final String LIVE_BASE = "/api/controller/live/"; |
1797 | 95 | public final String LIVE_NEXT = "/api/controller/live/next"; | 95 | public final String LIVE_NEXT = "/api/controller/live/next"; |
1798 | 96 | public final String LIVE_PREVIOUS = "/api/controller/live/previous"; | 96 | public final String LIVE_PREVIOUS = "/api/controller/live/previous"; |
1799 | 97 | public final String LIVE_TEXT = "/api/controller/live/text"; | 97 | public final String LIVE_TEXT = "/api/controller/live/text"; |
1800 | 98 | public final String LIVE_SET = "/api/controller/live/set?data="; | 98 | public final String LIVE_SET = "/api/controller/live/set?data="; |
1801 | 99 | 99 | ||
1802 | 100 | /** Use with {@link #SERVICE_BASE} + (previous|next) */ | 100 | /** |
1803 | 101 | public final String SERVICE_BASE = "/api/service/"; | 101 | * Use with {@link #SERVICE_BASE} + (previous|next) |
1804 | 102 | // todo: cleanup, use {@link #SERVICE_BASE} | 102 | */ |
1805 | 103 | public final String SERVICE_LIST = "/api/service/list"; | 103 | public final String SERVICE_BASE = "/api/service/"; |
1806 | 104 | public final String SERVICE_SET = "/api/service/set?data="; | 104 | // todo: cleanup, use {@link #SERVICE_BASE} |
1807 | 105 | 105 | public final String SERVICE_LIST = "/api/service/list"; | |
1808 | 106 | /** Use with {@link #DISPLAY_BASE} + (blank|theme|desktop|show) */ | 106 | public final String SERVICE_SET = "/api/service/set?data="; |
1809 | 107 | public final String DISPLAY_BASE = "/api/display/"; | 107 | |
1810 | 108 | public final String POLL_STATUS = "/api/poll"; | 108 | /** |
1811 | 109 | 109 | * Use with {@link #DISPLAY_BASE} + (blank|theme|desktop|show) | |
1812 | 110 | public final String ALERT = "/api/alert?data="; | 110 | */ |
1813 | 111 | 111 | public final String DISPLAY_BASE = "/api/display/"; | |
1814 | 112 | public final String SEARCHABLE_PLUGINS = "/api/plugin/search"; | 112 | public final String POLL_STATUS = "/api/poll"; |
1815 | 113 | /** | 113 | |
1816 | 114 | * This is a special string that uses the String.format() method. See | 114 | public final String ALERT = "/api/alert?data="; |
1817 | 115 | * {@link String#format(String, Object...)} | 115 | |
1818 | 116 | */ | 116 | public final String SEARCHABLE_PLUGINS = "/api/plugin/search"; |
1819 | 117 | public final String SEARCH_PLUGIN_FORMATTED = "/api/%s/search?data="; | 117 | /** |
1820 | 118 | /** Match intent extra key with regex since multiple plugins can be inserted */ | 118 | * This is a special string that uses the String.format() method. See |
1821 | 119 | public final String SEARCH_PLUGIN_ADD = "/api/%s/add?data="; | 119 | * {@link String#format(String, Object...)} |
1822 | 120 | /** Match intent extra key with regex since multiple plugins can be inserted */ | 120 | */ |
1823 | 121 | public final String SEARCH_PLUGIN_LIVE = "/api/%s/live?data="; | 121 | public final String SEARCH_PLUGIN_FORMATTED = "/api/%s/search?data="; |
1824 | 122 | /** | ||
1825 | 123 | * Match intent extra key with regex since multiple plugins can be inserted | ||
1826 | 124 | */ | ||
1827 | 125 | public final String SEARCH_PLUGIN_ADD = "/api/%s/add?data="; | ||
1828 | 126 | /** | ||
1829 | 127 | * Match intent extra key with regex since multiple plugins can be inserted | ||
1830 | 128 | */ | ||
1831 | 129 | public final String SEARCH_PLUGIN_LIVE = "/api/%s/live?data="; | ||
1832 | 122 | } | 130 | } |
1833 | 123 | 131 | ||
1834 | === modified file 'src/org/openlp/android/data/Poll.java' | |||
1835 | --- src/org/openlp/android/data/Poll.java 2013-04-06 13:44:51 +0000 | |||
1836 | +++ src/org/openlp/android/data/Poll.java 2013-06-04 19:32:29 +0000 | |||
1837 | @@ -23,99 +23,99 @@ | |||
1838 | 23 | 23 | ||
1839 | 24 | public class Poll { | 24 | public class Poll { |
1840 | 25 | 25 | ||
1936 | 26 | private int slide; | 26 | private int slide; |
1937 | 27 | private String item; | 27 | private String item; |
1938 | 28 | private int service = -1; | 28 | private int service = -1; |
1939 | 29 | private boolean twelveHourDisplay = false; | 29 | private boolean twelveHourDisplay = false; |
1940 | 30 | private boolean blankedDisplayed = false; | 30 | private boolean blankedDisplayed = false; |
1941 | 31 | private boolean themeDisplayed = false; | 31 | private boolean themeDisplayed = false; |
1942 | 32 | private boolean desktopDisplayed = false; | 32 | private boolean desktopDisplayed = false; |
1943 | 33 | private boolean displayHidden = false; | 33 | private boolean displayHidden = false; |
1944 | 34 | 34 | ||
1945 | 35 | public int getSlide() { | 35 | public int getSlide() { |
1946 | 36 | return slide; | 36 | return slide; |
1947 | 37 | } | 37 | } |
1948 | 38 | 38 | ||
1949 | 39 | public void setSlide(int slide) { | 39 | public void setSlide(int slide) { |
1950 | 40 | this.slide = slide; | 40 | this.slide = slide; |
1951 | 41 | } | 41 | } |
1952 | 42 | 42 | ||
1953 | 43 | public String getItem() { | 43 | public String getItem() { |
1954 | 44 | return item; | 44 | return item; |
1955 | 45 | } | 45 | } |
1956 | 46 | 46 | ||
1957 | 47 | public void setItem(String item) { | 47 | public void setItem(String item) { |
1958 | 48 | this.item = item; | 48 | this.item = item; |
1959 | 49 | } | 49 | } |
1960 | 50 | 50 | ||
1961 | 51 | public boolean isTwelveHourDisplay() { | 51 | public boolean isTwelveHourDisplay() { |
1962 | 52 | return twelveHourDisplay; | 52 | return twelveHourDisplay; |
1963 | 53 | } | 53 | } |
1964 | 54 | 54 | ||
1965 | 55 | public void setTwelveHourDisplay(boolean twelveHourDisplay) { | 55 | public void setTwelveHourDisplay(boolean twelveHourDisplay) { |
1966 | 56 | this.twelveHourDisplay = twelveHourDisplay; | 56 | this.twelveHourDisplay = twelveHourDisplay; |
1967 | 57 | } | 57 | } |
1968 | 58 | 58 | ||
1969 | 59 | public boolean isBlankedDisplayed() { | 59 | public boolean isBlankedDisplayed() { |
1970 | 60 | return blankedDisplayed; | 60 | return blankedDisplayed; |
1971 | 61 | } | 61 | } |
1972 | 62 | 62 | ||
1973 | 63 | public void setBlankedDisplayed(boolean blankedDisplayed) { | 63 | public void setBlankedDisplayed(boolean blankedDisplayed) { |
1974 | 64 | this.blankedDisplayed = blankedDisplayed; | 64 | this.blankedDisplayed = blankedDisplayed; |
1975 | 65 | if (blankedDisplayed) { | 65 | if (blankedDisplayed) { |
1976 | 66 | this.displayHidden = true; | 66 | this.displayHidden = true; |
1977 | 67 | } | 67 | } |
1978 | 68 | } | 68 | } |
1979 | 69 | 69 | ||
1980 | 70 | public boolean isThemeDisplayed() { | 70 | public boolean isThemeDisplayed() { |
1981 | 71 | return themeDisplayed; | 71 | return themeDisplayed; |
1982 | 72 | } | 72 | } |
1983 | 73 | 73 | ||
1984 | 74 | public void setThemeDisplayed(boolean themeDisplayed) { | 74 | public void setThemeDisplayed(boolean themeDisplayed) { |
1985 | 75 | this.themeDisplayed = themeDisplayed; | 75 | this.themeDisplayed = themeDisplayed; |
1986 | 76 | if (themeDisplayed) { | 76 | if (themeDisplayed) { |
1987 | 77 | this.displayHidden = true; | 77 | this.displayHidden = true; |
1988 | 78 | } | 78 | } |
1989 | 79 | } | 79 | } |
1990 | 80 | 80 | ||
1991 | 81 | public boolean isDesktopDisplayed() { | 81 | public boolean isDesktopDisplayed() { |
1992 | 82 | return desktopDisplayed; | 82 | return desktopDisplayed; |
1993 | 83 | } | 83 | } |
1994 | 84 | 84 | ||
1995 | 85 | public void setDesktopDisplayed(boolean desktopDisplayed) { | 85 | public void setDesktopDisplayed(boolean desktopDisplayed) { |
1996 | 86 | this.desktopDisplayed = desktopDisplayed; | 86 | this.desktopDisplayed = desktopDisplayed; |
1997 | 87 | if (desktopDisplayed) { | 87 | if (desktopDisplayed) { |
1998 | 88 | this.displayHidden = true; | 88 | this.displayHidden = true; |
1999 | 89 | } | 89 | } |
2000 | 90 | } | 90 | } |
2001 | 91 | 91 | ||
2002 | 92 | public boolean isDisplayHidden() { | 92 | public boolean isDisplayHidden() { |
2003 | 93 | return displayHidden; | 93 | return displayHidden; |
2004 | 94 | } | 94 | } |
2005 | 95 | 95 | ||
2006 | 96 | public void setDisplayHidden(boolean displayHidden) { | 96 | public void setDisplayHidden(boolean displayHidden) { |
2007 | 97 | this.displayHidden = displayHidden; | 97 | this.displayHidden = displayHidden; |
2008 | 98 | } | 98 | } |
2009 | 99 | 99 | ||
2010 | 100 | public int getService() { | 100 | public int getService() { |
2011 | 101 | return service; | 101 | return service; |
2012 | 102 | } | 102 | } |
2013 | 103 | 103 | ||
2014 | 104 | public void setService(int service) { | 104 | public void setService(int service) { |
2015 | 105 | this.service = service; | 105 | this.service = service; |
2016 | 106 | } | 106 | } |
2017 | 107 | 107 | ||
2018 | 108 | @Override | 108 | @Override |
2019 | 109 | public String toString() { | 109 | public String toString() { |
2020 | 110 | return "Poll{" + | 110 | return "Poll{" + |
2021 | 111 | "slide=" + slide + | 111 | "slide=" + slide + |
2022 | 112 | ", item='" + item + '\'' + | 112 | ", item='" + item + '\'' + |
2023 | 113 | ", service=" + service + | 113 | ", service=" + service + |
2024 | 114 | ", twelveHourDisplay=" + twelveHourDisplay + | 114 | ", twelveHourDisplay=" + twelveHourDisplay + |
2025 | 115 | ", blankedDisplayed=" + blankedDisplayed + | 115 | ", blankedDisplayed=" + blankedDisplayed + |
2026 | 116 | ", themeDisplayed=" + themeDisplayed + | 116 | ", themeDisplayed=" + themeDisplayed + |
2027 | 117 | ", desktopDisplayed=" + desktopDisplayed + | 117 | ", desktopDisplayed=" + desktopDisplayed + |
2028 | 118 | ", displayHidden=" + displayHidden + | 118 | ", displayHidden=" + displayHidden + |
2029 | 119 | '}'; | 119 | '}'; |
2030 | 120 | } | 120 | } |
2031 | 121 | } | 121 | } |
2032 | 122 | 122 | ||
2033 | === modified file 'src/org/openlp/android/data/SlideItem.java' | |||
2034 | --- src/org/openlp/android/data/SlideItem.java 2013-04-06 13:44:51 +0000 | |||
2035 | +++ src/org/openlp/android/data/SlideItem.java 2013-06-04 19:32:29 +0000 | |||
2036 | @@ -21,46 +21,46 @@ | |||
2037 | 21 | package org.openlp.android.data; | 21 | package org.openlp.android.data; |
2038 | 22 | 22 | ||
2039 | 23 | public class SlideItem { | 23 | public class SlideItem { |
2082 | 24 | private String text; | 24 | private String text; |
2083 | 25 | private boolean selected; | 25 | private boolean selected; |
2084 | 26 | private String tag; | 26 | private String tag; |
2085 | 27 | private String html; | 27 | private String html; |
2086 | 28 | 28 | ||
2087 | 29 | public String getText() { | 29 | public String getText() { |
2088 | 30 | return text; | 30 | return text; |
2089 | 31 | } | 31 | } |
2090 | 32 | 32 | ||
2091 | 33 | public void setText(String text) { | 33 | public void setText(String text) { |
2092 | 34 | this.text = text; | 34 | this.text = text; |
2093 | 35 | } | 35 | } |
2094 | 36 | 36 | ||
2095 | 37 | public boolean isSelected() { | 37 | public boolean isSelected() { |
2096 | 38 | return selected; | 38 | return selected; |
2097 | 39 | } | 39 | } |
2098 | 40 | 40 | ||
2099 | 41 | public void setSelected(boolean selected) { | 41 | public void setSelected(boolean selected) { |
2100 | 42 | this.selected = selected; | 42 | this.selected = selected; |
2101 | 43 | } | 43 | } |
2102 | 44 | 44 | ||
2103 | 45 | public String getTag() { | 45 | public String getTag() { |
2104 | 46 | return tag; | 46 | return tag; |
2105 | 47 | } | 47 | } |
2106 | 48 | 48 | ||
2107 | 49 | public void setTag(String tag) { | 49 | public void setTag(String tag) { |
2108 | 50 | this.tag = tag; | 50 | this.tag = tag; |
2109 | 51 | } | 51 | } |
2110 | 52 | 52 | ||
2111 | 53 | public String getHtml() { | 53 | public String getHtml() { |
2112 | 54 | return html; | 54 | return html; |
2113 | 55 | } | 55 | } |
2114 | 56 | 56 | ||
2115 | 57 | public void setHtml(String html) { | 57 | public void setHtml(String html) { |
2116 | 58 | this.html = html; | 58 | this.html = html; |
2117 | 59 | } | 59 | } |
2118 | 60 | 60 | ||
2119 | 61 | @Override | 61 | @Override |
2120 | 62 | public String toString() { | 62 | public String toString() { |
2121 | 63 | return "SlidePOJO{" + "text='" + text + '\'' + ", selected=" + selected | 63 | return "SlidePOJO{" + "text='" + text + '\'' + ", selected=" + selected |
2122 | 64 | + ", tag='" + tag + '\'' + ", html='" + html + '\'' + '}'; | 64 | + ", tag='" + tag + '\'' + ", html='" + html + '\'' + '}'; |
2123 | 65 | } | 65 | } |
2124 | 66 | } | 66 | } |
2125 | 67 | 67 | ||
2126 | === modified file 'src/org/openlp/android/service/PingIntent.java' | |||
2127 | --- src/org/openlp/android/service/PingIntent.java 2013-04-06 13:44:51 +0000 | |||
2128 | +++ src/org/openlp/android/service/PingIntent.java 2013-06-04 19:32:29 +0000 | |||
2129 | @@ -32,60 +32,60 @@ | |||
2130 | 32 | 32 | ||
2131 | 33 | public class PingIntent extends Service { | 33 | public class PingIntent extends Service { |
2132 | 34 | 34 | ||
2177 | 35 | private Handler handler = new Handler(); | 35 | private Handler handler = new Handler(); |
2178 | 36 | private Integer delay; | 36 | private Integer delay; |
2179 | 37 | 37 | ||
2180 | 38 | public PingIntent() { | 38 | public PingIntent() { |
2181 | 39 | super(); | 39 | super(); |
2182 | 40 | Log.v(LOG_TAG, "Instantiating PingIntent..."); | 40 | Log.v(LOG_TAG, "Instantiating PingIntent..."); |
2183 | 41 | 41 | ||
2184 | 42 | } | 42 | } |
2185 | 43 | 43 | ||
2186 | 44 | @Override | 44 | @Override |
2187 | 45 | public IBinder onBind(Intent intent) { | 45 | public IBinder onBind(Intent intent) { |
2188 | 46 | return null; | 46 | return null; |
2189 | 47 | } | 47 | } |
2190 | 48 | 48 | ||
2191 | 49 | @Override | 49 | @Override |
2192 | 50 | public void onStart(Intent intent, int startId) { | 50 | public void onStart(Intent intent, int startId) { |
2193 | 51 | String PREFERENCES_KEY = | 51 | String PREFERENCES_KEY = |
2194 | 52 | getApplicationContext().getString(R.string.keySharedPreferences); | 52 | getApplicationContext().getString(R.string.keySharedPreferences); |
2195 | 53 | SharedPreferences preferences = getApplicationContext() | 53 | SharedPreferences preferences = getApplicationContext() |
2196 | 54 | .getSharedPreferences(PREFERENCES_KEY, MODE_PRIVATE); | 54 | .getSharedPreferences(PREFERENCES_KEY, MODE_PRIVATE); |
2197 | 55 | Resources resources = getApplicationContext().getResources(); | 55 | Resources resources = getApplicationContext().getResources(); |
2198 | 56 | delay = Integer.valueOf( | 56 | delay = Integer.valueOf( |
2199 | 57 | resources.getString(R.string.backgroundRefreshDefaultValue)); | 57 | resources.getString(R.string.backgroundRefreshDefaultValue)); |
2200 | 58 | Log.v(LOG_TAG, "Starting PingIntent..."); | 58 | Log.v(LOG_TAG, "Starting PingIntent..."); |
2201 | 59 | super.onStart(intent, startId); | 59 | super.onStart(intent, startId); |
2202 | 60 | delay = Integer.parseInt(preferences | 60 | delay = Integer.parseInt(preferences |
2203 | 61 | .getString(resources.getString(R.string.keyBackgroundService), | 61 | .getString(resources.getString(R.string.keyBackgroundService), |
2204 | 62 | delay.toString())); | 62 | delay.toString())); |
2205 | 63 | 63 | ||
2206 | 64 | Log.d(LOG_TAG, "PingIntent delay: " + delay); | 64 | Log.d(LOG_TAG, "PingIntent delay: " + delay); |
2207 | 65 | handler.removeCallbacks(r); | 65 | handler.removeCallbacks(r); |
2208 | 66 | handler.postDelayed(r, delay); | 66 | handler.postDelayed(r, delay); |
2209 | 67 | } | 67 | } |
2210 | 68 | 68 | ||
2211 | 69 | Runnable r = new Runnable() { | 69 | Runnable r = new Runnable() { |
2212 | 70 | 70 | ||
2213 | 71 | @Override | 71 | @Override |
2214 | 72 | public void run() { | 72 | public void run() { |
2215 | 73 | Intent apiCallPingIntent = | 73 | Intent apiCallPingIntent = |
2216 | 74 | new Intent(getApplicationContext(), ApiCallIntent.class); | 74 | new Intent(getApplicationContext(), ApiCallIntent.class); |
2217 | 75 | apiCallPingIntent.putExtra(Api.POLL_STATUS, ""); | 75 | apiCallPingIntent.putExtra(Api.POLL_STATUS, ""); |
2218 | 76 | startService(apiCallPingIntent); | 76 | startService(apiCallPingIntent); |
2219 | 77 | if (delay > 0) { | 77 | if (delay > 0) { |
2220 | 78 | handler.postDelayed(r, delay); | 78 | handler.postDelayed(r, delay); |
2221 | 79 | } | ||
2222 | 79 | } | 80 | } |
2234 | 80 | } | 81 | }; |
2235 | 81 | }; | 82 | |
2236 | 82 | 83 | @Override | |
2237 | 83 | @Override | 84 | public void onDestroy() { |
2238 | 84 | public void onDestroy() { | 85 | Log.v(LOG_TAG, "Stopping PingIntent..."); |
2239 | 85 | Log.v(LOG_TAG, "Stopping PingIntent..."); | 86 | handler.removeCallbacks(r); |
2240 | 86 | handler.removeCallbacks(r); | 87 | super.onDestroy(); |
2241 | 87 | super.onDestroy(); | 88 | } |
2242 | 88 | } | 89 | |
2243 | 89 | 90 | private static final String LOG_TAG = PingIntent.class.getName(); | |
2233 | 90 | private static final String LOG_TAG = PingIntent.class.getName(); | ||
2244 | 91 | } | 91 | } |
2245 | 92 | 92 | ||
2246 | === modified file 'src/org/openlp/android/utility/GroupExpandableListAdapter.java' | |||
2247 | --- src/org/openlp/android/utility/GroupExpandableListAdapter.java 2013-04-06 13:44:51 +0000 | |||
2248 | +++ src/org/openlp/android/utility/GroupExpandableListAdapter.java 2013-06-04 19:32:29 +0000 | |||
2249 | @@ -34,92 +34,91 @@ | |||
2250 | 34 | import java.util.Map; | 34 | import java.util.Map; |
2251 | 35 | 35 | ||
2252 | 36 | public class GroupExpandableListAdapter extends BaseExpandableListAdapter { | 36 | public class GroupExpandableListAdapter extends BaseExpandableListAdapter { |
2341 | 37 | List<String> groups; | 37 | List<String> groups; |
2342 | 38 | List<List<Map<String, JSONArray>>> children; | 38 | List<List<Map<String, JSONArray>>> children; |
2343 | 39 | LayoutInflater inflater; | 39 | LayoutInflater inflater; |
2344 | 40 | Activity context; | 40 | Activity context; |
2345 | 41 | 41 | ||
2346 | 42 | public GroupExpandableListAdapter(Activity context, List<String> groups, | 42 | public GroupExpandableListAdapter(Activity context, List<String> groups, |
2347 | 43 | List<List<Map<String, JSONArray>>> children) { | 43 | List<List<Map<String, JSONArray>>> children) { |
2348 | 44 | this.context = context; | 44 | this.context = context; |
2349 | 45 | this.groups = groups; | 45 | this.groups = groups; |
2350 | 46 | this.children = children; | 46 | this.children = children; |
2351 | 47 | inflater = context.getLayoutInflater(); | 47 | inflater = context.getLayoutInflater(); |
2352 | 48 | } | 48 | } |
2353 | 49 | 49 | ||
2354 | 50 | @Override | 50 | @Override |
2355 | 51 | public int getGroupCount() { | 51 | public int getGroupCount() { |
2356 | 52 | return groups.size(); | 52 | return groups.size(); |
2357 | 53 | } | 53 | } |
2358 | 54 | 54 | ||
2359 | 55 | @Override | 55 | @Override |
2360 | 56 | public int getChildrenCount(int position) { | 56 | public int getChildrenCount(int position) { |
2361 | 57 | return children.get(position).size(); | 57 | return children.get(position).size(); |
2362 | 58 | } | 58 | } |
2363 | 59 | 59 | ||
2364 | 60 | @Override | 60 | @Override |
2365 | 61 | public Object getGroup(int position) { | 61 | public Object getGroup(int position) { |
2366 | 62 | return groups.get(position); | 62 | return groups.get(position); |
2367 | 63 | } | 63 | } |
2368 | 64 | 64 | ||
2369 | 65 | @Override | 65 | @Override |
2370 | 66 | public Object getChild(int rootPosition, int childPosition) { | 66 | public Object getChild(int rootPosition, int childPosition) { |
2371 | 67 | return children.get(rootPosition).get(childPosition); | 67 | return children.get(rootPosition).get(childPosition); |
2372 | 68 | } | 68 | } |
2373 | 69 | 69 | ||
2374 | 70 | @Override | 70 | @Override |
2375 | 71 | public long getGroupId(int position) { | 71 | public long getGroupId(int position) { |
2376 | 72 | return groups.indexOf(groups.get(position)); | 72 | return groups.indexOf(groups.get(position)); |
2377 | 73 | } | 73 | } |
2378 | 74 | 74 | ||
2379 | 75 | @Override | 75 | @Override |
2380 | 76 | public long getChildId(int i, int i1) { | 76 | public long getChildId(int i, int i1) { |
2381 | 77 | List<Map<String, JSONArray>> child = children.get(i); | 77 | List<Map<String, JSONArray>> child = children.get(i); |
2382 | 78 | return child.indexOf(child.get(i1)); | 78 | return child.indexOf(child.get(i1)); |
2383 | 79 | } | 79 | } |
2384 | 80 | 80 | ||
2385 | 81 | @Override | 81 | @Override |
2386 | 82 | public boolean hasStableIds() { | 82 | public boolean hasStableIds() { |
2387 | 83 | return false; | 83 | return false; |
2388 | 84 | } | 84 | } |
2389 | 85 | 85 | ||
2390 | 86 | @Override | 86 | @Override |
2391 | 87 | public View getGroupView(int position, boolean b, View view, | 87 | public View getGroupView(int position, boolean b, View view, |
2392 | 88 | ViewGroup viewGroup) { | 88 | ViewGroup viewGroup) { |
2393 | 89 | if (view == null) { | 89 | if (view == null) { |
2394 | 90 | view = inflater.inflate(R.layout.group_parent, null); | 90 | view = inflater.inflate(R.layout.group_parent, null); |
2395 | 91 | view.setClickable(false); | 91 | view.setClickable(false); |
2396 | 92 | } | 92 | } |
2397 | 93 | TextView textView = (TextView) view.findViewById(R.id.groupParentText); | 93 | TextView textView = (TextView) view.findViewById(R.id.groupParentText); |
2398 | 94 | TextView numberView = (TextView) view | 94 | TextView numberView = (TextView) view |
2399 | 95 | .findViewById(R.id.parentChildCount); | 95 | .findViewById(R.id.parentChildCount); |
2400 | 96 | numberView.setText(String.format("%s", children.get(position).size())); | 96 | numberView.setText(String.format("%s", children.get(position).size())); |
2401 | 97 | textView.setText(groups.get(position)); | 97 | textView.setText(groups.get(position)); |
2402 | 98 | return view; | 98 | return view; |
2403 | 99 | } | 99 | } |
2404 | 100 | 100 | ||
2405 | 101 | @Override | 101 | @Override |
2406 | 102 | public View getChildView(int groupPosition, int childPosition, boolean b, | 102 | public View getChildView(int groupPosition, int childPosition, boolean b, |
2407 | 103 | View view, ViewGroup viewGroup) { | 103 | View view, ViewGroup viewGroup) { |
2408 | 104 | if (view == null) { | 104 | if (view == null) { |
2409 | 105 | view = inflater.inflate(R.layout.group_child, null); | 105 | view = inflater.inflate(R.layout.group_child, null); |
2410 | 106 | view.setClickable(false); | 106 | view.setClickable(false); |
2411 | 107 | } | 107 | } |
2412 | 108 | TextView childView = (TextView) view.findViewById(R.id.groupChildText); | 108 | TextView childView = (TextView) view.findViewById(R.id.groupChildText); |
2413 | 109 | List<Map<String, JSONArray>> childItem = children.get(groupPosition); | 109 | List<Map<String, JSONArray>> childItem = children.get(groupPosition); |
2414 | 110 | Map<String, JSONArray> mapItem = childItem.get(childPosition); | 110 | Map<String, JSONArray> mapItem = childItem.get(childPosition); |
2415 | 111 | JSONArray jsonItem = mapItem.get(groups.get(groupPosition)); | 111 | JSONArray jsonItem = mapItem.get(groups.get(groupPosition)); |
2416 | 112 | try { | 112 | try { |
2417 | 113 | childView.setText(String.format("%s", jsonItem.get(1))); | 113 | childView.setText(String.format("%s", jsonItem.get(1))); |
2418 | 114 | } | 114 | } catch (JSONException e) { |
2419 | 115 | catch (JSONException e) { | 115 | e.printStackTrace(); |
2420 | 116 | e.printStackTrace(); | 116 | } |
2421 | 117 | } | 117 | return view; |
2422 | 118 | return view; | 118 | } |
2423 | 119 | } | 119 | |
2424 | 120 | 120 | @Override | |
2425 | 121 | @Override | 121 | public boolean isChildSelectable(int i, int i1) { |
2426 | 122 | public boolean isChildSelectable(int i, int i1) { | 122 | return true; |
2427 | 123 | return true; | 123 | } |
2340 | 124 | } | ||
2428 | 125 | } | 124 | } |
2429 | 126 | 125 | ||
2430 | === modified file 'src/org/openlp/android/utility/JSONHandler.java' | |||
2431 | --- src/org/openlp/android/utility/JSONHandler.java 2013-04-06 13:44:51 +0000 | |||
2432 | +++ src/org/openlp/android/utility/JSONHandler.java 2013-06-04 19:32:29 +0000 | |||
2433 | @@ -38,139 +38,132 @@ | |||
2434 | 38 | 38 | ||
2435 | 39 | public class JSONHandler { | 39 | public class JSONHandler { |
2436 | 40 | 40 | ||
2572 | 41 | public static String createRequestJSON(String key, String value) | 41 | public static String createRequestJSON(String key, String value) |
2573 | 42 | throws JSONHandlerException { | 42 | throws JSONHandlerException { |
2574 | 43 | try { | 43 | try { |
2575 | 44 | String responseJSON; | 44 | String responseJSON; |
2576 | 45 | JSONObject jo = new JSONObject(); | 45 | JSONObject jo = new JSONObject(); |
2577 | 46 | jo.put(key, value); | 46 | jo.put(key, value); |
2578 | 47 | responseJSON = new JSONStringer().object().key("request").value(jo) | 47 | responseJSON = new JSONStringer().object().key("request").value(jo) |
2579 | 48 | .endObject().toString(); | 48 | .endObject().toString(); |
2580 | 49 | responseJSON = URLEncoder.encode(responseJSON, "UTF-8"); | 49 | responseJSON = URLEncoder.encode(responseJSON, "UTF-8"); |
2581 | 50 | return responseJSON; | 50 | return responseJSON; |
2582 | 51 | } | 51 | } catch (JSONException e) { |
2583 | 52 | catch (JSONException e) { | 52 | throw new JSONHandlerException(e); |
2584 | 53 | throw new JSONHandlerException(e); | 53 | } catch (UnsupportedEncodingException e) { |
2585 | 54 | } | 54 | throw new JSONHandlerException(e); |
2586 | 55 | catch (UnsupportedEncodingException e) { | 55 | } |
2587 | 56 | throw new JSONHandlerException(e); | 56 | } |
2588 | 57 | } | 57 | |
2589 | 58 | } | 58 | public static List<SlideItem> parseServiceItemResponseJSON( |
2590 | 59 | 59 | HttpEntity entity) | |
2591 | 60 | public static List<SlideItem> parseServiceItemResponseJSON( | 60 | throws JSONHandlerException { |
2592 | 61 | HttpEntity entity) | 61 | try { |
2593 | 62 | throws JSONHandlerException { | 62 | List<SlideItem> serviceItemList; |
2594 | 63 | try { | 63 | InputStream inputStream = entity.getContent(); |
2595 | 64 | List<SlideItem> serviceItemList; | 64 | String result = StringHelper.convertStreamToString(inputStream); |
2596 | 65 | InputStream inputStream = entity.getContent(); | 65 | Log.v(LOG_TAG, result); |
2597 | 66 | String result = StringHelper.convertStreamToString(inputStream); | 66 | serviceItemList = getServiceItemsFromString(result); |
2598 | 67 | Log.v(LOG_TAG, result); | 67 | inputStream.close(); |
2599 | 68 | serviceItemList = getServiceItemsFromString(result); | 68 | return serviceItemList; |
2600 | 69 | inputStream.close(); | 69 | } catch (IOException e) { |
2601 | 70 | return serviceItemList; | 70 | throw new JSONHandlerException(e); |
2602 | 71 | } | 71 | } |
2603 | 72 | catch (IOException e) { | 72 | } |
2604 | 73 | throw new JSONHandlerException(e); | 73 | |
2605 | 74 | } | 74 | public static List<SlideItem> getServiceItemsFromString(String itemsJson) |
2606 | 75 | } | 75 | throws JSONHandlerException { |
2607 | 76 | 76 | try { | |
2608 | 77 | public static List<SlideItem> getServiceItemsFromString(String itemsJson) | 77 | List<SlideItem> serviceItemList = new ArrayList<SlideItem>(); |
2609 | 78 | throws JSONHandlerException { | 78 | JSONObject jObject = new JSONObject(itemsJson); |
2610 | 79 | try { | 79 | JSONObject results = jObject.getJSONObject("results"); |
2611 | 80 | List<SlideItem> serviceItemList = new ArrayList<SlideItem>(); | 80 | JSONArray items = results.getJSONArray("items"); |
2612 | 81 | JSONObject jObject = new JSONObject(itemsJson); | 81 | |
2613 | 82 | JSONObject results = jObject.getJSONObject("results"); | 82 | for (int i = 0; i < items.length(); i++) { |
2614 | 83 | JSONArray items = results.getJSONArray("items"); | 83 | JSONObject item = items.getJSONObject(i); |
2615 | 84 | 84 | SlideItem slide = new SlideItem(); | |
2616 | 85 | for (int i = 0; i < items.length(); i++) { | 85 | slide.setTag(""); |
2617 | 86 | JSONObject item = items.getJSONObject(i); | 86 | slide.setText(item.getString("title")); |
2618 | 87 | SlideItem slide = new SlideItem(); | 87 | slide.setSelected(item.getBoolean("selected")); |
2619 | 88 | slide.setTag(""); | 88 | slide.setHtml(""); |
2620 | 89 | slide.setText(item.getString("title")); | 89 | serviceItemList.add(slide); |
2621 | 90 | slide.setSelected(item.getBoolean("selected")); | 90 | } |
2622 | 91 | slide.setHtml(""); | 91 | return serviceItemList; |
2623 | 92 | serviceItemList.add(slide); | 92 | } catch (JSONException e) { |
2624 | 93 | } | 93 | throw new JSONHandlerException(e); |
2625 | 94 | return serviceItemList; | 94 | } |
2626 | 95 | } | 95 | } |
2627 | 96 | catch (JSONException e) { | 96 | |
2628 | 97 | throw new JSONHandlerException(e); | 97 | public static List<SlideItem> parseSlideItemResponseJSON(HttpEntity entity) |
2629 | 98 | } | 98 | throws JSONHandlerException { |
2630 | 99 | } | 99 | try { |
2631 | 100 | 100 | List<SlideItem> serviceItemList; | |
2632 | 101 | public static List<SlideItem> parseSlideItemResponseJSON(HttpEntity entity) | 101 | InputStream inputStream = entity.getContent(); |
2633 | 102 | throws JSONHandlerException { | 102 | String result = StringHelper.convertStreamToString(inputStream); |
2634 | 103 | try { | 103 | Log.v(LOG_TAG, result); |
2635 | 104 | List<SlideItem> serviceItemList; | 104 | serviceItemList = getSlideItemsFromString(result); |
2636 | 105 | InputStream inputStream = entity.getContent(); | 105 | inputStream.close(); |
2637 | 106 | String result = StringHelper.convertStreamToString(inputStream); | 106 | return serviceItemList; |
2638 | 107 | Log.v(LOG_TAG, result); | 107 | } catch (IOException e) { |
2639 | 108 | serviceItemList = getSlideItemsFromString(result); | 108 | throw new JSONHandlerException(e); |
2640 | 109 | inputStream.close(); | 109 | } |
2641 | 110 | return serviceItemList; | 110 | } |
2642 | 111 | } | 111 | |
2643 | 112 | catch (IOException e) { | 112 | public static List<SlideItem> getSlideItemsFromString(String itemJson) |
2644 | 113 | throw new JSONHandlerException(e); | 113 | throws JSONHandlerException { |
2645 | 114 | } | 114 | try { |
2646 | 115 | } | 115 | JSONObject jObject = new JSONObject(itemJson); |
2647 | 116 | 116 | JSONObject results = jObject.getJSONObject("results"); | |
2648 | 117 | public static List<SlideItem> getSlideItemsFromString(String itemJson) | 117 | JSONArray items = results.getJSONArray("slides"); |
2649 | 118 | throws JSONHandlerException { | 118 | |
2650 | 119 | try { | 119 | List<SlideItem> serviceItemList = new ArrayList<SlideItem>(); |
2651 | 120 | JSONObject jObject = new JSONObject(itemJson); | 120 | for (int i = 0; i < items.length(); i++) { |
2652 | 121 | JSONObject results = jObject.getJSONObject("results"); | 121 | JSONObject item = items.getJSONObject(i); |
2653 | 122 | JSONArray items = results.getJSONArray("slides"); | 122 | SlideItem slide = new SlideItem(); |
2654 | 123 | 123 | slide.setText(item.getString("text")); | |
2655 | 124 | List<SlideItem> serviceItemList = new ArrayList<SlideItem>(); | 124 | slide.setTag(item.getString("tag")); |
2656 | 125 | for (int i = 0; i < items.length(); i++) { | 125 | slide.setSelected(item.getBoolean("selected")); |
2657 | 126 | JSONObject item = items.getJSONObject(i); | 126 | slide.setHtml(item.getString("html")); |
2658 | 127 | SlideItem slide = new SlideItem(); | 127 | serviceItemList.add(slide); |
2659 | 128 | slide.setText(item.getString("text")); | 128 | } |
2660 | 129 | slide.setTag(item.getString("tag")); | 129 | return serviceItemList; |
2661 | 130 | slide.setSelected(item.getBoolean("selected")); | 130 | } catch (JSONException e) { |
2662 | 131 | slide.setHtml(item.getString("html")); | 131 | throw new JSONHandlerException(e); |
2663 | 132 | serviceItemList.add(slide); | 132 | } |
2664 | 133 | } | 133 | } |
2665 | 134 | return serviceItemList; | 134 | |
2666 | 135 | } | 135 | public static Poll getPollFromString(String pollJson) |
2667 | 136 | catch (JSONException e) { | 136 | throws JSONHandlerException { |
2668 | 137 | throw new JSONHandlerException(e); | 137 | Log.v(LOG_TAG, String.format("parsePollResponseJSON: " + pollJson)); |
2669 | 138 | } | 138 | try { |
2670 | 139 | } | 139 | JSONObject jObject = new JSONObject(pollJson); |
2671 | 140 | 140 | JSONObject results = jObject.getJSONObject("results"); | |
2672 | 141 | public static Poll getPollFromString(String pollJson) | 141 | Poll poll = new Poll(); |
2673 | 142 | throws JSONHandlerException { | 142 | poll.setSlide(results.getInt("slide")); |
2674 | 143 | Log.v(LOG_TAG, String.format("parsePollResponseJSON: " + pollJson)); | 143 | poll.setItem(results.getString("item")); |
2675 | 144 | try { | 144 | poll.setTwelveHourDisplay(results.getBoolean("twelve")); |
2676 | 145 | JSONObject jObject = new JSONObject(pollJson); | 145 | poll.setBlankedDisplayed(results.getBoolean("blank")); |
2677 | 146 | JSONObject results = jObject.getJSONObject("results"); | 146 | poll.setThemeDisplayed(results.getBoolean("theme")); |
2678 | 147 | Poll poll = new Poll(); | 147 | poll.setDesktopDisplayed(results.getBoolean("display")); |
2679 | 148 | poll.setSlide(results.getInt("slide")); | 148 | if (!results.has("service")) { |
2680 | 149 | poll.setItem(results.getString("item")); | 149 | Log.w(LOG_TAG, |
2681 | 150 | poll.setTwelveHourDisplay(results.getBoolean("twelve")); | 150 | "Current OpenLP too old. Missing \"service\" (OpenLP < 1941)"); |
2682 | 151 | poll.setBlankedDisplayed(results.getBoolean("blank")); | 151 | } |
2683 | 152 | poll.setThemeDisplayed(results.getBoolean("theme")); | 152 | poll.setService( |
2684 | 153 | poll.setDesktopDisplayed(results.getBoolean("display")); | 153 | results.has("service") ? results.getInt("service") : -1); |
2685 | 154 | if (!results.has("service")) { | 154 | return poll; |
2686 | 155 | Log.w(LOG_TAG, | 155 | } catch (JSONException e) { |
2687 | 156 | "Current OpenLP too old. Missing \"service\" (OpenLP < 1941)"); | 156 | throw new JSONHandlerException(e); |
2688 | 157 | } | 157 | } |
2689 | 158 | poll.setService( | 158 | } |
2690 | 159 | results.has("service") ? results.getInt("service") : -1); | 159 | |
2691 | 160 | return poll; | 160 | public static class JSONHandlerException extends Exception { |
2692 | 161 | } | 161 | private static final long serialVersionUID = -6772307308404816615L; |
2693 | 162 | catch (JSONException e) { | 162 | |
2694 | 163 | throw new JSONHandlerException(e); | 163 | public JSONHandlerException(Throwable throwable) { |
2695 | 164 | } | 164 | super(throwable); |
2696 | 165 | } | 165 | } |
2697 | 166 | 166 | } | |
2698 | 167 | public static class JSONHandlerException extends Exception { | 167 | |
2699 | 168 | private static final long serialVersionUID = -6772307308404816615L; | 168 | private static String LOG_TAG = JSONHandler.class.getName(); |
2565 | 169 | |||
2566 | 170 | public JSONHandlerException(Throwable throwable) { | ||
2567 | 171 | super(throwable); | ||
2568 | 172 | } | ||
2569 | 173 | } | ||
2570 | 174 | |||
2571 | 175 | private static String LOG_TAG = JSONHandler.class.getName(); | ||
2700 | 176 | } | 169 | } |
2701 | 177 | 170 | ||
2702 | === modified file 'src/org/openlp/android/utility/OpenLPController.java' | |||
2703 | --- src/org/openlp/android/utility/OpenLPController.java 2013-04-06 13:44:51 +0000 | |||
2704 | +++ src/org/openlp/android/utility/OpenLPController.java 2013-06-04 19:32:29 +0000 | |||
2705 | @@ -56,579 +56,560 @@ | |||
2706 | 56 | 56 | ||
2707 | 57 | public class OpenLPController extends PagerAdapter { | 57 | public class OpenLPController extends PagerAdapter { |
2708 | 58 | 58 | ||
2843 | 59 | private static Activity context; | 59 | private static Activity context; |
2844 | 60 | private ListView listViewService; | 60 | private ListView listViewService; |
2845 | 61 | private ListView listViewLive; | 61 | private ListView listViewLive; |
2846 | 62 | private int currentService = -1; | 62 | private int currentService = -1; |
2847 | 63 | private int currentLive = -1; | 63 | private int currentLive = -1; |
2848 | 64 | private String itemId = ""; | 64 | private String itemId = ""; |
2849 | 65 | 65 | ||
2850 | 66 | private static int currentPage = 0; | 66 | private static int currentPage = 0; |
2851 | 67 | 67 | ||
2852 | 68 | public static final String PAGE_KEY = "openlp.pageKey"; | 68 | public static final String PAGE_KEY = "openlp.pageKey"; |
2853 | 69 | public static final int PAGE_SERVICE = 0; | 69 | public static final int PAGE_SERVICE = 0; |
2854 | 70 | public static final int PAGE_LIVE = 1; | 70 | public static final int PAGE_LIVE = 1; |
2855 | 71 | public static final int PAGE_DISPLAY = 2; | 71 | public static final int PAGE_DISPLAY = 2; |
2856 | 72 | public static final int PAGE_STAGE = 3; | 72 | public static final int PAGE_STAGE = 3; |
2857 | 73 | public static final int PAGE_ALERT = 4; | 73 | public static final int PAGE_ALERT = 4; |
2858 | 74 | public static final int PAGE_SEARCH = 5; | 74 | public static final int PAGE_SEARCH = 5; |
2859 | 75 | 75 | ||
2860 | 76 | private String displayType; | 76 | private String displayType; |
2861 | 77 | private WebView webView; | 77 | private WebView webView; |
2862 | 78 | private SharedPreferences preferences; | 78 | private SharedPreferences preferences; |
2863 | 79 | 79 | ||
2864 | 80 | public Intent pingIntent; | 80 | public Intent pingIntent; |
2865 | 81 | public Intent apiCallIntent; | 81 | public Intent apiCallIntent; |
2866 | 82 | 82 | ||
2867 | 83 | public OpenLPController(Activity context) { | 83 | public OpenLPController(Activity context) { |
2868 | 84 | OpenLPController.context = context; | 84 | OpenLPController.context = context; |
2869 | 85 | preferences = context.getApplicationContext().getSharedPreferences( | 85 | preferences = context.getApplicationContext().getSharedPreferences( |
2870 | 86 | context.getString(R.string.keySharedPreferences), | 86 | context.getString(R.string.keySharedPreferences), |
2871 | 87 | Context.MODE_PRIVATE); | 87 | Context.MODE_PRIVATE); |
2872 | 88 | pingIntent = new Intent(context, PingIntent.class); | 88 | pingIntent = new Intent(context, PingIntent.class); |
2873 | 89 | apiCallIntent = new Intent(context, ApiCallIntent.class); | 89 | apiCallIntent = new Intent(context, ApiCallIntent.class); |
2874 | 90 | 90 | ||
2875 | 91 | IntentFilter apiCallFilter = | 91 | IntentFilter apiCallFilter = |
2876 | 92 | new IntentFilter(ApiCallIntent.API_CALL_RECEIVE); | 92 | new IntentFilter(ApiCallIntent.API_CALL_RECEIVE); |
2877 | 93 | apiCallFilter.addCategory(Intent.CATEGORY_DEFAULT); | 93 | apiCallFilter.addCategory(Intent.CATEGORY_DEFAULT); |
2878 | 94 | context.registerReceiver(apiCallReceiver, apiCallFilter); | 94 | context.registerReceiver(apiCallReceiver, apiCallFilter); |
2879 | 95 | } | 95 | } |
2880 | 96 | 96 | ||
2881 | 97 | public final BroadcastReceiver apiCallReceiver = new BroadcastReceiver() { | 97 | public final BroadcastReceiver apiCallReceiver = new BroadcastReceiver() { |
2882 | 98 | @Override | 98 | @Override |
2883 | 99 | public void onReceive(Context broadcastedContext, Intent intent) { | 99 | public void onReceive(Context broadcastedContext, Intent intent) { |
2884 | 100 | Log.v(LOG_TAG, String | 100 | Log.v(LOG_TAG, String |
2885 | 101 | .format("%s broadcast received: intent(%s), context(%s)", | 101 | .format("%s broadcast received: intent(%s), context(%s)", |
2886 | 102 | ApiCallIntent.API_CALL_RECEIVE, intent, | 102 | ApiCallIntent.API_CALL_RECEIVE, intent, |
2887 | 103 | broadcastedContext)); | 103 | broadcastedContext)); |
2888 | 104 | if (intent.hasExtra("error")) { | 104 | if (intent.hasExtra("error")) { |
2889 | 105 | context.stopService(pingIntent); | 105 | context.stopService(pingIntent); |
2890 | 106 | Log.w(LOG_TAG, "Stopping PingIntent. Got erroneous intent: " + | 106 | Log.w(LOG_TAG, "Stopping PingIntent. Got erroneous intent: " + |
2891 | 107 | intent.getStringExtra("error")); | 107 | intent.getStringExtra("error")); |
2892 | 108 | Toast.makeText(broadcastedContext, String | 108 | Toast.makeText(broadcastedContext, String |
2893 | 109 | .format("%s: %s", context.getString(R.string.requestFailed), | 109 | .format("%s: %s", context.getString(R.string.requestFailed), |
2894 | 110 | intent.getStringExtra("error")), Toast.LENGTH_LONG) | 110 | intent.getStringExtra("error")), Toast.LENGTH_LONG) |
2895 | 111 | .show(); | 111 | .show(); |
2896 | 112 | } | 112 | } else { |
2897 | 113 | else { | 113 | if (intent.hasExtra("apiBase")) { |
2898 | 114 | if (intent.hasExtra("apiBase")) { | 114 | String apiBase = intent.getStringExtra("apiBase"); |
2899 | 115 | String apiBase = intent.getStringExtra("apiBase"); | 115 | if (apiBase.equals(Api.ALERT)) { |
2900 | 116 | if (apiBase.equals(Api.ALERT)) { | 116 | Toast.makeText(broadcastedContext, "Alert sent!", |
2901 | 117 | Toast.makeText(broadcastedContext, "Alert sent!", | 117 | Toast.LENGTH_SHORT).show(); |
2902 | 118 | Toast.LENGTH_SHORT).show(); | 118 | } |
2903 | 119 | } | 119 | if (apiBase.equals(Api.DISPLAY_BASE)) { |
2904 | 120 | if (apiBase.equals(Api.DISPLAY_BASE)) { | 120 | controller.poll(); |
2905 | 121 | controller.poll(); | 121 | } |
2906 | 122 | } | 122 | if (apiBase.equals(Api.POLL_STATUS)) { |
2907 | 123 | if (apiBase.equals(Api.POLL_STATUS)) { | 123 | handlePollResponse(intent.getStringExtra("pollJson")); |
2908 | 124 | handlePollResponse(intent.getStringExtra("pollJson")); | 124 | } |
2909 | 125 | } | 125 | if (apiBase.equals(Api.LIVE_TEXT)) { |
2910 | 126 | if (apiBase.equals(Api.LIVE_TEXT)) { | 126 | handleLiveItemsResponse( |
2911 | 127 | handleLiveItemsResponse( | 127 | intent.getStringExtra("itemsJson")); |
2912 | 128 | intent.getStringExtra("itemsJson")); | 128 | } |
2913 | 129 | } | 129 | if (apiBase.equals(Api.SERVICE_LIST)) { |
2914 | 130 | if (apiBase.equals(Api.SERVICE_LIST)) { | 130 | handleServiceItemsResponse( |
2915 | 131 | handleServiceItemsResponse( | 131 | intent.getStringExtra("itemsJson")); |
2916 | 132 | intent.getStringExtra("itemsJson")); | 132 | } |
2917 | 133 | } | 133 | } |
2918 | 134 | } | 134 | } |
2919 | 135 | } | 135 | } |
2920 | 136 | } | 136 | }; |
2921 | 137 | }; | 137 | |
2922 | 138 | 138 | private void handlePollResponse(final String pollResponse) { | |
2923 | 139 | private void handlePollResponse(final String pollResponse) { | 139 | try { |
2924 | 140 | try { | 140 | |
2925 | 141 | 141 | Poll poll = JSONHandler.getPollFromString(pollResponse); | |
2926 | 142 | Poll poll = JSONHandler.getPollFromString(pollResponse); | 142 | if (poll != null) { |
2927 | 143 | if (poll != null) { | 143 | if (currentPage == PAGE_DISPLAY) { |
2928 | 144 | if (currentPage == PAGE_DISPLAY) { | 144 | setDisplayFromPoll(poll); |
2929 | 145 | setDisplayFromPoll(poll); | 145 | } else { |
2930 | 146 | } | 146 | setServiceOrLiveFromPoll(poll); |
2931 | 147 | else { | 147 | } |
2932 | 148 | setServiceOrLiveFromPoll(poll); | 148 | } else { |
2933 | 149 | } | 149 | Log.w(LOG_TAG, "Parsed poll is null. This is not expected!"); |
2934 | 150 | } | 150 | } |
2935 | 151 | else { | 151 | } catch (JSONHandler.JSONHandlerException e) { |
2936 | 152 | Log.w(LOG_TAG, "Parsed poll is null. This is not expected!"); | 152 | Log.e(LOG_TAG, e.toString()); |
2937 | 153 | } | 153 | Toast.makeText(context, String.format("%s: %s", |
2938 | 154 | } | 154 | context.getString(R.string.couldNotHandlePollResponse), |
2939 | 155 | catch (JSONHandler.JSONHandlerException e) { | 155 | e.getMessage()), Toast.LENGTH_LONG).show(); |
2940 | 156 | Log.e(LOG_TAG, e.toString()); | 156 | } |
2941 | 157 | Toast.makeText(context, String.format("%s: %s", | 157 | } |
2942 | 158 | context.getString(R.string.couldNotHandlePollResponse), | 158 | |
2943 | 159 | e.getMessage()), Toast.LENGTH_LONG).show(); | 159 | private void setDisplayFromPoll(Poll poll) { |
2944 | 160 | } | 160 | final ToggleButton toggleButton = (ToggleButton) |
2945 | 161 | } | 161 | context.findViewById(R.id.toggleDisplayButton); |
2946 | 162 | 162 | if (poll == null) { | |
2947 | 163 | private void setDisplayFromPoll(Poll poll) { | 163 | toggleButton.setEnabled(false); |
2948 | 164 | final ToggleButton toggleButton = (ToggleButton) | 164 | } else { |
2949 | 165 | context.findViewById(R.id.toggleDisplayButton); | 165 | String onText; |
2950 | 166 | if (poll == null) { | 166 | String offText; |
2951 | 167 | toggleButton.setEnabled(false); | 167 | |
2952 | 168 | } | 168 | displayType = getDisplayType(); |
2953 | 169 | else { | 169 | Log.d(LOG_TAG, "onPostExecute Display Type = " + displayType |
2954 | 170 | String onText; | 170 | + " " + poll.isDisplayHidden()); |
2955 | 171 | String offText; | 171 | if (displayType.equals(context.getString(R.string.displayScreen))) { |
2956 | 172 | 172 | Log.v(LOG_TAG, "Blank called"); | |
2957 | 173 | displayType = getDisplayType(); | 173 | onText = context.getString(R.string.displayScreen); |
2958 | 174 | Log.d(LOG_TAG, "onPostExecute Display Type = " + displayType | 174 | offText = context.getString(R.string.displayScreen); |
2959 | 175 | + " " + poll.isDisplayHidden()); | 175 | } else if (displayType |
2960 | 176 | if (displayType.equals(context.getString(R.string.displayScreen))) { | 176 | .equals(context.getString(R.string.displayTheme))) { |
2961 | 177 | Log.v(LOG_TAG, "Blank called"); | 177 | Log.v(LOG_TAG, "Theme called"); |
2962 | 178 | onText = context.getString(R.string.displayScreen); | 178 | onText = context.getString(R.string.displayTheme); |
2963 | 179 | offText = context.getString(R.string.displayScreen); | 179 | offText = context.getString(R.string.displayTheme); |
2964 | 180 | } | 180 | } else { |
2965 | 181 | else if (displayType | 181 | Log.v(LOG_TAG, "Desktop called"); |
2966 | 182 | .equals(context.getString(R.string.displayTheme))) { | 182 | onText = context.getString(R.string.displayDesktop); |
2967 | 183 | Log.v(LOG_TAG, "Theme called"); | 183 | offText = context.getString(R.string.displayDesktop); |
2968 | 184 | onText = context.getString(R.string.displayTheme); | 184 | } |
2969 | 185 | offText = context.getString(R.string.displayTheme); | 185 | /* |
2836 | 186 | } | ||
2837 | 187 | else { | ||
2838 | 188 | Log.v(LOG_TAG, "Desktop called"); | ||
2839 | 189 | onText = context.getString(R.string.displayDesktop); | ||
2840 | 190 | offText = context.getString(R.string.displayDesktop); | ||
2841 | 191 | } | ||
2842 | 192 | /* | ||
2970 | 193 | Set display blanked to the off value to that of the screen | 186 | Set display blanked to the off value to that of the screen |
2971 | 194 | */ | 187 | */ |
3023 | 195 | if (poll.isDisplayHidden()) { | 188 | if (poll.isDisplayHidden()) { |
3024 | 196 | if (poll.isBlankedDisplayed()) { | 189 | if (poll.isBlankedDisplayed()) { |
3025 | 197 | Log.v(LOG_TAG, "Hidden Blank called"); | 190 | Log.v(LOG_TAG, "Hidden Blank called"); |
3026 | 198 | onText = context.getString(R.string.displayScreen); | 191 | onText = context.getString(R.string.displayScreen); |
3027 | 199 | } | 192 | } else if (poll.isThemeDisplayed()) { |
3028 | 200 | else if (poll.isThemeDisplayed()) { | 193 | Log.v(LOG_TAG, "Hidden Theme called"); |
3029 | 201 | Log.v(LOG_TAG, "Hidden Theme called"); | 194 | onText = context.getString(R.string.displayTheme); |
3030 | 202 | onText = context.getString(R.string.displayTheme); | 195 | } else { |
3031 | 203 | } | 196 | Log.v(LOG_TAG, "Hidden Desktop called"); |
3032 | 204 | else { | 197 | onText = context.getString(R.string.displayDesktop); |
3033 | 205 | Log.v(LOG_TAG, "Hidden Desktop called"); | 198 | } |
3034 | 206 | onText = context.getString(R.string.displayDesktop); | 199 | } |
3035 | 207 | } | 200 | toggleButton.setTextOn( |
3036 | 208 | } | 201 | context.getString(R.string.displayBlankOn) + " " + onText); |
3037 | 209 | toggleButton.setTextOn( | 202 | toggleButton.setTextOff( |
3038 | 210 | context.getString(R.string.displayBlankOn) + " " + onText); | 203 | context.getString(R.string.displayBlankOff) + " " + offText); |
3039 | 211 | toggleButton.setTextOff( | 204 | toggleButton.setEnabled(true); |
3040 | 212 | context.getString(R.string.displayBlankOff) + " " + offText); | 205 | toggleButton.setChecked(false); |
3041 | 213 | toggleButton.setEnabled(true); | 206 | if (poll.isDisplayHidden()) { |
3042 | 214 | toggleButton.setChecked(false); | 207 | toggleButton.setChecked(true); |
3043 | 215 | if (poll.isDisplayHidden()) { | 208 | } |
3044 | 216 | toggleButton.setChecked(true); | 209 | } |
3045 | 217 | } | 210 | } |
3046 | 218 | } | 211 | |
3047 | 219 | } | 212 | private void setServiceOrLiveFromPoll(Poll poll) { |
3048 | 220 | 213 | if (currentPage == PAGE_LIVE) { | |
3049 | 221 | private void setServiceOrLiveFromPoll(Poll poll) { | 214 | if (!itemId.equals(poll.getItem()) || |
3050 | 222 | if (currentPage == PAGE_LIVE) { | 215 | currentLive != poll.getSlide()) { |
3051 | 223 | if (!itemId.equals(poll.getItem()) || | 216 | Log.v(LOG_TAG, "Slide Changed. Polling update..."); |
3052 | 224 | currentLive != poll.getSlide()) { | 217 | currentLive = poll.getSlide(); |
3053 | 225 | Log.v(LOG_TAG, "Slide Changed. Polling update..."); | 218 | itemId = poll.getItem(); |
3054 | 226 | currentLive = poll.getSlide(); | 219 | controller.fetchItems(Api.LIVE_TEXT); |
3055 | 227 | itemId = poll.getItem(); | 220 | } |
3056 | 228 | controller.fetchItems(Api.LIVE_TEXT); | 221 | } else if (currentPage == PAGE_SERVICE) { |
3057 | 229 | } | 222 | if (currentService < poll.getService()) { |
3058 | 230 | } | 223 | Log.v(LOG_TAG, "Service Changed. Polling update..."); |
3059 | 231 | else if (currentPage == PAGE_SERVICE) { | 224 | currentService = poll.getService(); |
3060 | 232 | if (currentService < poll.getService()) { | 225 | controller.fetchItems(Api.SERVICE_LIST); |
3061 | 233 | Log.v(LOG_TAG, "Service Changed. Polling update..."); | 226 | } |
3062 | 234 | currentService = poll.getService(); | 227 | } |
3063 | 235 | controller.fetchItems(Api.SERVICE_LIST); | 228 | } |
3064 | 236 | } | 229 | |
3065 | 237 | } | 230 | private void handleLiveItemsResponse(final String itemsJson) { |
3066 | 238 | } | 231 | try { |
3067 | 239 | 232 | List<SlideItem> liveItems = | |
3068 | 240 | private void handleLiveItemsResponse(final String itemsJson) { | 233 | JSONHandler.getSlideItemsFromString(itemsJson); |
3069 | 241 | try { | 234 | listViewLive |
3070 | 242 | List<SlideItem> liveItems = | 235 | .setAdapter(new SlideAdapter(context, liveItems, currentLive)); |
3020 | 243 | JSONHandler.getSlideItemsFromString(itemsJson); | ||
3021 | 244 | listViewLive | ||
3022 | 245 | .setAdapter(new SlideAdapter(context, liveItems, currentLive)); | ||
3071 | 246 | listViewLive.setSelection(currentLive); | 236 | listViewLive.setSelection(currentLive); |
3191 | 247 | } | 237 | } catch (JSONHandler.JSONHandlerException e) { |
3192 | 248 | catch (JSONHandler.JSONHandlerException e) { | 238 | Log.e(LOG_TAG, e.toString()); |
3193 | 249 | Log.e(LOG_TAG, e.toString()); | 239 | Toast.makeText(context, String.format("%s: %s", |
3194 | 250 | Toast.makeText(context, String.format("%s: %s", | 240 | context.getString(R.string.couldNotHandleLiveItems), |
3195 | 251 | context.getString(R.string.couldNotHandleLiveItems), | 241 | e.getMessage()), Toast.LENGTH_LONG).show(); |
3196 | 252 | e.getMessage()), Toast.LENGTH_LONG).show(); | 242 | } |
3197 | 253 | } | 243 | } |
3198 | 254 | } | 244 | |
3199 | 255 | 245 | private void handleServiceItemsResponse(final String itemsJson) { | |
3200 | 256 | private void handleServiceItemsResponse(final String itemsJson) { | 246 | try { |
3201 | 257 | try { | 247 | List<SlideItem> serviceItems = |
3202 | 258 | List<SlideItem> serviceItems = | 248 | JSONHandler.getServiceItemsFromString(itemsJson); |
3203 | 259 | JSONHandler.getServiceItemsFromString(itemsJson); | 249 | listViewService.setAdapter( |
3204 | 260 | listViewService.setAdapter( | 250 | new SlideAdapter(context, serviceItems, currentService)); |
3205 | 261 | new SlideAdapter(context, serviceItems, currentService)); | 251 | } catch (JSONHandler.JSONHandlerException e) { |
3206 | 262 | } | 252 | Log.e(LOG_TAG, e.toString()); |
3207 | 263 | catch (JSONHandler.JSONHandlerException e) { | 253 | Toast.makeText(context, String.format("%s: %s", |
3208 | 264 | Log.e(LOG_TAG, e.toString()); | 254 | context.getString(R.string.couldNotHandleServiceItems), |
3209 | 265 | Toast.makeText(context, String.format("%s: %s", | 255 | e.getMessage()), Toast.LENGTH_LONG).show(); |
3210 | 266 | context.getString(R.string.couldNotHandleServiceItems), | 256 | } |
3211 | 267 | e.getMessage()), Toast.LENGTH_LONG).show(); | 257 | } |
3212 | 268 | } | 258 | |
3213 | 269 | } | 259 | private OpenLPNavigate controller = new OpenLPNavigate() { |
3214 | 270 | 260 | @Override | |
3215 | 271 | private OpenLPNavigate controller = new OpenLPNavigate() { | 261 | public void navigate(final String navigationRequest) { |
3216 | 272 | @Override | 262 | Intent navigationIntent = new Intent(context, ApiCallIntent.class); |
3217 | 273 | public void navigate(final String navigationRequest) { | 263 | if (currentPage == PAGE_SERVICE) { |
3218 | 274 | Intent navigationIntent = new Intent(context, ApiCallIntent.class); | 264 | navigationIntent.putExtra(Api.SERVICE_BASE, navigationRequest); |
3219 | 275 | if (currentPage == PAGE_SERVICE) { | 265 | } |
3220 | 276 | navigationIntent.putExtra(Api.SERVICE_BASE, navigationRequest); | 266 | if (currentPage == PAGE_LIVE) { |
3221 | 277 | } | 267 | navigationIntent.putExtra(Api.LIVE_BASE, navigationRequest); |
3222 | 278 | if (currentPage == PAGE_LIVE) { | 268 | } |
3223 | 279 | navigationIntent.putExtra(Api.LIVE_BASE, navigationRequest); | 269 | context.startService(navigationIntent); |
3224 | 280 | } | 270 | } |
3225 | 281 | context.startService(navigationIntent); | 271 | |
3226 | 282 | } | 272 | @Override |
3227 | 283 | 273 | public void setData(String apiPart, int id) { | |
3228 | 284 | @Override | 274 | Intent setDataIntent = new Intent(context, ApiCallIntent.class); |
3229 | 285 | public void setData(String apiPart, int id) { | 275 | setDataIntent.putExtra(apiPart, id); |
3230 | 286 | Intent setDataIntent = new Intent(context, ApiCallIntent.class); | 276 | context.startService(setDataIntent); |
3231 | 287 | setDataIntent.putExtra(apiPart, id); | 277 | } |
3232 | 288 | context.startService(setDataIntent); | 278 | |
3233 | 289 | } | 279 | @Override |
3234 | 290 | 280 | public void setDisplay(String displayRequest) { | |
3235 | 291 | @Override | 281 | Log.d(LOG_TAG, String |
3236 | 292 | public void setDisplay(String displayRequest) { | 282 | .format("Setting Display: displayRequest(%s)", displayRequest)); |
3237 | 293 | Log.d(LOG_TAG, String | 283 | Intent displayIntent = new Intent(context, ApiCallIntent.class); |
3238 | 294 | .format("Setting Display: displayRequest(%s)", displayRequest)); | 284 | displayIntent.putExtra(Api.DISPLAY_BASE, displayRequest); |
3239 | 295 | Intent displayIntent = new Intent(context, ApiCallIntent.class); | 285 | context.startService(displayIntent); |
3240 | 296 | displayIntent.putExtra(Api.DISPLAY_BASE, displayRequest); | 286 | } |
3241 | 297 | context.startService(displayIntent); | 287 | |
3242 | 298 | } | 288 | @Override |
3243 | 299 | 289 | public void poll() { | |
3244 | 300 | @Override | 290 | Intent pollIntent = new Intent(context, ApiCallIntent.class); |
3245 | 301 | public void poll() { | 291 | pollIntent.putExtra(Api.POLL_STATUS, ""); |
3246 | 302 | Intent pollIntent = new Intent(context, ApiCallIntent.class); | 292 | context.startService(pollIntent); |
3247 | 303 | pollIntent.putExtra(Api.POLL_STATUS, ""); | 293 | } |
3248 | 304 | context.startService(pollIntent); | 294 | |
3249 | 305 | } | 295 | @Override |
3250 | 306 | 296 | public void fetchItems(String apiPart) { | |
3251 | 307 | @Override | 297 | Intent fetchItemsIntent = new Intent(context, ApiCallIntent.class); |
3252 | 308 | public void fetchItems(String apiPart) { | 298 | fetchItemsIntent.putExtra(apiPart, ""); |
3253 | 309 | Intent fetchItemsIntent = new Intent(context, ApiCallIntent.class); | 299 | context.startService(fetchItemsIntent); |
3254 | 310 | fetchItemsIntent.putExtra(apiPart, ""); | 300 | } |
3255 | 311 | context.startService(fetchItemsIntent); | 301 | }; |
3256 | 312 | } | 302 | |
3257 | 313 | }; | 303 | @Override |
3258 | 314 | 304 | public Object instantiateItem(final ViewGroup container, int position) { | |
3259 | 315 | @Override | 305 | LayoutInflater inflater = (LayoutInflater) container.getContext() |
3260 | 316 | public Object instantiateItem(final ViewGroup container, int position) { | 306 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
3261 | 317 | LayoutInflater inflater = (LayoutInflater) container.getContext() | 307 | int res = 0; |
3262 | 318 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); | 308 | try { |
3263 | 319 | int res = 0; | 309 | res = getLayoutForPosition(position); |
3264 | 320 | try { | 310 | } catch (NoLayoutForPositionException e) { |
3265 | 321 | res = getLayoutForPosition(position); | 311 | Log.e(LOG_TAG, e.getMessage()); |
3266 | 322 | } | 312 | } |
3267 | 323 | catch (NoLayoutForPositionException e) { | 313 | |
3268 | 324 | Log.e(LOG_TAG, e.getMessage()); | 314 | View view = inflater.inflate(res, null); |
3269 | 325 | } | 315 | |
3270 | 326 | 316 | if (position == PAGE_SERVICE || position == PAGE_LIVE) { | |
3271 | 327 | View view = inflater.inflate(res, null); | 317 | if (position == PAGE_SERVICE) { |
3272 | 328 | 318 | listViewService = (ListView) view.findViewById(R.id.list); | |
3273 | 329 | if (position == PAGE_SERVICE || position == PAGE_LIVE) { | 319 | listViewService |
3274 | 330 | if (position == PAGE_SERVICE) { | 320 | .setOnItemClickListener(onItemClickListenerService); |
3275 | 331 | listViewService = (ListView) view.findViewById(R.id.list); | 321 | listViewService.setOnItemLongClickListener( |
3276 | 332 | listViewService | 322 | adapterViewOnItemLongClickListener); |
3277 | 333 | .setOnItemClickListener(onItemClickListenerService); | 323 | } |
3278 | 334 | listViewService.setOnItemLongClickListener( | 324 | |
3279 | 335 | adapterViewOnItemLongClickListener); | 325 | if (position == PAGE_LIVE) { |
3280 | 336 | } | 326 | listViewLive = (ListView) view.findViewById(R.id.list); |
3281 | 337 | 327 | listViewLive.setOnItemClickListener(onItemClickListenerSetLive); | |
3282 | 338 | if (position == PAGE_LIVE) { | 328 | } |
3283 | 339 | listViewLive = (ListView) view.findViewById(R.id.list); | 329 | |
3284 | 340 | listViewLive.setOnItemClickListener(onItemClickListenerSetLive); | 330 | view.findViewById(R.id.prev) |
3285 | 341 | } | 331 | .setOnClickListener(onClickListenerNavigate); |
3286 | 342 | 332 | view.findViewById(R.id.next) | |
3287 | 343 | view.findViewById(R.id.prev) | 333 | .setOnClickListener(onClickListenerNavigate); |
3288 | 344 | .setOnClickListener(onClickListenerNavigate); | 334 | } |
3289 | 345 | view.findViewById(R.id.next) | 335 | |
3290 | 346 | .setOnClickListener(onClickListenerNavigate); | 336 | if (position == PAGE_STAGE) { |
3291 | 347 | } | 337 | webView = getWebViewFromView(view); |
3292 | 348 | 338 | } | |
3293 | 349 | if (position == PAGE_STAGE) { | 339 | if (position == PAGE_ALERT) { |
3294 | 350 | webView = getWebViewFromView(view); | 340 | view.findViewById(R.id.send).setOnClickListener(mSend); |
3295 | 351 | } | 341 | } |
3296 | 352 | if (position == PAGE_ALERT) { | 342 | if (position == PAGE_DISPLAY) { |
3297 | 353 | view.findViewById(R.id.send).setOnClickListener(mSend); | 343 | view.findViewById(R.id.toggleDisplayButton) |
3298 | 354 | } | 344 | .setOnClickListener(onClickListenerToggleDisplay); |
3299 | 355 | if (position == PAGE_DISPLAY) { | 345 | } |
3300 | 356 | view.findViewById(R.id.toggleDisplayButton) | 346 | |
3301 | 357 | .setOnClickListener(onClickListenerToggleDisplay); | 347 | container.addView(view, 0); |
3302 | 358 | } | 348 | return view; |
3303 | 359 | 349 | } | |
3304 | 360 | container.addView(view, 0); | 350 | |
3305 | 361 | return view; | 351 | private WebView getWebViewFromView(View view) { |
3306 | 362 | } | 352 | WebView myWebView = (WebView) view.findViewById(R.id.stageview); |
3188 | 363 | |||
3189 | 364 | private WebView getWebViewFromView(View view) { | ||
3190 | 365 | WebView myWebView = (WebView) view.findViewById(R.id.stageview); | ||
3307 | 366 | /* | 353 | /* |
3308 | 367 | * Handle SSL self signed certificates and refresh the screen if the certificate | 354 | * Handle SSL self signed certificates and refresh the screen if the certificate |
3309 | 368 | * page appears. | 355 | * page appears. |
3310 | 369 | */ | 356 | */ |
3311 | 370 | myWebView.setWebViewClient(new WebViewClient() { | 357 | myWebView.setWebViewClient(new WebViewClient() { |
3575 | 371 | public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) { | 358 | public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { |
3576 | 372 | handler.proceed() ; | 359 | handler.proceed(); |
3577 | 373 | } | 360 | } |
3578 | 374 | } ); | 361 | }); |
3579 | 375 | WebSettings webSettings = myWebView.getSettings(); | 362 | WebSettings webSettings = myWebView.getSettings(); |
3580 | 376 | webSettings.setJavaScriptEnabled(true); | 363 | webSettings.setJavaScriptEnabled(true); |
3581 | 377 | webSettings.setBuiltInZoomControls(true); | 364 | webSettings.setBuiltInZoomControls(true); |
3582 | 378 | webSettings.setLoadWithOverviewMode(true); | 365 | webSettings.setLoadWithOverviewMode(true); |
3583 | 379 | webSettings.setUseWideViewPort(true); | 366 | webSettings.setUseWideViewPort(true); |
3584 | 380 | myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); | 367 | myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); |
3585 | 381 | myWebView.setScrollbarFadingEnabled(true); | 368 | myWebView.setScrollbarFadingEnabled(true); |
3586 | 382 | 369 | ||
3587 | 383 | myWebView.loadUrl(getUrlBase()); | 370 | myWebView.loadUrl(getUrlBase()); |
3588 | 384 | return myWebView; | 371 | return myWebView; |
3589 | 385 | } | 372 | } |
3590 | 386 | 373 | ||
3591 | 387 | public static int getPageForButton(View view) { | 374 | public static int getPageForButton(View view) { |
3592 | 388 | final int buttonId = view.getId(); | 375 | final int buttonId = view.getId(); |
3593 | 389 | if (buttonId == R.id.buttonAlert) { | 376 | if (buttonId == R.id.buttonAlert) { |
3594 | 390 | return PAGE_ALERT; | 377 | return PAGE_ALERT; |
3595 | 391 | } | 378 | } |
3596 | 392 | if (buttonId == R.id.buttonDisplay) { | 379 | if (buttonId == R.id.buttonDisplay) { |
3597 | 393 | return PAGE_DISPLAY; | 380 | return PAGE_DISPLAY; |
3598 | 394 | } | 381 | } |
3599 | 395 | if (buttonId == R.id.buttonLive) { | 382 | if (buttonId == R.id.buttonLive) { |
3600 | 396 | return PAGE_LIVE; | 383 | return PAGE_LIVE; |
3601 | 397 | } | 384 | } |
3602 | 398 | if (buttonId == R.id.buttonSearch) { | 385 | if (buttonId == R.id.buttonSearch) { |
3603 | 399 | return PAGE_SEARCH; | 386 | return PAGE_SEARCH; |
3604 | 400 | } | 387 | } |
3605 | 401 | if (buttonId == R.id.buttonService) { | 388 | if (buttonId == R.id.buttonService) { |
3606 | 402 | return PAGE_SERVICE; | 389 | return PAGE_SERVICE; |
3607 | 403 | } | 390 | } |
3608 | 404 | if (buttonId == R.id.buttonStage) { | 391 | if (buttonId == R.id.buttonStage) { |
3609 | 405 | return PAGE_STAGE; | 392 | return PAGE_STAGE; |
3610 | 406 | } | 393 | } |
3611 | 407 | 394 | ||
3612 | 408 | Log.e(OpenLPController.class.getName(), | 395 | Log.e(OpenLPController.class.getName(), |
3613 | 409 | "No Button connected to the requested view, with id: " + buttonId); | 396 | "No Button connected to the requested view, with id: " + buttonId); |
3614 | 410 | return 0; | 397 | return 0; |
3615 | 411 | } | 398 | } |
3616 | 412 | 399 | ||
3617 | 413 | public ViewPager.OnPageChangeListener onPageChangeListener = | 400 | public ViewPager.OnPageChangeListener onPageChangeListener = |
3618 | 414 | new ViewPager.OnPageChangeListener() { | 401 | new ViewPager.OnPageChangeListener() { |
3619 | 415 | @Override | 402 | @Override |
3620 | 416 | public void onPageScrolled(int i, float v, int i1) { | 403 | public void onPageScrolled(int i, float v, int i1) { |
3621 | 417 | } | 404 | } |
3622 | 418 | 405 | ||
3623 | 419 | @Override | 406 | @Override |
3624 | 420 | public void onPageSelected(int selectedPage) { | 407 | public void onPageSelected(int selectedPage) { |
3625 | 421 | Log.d(LOG_TAG, String | 408 | Log.d(LOG_TAG, String |
3626 | 422 | .format("Selected Page: position(%s) title(%s)", | 409 | .format("Selected Page: position(%s) title(%s)", |
3627 | 423 | selectedPage, getPageTitle(selectedPage))); | 410 | selectedPage, getPageTitle(selectedPage))); |
3628 | 424 | currentPage = selectedPage; | 411 | currentPage = selectedPage; |
3629 | 425 | 412 | ||
3630 | 426 | if (currentPage == PAGE_SERVICE || currentPage == PAGE_LIVE) { | 413 | if (currentPage == PAGE_SERVICE || currentPage == PAGE_LIVE) { |
3631 | 427 | context.startService(pingIntent); | 414 | context.startService(pingIntent); |
3632 | 428 | if (currentPage == PAGE_SERVICE) { | 415 | if (currentPage == PAGE_SERVICE) { |
3633 | 429 | controller.fetchItems(Api.SERVICE_LIST); | 416 | controller.fetchItems(Api.SERVICE_LIST); |
3634 | 430 | } | 417 | } |
3635 | 431 | if (currentPage == PAGE_LIVE) { | 418 | if (currentPage == PAGE_LIVE) { |
3636 | 432 | controller.fetchItems(Api.LIVE_TEXT); | 419 | controller.fetchItems(Api.LIVE_TEXT); |
3637 | 433 | } | 420 | } |
3638 | 434 | } | 421 | } else { |
3639 | 435 | else { | 422 | context.stopService(pingIntent); |
3640 | 436 | context.stopService(pingIntent); | 423 | } |
3641 | 437 | } | 424 | |
3642 | 438 | 425 | if (currentPage == PAGE_STAGE) { | |
3643 | 439 | if (currentPage == PAGE_STAGE) { | 426 | if (webView == null) { |
3644 | 440 | if (webView == null) { | 427 | webView = getWebViewFromView(context.getLayoutInflater() |
3645 | 441 | webView = getWebViewFromView(context.getLayoutInflater() | 428 | .inflate(R.layout.stageview, null)); |
3646 | 442 | .inflate(R.layout.stageview, null)); | 429 | } |
3647 | 443 | } | 430 | } |
3648 | 444 | } | 431 | |
3649 | 445 | 432 | if (currentPage == PAGE_DISPLAY) { | |
3650 | 446 | if (currentPage == PAGE_DISPLAY) { | 433 | controller.poll(); |
3651 | 447 | controller.poll(); | 434 | } |
3652 | 448 | } | 435 | } |
3653 | 449 | } | 436 | |
3654 | 450 | 437 | @Override | |
3655 | 451 | @Override | 438 | public void onPageScrollStateChanged(int i) { |
3656 | 452 | public void onPageScrollStateChanged(int i) { | 439 | } |
3657 | 453 | } | 440 | }; |
3658 | 454 | }; | 441 | |
3659 | 455 | 442 | ||
3660 | 456 | 443 | @Override | |
3661 | 457 | @Override | 444 | public CharSequence getPageTitle(int position) { |
3662 | 458 | public CharSequence getPageTitle(int position) { | 445 | String page = "none"; |
3663 | 459 | String page = "none"; | 446 | switch (position) { |
3664 | 460 | switch (position) { | 447 | case PAGE_SERVICE: |
3665 | 461 | case PAGE_SERVICE: | 448 | page = context.getString(R.string.tabService); |
3666 | 462 | page = context.getString(R.string.tabService); | 449 | break; |
3667 | 463 | break; | 450 | case PAGE_LIVE: |
3668 | 464 | case PAGE_LIVE: | 451 | page = context.getString(R.string.tabLive); |
3669 | 465 | page = context.getString(R.string.tabLive); | 452 | break; |
3670 | 466 | break; | 453 | case PAGE_DISPLAY: |
3671 | 467 | case PAGE_DISPLAY: | 454 | page = context.getString(R.string.tabDisplay); |
3672 | 468 | page = context.getString(R.string.tabDisplay); | 455 | break; |
3673 | 469 | break; | 456 | case PAGE_STAGE: |
3674 | 470 | case PAGE_STAGE: | 457 | page = context.getString(R.string.tabStage); |
3675 | 471 | page = context.getString(R.string.tabStage); | 458 | break; |
3676 | 472 | break; | 459 | case PAGE_ALERT: |
3677 | 473 | case PAGE_ALERT: | 460 | page = context.getString(R.string.tabAlert); |
3678 | 474 | page = context.getString(R.string.tabAlert); | 461 | break; |
3679 | 475 | break; | 462 | case PAGE_SEARCH: |
3680 | 476 | case PAGE_SEARCH: | 463 | page = context.getString(R.string.buttonSearchText); |
3681 | 477 | page = context.getString(R.string.buttonSearchText); | 464 | break; |
3682 | 478 | break; | 465 | } |
3683 | 479 | } | 466 | return page; |
3684 | 480 | return page; | 467 | } |
3685 | 481 | } | 468 | |
3686 | 482 | 469 | private int getLayoutForPosition(int position) | |
3687 | 483 | private int getLayoutForPosition(int position) | 470 | throws NoLayoutForPositionException { |
3688 | 484 | throws NoLayoutForPositionException { | 471 | switch (position) { |
3689 | 485 | switch (position) { | 472 | case PAGE_SERVICE: |
3690 | 486 | case PAGE_SERVICE: | 473 | return R.layout.slide_service; |
3691 | 487 | return R.layout.slide_service; | 474 | case PAGE_LIVE: |
3692 | 488 | case PAGE_LIVE: | 475 | return R.layout.slide_service; |
3693 | 489 | return R.layout.slide_service; | 476 | case PAGE_DISPLAY: |
3694 | 490 | case PAGE_DISPLAY: | 477 | return R.layout.misc; |
3695 | 491 | return R.layout.misc; | 478 | case PAGE_STAGE: |
3696 | 492 | case PAGE_STAGE: | 479 | return R.layout.stageview; |
3697 | 493 | return R.layout.stageview; | 480 | case PAGE_ALERT: |
3698 | 494 | case PAGE_ALERT: | 481 | return R.layout.alert; |
3699 | 495 | return R.layout.alert; | 482 | case PAGE_SEARCH: |
3700 | 496 | case PAGE_SEARCH: | 483 | return R.layout.search; |
3701 | 497 | return R.layout.search; | 484 | default: |
3702 | 498 | default: | 485 | throw new NoLayoutForPositionException( |
3703 | 499 | throw new NoLayoutForPositionException( | 486 | "No Layout for position (" + position + ")"); |
3704 | 500 | "No Layout for position (" + position + ")"); | 487 | } |
3705 | 501 | } | 488 | } |
3706 | 502 | } | 489 | |
3707 | 503 | 490 | private AdapterView.OnItemClickListener onItemClickListenerSetLive = | |
3708 | 504 | private AdapterView.OnItemClickListener onItemClickListenerSetLive = | 491 | new AdapterView.OnItemClickListener() { |
3709 | 505 | new AdapterView.OnItemClickListener() { | 492 | @Override |
3710 | 506 | @Override | 493 | public void onItemClick(AdapterView<?> adapterView, View view, |
3711 | 507 | public void onItemClick(AdapterView<?> adapterView, View view, | 494 | int i, long l) { |
3712 | 508 | int i, long l) { | 495 | controller.setData(Api.LIVE_SET, i); |
3713 | 509 | controller.setData(Api.LIVE_SET, i); | 496 | } |
3714 | 510 | } | 497 | }; |
3715 | 511 | }; | 498 | |
3716 | 512 | 499 | private AdapterView.OnItemLongClickListener | |
3717 | 513 | private AdapterView.OnItemLongClickListener | 500 | adapterViewOnItemLongClickListener = |
3718 | 514 | adapterViewOnItemLongClickListener = | 501 | new AdapterView.OnItemLongClickListener() { |
3719 | 515 | new AdapterView.OnItemLongClickListener() { | 502 | @Override |
3720 | 516 | @Override | 503 | public boolean onItemLongClick(AdapterView<?> adapterView, |
3721 | 517 | public boolean onItemLongClick(AdapterView<?> adapterView, | 504 | View view, int i, long l) { |
3722 | 518 | View view, int i, long l) { | 505 | controller.setData(Api.SERVICE_SET, i); |
3723 | 519 | controller.setData(Api.SERVICE_SET, i); | 506 | ((PagerActivity) context).setCurrentPage(PAGE_LIVE); |
3724 | 520 | ((PagerActivity) context).setCurrentPage(PAGE_LIVE); | 507 | return true; |
3725 | 521 | return true; | 508 | } |
3726 | 522 | } | 509 | }; |
3727 | 523 | }; | 510 | |
3728 | 524 | 511 | private ListView.OnItemClickListener onItemClickListenerService = | |
3729 | 525 | private ListView.OnItemClickListener onItemClickListenerService = | 512 | new AdapterView.OnItemClickListener() { |
3730 | 526 | new AdapterView.OnItemClickListener() { | 513 | @Override |
3731 | 527 | @Override | 514 | public void onItemClick(AdapterView<?> adapterView, View view, |
3732 | 528 | public void onItemClick(AdapterView<?> adapterView, View view, | 515 | int i, long l) { |
3733 | 529 | int i, long l) { | 516 | controller.setData(Api.SERVICE_SET, i); |
3734 | 530 | controller.setData(Api.SERVICE_SET, i); | 517 | } |
3735 | 531 | } | 518 | }; |
3736 | 532 | }; | 519 | |
3737 | 533 | 520 | private Button.OnClickListener onClickListenerNavigate = | |
3738 | 534 | private Button.OnClickListener onClickListenerNavigate = | 521 | new Button.OnClickListener() { |
3739 | 535 | new Button.OnClickListener() { | 522 | @Override |
3740 | 536 | @Override | 523 | public void onClick(View v) { |
3741 | 537 | public void onClick(View v) { | 524 | if (v.getId() == R.id.prev) { |
3742 | 538 | if (v.getId() == R.id.prev) { | 525 | controller.navigate(OpenLPNavigate.NAVIGATE_PREVIOUS); |
3743 | 539 | controller.navigate(OpenLPNavigate.NAVIGATE_PREVIOUS); | 526 | } else if (v.getId() == R.id.next) { |
3744 | 540 | } | 527 | controller.navigate(OpenLPNavigate.NAVIGATE_NEXT); |
3745 | 541 | else if (v.getId() == R.id.next) { | 528 | } |
3746 | 542 | controller.navigate(OpenLPNavigate.NAVIGATE_NEXT); | 529 | } |
3747 | 543 | } | 530 | }; |
3748 | 544 | } | 531 | |
3749 | 545 | }; | 532 | /** |
3750 | 546 | 533 | * Alert Button Listener | |
3751 | 547 | /** | 534 | */ |
3752 | 548 | * Alert Button Listener | 535 | private Button.OnClickListener mSend = new Button.OnClickListener() { |
3753 | 549 | */ | 536 | @Override |
3754 | 550 | private Button.OnClickListener mSend = new Button.OnClickListener() { | 537 | public void onClick(View v) { |
3755 | 551 | @Override | 538 | EditText edittext = (EditText) context.findViewById(R.id.alert); |
3756 | 552 | public void onClick(View v) { | 539 | |
3757 | 553 | EditText edittext = (EditText) context.findViewById(R.id.alert); | 540 | if (edittext.getText().toString().trim().length() > 0) { |
3758 | 554 | 541 | apiCallIntent | |
3759 | 555 | if (edittext.getText().toString().trim().length() > 0) { | 542 | .putExtra(Api.ALERT, edittext.getText().toString()); |
3760 | 556 | apiCallIntent | 543 | context.startService(apiCallIntent); |
3761 | 557 | .putExtra(Api.ALERT, edittext.getText().toString()); | 544 | } else { |
3762 | 558 | context.startService(apiCallIntent); | 545 | Toast.makeText(context, |
3763 | 559 | } | 546 | context.getString(R.string.alertTextNull), |
3764 | 560 | else { | 547 | Toast.LENGTH_SHORT).show(); |
3765 | 561 | Toast.makeText(context, | 548 | } |
3766 | 562 | context.getString(R.string.alertTextNull), | 549 | } |
3767 | 563 | Toast.LENGTH_SHORT).show(); | 550 | }; |
3768 | 564 | } | 551 | |
3769 | 565 | } | 552 | public View.OnClickListener onClickListenerToggleDisplay = |
3770 | 566 | }; | 553 | new View.OnClickListener() { |
3771 | 567 | 554 | @Override | |
3772 | 568 | public View.OnClickListener onClickListenerToggleDisplay = | 555 | public void onClick(View view) { |
3773 | 569 | new View.OnClickListener() { | 556 | ToggleButton toggleButton = (ToggleButton) view; |
3774 | 570 | @Override | 557 | |
3775 | 571 | public void onClick(View view) { | 558 | String displayType = getDisplayType(); |
3776 | 572 | ToggleButton toggleButton = (ToggleButton) view; | 559 | if (!toggleButton.isChecked()) { |
3777 | 573 | 560 | controller.setDisplay(OpenLPNavigate.DISPLAY_SHOW); | |
3778 | 574 | String displayType = getDisplayType(); | 561 | } else { |
3779 | 575 | if (!toggleButton.isChecked()) { | 562 | if (displayType |
3780 | 576 | controller.setDisplay(OpenLPNavigate.DISPLAY_SHOW); | 563 | .equals(context.getString(R.string.displayScreen))) { |
3781 | 577 | } | 564 | controller.setDisplay(OpenLPNavigate.HIDE_SCREEN); |
3782 | 578 | else { | 565 | } else if (displayType |
3783 | 579 | if (displayType | 566 | .equals(context.getString(R.string.displayTheme))) { |
3784 | 580 | .equals(context.getString(R.string.displayScreen))) { | 567 | controller.setDisplay(OpenLPNavigate.HIDE_THEME); |
3785 | 581 | controller.setDisplay(OpenLPNavigate.HIDE_SCREEN); | 568 | } else { |
3786 | 582 | } | 569 | controller.setDisplay(OpenLPNavigate.HIDE_DESKTOP); |
3787 | 583 | else if (displayType | 570 | } |
3788 | 584 | .equals(context.getString(R.string.displayTheme))) { | 571 | } |
3789 | 585 | controller.setDisplay(OpenLPNavigate.HIDE_THEME); | 572 | } |
3790 | 586 | } | 573 | }; |
3791 | 587 | else { | 574 | |
3792 | 588 | controller.setDisplay(OpenLPNavigate.HIDE_DESKTOP); | 575 | @Override |
3793 | 589 | } | 576 | public int getCount() { |
3794 | 590 | } | 577 | return 5; |
3795 | 591 | } | 578 | } |
3796 | 592 | }; | 579 | |
3797 | 593 | 580 | @Override | |
3798 | 594 | @Override | 581 | public boolean isViewFromObject(View view, Object o) { |
3799 | 595 | public int getCount() { | 582 | return view == o; |
3800 | 596 | return 5; | 583 | } |
3801 | 597 | } | 584 | |
3802 | 598 | 585 | @Override | |
3803 | 599 | @Override | 586 | public void destroyItem(ViewGroup container, int position, Object object) { |
3804 | 600 | public boolean isViewFromObject(View view, Object o) { | 587 | container.removeView((View) object); |
3805 | 601 | return view == o; | 588 | } |
3806 | 602 | } | 589 | |
3807 | 603 | 590 | private static final String LOG_TAG = OpenLPController.class.getName(); | |
3808 | 604 | @Override | 591 | |
3809 | 605 | public void destroyItem(ViewGroup container, int position, Object object) { | 592 | private String getDisplayType() { |
3810 | 606 | container.removeView((View) object); | 593 | displayType = preferences |
3811 | 607 | } | 594 | .getString(context.getString(R.string.keyDisplayBlankType), |
3812 | 608 | 595 | context.getString(R.string.displayTypeValue)); | |
3813 | 609 | private static final String LOG_TAG = OpenLPController.class.getName(); | 596 | return displayType; |
3814 | 610 | 597 | } | |
3815 | 611 | private String getDisplayType() { | 598 | |
3816 | 612 | displayType = preferences | 599 | private String getUrlBase() { |
3817 | 613 | .getString(context.getString(R.string.keyDisplayBlankType), | 600 | Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false); |
3818 | 614 | context.getString(R.string.displayTypeValue)); | 601 | |
3819 | 615 | return displayType; | 602 | return String.format("%s://%s:%s/stage", |
3820 | 616 | } | 603 | useSsl ? "https" : "http", |
3821 | 617 | 604 | preferences.getString(context.getString(R.string.keyHost), | |
3822 | 618 | private String getUrlBase() { | 605 | context.getString(R.string.hostDefaultValue)), |
3823 | 619 | Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false); | 606 | preferences.getString(context.getString(R.string.keyPort), |
3824 | 620 | 607 | context.getString(R.string.portDefaultValue))); | |
3825 | 621 | return String.format("%s://%s:%s/stage", | 608 | } |
3826 | 622 | useSsl ? "https" : "http", | 609 | |
3827 | 623 | preferences.getString(context.getString(R.string.keyHost), | 610 | class NoLayoutForPositionException extends Exception { |
3828 | 624 | context.getString(R.string.hostDefaultValue)), | 611 | NoLayoutForPositionException(String detailMessage) { |
3829 | 625 | preferences.getString(context.getString(R.string.keyPort), | 612 | super(detailMessage); |
3830 | 626 | context.getString(R.string.portDefaultValue))); | 613 | } |
3831 | 627 | } | 614 | } |
3569 | 628 | |||
3570 | 629 | class NoLayoutForPositionException extends Exception { | ||
3571 | 630 | NoLayoutForPositionException(String detailMessage) { | ||
3572 | 631 | super(detailMessage); | ||
3573 | 632 | } | ||
3574 | 633 | } | ||
3832 | 634 | } | 615 | } |
3833 | 635 | 616 | ||
3834 | === modified file 'src/org/openlp/android/utility/OpenLPHttpClient.java' | |||
3835 | --- src/org/openlp/android/utility/OpenLPHttpClient.java 2013-04-07 12:24:38 +0000 | |||
3836 | +++ src/org/openlp/android/utility/OpenLPHttpClient.java 2013-06-04 19:32:29 +0000 | |||
3837 | @@ -68,49 +68,49 @@ | |||
3838 | 68 | */ | 68 | */ |
3839 | 69 | public class OpenLPHttpClient extends DefaultHttpClient { | 69 | public class OpenLPHttpClient extends DefaultHttpClient { |
3840 | 70 | 70 | ||
3845 | 71 | private HttpGet httpGet; | 71 | private HttpGet httpGet; |
3846 | 72 | private URL url; | 72 | private URL url; |
3847 | 73 | private final String urlBase; | 73 | private final String urlBase; |
3848 | 74 | private SSLSocketFactory sslSocketFactory; | 74 | private SSLSocketFactory sslSocketFactory; |
3849 | 75 | private Context context; | 75 | private Context context; |
3850 | 76 | 76 | ||
3856 | 77 | public OpenLPHttpClient(Context context) { | 77 | public OpenLPHttpClient(Context context) { |
3857 | 78 | SharedPreferences preferences = context.getSharedPreferences( | 78 | SharedPreferences preferences = context.getSharedPreferences( |
3858 | 79 | context.getString(R.string.keySharedPreferences), | 79 | context.getString(R.string.keySharedPreferences), |
3859 | 80 | Context.MODE_PRIVATE); | 80 | Context.MODE_PRIVATE); |
3860 | 81 | HttpParams httpParams = new BasicHttpParams(); | 81 | HttpParams httpParams = new BasicHttpParams(); |
3861 | 82 | 82 | ||
3862 | 83 | this.context = context; | 83 | this.context = context; |
3863 | 84 | 84 | ||
3893 | 85 | Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false); | 85 | Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false); |
3894 | 86 | 86 | ||
3895 | 87 | String port = preferences.getString( | 87 | String port = preferences.getString( |
3896 | 88 | context.getString(R.string.keyPort), | 88 | context.getString(R.string.keyPort), |
3897 | 89 | context.getString(R.string.portDefaultValue) | 89 | context.getString(R.string.portDefaultValue) |
3898 | 90 | ); | 90 | ); |
3899 | 91 | 91 | ||
3900 | 92 | SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry(); | 92 | SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry(); |
3901 | 93 | if (!useSsl) { | 93 | if (!useSsl) { |
3902 | 94 | schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port))); | 94 | schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port))); |
3903 | 95 | } else { | 95 | } else { |
3904 | 96 | try { | 96 | try { |
3905 | 97 | initSsl(); | 97 | initSsl(); |
3906 | 98 | schemeRegistry.register(new Scheme("https", sslSocketFactory, Integer.valueOf(port))); | 98 | schemeRegistry.register(new Scheme("https", sslSocketFactory, Integer.valueOf(port))); |
3907 | 99 | } catch (NoSuchAlgorithmException e) { | 99 | } catch (NoSuchAlgorithmException e) { |
3908 | 100 | Log.e(LOG_TAG, e.toString()); | 100 | Log.e(LOG_TAG, e.toString()); |
3909 | 101 | } catch (KeyManagementException e) { | 101 | } catch (KeyManagementException e) { |
3910 | 102 | Log.e(LOG_TAG, e.toString()); | 102 | Log.e(LOG_TAG, e.toString()); |
3911 | 103 | } catch (KeyStoreException e) { | 103 | } catch (KeyStoreException e) { |
3912 | 104 | Log.e(LOG_TAG, e.toString()); | 104 | Log.e(LOG_TAG, e.toString()); |
3913 | 105 | } catch (UnrecoverableKeyException e) { | 105 | } catch (UnrecoverableKeyException e) { |
3914 | 106 | Log.e(LOG_TAG, e.toString()); | 106 | Log.e(LOG_TAG, e.toString()); |
3915 | 107 | } catch (CertificateException e) { | 107 | } catch (CertificateException e) { |
3916 | 108 | e.printStackTrace(); | 108 | e.printStackTrace(); |
3917 | 109 | } catch (IOException e) { | 109 | } catch (IOException e) { |
3918 | 110 | e.printStackTrace(); | 110 | e.printStackTrace(); |
3919 | 111 | } | 111 | } |
3920 | 112 | 112 | ||
3921 | 113 | } | 113 | } |
3922 | 114 | 114 | ||
3923 | 115 | String userid = preferences.getString( | 115 | String userid = preferences.getString( |
3924 | 116 | context.getString(R.string.key_userid), | 116 | context.getString(R.string.key_userid), |
3925 | @@ -123,131 +123,131 @@ | |||
3926 | 123 | context.getString(R.string.passwordDefaultValue) | 123 | context.getString(R.string.passwordDefaultValue) |
3927 | 124 | ); | 124 | ); |
3928 | 125 | 125 | ||
3930 | 126 | Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password); | 126 | Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password); |
3931 | 127 | 127 | ||
3932 | 128 | Credentials creds = new UsernamePasswordCredentials(userid, password); | 128 | Credentials creds = new UsernamePasswordCredentials(userid, password); |
3933 | 129 | getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds); | 129 | getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds); |
3934 | 130 | 130 | ||
3935 | 131 | urlBase = String.format("http%s://%s:%s", | 131 | urlBase = String.format("http%s://%s:%s", |
3988 | 132 | useSsl ? "s" : "", | 132 | useSsl ? "s" : "", |
3989 | 133 | preferences.getString( | 133 | preferences.getString( |
3990 | 134 | context.getString(R.string.keyHost), | 134 | context.getString(R.string.keyHost), |
3991 | 135 | context.getString(R.string.hostDefaultValue)), port); | 135 | context.getString(R.string.hostDefaultValue)), port); |
3992 | 136 | 136 | ||
3993 | 137 | int connectionTimeout = context.getResources().getInteger( | 137 | int connectionTimeout = context.getResources().getInteger( |
3994 | 138 | R.integer.connectionTimeoutDefaultValue); | 138 | R.integer.connectionTimeoutDefaultValue); |
3995 | 139 | int socketTimeout = context.getResources().getInteger( | 139 | int socketTimeout = context.getResources().getInteger( |
3996 | 140 | R.integer.socketTimeoutDefaultValue); | 140 | R.integer.socketTimeoutDefaultValue); |
3997 | 141 | 141 | ||
3998 | 142 | if (preferences.getBoolean( | 142 | if (preferences.getBoolean( |
3999 | 143 | context.getString(R.string.keyEnableCustomTimeout), false)) { | 143 | context.getString(R.string.keyEnableCustomTimeout), false)) { |
4000 | 144 | Log.d(LOG_TAG, String.format("Retrieving values for %s and %s", | 144 | Log.d(LOG_TAG, String.format("Retrieving values for %s and %s", |
4001 | 145 | context.getString(R.string.keyConnectionTimeout), | 145 | context.getString(R.string.keyConnectionTimeout), |
4002 | 146 | context.getString(R.string.keySocketTimeout))); | 146 | context.getString(R.string.keySocketTimeout))); |
4003 | 147 | connectionTimeout = Integer.parseInt(preferences.getString( | 147 | connectionTimeout = Integer.parseInt(preferences.getString( |
4004 | 148 | context.getString(R.string.keyConnectionTimeout), | 148 | context.getString(R.string.keyConnectionTimeout), |
4005 | 149 | String.valueOf(context.getResources().getInteger( | 149 | String.valueOf(context.getResources().getInteger( |
4006 | 150 | R.integer.connectionTimeoutDefaultValue)))); | 150 | R.integer.connectionTimeoutDefaultValue)))); |
4007 | 151 | socketTimeout = Integer.parseInt(preferences.getString( | 151 | socketTimeout = Integer.parseInt(preferences.getString( |
4008 | 152 | context.getString(R.string.keySocketTimeout), | 152 | context.getString(R.string.keySocketTimeout), |
4009 | 153 | String.valueOf(context.getResources().getInteger( | 153 | String.valueOf(context.getResources().getInteger( |
4010 | 154 | R.integer.socketTimeoutDefaultValue)))); | 154 | R.integer.socketTimeoutDefaultValue)))); |
4011 | 155 | } | 155 | } |
4012 | 156 | HttpConnectionParams | 156 | HttpConnectionParams |
4013 | 157 | .setConnectionTimeout(httpParams, connectionTimeout); | 157 | .setConnectionTimeout(httpParams, connectionTimeout); |
4014 | 158 | HttpConnectionParams.setSoTimeout(httpParams, socketTimeout); | 158 | HttpConnectionParams.setSoTimeout(httpParams, socketTimeout); |
4015 | 159 | setParams(httpParams); | 159 | setParams(httpParams); |
4016 | 160 | httpGet = new HttpGet(); | 160 | httpGet = new HttpGet(); |
4017 | 161 | } | 161 | } |
4018 | 162 | 162 | ||
4019 | 163 | public URL getUrl() { | 163 | public URL getUrl() { |
4020 | 164 | return url; | 164 | return url; |
4021 | 165 | } | 165 | } |
4022 | 166 | 166 | ||
4023 | 167 | public void setUrl(String apiPart) throws URISyntaxException, | 167 | public void setUrl(String apiPart) throws URISyntaxException, |
4024 | 168 | MalformedURLException { | 168 | MalformedURLException { |
4025 | 169 | url = new URL(urlBase.concat(apiPart)); | 169 | url = new URL(urlBase.concat(apiPart)); |
4026 | 170 | try { | 170 | try { |
4027 | 171 | Log.d(LOG_TAG, "URL set to: " + URLDecoder.decode(url.toString(), "UTF-8")); | 171 | Log.d(LOG_TAG, "URL set to: " + URLDecoder.decode(url.toString(), "UTF-8")); |
4028 | 172 | } catch (UnsupportedEncodingException e) { | 172 | } catch (UnsupportedEncodingException e) { |
4029 | 173 | Log.e(LOG_TAG, "Unable to decode url: " + e.getMessage()); | 173 | Log.e(LOG_TAG, "Unable to decode url: " + e.getMessage()); |
4030 | 174 | } | 174 | } |
4031 | 175 | httpGet.setURI(getUrl().toURI()); | 175 | httpGet.setURI(getUrl().toURI()); |
4032 | 176 | } | 176 | } |
4033 | 177 | 177 | ||
4034 | 178 | public HttpResponse execute() throws IOException { | 178 | public HttpResponse execute() throws IOException { |
4035 | 179 | return super.execute(httpGet); | 179 | return super.execute(httpGet); |
4036 | 180 | } | 180 | } |
4037 | 181 | 181 | ||
4038 | 182 | public HttpReturn handleExecute() throws IOException { | 182 | public HttpReturn handleExecute() throws IOException { |
4039 | 183 | HttpResponse response = this.execute(); | 183 | HttpResponse response = this.execute(); |
4040 | 184 | 184 | ||
4041 | 185 | Log.d(LOG_TAG, "Http response code " + String.valueOf(response.getStatusLine().getStatusCode())); | 185 | Log.d(LOG_TAG, "Http response code " + String.valueOf(response.getStatusLine().getStatusCode())); |
4042 | 186 | 186 | ||
4073 | 187 | if (response.getStatusLine().getStatusCode() == 200) { | 187 | if (response.getStatusLine().getStatusCode() == 200) { |
4074 | 188 | BufferedReader bufferedReader; | 188 | BufferedReader bufferedReader; |
4075 | 189 | HttpEntity entity = response.getEntity(); | 189 | HttpEntity entity = response.getEntity(); |
4076 | 190 | 190 | ||
4077 | 191 | if (entity != null) { | 191 | if (entity != null) { |
4078 | 192 | bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent())); | 192 | bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent())); |
4079 | 193 | StringBuilder stringBuilder = new StringBuilder(); | 193 | StringBuilder stringBuilder = new StringBuilder(); |
4080 | 194 | 194 | ||
4081 | 195 | String line = bufferedReader.readLine(); | 195 | String line = bufferedReader.readLine(); |
4082 | 196 | while (line != null) { | 196 | while (line != null) { |
4083 | 197 | stringBuilder.append(line); | 197 | stringBuilder.append(line); |
4084 | 198 | line = bufferedReader.readLine(); | 198 | line = bufferedReader.readLine(); |
4085 | 199 | } | 199 | } |
4086 | 200 | bufferedReader.close(); | 200 | bufferedReader.close(); |
4087 | 201 | return new HttpReturn(0, stringBuilder.toString(), this.context); | 201 | return new HttpReturn(0, stringBuilder.toString(), this.context); |
4088 | 202 | } | 202 | } |
4089 | 203 | } | 203 | } |
4090 | 204 | return new HttpReturn(response.getStatusLine().getStatusCode() , null, this.context); | 204 | return new HttpReturn(response.getStatusLine().getStatusCode(), null, this.context); |
4091 | 205 | } | 205 | } |
4092 | 206 | 206 | ||
4093 | 207 | public HttpEntity handleAndReturnEntity() throws IOException { | 207 | public HttpEntity handleAndReturnEntity() throws IOException { |
4094 | 208 | HttpResponse response = this.execute(); | 208 | HttpResponse response = this.execute(); |
4095 | 209 | 209 | ||
4096 | 210 | if (response.getStatusLine().getStatusCode() == 200) { | 210 | if (response.getStatusLine().getStatusCode() == 200) { |
4097 | 211 | return response.getEntity(); | 211 | return response.getEntity(); |
4098 | 212 | } | 212 | } |
4099 | 213 | return null; | 213 | return null; |
4100 | 214 | } | 214 | } |
4101 | 215 | 215 | ||
4102 | 216 | private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, | 216 | private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, |
4103 | 217 | UnrecoverableKeyException, IOException, CertificateException { | 217 | UnrecoverableKeyException, IOException, CertificateException { |
4131 | 218 | final SSLContext sslContext = SSLContext.getInstance("TLS"); | 218 | final SSLContext sslContext = SSLContext.getInstance("TLS"); |
4132 | 219 | X509TrustManager trustManager = new X509TrustManager() { | 219 | X509TrustManager trustManager = new X509TrustManager() { |
4133 | 220 | @Override | 220 | @Override |
4134 | 221 | public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { | 221 | public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { |
4135 | 222 | } | 222 | } |
4136 | 223 | 223 | ||
4137 | 224 | @Override | 224 | @Override |
4138 | 225 | public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { | 225 | public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { |
4139 | 226 | } | 226 | } |
4140 | 227 | 227 | ||
4141 | 228 | @Override | 228 | @Override |
4142 | 229 | public X509Certificate[] getAcceptedIssuers() { | 229 | public X509Certificate[] getAcceptedIssuers() { |
4143 | 230 | return null; | 230 | return null; |
4144 | 231 | } | 231 | } |
4145 | 232 | }; | 232 | }; |
4146 | 233 | sslContext.init(null, new TrustManager[]{trustManager}, null); | 233 | sslContext.init(null, new TrustManager[]{trustManager}, null); |
4147 | 234 | 234 | ||
4148 | 235 | KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); | 235 | KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
4149 | 236 | keyStore.load(null, null); | 236 | keyStore.load(null, null); |
4150 | 237 | sslSocketFactory = new SSLSocketFactory(keyStore) { | 237 | sslSocketFactory = new SSLSocketFactory(keyStore) { |
4151 | 238 | @Override | 238 | @Override |
4152 | 239 | public Socket createSocket() throws IOException { | 239 | public Socket createSocket() throws IOException { |
4153 | 240 | return sslContext.getSocketFactory().createSocket(); | 240 | return sslContext.getSocketFactory().createSocket(); |
4154 | 241 | } | 241 | } |
4155 | 242 | 242 | ||
4156 | 243 | @Override | 243 | @Override |
4157 | 244 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, | 244 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, |
4158 | 245 | UnknownHostException { | 245 | UnknownHostException { |
4164 | 246 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); | 246 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); |
4165 | 247 | } | 247 | } |
4166 | 248 | }; | 248 | }; |
4167 | 249 | sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); | 249 | sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
4168 | 250 | } | 250 | } |
4169 | 251 | 251 | ||
4171 | 252 | private final String LOG_TAG = OpenLPHttpClient.class.getName(); | 252 | private final String LOG_TAG = OpenLPHttpClient.class.getName(); |
4172 | 253 | } | 253 | } |
4173 | 254 | 254 | ||
4174 | === modified file 'src/org/openlp/android/utility/SlideAdapter.java' | |||
4175 | --- src/org/openlp/android/utility/SlideAdapter.java 2013-04-06 13:44:51 +0000 | |||
4176 | +++ src/org/openlp/android/utility/SlideAdapter.java 2013-06-04 19:32:29 +0000 | |||
4177 | @@ -35,99 +35,98 @@ | |||
4178 | 35 | import org.openlp.android.data.SlideItem; | 35 | import org.openlp.android.data.SlideItem; |
4179 | 36 | 36 | ||
4180 | 37 | public class SlideAdapter extends BaseAdapter { | 37 | public class SlideAdapter extends BaseAdapter { |
4276 | 38 | List<SlideItem> items; | 38 | List<SlideItem> items; |
4277 | 39 | Activity context; | 39 | Activity context; |
4278 | 40 | LayoutInflater inflater; | 40 | LayoutInflater inflater; |
4279 | 41 | boolean useTagDisplay = true; | 41 | boolean useTagDisplay = true; |
4280 | 42 | private int[] colors = new int[] { 0x74717000, 0x00000000 }; | 42 | private int[] colors = new int[]{0x74717000, 0x00000000}; |
4281 | 43 | private int currentSlide = -1; | 43 | private int currentSlide = -1; |
4282 | 44 | SharedPreferences prefs; | 44 | SharedPreferences prefs; |
4283 | 45 | 45 | ||
4284 | 46 | public SlideAdapter(Activity context, List<SlideItem> items, int slide) { | 46 | public SlideAdapter(Activity context, List<SlideItem> items, int slide) { |
4285 | 47 | this.context = context; | 47 | this.context = context; |
4286 | 48 | this.items = items; | 48 | this.items = items; |
4287 | 49 | this.currentSlide = slide; | 49 | this.currentSlide = slide; |
4288 | 50 | inflater = context.getLayoutInflater(); | 50 | inflater = context.getLayoutInflater(); |
4289 | 51 | 51 | ||
4290 | 52 | prefs = context.getSharedPreferences( | 52 | prefs = context.getSharedPreferences( |
4291 | 53 | context.getString(R.string.keySharedPreferences), | 53 | context.getString(R.string.keySharedPreferences), |
4292 | 54 | Context.MODE_PRIVATE); | 54 | Context.MODE_PRIVATE); |
4293 | 55 | } | 55 | } |
4294 | 56 | 56 | ||
4295 | 57 | public SlideAdapter(Activity context, List<SlideItem> items, | 57 | public SlideAdapter(Activity context, List<SlideItem> items, |
4296 | 58 | boolean useTagDisplay) { | 58 | boolean useTagDisplay) { |
4297 | 59 | this.context = context; | 59 | this.context = context; |
4298 | 60 | this.items = items; | 60 | this.items = items; |
4299 | 61 | this.useTagDisplay = useTagDisplay; | 61 | this.useTagDisplay = useTagDisplay; |
4300 | 62 | inflater = context.getLayoutInflater(); | 62 | inflater = context.getLayoutInflater(); |
4301 | 63 | 63 | ||
4302 | 64 | prefs = context.getSharedPreferences( | 64 | prefs = context.getSharedPreferences( |
4303 | 65 | context.getString(R.string.keySharedPreferences), | 65 | context.getString(R.string.keySharedPreferences), |
4304 | 66 | Context.MODE_PRIVATE); | 66 | Context.MODE_PRIVATE); |
4305 | 67 | } | 67 | } |
4306 | 68 | 68 | ||
4307 | 69 | @Override | 69 | @Override |
4308 | 70 | public int getCount() { | 70 | public int getCount() { |
4309 | 71 | return items.size(); | 71 | return items.size(); |
4310 | 72 | } | 72 | } |
4311 | 73 | 73 | ||
4312 | 74 | @Override | 74 | @Override |
4313 | 75 | public Object getItem(int i) { | 75 | public Object getItem(int i) { |
4314 | 76 | return items.get(i); | 76 | return items.get(i); |
4315 | 77 | } | 77 | } |
4316 | 78 | 78 | ||
4317 | 79 | @Override | 79 | @Override |
4318 | 80 | public long getItemId(int i) { | 80 | public long getItemId(int i) { |
4319 | 81 | return items.indexOf(items.get(i)); | 81 | return items.indexOf(items.get(i)); |
4320 | 82 | } | 82 | } |
4321 | 83 | 83 | ||
4322 | 84 | @Override | 84 | @Override |
4323 | 85 | public View getView(int position, View convertView, ViewGroup parent) { | 85 | public View getView(int position, View convertView, ViewGroup parent) { |
4324 | 86 | ViewHolder holder; | 86 | ViewHolder holder; |
4325 | 87 | View view = convertView; | 87 | View view = convertView; |
4326 | 88 | 88 | ||
4327 | 89 | SlideItem item = items.get(position); | 89 | SlideItem item = items.get(position); |
4328 | 90 | 90 | ||
4329 | 91 | if (view == null) { | 91 | if (view == null) { |
4330 | 92 | view = inflater.inflate(R.layout.slide_list_item, null); | 92 | view = inflater.inflate(R.layout.slide_list_item, null); |
4331 | 93 | holder = new ViewHolder(); | 93 | holder = new ViewHolder(); |
4332 | 94 | 94 | ||
4333 | 95 | holder.rowMarker = (TextView) view.findViewById(R.id.rowItemMarker); | 95 | holder.rowMarker = (TextView) view.findViewById(R.id.rowItemMarker); |
4334 | 96 | holder.rowItem = (TextView) view.findViewById(R.id.rowItemText); | 96 | holder.rowItem = (TextView) view.findViewById(R.id.rowItemText); |
4335 | 97 | 97 | ||
4336 | 98 | view.setTag(holder); | 98 | view.setTag(holder); |
4337 | 99 | } | 99 | } else { |
4338 | 100 | else { | 100 | holder = (ViewHolder) view.getTag(); |
4339 | 101 | holder = (ViewHolder) view.getTag(); | 101 | } |
4340 | 102 | } | 102 | |
4341 | 103 | 103 | int size = Integer.parseInt(prefs.getString( | |
4342 | 104 | int size = Integer.parseInt(prefs.getString( | 104 | context.getString(R.string.keyTextSize), |
4343 | 105 | context.getString(R.string.keyTextSize), | 105 | String.valueOf(context.getResources().getInteger( |
4344 | 106 | String.valueOf(context.getResources().getInteger( | 106 | R.integer.textSizeDefaultValue)))); |
4345 | 107 | R.integer.textSizeDefaultValue)))); | 107 | |
4346 | 108 | 108 | holder.rowMarker.setText(item.getTag()); | |
4347 | 109 | holder.rowMarker.setText(item.getTag()); | 109 | holder.rowItem.setText(item.getText()); |
4348 | 110 | holder.rowItem.setText(item.getText()); | 110 | holder.rowItem.setTextSize(size); |
4349 | 111 | holder.rowItem.setTextSize(size); | 111 | |
4350 | 112 | 112 | if (useTagDisplay) { | |
4351 | 113 | if (useTagDisplay) { | 113 | holder.rowMarker.setMinWidth(40); |
4352 | 114 | holder.rowMarker.setMinWidth(40); | 114 | } |
4353 | 115 | } | 115 | if (position == this.currentSlide) { |
4354 | 116 | if (position == this.currentSlide) { | 116 | holder.rowItem.setTextColor(Color.WHITE); |
4355 | 117 | holder.rowItem.setTextColor(Color.WHITE); | 117 | view.setBackgroundColor(Color.argb(99, 200, 200, 200)); |
4356 | 118 | view.setBackgroundColor(Color.argb(99, 200, 200, 200)); | 118 | } else { |
4357 | 119 | } else { | 119 | holder.rowItem.setTextColor(Color.LTGRAY); |
4358 | 120 | holder.rowItem.setTextColor(Color.LTGRAY); | 120 | view.setBackgroundColor(colors[position % colors.length]); |
4359 | 121 | view.setBackgroundColor(colors[position % colors.length]); | 121 | } |
4360 | 122 | } | 122 | |
4361 | 123 | 123 | return view; | |
4362 | 124 | return view; | 124 | } |
4363 | 125 | } | 125 | |
4364 | 126 | 126 | static class ViewHolder { | |
4365 | 127 | static class ViewHolder { | 127 | TextView rowMarker; |
4366 | 128 | TextView rowMarker; | 128 | TextView rowItem; |
4367 | 129 | TextView rowItem; | 129 | } |
4368 | 130 | } | 130 | |
4369 | 131 | 131 | private final String LOG_TAG = SlideAdapter.class.getName(); | |
4275 | 132 | private final String LOG_TAG = SlideAdapter.class.getName(); | ||
4370 | 133 | } | 132 | } |
4371 | 134 | 133 | ||
4372 | === modified file 'src/org/openlp/android/utility/StringHelper.java' | |||
4373 | --- src/org/openlp/android/utility/StringHelper.java 2013-04-06 13:44:51 +0000 | |||
4374 | +++ src/org/openlp/android/utility/StringHelper.java 2013-06-04 19:32:29 +0000 | |||
4375 | @@ -29,35 +29,32 @@ | |||
4376 | 29 | * String helper utility to do common string processing. | 29 | * String helper utility to do common string processing. |
4377 | 30 | */ | 30 | */ |
4378 | 31 | public class StringHelper { | 31 | public class StringHelper { |
4381 | 32 | public synchronized static String convertStreamToString(InputStream is) { | 32 | public synchronized static String convertStreamToString(InputStream is) { |
4382 | 33 | /* | 33 | /* |
4383 | 34 | * To convert the InputStream to String we use the | 34 | * To convert the InputStream to String we use the |
4384 | 35 | * BufferedReader.readLine() method. We iterate until the BufferedReader | 35 | * BufferedReader.readLine() method. We iterate until the BufferedReader |
4385 | 36 | * return null which means there's no more data to read. Each line will | 36 | * return null which means there's no more data to read. Each line will |
4386 | 37 | * appended to a StringBuilder and returned as String. | 37 | * appended to a StringBuilder and returned as String. |
4387 | 38 | */ | 38 | */ |
4388 | 39 | 39 | ||
4391 | 40 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); | 40 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
4392 | 41 | StringBuilder sb = new StringBuilder(); | 41 | StringBuilder sb = new StringBuilder(); |
4393 | 42 | 42 | ||
4413 | 43 | String line = null; | 43 | String line = null; |
4414 | 44 | try { | 44 | try { |
4415 | 45 | while ((line = reader.readLine()) != null) { | 45 | while ((line = reader.readLine()) != null) { |
4416 | 46 | sb.append(line + "\n"); | 46 | sb.append(line + "\n"); |
4417 | 47 | } | 47 | } |
4418 | 48 | } | 48 | } catch (IOException e) { |
4419 | 49 | catch (IOException e) { | 49 | e.printStackTrace(); |
4420 | 50 | e.printStackTrace(); | 50 | } finally { |
4421 | 51 | } | 51 | try { |
4422 | 52 | finally { | 52 | is.close(); |
4423 | 53 | try { | 53 | } catch (IOException e) { |
4424 | 54 | is.close(); | 54 | e.printStackTrace(); |
4425 | 55 | } | 55 | } |
4426 | 56 | catch (IOException e) { | 56 | } |
4427 | 57 | e.printStackTrace(); | 57 | return sb.toString(); |
4428 | 58 | } | 58 | } |
4410 | 59 | } | ||
4411 | 60 | return sb.toString(); | ||
4412 | 61 | } | ||
4429 | 62 | 59 | ||
4430 | 63 | } | 60 | } |
4431 | 64 | 61 | ||
4432 | === modified file 'src/org/openlp/android/utility/WebCallReturningAsyncTask.java' | |||
4433 | --- src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2013-04-06 13:44:51 +0000 | |||
4434 | +++ src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2013-06-04 19:32:29 +0000 | |||
4435 | @@ -34,85 +34,81 @@ | |||
4436 | 34 | import java.io.InputStreamReader; | 34 | import java.io.InputStreamReader; |
4437 | 35 | 35 | ||
4438 | 36 | public class WebCallReturningAsyncTask extends AsyncTask<String, Void, String> { | 36 | public class WebCallReturningAsyncTask extends AsyncTask<String, Void, String> { |
4520 | 37 | private Activity context; | 37 | private Activity context; |
4521 | 38 | private String apiPart; | 38 | private String apiPart; |
4522 | 39 | 39 | ||
4523 | 40 | public WebCallReturningAsyncTask(Activity context) { | 40 | public WebCallReturningAsyncTask(Activity context) { |
4524 | 41 | this.context = context; | 41 | this.context = context; |
4525 | 42 | } | 42 | } |
4526 | 43 | 43 | ||
4527 | 44 | public WebCallReturningAsyncTask(Activity context, String apiPart) { | 44 | public WebCallReturningAsyncTask(Activity context, String apiPart) { |
4528 | 45 | this.context = context; | 45 | this.context = context; |
4529 | 46 | this.apiPart = apiPart; | 46 | this.apiPart = apiPart; |
4530 | 47 | } | 47 | } |
4531 | 48 | 48 | ||
4532 | 49 | @Override | 49 | @Override |
4533 | 50 | protected String doInBackground(String... apiCall) { | 50 | protected String doInBackground(String... apiCall) { |
4534 | 51 | OpenLPHttpClient httpClient = new OpenLPHttpClient(context); | 51 | OpenLPHttpClient httpClient = new OpenLPHttpClient(context); |
4535 | 52 | HttpResponse response = null; | 52 | HttpResponse response = null; |
4536 | 53 | BufferedReader bufferedReader = null; | 53 | BufferedReader bufferedReader = null; |
4537 | 54 | 54 | ||
4538 | 55 | try { | 55 | try { |
4539 | 56 | if (apiPart == null) { | 56 | if (apiPart == null) { |
4540 | 57 | httpClient.setUrl(apiCall[0]); | 57 | httpClient.setUrl(apiCall[0]); |
4541 | 58 | } | 58 | } else { |
4542 | 59 | else { | 59 | httpClient.setUrl(String.format("%s%s", apiPart, apiCall[0])); |
4543 | 60 | httpClient.setUrl(String.format("%s%s", apiPart, apiCall[0])); | 60 | } |
4544 | 61 | } | 61 | |
4545 | 62 | 62 | if (httpClient.getUrl().getHost().trim().length() <= 0) { | |
4546 | 63 | if (httpClient.getUrl().getHost().trim().length() <= 0) { | 63 | context.startActivity(new Intent(context, Preferences.class)); |
4547 | 64 | context.startActivity(new Intent(context, Preferences.class)); | 64 | } else { |
4548 | 65 | } | 65 | response = httpClient.execute(); |
4549 | 66 | else { | 66 | } |
4550 | 67 | response = httpClient.execute(); | 67 | |
4551 | 68 | } | 68 | if (response != null |
4552 | 69 | 69 | && response.getStatusLine().getStatusCode() == 200) { | |
4553 | 70 | if (response != null | 70 | HttpEntity entity = response.getEntity(); |
4554 | 71 | && response.getStatusLine().getStatusCode() == 200) { | 71 | |
4555 | 72 | HttpEntity entity = response.getEntity(); | 72 | if (entity != null) { |
4556 | 73 | 73 | bufferedReader = new BufferedReader( | |
4557 | 74 | if (entity != null) { | 74 | new InputStreamReader(entity.getContent())); |
4558 | 75 | bufferedReader = new BufferedReader( | 75 | StringBuilder stringBuilder = new StringBuilder(); |
4559 | 76 | new InputStreamReader(entity.getContent())); | 76 | |
4560 | 77 | StringBuilder stringBuilder = new StringBuilder(); | 77 | String line = bufferedReader.readLine(); |
4561 | 78 | 78 | while (line != null) { | |
4562 | 79 | String line = bufferedReader.readLine(); | 79 | stringBuilder.append(line); |
4563 | 80 | while (line != null) { | 80 | line = bufferedReader.readLine(); |
4564 | 81 | stringBuilder.append(line); | 81 | } |
4565 | 82 | line = bufferedReader.readLine(); | 82 | |
4566 | 83 | } | 83 | Log.i(LOG_TAG, String.format("entity: %s", |
4567 | 84 | 84 | stringBuilder.toString())); | |
4568 | 85 | Log.i(LOG_TAG, String.format("entity: %s", | 85 | bufferedReader.close(); |
4569 | 86 | stringBuilder.toString())); | 86 | return stringBuilder.toString(); |
4570 | 87 | bufferedReader.close(); | 87 | } |
4571 | 88 | return stringBuilder.toString(); | 88 | } |
4572 | 89 | } | 89 | } catch (Exception e) { |
4573 | 90 | } | 90 | Log.e(LOG_TAG, e.toString()); |
4574 | 91 | } | 91 | Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); |
4575 | 92 | catch (Exception e) { | 92 | if (bufferedReader != null) { |
4576 | 93 | Log.e(LOG_TAG, e.toString()); | 93 | try { |
4577 | 94 | Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); | 94 | bufferedReader.close(); |
4578 | 95 | if (bufferedReader != null) { | 95 | } catch (IOException e1) { |
4579 | 96 | try { | 96 | // do nothing as we are in an error state anyway |
4580 | 97 | bufferedReader.close(); | 97 | } |
4581 | 98 | } | 98 | } |
4582 | 99 | catch (IOException e1) { | 99 | } |
4583 | 100 | // do nothing as we are in an error state anyway | 100 | return null; |
4584 | 101 | } | 101 | } |
4585 | 102 | } | 102 | |
4586 | 103 | } | 103 | @Override |
4587 | 104 | return null; | 104 | protected void onPreExecute() { |
4588 | 105 | } | 105 | super.onPreExecute(); |
4589 | 106 | 106 | } | |
4590 | 107 | @Override | 107 | |
4591 | 108 | protected void onPreExecute() { | 108 | @Override |
4592 | 109 | super.onPreExecute(); | 109 | protected void onPostExecute(String s) { |
4593 | 110 | } | 110 | super.onPostExecute(s); |
4594 | 111 | 111 | } | |
4595 | 112 | @Override | 112 | |
4596 | 113 | protected void onPostExecute(String s) { | 113 | private final String LOG_TAG = this.getClass().getName(); |
4516 | 114 | super.onPostExecute(s); | ||
4517 | 115 | } | ||
4518 | 116 | |||
4519 | 117 | private final String LOG_TAG = this.getClass().getName(); | ||
4597 | 118 | } | 114 | } |
Looks good to me :)
So we'll settle on using spaces for indentation?
The thought crossed my mind: What is the possibility of 'mavenizing' the build? I was thinking in terms of the code-style/ error-detection plugins available for maven which could help us keep everything clean.
Maybe not the best place to discuss it though :P