From 9de00f4464e5cab586c578ce6ccb337d3c9416d9 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 15 Jul 2014 15:31:18 -0700 Subject: #368 When trying to enter Admin tab, confirm password for admin users --- .../dsub/activity/SubsonicActivity.java | 34 +++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 92775f3e..a2f8ab22 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -180,22 +180,20 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte drawerList.setOnItemClickListener(new ListView.OnItemClickListener() { @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { + public void onItemClick(AdapterView parent, final View view, final int position, long id) { position = drawerAdapter.getActualPosition(position); if("Settings".equals(drawerItemsDescriptions[position])) { startActivity(new Intent(SubsonicActivity.this, SettingsActivity.class)); drawer.closeDrawers(); - } else { - startFragmentActivity(drawerItemsDescriptions[position]); - - if(lastSelectedView != view) { - if(lastSelectedView != null) { - lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle); + } else if("Admin".equals(drawerItemsDescriptions[position]) && UserUtil.isCurrentAdmin()) { + UserUtil.confirmCredentials(context, new Runnable() { + @Override + public void run() { + drawerItemSelected(position, view); } - lastSelectedView = (TextView) view.findViewById(R.id.drawer_name); - lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle_Bold); - lastSelectedPosition = position; - } + }); + } else { + drawerItemSelected(position, view); } } }); @@ -468,6 +466,20 @@ 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; + } + } public void startFragmentActivity(String fragmentType) { Intent intent = new Intent(); -- cgit v1.2.3