diff --git a/app/src/main/java/org/xbmc/kore/Settings.java b/app/src/main/java/org/xbmc/kore/Settings.java index 5ca677b..0da3a8c 100644 --- a/app/src/main/java/org/xbmc/kore/Settings.java +++ b/app/src/main/java/org/xbmc/kore/Settings.java @@ -128,6 +128,11 @@ public class Settings { public static final String KEY_PREF_CURRENT_HOST_ID = "current_host_id"; public static final int DEFAULT_PREF_CURRENT_HOST_ID = -1; + public static final String KEY_PREF_REMOTE_BAR_ITEMS = "pref_remote_bar_items"; + public static String getRemoteBarItemsPrefKey(int hostId) { + return Settings.KEY_PREF_REMOTE_BAR_ITEMS + hostId; + } + public static final String KEY_PREF_NAV_DRAWER_ITEMS = "pref_nav_drawer_items"; public static String getNavDrawerItemsPrefKey(int hostId) { return Settings.KEY_PREF_NAV_DRAWER_ITEMS + hostId; diff --git a/app/src/main/java/org/xbmc/kore/jsonrpc/method/GUI.java b/app/src/main/java/org/xbmc/kore/jsonrpc/method/GUI.java index 57f4ae6..6d5bdaf 100644 --- a/app/src/main/java/org/xbmc/kore/jsonrpc/method/GUI.java +++ b/app/src/main/java/org/xbmc/kore/jsonrpc/method/GUI.java @@ -155,6 +155,10 @@ public class GUI { * For use in params, to go directly to TV shows */ public final static String PARAM_TV_SHOWS_TITLES = "TvShowTitles"; + /** + * For use in params, to go to root screen + */ + public final static String PARAM_ROOT = "Root"; /** * Activates a window in XBMC. See class constants to check which windows are allowed. diff --git a/app/src/main/java/org/xbmc/kore/ui/sections/hosts/AddHostFragmentFinish.java b/app/src/main/java/org/xbmc/kore/ui/sections/hosts/AddHostFragmentFinish.java index 63f3eb0..97f81d3 100644 --- a/app/src/main/java/org/xbmc/kore/ui/sections/hosts/AddHostFragmentFinish.java +++ b/app/src/main/java/org/xbmc/kore/ui/sections/hosts/AddHostFragmentFinish.java @@ -139,13 +139,17 @@ public class AddHostFragmentFinish extends Fragment { boolean isEnabled = result.asBoolean(false); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - Set shownItems = new HashSet<>(Arrays.asList( + Set barItems = new HashSet<>(Arrays.asList( + context.getResources() + .getStringArray(R.array.default_values_remote_bar_items))); + Set navItems = new HashSet<>(Arrays.asList( context.getResources() .getStringArray(R.array.entry_values_nav_drawer_items))); if (!isEnabled) - shownItems.remove(String.valueOf(NavigationDrawerFragment.ACTIVITY_PVR)); + navItems.remove(String.valueOf(NavigationDrawerFragment.ACTIVITY_PVR)); sp.edit() - .putStringSet(Settings.getNavDrawerItemsPrefKey(hostId), shownItems) + .putStringSet(Settings.getRemoteBarItemsPrefKey(hostId), barItems) + .putStringSet(Settings.getNavDrawerItemsPrefKey(hostId), navItems) .apply(); } diff --git a/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteFragment.java b/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteFragment.java index 5e58923..eaca364 100644 --- a/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteFragment.java +++ b/app/src/main/java/org/xbmc/kore/ui/sections/remote/RemoteFragment.java @@ -25,6 +25,7 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -39,6 +40,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import org.xbmc.kore.R; +import org.xbmc.kore.Settings; import org.xbmc.kore.eventclient.ButtonCodes; import org.xbmc.kore.eventclient.EventServerConnection; import org.xbmc.kore.eventclient.Packet; @@ -59,9 +61,14 @@ import org.xbmc.kore.utils.RepeatListener; import org.xbmc.kore.utils.UIUtils; import org.xbmc.kore.utils.Utils; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; +import butterknife.Optional; /** * Remote view @@ -107,11 +114,17 @@ public class RemoteFragment extends Fragment /** * Buttons */ - @InjectView(R.id.home) ImageButton homeButton; - @InjectView(R.id.movies) ImageButton moviesButton; - @InjectView(R.id.tv_shows) ImageButton tvShowsButton; - @InjectView(R.id.music) ImageButton musicButton; - @InjectView(R.id.pictures) ImageButton picturesButton; + @Optional @InjectView(R.id.home) ImageButton homeButton; + @Optional @InjectView(R.id.movies) ImageButton moviesButton; + @Optional @InjectView(R.id.tv_shows) ImageButton tvShowsButton; + @Optional @InjectView(R.id.music) ImageButton musicButton; + @Optional @InjectView(R.id.pvr) ImageButton pvrButton; + @Optional @InjectView(R.id.pictures) ImageButton picturesButton; + @Optional @InjectView(R.id.videos) ImageButton videosButton; + //@Optional @InjectView(R.id.favourites) ImageButton favouritesButton; + @Optional @InjectView(R.id.addons) ImageButton addonsButton; + @Optional @InjectView(R.id.weather) ImageButton weatherButton; + @Optional @InjectView(R.id.system) ImageButton systemButton; @InjectView(R.id.select) ImageView selectButton; @InjectView(R.id.left) ImageView leftButton; @@ -227,6 +240,19 @@ public class RemoteFragment extends Fragment skipPreviousIcon = styledAttributes.getResourceId(styledAttributes.getIndex(3), R.drawable.ic_skip_previous_white_24dp); styledAttributes.recycle(); + Set shownItems = PreferenceManager + .getDefaultSharedPreferences(getActivity()) + .getStringSet(Settings.getRemoteBarItemsPrefKey(hostInfo.getId()), + new HashSet<>(Arrays.asList(getResources().getStringArray(R.array.default_values_remote_bar_items)))); + ImageButton[] buttons = { + homeButton, moviesButton, tvShowsButton, musicButton, pvrButton, picturesButton, + videosButton, addonsButton, weatherButton, systemButton + }; + for (int i = 0; i < buttons.length; i++) { + if (buttons[i] != null) + buttons[i].setVisibility(shownItems.contains(String.valueOf(i)) ? View.VISIBLE : View.GONE); + } + // // Pad main content view to account for bottom system bar // UIUtils.setPaddingForSystemBars(getActivity(), root, false, false, true); @@ -274,7 +300,6 @@ public class RemoteFragment extends Fragment } } - @Override public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -404,38 +429,85 @@ public class RemoteFragment extends Fragment private ApiCallback defaultActionCallback = ApiMethod.getDefaultActionCallback(); /** - * Callbacks for boottoom button bar + * Callbacks for bottom button bar */ + @Optional @OnClick(R.id.home) public void onHomeClicked(View v) { GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.HOME); action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); } + @Optional @OnClick(R.id.movies) public void onMoviedClicked(View v) { GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.VIDEOS, GUI.ActivateWindow.PARAM_MOVIE_TITLES); action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); } + @Optional @OnClick(R.id.tv_shows) public void onTvShowsClicked(View v) { GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.VIDEOS, GUI.ActivateWindow.PARAM_TV_SHOWS_TITLES); action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); } + @Optional @OnClick(R.id.music) public void onMusicClicked(View v) { - GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.MUSICLIBRARY); + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.MUSIC, GUI.ActivateWindow.PARAM_ROOT); action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); } + @Optional + @OnClick(R.id.pvr) + public void onRadioClicked(View v) { + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.PVR); + action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); + } + + @Optional @OnClick(R.id.pictures) public void onPicturesClicked(View v) { GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.PICTURES); action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); } + @Optional + @OnClick(R.id.videos) + public void onVideosClicked(View v) { + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.VIDEOS, GUI.ActivateWindow.PARAM_ROOT); + action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); + } + + /*@Optional + @OnClick(R.id.favourites) + public void onFavouritesClicked(View v) { + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.FAVOURITES); + action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); + }*/ + + @Optional + @OnClick(R.id.addons) + public void onAddonsClicked(View v) { + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.ADDONBROWSER); + action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); + } + + @Optional + @OnClick(R.id.weather) + public void onWeatherClicked(View v) { + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.WEATHER); + action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); + } + + @Optional + @OnClick(R.id.system) + public void onSystemClicked(View v) { + GUI.ActivateWindow action = new GUI.ActivateWindow(GUI.ActivateWindow.SETTINGS); + action.execute(hostManager.getConnection(), defaultActionCallback, callbackHandler); + } + /** * Calllbacks for media control buttons */ diff --git a/app/src/main/java/org/xbmc/kore/ui/sections/settings/SettingsFragment.java b/app/src/main/java/org/xbmc/kore/ui/sections/settings/SettingsFragment.java index 1be643c..07c837f 100644 --- a/app/src/main/java/org/xbmc/kore/ui/sections/settings/SettingsFragment.java +++ b/app/src/main/java/org/xbmc/kore/ui/sections/settings/SettingsFragment.java @@ -56,17 +56,19 @@ public class SettingsFragment extends PreferenceFragmentCompat // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); - // Get the preference for side menu itens and change its Id to include + // Get the preference for side menu items and change its Id to include // the current host Preference sideMenuItems = findPreference(Settings.KEY_PREF_NAV_DRAWER_ITEMS); + Preference remoteBarItems = findPreference(Settings.KEY_PREF_REMOTE_BAR_ITEMS); hostId = HostManager.getInstance(getActivity()).getHostInfo().getId(); sideMenuItems.setKey(Settings.getNavDrawerItemsPrefKey(hostId)); + remoteBarItems.setKey(Settings.getRemoteBarItemsPrefKey(hostId)); - // HACK: After changing the key dinamically like above, we need to force the preference + // HACK: After changing the key dynamically like above, we need to force the preference // to read its value. This can be done by calling onSetInitialValue, which is protected, // so, instead of subclassing MultiSelectListPreference and make it public, this little // hack changes its access mode. - // Furthermore, only do this is nothing is saved yet on the shared preferences, + // Furthermore, only do this if nothing is saved yet on the shared preferences, // otherwise the defaults won't be applied if (getPreferenceManager().getSharedPreferences().getStringSet(Settings.getNavDrawerItemsPrefKey(hostId), null) != null) { Class iterClass = sideMenuItems.getClass(); @@ -78,6 +80,16 @@ public class SettingsFragment extends PreferenceFragmentCompat } catch (Exception e) { } } + if (getPreferenceManager().getSharedPreferences().getStringSet(Settings.getRemoteBarItemsPrefKey(hostId), null) != null) { + Class iterClass = remoteBarItems.getClass(); + try { + @SuppressWarnings("unchecked") + Method m = iterClass.getDeclaredMethod("onSetInitialValue", boolean.class, Object.class); + m.setAccessible(true); + m.invoke(remoteBarItems, true, null); + } catch (Exception e) { + } + } // Check permission for phone state and set preference accordingly if (!hasPhonePermission()) { @@ -110,15 +122,16 @@ public class SettingsFragment extends PreferenceFragmentCompat // Update summaries setupPreferences(); - if (key.equals(Settings.KEY_PREF_THEME) || key.equals(Settings.getNavDrawerItemsPrefKey(hostId))) { + if (key.equals(Settings.KEY_PREF_THEME) || key.equals(Settings.getNavDrawerItemsPrefKey(hostId)) + || key.equals((Settings.getRemoteBarItemsPrefKey(hostId)))) { // Explicitly clear cache of resource ids that is maintained in the activity UIUtils.playPauseIconsLoaded = false; // restart to apply new theme (actually build an entirely new task stack) TaskStackBuilder.create(getActivity()) - .addNextIntent(new Intent(getActivity(), RemoteActivity.class)) - .addNextIntent(new Intent(getActivity(), SettingsActivity.class)) - .startActivities(); + .addNextIntent(new Intent(getActivity(), RemoteActivity.class)) + .addNextIntent(new Intent(getActivity(), SettingsActivity.class)) + .startActivities(); } // If the pause during call is selected, make sure we have permission to read phone state diff --git a/app/src/main/res/drawable/ic_cloud_white_24dp.xml b/app/src/main/res/drawable/ic_cloud_white_24dp.xml new file mode 100644 index 0000000..e0baaf3 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_white_24dp.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/ic_star_white_24dp.xml b/app/src/main/res/drawable/ic_star_white_24dp.xml new file mode 100644 index 0000000..eb2dda5 --- /dev/null +++ b/app/src/main/res/drawable/ic_star_white_24dp.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/ic_sunny_white_24dp.xml b/app/src/main/res/drawable/ic_sunny_white_24dp.xml new file mode 100644 index 0000000..40b768f --- /dev/null +++ b/app/src/main/res/drawable/ic_sunny_white_24dp.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/ic_video_white_24dp.xml b/app/src/main/res/drawable/ic_video_white_24dp.xml new file mode 100644 index 0000000..2c00842 --- /dev/null +++ b/app/src/main/res/drawable/ic_video_white_24dp.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/layout/fragment_remote.xml b/app/src/main/res/layout/fragment_remote.xml index 1f20834..59f575a 100644 --- a/app/src/main/res/layout/fragment_remote.xml +++ b/app/src/main/res/layout/fragment_remote.xml @@ -150,6 +150,15 @@ android:src="?attr/iconMusic" android:tint="?attr/defaultButtonColorFilter" android:contentDescription="@string/music"/> + + + + + + לפי אמן לפי אמן ושנה מושתק + מועדפים + קיצורים בפס התחתון + הגדרות + וידאו + מזג אוויר diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index e43abad..ec36c3f 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -41,6 +41,21 @@ + + + @string/home + @string/movies + @string/tv_shows + @string/music + @string/pvr + @string/pictures + @string/videos + + @string/addons + @string/weather + @string/system + + @string/movies @@ -68,6 +83,27 @@ 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 0 + 1 + 2 + 3 + 5 + + 2 diff --git a/app/src/main/res/values/attr.xml b/app/src/main/res/values/attr.xml index ce60b4a..5c8d5b0 100644 --- a/app/src/main/res/values/attr.xml +++ b/app/src/main/res/values/attr.xml @@ -49,7 +49,11 @@ + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 06298bf..697e704 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,8 +35,12 @@ Addons Files Video + Videos File Browser PVR + Favourites + Weather + System No media center configured Add Media Center @@ -339,6 +343,7 @@ Pause during phone call Use device volume keys Vibrate on touch + Bottom bar shortcuts Side menu shortcuts About diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 6c23295..c6091ca 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -99,6 +99,9 @@ @drawable/ic_extension_white_24dp @drawable/ic_folder_white_24dp @drawable/ic_dvr_white_24dp + @drawable/ic_video_white_24dp + @drawable/ic_star_white_24dp + @drawable/ic_sunny_white_24dp @drawable/ic_add_box_white_24dp @drawable/ic_add_box_white_24dp @@ -228,6 +231,9 @@ @drawable/ic_extension_white_24dp @drawable/ic_folder_white_24dp @drawable/ic_dvr_white_24dp + @drawable/ic_video_white_24dp + @drawable/ic_star_white_24dp + @drawable/ic_sunny_white_24dp @drawable/ic_add_box_black_24dp @drawable/ic_add_box_white_24dp diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 3e2a320..75977af 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -37,6 +37,13 @@ android:key="pref_vibrate_remote_buttons" android:title="@string/vibrate_on_remote" android:defaultValue="false"/> + +