Search in sources :

Example 21 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project Gadgetbridge by Freeyourgadget.

the class ConfigureReminders method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_configure_reminders);
    gbDevice = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
    mGBReminderListAdapter = new GBReminderListAdapter(this);
    final RecyclerView remindersRecyclerView = findViewById(R.id.reminder_list);
    remindersRecyclerView.setHasFixedSize(true);
    remindersRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    remindersRecyclerView.setAdapter(mGBReminderListAdapter);
    updateRemindersFromDB();
    final FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
            final Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
            int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR, 9);
            int deviceSlots = coordinator.getReminderSlotCount() - reservedSlots;
            if (mGBReminderListAdapter.getItemCount() >= deviceSlots) {
                // No more free slots
                new AlertDialog.Builder(v.getContext()).setTitle(R.string.reminder_no_free_slots_title).setMessage(getBaseContext().getString(R.string.reminder_no_free_slots_description, String.format(Locale.getDefault(), "%d", deviceSlots))).setIcon(R.drawable.ic_warning).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                    public void onClick(final DialogInterface dialog, final int whichButton) {
                    }
                }).show();
                return;
            }
            final Reminder reminder;
            try (DBHandler db = GBApplication.acquireDB()) {
                final DaoSession daoSession = db.getDaoSession();
                final Device device = DBHelper.getDevice(gbDevice, daoSession);
                final User user = DBHelper.getUser(daoSession);
                reminder = createDefaultReminder(device, user);
            } catch (final Exception e) {
                LOG.error("Error accessing database", e);
                return;
            }
            configureReminder(reminder);
        }
    });
}
Also used : Reminder(nodomain.freeyourgadget.gadgetbridge.entities.Reminder) User(nodomain.freeyourgadget.gadgetbridge.entities.User) DialogInterface(android.content.DialogInterface) Device(nodomain.freeyourgadget.gadgetbridge.entities.Device) GBDevice(nodomain.freeyourgadget.gadgetbridge.impl.GBDevice) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) GBReminderListAdapter(nodomain.freeyourgadget.gadgetbridge.adapter.GBReminderListAdapter) DBHandler(nodomain.freeyourgadget.gadgetbridge.database.DBHandler) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) DeviceCoordinator(nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator) DaoSession(nodomain.freeyourgadget.gadgetbridge.entities.DaoSession)

Example 22 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project kdeconnect-android by KDE.

the class CustomDevicesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    ThemeUtil.setUserPreferredTheme(this);
    super.onCreate(savedInstanceState);
    final ActivityCustomDevicesBinding binding = ActivityCustomDevicesBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    recyclerView = binding.recyclerView;
    emptyListMessage = binding.emptyListMessage;
    final FloatingActionButton fab = binding.floatingActionButton;
    setSupportActionBar(binding.toolbarLayout.toolbar);
    Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    fab.setOnClickListener(v -> showEditTextDialog(""));
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    customDeviceList = getCustomDeviceList(sharedPreferences);
    showEmptyListMessageIfRequired();
    customDevicesAdapter = new CustomDevicesAdapter(this);
    customDevicesAdapter.setCustomDevices(customDeviceList);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    recyclerView.setAdapter(customDevicesAdapter);
    addDeviceDialog = (EditTextAlertDialogFragment) getSupportFragmentManager().findFragmentByTag(TAG_ADD_DEVICE_DIALOG);
    if (addDeviceDialog != null) {
        addDeviceDialog.setCallback(new AddDeviceDialogCallback());
    }
    TooltipCompat.setTooltipText(fab, getString(R.string.custom_device_fab_hint));
    if (savedInstanceState != null) {
        editingDeviceAtPosition = savedInstanceState.getInt(KEY_EDITING_DEVICE_AT_POSITION);
    } else {
        editingDeviceAtPosition = -1;
    }
}
Also used : ActivityCustomDevicesBinding(org.kde.kdeconnect_tp.databinding.ActivityCustomDevicesBinding) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration)

Example 23 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project android by nextcloud.

the class FileDetailFragment method showHideFragmentView.

/**
 * method will handle the views need to be hidden when sharing process fragment shows
 * @param isFragmentReplaced
 */
public void showHideFragmentView(boolean isFragmentReplaced) {
    binding.tabLayout.setVisibility(isFragmentReplaced ? View.GONE : View.VISIBLE);
    binding.pager.setVisibility(isFragmentReplaced ? View.GONE : View.VISIBLE);
    binding.sharingFrameContainer.setVisibility(isFragmentReplaced ? View.VISIBLE : View.GONE);
    FloatingActionButton mFabMain = requireActivity().findViewById(R.id.fab_main);
    if (isFragmentReplaced) {
        mFabMain.hide();
    } else {
        mFabMain.show();
    }
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton)

Example 24 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project android by nextcloud.

the class PreviewTextStringFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    if (view == null) {
        throw new RuntimeException("View may not be null");
    }
    FloatingActionButton fabMain = requireActivity().findViewById(R.id.fab_main);
    fabMain.setVisibility(View.VISIBLE);
    fabMain.setEnabled(true);
    fabMain.setOnClickListener(v -> edit());
    ThemeFabUtils.colorFloatingActionButton(fabMain, R.drawable.ic_edit, requireContext());
    return view;
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) SearchView(androidx.appcompat.widget.SearchView) View(android.view.View)

Example 25 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project iterable-android-sdk by Iterable.

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);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)29 View (android.view.View)19 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)7 TextView (android.widget.TextView)6 Toolbar (androidx.appcompat.widget.Toolbar)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 Intent (android.content.Intent)4 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)4 ArrayList (java.util.ArrayList)4 MainActivity (app.insti.activity.MainActivity)3 CardInterface (app.insti.interfaces.CardInterface)3 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 Point (android.graphics.Point)2 Uri (android.net.Uri)2 TextPaint (android.text.TextPaint)2 GenericAdapter (app.insti.adapter.GenericAdapter)2