From 366b3d35ae8d3a410678e90f3382e457c7d9445e Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 27 Apr 2015 18:09:40 -0700 Subject: Merge work for #259 after project structure change --- app/app.iml | 2 + app/build.gradle | 1 + .../dsub/activity/DownloadActivity.java | 62 ----- .../dsub/activity/SubsonicActivity.java | 81 ++++--- .../dsub/activity/SubsonicFragmentActivity.java | 137 ++++++++--- .../dsub/fragments/NowPlayingFragment.java | 181 ++++++++------- .../dsub/fragments/SelectBookmarkFragment.java | 3 +- .../dsub/fragments/SelectDirectoryFragment.java | 5 +- .../dsub/fragments/SubsonicFragment.java | 254 +++++++++++---------- .../dsub/provider/DSubWidgetProvider.java | 5 +- .../java/github/daneren2005/dsub/util/Util.java | 27 ++- .../main/res/layout/abstract_fragment_activity.xml | 193 ++++++++++------ .../res/layout/abstract_fragment_container.xml | 6 - app/src/main/res/values/styles.xml | 6 + app/src/main/res/values/themes.xml | 17 ++ 15 files changed, 545 insertions(+), 435 deletions(-) delete mode 100644 app/src/main/java/github/daneren2005/dsub/activity/DownloadActivity.java delete mode 100644 app/src/main/res/layout/abstract_fragment_container.xml diff --git a/app/app.iml b/app/app.iml index e50d2481..12ca762d 100644 --- a/app/app.iml +++ b/app/app.iml @@ -87,6 +87,7 @@ + @@ -101,6 +102,7 @@ + diff --git a/app/build.gradle b/app/build.gradle index cb3119bd..76381247 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,4 +29,5 @@ dependencies { compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:mediarouter-v7:22.1.1' compile 'com.google.android.gms:play-services-cast:7.0.0' + compile 'com.sothree.slidinguppanel:library:3.0.0' } diff --git a/app/src/main/java/github/daneren2005/dsub/activity/DownloadActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/DownloadActivity.java deleted file mode 100644 index e13a8b8c..00000000 --- a/app/src/main/java/github/daneren2005/dsub/activity/DownloadActivity.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Subsonic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Subsonic. If not, see . - - Copyright 2009 (C) Sindre Mehus - */ -package github.daneren2005.dsub.activity; - -import github.daneren2005.dsub.R; -import android.os.Bundle; -import android.view.MotionEvent; -import github.daneren2005.dsub.fragments.NowPlayingFragment; - -import android.widget.EditText; - -import github.daneren2005.dsub.util.Constants; - -public class DownloadActivity extends SubsonicActivity { - private static final String TAG = DownloadActivity.class.getSimpleName(); - private EditText playlistNameView; - - /** - * Called when the activity is first created. - */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.download_activity); - - if (findViewById(R.id.fragment_container) != null && savedInstanceState == null) { - currentFragment = new NowPlayingFragment(); - if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) { - Bundle args = new Bundle(); - args.putBoolean(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW, true); - currentFragment.setArguments(args); - } - currentFragment.setPrimaryFragment(true); - getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "").commit(); - } - } - - @Override - public boolean onTouchEvent(MotionEvent me) { - if(currentFragment != null && currentFragment.getGestureDetector() != null) { - return currentFragment.getGestureDetector().onTouchEvent(me); - } else { - return false; - } - } -} 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 4651eb0b..17f22586 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -118,7 +118,16 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte super.onCreate(bundle); startService(new Intent(this, DownloadService.class)); setVolumeControlStream(AudioManager.STREAM_MUSIC); - + + if(getIntent().hasExtra(Constants.FRAGMENT_POSITION)) { + lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0); + } + } + + @Override + 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); @@ -130,14 +139,6 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); - if(getIntent().hasExtra(Constants.FRAGMENT_POSITION)) { - lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0); - } - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. if(drawerToggle != null) { drawerToggle.syncState(); @@ -160,7 +161,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte restart(); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } - + populateDrawer(); UpdateView.addActiveActivity(); } @@ -210,7 +211,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte LayoutInflater layoutInflater = getLayoutInflater(); layoutInflater.inflate(viewId, rootView); } - + drawerList = (ListView) findViewById(R.id.left_drawer); drawerList.setOnItemClickListener(new ListView.OnItemClickListener() { @Override @@ -299,7 +300,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte primaryContainer = findViewById(R.id.fragment_container); } } - + @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); @@ -370,10 +371,11 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte public void onNewIntent(Intent intent) { super.onNewIntent(intent); } - + @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); + SubsonicFragment currentFragment = getCurrentFragment(); if(drawerOpen) { menuInflater.inflate(R.menu.drawer_menu, menu); } else if(currentFragment != null) { @@ -399,7 +401,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte return true; } - return currentFragment.onOptionsItemSelected(item); + return getCurrentFragment().onOptionsItemSelected(item); } @Override @@ -415,7 +417,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte } return super.onKeyDown(keyCode, event); } - + @Override public void setTitle(CharSequence title) { if(title != null && !title.equals(getSupportActionBar().getTitle())) { @@ -426,7 +428,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte public void setSubtitle(CharSequence title) { getSupportActionBar().setSubtitle(title); } - + @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { int top = spinnerAdapter.getCount() - 1; @@ -439,9 +441,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte @Override public void onNothingSelected(AdapterView parent) { - + } - + private void populateDrawer() { SharedPreferences prefs = Util.getPreferences(this); boolean podcastsEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_PODCASTS_ENABLED, true); @@ -449,7 +451,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte boolean sharedEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_SHARED_ENABLED, true) && !Util.isOffline(this); boolean chatEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true) && !Util.isOffline(this); boolean adminEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_ADMIN_ENABLED, true) && !Util.isOffline(this); - + if(drawerItems == null || !enabledItems[0] == podcastsEnabled || !enabledItems[1] == bookmarksEnabled || !enabledItems[2] == sharedEnabled || !enabledItems[3] == chatEnabled || !enabledItems[4] == adminEnabled) { drawerItems = getResources().getStringArray(R.array.drawerItems); drawerItemsDescriptions = getResources().getStringArray(R.array.drawerItemsDescriptions); @@ -488,7 +490,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(!getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) { drawerItemsVisibleList.set(8, false); } - + drawerList.setAdapter(drawerAdapter = new DrawerAdapter(this, drawerItemsList, drawerItemsIconsList, drawerItemsVisibleList)); enabledItems[0] = podcastsEnabled; enabledItems[1] = bookmarksEnabled; @@ -517,15 +519,15 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte } } } - + private void drawerItemSelected(int position, View view) { startFragmentActivity(drawerItemsDescriptions[position]); - + if(lastSelectedView != view) { if(lastSelectedView != null) { lastSelectedView.setTextAppearance(this, R.style.DSub_TextViewStyle); } - + lastSelectedView = (TextView) view.findViewById(R.id.drawer_name); lastSelectedView.setTextAppearance(this, R.style.DSub_TextViewStyle_Bold); lastSelectedPosition = position; @@ -575,6 +577,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte } } + protected SubsonicFragment getCurrentFragment() { + return this.currentFragment; + } + public void replaceFragment(SubsonicFragment fragment, int tag) { replaceFragment(fragment, tag, false); } @@ -628,11 +634,11 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte backStack.remove(backStack.size() - 1); } } - + // Add fragment to the right container trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right); trans.add(R.id.fragment_second_container, fragment, tag + ""); - + // Commit it all trans.commit(); } @@ -656,7 +662,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte trans.commit(); } else { FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); - + // Remove old right fragment trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left); trans.remove(oldFrag); @@ -682,7 +688,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte secondaryContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.exit_to_right)); secondaryContainer.setVisibility(View.GONE); } - + trans.commit(); } recreateSpinner(); @@ -697,10 +703,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte currentFragment.invalidate(); populateDrawer(); } - + supportInvalidateOptionsMenu(); } - + protected void recreateSpinner() { if(currentFragment == null || currentFragment.getTitle() == null) { return; @@ -745,7 +751,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte theme = theme.substring(0, theme.indexOf("_fullscreen")); Util.setTheme(this, theme); } - + Util.applyTheme(this, theme); } private void applyFullscreen() { @@ -754,8 +760,8 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte // Hide additional elements on higher Android versions if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + View.SYSTEM_UI_FLAG_FULLSCREEN | + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; getWindow().getDecorView().setSystemUiVisibility(flags); } else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { @@ -786,7 +792,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(finished) { return null; } - + // If service is not available, request it to start and wait for it. for (int i = 0; i < 5; i++) { DownloadService downloadService = DownloadService.getInstance(); @@ -799,7 +805,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte } return DownloadService.getInstance(); } - + public static String getThemeName() { return theme; } @@ -811,6 +817,13 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte return touchscreen; } + public void openNowPlaying() { + + } + public void closeNowPlaying() { + + } + private void setUncaughtExceptionHandler() { Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler(); if (!(handler instanceof SubsonicActivity.SubsonicUncaughtExceptionHandler)) { 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 6614e09d..b534adc5 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -31,14 +31,16 @@ import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; import android.support.v4.app.FragmentTransaction; +import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; +import com.sothree.slidinguppanel.SlidingUpPanelLayout; + import java.io.File; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -53,6 +55,7 @@ import github.daneren2005.dsub.fragments.AdminFragment; import github.daneren2005.dsub.fragments.ChatFragment; import github.daneren2005.dsub.fragments.DownloadFragment; import github.daneren2005.dsub.fragments.MainFragment; +import github.daneren2005.dsub.fragments.NowPlayingFragment; import github.daneren2005.dsub.fragments.SearchFragment; import github.daneren2005.dsub.fragments.SelectArtistFragment; import github.daneren2005.dsub.fragments.SelectBookmarkFragment; @@ -66,7 +69,6 @@ import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.updates.Updater; -import github.daneren2005.dsub.util.BackgroundTask; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.SilentBackgroundTask; @@ -83,6 +85,12 @@ public class SubsonicFragmentActivity extends SubsonicActivity { private static boolean sessionInitialized = false; private static long ALLOWED_SKEW = 30000L; + private Handler handler = new Handler(); + private SlidingUpPanelLayout slideUpPanel; + private NowPlayingFragment nowPlayingFragment; + private Toolbar mainToolbar; + private Toolbar nowPlayingToolbar; + private ScheduledExecutorService executorService; private View bottomBar; private View coverArtView; @@ -105,14 +113,6 @@ public class SubsonicFragmentActivity extends SubsonicActivity { if(drawerAdapter != null) { drawerAdapter.setDownloadVisible(true); } - } else if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD)) { - DownloadService service = getDownloadService(); - if((service != null && service.getCurrentPlaying() != null)) { - getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD); - Intent intent = new Intent(); - intent.setClass(this, DownloadActivity.class); - startActivity(intent); - } } setContentView(R.layout.abstract_fragment_activity); @@ -128,49 +128,99 @@ public class SubsonicFragmentActivity extends SubsonicActivity { } } currentFragment = getNewFragment(fragmentType); - + if("".equals(fragmentType) || fragmentType == null || firstRun) { // Initial startup stuff if(!sessionInitialized) { loadSession(); } } - + currentFragment.setPrimaryFragment(true); getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "").commit(); - + if(getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) { SearchFragment fragment = new SearchFragment(); replaceFragment(fragment, fragment.getSupportTag()); } - + // If a album type is set, switch to that album type view String albumType = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE); if(albumType != null) { SubsonicFragment fragment = new SelectDirectoryFragment(); - + Bundle args = new Bundle(); args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, albumType); args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 20); args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0); - + fragment.setArguments(args); replaceFragment(fragment, fragment.getSupportTag()); } } - 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); + slideUpPanel = (SlidingUpPanelLayout) findViewById(R.id.slide_up_panel); + slideUpPanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { + @Override + public void onPanelSlide(View panel, float slideOffset) { + + } + + @Override + public void onPanelCollapsed(View panel) { + bottomBar.setVisibility(View.VISIBLE); + nowPlayingToolbar.setVisibility(View.GONE); + nowPlayingFragment.setPrimaryFragment(false); + setSupportActionBar(mainToolbar); + } + + @Override + public void onPanelExpanded(View panel) { + bottomBar.setVisibility(View.GONE); + nowPlayingToolbar.setVisibility(View.VISIBLE); + setSupportActionBar(nowPlayingToolbar); + nowPlayingFragment.setPrimaryFragment(true); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + drawerToggle.setDrawerIndicatorEnabled(true); + } + + @Override + public void onPanelAnchored(View panel) { + + } + + @Override + public void onPanelHidden(View panel) { + } }); + + if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD)) { + // Post this later so it actually runs + handler.postDelayed(new Runnable() { + @Override + public void run() { + openNowPlaying(); + } + }, 200); + } + + 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); trackView = (TextView) bottomBar.findViewById(R.id.track_name); artistView = (TextView) bottomBar.findViewById(R.id.artist_name); + setSupportActionBar(mainToolbar); + + nowPlayingFragment = new NowPlayingFragment(); + FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); + trans.add(R.id.now_playing_fragment_container, nowPlayingFragment, nowPlayingFragment.getTag() + ""); + trans.commit(); + ImageButton previousButton = (ImageButton) findViewById(R.id.download_previous); previousButton.setOnClickListener(new View.OnClickListener() { @Override @@ -262,7 +312,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { } } } - + @Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); @@ -300,7 +350,6 @@ public class SubsonicFragmentActivity extends SubsonicActivity { public void onResume() { super.onResume(); - final Handler handler = new Handler(); Runnable runnable = new Runnable() { @Override public void run() { @@ -369,7 +418,9 @@ public class SubsonicFragmentActivity extends SubsonicActivity { @Override public void onBackPressed() { - if(onBackPressedSupport()) { + if(slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) { + slideUpPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); + } else if(onBackPressedSupport()) { if(!Util.disableExitPrompt(this) && lastBackPressTime < (System.currentTimeMillis() - 4000)) { lastBackPressTime = System.currentTimeMillis(); Util.toast(this, R.string.main_back_confirm); @@ -379,6 +430,15 @@ public class SubsonicFragmentActivity extends SubsonicActivity { } } + @Override + protected SubsonicFragment getCurrentFragment() { + if(slideUpPanel.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) { + return nowPlayingFragment; + } else { + return super.getCurrentFragment(); + } + } + @Override public void replaceFragment(SubsonicFragment fragment, int tag, boolean replaceCurrent) { super.replaceFragment(fragment, tag, replaceCurrent); @@ -393,24 +453,24 @@ public class SubsonicFragmentActivity extends SubsonicActivity { drawerToggle.setDrawerIndicatorEnabled(true); } } - + @Override public void startFragmentActivity(String fragmentType) { // Create a transaction that does all of this FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); - + // Clear existing stack for(int i = backStack.size() - 1; i >= 0; i--) { trans.remove(backStack.get(i)); } trans.remove(currentFragment); backStack.clear(); - + // Create new stack currentFragment = getNewFragment(fragmentType); currentFragment.setPrimaryFragment(true); trans.add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + ""); - + // Done, cleanup trans.commit(); supportInvalidateOptionsMenu(); @@ -426,7 +486,16 @@ public class SubsonicFragmentActivity extends SubsonicActivity { drawerToggle.setDrawerIndicatorEnabled(true); } } - + + @Override + public void openNowPlaying() { + slideUpPanel.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); + } + @Override + public void closeNowPlaying() { + slideUpPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); + } + private SubsonicFragment getNewFragment(String fragmentType) { if("Artist".equals(fragmentType)) { return new SelectArtistFragment(); @@ -447,7 +516,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { } else { return new MainFragment(); } - } + } private void update() { DownloadService downloadService = getDownloadService(); @@ -502,7 +571,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { if(ServerInfo.canSavePlayQueue(this) && !Util.isOffline(this)) { loadRemotePlayQueue(); } - + sessionInitialized = true; } private void loadSettings() { @@ -551,7 +620,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { return true; } } - + private void loadBookmarks() { final Context context = this; new SilentBackgroundTask(context) { @@ -562,7 +631,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { return null; } - + @Override public void error(Throwable error) { Log.e(TAG, "Failed to get bookmarks", error); diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java index fa7e3404..953b429a 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -20,6 +20,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import android.annotation.TargetApi; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; @@ -141,6 +142,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis startFlipped = true; } } + primaryFragment = false; } @Override @@ -153,11 +155,8 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { rootView = inflater.inflate(R.layout.download, container, false); setTitle(R.string.button_bar_now_playing); - + mainLayout = rootView.findViewById(R.id.download_layout); - if(!primaryFragment) { - mainLayout.setVisibility(View.GONE); - } WindowManager w = context.getWindowManager(); Display d = w.getDefaultDisplay(); @@ -397,7 +396,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } else { // Immediately skip to the next song downloadService.next(true); - + // Otherwise set rating to 1 setRating(entry, 1); rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_selected); @@ -470,35 +469,35 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onStopTrackingTouch(final SeekBar seekBar) { - new SilentBackgroundTask(context) { - @Override - protected Void doInBackground() throws Throwable { - getDownloadService().seekTo(progressBar.getProgress()); - return null; - } - - @Override - protected void done(Void result) { - seekInProgress = false; - NowPlayingFragment.this.onProgressChanged(); - } - }.execute(); - } - - @Override - public void onStartTrackingTouch(final SeekBar seekBar) { + @Override + public void onStopTrackingTouch(final SeekBar seekBar) { + new SilentBackgroundTask(context) { + @Override + protected Void doInBackground() throws Throwable { + getDownloadService().seekTo(progressBar.getProgress()); + return null; + } + + @Override + protected void done(Void result) { + seekInProgress = false; + NowPlayingFragment.this.onProgressChanged(); + } + }.execute(); + } + + @Override + public void onStartTrackingTouch(final SeekBar seekBar) { seekInProgress = true; - } + } - @Override - public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { + @Override + public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { if (fromUser) { Util.toast(context, Util.formatDuration(position / 1000), true); setControlsVisible(true); } - } + } }); playlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @@ -543,13 +542,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis registerForContextMenu(playlistView); - DownloadService downloadService = getDownloadService(); - if (downloadService != null && context.getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) { - context.getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE); - warnIfStorageUnavailable(); - downloadService.setShufflePlayEnabled(true); - } - if(Build.MODEL.equals("Nexus 4") || Build.MODEL.equals("GT-I9100")) { View slider = rootView.findViewById(R.id.download_slider); slider.setPadding(0, 0, 0, 0); @@ -603,7 +595,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if(menuItemSelected(menuItem.getItemId(), null)) { return true; } - + return super.onOptionsItemSelected(menuItem); } @@ -640,7 +632,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if(!primaryFragment) { return false; } - + AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); DownloadFile downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position); return menuItemSelected(menuItem.getItemId(), downloadFile) || super.onContextItemSelected(menuItem); @@ -840,7 +832,9 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis @Override public void onResume() { super.onResume(); - + onResumeHandlers(); + } + private void onResumeHandlers() { final Handler handler = new Handler(); Runnable runnable = new Runnable() { @Override @@ -897,25 +891,43 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis @Override public void onPause() { super.onPause(); + onPauseHandlers(); + } + private void onPauseHandlers() { executorService.shutdown(); if(getDownloadService() != null) { getDownloadService().stopRemoteScan(); } + playlistFlipper.setDisplayedChild(0); } - + @Override public void setPrimaryFragment(boolean primary) { super.setPrimaryFragment(primary); if(rootView != null) { if(primary) { - mainLayout.setVisibility(View.VISIBLE); - updateButtons(); + onResumeHandlers(); } else { - mainLayout.setVisibility(View.GONE); + onPauseHandlers(); } } } + @Override + public void setTitle(int title) { + this.title = context.getResources().getString(title); + if(this.primaryFragment) { + context.setTitle(this.title); + } + } + @Override + public void setSubtitle(CharSequence title) { + this.subtitle = title; + if(this.primaryFragment) { + context.setSubtitle(title); + } + } + private void scheduleHideControls() { if (hideControlsFuture != null) { hideControlsFuture.cancel(false); @@ -953,7 +965,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if(context == null) { return; } - + if(Util.isOffline(context)) { bookmarkButton.setVisibility(View.GONE); rateBadButton.setVisibility(View.GONE); @@ -970,6 +982,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } // Scroll to current playing/downloading. + @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void scrollToCurrent() { if (getDownloadService() == null || songListAdapter == null) { scrollWhenLoaded = true; @@ -1042,26 +1055,26 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis public void onStopTrackingTouch(SeekBar seekBar) { } }); - lengthBar.setProgress(length - 1); + lengthBar.setProgress(length - 1); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.menu_set_timer) - .setView(dialogView) - .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - int length = getMinutes(lengthBar.getProgress()); + .setView(dialogView) + .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + int length = getMinutes(lengthBar.getProgress()); - SharedPreferences.Editor editor = prefs.edit(); - editor.putString(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION, Integer.toString(length)); - editor.commit(); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION, Integer.toString(length)); + editor.commit(); - getDownloadService().setSleepTimerDuration(length); - getDownloadService().startSleepTimer(); - context.supportInvalidateOptionsMenu(); - } - }) - .setNegativeButton(R.string.common_cancel, null); + getDownloadService().setSleepTimerDuration(length); + getDownloadService().startSleepTimer(); + context.supportInvalidateOptionsMenu(); + } + }) + .setNegativeButton(R.string.common_cancel, null); AlertDialog dialog = builder.create(); dialog.show(); } @@ -1086,7 +1099,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis playlistFlipper.setInAnimation(AnimationUtils.loadAnimation(context, R.anim.push_up_in)); playlistFlipper.setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.push_up_out)); playlistFlipper.setDisplayedChild(1); - + UpdateView.triggerUpdate(); } } @@ -1124,7 +1137,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis protected Void doInBackground() throws Throwable { currentPlayingIndex = downloadService.getCurrentPlayingIndex() + 1; size = downloadService.size(); - + return null; } @@ -1132,14 +1145,14 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis protected void done(Void result) { List list; list = downloadService.getSongs(); - + if(downloadService.isShufflePlayEnabled()) { emptyTextView.setText(R.string.download_shuffle_loading); } else { emptyTextView.setText(R.string.download_empty); } - + if(songListAdapter == null || refresh) { songList = new ArrayList(); songList.addAll(list); @@ -1149,7 +1162,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis songList.addAll(list); songListAdapter.notifyDataSetChanged(); } - + emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE); currentRevision = downloadService.getDownloadListUpdateRevision(); @@ -1170,7 +1183,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis default: break; } - + if(scrollWhenLoaded) { scrollToCurrent(); scrollWhenLoaded = false; @@ -1193,7 +1206,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if (downloadService == null || onCurrentChangedTask != null) { return; } - + onCurrentChangedTask = new SilentBackgroundTask(context) { int currentPlayingIndex; int currentPlayingSize; @@ -1254,7 +1267,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } } }; - + if(onDownloadListChangedTask == null) { onCurrentChangedTask.execute(); } @@ -1390,33 +1403,33 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } }.execute(); } - + private void createBookmark() { DownloadService downloadService = getDownloadService(); if(downloadService == null) { return; } - + final DownloadFile currentDownload = downloadService.getCurrentPlaying(); if(currentDownload == null) { return; } - + View dialogView = context.getLayoutInflater().inflate(R.layout.create_bookmark, null); final EditText commentBox = (EditText)dialogView.findViewById(R.id.comment_text); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.download_save_bookmark_title) - .setView(dialogView) - .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - String comment = commentBox.getText().toString(); + .setView(dialogView) + .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + String comment = commentBox.getText().toString(); - createBookmark(currentDownload, comment); - } - }) - .setNegativeButton(R.string.common_cancel, null); + createBookmark(currentDownload, comment); + } + }) + .setNegativeButton(R.string.common_cancel, null); AlertDialog dialog = builder.create(); dialog.show(); } @@ -1425,13 +1438,13 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if(downloadService == null) { return; } - + final Entry currentSong = currentDownload.getSong(); final int position = downloadService.getPlayerPosition(); final Bookmark oldBookmark = currentSong.getBookmark(); currentSong.setBookmark(new Bookmark(position)); bookmarkButton.setImageResource(R.drawable.ic_menu_bookmark_selected); - + new SilentBackgroundTask(context) { @Override protected Void doInBackground() throws Throwable { @@ -1453,12 +1466,12 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis Util.toast(context, R.string.download_save_bookmark); setControlsVisible(true); } - + @Override protected void error(Throwable error) { Log.w(TAG, "Failed to create bookmark", error); currentSong.setBookmark(oldBookmark); - + // If no bookmark at start, then return to no bookmark if(oldBookmark == null) { int bookmark; @@ -1469,14 +1482,14 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } bookmarkButton.setImageResource(bookmark); } - + String msg; if(error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); } else { msg = context.getResources().getString(R.string.download_save_bookmark_failed) + getErrorMessage(error); } - + Util.toast(context, msg, false); } }.execute(); diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index c71d99f6..830e2957 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -25,7 +25,6 @@ import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import github.daneren2005.dsub.R; -import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.service.DownloadService; @@ -110,7 +109,7 @@ public class SelectBookmarkFragment extends SelectListFragment playlists = new ArrayList(); playlists.addAll(musicService.getPlaylists(false, context, this)); - + // Iterate through and remove all non owned public playlists Iterator it = playlists.iterator(); while(it.hasNext()) { @@ -1003,7 +1010,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR it.remove(); } } - + return playlists; } @@ -1016,7 +1023,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override public View getView(int position, View convertView, ViewGroup parent) { Playlist playlist = getItem(position); - + // Create new if not getting a convert view to use PlaylistSongView view; if(convertView instanceof PlaylistSongView) { @@ -1033,21 +1040,21 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.playlist_add_to) - .setAdapter(playlistAdapter, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - if (which > 0) { - addToPlaylist(playlists.get(which), songs); - } else { - createNewPlaylist(songs, false); + .setAdapter(playlistAdapter, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + if (which > 0) { + addToPlaylist(playlists.get(which), songs); + } else { + createNewPlaylist(songs, false); + } } - } - }); + }); AlertDialog dialog = builder.create(); dialog.show(); } @Override - protected void error(Throwable error) { + protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); @@ -1075,7 +1082,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } @Override - protected void error(Throwable error) { + protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); @@ -1087,7 +1094,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } }.execute(); } - + protected void createNewPlaylist(final List songs, final boolean getSuggestion) { View layout = context.getLayoutInflater().inflate(R.layout.save_playlist, null); final EditText playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name); @@ -1115,34 +1122,34 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.download_playlist_title) - .setMessage(R.string.download_playlist_name) - .setView(layout) - .setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - String playlistName = String.valueOf(playlistNameView.getText()); - if(overwriteCheckBox.isChecked()) { - overwritePlaylist(songs, playlistName, getDownloadService().getSuggestedPlaylistId()); - } else { - createNewPlaylist(songs, playlistName); - - if(getSuggestion) { - DownloadService downloadService = getDownloadService(); - if(downloadService != null) { - downloadService.setSuggestedPlaylistName(playlistName, null); + .setMessage(R.string.download_playlist_name) + .setView(layout) + .setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + String playlistName = String.valueOf(playlistNameView.getText()); + if(overwriteCheckBox.isChecked()) { + overwritePlaylist(songs, playlistName, getDownloadService().getSuggestedPlaylistId()); + } else { + createNewPlaylist(songs, playlistName); + + if(getSuggestion) { + DownloadService downloadService = getDownloadService(); + if(downloadService != null) { + downloadService.setSuggestedPlaylistName(playlistName, null); + } } } } - } - }) - .setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }) - .setCancelable(true); - + }) + .setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }) + .setCancelable(true); + AlertDialog dialog = builder.create(); dialog.show(); } @@ -1184,7 +1191,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } @Override - protected void error(Throwable error) { + protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); @@ -1197,6 +1204,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }.execute(); } + @TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1) public void displaySongInfo(final Entry song) { Integer duration = null; Integer bitrate = null; @@ -1209,12 +1217,12 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(file.exists()) { MediaMetadataRetriever metadata = new MediaMetadataRetriever(); metadata.setDataSource(file.getAbsolutePath()); - + String tmp = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); duration = Integer.parseInt((tmp != null) ? tmp : "0") / 1000; format = FileUtil.getExtension(file.getName()); size = file.length(); - + // If no duration try to read bitrate tag if(duration == null) { tmp = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE); @@ -1224,7 +1232,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR // Divide by 1000 so in kbps bitrate = (int) (size / duration) / 1000 * 8; } - + if(Util.isOffline(context)) { song.setGenre(metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE)); String year = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_YEAR); @@ -1286,7 +1294,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR Util.info(context, song.getTitle(), msg); } - + protected void playVideo(Entry entry) { if(entryExists(entry)) { playExternalPlayer(entry); @@ -1315,7 +1323,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR intent.putExtra(Intent.EXTRA_TITLE, entry.getTitle()); List intents = context.getPackageManager() - .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); + .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if(intents != null && intents.size() > 0) { startActivity(intent); }else { @@ -1373,7 +1381,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void deleteRecursively(Artist artist) { deleteRecursively(FileUtil.getArtistDirectory(context, artist)); } - + public void deleteRecursively(Entry album) { deleteRecursively(FileUtil.getAlbumDirectory(context, album)); @@ -1490,7 +1498,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR intent.putExtra(Intent.EXTRA_TEXT, share.getUrl()); context.startActivity(Intent.createChooser(intent, context.getResources().getString(R.string.share_via))); } - + public GestureDetector getGestureDetector() { return gestureScanner; } @@ -1515,7 +1523,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void onClick(DialogInterface dialog, int id) { final Bookmark oldBookmark = song.getBookmark(); song.setBookmark(null); - + new SilentBackgroundTask(context) { @Override protected Void doInBackground() throws Throwable { @@ -1528,7 +1536,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override protected void error(Throwable error) { song.setBookmark(oldBookmark); - + String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); @@ -1546,7 +1554,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR AlertDialog dialog = builder.create(); dialog.show(); } - + protected void playNow(List entries) { playNow(entries, null, null); } @@ -1558,7 +1566,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR break; } } - + // If no bookmark found, just play from start if(bookmark == null) { playNow(entries, 0, playlistName, playlistId); @@ -1585,17 +1593,17 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(downloadService == null) { return null; } - + downloadService.clear(); downloadService.download(entries, false, true, true, false, entries.indexOf(song), position); downloadService.setSuggestedPlaylistName(playlistName, playlistId); return null; } - + @Override protected void done(Void result) { - Util.startActivityWithoutTransition(context, DownloadActivity.class); + context.openNowPlaying(); } }.execute(); } @@ -1657,19 +1665,19 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR View layout = context.getLayoutInflater().inflate(R.layout.rating, null); final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.rating_bar); ratingBar.setRating((float) entry.getRating()); - + AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getResources().getString(R.string.rating_title, entry.getTitle())) - .setView(layout) - .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - int rating = (int) ratingBar.getRating(); - setRating(entry, rating, onRatingChange); - } - }) - .setNegativeButton(R.string.common_cancel, null); - + .setView(layout) + .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + int rating = (int) ratingBar.getRating(); + setRating(entry, rating, onRatingChange); + } + }) + .setNegativeButton(R.string.common_cancel, null); + AlertDialog dialog = builder.create(); dialog.show(); } @@ -1684,7 +1692,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(onRatingChange != null) { onRatingChange.ratingChange(rating); } - + new SilentBackgroundTask(context) { @Override protected Void doInBackground() throws Throwable { @@ -1711,7 +1719,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(onRatingChange != null) { onRatingChange.ratingChange(oldRating); } - + String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); @@ -1723,16 +1731,16 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } }.execute(); } - + protected abstract class EntryInstanceUpdater { private Entry entry; - + public EntryInstanceUpdater(Entry entry) { this.entry = entry; } - + public abstract void update(Entry found); - + public void execute() { DownloadService downloadService = getDownloadService(); if(downloadService != null && !entry.isDirectory()) { @@ -1745,12 +1753,12 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR serializeChanges = true; } } - + if(serializeChanges) { downloadService.serializeQueue(); } } - + Entry find = UpdateView.findEntry(entry); if(find != null) { update(find); @@ -1810,7 +1818,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } if(result) { - Util.startActivityWithoutTransition(context, DownloadActivity.class); + context.openNowPlaying(); } } } diff --git a/app/src/main/java/github/daneren2005/dsub/provider/DSubWidgetProvider.java b/app/src/main/java/github/daneren2005/dsub/provider/DSubWidgetProvider.java index 444b6cff..7cb3ce8b 100644 --- a/app/src/main/java/github/daneren2005/dsub/provider/DSubWidgetProvider.java +++ b/app/src/main/java/github/daneren2005/dsub/provider/DSubWidgetProvider.java @@ -39,7 +39,6 @@ import android.util.Log; import android.view.View; import android.widget.RemoteViews; import github.daneren2005.dsub.R; -import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.activity.SubsonicActivity; import github.daneren2005.dsub.activity.SubsonicFragmentActivity; import github.daneren2005.dsub.domain.MusicDirectory; @@ -270,9 +269,7 @@ public class DSubWidgetProvider extends AppWidgetProvider { /** * Link up various button actions using {@link PendingIntent}. * - * @param playerActive True if player is active in background, which means - * widget click will launch {@link DownloadActivity}, - * otherwise we launch {@link github.daneren2005.dsub.activity.SubsonicFragmentActivity}. + * @param playerActive @param playerActive True if player is active in background. Launch {@link github.daneren2005.dsub.activity.SubsonicFragmentActivity}. */ private void linkButtons(Context context, RemoteViews views, boolean playerActive) { Intent intent = new Intent(context, SubsonicFragmentActivity.class); diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index 75d8d5dd..876dc648 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -48,6 +48,7 @@ import android.view.Gravity; import android.widget.TextView; import android.widget.Toast; import github.daneren2005.dsub.R; +import github.daneren2005.dsub.activity.SubsonicFragmentActivity; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PlayerState; import github.daneren2005.dsub.domain.RepeatMode; @@ -256,14 +257,26 @@ public final class Util { } public static void applyTheme(Context context, String theme) { - if ("dark".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Dark); - } else if ("black".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Black); - } else if ("holo".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Holo); + if(context instanceof SubsonicFragmentActivity) { + if ("dark".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Dark_No_Actionbar); + } else if ("black".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Black_No_Actionbar); + } else if ("holo".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Holo_No_Actionbar); + } else { + context.setTheme(R.style.Theme_DSub_Light_No_Actionbar); + } } else { - context.setTheme(R.style.Theme_DSub_Light); + if ("dark".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Dark); + } else if ("black".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Black); + } else if ("holo".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Holo); + } else { + context.setTheme(R.style.Theme_DSub_Light); + } } SharedPreferences prefs = Util.getPreferences(context); diff --git a/app/src/main/res/layout/abstract_fragment_activity.xml b/app/src/main/res/layout/abstract_fragment_activity.xml index d9c99f2f..3aa6374f 100644 --- a/app/src/main/res/layout/abstract_fragment_activity.xml +++ b/app/src/main/res/layout/abstract_fragment_activity.xml @@ -1,84 +1,125 @@ - + android:gravity="bottom" + sothree:umanoPanelHeight="?attr/actionBarSize" + sothree:umanoShadowHeight="4dp" + sothree:umanoDragView="@+id/slide_up_swipe_target"> - + - + + + + - - - - - - - - + + + + + + - - - - - - - - - - + style="@style/BasicButton" + android:orientation="horizontal"> + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/abstract_fragment_container.xml b/app/src/main/res/layout/abstract_fragment_container.xml deleted file mode 100644 index 61e17d1d..00000000 --- a/app/src/main/res/layout/abstract_fragment_container.xml +++ /dev/null @@ -1,6 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 43271afd..061cfae7 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -23,6 +23,12 @@ @dimen/Button.Small @dimen/Button.Small + + + + + + + - - + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 27082530..ecba7592 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,8 +1,6 @@ - - + + @@ -115,20 +115,6 @@ false true - - - - -- cgit v1.2.3 From 111757497f4e7ba13a04ebf75b4e0e9bf9a2d011 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 17 Jun 2015 08:09:26 -0700 Subject: Fix Setting being selected --- .../main/java/github/daneren2005/dsub/activity/SubsonicActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d730b412..fe785ef8 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -244,8 +244,8 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte // Settings are on a different selectable track if (menuItem.getItemId() != R.id.drawer_settings) { menuItem.setChecked(true); + lastSelectedPosition = menuItem.getItemId(); } - lastSelectedPosition = menuItem.getItemId(); switch (menuItem.getItemId()) { case R.id.drawer_home: -- cgit v1.2.3 From 4d8d67a02e18948f707bfe2465435c4a69459468 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 17 Jun 2015 08:10:05 -0700 Subject: Switch SettingsActivity over to use manually inserted Toolbar --- .../dsub/activity/SettingsActivity.java | 54 ++++------------------ .../java/github/daneren2005/dsub/util/Util.java | 3 +- app/src/main/res/layout/download_activity.xml | 4 -- app/src/main/res/layout/settings_activity.xml | 16 +++++++ 4 files changed, 28 insertions(+), 49 deletions(-) delete mode 100644 app/src/main/res/layout/download_activity.xml create mode 100644 app/src/main/res/layout/settings_activity.xml diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java index babc9d48..595529b7 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SettingsActivity.java @@ -19,62 +19,25 @@ package github.daneren2005.dsub.activity; import android.annotation.TargetApi; -import android.accounts.Account; -import android.content.ContentResolver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; 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.PreferenceCategory; -import android.preference.PreferenceScreen; -import android.support.v7.app.ActionBarActivity; -import android.text.InputType; -import android.util.Log; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.EditText; -import android.widget.FrameLayout; +import android.support.v7.widget.Toolbar; import github.daneren2005.dsub.R; import github.daneren2005.dsub.fragments.PreferenceCompatFragment; import github.daneren2005.dsub.fragments.SettingsFragment; -import github.daneren2005.dsub.service.DownloadService; -import github.daneren2005.dsub.service.MusicService; -import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.util.Constants; -import github.daneren2005.dsub.util.LoadingTask; -import github.daneren2005.dsub.util.SyncUtil; -import github.daneren2005.dsub.view.ErrorDialog; -import github.daneren2005.dsub.util.FileUtil; -import github.daneren2005.dsub.util.Util; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URL; -import java.text.DecimalFormat; -import java.util.LinkedHashMap; -import java.util.Map; public class SettingsActivity extends SubsonicActivity { - private static final String TAG = SettingsActivity.class.getSimpleName(); + private static final String TAG = SettingsActivity.class.getSimpleName(); private PreferenceCompatFragment fragment; @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); lastSelectedPosition = R.id.drawer_settings; - setContentView(R.layout.download_activity); + setContentView(R.layout.settings_activity); if (savedInstanceState == null) { fragment = new SettingsFragment(); @@ -88,5 +51,8 @@ public class SettingsActivity extends SubsonicActivity { currentFragment.setPrimaryFragment(true); getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "").commit(); } - } + + Toolbar mainToolbar = (Toolbar) findViewById(R.id.main_toolbar); + setSupportActionBar(mainToolbar); + } } diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index 969e178e..0160ddd0 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -48,6 +48,7 @@ import android.view.Gravity; import android.widget.TextView; import android.widget.Toast; import github.daneren2005.dsub.R; +import github.daneren2005.dsub.activity.SettingsActivity; import github.daneren2005.dsub.activity.SubsonicFragmentActivity; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PlayerState; @@ -257,7 +258,7 @@ public final class Util { } public static void applyTheme(Context context, String theme) { - if(context instanceof SubsonicFragmentActivity) { + if(context instanceof SubsonicFragmentActivity || context instanceof SettingsActivity) { if ("dark".equals(theme)) { context.setTheme(R.style.Theme_DSub_Dark_No_Actionbar); } else if ("black".equals(theme)) { diff --git a/app/src/main/res/layout/download_activity.xml b/app/src/main/res/layout/download_activity.xml deleted file mode 100644 index 017e4013..00000000 --- a/app/src/main/res/layout/download_activity.xml +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/app/src/main/res/layout/settings_activity.xml b/app/src/main/res/layout/settings_activity.xml new file mode 100644 index 00000000..89355cb7 --- /dev/null +++ b/app/src/main/res/layout/settings_activity.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file -- cgit v1.2.3 From 4c24853c6ad9f08004e8981a7187dd3ae1a794db Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 17 Jun 2015 08:10:32 -0700 Subject: Convert MainFragment over to SectionAdapter --- .../daneren2005/dsub/adapter/MainAdapter.java | 113 ++++++++ .../daneren2005/dsub/adapter/MergeAdapter.java | 290 --------------------- .../dsub/adapter/SackOfViewsAdapter.java | 181 ------------- .../daneren2005/dsub/adapter/SectionAdapter.java | 41 ++- .../daneren2005/dsub/fragments/MainFragment.java | 267 +++++-------------- .../daneren2005/dsub/view/AlbumListCountView.java | 132 ++++++++++ .../daneren2005/dsub/view/BasicHeaderView.java | 5 +- .../github/daneren2005/dsub/view/UpdateView.java | 4 + app/src/main/res/layout/album_list_header.xml | 28 ++ app/src/main/res/layout/album_list_item.xml | 3 +- app/src/main/res/layout/basic_count_item.xml | 2 +- app/src/main/res/layout/main_buttons.xml | 157 ----------- 12 files changed, 386 insertions(+), 837 deletions(-) create mode 100644 app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java delete mode 100644 app/src/main/java/github/daneren2005/dsub/adapter/MergeAdapter.java delete mode 100644 app/src/main/java/github/daneren2005/dsub/adapter/SackOfViewsAdapter.java create mode 100644 app/src/main/java/github/daneren2005/dsub/view/AlbumListCountView.java create mode 100644 app/src/main/res/layout/album_list_header.xml delete mode 100644 app/src/main/res/layout/main_buttons.xml diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java new file mode 100644 index 00000000..e451bc19 --- /dev/null +++ b/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java @@ -0,0 +1,113 @@ +/* + This file is part of Subsonic. + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see . + Copyright 2015 (C) Scott Jackson +*/ + +package github.daneren2005.dsub.adapter; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CheckBox; +import android.widget.CompoundButton; + +import java.util.List; + +import github.daneren2005.dsub.R; +import github.daneren2005.dsub.domain.ServerInfo; +import github.daneren2005.dsub.util.Util; +import github.daneren2005.dsub.view.AlbumListCountView; +import github.daneren2005.dsub.view.BasicHeaderView; +import github.daneren2005.dsub.view.BasicListView; +import github.daneren2005.dsub.view.UpdateView; + +public class MainAdapter extends SectionAdapter { + public static final int VIEW_TYPE_ALBUM_LIST = 1; + public static final int VIEW_TYPE_ALBUM_COUNT_LIST = 2; + + public MainAdapter(Context context, List headers, List> sections, OnItemClickedListener onItemClickedListener) { + super(context, headers, sections); + this.onItemClickedListener = onItemClickedListener; + } + + @Override + public UpdateView.UpdateViewHolder onCreateSectionViewHolder(ViewGroup parent, int viewType) { + UpdateView updateView; + if(viewType == VIEW_TYPE_ALBUM_LIST) { + updateView = new BasicListView(context); + } else { + updateView = new AlbumListCountView(context); + } + + return new UpdateView.UpdateViewHolder(updateView); + } + + @Override + public void onBindViewHolder(UpdateView.UpdateViewHolder holder, Integer item, int viewType) { + UpdateView updateView = holder.getUpdateView(); + + if(viewType == VIEW_TYPE_ALBUM_LIST) { + updateView.setObject(context.getResources().getString(item)); + } else { + // Hacky method to make sure updateBackground is called in background thread + updateView.setObject(item, null); + } + } + + @Override + public int getItemViewType(Integer item) { + if(item == R.string.main_albums_newest) { + return VIEW_TYPE_ALBUM_COUNT_LIST; + } else { + return VIEW_TYPE_ALBUM_LIST; + } + } + + @Override + public UpdateView.UpdateViewHolder onCreateHeaderHolder(ViewGroup parent) { + return new UpdateView.UpdateViewHolder(new BasicHeaderView(context, R.layout.album_list_header)); + } + @Override + public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header) { + UpdateView view = holder.getUpdateView(); + CheckBox checkBox = (CheckBox) view.findViewById(R.id.item_checkbox); + + String display; + if ("albums".equals(header)) { + display = context.getResources().getString(R.string.main_albums_title); + + if(!Util.isOffline(context) && ServerInfo.canAlbumListPerFolder(context)) { + checkBox.setVisibility(View.VISIBLE); + checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + Util.setAlbumListsPerFolder(context, isChecked); + } + }); + checkBox.setChecked(Util.getAlbumListsPerFolder(context)); + } else { + checkBox.setVisibility(View.GONE); + } + } else if("videos".equals(header)) { + display = context.getResources().getString(R.string.main_videos); + checkBox.setVisibility(View.GONE); + } else { + display = header; + checkBox.setVisibility(View.GONE); + } + + if(view != null) { + view.setObject(display); + } + } +} diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/MergeAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/MergeAdapter.java deleted file mode 100644 index a2db4cf0..00000000 --- a/app/src/main/java/github/daneren2005/dsub/adapter/MergeAdapter.java +++ /dev/null @@ -1,290 +0,0 @@ -/*** - Copyright (c) 2008-2009 CommonsWare, LLC - Portions (c) 2009 Google, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package github.daneren2005.dsub.adapter; - -import android.database.DataSetObserver; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ListAdapter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Arrays; - -/** - * Adapter that merges multiple child adapters and views - * into a single contiguous whole. - *

- * Adapters used as pieces within MergeAdapter must - * have view type IDs monotonically increasing from 0. Ideally, - * adapters also have distinct ranges for their row ids, as - * returned by getItemId(). - */ -public class MergeAdapter extends BaseAdapter { - - private final CascadeDataSetObserver observer = new CascadeDataSetObserver(); - private final ArrayList pieces = new ArrayList(); - - /** - * Stock constructor, simply chaining to the superclass. - */ - public MergeAdapter() { - super(); - } - - /** - * Adds a new adapter to the roster of things to appear - * in the aggregate list. - * - * @param adapter Source for row views for this section - */ - public void addAdapter(ListAdapter adapter) { - pieces.add(adapter); - adapter.registerDataSetObserver(observer); - } - - public void removeAdapter(ListAdapter adapter) { - adapter.unregisterDataSetObserver(observer); - pieces.remove(adapter); - } - - /** - * Adds a new View to the roster of things to appear - * in the aggregate list. - * - * @param view Single view to add - */ - public ListAdapter addView(View view) { - return addView(view, false); - } - - /** - * Adds a new View to the roster of things to appear - * in the aggregate list. - * - * @param view Single view to add - * @param enabled false if views are disabled, true if enabled - */ - public ListAdapter addView(View view, boolean enabled) { - return addViews(Arrays.asList(view), enabled); - } - - /** - * Adds a list of views to the roster of things to appear - * in the aggregate list. - * - * @param views List of views to add - */ - public ListAdapter addViews(List views) { - return addViews(views, false); - } - - /** - * Adds a list of views to the roster of things to appear - * in the aggregate list. - * - * @param views List of views to add - * @param enabled false if views are disabled, true if enabled - */ - public ListAdapter addViews(List views, boolean enabled) { - ListAdapter adapter = enabled ? new EnabledSackAdapter(views) : new SackOfViewsAdapter(views); - addAdapter(adapter); - return adapter; - } - - /** - * Get the data item associated with the specified - * position in the data set. - * - * @param position Position of the item whose data we want - */ - @Override - public Object getItem(int position) { - for (ListAdapter piece : pieces) { - int size = piece.getCount(); - - if (position < size) { - return (piece.getItem(position)); - } - - position -= size; - } - - return (null); - } - - /** - * How many items are in the data set represented by this - * Adapter. - */ - @Override - public int getCount() { - int total = 0; - - for (ListAdapter piece : pieces) { - total += piece.getCount(); - } - - return (total); - } - - /** - * Returns the number of types of Views that will be - * created by getView(). - */ - @Override - public int getViewTypeCount() { - int total = 0; - - for (ListAdapter piece : pieces) { - total += piece.getViewTypeCount(); - } - - return (Math.max(total, 1)); // needed for setListAdapter() before content add' - } - - /** - * Get the type of View that will be created by getView() - * for the specified item. - * - * @param position Position of the item whose data we want - */ - @Override - public int getItemViewType(int position) { - int typeOffset = 0; - int result = -1; - - for (ListAdapter piece : pieces) { - int size = piece.getCount(); - - if (position < size) { - result = typeOffset + piece.getItemViewType(position); - break; - } - - position -= size; - typeOffset += piece.getViewTypeCount(); - } - - return (result); - } - - /** - * Are all items in this ListAdapter enabled? If yes it - * means all items are selectable and clickable. - */ - @Override - public boolean areAllItemsEnabled() { - return (false); - } - - /** - * Returns true if the item at the specified position is - * not a separator. - * - * @param position Position of the item whose data we want - */ - @Override - public boolean isEnabled(int position) { - for (ListAdapter piece : pieces) { - int size = piece.getCount(); - - if (position < size) { - return (piece.isEnabled(position)); - } - - position -= size; - } - - return (false); - } - - /** - * Get a View that displays the data at the specified - * position in the data set. - * - * @param position Position of the item whose data we want - * @param convertView View to recycle, if not null - * @param parent ViewGroup containing the returned View - */ - @Override - public View getView(int position, View convertView, - ViewGroup parent) { - for (ListAdapter piece : pieces) { - int size = piece.getCount(); - - if (position < size) { - - return (piece.getView(position, convertView, parent)); - } - - position -= size; - } - - return (null); - } - - /** - * Get the row id associated with the specified position - * in the list. - * - * @param position Position of the item whose data we want - */ - @Override - public long getItemId(int position) { - for (ListAdapter piece : pieces) { - int size = piece.getCount(); - - if (position < size) { - return (piece.getItemId(position)); - } - - position -= size; - } - - return (-1); - } - - private static class EnabledSackAdapter extends SackOfViewsAdapter { - public EnabledSackAdapter(List views) { - super(views); - } - - @Override - public boolean areAllItemsEnabled() { - return (true); - } - - @Override - public boolean isEnabled(int position) { - return (true); - } - } - - private class CascadeDataSetObserver extends DataSetObserver { - @Override - public void onChanged() { - notifyDataSetChanged(); - } - - @Override - public void onInvalidated() { - notifyDataSetInvalidated(); - } - } -} - diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SackOfViewsAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SackOfViewsAdapter.java deleted file mode 100644 index e4744cc5..00000000 --- a/app/src/main/java/github/daneren2005/dsub/adapter/SackOfViewsAdapter.java +++ /dev/null @@ -1,181 +0,0 @@ -/*** - Copyright (c) 2008-2009 CommonsWare, LLC - Portions (c) 2009 Google, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package github.daneren2005.dsub.adapter; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ListView; - -import java.util.ArrayList; -import java.util.List; - -/** - * Adapter that simply returns row views from a list. - *

- * If you supply a size, you must implement newView(), to - * create a required view. The adapter will then cache these - * views. - *

- * If you supply a list of views in the constructor, that - * list will be used directly. If any elements in the list - * are null, then newView() will be called just for those - * slots. - *

- * Subclasses may also wish to override areAllItemsEnabled() - * (default: false) and isEnabled() (default: false), if some - * of their rows should be selectable. - *

- * It is assumed each view is unique, and therefore will not - * get recycled. - *

- * Note that this adapter is not designed for long lists. It - * is more for screens that should behave like a list. This - * is particularly useful if you combine this with other - * adapters (e.g., SectionedAdapter) that might have an - * arbitrary number of rows, so it all appears seamless. - */ -public class SackOfViewsAdapter extends BaseAdapter { - private List views = null; - - /** - * Constructor creating an empty list of views, but with - * a specified count. Subclasses must override newView(). - */ - public SackOfViewsAdapter(int count) { - super(); - - views = new ArrayList(count); - - for (int i = 0; i < count; i++) { - views.add(null); - } - } - - /** - * Constructor wrapping a supplied list of views. - * Subclasses must override newView() if any of the elements - * in the list are null. - */ - public SackOfViewsAdapter(List views) { - for (View view : views) { - view.setLayoutParams(new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - } - this.views = views; - } - - /** - * Get the data item associated with the specified - * position in the data set. - * - * @param position Position of the item whose data we want - */ - @Override - public Object getItem(int position) { - return (views.get(position)); - } - - /** - * How many items are in the data set represented by this - * Adapter. - */ - @Override - public int getCount() { - return (views.size()); - } - - /** - * Returns the number of types of Views that will be - * created by getView(). - */ - @Override - public int getViewTypeCount() { - return (getCount()); - } - - /** - * Get the type of View that will be created by getView() - * for the specified item. - * - * @param position Position of the item whose data we want - */ - @Override - public int getItemViewType(int position) { - return (position); - } - - /** - * Are all items in this ListAdapter enabled? If yes it - * means all items are selectable and clickable. - */ - @Override - public boolean areAllItemsEnabled() { - return (false); - } - - /** - * Returns true if the item at the specified position is - * not a separator. - * - * @param position Position of the item whose data we want - */ - @Override - public boolean isEnabled(int position) { - return (false); - } - - /** - * Get a View that displays the data at the specified - * position in the data set. - * - * @param position Position of the item whose data we want - * @param convertView View to recycle, if not null - * @param parent ViewGroup containing the returned View - */ - @Override - public View getView(int position, View convertView, - ViewGroup parent) { - View result = views.get(position); - - if (result == null) { - result = newView(position, parent); - views.set(position, result); - } - - return (result); - } - - /** - * Get the row id associated with the specified position - * in the list. - * - * @param position Position of the item whose data we want - */ - @Override - public long getItemId(int position) { - return (position); - } - - /** - * Create a new View to go into the list at the specified - * position. - * - * @param position Position of the item whose data we want - * @param parent ViewGroup containing the returned View - */ - protected View newView(int position, ViewGroup parent) { - throw new RuntimeException("You must override newView()!"); - } -} diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java index 599870d7..f57012b5 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java @@ -77,6 +77,7 @@ public abstract class SectionAdapter extends RecyclerView.Adapter extends RecyclerView.Adapter section: sections) { - if(position == subPosition) { - int index = sections.indexOf(section); - onBindHeaderHolder(holder, headers.get(index)); + boolean validHeader = headers.get(subHeader) != null; + if(position == subPosition && validHeader) { + onBindHeaderHolder(holder, headers.get(subHeader)); return; } - if(position <= (subPosition + section.size())) { - T item = section.get(position - subPosition - 1); + int headerOffset = validHeader ? 1 : 0; + if(position < (subPosition + section.size() + headerOffset)) { + T item = section.get(position - subPosition - headerOffset); onBindViewHolder(holder, item, getItemViewType(item)); if(updateView.isCheckable()) { @@ -154,7 +157,11 @@ public abstract class SectionAdapter extends RecyclerView.Adapter extends RecyclerView.Adapter section: sections) { count += section.size(); } @@ -179,16 +191,23 @@ public abstract class SectionAdapter extends RecyclerView.Adapter section: sections) { - if(position == subPosition) { + boolean validHeader = headers.get(subHeader) != null; + if(position == subPosition && validHeader) { return VIEW_TYPE_HEADER; } - if(position <= (subPosition + section.size())) { - return getItemViewType(section.get(position - subPosition - 1)); + int headerOffset = validHeader ? 1 : 0; + if(position < (subPosition + section.size() + headerOffset)) { + return getItemViewType(section.get(position - subPosition - headerOffset)); } - subPosition += section.size() + 1; + subPosition += section.size(); + if(validHeader) { + subPosition += 1; + } + subHeader++; } return -1; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java index 0c33ef8c..90a91383 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java @@ -9,28 +9,23 @@ import android.os.Build; import android.os.Bundle; import android.os.StatFs; import android.util.Log; -import android.view.ContextMenu; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.ListView; -import android.widget.TextView; + import github.daneren2005.dsub.R; -import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.adapter.MainAdapter; +import github.daneren2005.dsub.adapter.SectionAdapter; import github.daneren2005.dsub.domain.ServerInfo; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.LoadingTask; import github.daneren2005.dsub.util.Pair; +import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.UserUtil; -import github.daneren2005.dsub.adapter.MergeAdapter; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; @@ -41,37 +36,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class MainFragment extends SubsonicFragment { +public class MainFragment extends SelectRecyclerFragment { private static final String TAG = MainFragment.class.getSimpleName(); - private LayoutInflater inflater; - private TextView countView; - - private static final int MENU_GROUP_SERVER = 10; - private static final int MENU_ITEM_SERVER_BASE = 100; - - @Override - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { - this.inflater = inflater; - rootView = inflater.inflate(R.layout.home, container, false); - - createLayout(); - return rootView; - } - - @Override - public void onResume() { - super.onResume(); - } - - @Override - public void onDestroy() { - super.onDestroy(); + public MainFragment() { + super(); + pullToRefresh = false; + serialize = false; } @Override @@ -116,100 +87,56 @@ public class MainFragment extends SubsonicFragment { } @Override - protected void refresh(boolean refresh) { - createLayout(); + public int getOptionsMenu() { + return 0; } - private void createLayout() { - View buttons = inflater.inflate(R.layout.main_buttons, null); - - final TextView offlineButton = (TextView) buttons.findViewById(R.id.main_offline); - offlineButton.setText(Util.isOffline(context) ? R.string.main_online : R.string.main_offline); - - final View albumsTitle = buttons.findViewById(R.id.main_albums); - final View videoTitle = buttons.findViewById(R.id.main_video_section); - final View albumsNewestButton = buttons.findViewById(R.id.main_albums_newest); - countView = (TextView) buttons.findViewById(R.id.main_albums_recent_count); - final View albumsRandomButton = buttons.findViewById(R.id.main_albums_random); - final View albumsHighestButton = buttons.findViewById(R.id.main_albums_highest); - final View albumsRecentButton = buttons.findViewById(R.id.main_albums_recent); - final View albumsFrequentButton = buttons.findViewById(R.id.main_albums_frequent); - final View albumsStarredButton = buttons.findViewById(R.id.main_albums_starred); - final View albumsGenresButton = buttons.findViewById(R.id.main_albums_genres); - final View albumsYearButton = buttons.findViewById(R.id.main_albums_year); - final View albumsAlphabeticalButton = buttons.findViewById(R.id.main_albums_alphabetical); - final View videosButton = buttons.findViewById(R.id.main_videos); - - final CheckBox albumsPerFolderCheckbox = (CheckBox) buttons.findViewById(R.id.main_albums_per_folder); - if(!Util.isOffline(context) && ServerInfo.canAlbumListPerFolder(context)) { - albumsPerFolderCheckbox.setChecked(Util.getAlbumListsPerFolder(context)); - albumsPerFolderCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - Util.setAlbumListsPerFolder(context, isChecked); - } - }); - } else { - albumsPerFolderCheckbox.setVisibility(View.GONE); - } - - int instance = Util.getActiveServer(context); - String name = Util.getServerName(context, instance); + @Override + public SectionAdapter getAdapter(List objs) { + List> sections = new ArrayList<>(); + List headers = new ArrayList<>(); - ListView list = (ListView) rootView.findViewById(R.id.main_list); + List offline = Arrays.asList(R.string.main_offline); + sections.add(offline); + headers.add(null); - MergeAdapter adapter = new MergeAdapter(); - adapter.addView(offlineButton, true); if (!Util.isOffline(context)) { - adapter.addView(albumsTitle, false); - adapter.addViews(Arrays.asList(albumsNewestButton, albumsRandomButton), true); + List albums = new ArrayList<>(); + albums.add(R.string.main_albums_newest); + albums.add(R.string.main_albums_random); if(ServerInfo.checkServerVersion(context, "1.8")) { - adapter.addView(albumsAlphabeticalButton, true); + albums.add(R.string.main_albums_alphabetical); } if(!Util.isTagBrowsing(context)) { - adapter.addView(albumsHighestButton, true); + albums.add(R.string.main_albums_highest); } - adapter.addViews(Arrays.asList(albumsStarredButton, albumsGenresButton, albumsYearButton, albumsRecentButton, albumsFrequentButton), true); + albums.add(R.string.main_albums_starred); + albums.add(R.string.main_albums_genres); + albums.add(R.string.main_albums_year); + albums.add(R.string.main_albums_recent); + albums.add(R.string.main_albums_highest); + + sections.add(albums); + headers.add("albums"); + if(ServerInfo.checkServerVersion(context, "1.8") && !Util.isTagBrowsing(context)) { - adapter.addView(videoTitle, false); - adapter.addView(videosButton, true); + List videos = Arrays.asList(R.string.main_videos); + sections.add(videos); + headers.add("videos"); } } - list.setAdapter(adapter); - list.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - if (view == offlineButton) { - toggleOffline(); - } else if (view == albumsNewestButton) { - showAlbumList("newest"); - } else if (view == albumsRandomButton) { - showAlbumList("random"); - } else if (view == albumsHighestButton) { - showAlbumList("highest"); - } else if (view == albumsRecentButton) { - showAlbumList("recent"); - } else if (view == albumsFrequentButton) { - showAlbumList("frequent"); - } else if (view == albumsStarredButton) { - showAlbumList("starred"); - } else if(view == albumsGenresButton) { - showAlbumList("genres"); - } else if(view == albumsYearButton) { - showAlbumList("years"); - } else if(view == albumsAlphabeticalButton) { - showAlbumList("alphabeticalByName"); - } else if(view == videosButton) { - showVideos(); - } - } - }); - setTitle(R.string.common_appname); + return new MainAdapter(context, headers, sections, this); + } - if(!Util.isOffline(context)) { - getMostRecentCount(); - } + @Override + public List getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { + return Arrays.asList(0); + } + + @Override + public int getTitleResource() { + return R.string.common_appname; } private void toggleOffline() { @@ -247,8 +174,8 @@ public class MainFragment extends SubsonicFragment { editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0); editor.commit(); - // Clear immediately so doesn't still show when pressing back - setMostRecentCount(0); + // TODO: Clear immediately so doesn't still show when pressing back + // setMostRecentCount(0); } SubsonicFragment fragment = new SelectDirectoryFragment(); @@ -447,81 +374,31 @@ public class MainFragment extends SubsonicFragment { }.execute(); } catch(Exception e) {} } - - private void getMostRecentCount() { - // Use stashed value until after refresh occurs - SharedPreferences prefs = Util.getPreferences(context); - final int startCount = prefs.getInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0); - setMostRecentCount(startCount); - - new SilentBackgroundTask(context) { - @Override - public Integer doInBackground() throws Exception { - String recentAddedFile = Util.getCacheName(context, "recent_count"); - ArrayList recents = FileUtil.deserialize(context, recentAddedFile, ArrayList.class); - if(recents == null) { - recents = new ArrayList(); - } - - MusicService musicService = MusicServiceFactory.getMusicService(context); - MusicDirectory recentlyAdded = musicService.getAlbumList("newest", 20, 0, context, null); - - // If first run, just put everything in it and return 0 - boolean firstRun = recents.isEmpty(); - - // Count how many new albums are in the list - int count = 0; - for(MusicDirectory.Entry album: recentlyAdded.getChildren()) { - if(!recents.contains(album.getId())) { - recents.add(album.getId()); - count++; - } - } - - // Keep recents list from growing infinitely - while(recents.size() > 40) { - recents.remove(0); - } - FileUtil.serialize(context, recents, recentAddedFile); - - if(firstRun) { - return 0; - } else { - // Add the old count which will get cleared out after viewing recents - count += startCount; - SharedPreferences.Editor editor = Util.getPreferences(context).edit(); - editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), count); - editor.commit(); - - return count; - } - } - - @Override - public void done(Integer result) { - setMostRecentCount(result); - } - - @Override - public void error(Throwable x) { - Log.w(TAG, "Failed to refresh most recent count", x); - } - }.execute(); - } - - private void setMostRecentCount(int count) { - if(count <= 0) { - countView.setVisibility(View.GONE); - } else { - String displayValue; - if(count < 10) { - displayValue = "0" + count; - } else { - displayValue = "" + count; - } - - countView.setText(displayValue); - countView.setVisibility(View.VISIBLE); + + @Override + public void onItemClicked(Integer item) { + if(item == R.string.main_offline) { + toggleOffline(); + } else if (item == R.string.main_albums_newest) { + showAlbumList("newest"); + } else if (item == R.string.main_albums_random) { + showAlbumList("random"); + } else if (item == R.string.main_albums_highest) { + showAlbumList("highest"); + } else if (item == R.string.main_albums_recent) { + showAlbumList("recent"); + } else if (item == R.string.main_albums_frequent) { + showAlbumList("frequent"); + } else if (item == R.string.main_albums_starred) { + showAlbumList("starred"); + } else if(item == R.string.main_albums_genres) { + showAlbumList("genres"); + } else if(item == R.string.main_albums_year) { + showAlbumList("years"); + } else if(item == R.string.main_albums_alphabetical) { + showAlbumList("alphabeticalByName"); + } else if(item == R.string.main_videos) { + showVideos(); } } } diff --git a/app/src/main/java/github/daneren2005/dsub/view/AlbumListCountView.java b/app/src/main/java/github/daneren2005/dsub/view/AlbumListCountView.java new file mode 100644 index 00000000..81695f53 --- /dev/null +++ b/app/src/main/java/github/daneren2005/dsub/view/AlbumListCountView.java @@ -0,0 +1,132 @@ +/* + This file is part of Subsonic. + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see . + Copyright 2015 (C) Scott Jackson +*/ + +package github.daneren2005.dsub.view; + +import android.content.Context; +import android.content.SharedPreferences; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import java.util.ArrayList; + +import github.daneren2005.dsub.R; +import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.service.MusicService; +import github.daneren2005.dsub.service.MusicServiceFactory; +import github.daneren2005.dsub.util.Constants; +import github.daneren2005.dsub.util.FileUtil; +import github.daneren2005.dsub.util.Util; + +public class AlbumListCountView extends UpdateView { + private final String TAG = AlbumListCountView.class.getSimpleName(); + + private TextView titleView; + private TextView countView; + private int albumListString; + private int startCount; + private int count = 0; + + public AlbumListCountView(Context context) { + super(context, false); + this.context = context; + LayoutInflater.from(context).inflate(R.layout.basic_count_item, this, true); + + titleView = (TextView) findViewById(R.id.basic_count_name); + countView = (TextView) findViewById(R.id.basic_count_count); + } + + protected void setObjectImpl(Object obj1, Object obj2) { + this.albumListString = (Integer) obj1; + titleView.setText(albumListString); + + SharedPreferences prefs = Util.getPreferences(context); + startCount = prefs.getInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0); + count = startCount; + update(); + } + + @Override + protected void updateBackground() { + try { + String recentAddedFile = Util.getCacheName(context, "recent_count"); + ArrayList recents = FileUtil.deserialize(context, recentAddedFile, ArrayList.class); + if (recents == null) { + recents = new ArrayList(); + } + + MusicService musicService = MusicServiceFactory.getMusicService(context); + MusicDirectory recentlyAdded = musicService.getAlbumList("newest", 20, 0, context, null); + + // If first run, just put everything in it and return 0 + boolean firstRun = recents.isEmpty(); + + // Count how many new albums are in the list + count = 0; + for (MusicDirectory.Entry album : recentlyAdded.getChildren()) { + if (!recents.contains(album.getId())) { + recents.add(album.getId()); + count++; + } + } + + // Keep recents list from growing infinitely + while (recents.size() > 40) { + recents.remove(0); + } + FileUtil.serialize(context, recents, recentAddedFile); + + if (!firstRun) { + // Add the old count which will get cleared out after viewing recents + count += startCount; + SharedPreferences.Editor editor = Util.getPreferences(context).edit(); + editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), count); + editor.commit(); + } + } catch(Exception e) { + Log.w(TAG, "Failed to refresh most recent count", e); + } + } + + @Override + protected void update() { + // Update count display with appropriate information + if(count <= 0) { + countView.setVisibility(View.GONE); + } else { + String displayName; + if(count < 10) { + displayName = "0" + count; + } else { + displayName = "" + count; + } + + countView.setText(displayName); + countView.setVisibility(View.VISIBLE); + } + } + + @Override + public void onClick() { + SharedPreferences.Editor editor = Util.getPreferences(context).edit(); + editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0); + editor.commit(); + + count = 0; + update(); + } +} diff --git a/app/src/main/java/github/daneren2005/dsub/view/BasicHeaderView.java b/app/src/main/java/github/daneren2005/dsub/view/BasicHeaderView.java index d8111692..b5dad2d1 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/BasicHeaderView.java +++ b/app/src/main/java/github/daneren2005/dsub/view/BasicHeaderView.java @@ -25,9 +25,12 @@ public class BasicHeaderView extends UpdateView { TextView nameView; public BasicHeaderView(Context context) { + this(context, R.layout.basic_header); + } + public BasicHeaderView(Context context, int layout) { super(context, false); - LayoutInflater.from(context).inflate(R.layout.basic_header, this, true); + LayoutInflater.from(context).inflate(layout, this, true); nameView = (TextView) findViewById(R.id.item_name); } diff --git a/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java b/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java index 62d1672d..44831c60 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java +++ b/app/src/main/java/github/daneren2005/dsub/view/UpdateView.java @@ -288,6 +288,10 @@ public class UpdateView extends LinearLayout { return checkable; } + public void onClick() { + + } + public static class UpdateViewHolder extends RecyclerView.ViewHolder { private UpdateView updateView; private View view; diff --git a/app/src/main/res/layout/album_list_header.xml b/app/src/main/res/layout/album_list_header.xml new file mode 100644 index 00000000..58af3353 --- /dev/null +++ b/app/src/main/res/layout/album_list_header.xml @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/album_list_item.xml b/app/src/main/res/layout/album_list_item.xml index 67c052eb..c43e52a8 100644 --- a/app/src/main/res/layout/album_list_item.xml +++ b/app/src/main/res/layout/album_list_item.xml @@ -3,7 +3,8 @@ android:id="@id/drag_handle" android:orientation="horizontal" android:layout_width="fill_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3 From f632dc5f46943c6a258d5f1cd85c6c6d923c4a3a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 18 Jun 2015 17:26:39 -0700 Subject: Go back to back icon for Now Playing fragment --- .../dsub/activity/SubsonicFragmentActivity.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) 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 08930ae7..db7559b3 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -227,7 +227,6 @@ public class SubsonicFragmentActivity extends SubsonicActivity { drawerToggle.setDrawerIndicatorEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeAsUpIndicator(coverArtView.getDrawable()); } @Override @@ -603,20 +602,15 @@ public class SubsonicFragmentActivity extends SubsonicActivity { artistView.setText(R.string.main_artist); } - if(coverArtView != null && coverArtView.getHeight() != 0) { - 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()); - } - }); - } + if(coverArtView != null) { + int height = coverArtView.getHeight(); + if(height <= 0) { + int[] attrs = new int[] {R.attr.actionBarSize}; + TypedArray typedArray = this.obtainStyledAttributes(attrs); + height = typedArray.getDimensionPixelSize(0, 0); + typedArray.recycle(); } + getImageLoader().loadImage(coverArtView, song, false, height, false); } int[] attrs = new int[] {(state == PlayerState.STARTED) ? R.attr.media_button_pause : R.attr.media_button_start}; -- cgit v1.2.3 From ec59370dd453c2438d194610dbba2b1435ba35f8 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 22 Jun 2015 18:16:31 -0700 Subject: Theme update --- .../dsub/activity/EditPlayActionActivity.java | 2 +- .../dsub/activity/SubsonicActivity.java | 18 +++- .../dsub/activity/SubsonicFragmentActivity.java | 2 +- .../daneren2005/dsub/fragments/MainFragment.java | 2 +- .../dsub/fragments/NowPlayingFragment.java | 2 +- .../dsub/fragments/SelectDirectoryFragment.java | 2 +- .../dsub/fragments/SelectPlaylistFragment.java | 2 +- .../dsub/fragments/SelectPodcastsFragment.java | 2 +- .../dsub/fragments/SelectShareFragment.java | 2 +- .../dsub/fragments/SubsonicFragment.java | 4 +- .../github/daneren2005/dsub/util/UserUtil.java | 2 +- .../java/github/daneren2005/dsub/util/Util.java | 36 +++++--- .../github/daneren2005/dsub/view/ChangeLog.java | 2 +- .../github/daneren2005/dsub/view/ErrorDialog.java | 2 +- .../main/res/layout/abstract_fragment_activity.xml | 27 +++--- app/src/main/res/layout/actionbar_spinner.xml | 21 +++-- app/src/main/res/layout/album_list_header.xml | 5 +- app/src/main/res/layout/album_list_item.xml | 6 +- app/src/main/res/layout/basic_choice_item.xml | 3 +- app/src/main/res/layout/basic_count_item.xml | 4 +- app/src/main/res/layout/basic_header.xml | 2 +- app/src/main/res/layout/basic_list_item.xml | 3 +- app/src/main/res/layout/change_email.xml | 3 +- app/src/main/res/layout/change_password.xml | 3 +- app/src/main/res/layout/chat_item.xml | 11 ++- app/src/main/res/layout/chat_item_reverse.xml | 11 ++- app/src/main/res/layout/complex_list_item.xml | 14 +-- app/src/main/res/layout/confirm_password.xml | 3 +- app/src/main/res/layout/create_bookmark.xml | 3 +- app/src/main/res/layout/create_podcast.xml | 3 +- app/src/main/res/layout/create_user.xml | 9 +- app/src/main/res/layout/download_playlist.xml | 3 +- app/src/main/res/layout/edit_play_action.xml | 15 ++- app/src/main/res/layout/equalizer_bar.xml | 55 ++++++----- app/src/main/res/layout/genre_list_item.xml | 9 +- app/src/main/res/layout/jukebox_volume.xml | 46 ---------- app/src/main/res/layout/lyrics.xml | 101 ++++++++++----------- app/src/main/res/layout/progress.xml | 30 +++--- app/src/main/res/layout/save_playlist.xml | 25 ++--- app/src/main/res/layout/search_buttons.xml | 73 --------------- app/src/main/res/layout/seekbar_preference.xml | 3 +- app/src/main/res/layout/select_album_header.xml | 15 ++- app/src/main/res/layout/select_artist_header.xml | 6 +- app/src/main/res/layout/settings_activity.xml | 33 ++++--- app/src/main/res/layout/shuffle_dialog.xml | 9 +- app/src/main/res/layout/song_list_item.xml | 29 +++--- app/src/main/res/layout/start_timer.xml | 3 +- app/src/main/res/layout/sync_dialog.xml | 3 +- app/src/main/res/layout/tab_progress.xml | 3 +- app/src/main/res/layout/update_playlist.xml | 9 +- app/src/main/res/layout/update_share.xml | 9 +- app/src/main/res/layout/user_header.xml | 6 +- app/src/main/res/layout/user_list_item.xml | 3 +- app/src/main/res/menu/select_album.xml | 2 +- app/src/main/res/menu/select_album_list.xml | 2 +- app/src/main/res/menu/select_song.xml | 2 +- app/src/main/res/menu/select_song_offline.xml | 2 +- app/src/main/res/menu/similar_artists.xml | 2 +- app/src/main/res/values-v16/themes.xml | 15 --- app/src/main/res/values/attrs.xml | 9 ++ app/src/main/res/values/colors.xml | 15 ++- app/src/main/res/values/styles.xml | 32 ------- app/src/main/res/values/themes.xml | 74 ++++++++------- 63 files changed, 397 insertions(+), 457 deletions(-) delete mode 100644 app/src/main/res/layout/jukebox_volume.xml delete mode 100644 app/src/main/res/layout/search_buttons.xml delete mode 100644 app/src/main/res/values-v16/themes.xml diff --git a/app/src/main/java/github/daneren2005/dsub/activity/EditPlayActionActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/EditPlayActionActivity.java index e1f2cad3..0396f8a4 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/EditPlayActionActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/EditPlayActionActivity.java @@ -16,7 +16,7 @@ package github.daneren2005.dsub.activity; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; 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 fe785ef8..f7e7251c 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -35,7 +35,8 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -72,7 +73,7 @@ import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.UpdateView; import github.daneren2005.dsub.util.UserUtil; -public class SubsonicActivity extends ActionBarActivity implements OnItemSelectedListener { +public class SubsonicActivity extends AppCompatActivity implements OnItemSelectedListener { private static final String TAG = SubsonicActivity.class.getSimpleName(); private static ImageLoader IMAGE_LOADER; protected static String theme; @@ -239,10 +240,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte drawerList = (NavigationView) findViewById(R.id.left_drawer); drawerList.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override - public boolean onNavigationItemSelected(MenuItem menuItem) { + public boolean onNavigationItemSelected(final MenuItem menuItem) { if(showingTabs) { // Settings are on a different selectable track - if (menuItem.getItemId() != R.id.drawer_settings) { + if (menuItem.getItemId() != R.id.drawer_settings && menuItem.getItemId() != R.id.drawer_admin) { menuItem.setChecked(true); lastSelectedPosition = menuItem.getItemId(); } @@ -275,10 +276,14 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte @Override public void run() { drawerItemSelected("Admin"); + menuItem.setChecked(true); + lastSelectedPosition = menuItem.getItemId(); } }); } else { drawerItemSelected("Admin"); + menuItem.setChecked(true); + lastSelectedPosition = menuItem.getItemId(); } return true; case R.id.drawer_downloading: @@ -322,7 +327,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(!isTv()) { drawer = (DrawerLayout) findViewById(R.id.drawer_layout); - drawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.common_appname, R.string.common_appname) { + // Pass in toolbar if it exists + Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); + drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.common_appname, R.string.common_appname) { @Override public void onDrawerClosed(View view) { setTitle(currentFragment.getTitle()); @@ -805,6 +812,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte Intent intent = new Intent(this, ((Object) this).getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(getIntent()); + intent.putExtra(Constants.FRAGMENT_POSITION, lastSelectedPosition); Util.startActivityWithoutTransition(this, intent); } 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 db7559b3..95ec7c15 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -613,7 +613,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { getImageLoader().loadImage(coverArtView, song, false, height, false); } - int[] attrs = new int[] {(state == PlayerState.STARTED) ? R.attr.media_button_pause : R.attr.media_button_start}; + int[] attrs = new int[] {(state == PlayerState.STARTED) ? R.attr.actionbar_pause : R.attr.actionbar_start}; TypedArray typedArray = this.obtainStyledAttributes(attrs); startButton.setImageResource(typedArray.getResourceId(0, 0)); typedArray.recycle(); diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java index 90a91383..96e1d326 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java @@ -1,6 +1,6 @@ package github.daneren2005.dsub.fragments; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java index 851e9478..151a66ca 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -21,7 +21,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import android.annotation.TargetApi; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 417b1328..08a051cf 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -1,7 +1,7 @@ package github.daneren2005.dsub.fragments; import android.annotation.TargetApi; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index 2f2cfcc1..49589971 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -1,6 +1,6 @@ package github.daneren2005.dsub.fragments; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.content.res.Resources; import android.os.Bundle; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java index eebb1a8a..520d0414 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java @@ -14,7 +14,7 @@ */ package github.daneren2005.dsub.fragments; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.ContextMenu; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java index 87dd55b4..3d79b7b9 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectShareFragment.java @@ -15,7 +15,7 @@ package github.daneren2005.dsub.fragments; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.ContextMenu; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java index cc9f8d62..a155e807 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -20,7 +20,7 @@ package github.daneren2005.dsub.fragments; import android.annotation.TargetApi; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -34,12 +34,14 @@ import android.os.Bundle; import android.os.StatFs; import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.internal.view.ContextThemeWrapper; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.ContextMenu; import android.view.GestureDetector; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; diff --git a/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java b/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java index fb2de05e..d758c4c9 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java +++ b/app/src/main/java/github/daneren2005/dsub/util/UserUtil.java @@ -16,7 +16,7 @@ package github.daneren2005.dsub.util; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index 0160ddd0..f44bc672 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -19,7 +19,7 @@ package github.daneren2005.dsub.util; import android.annotation.TargetApi; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; @@ -251,34 +251,40 @@ public final class Util { SharedPreferences prefs = getPreferences(context); return prefs.getString(Constants.PREFERENCES_KEY_THEME, null); } - public static void setTheme(Context context, String theme) { - SharedPreferences.Editor editor = getPreferences(context).edit(); - editor.putString(Constants.PREFERENCES_KEY_THEME, theme); - editor.commit(); + public static int getThemeRes(Context context) { + return getThemeRes(context, getTheme(context)); } - - public static void applyTheme(Context context, String theme) { + public static int getThemeRes(Context context, String theme) { if(context instanceof SubsonicFragmentActivity || context instanceof SettingsActivity) { if ("dark".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Dark_No_Actionbar); + return R.style.Theme_DSub_Dark_No_Actionbar; } else if ("black".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Black_No_Actionbar); + return R.style.Theme_DSub_Black_No_Actionbar; } else if ("holo".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Holo_No_Actionbar); + return R.style.Theme_DSub_Holo_No_Actionbar; } else { - context.setTheme(R.style.Theme_DSub_Light_No_Actionbar); + return R.style.Theme_DSub_Light_No_Actionbar; } } else { if ("dark".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Dark); + return R.style.Theme_DSub_Dark; } else if ("black".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Black); + return R.style.Theme_DSub_Black; } else if ("holo".equals(theme)) { - context.setTheme(R.style.Theme_DSub_Holo); + return R.style.Theme_DSub_Holo; } else { - context.setTheme(R.style.Theme_DSub_Light); + return R.style.Theme_DSub_Light; } } + } + public static void setTheme(Context context, String theme) { + SharedPreferences.Editor editor = getPreferences(context).edit(); + editor.putString(Constants.PREFERENCES_KEY_THEME, theme); + editor.commit(); + } + + public static void applyTheme(Context context, String theme) { + context.setTheme(getThemeRes(context, theme)); SharedPreferences prefs = Util.getPreferences(context); if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) { diff --git a/app/src/main/java/github/daneren2005/dsub/view/ChangeLog.java b/app/src/main/java/github/daneren2005/dsub/view/ChangeLog.java index 096583c7..e3d24485 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/ChangeLog.java +++ b/app/src/main/java/github/daneren2005/dsub/view/ChangeLog.java @@ -42,7 +42,7 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; diff --git a/app/src/main/java/github/daneren2005/dsub/view/ErrorDialog.java b/app/src/main/java/github/daneren2005/dsub/view/ErrorDialog.java index 0b9d05a0..3d6eaa52 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/ErrorDialog.java +++ b/app/src/main/java/github/daneren2005/dsub/view/ErrorDialog.java @@ -19,7 +19,7 @@ package github.daneren2005.dsub.view; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; diff --git a/app/src/main/res/layout/abstract_fragment_activity.xml b/app/src/main/res/layout/abstract_fragment_activity.xml index 74a94111..bf8d9640 100644 --- a/app/src/main/res/layout/abstract_fragment_activity.xml +++ b/app/src/main/res/layout/abstract_fragment_activity.xml @@ -1,6 +1,7 @@ + android:elevation="4dp" + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" + app:popupTheme="?attr/actionbarPopupStyle"/> @@ -39,7 +42,9 @@ android:layout_height="?attr/actionBarSize" android:layout_width="match_parent" android:elevation="4dp" - android:visibility="gone"/> + android:visibility="gone" + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" + app:popupTheme="?attr/actionbarPopupStyle"/> + android:focusableInTouchMode="true" + style="?attr/actionbarTitleStyle"> + android:text="@string/main.artist" + style="?attr/actionbarSubtitleStyle"/> @@ -104,21 +105,21 @@ diff --git a/app/src/main/res/layout/actionbar_spinner.xml b/app/src/main/res/layout/actionbar_spinner.xml index 22055901..4d9f95a4 100644 --- a/app/src/main/res/layout/actionbar_spinner.xml +++ b/app/src/main/res/layout/actionbar_spinner.xml @@ -1,13 +1,14 @@ - + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:gravity="fill_horizontal" > + + diff --git a/app/src/main/res/layout/album_list_header.xml b/app/src/main/res/layout/album_list_header.xml index 58af3353..e78d0ace 100644 --- a/app/src/main/res/layout/album_list_header.xml +++ b/app/src/main/res/layout/album_list_header.xml @@ -11,7 +11,7 @@ android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:background="@android:color/transparent" - android:textColor="@color/cyan" + android:textColor="?attr/colorAccent" android:textStyle="bold" android:paddingLeft="6dp" android:paddingRight="6dp" @@ -24,5 +24,6 @@ android:layout_height="wrap_content" android:text="@string/main.albums_per_folder" android:layout_marginRight="6dp" - android:layout_gravity="right"/> + android:layout_gravity="right" + android:textColor="?android:textColorPrimary"/> \ No newline at end of file diff --git a/app/src/main/res/layout/album_list_item.xml b/app/src/main/res/layout/album_list_item.xml index c43e52a8..150cbd8f 100644 --- a/app/src/main/res/layout/album_list_item.xml +++ b/app/src/main/res/layout/album_list_item.xml @@ -44,14 +44,16 @@ android:textAppearance="?android:attr/textAppearanceMedium" android:singleLine="true" android:ellipsize="marquee" - android:paddingBottom="6dip"/> + android:paddingBottom="6dip" + android:textColor="?android:textColorPrimary"/> + android:singleLine="true" + android:textColor="?android:textColorSecondary"/> diff --git a/app/src/main/res/layout/basic_choice_item.xml b/app/src/main/res/layout/basic_choice_item.xml index 00a45be4..e2dc2204 100644 --- a/app/src/main/res/layout/basic_choice_item.xml +++ b/app/src/main/res/layout/basic_choice_item.xml @@ -14,7 +14,8 @@ android:gravity="left|center_vertical" android:paddingLeft="6dip" android:paddingRight="6dip" - android:background="@android:color/transparent"/> + android:background="@android:color/transparent" + android:textColor="?android:textColorPrimary"/> + android:text="Text" + android:textColor="?android:textColorPrimary"/> \ No newline at end of file diff --git a/app/src/main/res/layout/basic_header.xml b/app/src/main/res/layout/basic_header.xml index b5ae900a..b1f94b33 100644 --- a/app/src/main/res/layout/basic_header.xml +++ b/app/src/main/res/layout/basic_header.xml @@ -5,7 +5,7 @@ android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:background="@android:color/transparent" - android:textColor="@color/cyan" + android:textColor="?attr/colorAccent" android:textStyle="bold" android:paddingLeft="6dp" android:paddingRight="6dp" diff --git a/app/src/main/res/layout/basic_list_item.xml b/app/src/main/res/layout/basic_list_item.xml index 88d8ca20..04fdfe06 100644 --- a/app/src/main/res/layout/basic_list_item.xml +++ b/app/src/main/res/layout/basic_list_item.xml @@ -15,7 +15,8 @@ android:paddingLeft="6dip" android:paddingRight="6dip" android:minHeight="50dip" - android:background="@android:color/transparent"/> + android:background="@android:color/transparent" + android:textColor="?android:textColorPrimary"/> + android:text="@string/admin.change_email_label" + android:textColor="?android:textColorPrimary"/> + android:text="@string/admin.change_password_label" + android:textColor="?android:textColorPrimary"/> + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground"> + android:textColor="?android:textColorPrimary"/> + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="?android:textColorSecondary"/> + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:textColorSecondary"/> \ No newline at end of file diff --git a/app/src/main/res/layout/chat_item_reverse.xml b/app/src/main/res/layout/chat_item_reverse.xml index b8102193..31875208 100644 --- a/app/src/main/res/layout/chat_item_reverse.xml +++ b/app/src/main/res/layout/chat_item_reverse.xml @@ -2,7 +2,8 @@ + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground"> + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="?android:textColorSecondary"/> + android:textColor="?android:textColorPrimary"/> + android:layout_gravity="right" + android:textColor="?android:textColorSecondary"/> + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="?android:attr/listPreferredItemHeight" + android:background="?attr/selectableItemBackground"> + android:background="@android:color/transparent" + android:textColor="?android:textColorPrimary"/> + android:background="@android:color/transparent" + android:textColor="?android:textColorSecondary"/> + android:text="@string/admin.add_user_password" + android:textColor="?android:textColorPrimary"/> + android:text="@string/common.comment" + android:textColor="?android:textColorPrimary"/> + android:text="@string/select_podcasts.add_url" + android:textColor="?android:textColorPrimary"/> + android:layout_marginLeft="4dp" + android:textColor="?android:textColorPrimary"/> + android:layout_marginLeft="4dp" + android:textColor="?android:textColorPrimary"/> + android:layout_marginLeft="4dp" + android:textColor="?android:textColorPrimary"/> + android:padding="10dip" + android:textColor="?android:textColorPrimary"/> + android:text="@string/tasker.edit_shuffle_mode" + android:textColor="?android:textColorPrimary"/> + android:text="@string/tasker.edit_shuffle_start_year" + android:textColor="?android:textColorPrimary"/> + android:text="@string/tasker.edit_shuffle_end_year" + android:textColor="?android:textColorPrimary"/> + android:text="@string/tasker.edit_shuffle_genre" + android:textColor="?android:textColorPrimary"/>