Search in sources :

Example 6 with FloatingActionButton

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

the class ActivitySummariesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    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");
    }
    deviceFilter = getDeviceId(mGBDevice);
    IntentFilter filterLocal = new IntentFilter();
    filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
    super.onCreate(savedInstanceState);
    ActivitySummariesAdapter activitySummariesAdapter = new ActivitySummariesAdapter(this, mGBDevice, activityFilter, dateFromFilter, dateToFilter, nameContainsFilter, deviceFilter, itemsFilter);
    int backgroundColor = getBackgroundColor(ActivitySummariesActivity.this);
    activitySummariesAdapter.setBackgroundColor(backgroundColor);
    activitySummariesAdapter.setShowTime(false);
    setItemAdapter(activitySummariesAdapter);
    getItemListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // item 0 is empty for dashboard
            if (position == 0)
                return;
            Object item = parent.getItemAtPosition(position);
            if (item != null) {
                ActivitySummary summary = (ActivitySummary) item;
                try {
                    showActivityDetail(position);
                } catch (Exception e) {
                    GB.toast(getApplicationContext(), "Unable to display Activity Detail, maybe the activity is not available yet: " + e.getMessage(), Toast.LENGTH_LONG, GB.ERROR, e);
                }
            }
        }
    });
    getItemListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    getItemListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

        @Override
        public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) {
            if (position == 0 && checked)
                subtrackDashboard = 1;
            if (position == 0 && !checked)
                subtrackDashboard = 0;
            final int selectedItems = getItemListView().getCheckedItemCount() - subtrackDashboard;
            actionMode.setTitle(selectedItems + " selected");
        }

        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            getMenuInflater().inflate(R.menu.activity_list_context_menu, menu);
            findViewById(R.id.fab).setVisibility(View.INVISIBLE);
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            boolean processed = false;
            SparseBooleanArray checked = getItemListView().getCheckedItemPositions();
            switch(menuItem.getItemId()) {
                case R.id.activity_action_delete:
                    List<BaseActivitySummary> toDelete = new ArrayList<>();
                    for (int i = 0; i < checked.size(); i++) {
                        if (checked.valueAt(i)) {
                            toDelete.add(getItemAdapter().getItem(checked.keyAt(i)));
                        }
                    }
                    deleteItems(toDelete);
                    processed = true;
                    break;
                case R.id.activity_action_export:
                    List<String> paths = new ArrayList<>();
                    for (int i = 0; i < checked.size(); i++) {
                        if (checked.valueAt(i)) {
                            BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
                            if (item != null) {
                                ActivitySummary summary = item;
                                String gpxTrack = summary.getGpxTrack();
                                if (gpxTrack != null) {
                                    paths.add(gpxTrack);
                                }
                            }
                        }
                    }
                    shareMultiple(paths);
                    processed = true;
                    break;
                case R.id.activity_action_select_all:
                    for (int i = 0; i < getItemListView().getCount(); i++) {
                        getItemListView().setItemChecked(i, true);
                    }
                    // don't finish actionmode in this case!
                    return true;
                case R.id.activity_action_addto_filter:
                    List<Long> toFilter = new ArrayList<>();
                    for (int i = 0; i < checked.size(); i++) {
                        if (checked.valueAt(i)) {
                            BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
                            if (item != null && item.getId() != null) {
                                ActivitySummary summary = item;
                                Long id = summary.getId();
                                toFilter.add(id);
                            }
                        }
                    }
                    itemsFilter = toFilter;
                    setItemsFilter(itemsFilter);
                    refresh();
                    processed = true;
                    break;
                default:
                    break;
            }
            actionMode.finish();
            return processed;
        }

        @Override
        public void onDestroyActionMode(ActionMode actionMode) {
            findViewById(R.id.fab).setVisibility(View.VISIBLE);
        }
    });
    swipeLayout = findViewById(R.id.list_activity_swipe_layout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            fetchTrackData();
        }
    });
    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            fetchTrackData();
        }
    });
    activityKindMap = fillKindMap();
}
Also used : BaseActivitySummary(nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary) ActivitySummary(nodomain.freeyourgadget.gadgetbridge.model.ActivitySummary) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) SparseBooleanArray(android.util.SparseBooleanArray) BaseActivitySummary(nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) ArrayList(java.util.ArrayList) List(java.util.List) Menu(android.view.Menu) ActivitySummariesAdapter(nodomain.freeyourgadget.gadgetbridge.adapter.ActivitySummariesAdapter) IntentFilter(android.content.IntentFilter) Bundle(android.os.Bundle) AbsListView(android.widget.AbsListView) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) ActionMode(android.view.ActionMode) AdapterView(android.widget.AdapterView)

Example 7 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project IITB-App by wncc.

the class MapFragment method setupWithData.

private void setupWithData(List<Venue> venues) {
    if (getActivity() == null || getView() == null || getContext() == null)
        return;
    // Setup fade animation for background
    int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor);
    int colorTo = getResources().getColor(R.color.colorGray);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    // milliseconds
    colorAnimation.setDuration(250);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            if (getActivity() == null || getView() == null)
                return;
            getView().findViewById(R.id.main_container).setBackgroundColor((int) animator.getAnimatedValue());
        }
    });
    colorAnimation.start();
    // Show the location fab
    if (getView() == null)
        return;
    ((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show();
    // Start the setup
    Locations mLocations = new Locations(venues);
    data = mLocations.data;
    markerlist = new ArrayList<>(data.values());
    if (getArguments() != null) {
        setupMap(getArguments().getString(Constants.MAP_INITIAL_MARKER));
    }
    // Setup locate button
    FloatingActionButton fab = getView().findViewById(R.id.locate_fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            locate(true);
        }
    });
    // Setup GPS if already has permission and GPS is on
    String permission = Manifest.permission.ACCESS_FINE_LOCATION;
    int res = getContext().checkCallingOrSelfPermission(permission);
    if (res == PackageManager.PERMISSION_GRANTED) {
        final LocationManager manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
        if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            locate(false);
            setFollowingUser(false);
        }
    }
}
Also used : LocationManager(android.location.LocationManager) ArgbEvaluator(android.animation.ArgbEvaluator) Locations(com.mrane.data.Locations) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) SubsamplingScaleImageView(com.mrane.zoomview.SubsamplingScaleImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) CampusMapView(com.mrane.zoomview.CampusMapView) ExpandableListView(android.widget.ExpandableListView) TextPaint(android.text.TextPaint)

Example 8 with FloatingActionButton

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

the class DrawActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.draw_layout);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    fabActions = findViewById(R.id.fab_actions);
    final FloatingActionButton fabSetColor = findViewById(R.id.fab_set_color);
    final CardView cardViewSetColor = findViewById(R.id.cv_set_color);
    final FloatingActionButton fabSaveAndClose = findViewById(R.id.fab_save_and_close);
    final CardView cardViewSaveAndClose = findViewById(R.id.cv_save_and_close);
    final FloatingActionButton fabClear = findViewById(R.id.fab_clear);
    final CardView cardViewClear = findViewById(R.id.cv_clear);
    fabActions.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            int status = Integer.parseInt(view.getTag().toString());
            if (status == 0) {
                status = 1;
                fabActions.animate().rotation(45).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
                AnimationUtils.scaleInAnimation(fabSetColor, 50, 150, new OvershootInterpolator(), true);
                AnimationUtils.scaleInAnimation(cardViewSetColor, 50, 150, new OvershootInterpolator(), true);
                AnimationUtils.scaleInAnimation(fabSaveAndClose, 100, 150, new OvershootInterpolator(), true);
                AnimationUtils.scaleInAnimation(cardViewSaveAndClose, 100, 150, new OvershootInterpolator(), true);
                AnimationUtils.scaleInAnimation(fabClear, 150, 150, new OvershootInterpolator(), true);
                AnimationUtils.scaleInAnimation(cardViewClear, 150, 150, new OvershootInterpolator(), true);
                fabSetColor.show();
                cardViewSetColor.setVisibility(View.VISIBLE);
                fabSaveAndClose.show();
                cardViewSaveAndClose.setVisibility(View.VISIBLE);
                fabClear.show();
                cardViewClear.setVisibility(View.VISIBLE);
            } else {
                status = 0;
                fabActions.animate().rotation(0).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
                fabSetColor.hide();
                cardViewSetColor.setVisibility(View.INVISIBLE);
                fabSaveAndClose.hide();
                cardViewSaveAndClose.setVisibility(View.INVISIBLE);
                fabClear.hide();
                cardViewClear.setVisibility(View.INVISIBLE);
            }
            view.setTag(status);
        }
    });
    cardViewClear.setOnClickListener(this::clear);
    fabClear.setOnClickListener(this::clear);
    cardViewSaveAndClose.setOnClickListener(this::close);
    fabSaveAndClose.setOnClickListener(this::close);
    cardViewSetColor.setOnClickListener(this::setColor);
    fabSetColor.setOnClickListener(this::setColor);
    Bundle extras = getIntent().getExtras();
    StoragePathProvider storagePathProvider = new StoragePathProvider();
    if (extras == null) {
        loadOption = OPTION_DRAW;
        refImage = null;
        savepointImage = new File(storagePathProvider.getTmpImageFilePath());
        savepointImage.delete();
        output = new File(storagePathProvider.getTmpImageFilePath());
    } else {
        if (extras.getInt(SCREEN_ORIENTATION) == 1) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        loadOption = extras.getString(OPTION);
        if (loadOption == null) {
            loadOption = OPTION_DRAW;
        }
        // refImage can also be present if resuming a drawing
        Uri uri = (Uri) extras.get(REF_IMAGE);
        if (uri != null) {
            refImage = new File(uri.getPath());
        }
        String savepoint = extras.getString(SAVEPOINT_IMAGE);
        if (savepoint != null) {
            savepointImage = new File(savepoint);
            if (!savepointImage.exists() && refImage != null && refImage.exists()) {
                ImageFileUtils.copyImageAndApplyExifRotation(refImage, savepointImage);
            }
        } else {
            savepointImage = new File(storagePathProvider.getTmpImageFilePath());
            savepointImage.delete();
            if (refImage != null && refImage.exists()) {
                ImageFileUtils.copyImageAndApplyExifRotation(refImage, savepointImage);
            }
        }
        uri = (Uri) extras.get(EXTRA_OUTPUT);
        if (uri != null) {
            output = new File(uri.getPath());
        } else {
            output = new File(storagePathProvider.getTmpImageFilePath());
        }
    }
    if (OPTION_SIGNATURE.equals(loadOption)) {
        alertTitleString = getString(R.string.quit_application, getString(R.string.sign_button));
    } else if (OPTION_ANNOTATE.equals(loadOption)) {
        alertTitleString = getString(R.string.quit_application, getString(R.string.markup_image));
    } else {
        alertTitleString = getString(R.string.quit_application, getString(R.string.draw_image));
    }
    drawView = findViewById(R.id.drawView);
    drawView.setupView(OPTION_SIGNATURE.equals(loadOption));
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) OvershootInterpolator(android.view.animation.OvershootInterpolator) Bundle(android.os.Bundle) CardView(androidx.cardview.widget.CardView) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DrawView(org.odk.collect.android.views.DrawView) View(android.view.View) AdapterView(android.widget.AdapterView) CardView(androidx.cardview.widget.CardView) ListView(android.widget.ListView) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView) File(java.io.File) Uri(android.net.Uri)

Example 9 with FloatingActionButton

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

the class DetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    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();
        }
    });
    final ActionBar back = getSupportActionBar();
    if (back != null) {
        back.setDisplayHomeAsUpEnabled(true);
    }
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 10 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project mapbox-plugins-android by mapbox.

the class DynamicSymbolChangeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_annotation);
    mapView = findViewById(R.id.mapView);
    mapView.setTag(false);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(mapboxMap -> {
        DynamicSymbolChangeActivity.this.mapboxMap = mapboxMap;
        LatLng target = new LatLng(51.506675, -0.128699);
        mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().bearing(90).tilt(40).zoom(10).target(target).build()));
        mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS).withImage(ID_ICON_1, generateBitmap(R.drawable.mapbox_ic_place), true).withImage(ID_ICON_2, generateBitmap(R.drawable.mapbox_ic_offline), true), style -> {
            symbolManager = new SymbolManager(mapView, mapboxMap, style);
            symbolManager.setIconAllowOverlap(true);
            symbolManager.setTextAllowOverlap(true);
            // Create Symbol
            SymbolOptions SymbolOptions = new SymbolOptions().withLatLng(LAT_LNG_CHELSEA).withIconImage(ID_ICON_1);
            symbol = symbolManager.create(SymbolOptions);
        });
    });
    FloatingActionButton fab = findViewById(R.id.fabStyles);
    fab.setVisibility(MapView.VISIBLE);
    fab.setOnClickListener(view -> {
        if (mapboxMap != null) {
            updateSymbol();
        }
    });
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) SymbolManager(com.mapbox.mapboxsdk.plugins.annotation.SymbolManager) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) SymbolOptions(com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions)

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