Remove ActionBarDrawerToggle

pull/281/head
Alex Baker 10 years ago
parent fe94ab5814
commit 8e909a26ba

@ -11,6 +11,7 @@ import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
@ -82,11 +83,20 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
supportActionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
navigationDrawer.openDrawer();
}
});
navigationDrawer = getNavigationDrawerFragment();
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationDrawer.setUp(drawerLayout);
initializeFragments();
@ -129,10 +139,6 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (isDrawerOpen()) {
return super.onCreateOptionsMenu(menu);
}
getMenuInflater().inflate(R.menu.task_list_activity, menu);
TaskListFragment tlf = getTaskListFragment();
if (tlf instanceof GtasksListFragment) {
@ -330,10 +336,7 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
Filter newList = data.getParcelableExtra(TagSettingsActivity.TOKEN_NEW_FILTER);
if (newList != null) {
getIntent().putExtra(TOKEN_SWITCH_TO_FILTER, newList); // Handle in onPostResume()
NavigationDrawerFragment navigationDrawer = getNavigationDrawerFragment();
if (navigationDrawer != null) {
navigationDrawer.clear();
}
navigationDrawer.clear();
}
} else if (requestCode == TaskListFragment.ACTIVITY_EDIT_TASK && resultCode != Activity.RESULT_CANCELED) {
// Handle switch to assigned filter when it comes from TaskEditActivity finishing
@ -358,7 +361,6 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
TaskListFragment tlf = getTaskListFragment();
if (AstridApiConstants.BROADCAST_EVENT_TAG_DELETED.equals(action)) {
NavigationDrawerFragment navigationDrawer = getNavigationDrawerFragment();
if (tlf != null) {
TagData tagData = tlf.getActiveTagData();
String activeUuid = RemoteModel.NO_UUID;
@ -374,9 +376,7 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
}
}
if (navigationDrawer != null) {
navigationDrawer.refresh();
}
navigationDrawer.refresh();
} else if (AstridApiConstants.BROADCAST_EVENT_TAG_RENAMED.equals(action)) {
if (tlf != null) {
TagData td = tlf.getActiveTagData();
@ -391,20 +391,14 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
}
}
NavigationDrawerFragment navigationDrawer = getNavigationDrawerFragment();
if (navigationDrawer != null) {
navigationDrawer.refresh();
}
navigationDrawer.refresh();
} else if (AstridApiConstants.BROADCAST_EVENT_FILTER_DELETED.equals(action)) {
StoreObject storeObject = (StoreObject) data.getExtras().get(DeleteFilterActivity.TOKEN_STORE_OBJECT);
Filter filter = SavedFilter.load(storeObject);
if (tlf.getFilter().equals(filter)) {
getIntent().putExtra(TOKEN_SWITCH_TO_FILTER, BuiltInFilterExposer.getMyTasksFilter(getResources())); // Handle in onPostResume()
}
NavigationDrawerFragment navigationDrawer = getNavigationDrawerFragment();
if (navigationDrawer != null) {
navigationDrawer.refresh();
}
navigationDrawer.refresh();
}
}
@ -416,13 +410,10 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
}
private void tagsChanged(boolean onActivityResult) {
NavigationDrawerFragment navigationDrawer = getNavigationDrawerFragment();
if (navigationDrawer != null) {
if (onActivityResult) {
navigationDrawer.clear();
} else {
navigationDrawer.refresh();
}
if (onActivityResult) {
navigationDrawer.clear();
} else {
navigationDrawer.refresh();
}
}
@ -434,10 +425,7 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
}
public void refreshFilterCount() {
NavigationDrawerFragment navigationDrawer = getNavigationDrawerFragment();
if (navigationDrawer != null) {
navigationDrawer.refreshFilterCount();
}
navigationDrawer.refreshFilterCount();
}
@Override

@ -6,13 +6,11 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.view.ContextMenu;
import android.view.KeyEvent;
@ -75,11 +73,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
*/
private OnFilterItemClickedListener mCallbacks;
/**
* Helper component that ties the action bar to the navigation drawer.
*/
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private ListView mDrawerListView;
private View mFragmentContainerView;
@ -92,9 +85,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
@Inject GeofenceService geofenceService;
@Inject Preferences preferences;
public NavigationDrawerFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -107,8 +97,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Indicate that this fragment would like to influence the set of actions in the action bar.
setHasOptionsMenu(true);
getActivity().setDefaultKeyMode(Activity.DEFAULT_KEYS_SEARCH_LOCAL);
@ -182,50 +170,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
mDrawerToggle = new ActionBarDrawerToggle(
getActivity(), /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
R.string.navigation_drawer_close /* "close drawer" description for accessibility */
) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, 0);
}
};
// Defer code dependent on restoration of previous instance state.
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
@Override
@ -273,13 +217,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
outState.putInt(TOKEN_LAST_SELECTED, mCurrentSelectedPosition);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Forward the new configuration the drawer toggle component.
mDrawerToggle.onConfigurationChanged(newConfig);
}
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
// called when context menu appears
@ -288,10 +225,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
switch (item.getItemId()) {
case CONTEXT_MENU_SHORTCUT: {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
@ -396,6 +329,12 @@ public class NavigationDrawerFragment extends InjectingFragment {
}
}
public void openDrawer() {
if (mDrawerLayout != null) {
mDrawerLayout.openDrawer(mFragmentContainerView);
}
}
public void refreshFilterCount() {
adapter.refreshFilterCount();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

@ -1,5 +1,4 @@
<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"
@ -49,14 +48,7 @@
</LinearLayout>
<fragment
android:id="@+id/navigation_drawer"
android:name="org.tasks.ui.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
tools:layout="@layout/fragment_navigation_drawer" />
<include layout="@layout/navigation_drawer" />
</android.support.v4.widget.DrawerLayout>

@ -0,0 +1,10 @@
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation_drawer"
android:name="org.tasks.ui.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
tools:layout="@layout/fragment_navigation_drawer" />

@ -1,5 +1,4 @@
<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"
@ -10,33 +9,19 @@
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<include layout="@layout/toolbar" />
<include layout="@layout/toolbar_separator"/>
<include layout="@layout/toolbar_separator" />
<FrameLayout
android:id="@+id/tasklist_fragment_container"
android:background="?attr/asContentBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:background="?attr/asContentBackground" />
</LinearLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed width in dp and extends the full height of
the container. -->
<fragment
android:id="@+id/navigation_drawer"
android:name="org.tasks.ui.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
tools:layout="@layout/fragment_navigation_drawer" />
<include layout="@layout/navigation_drawer" />
</android.support.v4.widget.DrawerLayout>

@ -408,8 +408,6 @@
<string name="delete_task">Изтрий задача</string>
<string name="voice_command_added_task">Добавена задача</string>
<string name="external_storage_unavailable">Не може да достъпвате до външната памет</string>
<string name="navigation_drawer_open">Отвори панела за навигация</string>
<string name="navigation_drawer_close">Затвори панела за навигация</string>
<plurals name="Ntasks">
<item quantity="one">1 задача</item>
<item quantity="other">%d задачи</item>

@ -400,8 +400,6 @@
<string name="delete_task">Aufgabe löschen</string>
<string name="voice_command_added_task">Hinzugefügte Aufgabe</string>
<string name="external_storage_unavailable">Kein Zugriff auf externen Speicher</string>
<string name="navigation_drawer_open">Navigationsmenüpunkt öffnen</string>
<string name="navigation_drawer_close">Navigationsmenüpunkt schließen</string>
<plurals name="Ntasks">
<item quantity="one">1 Aufgabe</item>
<item quantity="other">%d Aufgaben</item>

@ -394,8 +394,6 @@
<string name="delete_task">Διαγραφή καθήκοντος</string>
<string name="voice_command_added_task">Η εργασία προστέθηκε</string>
<string name="external_storage_unavailable">Δεν είναι δυνατή η πρόσβαση σε εξωτερικά μέσα αποθήκευσης</string>
<string name="navigation_drawer_open">Άνοιγμα συρταριού πλοήγησης</string>
<string name="navigation_drawer_close">Κλείσιμο συρταριού πλοήγησης</string>
<string name="today">Σήμερα</string>
<string name="tomorrow">Αύριο</string>
<string name="yesterday">Χθές</string>

@ -99,6 +99,4 @@
<string name="tag_new_list">Uusi Lista</string>
<string name="tag_no_title_error">Ole hyvä syötä ensin nimi tälle listalle!</string>
<string name="delete_task">Poista tehtävä</string>
<string name="navigation_drawer_open">Avaa navigointi laatikko</string>
<string name="navigation_drawer_close">Sulje navigointi laatikko</string>
</resources>

@ -399,8 +399,6 @@
<string name="delete_task">Supprimer la tâche ? </string>
<string name="voice_command_added_task">Tâche ajoutée</string>
<string name="external_storage_unavailable">Impossible d\'accéder au stockage externe</string>
<string name="navigation_drawer_open">Ouvrir le panneau de navigation</string>
<string name="navigation_drawer_close">Fermer le panneau de navigation</string>
<plurals name="Ntasks">
<item quantity="one">1 tâche</item>
<item quantity="other">%d tâches</item>

@ -406,8 +406,6 @@
<string name="delete_task">タスクを削除</string>
<string name="voice_command_added_task">追加されたタスク</string>
<string name="external_storage_unavailable">外部メモリーにアクセスできません</string>
<string name="navigation_drawer_open">ナビゲーションドロワーを開く</string>
<string name="navigation_drawer_close">ナビゲーションドロワーを閉じる</string>
<plurals name="Ntasks">
<item quantity="one">タスク 1 件</item>
<item quantity="other">タスク %d 件</item>

@ -410,8 +410,6 @@ Tasks의 백업에서 당신의 일정을 복구하시기 바랍니다.
<string name="delete_task">일정 지우기</string>
<string name="voice_command_added_task">추가된 일정</string>
<string name="external_storage_unavailable">외부 저장소에 접근할 수 없음</string>
<string name="navigation_drawer_open">탐색 서랍 열기</string>
<string name="navigation_drawer_close">탐색 서랍 닫기</string>
<plurals name="Ntasks">
<item quantity="one">1 일정</item>
<item quantity="other">%d 일정</item>

@ -396,8 +396,6 @@
<string name="delete_task">Excluir tarefa</string>
<string name="voice_command_added_task">Tarefa adicionada</string>
<string name="external_storage_unavailable">Não é possível acessar Cartão SD</string>
<string name="navigation_drawer_open">Abrir barra lateral</string>
<string name="navigation_drawer_close">Fechar barra lateral</string>
<plurals name="Ntasks">
<item quantity="one">1 tarefa</item>
<item quantity="other">%d tarefas</item>

@ -407,8 +407,6 @@ das tarefas através de um backup em Definições-&gt;Sincronização e backup-&
<string name="delete_task">Eliminar tarefa</string>
<string name="voice_command_added_task">Tarefa adicionada</string>
<string name="external_storage_unavailable">Não foi possível aceder ao disco externo</string>
<string name="navigation_drawer_open">Abrir gaveta de navegação</string>
<string name="navigation_drawer_close">Fechar gaveta de navegação</string>
<plurals name="Ntasks">
<item quantity="one">1 tarefa</item>
<item quantity="other">%d tarefas</item>

@ -407,8 +407,6 @@
<string name="delete_task">Удалить задачу</string>
<string name="voice_command_added_task">Добавленная задача</string>
<string name="external_storage_unavailable">Не могу открыть внешний накопитель</string>
<string name="navigation_drawer_open">Открыть боковую панель</string>
<string name="navigation_drawer_close">Закрыть боковую панель</string>
<plurals name="Ntasks">
<item quantity="one">1 задача</item>
<item quantity="other">%d задач(а/и)</item>

@ -405,8 +405,6 @@
<string name="delete_task">Vymazať úlohu</string>
<string name="voice_command_added_task">Pridaná úloha</string>
<string name="external_storage_unavailable">Nemožno získať prístup k externej pamäti</string>
<string name="navigation_drawer_open">Otvoriť zásuvku navigácie</string>
<string name="navigation_drawer_close">Zatvoriť zásuvku navigácie</string>
<plurals name="Ntasks">
<item quantity="one">1 úloha</item>
<item quantity="other">%d úlohy</item>

@ -5,9 +5,6 @@
<string name="voice_command_added_task">Added task</string>
<string name="external_storage_unavailable">Cannot access external storage</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<!-- ==================================================== Generic Units == -->
<plurals name="Ntasks">

Loading…
Cancel
Save