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 --- .../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 ++ 4 files changed, 140 insertions(+), 82 deletions(-) delete mode 100644 app/src/main/res/layout/abstract_fragment_container.xml (limited to 'app/src/main/res') 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 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 (limited to 'app/src/main/res') 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 (limited to 'app/src/main/res') 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 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 (limited to 'app/src/main/res') 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"/>