Browse Source

Added a button to open the drawer

pull/70/head
babaliaris 4 years ago
parent
commit
7c32f11a62
  1. 18
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  2. 16
      app/src/main/res/layout/activity_main.xml
  3. 1
      app/src/main/res/values/strings.xml

18
app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java

@ -5,6 +5,8 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatDelegate;
@ -57,6 +59,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
private SectionsPagerAdapter sectionsPagerAdapter;
private ViewPager viewPager;
private TabLayout tabLayout;
private ImageView drawerButton;
//Fix for vector drawables on android <21
static {
@ -89,6 +92,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
tabLayout = findViewById(R.id.tabs);
viewPager = findViewById(R.id.container);
drawerButton = findViewById(R.id.main_activity_open_drawer_btn);
//Create the adapter that will return a fragment for each section of the activity
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
@ -110,6 +114,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
updateTabIcon(i);
setMainActivity(this);
setDrawerButtonListener();
}
@Override
@ -287,4 +292,17 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
}
}
}
private void setDrawerButtonListener()
{
this.drawerButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
drawer.openDrawer();
}
});
}
}

16
app/src/main/res/layout/activity_main.xml

@ -14,6 +14,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ToolbarTheme">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/main_activity_open_drawer_btn"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:contentDescription="@string/drawer_button_cnt_desc"
app:srcCompat="@drawable/ic_launcher_foreground" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
@ -24,6 +38,8 @@
app:tabSelectedTextColor="@color/accent"
app:tabTextColor="@color/white"
app:tabIconTint="@color/activity_main_tabs_selector" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager

1
app/src/main/res/values/strings.xml

@ -234,5 +234,6 @@
<!--SessionManager-->
<string name="session_shared_prefs">SessionSharedPrefs</string>
<string name="drawer_button_cnt_desc">Button to open the drawer menu</string>
</resources>

Loading…
Cancel
Save