Search in sources :

Example 6 with OnClickListener

use of android.view.View.OnClickListener in project photo-picker-plus-android by chute.

the class ServicesRecyclerAdapter method setupLocalService.

private void setupLocalService(ListItemViewHolder holder, LocalServiceType type) {
    Uri lastVideoThumbFromAllVideos = MediaDAO.getLastVideoThumbnailFromAllVideos(context.getApplicationContext());
    Uri lastVideoThumbFromCameraVideos = MediaDAO.getLastVideoThumbnailFromCameraVideos(context.getApplicationContext());
    Uri lastImageFromAllPhotos = MediaDAO.getLastPhotoFromAllPhotos(context.getApplicationContext());
    Uri lastImageFromCameraPhotos = MediaDAO.getLastPhotoFromCameraPhotos(context.getApplicationContext());
    switch(type) {
        case TAKE_PHOTO:
            holder.imageViewService.setBackgroundResource(R.drawable.take_photo);
            holder.textViewServiceTitle.setText(R.string.take_photos);
            break;
        case CAMERA_MEDIA:
            Uri uriCameraMedia = null;
            if (supportsImages) {
                uriCameraMedia = lastImageFromAllPhotos;
            } else {
                uriCameraMedia = lastVideoThumbFromCameraVideos;
            }
            Picasso.with(context).load(uriCameraMedia).fit().centerCrop().into(holder.imageViewService);
            holder.textViewServiceTitle.setText(R.string.camera_media);
            break;
        case LAST_PHOTO_TAKEN:
            Picasso.with(context).load(lastImageFromAllPhotos).fit().centerCrop().into(holder.imageViewService);
            holder.textViewServiceTitle.setText(context.getResources().getString(R.string.last_photo));
            break;
        case ALL_MEDIA:
            Uri uriAllMedia = null;
            if (supportsImages) {
                uriAllMedia = lastImageFromAllPhotos;
            } else {
                uriAllMedia = lastVideoThumbFromAllVideos;
            }
            Picasso.with(context).load(uriAllMedia).fit().centerCrop().into(holder.imageViewService);
            holder.textViewServiceTitle.setText(context.getResources().getString(R.string.all_media));
            break;
        case LAST_VIDEO_CAPTURED:
            String thumbnail = MediaDAO.getLastVideoThumbnailFromCurosr(context);
            Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(thumbnail, MediaStore.Images.Thumbnails.MINI_KIND);
            holder.imageViewService.setImageBitmap(bitmap);
            holder.textViewServiceTitle.setText(context.getResources().getString(R.string.last_video_captured));
            break;
        case RECORD_VIDEO:
            holder.imageViewService.setBackgroundResource(R.drawable.take_photo);
            holder.textViewServiceTitle.setText(R.string.record_video);
            break;
    }
    /* Click listeners */
    switch(type) {
        case ALL_MEDIA:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.photoStream();
                }
            });
            break;
        case CAMERA_MEDIA:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.cameraRoll();
                }
            });
            break;
        case TAKE_PHOTO:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.takePhoto();
                }
            });
            break;
        case LAST_PHOTO_TAKEN:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.lastPhoto();
                }
            });
            break;
        case LAST_VIDEO_CAPTURED:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.lastVideo();
                }
            });
            break;
        case RECORD_VIDEO:
            holder.imageViewService.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    serviceClickedListener.recordVideo();
                }
            });
            break;
    }
}
Also used : Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) Uri(android.net.Uri) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with OnClickListener

use of android.view.View.OnClickListener in project UltimateAndroid by cymcsg.

the class MaterialDesignActivity method onCreate.

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.material_design_activity_main);
    buttonSelectColor = (ButtonFloatSmall) findViewById(R.id.buttonColorSelector);
    buttonSelectColor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            ColorSelector colorSelector = new ColorSelector(MaterialDesignActivity.this, backgroundColor, MaterialDesignActivity.this);
            colorSelector.show();
        }
    });
    LayoutRipple layoutRipple = (LayoutRipple) findViewById(R.id.itemButtons);
    setOriginRiple(layoutRipple);
    layoutRipple.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(MaterialDesignActivity.this, ButtonsActivity.class);
            intent.putExtra("BACKGROUND", backgroundColor);
            startActivity(intent);
        }
    });
    layoutRipple = (LayoutRipple) findViewById(R.id.itemSwitches);
    setOriginRiple(layoutRipple);
    layoutRipple.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(MaterialDesignActivity.this, SwitchActivity.class);
            intent.putExtra("BACKGROUND", backgroundColor);
            startActivity(intent);
        }
    });
    layoutRipple = (LayoutRipple) findViewById(R.id.itemProgress);
    setOriginRiple(layoutRipple);
    layoutRipple.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(MaterialDesignActivity.this, ProgressActivity.class);
            intent.putExtra("BACKGROUND", backgroundColor);
            startActivity(intent);
        }
    });
    layoutRipple = (LayoutRipple) findViewById(R.id.itemWidgets);
    setOriginRiple(layoutRipple);
    layoutRipple.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(MaterialDesignActivity.this, WidgetActivity.class);
            intent.putExtra("BACKGROUND", backgroundColor);
            startActivity(intent);
        }
    });
}
Also used : LayoutRipple(com.gc.materialdesign.views.LayoutRipple) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) ColorSelector(com.gc.materialdesign.widgets.ColorSelector) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

Example 8 with OnClickListener

use of android.view.View.OnClickListener in project android-betterpickers by code-troopers.

the class CalendarDatePickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }
    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, container, false);
    mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);
    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
        mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mStyleResId = savedInstanceState.getInt(KEY_THEME);
        mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
    }
    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);
    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialogs);
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);
    int headerBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int preHeaderBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpPreHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor, ContextCompat.getColor(getActivity(), R.color.radial_gray_light));
    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        doneButton.setText(mDoneText);
    }
    doneButton.setTextColor(buttonTextColor);
    doneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialogFragment.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    if (mCancelText != null) {
        cancelButton.setText(mCancelText);
    }
    cancelButton.setTextColor(buttonTextColor);
    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            dismiss();
        }
    });
    view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
    updateDisplay(false);
    setCurrentView(currentView);
    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    mHapticFeedbackController = new HapticFeedbackController(activity);
    mDayPickerView.setTheme(themeColors);
    mYearPickerView.setTheme(themeColors);
    mSelectedDateLayout.setBackgroundColor(headerBackgroundColor);
    mYearView.setBackgroundColor(headerBackgroundColor);
    mMonthAndDayView.setBackgroundColor(headerBackgroundColor);
    if (mDayOfWeekView != null) {
        mDayOfWeekView.setBackgroundColor(preHeaderBackgroundColor);
    }
    view.setBackgroundColor(bodyBgColor);
    mYearPickerView.setBackgroundColor(bodyBgColor);
    mDayPickerView.setBackgroundColor(bodyBgColor);
    return view;
}
Also used : Activity(android.app.Activity) View(android.view.View) TextView(android.widget.TextView) AlphaAnimation(android.view.animation.AlphaAnimation) Button(android.widget.Button) TypedArray(android.content.res.TypedArray) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) OnClickListener(android.view.View.OnClickListener) HapticFeedbackController(com.codetroopers.betterpickers.HapticFeedbackController) Resources(android.content.res.Resources) CalendarDay(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter.CalendarDay)

Example 9 with OnClickListener

use of android.view.View.OnClickListener in project android by cSploit.

the class PortScanner method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    mPreferences = System.getSettings();
    mTextDoc = (TextView) findViewById(R.id.scanDoc);
    mTextParameters = (EditText) findViewById(R.id.scanParameters);
    mScanFloatingActionButton = (FloatingActionButton) findViewById(R.id.scanToggleButton);
    mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);
    mShowCustomParameters = mPreferences.getBoolean(CUSTOM_PARAMETERS, false);
    if (mShowCustomParameters)
        displayParametersField();
    else
        hideParametersField();
    mScanFloatingActionButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    ListView mScanList = (ListView) findViewById(R.id.scanListView);
    createPortList();
    final Target target = System.getCurrentTarget();
    final String cmdlineRep = target.getCommandLineRepresentation();
    mScanReceiver = new Receiver(target);
    mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mPortList);
    mScanList.setAdapter(mListAdapter);
    mScanList.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            int portNumber = target.getOpenPorts().get(position).getNumber();
            if (!urlFormats.containsKey(portNumber)) {
                portNumber = 0;
            }
            final String url = String.format(urlFormats.get(portNumber), cmdlineRep, portNumber);
            new ConfirmDialog("Open", "Open " + url + " ?", PortScanner.this, new ConfirmDialogListener() {

                @Override
                public void onConfirm() {
                    try {
                        Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        PortScanner.this.startActivity(browser);
                    } catch (ActivityNotFoundException e) {
                        System.errorLogging(e);
                        new ErrorDialog(getString(R.string.error), getString(R.string.no_activities_for_url), PortScanner.this).show();
                    }
                }

                @Override
                public void onCancel() {
                }
            }).show();
            return false;
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Target(org.csploit.android.net.Target) ListView(android.widget.ListView) ActivityNotFoundException(android.content.ActivityNotFoundException) OnClickListener(android.view.View.OnClickListener) ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog)

Example 10 with OnClickListener

use of android.view.View.OnClickListener in project android by cSploit.

the class Hijacker method onCreate.

public void onCreate(Bundle savedInstanceState) {
    SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
    Boolean isDark = themePrefs.getBoolean("isDark", false);
    if (isDark)
        setTheme(R.style.DarkTheme);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setTitle(System.getCurrentTarget() + " > MITM > " + getString(R.string.session_sniffer));
    setContentView(R.layout.plugin_mitm_hijacker);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mHijackToggleButton = (ToggleButton) findViewById(R.id.hijackToggleButton);
    mHijackProgress = (ProgressBar) findViewById(R.id.hijackActivity);
    ListView mListView = (ListView) findViewById(R.id.listView);
    mAdapter = new SessionListAdapter(R.layout.plugin_mitm_hijacker_list_item);
    mSpoof = new SpoofSession();
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Session session = mAdapter.getByPosition(position);
            if (session != null) {
                new ConfirmDialog(getString(R.string.hijack_session), mRunning ? getString(R.string.start_hijacking) : getString(R.string.start_hijacking2), Hijacker.this, new ConfirmDialogListener() {

                    @Override
                    public void onConfirm() {
                        if (mRunning)
                            setStoppedState();
                        System.setCustomData(session);
                        startActivity(new Intent(Hijacker.this, HijackerWebView.class));
                    }

                    @Override
                    public void onCancel() {
                    }
                }).show();
            }
        }
    });
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final Session session = mAdapter.getByPosition(position);
            if (session != null) {
                new InputDialog(getString(R.string.save_session), getString(R.string.set_session_filename), session.getFileName(), true, false, Hijacker.this, new InputDialogListener() {

                    @Override
                    public void onInputEntered(String name) {
                        if (!name.isEmpty()) {
                            try {
                                String filename = session.save(name);
                                Toast.makeText(Hijacker.this, getString(R.string.session_saved_to) + filename + " .", Toast.LENGTH_SHORT).show();
                            } catch (IOException e) {
                                new ErrorDialog(getString(R.string.error), e.toString(), Hijacker.this).show();
                            }
                        } else
                            new ErrorDialog(getString(R.string.error), getString(R.string.invalid_session), Hijacker.this).show();
                    }
                }).show();
            }
            return true;
        }
    });
    mHijackToggleButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    mRequestListener = new RequestListener();
}
Also used : InputDialog(org.csploit.android.gui.dialogs.InputDialog) OnRequestListener(org.csploit.android.net.http.proxy.Proxy.OnRequestListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) SharedPreferences(android.content.SharedPreferences) SpoofSession(org.csploit.android.plugins.mitm.SpoofSession) ErrorDialog(org.csploit.android.gui.dialogs.ErrorDialog) Intent(android.content.Intent) IOException(java.io.IOException) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) InputDialogListener(org.csploit.android.gui.dialogs.InputDialog.InputDialogListener) ListView(android.widget.ListView) OnClickListener(android.view.View.OnClickListener) ConfirmDialogListener(org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener) ConfirmDialog(org.csploit.android.gui.dialogs.ConfirmDialog) SpoofSession(org.csploit.android.plugins.mitm.SpoofSession)

Aggregations

OnClickListener (android.view.View.OnClickListener)772 View (android.view.View)770 TextView (android.widget.TextView)478 Button (android.widget.Button)262 ImageView (android.widget.ImageView)251 Intent (android.content.Intent)179 ListView (android.widget.ListView)110 AdapterView (android.widget.AdapterView)88 LinearLayout (android.widget.LinearLayout)49 ScrollView (android.widget.ScrollView)49 Bundle (android.os.Bundle)42 LayoutInflater (android.view.LayoutInflater)35 ViewGroup (android.view.ViewGroup)30 ArrayList (java.util.ArrayList)29 EditText (android.widget.EditText)27 BindView (butterknife.BindView)27 KeyEvent (android.view.KeyEvent)25 DialogInterface (android.content.DialogInterface)24 FragmentManager (android.support.v4.app.FragmentManager)23 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)23