Search in sources :

Example 1 with FloatingActionButton

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

the class NotificationsFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Activity activity = getActivity();
    if (activity == null)
        throw new AssertionError("Activity is null");
    /* 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 notificationsEnabled as it goes, and hides
         * the compose button on down-scroll. */
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
    hideFab = preferences.getBoolean("fabHide", false);
    scrollListener = new EndlessOnScrollListener(layoutManager) {

        @Override
        public void onScrolled(@NonNull RecyclerView view, int dx, int dy) {
            super.onScrolled(view, dx, dy);
            ActionButtonActivity activity = (ActionButtonActivity) getActivity();
            FloatingActionButton composeButton = activity.getActionButton();
            if (composeButton != null) {
                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 totalItemsCount, RecyclerView view) {
            NotificationsFragment.this.onLoadMore();
        }
    };
    recyclerView.addOnScrollListener(scrollListener);
    eventHub.getEvents().observeOn(AndroidSchedulers.mainThread()).to(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY))).subscribe(event -> {
        if (event instanceof FavoriteEvent) {
            setFavouriteForStatus(((FavoriteEvent) event).getStatusId(), ((FavoriteEvent) event).getFavourite());
        } else if (event instanceof BookmarkEvent) {
            setBookmarkForStatus(((BookmarkEvent) event).getStatusId(), ((BookmarkEvent) event).getBookmark());
        } else if (event instanceof ReblogEvent) {
            setReblogForStatus(((ReblogEvent) event).getStatusId(), ((ReblogEvent) event).getReblog());
        } else if (event instanceof PinEvent) {
            setPinForStatus(((PinEvent) event).getStatusId(), ((PinEvent) event).getPinned());
        } else if (event instanceof BlockEvent) {
            removeAllByAccountId(((BlockEvent) event).getAccountId());
        } else if (event instanceof PreferenceChangedEvent) {
            onPreferenceChanged(((PreferenceChangedEvent) event).getPreferenceKey());
        }
    });
}
Also used : PinEvent(com.keylesspalace.tusky.appstore.PinEvent) ReblogEvent(com.keylesspalace.tusky.appstore.ReblogEvent) SharedPreferences(android.content.SharedPreferences) ActionButtonActivity(com.keylesspalace.tusky.interfaces.ActionButtonActivity) Activity(android.app.Activity) ActionButtonActivity(com.keylesspalace.tusky.interfaces.ActionButtonActivity) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) FavoriteEvent(com.keylesspalace.tusky.appstore.FavoriteEvent) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) BookmarkEvent(com.keylesspalace.tusky.appstore.BookmarkEvent) PreferenceChangedEvent(com.keylesspalace.tusky.appstore.PreferenceChangedEvent) BlockEvent(com.keylesspalace.tusky.appstore.BlockEvent)

Example 2 with FloatingActionButton

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

the class ReminderDetails method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reminder_details);
    reminder = (Reminder) getIntent().getSerializableExtra(Reminder.EXTRA_REMINDER);
    if (reminder == null) {
        GB.toast("No reminder provided to ReminderDetails Activity", Toast.LENGTH_LONG, GB.ERROR);
        finish();
        return;
    }
    reminderRepeat = findViewById(R.id.reminder_repeat);
    reminderDate = findViewById(R.id.reminder_date);
    reminderTime = findViewById(R.id.reminder_time);
    reminderText = findViewById(R.id.reminder_message);
    device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
    final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
    final String[] repeatStrings = getResources().getStringArray(R.array.reminder_repeat);
    repeatAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, repeatStrings);
    final View cardRepeat = findViewById(R.id.card_repeat);
    cardRepeat.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new AlertDialog.Builder(ReminderDetails.this).setAdapter(repeatAdapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    reminder.setRepetition(i);
                    updateUiFromReminder();
                }
            }).create().show();
        }
    });
    final View cardDate = findViewById(R.id.card_date);
    cardDate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final Calendar date = new GregorianCalendar();
            date.setTime(reminder.getDate());
            new DatePickerDialog(ReminderDetails.this, ReminderDetails.this, date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)).show();
        }
    });
    final View cardTime = findViewById(R.id.card_time);
    cardTime.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new TimePickerDialog(ReminderDetails.this, ReminderDetails.this, reminder.getDate().getHours(), reminder.getDate().getMinutes(), DateFormat.is24HourFormat(GBApplication.getContext())).show();
        }
    });
    reminderText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(coordinator.getMaximumReminderMessageLength()) });
    reminderText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(final CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(final CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(final Editable s) {
            reminder.setMessage(s.toString());
        }
    });
    final FloatingActionButton fab = findViewById(R.id.fab_save);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            updateReminder();
            ReminderDetails.this.setResult(1);
            finish();
        }
    });
    updateUiFromReminder();
}
Also used : InputFilter(android.text.InputFilter) DialogInterface(android.content.DialogInterface) DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) TimePickerDialog(android.app.TimePickerDialog) View(android.view.View) TextView(android.widget.TextView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) DeviceCoordinator(nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator)

Example 3 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.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);
    }
    if (mGBDevice == null) {
        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);
        }
    });
    // Set up the ViewPager with the sections adapter.
    ViewPager viewPager = (ViewPager) findViewById(R.id.appmanager_pager);
    if (viewPager != null) {
        viewPager.setAdapter(getPagerAdapter());
    }
}
Also used : Bundle(android.os.Bundle) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Intent(android.content.Intent) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager)

Example 4 with FloatingActionButton

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

the class AbstractAppManagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mGBDevice = ((AppManagerActivity) getActivity()).getGBDevice();
    mCoordinator = DeviceHelper.getInstance().getCoordinator(mGBDevice);
    final FloatingActionButton appListFab = ((FloatingActionButton) getActivity().findViewById(R.id.fab));
    final FloatingActionButton appListFabNew = ((FloatingActionButton) getActivity().findViewById(R.id.fab_new));
    watchfaceDesignerActivity = mCoordinator.getWatchfaceDesignerActivity();
    View rootView = inflater.inflate(R.layout.activity_appmanager, container, false);
    RecyclerView appListView = (RecyclerView) (rootView.findViewById(R.id.appListView));
    appListView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (dy > 0) {
                appListFab.hide();
                appListFabNew.hide();
            } else if (dy < 0) {
                appListFab.show();
                if (watchfaceDesignerActivity != null) {
                    appListFabNew.show();
                }
            }
        }
    });
    appListView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mGBDeviceAppAdapter = new GBDeviceAppAdapter(appList, R.layout.item_pebble_watchapp, this);
    appListView.setAdapter(mGBDeviceAppAdapter);
    ItemTouchHelper.Callback appItemTouchHelperCallback = new AppItemTouchHelperCallback(mGBDeviceAppAdapter);
    appManagementTouchHelper = new ItemTouchHelper(appItemTouchHelperCallback);
    appManagementTouchHelper.attachToRecyclerView(appListView);
    if ((watchfaceDesignerActivity != null) && (appListFabNew != null)) {
        appListFabNew.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent startIntent = new Intent(getContext(), watchfaceDesignerActivity);
                startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
                getContext().startActivity(startIntent);
            }
        });
        appListFabNew.show();
    }
    return rootView;
}
Also used : GBDeviceAppAdapter(nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAppAdapter) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 5 with FloatingActionButton

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

the class ActivityListingChartFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_steps_list, container, false);
    getChartsHost().enableSwipeRefresh(false);
    ListView stepsList = rootView.findViewById(R.id.itemListView);
    stepListAdapter = new ActivityListingAdapter(getContext());
    stepsList.setAdapter(stepListAdapter);
    stepsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            ActivitySession item = stepListAdapter.getItem(i);
            if (item.getSessionType() != ActivitySession.SESSION_SUMMARY) {
                int tsFrom = (int) (item.getStartTime().getTime() / 1000);
                int tsTo = (int) (item.getEndTime().getTime() / 1000);
                showDetail(tsFrom, tsTo, item, getChartsHost().getDevice());
            }
        }
    });
    stepsDateView = rootView.findViewById(R.id.stepsDateView);
    FloatingActionButton fab;
    fab = rootView.findViewById(R.id.fab);
    fab.setVisibility(View.VISIBLE);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDashboard(tsDateTo, getChartsHost().getDevice());
        }
    });
    refresh();
    return rootView;
}
Also used : ListView(android.widget.ListView) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ActivitySession(nodomain.freeyourgadget.gadgetbridge.model.ActivitySession)

Aggregations

FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)28 View (android.view.View)18 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)7 TextView (android.widget.TextView)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 Toolbar (androidx.appcompat.widget.Toolbar)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