use of android.support.v7.app.ActionBarDrawerToggle in project edx-app-android by edx.
the class BaseFragmentActivity method addDrawer.
/**
* It will add the slide drawer in the activity's layout.
* <p>
* For addition, {@link DrawerLayout} with id {@link R.id#drawer_layout R.id.drawer_layout} will
* be searched in activity's layout, if it exists, the {@link NavigationFragment Navigation Drawer}
* will be replaced by the container having id {@link R.id#slider_menu R.id.slider_menu}.
* </p>
*
* @deprecated As of release v2.13, see new toolbar design used in
* {@link org.edx.mobile.view.MainDashboardActivity} and menu options used in
* {@link org.edx.mobile.view.MainTabsDashboardFragment} as an alternate.
*/
@Deprecated
protected void addDrawer() {
DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
if (mDrawerLayout != null) {
getSupportFragmentManager().beginTransaction().replace(R.id.slider_menu, new NavigationFragment(), "NavigationFragment").commit();
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.label_open_navigation_menu, R.string.label_close_navigation_menu) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
Fragment frag = getSupportFragmentManager().findFragmentByTag("NavigationFragment");
if (frag == null) {
getSupportFragmentManager().beginTransaction().replace(R.id.slider_menu, new NavigationFragment(), "NavigationFragment").commit();
}
invalidateOptionsMenu();
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// this disables the animation
super.onDrawerSlide(drawerView, 0);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
}
use of android.support.v7.app.ActionBarDrawerToggle in project Android-NotesApp by HelloPraveen.
the class MainActivity method onCreate.
@TargetApi(Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
SpannableStringBuilder SS = new SpannableStringBuilder("Notes");
SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
if (getSupportActionBar() != null)
getSupportActionBar().setTitle(SS);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
FloatingActionButton fab = findViewById(R.id.fab);
CoordinatorLayout sv = findViewById(R.id.fabView);
populateData();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, NoteActivity.class);
startActivity(i);
finish();
}
});
boolean fromNew;
boolean fromEdit;
boolean fromDelete;
boolean fromRestore;
if (this.getIntent().getExtras() != null && this.getIntent().getExtras().containsKey("note")) {
fromNew = getIntent().getExtras().getBoolean("new");
fromEdit = getIntent().getExtras().getBoolean("edit");
fromDelete = getIntent().getExtras().getBoolean("delete");
fromRestore = getIntent().getExtras().getBoolean("restore");
if (fromNew)
Snackbar.make(sv, "Note added successfully!", Snackbar.LENGTH_SHORT).show();
if (fromEdit)
Snackbar.make(sv, "Note edited successfully!", Snackbar.LENGTH_SHORT).show();
if (fromDelete)
Snackbar.make(sv, "Note deleted successfully!", Snackbar.LENGTH_SHORT).show();
if (fromRestore)
Snackbar.make(sv, "Note restored successfully!", Snackbar.LENGTH_SHORT).show();
InterstitialAd interstitialAd = new InterstitialAd(MainActivity.this);
interstitialAd.setAdUnitId("ca-app-pub-6275597090094912/5536611682");
interstitialAd.loadAd(new AdRequest.Builder().build());
}
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
boolean shortcut = preferences.getBoolean("shortcut", true);
if (!shortcut) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
int notificationId = 1;
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "NOTES_ADD";
String channelName = "Notes Shortcuts";
@SuppressLint("WrongConstant") NotificationChannel mChannel = new NotificationChannel(channelId, channelName, 3);
if (notificationManager != null) {
mChannel.setSound(null, null);
notificationManager.createNotificationChannel(mChannel);
}
Intent intent = new Intent(this, NoteActivity.class);
intent.putExtra("IS_FROM_NOTIFICATION", true);
@SuppressLint("WrongConstant") PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, intent, NotificationManager.IMPORTANCE_LOW);
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), channelId);
builder.setContentTitle("Tap to add a note");
builder.setContentText("Note something productive today.");
builder.setContentIntent(pendingIntent);
builder.setTicker("Add Notes");
builder.setChannelId(channelId);
builder.setOngoing(true);
builder.setColor(getResources().getColor(R.color.colorPrimary));
builder.setAutoCancel(true);
builder.setSmallIcon(R.drawable.notification_white);
builder.setPriority(NotificationManager.IMPORTANCE_LOW);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
stackBuilder.addNextIntent(intent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
if (notificationManager != null)
notificationManager.notify(notificationId, builder.build());
} else {
Intent intent = new Intent(this, NoteActivity.class);
intent.putExtra("IS_FROM_NOTIFICATION", true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, intent, 0);
Notification.Builder builder = new Notification.Builder(getApplicationContext());
builder.setContentTitle("Tap to add a note");
builder.setContentText("Note something productive today.");
builder.setContentIntent(pendingIntent);
builder.setTicker("Add Notes");
builder.setOngoing(true);
builder.setAutoCancel(true);
builder.setColor(getResources().getColor(R.color.colorPrimary));
builder.setSmallIcon(R.drawable.notification_white);
builder.setPriority(Notification.PRIORITY_MAX);
Notification notification = builder.build();
NotificationManager notificationManger = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManger != null)
notificationManger.notify(1, notification);
}
} else {
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (nMgr != null)
nMgr.cancelAll();
}
}
use of android.support.v7.app.ActionBarDrawerToggle in project iNaturalistAndroid by inaturalist.
the class BaseFragmentActivity method onDrawerCreate.
public void onDrawerCreate(Bundle savedInstanceState) {
Fabric.with(this, new Crashlytics());
moveDrawerToTop();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mSideMenu = (ViewGroup) findViewById(R.id.left_drawer);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 0, 0) {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
resizeMenu();
}
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}
public void onDrawerOpened(View drawerView) {
// Log an event every time the side menu is opened
AnalyticsClient.getInstance().logEvent(AnalyticsClient.EVENT_NAME_MENU);
refreshUnreadActivities();
super.onDrawerOpened(drawerView);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setIcon(android.R.color.transparent);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
((ImageView) findViewById(R.id.menu_explore_icon)).setAlpha(0.54f);
((ImageView) findViewById(R.id.menu_projects_icon)).setAlpha(0.54f);
((ImageView) findViewById(R.id.menu_guides_icon)).setAlpha(0.54f);
((ImageView) findViewById(R.id.menu_activity_icon)).setAlpha(0.54f);
((ImageView) findViewById(R.id.menu_settings_icon)).setAlpha(0.54f);
((ImageView) findViewById(R.id.menu_missions_icon)).setAlpha(0.54f);
((ImageView) findViewById(R.id.menu_help_icon)).setAlpha(0.54f);
}
buildSideMenu();
if (app == null) {
app = (INaturalistApp) getApplicationContext();
}
if (mHelper == null) {
mHelper = new ActivityHelper(this);
}
// See if we need to display the tutorial (only for the first time using the app)
SharedPreferences preferences = getSharedPreferences("iNaturalistPreferences", MODE_PRIVATE);
boolean firstTime = preferences.getBoolean("first_time", true);
if (firstTime) {
Intent intent = new Intent(this, TutorialActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("first_time", true);
startActivity(intent);
} else {
app.detectUserCountryAndUpdateNetwork(this);
}
// Show the mission "new" badge only for the first couple of times
int missionViewCount = preferences.getInt("mission_view_count", 0);
((TextView) findViewById(R.id.missions_new)).setVisibility(missionViewCount < 10 ? View.VISIBLE : View.GONE);
refreshUnreadActivities();
refreshUserDetails();
((Button) findViewById(R.id.menu_login)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// User not logged-in - redirect to onboarding screen
startActivity(new Intent(BaseFragmentActivity.this, OnboardingActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP));
}
});
if (!app.hasAutoSync() && app.loggedIn()) {
// Tell the user about the new auto sync feature
mHelper.confirm(getString(R.string.introducing_auto_sync), getString(R.string.turn_on_auto_sync), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Turn off auto sync
app.setAutoSync(false);
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Turn on auto sync
app.setAutoSync(true);
}
}, R.string.no_thanks, R.string.turn_on);
} else if (!app.hasAutoSync()) {
// Default - set auto sync on
app.setAutoSync(true);
}
}
use of android.support.v7.app.ActionBarDrawerToggle in project Saiy-PS by brandall76.
the class ActivityHome method setupDrawer.
/**
* Self explanatory utility
*/
private void setupDrawer() {
if (DEBUG) {
MyLog.i(CLS_NAME, "setupDrawer");
}
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
}
use of android.support.v7.app.ActionBarDrawerToggle in project Audient by komamj.
the class MainActivity method onPermissonGranted.
@Override
protected void onPermissonGranted() {
setSupportActionBar(mToolbar);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
mDrawerLayout.addDrawerListener(toggle);
toggle.syncState();
mNavigationView.setNavigationItemSelectedListener(this);
View headerView = mNavigationView.getHeaderView(0);
mName = headerView.findViewById(R.id.tv_user_name);
mUserImage = headerView.findViewById(R.id.iv_user);
mBlurImage = headerView.findViewById(R.id.iv_blur);
// inject presenter layer
DaggerMainComponent.builder().audientRepositoryComponent(((AudientApplication) getApplication()).getRepositoryComponent()).mainPresenterModule(new MainPresenterModule(this)).build().inject(this);
List<Fragment> fragments = new ArrayList<>();
fragments.add(MineFragment.newInstance());
fragments.add(PlaylistFragment.newInstance());
fragments.add(TopListFragment.newInstance());
AudientAdapter audientAdapter = new AudientAdapter(getSupportFragmentManager(), fragments, mPageTitles);
mViewPager.setAdapter(audientAdapter);
mViewPager.setCurrentItem(1);
mViewPager.setOffscreenPageLimit(2);
mTabLayout.setupWithViewPager(mViewPager);
}
Aggregations