diff --git a/assets/html/img/ultrasonic.png b/assets/html/img/ultrasonic.png index 8b8ef219..3e8c9f56 100644 Binary files a/assets/html/img/ultrasonic.png and b/assets/html/img/ultrasonic.png differ diff --git a/gen/com/thejoshwa/ultrasonic/androidapp/R.java b/gen/com/thejoshwa/ultrasonic/androidapp/R.java index 44fb17bf..d07b2875 100644 --- a/gen/com/thejoshwa/ultrasonic/androidapp/R.java +++ b/gen/com/thejoshwa/ultrasonic/androidapp/R.java @@ -839,12 +839,12 @@ or to a theme attribute in the form "?[package:][type:]na public static final int select_album_n_songs_unpinned=0x7f0d0002; } public static final class string { - public static final int background_task_loading=0x7f080101; - public static final int background_task_network_error=0x7f080103; - public static final int background_task_no_network=0x7f080102; - public static final int background_task_not_found=0x7f080104; - public static final int background_task_parse_error=0x7f080105; - public static final int background_task_wait=0x7f080100; + public static final int background_task_loading=0x7f080105; + public static final int background_task_network_error=0x7f080107; + public static final int background_task_no_network=0x7f080106; + public static final int background_task_not_found=0x7f080108; + public static final int background_task_parse_error=0x7f080109; + public static final int background_task_wait=0x7f080104; public static final int button_bar_browse=0x7f080013; public static final int button_bar_home=0x7f080012; public static final int button_bar_now_playing=0x7f080016; @@ -894,9 +894,9 @@ or to a theme attribute in the form "?[package:][type:]na public static final int download_repeat_single=0x7f080073; public static final int download_visualizer_off=0x7f080075; public static final int download_visualizer_on=0x7f080074; - public static final int equalizer_enabled=0x7f080112; - public static final int equalizer_label=0x7f080111; - public static final int equalizer_preset=0x7f080113; + public static final int equalizer_enabled=0x7f080116; + public static final int equalizer_label=0x7f080115; + public static final int equalizer_preset=0x7f080117; public static final int error_label=0x7f08007f; public static final int help_back=0x7f080039; public static final int help_close=0x7f08003a; @@ -938,14 +938,14 @@ or to a theme attribute in the form "?[package:][type:]na public static final int menu_settings=0x7f080030; public static final int music_library_label=0x7f080048; public static final int music_library_label_offline=0x7f080049; - public static final int music_service_retry=0x7f0800ff; - public static final int parser_artist_count=0x7f08010d; - public static final int parser_not_authenticated=0x7f08010b; - public static final int parser_not_authorized=0x7f08010c; - public static final int parser_reading=0x7f080107; - public static final int parser_reading_done=0x7f080108; - public static final int parser_upgrade_client=0x7f080109; - public static final int parser_upgrade_server=0x7f08010a; + public static final int music_service_retry=0x7f080103; + public static final int parser_artist_count=0x7f080111; + public static final int parser_not_authenticated=0x7f08010f; + public static final int parser_not_authorized=0x7f080110; + public static final int parser_reading=0x7f08010b; + public static final int parser_reading_done=0x7f08010c; + public static final int parser_upgrade_client=0x7f08010d; + public static final int parser_upgrade_server=0x7f08010e; public static final int play_video_loading=0x7f08003d; public static final int play_video_noplugin=0x7f08003e; public static final int playlist_label=0x7f080036; @@ -982,151 +982,155 @@ or to a theme attribute in the form "?[package:][type:]na public static final int select_album_play_all=0x7f080051; public static final int select_album_searching=0x7f080050; public static final int select_album_select=0x7f08004b; - public static final int select_artist_all_folders=0x7f080110; + public static final int select_artist_all_folders=0x7f080114; public static final int select_artist_empty=0x7f080059; - public static final int select_artist_folder=0x7f08010f; - public static final int select_artist_refresh=0x7f08010e; + public static final int select_artist_folder=0x7f080113; + public static final int select_artist_refresh=0x7f080112; public static final int select_genre_empty=0x7f08005a; public static final int select_playlist_empty=0x7f08005b; - public static final int service_connecting=0x7f080106; - public static final int settings_appearance_title=0x7f080095; - public static final int settings_buffer_length=0x7f0800ce; - public static final int settings_buffer_length_1=0x7f0800d0; - public static final int settings_buffer_length_10=0x7f0800d4; - public static final int settings_buffer_length_12=0x7f0800d5; - public static final int settings_buffer_length_15=0x7f0800d6; - public static final int settings_buffer_length_2=0x7f0800d1; - public static final int settings_buffer_length_20=0x7f0800d7; - public static final int settings_buffer_length_30=0x7f0800d8; - public static final int settings_buffer_length_5=0x7f0800d2; - public static final int settings_buffer_length_8=0x7f0800d3; - public static final int settings_cache_location=0x7f08008d; - public static final int settings_cache_location_error=0x7f08008e; - public static final int settings_cache_size=0x7f08008c; - public static final int settings_cache_size_100=0x7f0800b5; - public static final int settings_cache_size_1000=0x7f0800b8; - public static final int settings_cache_size_10000=0x7f0800bb; - public static final int settings_cache_size_200=0x7f0800b6; - public static final int settings_cache_size_2000=0x7f0800b9; - public static final int settings_cache_size_20000=0x7f0800bc; - public static final int settings_cache_size_500=0x7f0800b7; - public static final int settings_cache_size_5000=0x7f0800ba; - public static final int settings_cache_size_unlimited=0x7f0800bd; - public static final int settings_cache_title=0x7f08008a; - public static final int settings_clear_search_history=0x7f0800be; - public static final int settings_connection_failure=0x7f080092; - public static final int settings_default_albums=0x7f0800fd; - public static final int settings_default_artists=0x7f0800fc; - public static final int settings_default_songs=0x7f0800fe; - public static final int settings_display_bitrate=0x7f0800a9; - public static final int settings_display_bitrate_summary=0x7f0800aa; - public static final int settings_hide_media_summary=0x7f0800c8; - public static final int settings_hide_media_title=0x7f0800c7; - public static final int settings_hide_media_toast=0x7f0800c9; - public static final int settings_invalid_url=0x7f080093; - public static final int settings_invalid_username=0x7f080094; - public static final int settings_max_albums=0x7f0800eb; - public static final int settings_max_artists=0x7f0800fa; - public static final int settings_max_bitrate_112=0x7f0800a0; - public static final int settings_max_bitrate_128=0x7f0800a1; - public static final int settings_max_bitrate_160=0x7f0800a2; - public static final int settings_max_bitrate_192=0x7f0800a3; - public static final int settings_max_bitrate_256=0x7f0800a4; - public static final int settings_max_bitrate_32=0x7f08009c; - public static final int settings_max_bitrate_320=0x7f0800a5; - public static final int settings_max_bitrate_64=0x7f08009d; - public static final int settings_max_bitrate_80=0x7f08009e; - public static final int settings_max_bitrate_96=0x7f08009f; - public static final int settings_max_bitrate_mobile=0x7f08009b; - public static final int settings_max_bitrate_unlimited=0x7f0800a6; - public static final int settings_max_bitrate_wifi=0x7f08009a; - public static final int settings_max_songs=0x7f0800fb; - public static final int settings_media_button_summary=0x7f0800cb; - public static final int settings_media_button_title=0x7f0800ca; - public static final int settings_network_timeout=0x7f0800cf; - public static final int settings_network_timeout_105000=0x7f0800df; - public static final int settings_network_timeout_120000=0x7f0800e0; - public static final int settings_network_timeout_15000=0x7f0800d9; - public static final int settings_network_timeout_30000=0x7f0800da; - public static final int settings_network_timeout_45000=0x7f0800db; - public static final int settings_network_timeout_60000=0x7f0800dc; - public static final int settings_network_timeout_75000=0x7f0800dd; - public static final int settings_network_timeout_90000=0x7f0800de; - public static final int settings_network_title=0x7f080099; - public static final int settings_other_title=0x7f0800c0; - public static final int settings_playback_control_title=0x7f0800c2; - public static final int settings_preload=0x7f08008b; - public static final int settings_preload_1=0x7f0800af; - public static final int settings_preload_10=0x7f0800b3; - public static final int settings_preload_2=0x7f0800b0; - public static final int settings_preload_3=0x7f0800b1; - public static final int settings_preload_5=0x7f0800b2; - public static final int settings_preload_unlimited=0x7f0800b4; - public static final int settings_screen_lit_summary=0x7f0800cd; - public static final int settings_screen_lit_title=0x7f0800cc; - public static final int settings_scrobble_summary=0x7f0800c4; - public static final int settings_scrobble_title=0x7f0800c3; - public static final int settings_search_1=0x7f0800ec; - public static final int settings_search_10=0x7f0800ef; - public static final int settings_search_100=0x7f0800f7; - public static final int settings_search_15=0x7f0800f0; - public static final int settings_search_20=0x7f0800f1; - public static final int settings_search_25=0x7f0800f2; - public static final int settings_search_250=0x7f0800f8; - public static final int settings_search_3=0x7f0800ed; - public static final int settings_search_30=0x7f0800f3; - public static final int settings_search_40=0x7f0800f4; - public static final int settings_search_5=0x7f0800ee; - public static final int settings_search_50=0x7f0800f5; - public static final int settings_search_500=0x7f0800f9; - public static final int settings_search_75=0x7f0800f6; - public static final int settings_search_history_cleared=0x7f0800bf; - public static final int settings_search_title=0x7f0800c1; - public static final int settings_server_address=0x7f080087; - public static final int settings_server_name=0x7f080086; - public static final int settings_server_password=0x7f080089; - public static final int settings_server_scaling_summary=0x7f0800c6; - public static final int settings_server_scaling_title=0x7f0800c5; - public static final int settings_server_unused1=0x7f080083; - public static final int settings_server_unused2=0x7f080084; - public static final int settings_server_unused3=0x7f080085; - public static final int settings_server_username=0x7f080088; + public static final int service_connecting=0x7f08010a; + public static final int settings_appearance_title=0x7f080099; + public static final int settings_buffer_length=0x7f0800d2; + public static final int settings_buffer_length_1=0x7f0800d4; + public static final int settings_buffer_length_10=0x7f0800d8; + public static final int settings_buffer_length_12=0x7f0800d9; + public static final int settings_buffer_length_15=0x7f0800da; + public static final int settings_buffer_length_2=0x7f0800d5; + public static final int settings_buffer_length_20=0x7f0800db; + public static final int settings_buffer_length_30=0x7f0800dc; + public static final int settings_buffer_length_5=0x7f0800d6; + public static final int settings_buffer_length_8=0x7f0800d7; + public static final int settings_cache_location=0x7f080091; + public static final int settings_cache_location_error=0x7f080092; + public static final int settings_cache_size=0x7f080090; + public static final int settings_cache_size_100=0x7f0800b9; + public static final int settings_cache_size_1000=0x7f0800bc; + public static final int settings_cache_size_10000=0x7f0800bf; + public static final int settings_cache_size_200=0x7f0800ba; + public static final int settings_cache_size_2000=0x7f0800bd; + public static final int settings_cache_size_20000=0x7f0800c0; + public static final int settings_cache_size_500=0x7f0800bb; + public static final int settings_cache_size_5000=0x7f0800be; + public static final int settings_cache_size_unlimited=0x7f0800c1; + public static final int settings_cache_title=0x7f08008e; + public static final int settings_clear_search_history=0x7f0800c2; + public static final int settings_connection_failure=0x7f080096; + public static final int settings_default_albums=0x7f080101; + public static final int settings_default_artists=0x7f080100; + public static final int settings_default_songs=0x7f080102; + public static final int settings_display_bitrate=0x7f0800ad; + public static final int settings_display_bitrate_summary=0x7f0800ae; + public static final int settings_hide_media_summary=0x7f0800cc; + public static final int settings_hide_media_title=0x7f0800cb; + public static final int settings_hide_media_toast=0x7f0800cd; + public static final int settings_invalid_url=0x7f080097; + public static final int settings_invalid_username=0x7f080098; + public static final int settings_max_albums=0x7f0800ef; + public static final int settings_max_artists=0x7f0800fe; + public static final int settings_max_bitrate_112=0x7f0800a4; + public static final int settings_max_bitrate_128=0x7f0800a5; + public static final int settings_max_bitrate_160=0x7f0800a6; + public static final int settings_max_bitrate_192=0x7f0800a7; + public static final int settings_max_bitrate_256=0x7f0800a8; + public static final int settings_max_bitrate_32=0x7f0800a0; + public static final int settings_max_bitrate_320=0x7f0800a9; + public static final int settings_max_bitrate_64=0x7f0800a1; + public static final int settings_max_bitrate_80=0x7f0800a2; + public static final int settings_max_bitrate_96=0x7f0800a3; + public static final int settings_max_bitrate_mobile=0x7f08009f; + public static final int settings_max_bitrate_unlimited=0x7f0800aa; + public static final int settings_max_bitrate_wifi=0x7f08009e; + public static final int settings_max_songs=0x7f0800ff; + public static final int settings_media_button_summary=0x7f0800cf; + public static final int settings_media_button_title=0x7f0800ce; + public static final int settings_network_timeout=0x7f0800d3; + public static final int settings_network_timeout_105000=0x7f0800e3; + public static final int settings_network_timeout_120000=0x7f0800e4; + public static final int settings_network_timeout_15000=0x7f0800dd; + public static final int settings_network_timeout_30000=0x7f0800de; + public static final int settings_network_timeout_45000=0x7f0800df; + public static final int settings_network_timeout_60000=0x7f0800e0; + public static final int settings_network_timeout_75000=0x7f0800e1; + public static final int settings_network_timeout_90000=0x7f0800e2; + public static final int settings_network_title=0x7f08009d; + public static final int settings_other_title=0x7f0800c4; + public static final int settings_playback_control_title=0x7f0800c6; + public static final int settings_preload=0x7f08008f; + public static final int settings_preload_1=0x7f0800b3; + public static final int settings_preload_10=0x7f0800b7; + public static final int settings_preload_2=0x7f0800b4; + public static final int settings_preload_3=0x7f0800b5; + public static final int settings_preload_5=0x7f0800b6; + public static final int settings_preload_unlimited=0x7f0800b8; + public static final int settings_screen_lit_summary=0x7f0800d1; + public static final int settings_screen_lit_title=0x7f0800d0; + public static final int settings_scrobble_summary=0x7f0800c8; + public static final int settings_scrobble_title=0x7f0800c7; + public static final int settings_search_1=0x7f0800f0; + public static final int settings_search_10=0x7f0800f3; + public static final int settings_search_100=0x7f0800fb; + public static final int settings_search_15=0x7f0800f4; + public static final int settings_search_20=0x7f0800f5; + public static final int settings_search_25=0x7f0800f6; + public static final int settings_search_250=0x7f0800fc; + public static final int settings_search_3=0x7f0800f1; + public static final int settings_search_30=0x7f0800f7; + public static final int settings_search_40=0x7f0800f8; + public static final int settings_search_5=0x7f0800f2; + public static final int settings_search_50=0x7f0800f9; + public static final int settings_search_500=0x7f0800fd; + public static final int settings_search_75=0x7f0800fa; + public static final int settings_search_history_cleared=0x7f0800c3; + public static final int settings_search_title=0x7f0800c5; + public static final int settings_server_add_server=0x7f080088; + public static final int settings_server_address=0x7f08008b; + public static final int settings_server_name=0x7f080087; + public static final int settings_server_number=0x7f080089; + public static final int settings_server_password=0x7f08008d; + public static final int settings_server_remove_server=0x7f08008a; + public static final int settings_server_scaling_summary=0x7f0800ca; + public static final int settings_server_scaling_title=0x7f0800c9; + public static final int settings_server_unused=0x7f080083; + public static final int settings_server_unused1=0x7f080084; + public static final int settings_server_unused2=0x7f080085; + public static final int settings_server_unused3=0x7f080086; + public static final int settings_server_username=0x7f08008c; public static final int settings_servers_title=0x7f080082; - public static final int settings_show_lockscreen_controls=0x7f0800e5; - public static final int settings_show_lockscreen_controls_summary=0x7f0800e6; - public static final int settings_show_notification=0x7f0800e1; - public static final int settings_show_notification_always=0x7f0800e3; - public static final int settings_show_notification_always_summary=0x7f0800e4; - public static final int settings_show_notification_summary=0x7f0800e2; - public static final int settings_show_now_playing=0x7f0800e9; - public static final int settings_show_now_playing_summary=0x7f0800ea; - public static final int settings_show_track_number=0x7f0800ad; - public static final int settings_show_track_number_summary=0x7f0800ae; + public static final int settings_show_lockscreen_controls=0x7f0800e9; + public static final int settings_show_lockscreen_controls_summary=0x7f0800ea; + public static final int settings_show_notification=0x7f0800e5; + public static final int settings_show_notification_always=0x7f0800e7; + public static final int settings_show_notification_always_summary=0x7f0800e8; + public static final int settings_show_notification_summary=0x7f0800e6; + public static final int settings_show_now_playing=0x7f0800ed; + public static final int settings_show_now_playing_summary=0x7f0800ee; + public static final int settings_show_track_number=0x7f0800b1; + public static final int settings_show_track_number_summary=0x7f0800b2; public static final int settings_test_connection_title=0x7f080081; - public static final int settings_testing_connection=0x7f08008f; - public static final int settings_testing_ok=0x7f080090; - public static final int settings_testing_unlicensed=0x7f080091; - public static final int settings_theme_dark=0x7f080098; - public static final int settings_theme_light=0x7f080097; - public static final int settings_theme_title=0x7f080096; + public static final int settings_testing_connection=0x7f080093; + public static final int settings_testing_ok=0x7f080094; + public static final int settings_testing_unlicensed=0x7f080095; + public static final int settings_theme_dark=0x7f08009c; + public static final int settings_theme_light=0x7f08009b; + public static final int settings_theme_title=0x7f08009a; public static final int settings_title=0x7f080080; - public static final int settings_use_folder_for_album_artist=0x7f0800ab; - public static final int settings_use_folder_for_album_artist_summary=0x7f0800ac; - public static final int settings_use_stream_proxy=0x7f0800e7; - public static final int settings_use_stream_proxy_summary=0x7f0800e8; - public static final int settings_wifi_required_summary=0x7f0800a8; - public static final int settings_wifi_required_title=0x7f0800a7; + public static final int settings_use_folder_for_album_artist=0x7f0800af; + public static final int settings_use_folder_for_album_artist_summary=0x7f0800b0; + public static final int settings_use_stream_proxy=0x7f0800eb; + public static final int settings_use_stream_proxy_summary=0x7f0800ec; + public static final int settings_wifi_required_summary=0x7f0800ac; + public static final int settings_wifi_required_title=0x7f0800ab; public static final int song_details_all=0x7f08007c; public static final int song_details_kbps=0x7f08007d; - public static final int util_bytes_format_byte=0x7f08011a; - public static final int util_bytes_format_gigabyte=0x7f080117; - public static final int util_bytes_format_kilobyte=0x7f080119; - public static final int util_bytes_format_megabyte=0x7f080118; - public static final int util_no_time=0x7f08011b; - public static final int util_zero_time=0x7f08011c; - public static final int widget_initial_text=0x7f080114; - public static final int widget_sdcard_busy=0x7f080115; - public static final int widget_sdcard_missing=0x7f080116; + public static final int util_bytes_format_byte=0x7f08011e; + public static final int util_bytes_format_gigabyte=0x7f08011b; + public static final int util_bytes_format_kilobyte=0x7f08011d; + public static final int util_bytes_format_megabyte=0x7f08011c; + public static final int util_no_time=0x7f08011f; + public static final int util_zero_time=0x7f080120; + public static final int widget_initial_text=0x7f080118; + public static final int widget_sdcard_busy=0x7f080119; + public static final int widget_sdcard_missing=0x7f08011a; } public static final class style { public static final int MenuDrawer=0x7f0a0005; diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png index 78518816..68c0dc45 100644 Binary files a/res/drawable-hdpi/ic_launcher.png and b/res/drawable-hdpi/ic_launcher.png differ diff --git a/res/drawable-hdpi/main_header_icon.png b/res/drawable-hdpi/main_header_icon.png index 1f5fbe93..6722bece 100644 Binary files a/res/drawable-hdpi/main_header_icon.png and b/res/drawable-hdpi/main_header_icon.png differ diff --git a/res/drawable-ldpi/ic_launcher.png b/res/drawable-ldpi/ic_launcher.png index b0f6f5d8..e2eb81cc 100644 Binary files a/res/drawable-ldpi/ic_launcher.png and b/res/drawable-ldpi/ic_launcher.png differ diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png index 756f948f..14cbd506 100644 Binary files a/res/drawable-mdpi/ic_launcher.png and b/res/drawable-mdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png index 888b7523..372e4591 100644 Binary files a/res/drawable-xhdpi/ic_launcher.png and b/res/drawable-xhdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/main_header_icon.png b/res/drawable-xhdpi/main_header_icon.png new file mode 100644 index 00000000..35dd21fb Binary files /dev/null and b/res/drawable-xhdpi/main_header_icon.png differ diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png index 683f9038..f4e7eabb 100644 Binary files a/res/drawable-xxhdpi/ic_launcher.png and b/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/res/drawable-xxhdpi/main_header_icon.png b/res/drawable-xxhdpi/main_header_icon.png new file mode 100644 index 00000000..352111ad Binary files /dev/null and b/res/drawable-xxhdpi/main_header_icon.png differ diff --git a/res/values/strings.xml b/res/values/strings.xml index d11d7ec4..82df29d4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -125,10 +125,14 @@ UltraSonic Settings Test Connection Servers + Unused Unused 1 Unused 2 Unused 3 Name + Add Server + Number Of Servers + Remove Server Server Address Username Password diff --git a/res/xml/settings.xml b/res/xml/settings.xml index a291ce83..6e851927 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -2,83 +2,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + a:title="@string/settings.show_now_playing" /> - = Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - getActionBar().setDisplayHomeAsUpEnabled(true); - } + getActionBar().setDisplayHomeAsUpEnabled(true); View aboutMenuItem = findViewById(R.id.menu_about); menuDrawer.setActiveView(aboutMenuItem); diff --git a/src/com/thejoshwa/ultrasonic/androidapp/activity/MainActivity.java b/src/com/thejoshwa/ultrasonic/androidapp/activity/MainActivity.java index 4ba3a39f..dc958f42 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/activity/MainActivity.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/activity/MainActivity.java @@ -45,10 +45,17 @@ import android.widget.TextView; public class MainActivity extends SubsonicTabActivity { private static final int MENU_GROUP_SERVER = 10; + private static final int MENU_ITEM_OFFLINE = 111; private static final int MENU_ITEM_SERVER_1 = 101; private static final int MENU_ITEM_SERVER_2 = 102; private static final int MENU_ITEM_SERVER_3 = 103; - private static final int MENU_ITEM_OFFLINE = 104; + private static final int MENU_ITEM_SERVER_4 = 104; + private static final int MENU_ITEM_SERVER_5 = 105; + private static final int MENU_ITEM_SERVER_6 = 106; + private static final int MENU_ITEM_SERVER_7 = 107; + private static final int MENU_ITEM_SERVER_8 = 108; + private static final int MENU_ITEM_SERVER_9 = 109; + private static final int MENU_ITEM_SERVER_10 = 110; private String theme; @@ -96,6 +103,10 @@ public class MainActivity extends SubsonicTabActivity { final View dummyView = findViewById(R.id.main_dummy); + if (!getActiveServerEnabled()) { + Util.setActiveServer(this, 0); + } + int instance = Util.getActiveServer(this); String name = Util.getServerName(this, instance); serverTextView.setText(name); @@ -104,7 +115,7 @@ public class MainActivity extends SubsonicTabActivity { MergeAdapter adapter = new MergeAdapter(); adapter.addViews(Arrays.asList(serverButton), true); - + if (!Util.isOffline(this)) { adapter.addView(musicTitle, false); adapter.addViews(Arrays.asList(artistsButton, albumsButton, genresButton), true); @@ -197,27 +208,76 @@ public class MainActivity extends SubsonicTabActivity { public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); - MenuItem menuItem1 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_1, MENU_ITEM_SERVER_1, Util.getServerName(this, 1)); - MenuItem menuItem2 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_2, MENU_ITEM_SERVER_2, Util.getServerName(this, 2)); - MenuItem menuItem3 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_3, MENU_ITEM_SERVER_3, Util.getServerName(this, 3)); - MenuItem menuItem4 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_OFFLINE, MENU_ITEM_OFFLINE, Util.getServerName(this, 0)); + int activeServer = Util.getActiveServer(this); + boolean checked = false; + + for (int i = 0; i <= Util.getActiveServers(this); i++) { + String serverName = Util.getServerName(this, i); + + if (Util.getServerEnabled(this, i)) { + int menuItemNum = getMenuItem(i); + + MenuItem menuItem = menu.add(MENU_GROUP_SERVER, menuItemNum, menuItemNum, serverName); + + if (activeServer == i) { + checked = true; + menuItem.setChecked(true); + } + } + } + + if (!checked) { + menu.findItem(getMenuItem(0)).setChecked(true); + } + menu.setGroupCheckable(MENU_GROUP_SERVER, true, true); menu.setHeaderTitle(R.string.main_select_server); + } + + private boolean getActiveServerEnabled() { - switch (Util.getActiveServer(this)) { - case 0: - menuItem4.setChecked(true); - break; - case 1: - menuItem1.setChecked(true); - break; - case 2: - menuItem2.setChecked(true); - break; - case 3: - menuItem3.setChecked(true); - break; - } + int activeServer = Util.getActiveServer(this); + boolean activeServerEnabled = false; + + for (int i = 0; i <= Util.getActiveServers(this); i++) { + if (Util.getServerEnabled(this, i)) { + if (activeServer == i) { + activeServerEnabled = true; + } + } + } + + return activeServerEnabled; + } + + private int getMenuItem(int serverInstance) { + switch (serverInstance) { + case 0: + return MENU_ITEM_OFFLINE; + case 1: + return MENU_ITEM_SERVER_1; + case 2: + return MENU_ITEM_SERVER_2; + case 3: + return MENU_ITEM_SERVER_3; + case 4: + return MENU_ITEM_SERVER_4; + case 5: + return MENU_ITEM_SERVER_5; + case 6: + return MENU_ITEM_SERVER_6; + case 7: + return MENU_ITEM_SERVER_7; + case 8: + return MENU_ITEM_SERVER_8; + case 9: + return MENU_ITEM_SERVER_9; + case 10: + return MENU_ITEM_SERVER_10; + + } + + return 0; } @Override @@ -235,6 +295,27 @@ public class MainActivity extends SubsonicTabActivity { case MENU_ITEM_SERVER_3: setActiveServer(3); break; + case MENU_ITEM_SERVER_4: + setActiveServer(4); + break; + case MENU_ITEM_SERVER_5: + setActiveServer(5); + break; + case MENU_ITEM_SERVER_6: + setActiveServer(6); + break; + case MENU_ITEM_SERVER_7: + setActiveServer(7); + break; + case MENU_ITEM_SERVER_8: + setActiveServer(8); + break; + case MENU_ITEM_SERVER_9: + setActiveServer(9); + break; + case MENU_ITEM_SERVER_10: + setActiveServer(10); + break; default: return super.onContextItemSelected(menuItem); } diff --git a/src/com/thejoshwa/ultrasonic/androidapp/activity/SettingsActivity.java b/src/com/thejoshwa/ultrasonic/androidapp/activity/SettingsActivity.java index 3af193b8..048382d3 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/activity/SettingsActivity.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/activity/SettingsActivity.java @@ -20,15 +20,16 @@ package com.thejoshwa.ultrasonic.androidapp.activity; import android.content.Intent; import android.content.SharedPreferences; -import android.os.Build; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; +import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.provider.SearchRecentSuggestions; +import android.text.InputType; import android.util.Log; import android.view.MenuItem; import android.view.View; @@ -51,7 +52,6 @@ import java.io.File; import java.net.URL; import java.util.LinkedHashMap; import java.util.Map; - import net.simonvt.menudrawer.MenuDrawer; import net.simonvt.menudrawer.Position; @@ -76,6 +76,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private ListPreference defaultArtists; private CheckBoxPreference mediaButtonsEnabled; private CheckBoxPreference lockScreenEnabled; + private int maxServerCount = 10; + private int minServerCount = 0; private static final String STATE_MENUDRAWER = "com.thejoshwa.ultrasonic.androidapp.menuDrawer"; private static final String STATE_ACTIVE_VIEW_ID = "com.thejoshwa.ultrasonic.androidapp.activeViewId"; @@ -84,9 +86,13 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer public MenuDrawer menuDrawer; private int activePosition = 1; private int menuActiveViewId; + private int activeServers = 3; View searchMenuItem = null; View playlistsMenuItem = null; View menuMain = null; + PreferenceCategory serversCategory; + EditTextPreference serverNumPreference; + Preference addServerPreference; @Override public void onCreate(Bundle savedInstanceState) { @@ -114,9 +120,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer findViewById(R.id.menu_about).setOnClickListener(this); findViewById(R.id.menu_exit).setOnClickListener(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - getActionBar().setDisplayHomeAsUpEnabled(true); - } + getActionBar().setDisplayHomeAsUpEnabled(true); View browseMenuItem = findViewById(R.id.menu_settings); menuDrawer.setActiveView(browseMenuItem); @@ -144,31 +148,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer mediaButtonsEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_MEDIA_BUTTONS); lockScreenEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SHOW_LOCK_SCREEN_CONTROLS); - findPreference("testConnection1").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - testConnection(1); - return false; - } - }); - - findPreference("testConnection2").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - testConnection(2); - return false; - } - }); - - findPreference("testConnection3").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - testConnection(3); - return false; - } - }); - - findPreference("clearSearchHistory").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + findPreference(Constants.PREFERENCES_KEY_CLEAR_SEARCH_HISTORY).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { SearchRecentSuggestions suggestions = new SearchRecentSuggestions(SettingsActivity.this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE); @@ -177,12 +157,64 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer return false; } }); + + serverNumPreference = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_NUMBER); + serverNumPreference.setSummary(serverNumPreference.getText()); + activeServers = Integer.parseInt(serverNumPreference.getText()); + + serversCategory = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_SERVERS_KEY); + + addServerPreference = new Preference(this); + addServerPreference.setKey(Constants.PREFERENCES_KEY_ADD_SERVER); + addServerPreference.setPersistent(false); + addServerPreference.setTitle(getResources().getString(R.string.settings_server_add_server)); + addServerPreference.setEnabled(activeServers < maxServerCount); + serversCategory.addPreference(addServerPreference); - for (int i = 1; i <= 3; i++) { + for (int i = 1; i <= activeServers; i++) { + final int instanceValue = i; + + serversCategory.addPreference(addServer(i)); + + findPreference(Constants.PREFERENCES_KEY_TEST_CONNECTION + i).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + + testConnection(instanceValue); + return false; + } + }); + String instance = String.valueOf(i); serverSettings.put(instance, new ServerSettings(instance)); } + + addServerPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + if (activeServers == maxServerCount) { + return false; + } + + activeServers++; + String instance = String.valueOf(activeServers); + serverNumPreference.setText(instance); + serverNumPreference.setSummary(instance); + Preference addServerPreference = findPreference(Constants.PREFERENCES_KEY_ADD_SERVER); + serversCategory.removePreference(addServerPreference); + serversCategory.addPreference(addServer(activeServers)); + serversCategory.addPreference(addServerPreference); + + serverSettings.put(instance, new ServerSettings(instance)); + + addServerPreference.setEnabled(activeServers < maxServerCount); + applyTheme(); + + return true; + } + }); + SharedPreferences prefs = Util.getPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); @@ -191,16 +223,118 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer update(); } + private PreferenceScreen addServer(final int instance) { + final PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(this); + screen.setTitle(R.string.settings_server_unused); + screen.setKey(Constants.PREFERENCES_KEY_SERVER + instance); + + final EditTextPreference serverNamePreference = new EditTextPreference(this); + serverNamePreference.setKey(Constants.PREFERENCES_KEY_SERVER_NAME + instance); + serverNamePreference.setDefaultValue(getResources().getString(R.string.settings_server_unused)); + serverNamePreference.setTitle(R.string.settings_server_name); + + if (serverNamePreference.getText() == null) { + serverNamePreference.setText(getResources().getString(R.string.settings_server_unused)); + } + + serverNamePreference.setSummary(serverNamePreference.getText()); + + final EditTextPreference serverUrlPreference = new EditTextPreference(this); + serverUrlPreference.setKey(Constants.PREFERENCES_KEY_SERVER_URL + instance); + serverUrlPreference.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI); + serverUrlPreference.setDefaultValue("http://yourhost"); + serverUrlPreference.setTitle(R.string.settings_server_address); + + if (serverUrlPreference.getText() == null) { + serverUrlPreference.setText("http://yourhost"); + } + + serverUrlPreference.setSummary(serverUrlPreference.getText()); + + screen.setSummary(serverUrlPreference.getText()); + + final EditTextPreference serverUsernamePreference = new EditTextPreference(this); + serverUsernamePreference.setKey(Constants.PREFERENCES_KEY_USERNAME + instance); + serverUsernamePreference.setTitle(R.string.settings_server_username); + + final EditTextPreference serverPasswordPreference = new EditTextPreference(this); + serverPasswordPreference.setKey(Constants.PREFERENCES_KEY_PASSWORD + instance); + serverPasswordPreference.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + serverPasswordPreference.setSummary("***"); + serverPasswordPreference.setTitle(R.string.settings_server_password); + + final CheckBoxPreference serverEnabledPreference = new CheckBoxPreference(this); + serverEnabledPreference.setDefaultValue(true); + serverEnabledPreference.setKey(Constants.PREFERENCES_KEY_SERVER_ENABLED + instance); + serverEnabledPreference.setTitle(R.string.equalizer_enabled); + + Preference serverRemoveServerPreference = new Preference(this); + serverRemoveServerPreference.setKey(Constants.PREFERENCES_KEY_REMOVE_SERVER + instance); + serverRemoveServerPreference.setPersistent(false); + serverRemoveServerPreference.setTitle(R.string.settings_server_remove_server); + + serverRemoveServerPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + + if (activeServers == minServerCount) { + return false; + } + + // Reset values to null so when we ask for them again they are new + serverNamePreference.setText(null); + serverUrlPreference.setText(null); + serverUsernamePreference.setText(null); + serverPasswordPreference.setText(null); + serverEnabledPreference.setChecked(true); + + activeServers--; + serversCategory.removePreference(screen); + String instance = String.valueOf(activeServers); + serverNumPreference.setText(instance); + serverNumPreference.setSummary(instance); + addServerPreference.setEnabled(activeServers < maxServerCount); + screen.getDialog().dismiss(); + + return true; + } + }); + + Preference serverTestConnectionPreference = new Preference(this); + serverTestConnectionPreference.setKey(Constants.PREFERENCES_KEY_TEST_CONNECTION + instance); + serverTestConnectionPreference.setPersistent(false); + serverTestConnectionPreference.setTitle(R.string.settings_test_connection_title); + serverTestConnectionPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + + testConnection(instance); + return false; + } + }); + + screen.addPreference(serverNamePreference); + screen.addPreference(serverUrlPreference); + screen.addPreference(serverUsernamePreference); + screen.addPreference(serverPasswordPreference); + screen.addPreference(serverEnabledPreference); + screen.addPreference(serverRemoveServerPreference); + screen.addPreference(serverTestConnectionPreference); + + return screen; + } + private void applyTheme() { String theme = Util.getTheme(this); + // Support the old fullscreen themes as well, for upgrade purposes if ("dark".equalsIgnoreCase(theme) || "fullscreen".equalsIgnoreCase(theme)) { setTheme(R.style.UltraSonicTheme); } else if ("light".equalsIgnoreCase(theme) || "fullscreenlight".equalsIgnoreCase(theme)) { setTheme(R.style.UltraSonicTheme_Light); } } - + @Override protected void onDestroy() { super.onDestroy(); @@ -351,6 +485,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private EditTextPreference serverName; private EditTextPreference serverUrl; private EditTextPreference username; + private CheckBoxPreference enabled; private PreferenceScreen screen; private ServerSettings(String instance) { @@ -359,6 +494,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer serverName = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance); serverUrl = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance); username = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_USERNAME + instance); + enabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_ENABLED + instance); serverUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override @@ -391,11 +527,11 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer } public void update() { - serverName.setSummary(serverName.getText()); - serverUrl.setSummary(serverUrl.getText()); - username.setSummary(username.getText()); - screen.setSummary(serverUrl.getText()); - screen.setTitle(serverName.getText()); + serverName.setSummary(serverName.getText()); + serverUrl.setSummary(serverUrl.getText()); + username.setSummary(username.getText()); + screen.setSummary(serverUrl.getText()); + screen.setTitle(serverName.getText()); } } diff --git a/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java b/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java index 7a220336..41befecc 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java @@ -113,9 +113,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{ findViewById(R.id.menu_about).setOnClickListener(this); findViewById(R.id.menu_exit).setOnClickListener(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - getActionBar().setDisplayHomeAsUpEnabled(true); - } + getActionBar().setDisplayHomeAsUpEnabled(true); TextView activeView = (TextView)findViewById(menuActiveViewId); diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java b/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java index acf76c25..acb1ed15 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java @@ -59,9 +59,15 @@ public final class Constants { public static final int NOTIFICATION_ID_ERROR = 101; // Preferences keys. + public static final String PREFERENCES_KEY_SERVER = "server"; + public static final String PREFERENCES_KEY_SERVER_ENABLED = "serverEnabled"; public static final String PREFERENCES_KEY_SERVER_INSTANCE = "serverInstanceId"; public static final String PREFERENCES_KEY_SERVER_NAME = "serverName"; public static final String PREFERENCES_KEY_SERVER_URL = "serverUrl"; + public static final String PREFERENCES_KEY_SERVER_NUMBER = "serverNum"; + public static final String PREFERENCES_KEY_SERVERS_KEY = "serversKey"; + public static final String PREFERENCES_KEY_ADD_SERVER = "addServer"; + public static final String PREFERENCES_KEY_REMOVE_SERVER = "removeServer"; public static final String PREFERENCES_KEY_MUSIC_FOLDER_ID = "musicFolderId"; public static final String PREFERENCES_KEY_USERNAME = "username"; public static final String PREFERENCES_KEY_PASSWORD = "password"; @@ -95,6 +101,8 @@ public final class Constants { public static final String PREFERENCES_KEY_DEFAULT_ARTISTS = "defaultArtists"; public static final String PREFERENCES_KEY_USE_STREAM_PROXY = "useStreamProxy"; public static final String PREFERENCES_KEY_SHOW_NOW_PLAYING = "showNowPlaying"; + public static final String PREFERENCES_KEY_CLEAR_SEARCH_HISTORY = "clearSearchHistory"; + public static final String PREFERENCES_KEY_TEST_CONNECTION = "testConnection"; // Name of the preferences file. public static final String PREFERENCES_FILE_NAME = "com.thejoshwa.ultrasonic.androidapp_preferences"; diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java b/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java index 2b8bfe98..fb7a504f 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java @@ -182,6 +182,12 @@ public class Util extends DownloadActivity { SharedPreferences prefs = getPreferences(context); return prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); } + + public static int getActiveServers(Context context) { + SharedPreferences prefs = getPreferences(context); + String value = prefs.getString(Constants.PREFERENCES_KEY_SERVER_NUMBER, "3"); + return Integer.parseInt(value); + } public static String getServerName(Context context, int instance) { if (instance == 0) { @@ -190,6 +196,14 @@ public class Util extends DownloadActivity { SharedPreferences prefs = getPreferences(context); return prefs.getString(Constants.PREFERENCES_KEY_SERVER_NAME + instance, null); } + + public static boolean getServerEnabled(Context context, int instance) { + if (instance == 0) { + return true; + } + SharedPreferences prefs = getPreferences(context); + return prefs.getBoolean(Constants.PREFERENCES_KEY_SERVER_ENABLED + instance, true); + } public static void setServerRestVersion(Context context, Version version) { SERVER_REST_VERSIONS.put(getActiveServer(context), version);