mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-28 10:40:47 +02:00
added drawer header
This commit is contained in:
@@ -57,13 +57,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
private static boolean firstAppStart = true;
|
||||
private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled;
|
||||
private static MenuItem bluetoothStatus;
|
||||
private static CharSequence fragmentTitle;
|
||||
|
||||
private DrawerLayout drawerLayout;
|
||||
private Toolbar toolbar;
|
||||
private NavigationView navDrawer;
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -104,8 +104,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
// Initial first fragment
|
||||
if(savedInstanceState == null) {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_content,new OverviewFragment()).commit();
|
||||
fragmentTitle = getString(R.string.title_overview);
|
||||
}
|
||||
|
||||
setTitle(fragmentTitle);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if (prefs.getBoolean("firstStart", true)) {
|
||||
@@ -149,6 +152,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
case R.id.nav_statistic:
|
||||
fragmentClass = StatisticsFragment.class;
|
||||
break;
|
||||
case R.id.nav_settings:
|
||||
startActivityForResult(new Intent(this, SettingsActivity.class), 1);
|
||||
return;
|
||||
default:
|
||||
fragmentClass = OverviewFragment.class;
|
||||
}
|
||||
@@ -168,7 +174,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
menuItem.setChecked(true);
|
||||
|
||||
// Set action bar title
|
||||
//setTitle(menuItem.getTitle());
|
||||
setTitle(menuItem.getTitle());
|
||||
fragmentTitle = menuItem.getTitle();
|
||||
|
||||
// Close the navigation drawer
|
||||
drawerLayout.closeDrawers();
|
||||
@@ -185,10 +192,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
case android.R.id.home:
|
||||
drawerLayout.openDrawer(GravityCompat.START);
|
||||
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:
|
||||
invokeSearchBluetoothDevice();
|
||||
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 |
@@ -39,6 +39,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/drawer_header"
|
||||
app:menu="@menu/drawer_view" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
23
android_app/app/src/main/res/layout/drawer_header.xml
Normal file
23
android_app/app/src/main/res/layout/drawer_header.xml
Normal 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>
|
@@ -8,10 +8,4 @@
|
||||
android:icon="@drawable/ic_bluetooth_disabled"
|
||||
android:title="@string/action_bluetooth_status"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_general_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<group android:checkableBehavior="single">
|
||||
<group android:id="@+id/menu_top"
|
||||
android:checkableBehavior="single">
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_overview"
|
||||
@@ -23,4 +24,12 @@
|
||||
android:title="@string/title_statistics" />
|
||||
|
||||
</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>
|
Reference in New Issue
Block a user