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 +- 14 files changed, 48 insertions(+), 32 deletions(-) (limited to 'app/src/main/java') 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; -- cgit v1.2.3