1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-29 02:59:57 +02:00

added drawer header

This commit is contained in:
OliE
2018-01-01 15:20:56 +01:00
parent b5fcb9525f
commit 0f7ae23da4
11 changed files with 44 additions and 14 deletions

View File

@@ -57,13 +57,13 @@ public class MainActivity extends AppCompatActivity {
private static boolean firstAppStart = true; private static boolean firstAppStart = true;
private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled; private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled;
private static MenuItem bluetoothStatus; private static MenuItem bluetoothStatus;
private static CharSequence fragmentTitle;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private Toolbar toolbar; private Toolbar toolbar;
private NavigationView navDrawer; private NavigationView navDrawer;
private ActionBarDrawerToggle drawerToggle; private ActionBarDrawerToggle drawerToggle;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -104,8 +104,11 @@ public class MainActivity extends AppCompatActivity {
// Initial first fragment // Initial first fragment
if(savedInstanceState == null) { if(savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_content,new OverviewFragment()).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_content,new OverviewFragment()).commit();
fragmentTitle = getString(R.string.title_overview);
} }
setTitle(fragmentTitle);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("firstStart", true)) { if (prefs.getBoolean("firstStart", true)) {
@@ -149,6 +152,9 @@ public class MainActivity extends AppCompatActivity {
case R.id.nav_statistic: case R.id.nav_statistic:
fragmentClass = StatisticsFragment.class; fragmentClass = StatisticsFragment.class;
break; break;
case R.id.nav_settings:
startActivityForResult(new Intent(this, SettingsActivity.class), 1);
return;
default: default:
fragmentClass = OverviewFragment.class; fragmentClass = OverviewFragment.class;
} }
@@ -168,7 +174,8 @@ public class MainActivity extends AppCompatActivity {
menuItem.setChecked(true); menuItem.setChecked(true);
// Set action bar title // Set action bar title
//setTitle(menuItem.getTitle()); setTitle(menuItem.getTitle());
fragmentTitle = menuItem.getTitle();
// Close the navigation drawer // Close the navigation drawer
drawerLayout.closeDrawers(); drawerLayout.closeDrawers();
@@ -185,10 +192,6 @@ public class MainActivity extends AppCompatActivity {
case android.R.id.home: case android.R.id.home:
drawerLayout.openDrawer(GravityCompat.START); drawerLayout.openDrawer(GravityCompat.START);
return true; return true;
case R.id.action_general_settings:
Intent intent = new Intent(this, SettingsActivity.class);
startActivityForResult(intent, 1);
return true;
case R.id.action_bluetooth_status: case R.id.action_bluetooth_status:
invokeSearchBluetoothDevice(); invokeSearchBluetoothDevice();
return true; return true;

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -39,6 +39,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start" android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer_view" /> app:menu="@menu/drawer_view" />
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/blue_pressed">
<ImageView
android:id="@+id/profileImageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher_openscale"
android:layout_gravity="left|top"
android:layout_margin="20dp" />
<TextView
android:id="@+id/nameTxt"
android:text="@string/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_gravity="center"/>
</LinearLayout>

View File

@@ -8,10 +8,4 @@
android:icon="@drawable/ic_bluetooth_disabled" android:icon="@drawable/ic_bluetooth_disabled"
android:title="@string/action_bluetooth_status" android:title="@string/action_bluetooth_status"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_general_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never"/>
</menu> </menu>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single"> <group android:id="@+id/menu_top"
android:checkableBehavior="single">
<item <item
android:id="@+id/nav_overview" android:id="@+id/nav_overview"
@@ -23,4 +24,12 @@
android:title="@string/title_statistics" /> android:title="@string/title_statistics" />
</group> </group>
</menu> <group android:id="@+id/menu_bottom"
android:checkableBehavior="none">
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_preferences_settings"
android:title="@string/action_settings" />
</group>
</menu>