Open the sliding menu only during the first run

This commit is contained in:
Ludovic Fauvet 2012-09-25 21:44:42 +02:00
parent 9fc4262486
commit 7fd4ad78b4

View File

@ -84,6 +84,7 @@ public class MainActivity extends SherlockFragmentActivity {
protected static final String ACTION_SHOW_TEXTINFO = "org.videolan.vlc.gui.ShowTextInfo";
private static final String PREF_SHOW_INFO = "show_info";
private static final String PREF_FIRST_RUN = "first_run";
private ActionBar mActionBar;
private SlidingMenu mMenu;
@ -98,6 +99,7 @@ public class MainActivity extends SherlockFragmentActivity {
private SharedPreferences mSettings;
private int mVersionNumber = -1;
private boolean mFirstRun = false;
public MainActivity() {
}
@ -130,8 +132,27 @@ public class MainActivity extends SherlockFragmentActivity {
listView.setAdapter(mSidebarAdapter);
mMenu.setViewBehind(sidebar);
/* Get the current version from package */
PackageInfo pinfo = null;
try {
pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (NameNotFoundException e) {
Log.e(TAG, "package info not found.");
}
if (pinfo != null)
mVersionNumber = pinfo.versionCode;
/* Get settings */
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
/* Check if it's the first run */
mFirstRun = mSettings.getInt(PREF_FIRST_RUN, -1) != mVersionNumber;
if (mFirstRun) {
Editor editor = mSettings.edit();
editor.putInt(PREF_FIRST_RUN, mVersionNumber);
editor.commit();
}
LibVLC.useIOMX(this);
try {
// Start LibVLC
@ -207,18 +228,9 @@ public class MainActivity extends SherlockFragmentActivity {
.commit();
/* Show info/alpha/beta Warning */
PackageInfo pinfo = null;
try {
pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (NameNotFoundException e) {
Log.e(TAG, "package info not found.");
}
if (pinfo != null) {
mVersionNumber = pinfo.versionCode;
if (mSettings.getInt(PREF_SHOW_INFO, -1) != mVersionNumber)
showInfoDialog();
else {
else if (mFirstRun) {
/*
* The sliding menu is automatically opened when the user closes
* the info dialog. If (for any reason) the dialog is not shown,
@ -232,7 +244,6 @@ public class MainActivity extends SherlockFragmentActivity {
}
}, 500);
}
}
/* Prepare the progressBar */
IntentFilter filter = new IntentFilter();
@ -436,7 +447,8 @@ public class MainActivity extends SherlockFragmentActivity {
}
/* Close the dialog */
infoDialog.dismiss();
/* and finally open the sliding menu */
/* and finally open the sliding menu if first run */
if (mFirstRun)
mMenu.showBehind();
}
});