summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/MainActivity.java19
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java23
2 files changed, 33 insertions, 9 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
index 32b4562a..f2e333ab 100644
--- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
@@ -20,10 +20,12 @@ package se.leap.bitmaskclient;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.support.annotation.StringRes;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@@ -108,6 +110,7 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener,
bundle.putParcelable(PROVIDER_KEY, provider);
eipFragment.setArguments(bundle);
fragmentManagerEnhanced.replace(R.id.main_container, eipFragment, MainActivity.TAG);
+ hideActionBarSubTitle();
} else {
super.onBackPressed();
}
@@ -135,9 +138,11 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener,
}
bundle.putParcelable(PROVIDER_KEY, provider);
fragment.setArguments(bundle);
+ hideActionBarSubTitle();
break;
case ACTION_SHOW_LOG_FRAGMENT:
fragment = new LogFragment();
+ setActionBarTitle(R.string.log_fragment_title);
break;
default:
break;
@@ -152,6 +157,19 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener,
}
}
+ private void hideActionBarSubTitle() {
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(null);
+ }
+ }
+ private void setActionBarTitle(@StringRes int stringId) {
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(stringId);
+ }
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
@@ -190,6 +208,7 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener,
fragment.setArguments(arguments);
new FragmentManagerEnhanced(getSupportFragmentManager())
.replace(R.id.main_container, fragment, EipFragment.TAG);
+ hideActionBarSubTitle();
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
index cc93fc96..640c143a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
@@ -27,6 +27,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
+import android.support.annotation.StringRes;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
@@ -118,8 +119,6 @@ public class NavigationDrawerFragment extends Fragment {
private volatile boolean wasPaused;
private volatile boolean shouldCloseOnResume;
- private String title;
-
private SharedPreferences preferences;
private final static String KEY_SHOW_ENABLE_EXPERIMENTAL_FEATURE = "KEY_SHOW_ENABLE_EXPERIMENTAL_FEATURE";
@@ -282,6 +281,7 @@ public class NavigationDrawerFragment extends Fragment {
final ActionBar actionBar = activity.getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
+ actionBar.setDisplayShowTitleEnabled(true);
return actionBar;
}
@@ -461,12 +461,12 @@ public class NavigationDrawerFragment extends Fragment {
Fragment fragment = null;
if (parent == drawerAccountsListView) {
- title = getString(R.string.vpn_fragment_title);
fragment = new EipFragment();
Bundle arguments = new Bundle();
Provider currentProvider = getSavedProviderFromSharedPreferences(preferences);
arguments.putParcelable(PROVIDER_KEY, currentProvider);
fragment.setArguments(arguments);
+ hideActionBarSubTitle();
} else {
DrawerSettingsItem settingsItem = settingsListAdapter.getItem(position);
switch (settingsItem.getItemType()) {
@@ -474,12 +474,12 @@ public class NavigationDrawerFragment extends Fragment {
getActivity().startActivityForResult(new Intent(getActivity(), ProviderListActivity.class), REQUEST_CODE_SWITCH_PROVIDER);
break;
case LOG:
- title = getString(log_fragment_title);
fragment = new LogFragment();
+ setActionBarTitle(log_fragment_title);
break;
case ABOUT:
- title = getString(about_fragment_title);
fragment = new AboutFragment();
+ setActionBarTitle(about_fragment_title);
break;
case ALWAYS_ON:
if (getShowAlwaysOnDialog(getContext())) {
@@ -503,14 +503,19 @@ public class NavigationDrawerFragment extends Fragment {
fragmentManager.replace(R.id.main_container, fragment, MainActivity.TAG);
}
- restoreActionBar();
}
- public void restoreActionBar() {
+ private void setActionBarTitle(@StringRes int resId) {
+ ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(resId);
+ }
+ }
+
+ private void hideActionBarSubTitle() {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setSubtitle(title);
+ actionBar.setSubtitle(null);
}
}