add toolbar and drawer handlers back in

This commit is contained in:
Nathan Freitas 2015-02-02 16:20:46 -05:00
parent 4c49822861
commit 5131c62c3e
1 changed files with 48 additions and 19 deletions

View File

@ -186,6 +186,31 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
{ {
setContentView(R.layout.layout_main); setContentView(R.layout.layout_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.inflateMenu(R.menu.orbot_main);
mToolbar.setTitle(R.string.app_name);
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(
this, mDrawer, mToolbar,
android.R.string.ok, android.R.string.cancel
);
mDrawer.setDrawerListener(mDrawerToggle);
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerToggle.syncState();
mDrawerToggle.setToolbarNavigationClickListener(new OnClickListener ()
{
@Override
public void onClick(View v) {
}
});
setupMenu();
lblStatus = (TextView)findViewById(R.id.lblStatus); lblStatus = (TextView)findViewById(R.id.lblStatus);
lblStatus.setOnLongClickListener(this); lblStatus.setOnLongClickListener(this);
imgStatus = (ImageProgressView)findViewById(R.id.imgStatus); imgStatus = (ImageProgressView)findViewById(R.id.imgStatus);
@ -311,10 +336,14 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
.show(); .show();
} }
@Override private void setupMenu ()
public boolean onOptionsItemSelected(MenuItem item) { {
super.onOptionsItemSelected(item); mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener ()
{
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.menu_start) if (item.getItemId() == R.id.menu_start)
{ {
@ -351,7 +380,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
} }
else if (item.getItemId() == R.id.menu_wizard) else if (item.getItemId() == R.id.menu_wizard)
{ {
startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); startActivity(new Intent(OrbotMainActivity.this, ChooseLocaleWizardActivity.class));
} }
else if (item.getItemId() == R.id.menu_exit) else if (item.getItemId() == R.id.menu_exit)
@ -369,6 +398,12 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
} }
return true; return true;
}
});
} }
/** /**
@ -850,9 +885,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
imgStatus.setImageResource(R.drawable.toron); imgStatus.setImageResource(R.drawable.toron);
mBtnBrowser.setEnabled(true);
mBtnVPN.setEnabled(true);
if (mItemOnOff != null) if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_stop); mItemOnOff.setTitle(R.string.menu_stop);
@ -911,9 +943,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
if (mItemOnOff != null) if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_start); mItemOnOff.setTitle(R.string.menu_start);
mBtnBrowser.setEnabled(false);
mBtnVPN.setEnabled(false);
} }
} }