use of android.support.design.widget.FloatingActionButton in project NoteText by ViWu.
the class MainMenu method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar();
initializeToolbar(toolbar, actionbar);
//set up grid and insert new set
gvItems = (GridView) findViewById(R.id.gvItems);
//Represents each item in gridView
Names = new ArrayList<String>();
newSet = new Set();
//set up adapter for grid
itemsAdapter = new ArrayAdapter<String>(MainMenu.this, R.layout.grid_item, Names);
gvItems.setAdapter(itemsAdapter);
setupListViewListener();
//create a floating action button to help the user
FloatingActionButton help = (FloatingActionButton) findViewById(R.id.help);
assert help != null;
help.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Click on the name of the set to edit. Hold down to delete/rename. To add sets, tap the button to the left.", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
//add button: Creates a popup window to type in name of new set
FloatingActionButton add = (FloatingActionButton) findViewById(R.id.add);
assert add != null;
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
AlertDialog.Builder alert = new AlertDialog.Builder(MainMenu.this);
final EditText setNameField = new EditText(MainMenu.this);
alert.setMessage("Enter Name of New Set");
alert.setTitle("Create New Set");
alert.setView(setNameField);
setNameField.requestFocus();
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
setNameField.setFilters(new InputFilter[] { new InputFilter.LengthFilter(25) });
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String itemText = setNameField.getText().toString();
if (itemText.length() > 0) {
fileCreate(itemText, view);
newSet.setName(itemText);
Sets.add(newSet);
gvItems.smoothScrollToPosition(itemsAdapter.getCount() - 1);
setCount++;
} else {
String msg = "Create set failed! Set names need to be at least one character long!";
errorDialog(msg);
}
checkNoSetExists();
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
});
alert.show();
}
});
loadInternalStorage();
checkNoSetExists();
}
use of android.support.design.widget.FloatingActionButton in project Tusky by Vavassor.
the class NotificationsFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
/* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't
* guaranteed to be set until then.
* Use a modified scroll listener that both loads more notifications as it goes, and hides
* the compose button on down-scroll. */
MainActivity activity = (MainActivity) getActivity();
final FloatingActionButton composeButton = activity.composeButton;
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
preferences.registerOnSharedPreferenceChangeListener(this);
hideFab = preferences.getBoolean("fabHide", false);
scrollListener = new EndlessOnScrollListener(layoutManager) {
@Override
public void onScrolled(RecyclerView view, int dx, int dy) {
super.onScrolled(view, dx, dy);
if (hideFab) {
if (dy > 0 && composeButton.isShown()) {
// hides the button if we're scrolling down
composeButton.hide();
} else if (dy < 0 && !composeButton.isShown()) {
// shows it if we are scrolling up
composeButton.show();
}
} else if (!composeButton.isShown()) {
composeButton.show();
}
}
@Override
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
NotificationsAdapter adapter = (NotificationsAdapter) view.getAdapter();
Notification notification = adapter.getItem(adapter.getItemCount() - 2);
if (notification != null) {
sendFetchNotificationsRequest(notification.id, null);
} else {
sendFetchNotificationsRequest();
}
}
};
recyclerView.addOnScrollListener(scrollListener);
}
use of android.support.design.widget.FloatingActionButton in project RSAndroidApp by RailwayStations.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
BaseApplication baseApplication = (BaseApplication) getApplication();
dbAdapter = baseApplication.getDbAdapter();
firstAppStart = baseApplication.getFirstAppStart();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + getString(R.string.fab_email)));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.fab_subject));
startActivity(Intent.createChooser(emailIntent, getString(R.string.fab_chooser_title)));
}
});
DrawerLayout 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();
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
handleGalleryNavItem();
View header = navigationView.getHeaderView(0);
TextView tvUpdate = (TextView) header.findViewById(R.id.tvUpdate);
if (firstAppStart == false) {
Intent introSliderIntent = new Intent(MainActivity.this, IntroSliderActivity.class);
startActivity(introSliderIntent);
finish();
}
try {
lastUpdateDate = loadUpdateDateFromFile("updatedate.txt");
} catch (Exception e) {
Log.e(TAG, "Cannot load last update", e);
}
if (!lastUpdateDate.equals("")) {
tvUpdate.setText("Letzte Aktualisierung am: " + lastUpdateDate);
} else {
disableNavItem();
tvUpdate.setText(R.string.no_stations_in_database);
}
cursor = dbAdapter.getStationsList(false);
customAdapter = new CustomAdapter(this, cursor, 0);
ListView listView = (ListView) findViewById(R.id.lstStations);
assert listView != null;
listView.setAdapter(customAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listview, View view, int position, long id) {
Bahnhof bahnhof = dbAdapter.fetchBahnhofByRowId(id);
Class cls = DetailsActivity.class;
Intent intentDetails = new Intent(MainActivity.this, cls);
intentDetails.putExtra(DetailsActivity.EXTRA_BAHNHOF, bahnhof);
startActivity(intentDetails);
finish();
}
});
// Initialize FirebaseAuth
mFirebaseAuth = FirebaseAuth.getInstance();
Intent searchIntent = getIntent();
if (Intent.ACTION_SEARCH.equals(searchIntent.getAction())) {
String query = searchIntent.getStringExtra(SearchManager.QUERY);
Toast.makeText(MainActivity.this, query, Toast.LENGTH_SHORT).show();
}
bindToStatus();
}
use of android.support.design.widget.FloatingActionButton in project Gadgetbridge by Freeyourgadget.
the class AppManagerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragmentappmanager);
Bundle extras = getIntent().getExtras();
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
} else {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
assert fab != null;
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, READ_REQUEST_CODE);
}
});
IntentFilter filterLocal = new IntentFilter();
filterLocal.addAction(GBApplication.ACTION_QUIT);
filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
// Set up the ViewPager with the sections adapter.
ViewPager viewPager = (ViewPager) findViewById(R.id.appmanager_pager);
if (viewPager != null) {
viewPager.setAdapter(getPagerAdapter());
}
}
use of android.support.design.widget.FloatingActionButton 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();
}
}
Aggregations