I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0ebecd9b authored by str4d's avatar str4d
Browse files

Changed navbar first-use mechanics to match Android design pattern

parent c062a0f8
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,6 @@
- Move help content from release notes to help page
- Rewrite release notes to be release-specific
- Fill out help page
- Change navbar first-open mechanics to match Android design docs
# Short-term
......
......@@ -63,6 +63,7 @@ public abstract class I2PActivityBase extends ActionBarActivity implements
protected static final String PREF_AUTO_START = "autoStart";
/** true leads to a poor install experience, very slow to paint the screen */
protected static final boolean DEFAULT_AUTO_START = false;
protected static final String PREF_NAV_DRAWER_OPENED = "navDrawerOpened";
/**
* Override this in subclasses that need a ViewPager, such as a
......@@ -122,18 +123,30 @@ public abstract class I2PActivityBase extends ActionBarActivity implements
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
private boolean wasDragged = false;
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
// Don't mark as opened if the user closed by dragging
// but uses the action bar icon to open
wasDragged = false;
getSupportActionBar().setTitle(mTitle);
supportInvalidateOptionsMenu();
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View view) {
if (wasDragged && !getPref(PREF_NAV_DRAWER_OPENED, false))
setPref(PREF_NAV_DRAWER_OPENED, true);
getSupportActionBar().setTitle(mDrawerTitle);
supportInvalidateOptionsMenu();
}
/** Called when the drawer motion state changes. */
public void onDrawerStateChanged(int newState) {
if (newState == DrawerLayout.STATE_DRAGGING)
wasDragged = true;
}
};
// Set the drawer toggle as the DrawerListener
......@@ -220,6 +233,11 @@ public abstract class I2PActivityBase extends ActionBarActivity implements
bindRouter(false);
}
/** @param def default */
public boolean getPref(String pref, boolean def) {
return _sharedPrefs.getBoolean(pref, def);
}
/** @param def default */
public String getPref(String pref, String def) {
return _sharedPrefs.getString(pref, def);
......
......@@ -20,8 +20,7 @@ import net.i2p.android.router.service.RouterService;
import net.i2p.android.router.util.Util;
public class MainActivity extends I2PActivityBase implements
MainFragment.RouterControlListener,
VersionDialog.VersionDialogListener {
MainFragment.RouterControlListener {
IRouterState mStateService = null;
MainFragment mMainFragment = null;
......@@ -36,6 +35,10 @@ public class MainActivity extends I2PActivityBase implements
getSupportFragmentManager().beginTransaction()
.add(R.id.main_fragment, mMainFragment).commit();
}
// Open nav drawer if the user has never opened it themselves
if (!getPref(PREF_NAV_DRAWER_OPENED, false))
mDrawerLayout.openDrawer(mDrawerList);
}
@Override
......@@ -234,10 +237,4 @@ public class MainActivity extends I2PActivityBase implements
}
return false;
}
// VersionDialog.VersionDialogListener
public void onFirstRun() {
mDrawerLayout.openDrawer(mDrawerList);
}
}
......@@ -2,7 +2,6 @@ package net.i2p.android.router;
import net.i2p.android.router.R;
import net.i2p.android.router.util.Util;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
......@@ -15,27 +14,6 @@ public class VersionDialog extends DialogFragment {
protected static final int DIALOG_NEW_INSTALL = 0;
protected static final int DIALOG_NEW_VERSION = 1;
public interface VersionDialogListener {
public void onFirstRun();
}
VersionDialogListener mListener;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// Verify that the host activity implements the callback interface
try {
// Instantiate the VersionDialogListener so we can tell the host
// if this is a new install.
mListener = (VersionDialogListener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
+ " must implement VersionDialogListener");
}
}
@Override
public Dialog onCreateDialog(Bundle SavedInstanceState) {
final String currentVersion = Util.getOurVersion(getActivity());
......@@ -51,15 +29,14 @@ public class VersionDialog extends DialogFragment {
public void onClick(DialogInterface dialog, int id) {
I2PActivityBase ab = (I2PActivityBase) getActivity();
ab.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
mListener.onFirstRun();
dialog.dismiss();
}
}).setNeutralButton(R.string.label_release_notes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
I2PActivityBase ab = (I2PActivityBase) getActivity();
ab.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
dialog.dismiss();
TextResourceDialog f = new TextResourceDialog();
Bundle args = new Bundle();
args.putInt(TextResourceDialog.TEXT_RESOURCE_ID, R.raw.releasenotes_txt);
......@@ -75,7 +52,7 @@ public class VersionDialog extends DialogFragment {
public void onClick(DialogInterface dialog, int id) {
I2PActivityBase ab = (I2PActivityBase) getActivity();
ab.setPref(MainFragment.PREF_INSTALLED_VERSION, currentVersion);
dialog.cancel();
dialog.dismiss();
Intent intent = new Intent(getActivity(), LicenseActivity.class);
startActivity(intent);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment