mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Add drawer to settings activity
This commit is contained in:
parent
a6bbc8a33b
commit
41cb2c9769
2 changed files with 52 additions and 6 deletions
|
|
@ -3,14 +3,18 @@ package fr.free.nrw.commons.settings;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.AppCompatDelegate;
|
import android.support.v7.app.AppCompatDelegate;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||||
|
|
||||||
|
public class SettingsActivity extends NavigationBaseActivity {
|
||||||
|
private SettingsFragment settingsFragment;
|
||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity {
|
|
||||||
private AppCompatDelegate settingsDelegate;
|
private AppCompatDelegate settingsDelegate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -22,11 +26,13 @@ public class SettingsActivity extends PreferenceActivity {
|
||||||
setTheme(R.style.LightAppTheme);
|
setTheme(R.style.LightAppTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the fragment as the main content.
|
settingsFragment = (SettingsFragment) getFragmentManager().findFragmentById(R.id.settingsFragment);
|
||||||
getFragmentManager().beginTransaction()
|
|
||||||
.replace(android.R.id.content, new SettingsFragment()).commit();
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_settings);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
initDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an action bar
|
// Get an action bar
|
||||||
|
|
@ -39,7 +45,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||||
settingsDelegate.onPostCreate(savedInstanceState);
|
settingsDelegate.onPostCreate(savedInstanceState);
|
||||||
|
|
||||||
//Get an up button
|
//Get an up button
|
||||||
settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
//settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle action-bar clicks
|
//Handle action-bar clicks
|
||||||
|
|
|
||||||
40
app/src/main/res/layout/activity_settings.xml
Normal file
40
app/src/main/res/layout/activity_settings.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/settingsFragment"
|
||||||
|
android:name="fr.free.nrw.commons.settings.SettingsFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:layout="@xml/preferences"
|
||||||
|
android:layout_below="@id/toolbar"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue