mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
backward compatible navigation drawer toggle // FREEBIE
This commit is contained in:
parent
6157a0df7a
commit
ed3151bdb5
@ -686,6 +686,8 @@
|
|||||||
|
|
||||||
<!-- conversation_list -->
|
<!-- conversation_list -->
|
||||||
<string name="conversation_list__menu_search">Search</string>
|
<string name="conversation_list__menu_search">Search</string>
|
||||||
|
<string name="conversation_list__drawer_open">Open navigation drawer</string>
|
||||||
|
<string name="conversation_list__drawer_close">Close navigation drawer</string>
|
||||||
|
|
||||||
<!-- conversation_secure_verified -->
|
<!-- conversation_secure_verified -->
|
||||||
<string name="conversation_secure_verified__menu_security">Security</string>
|
<string name="conversation_secure_verified__menu_security">Security</string>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@ -8,6 +9,7 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.provider.Telephony;
|
import android.provider.Telephony;
|
||||||
|
import android.support.v4.app.ActionBarDrawerToggle;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -51,6 +53,7 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
|||||||
private ConversationListFragment fragment;
|
private ConversationListFragment fragment;
|
||||||
private MasterSecret masterSecret;
|
private MasterSecret masterSecret;
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
|
private DrawerToggle drawerToggle;
|
||||||
private ListView drawerList;
|
private ListView drawerList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,6 +74,12 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
|||||||
DirectoryRefreshListener.schedule(this);
|
DirectoryRefreshListener.schedule(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostCreate(Bundle bundle) {
|
||||||
|
super.onPostCreate(bundle);
|
||||||
|
drawerToggle.syncState();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -217,6 +226,13 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
DrawerLayout drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
|
DrawerLayout drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
|
||||||
|
drawerToggle = new DrawerToggle(this, drawerLayout,
|
||||||
|
R.drawable.ic_drawer,
|
||||||
|
R.string.conversation_list__drawer_open,
|
||||||
|
R.string.conversation_list__drawer_close);
|
||||||
|
|
||||||
|
drawerLayout.setDrawerListener(drawerToggle);
|
||||||
|
|
||||||
ListView drawer = (ListView)findViewById(R.id.left_drawer);
|
ListView drawer = (ListView)findViewById(R.id.left_drawer);
|
||||||
SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.navigation_drawer_item, from, to);
|
SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.navigation_drawer_item, from, to);
|
||||||
|
|
||||||
@ -274,4 +290,31 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DrawerToggle extends ActionBarDrawerToggle {
|
||||||
|
|
||||||
|
public DrawerToggle(Activity activity, DrawerLayout drawerLayout,
|
||||||
|
int drawerImageRes, int openDrawerContentDescRes,
|
||||||
|
int closeDrawerContentDescRes) {
|
||||||
|
|
||||||
|
super(activity, drawerLayout, drawerImageRes,
|
||||||
|
openDrawerContentDescRes, closeDrawerContentDescRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerClosed(View drawerView) {
|
||||||
|
|
||||||
|
super.onDrawerClosed(drawerView);
|
||||||
|
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerOpened(View drawerView) {
|
||||||
|
|
||||||
|
super.onDrawerOpened(drawerView);
|
||||||
|
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user