Search in sources :

Example 26 with Toolbar

use of androidx.appcompat.widget.Toolbar in project zxing-android-embedded by journeyapps.

the class ToolbarCaptureActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.capture_appcompat);
    Toolbar toolbar = findViewById(R.id.my_awesome_toolbar);
    toolbar.setTitle("Scan Barcode");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    barcodeScannerView = findViewById(R.id.zxing_barcode_scanner);
    capture = new CaptureManager(this, barcodeScannerView);
    capture.initializeFromIntent(getIntent(), savedInstanceState);
    capture.decode();
}
Also used : CaptureManager(com.journeyapps.barcodescanner.CaptureManager) Toolbar(androidx.appcompat.widget.Toolbar)

Example 27 with Toolbar

use of androidx.appcompat.widget.Toolbar in project Gadgetbridge by Freeyourgadget.

the class ControlCenterv2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    AbstractGBActivity.init(this, AbstractGBActivity.NO_ACTIONBAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_controlcenterv2);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.controlcenter_navigation_drawer_open, R.string.controlcenter_navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    // end of material design boilerplate
    deviceManager = ((GBApplication) getApplication()).getDeviceManager();
    deviceListView = findViewById(R.id.deviceListView);
    deviceListView.setHasFixedSize(true);
    deviceListView.setLayoutManager(new LinearLayoutManager(this));
    deviceList = deviceManager.getDevices();
    mGBDeviceAdapter = new GBDeviceAdapterv2(this, deviceList, deviceActivityHashMap);
    // get activity data asynchronously, this fills the deviceActivityHashMap
    // and calls refreshPairedDevices() → notifyDataSetChanged
    createRefreshTask("get activity data", getApplication()).execute();
    deviceListView.setAdapter(this.mGBDeviceAdapter);
    fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            launchDiscoveryActivity();
        }
    });
    showFabIfNeccessary();
    /* uncomment to enable fixed-swipe to reveal more actions

        ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
                ItemTouchHelper.LEFT , ItemTouchHelper.RIGHT) {
            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                if(dX>50)
                    dX = 50;
                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);

            }

            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                GB.toast(getBaseContext(), "onMove", Toast.LENGTH_LONG, GB.ERROR);

                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                GB.toast(getBaseContext(), "onSwiped", Toast.LENGTH_LONG, GB.ERROR);

            }

            @Override
            public void onChildDrawOver(Canvas c, RecyclerView recyclerView,
                                        RecyclerView.ViewHolder viewHolder, float dX, float dY,
                                        int actionState, boolean isCurrentlyActive) {
            }
        });

        swipeToDismissTouchHelper.attachToRecyclerView(deviceListView);
        */
    registerForContextMenu(deviceListView);
    IntentFilter filterLocal = new IntentFilter();
    filterLocal.addAction(GBApplication.ACTION_LANGUAGE_CHANGE);
    filterLocal.addAction(GBApplication.ACTION_QUIT);
    filterLocal.addAction(GBApplication.ACTION_NEW_DATA);
    filterLocal.addAction(DeviceManager.ACTION_DEVICES_CHANGED);
    filterLocal.addAction(DeviceService.ACTION_REALTIME_SAMPLES);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
    refreshPairedDevices();
    /*
         * Ask for permission to intercept notifications on first run.
         */
    Prefs prefs = GBApplication.getPrefs();
    pesterWithPermissions = prefs.getBoolean("permission_pestering", true);
    Set<String> set = NotificationManagerCompat.getEnabledListenerPackages(this);
    if (pesterWithPermissions) {
        if (!set.contains(this.getPackageName())) {
            // If notification listener access hasn't been granted
            Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
            startActivity(enableIntent);
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkAndRequestPermissions();
    }
    ChangeLog cl = createChangeLog();
    if (cl.isFirstRun()) {
        try {
            cl.getLogDialog().show();
        } catch (Exception ignored) {
            GB.toast(getBaseContext(), "Error showing Changelog", Toast.LENGTH_LONG, GB.ERROR);
        }
    }
    GBApplication.deviceService().start();
    if (GB.isBluetoothEnabled() && deviceList.isEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        startActivity(new Intent(this, DiscoveryActivity.class));
    } else {
        GBApplication.deviceService().requestDeviceInfo();
    }
}
Also used : IntentFilter(android.content.IntentFilter) NavigationView(com.google.android.material.navigation.NavigationView) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) GBDeviceAdapterv2(nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapterv2) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NavigationView(com.google.android.material.navigation.NavigationView) ChangeLog(de.cketti.library.changelog.ChangeLog) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 28 with Toolbar

use of androidx.appcompat.widget.Toolbar in project Etar-Calendar by Etar-Group.

the class EventInfoFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        mIsDialog = savedInstanceState.getBoolean(BUNDLE_KEY_IS_DIALOG, false);
        mWindowStyle = savedInstanceState.getInt(BUNDLE_KEY_WINDOW_STYLE, DIALOG_WINDOW_STYLE);
        mDeleteDialogVisible = savedInstanceState.getBoolean(BUNDLE_KEY_DELETE_DIALOG_VISIBLE, false);
        mCalendarColor = savedInstanceState.getInt(BUNDLE_KEY_CALENDAR_COLOR);
        mCalendarColorInitialized = savedInstanceState.getBoolean(BUNDLE_KEY_CALENDAR_COLOR_INIT);
        mOriginalColor = savedInstanceState.getInt(BUNDLE_KEY_ORIGINAL_COLOR);
        mOriginalColorInitialized = savedInstanceState.getBoolean(BUNDLE_KEY_ORIGINAL_COLOR_INIT);
        mCurrentColor = savedInstanceState.getInt(BUNDLE_KEY_CURRENT_COLOR);
        mCurrentColorInitialized = savedInstanceState.getBoolean(BUNDLE_KEY_CURRENT_COLOR_INIT);
        mCurrentColorKey = savedInstanceState.getString(BUNDLE_KEY_CURRENT_COLOR_KEY);
        mTentativeUserSetResponse = savedInstanceState.getInt(BUNDLE_KEY_TENTATIVE_USER_RESPONSE, Attendees.ATTENDEE_STATUS_NONE);
        if (mTentativeUserSetResponse != Attendees.ATTENDEE_STATUS_NONE && mEditResponseHelper != null) {
            // If the edit response helper dialog is open, we'll need to
            // know if either of the choices were selected.
            mEditResponseHelper.setWhichEvents(savedInstanceState.getInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, -1));
        }
        mUserSetResponse = savedInstanceState.getInt(BUNDLE_KEY_USER_SET_ATTENDEE_RESPONSE, Attendees.ATTENDEE_STATUS_NONE);
        if (mUserSetResponse != Attendees.ATTENDEE_STATUS_NONE) {
            // If the response was set by the user before a configuration
            // change, we'll need to know which choice was selected.
            mWhichEvents = savedInstanceState.getInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, -1);
        }
        mReminders = Utils.readRemindersFromBundle(savedInstanceState);
    }
    if (mWindowStyle == DIALOG_WINDOW_STYLE) {
        mView = inflater.inflate(R.layout.event_info_dialog, container, false);
    } else {
        mView = inflater.inflate(R.layout.event_info, container, false);
    }
    Toolbar myToolbar = (Toolbar) mView.findViewById(R.id.toolbar);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (myToolbar != null && activity != null) {
        activity.setSupportActionBar(myToolbar);
        activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
        myToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
    }
    mScrollView = (ScrollView) mView.findViewById(R.id.event_info_scroll_view);
    mLoadingMsgView = mView.findViewById(R.id.event_info_loading_msg);
    mErrorMsgView = mView.findViewById(R.id.event_info_error_msg);
    mTitle = (TextView) mView.findViewById(R.id.title);
    mWhenDateTime = (TextView) mView.findViewById(R.id.when_datetime);
    mWhere = (TextView) mView.findViewById(R.id.where);
    mDesc = mView.findViewById(R.id.description);
    mHeadlines = mView.findViewById(R.id.event_info_headline);
    mLongAttendees = (AttendeesView) mView.findViewById(R.id.long_attendee_list);
    mResponseRadioGroup = (RadioGroup) mView.findViewById(R.id.response_value);
    if (mUri == null) {
        // restore event ID from bundle
        mEventId = savedInstanceState.getLong(BUNDLE_KEY_EVENT_ID);
        mUri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
        mStartMillis = savedInstanceState.getLong(BUNDLE_KEY_START_MILLIS);
        mEndMillis = savedInstanceState.getLong(BUNDLE_KEY_END_MILLIS);
    }
    mAnimateAlpha = ObjectAnimator.ofFloat(mScrollView, "Alpha", 0, 1);
    mAnimateAlpha.setDuration(FADE_IN_TIME);
    mAnimateAlpha.addListener(new AnimatorListenerAdapter() {

        int defLayerType;

        @Override
        public void onAnimationStart(Animator animation) {
            // Use hardware layer for better performance during animation
            defLayerType = mScrollView.getLayerType();
            mScrollView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            // Ensure that the loading message is gone before showing the
            // event info
            mLoadingMsgView.removeCallbacks(mLoadingMsgAlphaUpdater);
            mLoadingMsgView.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mScrollView.setLayerType(defLayerType, null);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mScrollView.setLayerType(defLayerType, null);
            // Do not cross fade after the first time
            mNoCrossFade = true;
        }
    });
    mLoadingMsgView.setAlpha(0);
    mScrollView.setAlpha(0);
    mErrorMsgView.setVisibility(View.INVISIBLE);
    mLoadingMsgView.postDelayed(mLoadingMsgAlphaUpdater, LOADING_MSG_DELAY);
    // start loading the data
    mHandler.startQuery(TOKEN_QUERY_EVENT, null, mUri, EVENT_PROJECTION, null, null, null);
    View b = mView.findViewById(R.id.delete);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mCanModifyCalendar) {
                return;
            }
            mDeleteHelper = new DeleteEventHelper(mContext, mActivity, !mIsDialog && !mIsTabletConfig);
            mDeleteHelper.setDeleteNotificationListener(EventInfoFragment.this);
            mDeleteHelper.setOnDismissListener(createDeleteOnDismissListener());
            mDeleteDialogVisible = true;
            mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable);
        }
    });
    b = mView.findViewById(R.id.change_color);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mCanModifyCalendar) {
                return;
            }
            showEventColorPickerDialog();
        }
    });
    // Hide Edit/Delete buttons if in full screen mode on a phone
    if (!mIsDialog && !mIsTabletConfig || mWindowStyle == EventInfoFragment.FULL_WINDOW_STYLE) {
        mView.findViewById(R.id.event_info_buttons_container).setVisibility(View.GONE);
    }
    // Create a listener for the email guests button
    emailAttendeesButton = (Button) mView.findViewById(R.id.email_attendees_button);
    if (emailAttendeesButton != null) {
        emailAttendeesButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                emailAttendees();
            }
        });
    }
    // Create a listener for the add reminder button
    View reminderAddButton = mView.findViewById(R.id.reminder_add);
    View.OnClickListener addReminderOnClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            addReminder();
            mUserModifiedReminders = true;
        }
    };
    reminderAddButton.setOnClickListener(addReminderOnClickListener);
    // Set reminders variables
    SharedPreferences prefs = GeneralPreferences.Companion.getSharedPreferences(mActivity);
    String defaultReminderString = prefs.getString(GeneralPreferences.KEY_DEFAULT_REMINDER, GeneralPreferences.NO_REMINDER_STRING);
    mDefaultReminderMinutes = Integer.parseInt(defaultReminderString);
    prepareReminders();
    return mView;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SharedPreferences(android.content.SharedPreferences) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) OnClickListener(android.view.View.OnClickListener) OnClickListener(android.view.View.OnClickListener) ScrollView(android.widget.ScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) AttendeesView(com.android.calendar.event.AttendeesView) TextView(android.widget.TextView) Paint(android.graphics.Paint) Toolbar(androidx.appcompat.widget.Toolbar)

Example 29 with Toolbar

use of androidx.appcompat.widget.Toolbar in project SwipeRecyclerView by yanzhenjie.

the class GridActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    mRecyclerView = findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.addItemDecoration(new BorderItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
    mRecyclerView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View itemView, int position) {
            // 根据原position判断该item是否是parent item
            if (mAdapter.isParentItem(position)) {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 判断parent是否打开了二级菜单
                if (mAdapter.isExpanded(parentPosition)) {
                    mDataList.get(parentPosition).setExpanded(false);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 关闭该parent下的二级菜单
                    mAdapter.collapseParent(parentPosition);
                } else {
                    mDataList.get(parentPosition).setExpanded(true);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 打开该parent下的二级菜单
                    mAdapter.expandParent(parentPosition);
                }
            } else {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 换取child position
                int childPosition = mAdapter.childItemPosition(position);
                String message = String.format("我是%1$d爸爸的%2$d儿子", parentPosition, childPosition);
                Toast.makeText(GridActivity.this, message, Toast.LENGTH_LONG).show();
            }
        }
    });
    mAdapter = new ExpandedAdapter(this);
    mRecyclerView.setAdapter(mAdapter);
    refresh();
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) OnItemClickListener(com.yanzhenjie.recyclerview.OnItemClickListener) ExpandedAdapter(com.yanzhenjie.recyclerview.sample.adapter.ExpandedAdapter) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar) BorderItemDecoration(com.yanzhenjie.recyclerview.widget.BorderItemDecoration)

Example 30 with Toolbar

use of androidx.appcompat.widget.Toolbar in project SwipeRecyclerView by yanzhenjie.

the class StaggeredActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    mRecyclerView = findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
    mRecyclerView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View itemView, int position) {
            // 根据原position判断该item是否是parent item
            if (mAdapter.isParentItem(position)) {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 判断parent是否打开了二级菜单
                if (mAdapter.isExpanded(parentPosition)) {
                    mDataList.get(parentPosition).setExpanded(false);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 关闭该parent下的二级菜单
                    mAdapter.collapseParent(parentPosition);
                } else {
                    mDataList.get(parentPosition).setExpanded(true);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 打开该parent下的二级菜单
                    mAdapter.expandParent(parentPosition);
                }
            } else {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 换取child position
                int childPosition = mAdapter.childItemPosition(position);
                String message = String.format("我是%1$d爸爸的%2$d儿子", parentPosition, childPosition);
                Toast.makeText(StaggeredActivity.this, message, Toast.LENGTH_LONG).show();
            }
        }
    });
    mAdapter = new ExpandedAdapter(this);
    mRecyclerView.setAdapter(mAdapter);
    refresh();
}
Also used : DefaultItemDecoration(com.yanzhenjie.recyclerview.widget.DefaultItemDecoration) OnItemClickListener(com.yanzhenjie.recyclerview.OnItemClickListener) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) ExpandedAdapter(com.yanzhenjie.recyclerview.sample.adapter.ExpandedAdapter) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

Toolbar (androidx.appcompat.widget.Toolbar)271 View (android.view.View)110 TextView (android.widget.TextView)55 RecyclerView (androidx.recyclerview.widget.RecyclerView)44 Bundle (android.os.Bundle)42 NonNull (androidx.annotation.NonNull)36 Intent (android.content.Intent)34 Fragment (androidx.fragment.app.Fragment)32 ActionBar (androidx.appcompat.app.ActionBar)29 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)29 Nullable (androidx.annotation.Nullable)28 BarPainter (com.xabber.android.ui.color.BarPainter)26 R (org.thoughtcrime.securesms.R)26 ViewGroup (android.view.ViewGroup)25 Context (android.content.Context)24 EditText (android.widget.EditText)22 MenuItem (android.view.MenuItem)21 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)20 Navigation (androidx.navigation.Navigation)20 Drawable (android.graphics.drawable.Drawable)18