Search in sources :

Example 1 with TitleFAB

use of jahirfiquitiva.libs.fabsmenu.TitleFAB in project FABsMenu by jahirfiquitiva.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_main);
    Button snackButton = findViewById(R.id.snack_button);
    snackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(findViewById(R.id.coordinator), "Testing, testing, 1, 2, 3", Snackbar.LENGTH_LONG).show();
        }
    });
    RecyclerView rv = findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    rv.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    rv.setAdapter(new SampleAdapter(this));
    menu = findViewById(R.id.fabs_menu);
    menu.attachToRecyclerView(rv);
    menu.setMenuListener(new FABsMenuListener() {

        // You don't need to override all methods. Just the ones you want.
        @Override
        public void onMenuClicked(FABsMenu fabsMenu) {
            // Default implementation opens the menu on click
            super.onMenuClicked(fabsMenu);
        // showToast("You pressed the menu!");
        }

        @Override
        public void onMenuCollapsed(FABsMenu fabsMenu) {
            super.onMenuCollapsed(fabsMenu);
        // showToast("The menu has been collapsed!");
        }

        @Override
        public void onMenuExpanded(FABsMenu fabsMenu) {
            super.onMenuExpanded(fabsMenu);
        // showToast("The menu has been expanded!");
        }
    });
    TitleFAB clickableTitle = findViewById(R.id.clickable_title);
    clickableTitle.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the red fab or its title");
        }
    });
    TitleFAB mini = findViewById(R.id.mini_fab);
    mini.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the mini fab!");
        }
    });
    TitleFAB green = findViewById(R.id.green_fab);
    green.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the green fab");
        }
    });
    // Removes a button
    TitleFAB toRemove = findViewById(R.id.to_remove);
    menu.removeButton(toRemove);
    // Adds a button to the bottom
    final TitleFAB toAdd = new TitleFAB(this);
    toAdd.setTitle("A new added fab");
    toAdd.setBackgroundColor(Color.parseColor("#ff5722"));
    toAdd.setTitleClickEnabled(true);
    toAdd.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the new button");
            toAdd.hide();
        }
    });
    menu.addButton(toAdd);
}
Also used : Button(android.widget.Button) FABsMenuListener(jahirfiquitiva.libs.fabsmenu.FABsMenuListener) RecyclerView(android.support.v7.widget.RecyclerView) FABsMenu(jahirfiquitiva.libs.fabsmenu.FABsMenu) TitleFAB(jahirfiquitiva.libs.fabsmenu.TitleFAB) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 2 with TitleFAB

use of jahirfiquitiva.libs.fabsmenu.TitleFAB in project FABsMenu by jahirfiquitiva.

the class MainActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.add) {
        final TitleFAB toAdd = new TitleFAB(this);
        toAdd.setTitle("A new added fab");
        toAdd.setBackgroundColor(Color.parseColor("#ff5722"));
        toAdd.setTitleClickEnabled(true);
        toAdd.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                showToast("You pressed the new button");
                toAdd.hide();
            }
        });
        menu.addButton(toAdd);
    } else if (item.getItemId() == R.id.remove) {
        menu.removeAllButtons();
    }
    return super.onOptionsItemSelected(item);
}
Also used : TitleFAB(jahirfiquitiva.libs.fabsmenu.TitleFAB) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 3 with TitleFAB

use of jahirfiquitiva.libs.fabsmenu.TitleFAB in project andOTP by andOTP.

the class MainActivity method onCreate.

// Initialize the main application
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.app_name);
    if (!settings.getScreenshotsEnabled())
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    settings.registerPreferenceChangeListener(this);
    encryptionType = settings.getEncryption();
    if (settings.getAuthMethod() != AuthMethod.NONE && savedInstanceState == null)
        requireAuthentication = true;
    setBroadcastCallback(new BroadcastReceivedCallback() {

        @Override
        public void onReceivedScreenOff() {
            if (settings.getRelockOnScreenOff() && settings.getAuthMethod() != AuthMethod.NONE)
                requireAuthentication = true;
        }
    });
    if (!settings.getFirstTimeWarningShown()) {
        showFirstTimeWarning();
    }
    fabsMenu = findViewById(R.id.fabs_menu);
    TitleFAB qrFAB = findViewById(R.id.fab_qr_scan);
    qrFAB.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            fabsMenu.collapse();
            scanQRCode();
        }
    });
    TitleFAB manualFAB = findViewById(R.id.fab_manual_entry);
    manualFAB.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            fabsMenu.collapse();
            ManualEntryDialog.show(MainActivity.this, settings, adapter);
        }
    });
    final ProgressBar progressBar = findViewById(R.id.progressBar);
    RecyclerView recList = findViewById(R.id.cardList);
    recList.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    tagsDrawerAdapter = new TagsAdapter(this, new HashMap<String, Boolean>());
    adapter = new EntriesCardAdapter(this, tagsDrawerAdapter);
    recList.setAdapter(adapter);
    touchHelperCallback = new SimpleItemTouchHelperCallback(adapter);
    ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
    touchHelper.attachToRecyclerView(recList);
    NotificationHelper.initializeNotificationChannels(this);
    restoreSortMode();
    float durationScale = android.provider.Settings.Global.getFloat(this.getContentResolver(), android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 0);
    if (durationScale == 0)
        durationScale = 1;
    final long animatorDuration = (long) (1000 / durationScale);
    adapter.setCallback(new EntriesCardAdapter.Callback() {

        @Override
        public void onMoveEventStart() {
            stopUpdater();
        }

        @Override
        public void onMoveEventStop() {
            startUpdater();
        }
    });
    handler = new Handler();
    handlerTask = new Runnable() {

        @Override
        public void run() {
            int progress = (int) (TokenCalculator.TOTP_DEFAULT_PERIOD - (System.currentTimeMillis() / 1000) % TokenCalculator.TOTP_DEFAULT_PERIOD);
            progressBar.setProgress(progress * 100);
            ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", (progress - 1) * 100);
            animation.setDuration(animatorDuration);
            animation.setInterpolator(new LinearInterpolator());
            animation.start();
            adapter.updateTokens();
            handler.postDelayed(this, 1000);
        }
    };
    setupDrawer();
}
Also used : TagsAdapter(org.shadowice.flocke.andotp.View.TagsAdapter) HashMap(java.util.HashMap) SimpleItemTouchHelperCallback(org.shadowice.flocke.andotp.View.ItemTouchHelper.SimpleItemTouchHelperCallback) ObjectAnimator(android.animation.ObjectAnimator) Handler(android.os.Handler) TitleFAB(jahirfiquitiva.libs.fabsmenu.TitleFAB) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) CheckedTextView(android.widget.CheckedTextView) ListView(android.widget.ListView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) LinearInterpolator(android.view.animation.LinearInterpolator) EntriesCardAdapter(org.shadowice.flocke.andotp.View.EntriesCardAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ProgressBar(android.widget.ProgressBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 TitleFAB (jahirfiquitiva.libs.fabsmenu.TitleFAB)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 ObjectAnimator (android.animation.ObjectAnimator)1 Handler (android.os.Handler)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 SearchView (android.support.v7.widget.SearchView)1 Toolbar (android.support.v7.widget.Toolbar)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 LinearInterpolator (android.view.animation.LinearInterpolator)1 AdapterView (android.widget.AdapterView)1 Button (android.widget.Button)1 CheckedTextView (android.widget.CheckedTextView)1 ListView (android.widget.ListView)1 ProgressBar (android.widget.ProgressBar)1 FABsMenu (jahirfiquitiva.libs.fabsmenu.FABsMenu)1 FABsMenuListener (jahirfiquitiva.libs.fabsmenu.FABsMenuListener)1 HashMap (java.util.HashMap)1 EntriesCardAdapter (org.shadowice.flocke.andotp.View.EntriesCardAdapter)1