|
34 | 34 | import android.support.v7.media.MediaRouteSelector;
|
35 | 35 | import android.support.v7.media.MediaRouter;
|
36 | 36 | import android.support.v7.widget.Toolbar;
|
37 |
| -import android.util.DisplayMetrics; |
38 |
| -import android.util.TypedValue; |
39 | 37 | import android.view.KeyEvent;
|
40 | 38 | import android.view.LayoutInflater;
|
41 | 39 | import android.view.Menu;
|
@@ -239,7 +237,7 @@ else if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI)
|
239 | 237 | protected NetworkState currentNetworkState;
|
240 | 238 | protected NetworkMonitor networkMonitor;
|
241 | 239 |
|
242 |
| - NavigationView navigationFooter; |
| 240 | + LinearLayout navigationFooter; |
243 | 241 |
|
244 | 242 | @Override
|
245 | 243 | protected void onCreate(Bundle savedInstanceState) {
|
@@ -847,14 +845,48 @@ public void onDrawerClosed(View drawerView) {
|
847 | 845 | navigationViewMain = (NavigationView) findViewById(R.id.navigationViewMain);
|
848 | 846 |
|
849 | 847 | // Footer view
|
850 |
| - navigationFooter = (NavigationView) findViewById(R.id.navigationViewFooter); |
851 |
| - ViewGroup.LayoutParams layoutParams = navigationFooter.getLayoutParams(); |
852 |
| - TypedValue value = new TypedValue(); |
853 |
| - getTheme().resolveAttribute(android.R.attr.listPreferredItemHeight, value, true); |
854 |
| - DisplayMetrics metrics = new DisplayMetrics(); |
855 |
| - getWindowManager().getDefaultDisplay().getMetrics(metrics); |
856 |
| - layoutParams.height = (int)value.getDimension(metrics)*navigationFooter.getMenu().size(); |
857 |
| - navigationFooter.setLayoutParams(layoutParams); |
| 848 | + navigationFooter = (LinearLayout) findViewById(R.id.navigationViewFooter); |
| 849 | + |
| 850 | + final LinearLayout navigationFooterHelpButton = (LinearLayout)navigationFooter.findViewById(R.id.navigationFooterHelpButton); |
| 851 | + navigationFooterHelpButton.setOnClickListener(new View.OnClickListener() { |
| 852 | + @Override |
| 853 | + public void onClick(View v) { |
| 854 | + navigationFooterHelpButton.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.primary_600)); |
| 855 | + handler.postDelayed(new Runnable() { |
| 856 | + @Override |
| 857 | + public void run() { |
| 858 | + navigationFooterHelpButton.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.navigation_drawer_background)); |
| 859 | + } |
| 860 | + }, 200); |
| 861 | + AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); |
| 862 | + View view = getLayoutInflater().inflate(R.layout.help_dialog, null); |
| 863 | + builder.setView(view); |
| 864 | + final AlertDialog usageDialog = builder.create(); |
| 865 | + Button button = (Button)view.findViewById(R.id.helpCloseButton); |
| 866 | + button.setOnClickListener(new View.OnClickListener() { |
| 867 | + @Override |
| 868 | + public void onClick(View v) { |
| 869 | + usageDialog.dismiss(); |
| 870 | + } |
| 871 | + }); |
| 872 | + usageDialog.show(); |
| 873 | + } |
| 874 | + }); |
| 875 | + |
| 876 | + final LinearLayout navigationFooterSettingsButton = (LinearLayout)navigationFooter.findViewById(R.id.navigationFooterSettingsButton); |
| 877 | + navigationFooterSettingsButton.setOnClickListener(new View.OnClickListener() { |
| 878 | + @Override |
| 879 | + public void onClick(View v) { |
| 880 | + navigationFooterSettingsButton.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.primary_600)); |
| 881 | + handler.postDelayed(new Runnable() { |
| 882 | + @Override |
| 883 | + public void run() { |
| 884 | + navigationFooterSettingsButton.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.navigation_drawer_background)); |
| 885 | + setNavGroup(R.menu.nav_items_settings); |
| 886 | + } |
| 887 | + }, 200); |
| 888 | + } |
| 889 | + }); |
858 | 890 |
|
859 | 891 | if(navigationViewMain.getHeaderView(0) != null)
|
860 | 892 | navigationViewMain.removeHeaderView(navigationViewMain.getHeaderView(0));
|
@@ -1125,25 +1157,6 @@ public void navMenuSettingsBack(MenuItem item) {
|
1125 | 1157 | setNavGroup(R.menu.nav_items_main);
|
1126 | 1158 | }
|
1127 | 1159 |
|
1128 |
| - public void navMenuSettings(MenuItem item) { |
1129 |
| - setNavGroup(R.menu.nav_items_settings); |
1130 |
| - } |
1131 |
| - |
1132 |
| - public void navMenuHelp(MenuItem item) { |
1133 |
| - AlertDialog.Builder builder = new AlertDialog.Builder(this); |
1134 |
| - View view = getLayoutInflater().inflate(R.layout.help_dialog, null); |
1135 |
| - builder.setView(view); |
1136 |
| - final AlertDialog usageDialog = builder.create(); |
1137 |
| - Button button = (Button)view.findViewById(R.id.helpCloseButton); |
1138 |
| - button.setOnClickListener(new View.OnClickListener() { |
1139 |
| - @Override |
1140 |
| - public void onClick(View v) { |
1141 |
| - usageDialog.dismiss(); |
1142 |
| - } |
1143 |
| - }); |
1144 |
| - usageDialog.show(); |
1145 |
| - } |
1146 |
| - |
1147 | 1160 | private void setNavGroup(int group) {
|
1148 | 1161 | navigationViewMain.getMenu().clear();
|
1149 | 1162 | navigationViewMain.inflateMenu(group);
|
|
0 commit comments