|
@@ -21,6 +21,8 @@ import android.support.v4.app.ActionBarDrawerToggle;
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
import android.support.v4.widget.DrawerLayout;
|
|
import android.support.v4.widget.DrawerLayout;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
+import android.view.Gravity;
|
|
|
|
+import android.view.KeyEvent;
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.widget.AdapterView;
|
|
import android.widget.AdapterView;
|
|
@@ -258,7 +260,7 @@ public class MainActivity extends Activity {
|
|
}
|
|
}
|
|
|
|
|
|
public void stopAndUnbind() {
|
|
public void stopAndUnbind() {
|
|
- if(mServiceBound){
|
|
+ if(mHoneyService != null){
|
|
unbindService();
|
|
unbindService();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -281,6 +283,7 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
|
|
+ super.onDestroy();
|
|
|
|
|
|
unregisterReceiver();
|
|
unregisterReceiver();
|
|
|
|
|
|
@@ -288,7 +291,6 @@ public class MainActivity extends Activity {
|
|
if(!mHoneyService.hasRunningListeners()){
|
|
if(!mHoneyService.hasRunningListeners()){
|
|
stopAndUnbind();
|
|
stopAndUnbind();
|
|
}
|
|
}
|
|
- super.onDestroy();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -307,8 +309,10 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
UpNavigatible upNav = (UpNavigatible) this.mDisplayedFragment;
|
|
UpNavigatible upNav = (UpNavigatible) this.mDisplayedFragment;
|
|
|
|
|
|
- getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
+ getFragmentManager().popBackStackImmediate(upNav.getUpFragment().getName(), 0);
|
|
- Fragment frag = null;
|
|
+ this.mDisplayedFragment = getFragmentManager().findFragmentById(R.id.content_frame);
|
|
|
|
+ configureFragment();
|
|
|
|
+
|
|
|
|
|
|
try{
|
|
try{
|
|
frag = (Fragment) upNav.getUpFragment().newInstance();
|
|
frag = (Fragment) upNav.getUpFragment().newInstance();
|
|
@@ -318,7 +322,7 @@ public class MainActivity extends Activity {
|
|
Log.i(null, "Could not create new instance of fragment");
|
|
Log.i(null, "Could not create new instance of fragment");
|
|
}
|
|
}
|
|
|
|
|
|
- if(frag != null) this.injectFragment(frag);
|
|
+ if(frag != null) this.injectFragment(frag);*/
|
|
|
|
|
|
if(!(this.mDisplayedFragment instanceof UpNavigatible) || !((UpNavigatible) this.mDisplayedFragment).isUpNavigatible()){
|
|
if(!(this.mDisplayedFragment instanceof UpNavigatible) || !((UpNavigatible) this.mDisplayedFragment).isUpNavigatible()){
|
|
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
@@ -384,42 +388,6 @@ public class MainActivity extends Activity {
|
|
Log.i(menuItemPosition.getKlass().toString(), "Could not create new instance of fragment");
|
|
Log.i(menuItemPosition.getKlass().toString(), "Could not create new instance of fragment");
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- case HOME:
|
|
|
|
- fragment = new HomeFragment();
|
|
|
|
- break;
|
|
|
|
- case THREAT_MAP:
|
|
|
|
- fragment = new ThreatMapFragment();
|
|
|
|
- break;
|
|
|
|
- case RECORDS:{
|
|
|
|
- Intent intent = this.getIntent();
|
|
|
|
- intent.removeExtra(LogFilter.LOG_FILTER_INTENT_KEY);
|
|
|
|
- fragment = new RecordOverviewFragment();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case STATISTICS: {
|
|
|
|
- Intent intent = this.getIntent();
|
|
|
|
- intent.removeExtra(LogFilter.LOG_FILTER_INTENT_KEY);
|
|
|
|
- fragment = new StatisticsFragment();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case SERVICES:
|
|
|
|
- fragment = new ServicesFragment();
|
|
|
|
- break;
|
|
|
|
- case PROFILE_MANAGER:
|
|
|
|
- fragment = new ProfileManagerFragment();
|
|
|
|
- break;
|
|
|
|
- case SETTINGS:
|
|
|
|
- fragment = new SettingsFragment();
|
|
|
|
- break;
|
|
|
|
- case APPLICATION_INFO:
|
|
|
|
- fragment = new AboutFragment();
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
if (fragment != null) {
|
|
if (fragment != null) {
|
|
|
|
|
|
injectFragment(fragment);
|
|
injectFragment(fragment);
|
|
@@ -500,6 +468,23 @@ public class MainActivity extends Activity {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean onKeyDown(int keycode, KeyEvent e) {
|
|
|
|
+ switch(keycode) {
|
|
|
|
+ case KeyEvent.KEYCODE_MENU:
|
|
|
|
+ if(this.mDrawerToggle.isDrawerIndicatorEnabled()){
|
|
|
|
+ if(this.mDrawerLayout.isDrawerOpen(Gravity.LEFT)){
|
|
|
|
+ this.mDrawerLayout.closeDrawer(Gravity.LEFT);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ this.mDrawerLayout.openDrawer(Gravity.LEFT);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return super.onKeyDown(keycode, e);
|
|
|
|
+ }
|
|
|
|
+
|
|
public static void displayBackStack(FragmentManager fm) {
|
|
public static void displayBackStack(FragmentManager fm) {
|
|
int count = fm.getBackStackEntryCount();
|
|
int count = fm.getBackStackEntryCount();
|
|
Log.d("Backstack log", "There are " + count + " entries");
|
|
Log.d("Backstack log", "There are " + count + " entries");
|