Search in sources :

Example 1 with DotsView

use of com.android.camera.ui.DotsView in project android_packages_apps_Snap by LineageOS.

the class GridAdapter method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final boolean isSecureCamera = getIntent().getBooleanExtra(CameraUtil.KEY_IS_SECURE_CAMERA, false);
    if (isSecureCamera) {
        setShowInLockScreen();
    }
    setContentView(R.layout.scene_mode_menu_layout);
    mSettingsManager = SettingsManager.getInstance();
    mCurrentScene = mSettingsManager.getValueIndex(SettingsManager.KEY_SCENE_MODE);
    mEntries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE);
    mThumbnails = mSettingsManager.getResource(SettingsManager.KEY_SCENE_MODE, SettingsManager.RESOURCE_TYPE_THUMBNAIL);
    mNumElement = mThumbnails.length;
    int pages = mNumElement / mElemPerPage;
    if (mNumElement % mElemPerPage != 0)
        pages++;
    mNumPage = pages;
    mAdapter = new MyPagerAdapter(this);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setOverScrollMode(ViewPager.OVER_SCROLL_NEVER);
    mPager.setAdapter(mAdapter);
    mCloseButton = findViewById(R.id.close_button);
    mCloseButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    int pageCount = mAdapter.getCount();
    mDotsView = (DotsView) findViewById(R.id.page_indicator);
    mPager.setCurrentItem(mCurrentScene / mElemPerPage);
    mDotsView.update(mCurrentScene / mElemPerPage, 0f);
    if (pageCount > 1) {
        mDotsView.setItems(new PageItems(pageCount));
        mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                mDotsView.update(position, positionOffset);
            }
        });
    } else {
        mDotsView.setVisibility(View.GONE);
    }
    mButton = (RotateImageView) findViewById(R.id.setting_button);
    mButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getBaseContext(), SettingsActivity.class);
            intent.putExtra(CameraUtil.KEY_IS_SECURE_CAMERA, isSecureCamera);
            startActivity(intent);
            finish();
        }
    });
}
Also used : Intent(android.content.Intent) GridView(android.widget.GridView) RotateImageView(com.android.camera.ui.RotateImageView) ImageView(android.widget.ImageView) DotsView(com.android.camera.ui.DotsView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ViewPager(android.support.v4.view.ViewPager)

Example 2 with DotsView

use of com.android.camera.ui.DotsView in project android_packages_apps_Snap by LineageOS.

the class BestpictureActivity method onCreate.

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    mActivity = this;
    Intent intent = getIntent();
    String action = intent.getAction();
    if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action) || ACTION_IMAGE_CAPTURE_SECURE.equals(action)) {
        mSecureCamera = true;
    } else {
        mSecureCamera = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false);
    }
    if (mSecureCamera) {
        // Change the window flags so that secure camera can show when locked
        Window win = getWindow();
        WindowManager.LayoutParams params = win.getAttributes();
        params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
        win.setAttributes(params);
    }
    mFilesPath = getFilesDir() + "/Bestpicture";
    setContentView(R.layout.bestpicture_editor);
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    mWidth = size.x / 4;
    mHeight = size.y / 4;
    mNamedImages = new PhotoModule.NamedImages();
    mImageItems = new ImageItems(mActivity);
    mDotsView = (DotsView) findViewById(R.id.dots_view);
    mDotsView.setItems(mImageItems);
    mPlaceHolderUri = getIntent().getData();
    mImagePager = (ViewPager) findViewById(R.id.bestpicture_pager);
    mImagePagerAdapter = new ImagePagerAdapter(getFragmentManager());
    mImagePager.setAdapter(mImagePagerAdapter);
    mImagePager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            mDotsView.update(position, positionOffset);
        }

        @Override
        public void onPageSelected(int position) {
        }
    });
    findViewById(R.id.bestpicture_done).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            int choosenCount = 0;
            for (int i = 0; i < mImageItems.mChosen.length; i++) {
                if (mImageItems.mChosen[i]) {
                    choosenCount++;
                }
            }
            boolean showSaveDialog = CameraUtil.loadDialogShowConfig(BestpictureActivity.this, CameraUtil.KEY_SAVE);
            if (showSaveDialog) {
                // add save dialog
                initSaveDialog(CameraUtil.MODE_TWO_BT, choosenCount);
                mDialog.show();
                setDialogLayoutPararms();
            } else {
                saveImages(choosenCount, false);
            }
        }
    });
    findViewById(R.id.delete_best).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            boolean showDeleteDialog = CameraUtil.loadDialogShowConfig(BestpictureActivity.this, CameraUtil.KEY_DELETE);
            if (showDeleteDialog) {
                initDeleteDialog(CameraUtil.MODE_TWO_BT);
                mDialog.show();
                setDialogLayoutPararms();
            } else {
                backToViewfinder();
            }
        }
    });
    RotateImageView moreView = (RotateImageView) findViewById(R.id.best_more);
    Bitmap mMoreBp = BitmapFactory.decodeResource(getResources(), R.drawable.more_options);
    mMoreBp = CameraUtil.adjustPhotoRotation(mMoreBp, 90);
    moreView.setImageBitmap(mMoreBp);
    moreView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            initOverFlow(v);
        }
    });
}
Also used : PopupWindow(android.widget.PopupWindow) Window(android.view.Window) Intent(android.content.Intent) Point(android.graphics.Point) ViewPager(android.support.v4.view.ViewPager) RotateImageView(com.android.camera.ui.RotateImageView) DotsView(com.android.camera.ui.DotsView) View(android.view.View) TextView(android.widget.TextView) Point(android.graphics.Point) WindowManager(android.view.WindowManager) RotateImageView(com.android.camera.ui.RotateImageView) Bitmap(android.graphics.Bitmap) Display(android.view.Display)

Aggregations

Intent (android.content.Intent)2 ViewPager (android.support.v4.view.ViewPager)2 View (android.view.View)2 TextView (android.widget.TextView)2 DotsView (com.android.camera.ui.DotsView)2 RotateImageView (com.android.camera.ui.RotateImageView)2 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 Display (android.view.Display)1 Window (android.view.Window)1 WindowManager (android.view.WindowManager)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 PopupWindow (android.widget.PopupWindow)1