diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-04-17 22:31:28 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-04-17 22:31:28 -0700 |
commit | e6641440c4184316a69d4c7ed67080ecb8242f33 (patch) | |
tree | 7bb7da8284fcf5a546e35a74243be3afee708e7c | |
parent | e300762952f92fe74b1ef0787faef9ba86771d10 (diff) | |
download | dsub-e6641440c4184316a69d4c7ed67080ecb8242f33.tar.gz dsub-e6641440c4184316a69d4c7ed67080ecb8242f33.tar.bz2 dsub-e6641440c4184316a69d4c7ed67080ecb8242f33.zip |
Add a bottom bar along main activity that links to download activity
4 files changed, 147 insertions, 12 deletions
diff --git a/subsonic-android/res/layout/main.xml b/subsonic-android/res/layout/main.xml index 823922dc..fe79716c 100644 --- a/subsonic-android/res/layout/main.xml +++ b/subsonic-android/res/layout/main.xml @@ -6,8 +6,76 @@ <android.support.v4.view.ViewPager android:id="@+id/pager" - android:layout_width="match_parent" + android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1" > </android.support.v4.view.ViewPager> + + <View + android:layout_width="fill_parent" + android:layout_height="1px" + android:background="@color/dividerColor"/> + + <LinearLayout + android:id="@+id/bottom_bar" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:background="@drawable/media_button" + android:orientation="horizontal" > + + <ImageView + android:id="@+id/album_art" + android:layout_width="wrap_content" + android:layout_height="fill_parent" + android:layout_gravity="left|center" + android:scaleType="fitXY" + android:src="@drawable/unknown_album"/> + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:orientation="vertical" + android:paddingLeft="8dip"> + + <TextView + android:id="@+id/track_name" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:textColor="?android:textColorPrimary" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textSize="13sp" + android:text="@string/search.artists"/> + + <TextView + android:id="@+id/artist_name" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:textColor="?android:textColorSecondary" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textSize="12sp" + android:text="@string/search.albums"/> + </LinearLayout> + + <ImageButton + style="@style/PlaybackControl.Small" + android:id="@+id/download_previous" + android:src="?attr/media_button_backward" + android:layout_centerVertical="true"/> + + <ImageButton + style="@style/PlaybackControl.Small" + android:id="@+id/download_start" + android:src="?attr/media_button_start" + android:layout_centerVertical="true"/> + + <ImageButton + style="@style/PlaybackControl.Small" + android:id="@+id/download_next" + android:src="?attr/media_button_forward" + android:layout_centerVertical="true"/> + </LinearLayout> </LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/values/styles.xml b/subsonic-android/res/values/styles.xml index 2d53a8d9..4dcce34f 100644 --- a/subsonic-android/res/values/styles.xml +++ b/subsonic-android/res/values/styles.xml @@ -12,6 +12,7 @@ </style> <style name="PlaybackControl.Small" parent="@style/PlaybackControl"> + <item name="android:padding">4dip</item> <item name="android:layout_width">46dip</item> <item name="android:layout_height">46dip</item> </style> diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 57423fb3..0240d5a3 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -4,26 +4,50 @@ import android.app.AlertDialog; import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import android.support.v4.view.ViewPager;
import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.fragments.MainFragment;
import github.daneren2005.dsub.fragments.SelectArtistFragment;
import github.daneren2005.dsub.fragments.SelectPlaylistFragment;
+import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.util.Util;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
public class MainActivity extends SubsonicActivity {
private static final String TAG = MainActivity.class.getSimpleName();
private static boolean infoDialogDisplayed;
+ private ScheduledExecutorService executorService;
+ private View coverArtView;
+ private TextView trackView;
+ private TextView artistView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
+ View bottomBar = findViewById(R.id.bottom_bar);
+ bottomBar.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Intent intent = new Intent();
+ intent.setClass(v.getContext(), DownloadActivity.class);
+ startActivity(intent);
+ }
+ });
+ coverArtView = bottomBar.findViewById(R.id.album_art);
+ trackView = (TextView) bottomBar.findViewById(R.id.track_name);
+ artistView = (TextView) bottomBar.findViewById(R.id.artist_name);
+
viewPager = (ViewPager) findViewById(R.id.pager);
pagerAdapter = new TabPagerAdapter(this, viewPager);
viewPager.setAdapter(pagerAdapter);
@@ -48,9 +72,31 @@ public class MainActivity extends SubsonicActivity { @Override
public void onResume() {
super.onResume();
+
+ final Handler handler = new Handler();
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ update();
+ }
+ });
+ }
+ };
+
+ executorService = Executors.newSingleThreadScheduledExecutor();
+ executorService.scheduleWithFixedDelay(runnable, 0L, 1000L, TimeUnit.MILLISECONDS);
}
@Override
+ public void onPause() {
+ super.onPause();
+ executorService.shutdown();
+ }
+
+ @Override
public void onBackPressed() {
if(pagerAdapter.onBackPressed()) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
@@ -66,7 +112,7 @@ public class MainActivity extends SubsonicActivity { dialog.show();
}
}
-
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
com.actionbarsherlock.view.MenuInflater menuInflater = getSupportMenuInflater();
@@ -74,9 +120,28 @@ public class MainActivity extends SubsonicActivity { return true;
}
@Override
- public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
return pagerAdapter.onOptionsItemSelected(item);
}
+
+ private void update() {
+ if (getDownloadService() == null) {
+ return;
+ }
+
+ DownloadFile current = getDownloadService().getCurrentPlaying();
+ if(current == null) {
+ trackView.setText("Title");
+ artistView.setText("Artist");
+ getImageLoader().loadImage(coverArtView, null, false, false);
+ return;
+ }
+
+ MusicDirectory.Entry song = current.getSong();
+ trackView.setText(song.getTitle());
+ artistView.setText(song.getArtist());
+ getImageLoader().loadImage(coverArtView, song, false, false);
+ }
private void showInfoDialog() {
if (!infoDialogDisplayed) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java index a6161790..3a05b059 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -120,6 +120,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
rootView = inflater.inflate(R.layout.download, container, false);
+ setHasOptionsMenu(true);
setTitle(nowPlaying ? "Now Playing" : "Downloading");
WindowManager w = context.getWindowManager();
@@ -671,6 +672,15 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe updateButtons();
}
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ executorService.shutdown();
+ if (visualizerView != null && visualizerView.isActive()) {
+ visualizerView.setActive(false);
+ }
+ }
private void scheduleHideControls() {
if (hideControlsFuture != null) {
@@ -744,15 +754,6 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe }
}
- @Override
- public void onPause() {
- super.onPause();
- executorService.shutdown();
- if (visualizerView != null && visualizerView.isActive()) {
- visualizerView.setActive(false);
- }
- }
-
/*@Override
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_SAVE_PLAYLIST) {
|