use of android.support.v4.widget.DrawerLayout in project Aegis by Decad3nce.
the class AegisActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SharedPreferences preferences = getSharedPreferences(PREFERENCES_AEGIS, MODE_PRIVATE);
mVersion = preferences.getString(PREFERENCES_AEGIS_VERSION, "35");
FragmentManager fragmentManager = getFragmentManager();
setContentView(R.layout.drawer_layout);
final ActionBar bar = getActionBar();
bar.setDisplayShowHomeEnabled(true);
bar.setHomeButtonEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
Fragment fragment = new SMSAlarmFragment();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
mTitle = mDrawerTitle = getTitle();
mMenuTitles = getMenuTitles();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
invalidateOptionsMenu();
getActionBar().setTitle(mTitle);
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle("Menu");
((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
Utils.hideItem(R.id.alarm_menu_settings, thisMenu);
Utils.hideItem(R.id.lock_menu_settings, thisMenu);
Utils.hideItem(R.id.locate_menu_settings, thisMenu);
Utils.hideItem(R.id.wipe_menu_settings, thisMenu);
Utils.hideItem(R.id.data_menu_settings, thisMenu);
Utils.showItem(R.id.action_help, thisMenu);
}
};
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerList.setAdapter(new DrawerLayoutAdapter(this, R.layout.drawer_list_item, new ArrayList(Arrays.asList(mMenuTitles))));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerLayout.setDrawerListener(mDrawerToggle);
int versionCode = 0;
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionCode = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
//shwat
}
if (savedInstanceState == null) {
if (versionCode > Integer.parseInt(mVersion)) {
mVersion = String.valueOf(versionCode);
WebView webView = new WebView(this);
webView.loadUrl("file:///android_asset/changelog.html");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setView(webView);
dialog.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = preferences.edit();
// value to store
editor.putString(PREFERENCES_AEGIS_VERSION, mVersion);
editor.commit();
dialog.dismiss();
}
});
dialog.show();
} else {
selectItem(0);
}
} else {
selectItem(mIndex);
}
}
use of android.support.v4.widget.DrawerLayout in project Gadgetbridge by Freeyourgadget.
the class ControlCenterv2 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
if (GBApplication.isDarkThemeEnabled()) {
setTheme(R.style.GadgetbridgeThemeDark_NoActionBar);
} else {
setTheme(R.style.GadgetbridgeTheme_NoActionBar);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_controlcenterv2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchDiscoveryActivity();
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.controlcenter_navigation_drawer_open, R.string.controlcenter_navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
//end of material design boilerplate
deviceManager = ((GBApplication) getApplication()).getDeviceManager();
deviceListView = (RecyclerView) findViewById(R.id.deviceListView);
deviceListView.setHasFixedSize(true);
deviceListView.setLayoutManager(new LinearLayoutManager(this));
background = (ImageView) findViewById(R.id.no_items_bg);
deviceList = deviceManager.getDevices();
mGBDeviceAdapter = new GBDeviceAdapterv2(this, deviceList);
deviceListView.setAdapter(this.mGBDeviceAdapter);
ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.LEFT, ItemTouchHelper.RIGHT) {
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (dX > 50)
dX = 50;
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
GB.toast(getBaseContext(), "onMove", Toast.LENGTH_LONG, GB.ERROR);
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
GB.toast(getBaseContext(), "onSwiped", Toast.LENGTH_LONG, GB.ERROR);
}
@Override
public void onChildDrawOver(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
}
});
//uncomment to enable fixed-swipe to reveal more actions
//swipeToDismissTouchHelper.attachToRecyclerView(deviceListView);
registerForContextMenu(deviceListView);
IntentFilter filterLocal = new IntentFilter();
filterLocal.addAction(GBApplication.ACTION_QUIT);
filterLocal.addAction(DeviceManager.ACTION_DEVICES_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
refreshPairedDevices();
/*
* Ask for permission to intercept notifications on first run.
*/
Prefs prefs = GBApplication.getPrefs();
if (prefs.getBoolean("firstrun", true)) {
prefs.getPreferences().edit().putBoolean("firstrun", false).apply();
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
startActivity(enableIntent);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkAndRequestPermissions();
}
ChangeLog cl = new ChangeLog(this);
if (cl.isFirstRun()) {
cl.getLogDialog().show();
}
GBApplication.deviceService().start();
if (GB.isBluetoothEnabled() && deviceList.isEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
startActivity(new Intent(this, DiscoveryActivity.class));
} else {
GBApplication.deviceService().requestDeviceInfo();
}
}
use of android.support.v4.widget.DrawerLayout in project LeafPic by HoraApps.
the class MainActivity method initUI.
private void initUI() {
/**** TOOLBAR ****/
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/**** RECYCLER VIEW ****/
rvAlbums = (RecyclerView) findViewById(R.id.grid_albums);
rvMedia = ((RecyclerView) findViewById(R.id.grid_photos));
rvAlbums.setHasFixedSize(true);
rvAlbums.setItemAnimator(new DefaultItemAnimator());
rvMedia.setHasFixedSize(true);
rvMedia.setItemAnimator(new DefaultItemAnimator());
albumsAdapter = new AlbumsAdapter(getAlbums().dispAlbums, MainActivity.this);
albumsAdapter.setOnClickListener(albumOnClickListener);
albumsAdapter.setOnLongClickListener(albumOnLongCLickListener);
rvAlbums.setAdapter(albumsAdapter);
mediaAdapter = new MediaAdapter(getAlbum().getMedia(), MainActivity.this);
mediaAdapter.setOnClickListener(photosOnClickListener);
mediaAdapter.setOnLongClickListener(photosOnLongClickListener);
rvMedia.setAdapter(mediaAdapter);
int spanCount = SP.getInt("n_columns_folders", 2);
rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvAlbums.addItemDecoration(rvAlbumsDecoration);
rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
spanCount = SP.getInt("n_columns_media", 3);
rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
rvMedia.addItemDecoration(rvMediaDecoration);
/**** SWIPE TO REFRESH ****/
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setColorSchemeColors(getAccentColor());
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getBackgroundColor());
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (albumsMode) {
getAlbums().clearSelectedAlbums();
new PrepareAlbumTask().execute();
} else {
getAlbum().clearSelectedPhotos();
new PreparePhotosTask().execute();
}
}
});
/**** DRAWER ****/
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
//Put your code here
// materialMenu.animateIconState(MaterialMenuDrawable.IconState.BURGER);
}
public void onDrawerOpened(View drawerView) {
//Put your code here
//materialMenu.animateIconState(MaterialMenuDrawable.IconState.ARROW);
}
});
/**** FAB ***/
fabCamera = (FloatingActionButton) findViewById(R.id.fab_camera);
fabCamera.setImageDrawable(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_camera_alt).color(Color.WHITE));
fabCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
}
});
//region TESTING
fabCamera.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// NOTE: this is used to acquire write permission on sd with api 21
// TODO call this one when unable to write on sd
requestSdCardPermissions();
return false;
}
});
//endregion
setRecentApp(getString(R.string.app_name));
setupUI();
}
use of android.support.v4.widget.DrawerLayout in project UltimateAndroid by cymcsg.
the class FoldingDrawerLayoutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.folding_drawer_activity_drawer);
mTitle = mDrawerTitle = getTitle();
mAnimalTitles = getResources().getStringArray(R.array.items_name);
mDrawerLayout = (FoldingDrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
// mFoldLayout = (FoldingNavigationLayout)findViewById(R.id.fold_view);
// mFoldLayout.setBackgroundColor(Color.BLACK);
// set a custom shadow that overlays the main content when the drawer
// opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.left_menu_layout, mAnimalTitles));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mItemSelectedListener = new ItemSelectedListener();
// enable ActionBar app icon to behave as action to toggle nav drawer
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close) {
/* "close drawer" description for accessibility */
@SuppressLint("NewApi")
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
if (IS_HONEYCOMB) {
// creates call to
invalidateOptionsMenu();
// onPrepareOptionsMenu()
}
}
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@SuppressLint("NewApi")
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mDrawerTitle);
if (IS_HONEYCOMB) {
// creates call to
invalidateOptionsMenu();
// onPrepareOptionsMenu()
}
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
selectItem(0);
}
// try {
// mDrawerLayout.getFoldingLayout(mDrawerList).setNumberOfFolds(
// numOfFolder);
// } catch (Exception e) {
// e.printStackTrace();
// Logs.e(e, "" + (mDrawerLayout != null) + " " + (mDrawerList != null)
// + " " + (mDrawerLayout.getFoldingLayout(mDrawerList) != null));
// }
HandlerUtils.sendMessageHandlerDelay(getNumHandler, 0, 1000);
}
use of android.support.v4.widget.DrawerLayout in project UltimateAndroid by cymcsg.
the class NavigationDrawerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fading_actionbar_activity_navigation_drawer);
mTitle = mDrawerTitle = getTitle();
mCityNames = getResources().getStringArray(R.array.drawer_items);
TypedArray typedArray = getResources().obtainTypedArray(R.array.city_images);
mCityImages = new int[typedArray.length()];
for (int i = 0; i < typedArray.length(); ++i) {
mCityImages[i] = typedArray.getResourceId(i, 0);
}
typedArray.recycle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.fading_actionbar_drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.fading_actionbar_drawer_list_item, mCityNames));
mDrawerList.setOnItemClickListener(this);
// enable ActionBar app icon to behave as action to toggle nav drawer
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.fading_actionbar_ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close) {
/* "close drawer" description for accessibility */
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
selectItem(0);
}
}
Aggregations