Skip to content

Commit 41cb2c9

Browse files
author
maskara
committed
Add drawer to settings activity
1 parent a6bbc8a commit 41cb2c9

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

app/src/main/java/fr/free/nrw/commons/settings/SettingsActivity.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.os.Bundle;
6-
import android.preference.PreferenceActivity;
76
import android.preference.PreferenceManager;
87
import android.support.v7.app.AppCompatDelegate;
98
import android.view.MenuItem;
109

10+
import butterknife.BindView;
11+
import butterknife.ButterKnife;
1112
import fr.free.nrw.commons.R;
13+
import fr.free.nrw.commons.theme.NavigationBaseActivity;
14+
15+
public class SettingsActivity extends NavigationBaseActivity {
16+
private SettingsFragment settingsFragment;
1217

13-
public class SettingsActivity extends PreferenceActivity {
1418
private AppCompatDelegate settingsDelegate;
1519

1620
@Override
@@ -22,11 +26,13 @@ protected void onCreate(Bundle savedInstanceState) {
2226
setTheme(R.style.LightAppTheme);
2327
}
2428

25-
// Display the fragment as the main content.
26-
getFragmentManager().beginTransaction()
27-
.replace(android.R.id.content, new SettingsFragment()).commit();
29+
settingsFragment = (SettingsFragment) getFragmentManager().findFragmentById(R.id.settingsFragment);
2830

2931
super.onCreate(savedInstanceState);
32+
setContentView(R.layout.activity_settings);
33+
34+
ButterKnife.bind(this);
35+
initDrawer();
3036
}
3137

3238
// Get an action bar
@@ -39,7 +45,7 @@ protected void onPostCreate(Bundle savedInstanceState) {
3945
settingsDelegate.onPostCreate(savedInstanceState);
4046

4147
//Get an up button
42-
settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
48+
//settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
4349
}
4450

4551
//Handle action-bar clicks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/drawer_layout"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<RelativeLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent">
11+
12+
<include
13+
android:id="@+id/toolbar"
14+
layout="@layout/toolbar"
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content" />
17+
18+
<fragment
19+
android:id="@+id/settingsFragment"
20+
android:name="fr.free.nrw.commons.settings.SettingsFragment"
21+
android:layout_width="match_parent"
22+
android:layout_height="match_parent"
23+
tools:layout="@xml/preferences"
24+
android:layout_below="@id/toolbar"/>
25+
</RelativeLayout>
26+
27+
<RelativeLayout
28+
android:id="@+id/drawer_pane"
29+
android:layout_width="320dp"
30+
android:layout_height="match_parent"
31+
android:layout_gravity="start"
32+
android:background="@android:color/white">
33+
34+
<FrameLayout
35+
android:id="@+id/drawer_fragment"
36+
android:layout_width="match_parent"
37+
android:layout_height="match_parent" />
38+
</RelativeLayout>
39+
40+
</android.support.v4.widget.DrawerLayout>

0 commit comments

Comments
 (0)