aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-04-28 17:31:59 -0700
committerScott Jackson <daneren2005@gmail.com>2015-04-28 17:31:59 -0700
commita72e12ae06fafe1885aa763ffa04faa84afb9523 (patch)
tree6efc75e383dfa2453e1a2b1633a9826a83075b41
parent366b3d35ae8d3a410678e90f3382e457c7d9445e (diff)
downloaddsub-a72e12ae06fafe1885aa763ffa04faa84afb9523.tar.gz
dsub-a72e12ae06fafe1885aa763ffa04faa84afb9523.tar.bz2
dsub-a72e12ae06fafe1885aa763ffa04faa84afb9523.zip
#259 Bunch of fixes/improvements to swipe up bar
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java28
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java49
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java5
-rw-r--r--app/src/main/res/layout-large-land/abstract_fragment_container.xml4
-rw-r--r--app/src/main/res/layout/abstract_fragment_activity.xml24
-rw-r--r--app/src/main/res/layout/abstract_fragment_container.xml6
-rw-r--r--app/src/main/res/values-large/dimens.xml2
-rw-r--r--app/src/main/res/values/dimens.xml2
-rw-r--r--app/src/main/res/values/strings.xml2
9 files changed, 94 insertions, 28 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
index 17f22586..814598c5 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -128,14 +128,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
- View actionbar = getLayoutInflater().inflate(R.layout.actionbar_spinner, null);
- actionBarSpinner = (Spinner)actionbar.findViewById(R.id.spinner);
- spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
- spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- actionBarSpinner.setOnItemSelectedListener(this);
- actionBarSpinner.setAdapter(spinnerAdapter);
-
- getSupportActionBar().setCustomView(actionbar);
+ if(spinnerAdapter == null) {
+ createCustomActionBarView();
+ }
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
@@ -151,6 +146,17 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
}
+ protected void createCustomActionBarView() {
+ View customActionbar = getLayoutInflater().inflate(R.layout.actionbar_spinner, null);
+ actionBarSpinner = (Spinner)customActionbar.findViewById(R.id.spinner);
+ spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
+ spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ actionBarSpinner.setOnItemSelectedListener(this);
+ actionBarSpinner.setAdapter(spinnerAdapter);
+
+ getSupportActionBar().setCustomView(customActionbar);
+ }
+
@Override
protected void onResume() {
super.onResume();
@@ -520,7 +526,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
}
- private void drawerItemSelected(int position, View view) {
+ protected void drawerItemSelected(int position, View view) {
startFragmentActivity(drawerItemsDescriptions[position]);
if(lastSelectedView != view) {
@@ -711,6 +717,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(currentFragment == null || currentFragment.getTitle() == null) {
return;
}
+ if(spinnerAdapter == null) {
+ createCustomActionBarView();
+ }
if(backStack.size() > 0) {
spinnerAdapter.clear();
@@ -733,6 +742,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
getSupportActionBar().setDisplayShowCustomEnabled(true);
}
} else if(!isTv()) {
+ getSupportActionBar().setTitle(currentFragment.getTitle());
getSupportActionBar().setDisplayShowCustomEnabled(false);
}
}
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index b534adc5..83d5bce8 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -36,6 +36,7 @@ import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.TextView;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
@@ -93,7 +94,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
private ScheduledExecutorService executorService;
private View bottomBar;
- private View coverArtView;
+ private ImageView coverArtView;
private TextView trackView;
private TextView artistView;
private ImageButton startButton;
@@ -172,18 +173,31 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
nowPlayingToolbar.setVisibility(View.GONE);
nowPlayingFragment.setPrimaryFragment(false);
setSupportActionBar(mainToolbar);
+
+ if(getSupportActionBar().getCustomView() == null) {
+ createCustomActionBarView();
+ }
+ recreateSpinner();
+ if(drawerToggle != null && backStack.size() > 0) {
+ drawerToggle.setDrawerIndicatorEnabled(false);
+ } else {
+ drawerToggle.setDrawerIndicatorEnabled(true);
+ }
}
@Override
public void onPanelExpanded(View panel) {
+ // Disable custom view before switching
+ getSupportActionBar().setDisplayShowCustomEnabled(false);
+
bottomBar.setVisibility(View.GONE);
nowPlayingToolbar.setVisibility(View.VISIBLE);
setSupportActionBar(nowPlayingToolbar);
nowPlayingFragment.setPrimaryFragment(true);
+ drawerToggle.setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setHomeButtonEnabled(true);
- drawerToggle.setDrawerIndicatorEnabled(true);
+ getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
}
@Override
@@ -210,7 +224,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
bottomBar = findViewById(R.id.bottom_bar);
mainToolbar = (Toolbar) findViewById(R.id.main_toolbar);
nowPlayingToolbar = (Toolbar) findViewById(R.id.now_playing_toolbar);
- coverArtView = bottomBar.findViewById(R.id.album_art);
+ coverArtView = (ImageView) bottomBar.findViewById(R.id.album_art);
trackView = (TextView) bottomBar.findViewById(R.id.track_name);
artistView = (TextView) bottomBar.findViewById(R.id.artist_name);
@@ -455,6 +469,15 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
}
@Override
+ protected void drawerItemSelected(int position, View view) {
+ super.drawerItemSelected(position, view);
+
+ if(slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
+ slideUpPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ }
+ }
+
+ @Override
public void startFragmentActivity(String fragmentType) {
// Create a transaction that does all of this
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
@@ -539,11 +562,23 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
trackView.setText(song.getTitle());
artistView.setText(song.getArtist());
} else {
- trackView.setText("Title");
- artistView.setText("Artist");
+ trackView.setText(R.string.main_title);
+ artistView.setText(R.string.main_artist);
}
- getImageLoader().loadImage(coverArtView, song, false, false);
+ SilentBackgroundTask task = getImageLoader().loadImage(coverArtView, song, false, coverArtView.getHeight(), false);
+ if(slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
+ if(task == null) {
+ getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
+ } else {
+ task.setOnCompletionListener(new Runnable() {
+ @Override
+ public void run() {
+ getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable());
+ }
+ });
+ }
+ }
int[] attrs = new int[] {(state == PlayerState.STARTED) ? R.attr.media_button_pause : R.attr.media_button_start};
TypedArray typedArray = this.obtainStyledAttributes(attrs);
startButton.setImageResource(typedArray.getResourceId(0, 0));
diff --git a/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java b/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java
index 1a0e8242..65ef46fe 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java
@@ -192,8 +192,11 @@ public class ImageLoader {
}
public SilentBackgroundTask loadImage(View view, MusicDirectory.Entry entry, boolean large, boolean crossfade) {
- // TODO: If we know this a artist, try to load artist info instead
int size = large ? imageSizeLarge : imageSizeDefault;
+ return loadImage(view, entry, large, size, crossfade);
+ }
+ public SilentBackgroundTask loadImage(View view, MusicDirectory.Entry entry, boolean large, int size, boolean crossfade) {
+ // TODO: If we know this a artist, try to load artist info instead
if(entry != null && !entry.isAlbum() && ServerInfo.checkServerVersion(context, "1.11") && !Util.isOffline(context)) {
SilentBackgroundTask task = new ArtistImageTask(view.getContext(), entry, size, imageSizeLarge, large, view, crossfade);
task.execute();
diff --git a/app/src/main/res/layout-large-land/abstract_fragment_container.xml b/app/src/main/res/layout-large-land/abstract_fragment_container.xml
index 5e3b1561..3901710f 100644
--- a/app/src/main/res/layout-large-land/abstract_fragment_container.xml
+++ b/app/src/main/res/layout-large-land/abstract_fragment_container.xml
@@ -2,8 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1">
+ android:layout_height="match_parent"
+ android:layout_marginTop="?attr/actionBarSize">
<FrameLayout
android:id="@+id/fragment_container"
diff --git a/app/src/main/res/layout/abstract_fragment_activity.xml b/app/src/main/res/layout/abstract_fragment_activity.xml
index 3aa6374f..29fbc3b1 100644
--- a/app/src/main/res/layout/abstract_fragment_activity.xml
+++ b/app/src/main/res/layout/abstract_fragment_activity.xml
@@ -19,11 +19,7 @@
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"/>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fragment_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginTop="?attr/actionBarSize"/>
+ <include layout="@layout/abstract_fragment_container"/>
</FrameLayout>
<LinearLayout
@@ -72,8 +68,18 @@
android:textColor="?android:textColorPrimary"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:textSize="13sp"
- android:text="@string/search.artists"/>
+ android:textSize="@dimen/BottomBar.Text.Major"
+ android:text="@string/main.title"
+ android:ellipsize="marquee"
+ android:marqueeRepeatLimit="marquee_forever"
+ android:scrollHorizontally="true"
+ android:focusable="true"
+ android:focusableInTouchMode="true">
+
+ <requestFocus android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:duplicateParentState="true" />
+ </TextView>
<TextView
android:id="@+id/artist_name"
@@ -82,8 +88,8 @@
android:textColor="?android:textColorSecondary"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:textSize="12sp"
- android:text="@string/search.albums"/>
+ android:textSize="@dimen/BottomBar.Text.Minor"
+ android:text="@string/main.artist"/>
</LinearLayout>
diff --git a/app/src/main/res/layout/abstract_fragment_container.xml b/app/src/main/res/layout/abstract_fragment_container.xml
new file mode 100644
index 00000000..f13356c4
--- /dev/null
+++ b/app/src/main/res/layout/abstract_fragment_container.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/fragment_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="?attr/actionBarSize"/> \ No newline at end of file
diff --git a/app/src/main/res/values-large/dimens.xml b/app/src/main/res/values-large/dimens.xml
index b08dda86..fe8f1a6c 100644
--- a/app/src/main/res/values-large/dimens.xml
+++ b/app/src/main/res/values-large/dimens.xml
@@ -4,4 +4,6 @@
<dimen name="Button.Small">54dip</dimen>
<dimen name="AlbumArt.Small">96dip</dimen>
<dimen name="AlbumArt.Header">210dip</dimen>
+ <dimen name="BottomBar.Text.Major">18sp</dimen>
+ <dimen name="BottomBar.Text.Minor">16sp</dimen>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index be3e843d..9759e1c2 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -4,4 +4,6 @@
<dimen name="Button.Small">46dip</dimen>
<dimen name="AlbumArt.Small">78dip</dimen>
<dimen name="AlbumArt.Header">120dip</dimen>
+ <dimen name="BottomBar.Text.Major">13sp</dimen>
+ <dimen name="BottomBar.Text.Minor">12sp</dimen>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b897cad6..8e7ae537 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -79,6 +79,8 @@
<string name="main.songs_genres">@string/main.albums_genres</string>
<string name="main.back_confirm">Press back again to exit</string>
<string name="main.scan_complete">Completed scan of Server</string>
+ <string name="main.artist">Artist</string>
+ <string name="main.title">Title</string>
<string name="menu.search">Search</string>
<string name="menu.shuffle">Shuffle</string>