Search in sources :

Example 11 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project dropbox-sdk-java by dropbox.

the class FilesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String path = getIntent().getStringExtra(EXTRA_PATH);
    mPath = path == null ? "" : path;
    setContentView(R.layout.activity_files);
    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            performWithPermissions(FileAction.UPLOAD);
        }
    });
    // init picaso client
    PicassoClient.init(this, DropboxClientFactory.getClient());
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.files_list);
    mFilesAdapter = new FilesAdapter(PicassoClient.getPicasso(), new FilesAdapter.Callback() {

        @Override
        public void onFolderClicked(FolderMetadata folder) {
            startActivity(FilesActivity.getIntent(FilesActivity.this, folder.getPathLower()));
        }

        @Override
        public void onFileClicked(final FileMetadata file) {
            mSelectedFile = file;
            performWithPermissions(FileAction.DOWNLOAD);
        }
    });
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(mFilesAdapter);
    mSelectedFile = null;
}
Also used : FileMetadata(com.dropbox.core.v2.files.FileMetadata) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) FolderMetadata(com.dropbox.core.v2.files.FolderMetadata) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 12 with FloatingActionButton

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

the class EventFragment method inflateViews.

private void inflateViews(final Event event) {
    if (getActivity() == null || getView() == null)
        return;
    eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2);
    final TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_page_title);
    final TextView eventDate = (TextView) getActivity().findViewById(R.id.event_page_date);
    final TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description);
    goingButton = getActivity().findViewById(R.id.going_button);
    interestedButton = getActivity().findViewById(R.id.interested_button);
    final ImageButton navigateButton = getActivity().findViewById(R.id.navigate_button);
    final ImageButton webEventButton = getActivity().findViewById(R.id.web_event_button);
    final ImageButton shareEventButton = getActivity().findViewById(R.id.share_event_button);
    if (event.isEventBigImage() || !creatingView) {
        Picasso.get().load(event.getEventImageURL()).into(eventPicture);
    } else {
        Picasso.get().load(Utils.resizeImageUrl(event.getEventImageURL())).into(eventPicture);
    }
    eventTitle.setText(event.getEventName());
    Timestamp timestamp = event.getEventStartTime();
    Date Date = new Date(timestamp.getTime());
    SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("dd MMM");
    SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm");
    // Check for minimal event
    if (event.getEventDescription() == null) {
        refreshEvent(event);
        return;
    }
    Utils.getMarkwon().setMarkdown(eventDescription, event.getEventDescription());
    final List<CardInterface> cardList = new ArrayList<>(event.getEventOfferedAchievements());
    cardList.addAll(event.getEventBodies());
    final RecyclerView bodyRecyclerView = getActivity().findViewById(R.id.body_card_recycler_view);
    GenericAdapter genericAdapter = new GenericAdapter(cardList, this);
    bodyRecyclerView.setAdapter(genericAdapter);
    bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    // Common
    final String timing = simpleDateFormatDate.format(Date) + " | " + simpleDateFormatTime.format(Date);
    StringBuilder eventVenueName = new StringBuilder();
    for (Venue venue : event.getEventVenues()) {
        eventVenueName.append(", ").append(venue.getVenueShortName());
    }
    // Make the venues clickable
    if (eventVenueName.length() > 0) {
        // Get the whole string
        SpannableString ss = new SpannableString(eventVenueName.toString().substring(2));
        // Make each venue clickable
        int i = 0;
        for (final Venue venue : event.getEventVenues()) {
            int length = venue.getVenueShortName().length();
            ClickableSpan cs = new ClickableSpan() {

                @Override
                public void onClick(@NonNull View widget) {
                    MapFragment mapFragment = MapFragment.newInstance(MapFragment.getPassableName(venue.getVenueShortName()));
                    ((MainActivity) getActivity()).updateFragment(mapFragment);
                }

                @Override
                public void updateDrawState(TextPaint ds) {
                    super.updateDrawState(ds);
                    if (getActivity() == null || !isAdded())
                        return;
                    ds.setColor(getResources().getColor(R.color.primaryTextColor));
                    ds.setUnderlineText(false);
                }
            };
            ss.setSpan(cs, i, i + length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            i += length + 2;
        }
        // Setup the text view
        eventDate.setText(TextUtils.concat(timing + " | ", ss));
        eventDate.setMovementMethod(LinkMovementMethod.getInstance());
    } else {
        eventDate.setText(TextUtils.concat(timing));
    }
    interestedButton.setOnClickListener(getInterestedButtonOnClickListener());
    goingButton.setOnClickListener(getGoingButtonOnClickListener());
    updateGoingInterestedButtonsAppearance(event.getEventUserUes());
    if (!event.getEventVenues().isEmpty()) {
        if (event.getEventVenues().get(0).getVenueLatitude() == 0) {
            navigateButton.setVisibility(View.GONE);
        } else {
            navigateButton.setOnClickListener(v -> {
                Venue primaryVenue = event.getEventVenues().get(0);
                Uri gmmIntentUri = Uri.parse("google.navigation:q=" + primaryVenue.getVenueLatitude() + "," + primaryVenue.getVenueLongitude() + "(" + primaryVenue.getVenueName() + ")");
                Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
                mapIntent.setPackage("com.google.android.apps.maps");
                startActivity(mapIntent);
            });
        }
    } else {
        navigateButton.setVisibility(View.GONE);
    }
    shareEventButton.setOnClickListener(new View.OnClickListener() {

        String shareUrl = ShareURLMaker.getEventURL(event);

        @Override
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
            i.putExtra(Intent.EXTRA_TEXT, shareUrl);
            startActivity(Intent.createChooser(i, "Share URL"));
        }
    });
    if (event.getEventWebsiteURL() != null && !event.getEventWebsiteURL().isEmpty()) {
        webEventButton.setVisibility(View.VISIBLE);
        webEventButton.setOnClickListener(new View.OnClickListener() {

            String eventwebURL = event.getEventWebsiteURL();

            @Override
            public void onClick(View view) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(eventwebURL));
                startActivity(browserIntent);
            }
        });
    }
    eventPicture.setOnClickListener(v -> zoomImageFromThumb(eventPicture));
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
    if (((MainActivity) getActivity()).editEventAccess(event)) {
        fab.show();
        NestedScrollView nsv = getView().findViewById(R.id.event_scrollview);
        nsv.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
            if (scrollY > oldScrollY)
                fab.hide();
            else
                fab.show();
        });
    }
    fab.setOnClickListener(v -> {
        WebViewFragment webViewFragment = new WebViewFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_UPDATE_EVENT);
        bundle.putString(Constants.WV_ID, event.getEventID());
        webViewFragment.setArguments(bundle);
        ((MainActivity) getActivity()).updateFragment(webViewFragment);
    });
}
Also used : MainActivity(app.insti.activity.MainActivity) Rect(android.graphics.Rect) ImageButton(android.widget.ImageButton) Bundle(android.os.Bundle) NestedScrollView(androidx.core.widget.NestedScrollView) RetrofitInterface(app.insti.api.RetrofitInterface) NonNull(androidx.annotation.NonNull) Date(java.util.Date) Spannable(android.text.Spannable) Uri(android.net.Uri) ImageView(android.widget.ImageView) ClickableSpan(android.text.style.ClickableSpan) Animator(android.animation.Animator) LinkMovementMethod(android.text.method.LinkMovementMethod) CalendarContract(android.provider.CalendarContract) AppBarLayout(com.google.android.material.appbar.AppBarLayout) Picasso(com.squareup.picasso.Picasso) CheckBox(android.widget.CheckBox) Gson(com.google.gson.Gson) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) GenericAdapter(app.insti.adapter.GenericAdapter) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) Utils(app.insti.Utils) ObjectAnimator(android.animation.ObjectAnimator) Timestamp(java.sql.Timestamp) CardInterface(app.insti.interfaces.CardInterface) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewGroup(android.view.ViewGroup) AlertDialog(android.app.AlertDialog) List(java.util.List) TextView(android.widget.TextView) TextPaint(android.text.TextPaint) Toolbar(androidx.appcompat.widget.Toolbar) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Call(retrofit2.Call) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) EmptyCallback(app.insti.api.EmptyCallback) Context(android.content.Context) Constants(app.insti.Constants) Spanned(android.text.Spanned) SimpleDateFormat(java.text.SimpleDateFormat) Intent(android.content.Intent) Response(retrofit2.Response) Event(app.insti.api.model.Event) ArrayList(java.util.ArrayList) Toast(android.widget.Toast) AnimatorSet(android.animation.AnimatorSet) ShareURLMaker(app.insti.ShareURLMaker) R(app.insti.R) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) Point(android.graphics.Point) TextUtils(android.text.TextUtils) RelativeSizeSpan(android.text.style.RelativeSizeSpan) Color(android.graphics.Color) Venue(app.insti.api.model.Venue) SharedPreferences(android.content.SharedPreferences) Callback(retrofit2.Callback) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) MainActivity(app.insti.activity.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Timestamp(java.sql.Timestamp) Uri(android.net.Uri) ImageButton(android.widget.ImageButton) NonNull(androidx.annotation.NonNull) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) TextView(android.widget.TextView) GenericAdapter(app.insti.adapter.GenericAdapter) CardInterface(app.insti.interfaces.CardInterface) Venue(app.insti.api.model.Venue) Bundle(android.os.Bundle) Intent(android.content.Intent) ClickableSpan(android.text.style.ClickableSpan) NestedScrollView(androidx.core.widget.NestedScrollView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Date(java.util.Date) TextPaint(android.text.TextPaint) Point(android.graphics.Point) TextPaint(android.text.TextPaint) SpannableString(android.text.SpannableString) RecyclerView(androidx.recyclerview.widget.RecyclerView) NestedScrollView(androidx.core.widget.NestedScrollView) SimpleDateFormat(java.text.SimpleDateFormat)

Example 13 with FloatingActionButton

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

the class BodyFragment method displayBody.

private void displayBody() {
    /* Skip if we're already destroyed */
    if (getActivity() == null || getView() == null)
        return;
    if (body != min_body)
        bodyDisplayed = true;
    bodyPicture = (ImageView) getActivity().findViewById(R.id.body_picture);
    /* Load only low res image if transition is not completed */
    if (transitionEnded) {
        Utils.loadImageWithPlaceholder(bodyPicture, body.getBodyImageURL());
    } else {
        Picasso.get().load(Utils.resizeImageUrl(body.getBodyImageURL())).into(bodyPicture);
    }
    /* Skip for min body */
    if (body == min_body) {
        return;
    }
    bodyPicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomImageFromThumb(bodyPicture);
            final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
            fab.hide();
        }
    });
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    final List<Role> roles = body.getBodyRoles();
    final List<User> users = new ArrayList<>();
    for (Role role : roles) {
        if (role.getRoleUsersDetail() != null) {
            for (User user : role.getRoleUsersDetail()) {
                user.setCurrentRole(role.getRoleName());
                users.add(user);
            }
        }
    }
    final List<CardInterface> cards = new ArrayList<>();
    cards.add(new BodyHeadCard(body));
    addWithTitleCard(cards, body.getBodyEvents(), "Events");
    addWithTitleCard(cards, users, "People");
    addWithTitleCard(cards, body.getBodyChildren(), "Organizations");
    addWithTitleCard(cards, body.getBodyParents(), "Part of");
    final RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
    GenericAdapter genericAdapter = new GenericAdapter(cards, this);
    recyclerView.setAdapter(genericAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
    /* Show update button if role */
    if (((MainActivity) getActivity()).editBodyAccess(body)) {
        final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
        fab.show();
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (dy > 0)
                    fab.hide();
                else
                    fab.show();
            }
        });
        fab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                WebViewFragment webViewFragment = new WebViewFragment();
                Bundle bundle = new Bundle();
                bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_UPDATE_BODY);
                bundle.putString(Constants.WV_ID, body.getBodyID());
                webViewFragment.setArguments(bundle);
                ((MainActivity) getActivity()).updateFragment(webViewFragment);
            }
        });
    }
}
Also used : CardInterface(app.insti.interfaces.CardInterface) User(app.insti.api.model.User) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) MainActivity(app.insti.activity.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Point(android.graphics.Point) Role(app.insti.api.model.Role) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) GenericAdapter(app.insti.adapter.GenericAdapter) BodyHeadCard(app.insti.utils.BodyHeadCard)

Example 14 with FloatingActionButton

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

the class BodyFragment method onBackPressed.

@Override
public boolean onBackPressed() {
    if (zoomMode) {
        zoomOut(expandedImageView, startBounds, startScaleFinal, bodyPicture);
        zoomMode = false;
        /* Show fab if the user has access */
        if (((MainActivity) getActivity()).editBodyAccess(body)) {
            final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
            fab.show();
        }
        return true;
    }
    return false;
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) MainActivity(app.insti.activity.MainActivity)

Example 15 with FloatingActionButton

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

the class MapFragment method setFollowingUser.

public void setFollowingUser(boolean followingUser) {
    if (getView() == null)
        return;
    FloatingActionButton fab = getView().findViewById(R.id.locate_fab);
    if (followingUser) {
        fab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary)));
        fab.setColorFilter(getResources().getColor(R.color.primaryTextColor));
    } else {
        fab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorAccent)));
        fab.setColorFilter(getResources().getColor(R.color.secondaryTextColor));
    }
    this.followingUser = followingUser;
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton)

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