aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java16
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java2
-rw-r--r--src/github/daneren2005/dsub/util/UserUtil.java17
3 files changed, 21 insertions, 14 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index a2f8ab22..514dea25 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -181,19 +181,19 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {
- position = drawerAdapter.getActualPosition(position);
- if("Settings".equals(drawerItemsDescriptions[position])) {
+ final int actualPosition = drawerAdapter.getActualPosition(position);
+ if("Settings".equals(drawerItemsDescriptions[actualPosition])) {
startActivity(new Intent(SubsonicActivity.this, SettingsActivity.class));
drawer.closeDrawers();
- } else if("Admin".equals(drawerItemsDescriptions[position]) && UserUtil.isCurrentAdmin()) {
- UserUtil.confirmCredentials(context, new Runnable() {
+ } else if("Admin".equals(drawerItemsDescriptions[actualPosition]) && UserUtil.isCurrentAdmin()) {
+ UserUtil.confirmCredentials(SubsonicActivity.this, new Runnable() {
@Override
public void run() {
- drawerItemSelected(position, view);
+ drawerItemSelected(actualPosition, view);
}
});
} else {
- drawerItemSelected(position, view);
+ drawerItemSelected(actualPosition, view);
}
}
});
@@ -472,11 +472,11 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(lastSelectedView != view) {
if(lastSelectedView != null) {
- lastSelectedView.setTextAppearance(this, R.style.Dsub_TextViewStyle);
+ lastSelectedView.setTextAppearance(this, R.style.DSub_TextViewStyle);
}
lastSelectedView = (TextView) view.findViewById(R.id.drawer_name);
- lastSelectedView.setTextAppearance(this, R.style.Dsub_TextViewStyle_Bold);
+ lastSelectedView.setTextAppearance(this, R.style.DSub_TextViewStyle_Bold);
lastSelectedPosition = position;
}
}
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index fc86ad36..561e32c4 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -209,7 +209,7 @@ public class MainFragment extends SubsonicFragment {
}
Util.setActiveServer(context, instance);
context.invalidate();
- UserUtil.refreshCurrentUser(context, false);
+ UserUtil.refreshCurrentUser(context, false, true);
}
}
diff --git a/src/github/daneren2005/dsub/util/UserUtil.java b/src/github/daneren2005/dsub/util/UserUtil.java
index 50ee2b7c..77e07f6b 100644
--- a/src/github/daneren2005/dsub/util/UserUtil.java
+++ b/src/github/daneren2005/dsub/util/UserUtil.java
@@ -49,8 +49,15 @@ public final class UserUtil {
private static User currentUser;
private static long lastVerifiedTime = 0;
+
public static void refreshCurrentUser(Context context, boolean forceRefresh) {
+ refreshCurrentUser(context, forceRefresh, false);
+ }
+ public static void refreshCurrentUser(Context context, boolean forceRefresh, boolean unAuth) {
currentUser = null;
+ if(unAuth) {
+ lastVerifiedTime = 0;
+ }
seedCurrentUser(context, forceRefresh);
}
@@ -141,13 +148,13 @@ public final class UserUtil {
return false;
}
- public static void confirmCredentials(final Context context, final Runnable onSuccess) {
+ public static void confirmCredentials(final Activity context, final Runnable onSuccess) {
final long currentTime = System.currentTimeMillis();
// If already ran this check within last x time, just go ahead and auth
- if((currentTime - lastVerified) < MIN_VERIFY_DURATION) {
+ if((currentTime - lastVerifiedTime) < MIN_VERIFY_DURATION) {
onSuccess.run();
} else {
- View layout = context.getLayoutInflater().inflate(R.layout.verify_password, null);
+ View layout = context.getLayoutInflater().inflate(R.layout.confirm_password, null);
final TextView passwordView = (TextView) layout.findViewById(R.id.password);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
@@ -162,7 +169,7 @@ public final class UserUtil {
String correctPassword = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + Util.getActiveServer(context), null);
if(password != null && password.equals(correctPassword)) {
- lastVerified = currentTime;
+ lastVerifiedTime = currentTime;
onSuccess.run();
} else {
Util.toast(context, R.string.admin_confirm_password_bad);
@@ -170,7 +177,7 @@ public final class UserUtil {
}
})
.setNegativeButton(R.string.common_cancel, null)
- .setCancellable(true);
+ .setCancelable(true);
AlertDialog dialog = builder.create();
dialog.show();