Search in sources :

Example 1 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener 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 2 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener 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)

Example 3 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project PocketHub by pockethub.

the class ItemListFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_item);
    swipeLayout.setOnRefreshListener(this);
    swipeLayout.setColorSchemeResources(R.color.pager_title_background_top_start, R.color.pager_title_background_end, R.color.text_link, R.color.pager_title_background_end);
    listView = (ListView) view.findViewById(android.R.id.list);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onListItemClick((ListView) parent, view, position, id);
        }
    });
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            return onListItemLongClick((ListView) parent, view, position, id);
        }
    });
    progressBar = (ProgressBar) view.findViewById(R.id.pb_loading);
    emptyView = (TextView) view.findViewById(android.R.id.empty);
    configureList(getActivity(), getListView());
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener)

Example 4 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project howabout-android by recomio.

the class MusicPlaylistActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    imageLoader = ImageLoader.getInstance();
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    setAdsContainer(R.id.adView);
    HowaboutApplication application = (HowaboutApplication) getApplication();
    playlistAdapter = application.getPlaylistAdapter();
    if (MusicPlayerService.isLoading()) {
        loadingProgressBar.setVisibility(View.VISIBLE);
        playPauseToggleButton.setVisibility(View.GONE);
    } else {
        if (MusicPlayerService.isPlaying()) {
            playPauseToggleButton.setImageDrawable(pauseIcon);
        } else {
            playPauseToggleButton.setImageDrawable(playIcon);
        }
        loadingProgressBar.setVisibility(View.GONE);
        playPauseToggleButton.setVisibility(View.VISIBLE);
    }
    listView.setAdapter(playlistAdapter);
    playlistAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            try {
                Track track = playlistAdapter.getCurrentItem();
                actionBar.setTitle(track.getTrackTitle());
                actionBar.setSubtitle(track.getArtistName());
                if (MusicPlayerService.isLoading()) {
                    loadingProgressBar.setVisibility(View.VISIBLE);
                    playPauseToggleButton.setVisibility(View.GONE);
                } else {
                    if (MusicPlayerService.isPlaying()) {
                        playPauseToggleButton.setImageDrawable(pauseIcon);
                    } else {
                        playPauseToggleButton.setImageDrawable(playIcon);
                    }
                    loadingProgressBar.setVisibility(View.GONE);
                    playPauseToggleButton.setVisibility(View.VISIBLE);
                }
                imageLoader.displayImage(track.getThumbnailUrl(), songImageView, new ImageLoadingListener() {

                    @Override
                    public void onLoadingStarted(String imageUri, View view) {
                    }

                    @Override
                    public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                    }

                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                    }

                    @Override
                    public void onLoadingCancelled(String imageUri, View view) {
                    }
                });
                String lyrics = playlistAdapter.getCurrentLyrics();
                if (lyrics == null) {
                    lyricsScrollView.setVisibility(View.GONE);
                    lyricsTextView.setText("");
                } else {
                    lyricsScrollView.setVisibility(View.VISIBLE);
                    lyricsTextView.setText(lyrics);
                }
                listView.invalidate();
            } catch (Exception e) {
            }
        }

        @Override
        public void onInvalidated() {
        }
    });
    playlistAdapter.notifyDataSetChanged();
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            playlistAdapter.play(position);
            playlistAdapter.notifyDataSetChanged();
        }
    });
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            playlistAdapter.remove(position);
            return true;
        }
    });
    playPauseToggleButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playPauseToggle();
            if (MusicPlayerService.isPlaying()) {
                playPauseToggleButton.setImageDrawable(pauseIcon);
            } else {
                playPauseToggleButton.setImageDrawable(playIcon);
            }
        }
    });
    prevButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playPrev();
        }
    });
    nextButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playlistAdapter.playNext();
        }
    });
    UpdateCurrentPositionTask updateCurrentPositionTask = new UpdateCurrentPositionTask();
    updateCurrentPositionTimer.scheduleAtFixedRate(updateCurrentPositionTask, 0, 1000);
}
Also used : ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) HowaboutApplication(io.recom.howabout.HowaboutApplication) DataSetObserver(android.database.DataSetObserver) ContentView(roboguice.inject.ContentView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Bitmap(android.graphics.Bitmap) OnClickListener(android.view.View.OnClickListener) ActionBar(com.actionbarsherlock.app.ActionBar) Track(io.recom.howabout.category.music.model.Track)

Example 5 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SystemappRemover method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Button delButton = (Button) getView().findViewById(R.id.btn_delete);
    final Button profileButton = (Button) getView().findViewById(R.id.btn_profile);
    // create arraylist of apps not to be removed
    final ArrayList<String> safetyList = new ArrayList<String>();
    // app
    safetyList.add("CertInstaller.apk");
    safetyList.add("DrmProvider.apk");
    safetyList.add("PackageInstaller.apk");
    safetyList.add("TelephonyProvider.apk");
    safetyList.add("ResurrectionStats.apk");
    safetyList.add("LockClock.apk");
    safetyList.add("ResurrectionOTA.apk");
    // priv-app
    safetyList.add("ContactsProvider.apk");
    safetyList.add("DefaultContainerService.apk");
    safetyList.add("Dialer.apk");
    safetyList.add("DownloadProvider.apk");
    safetyList.add("FusedLocation.apk");
    safetyList.add("Keyguard.apk");
    safetyList.add("MediaProvider.apk");
    safetyList.add("ProxyHandler.apk");
    safetyList.add("Settings.apk");
    safetyList.add("SettingsProvider.apk");
    safetyList.add("SystemUI.apk");
    safetyList.add("TeleService.apk");
    // create arraylist from /system/app and /system/priv-app content
    File system = new File(systemPath);
    File systemPriv = new File(systemPrivPath);
    String[] sysappArray = combine(system.list(), systemPriv.list());
    mSysApp = new ArrayList<String>(Arrays.asList(sysappArray));
    // remove .odex files from list
    filterOdex();
    // remove "apps not to be removed" from list and sort list
    mSysApp.removeAll(safetyList);
    Collections.sort(mSysApp);
    // populate listview via arrayadapter
    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice, mSysApp);
    // startup dialog
    //showDialog(STARTUP_DIALOG, null, adapter);
    final ListView lv = (ListView) getView().findViewById(R.string.listsystem);
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    lv.setAdapter(adapter);
    // longclick an entry
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
            // create deletion dialog
            String item = lv.getAdapter().getItem(arg2).toString();
            showDialog(DELETE_DIALOG, item, adapter);
            return false;
        }
    });
    // click button delete
    delButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // check which items are selected
            String item = null;
            int len = lv.getCount();
            SparseBooleanArray checked = lv.getCheckedItemPositions();
            for (int i = lv.getCount() - 1; i > 0; i--) {
                if (checked.get(i)) {
                    item = mSysApp.get(i);
                }
            }
            if (item == null) {
                toast(getResources().getString(R.string.sizer_message_noselect));
                return;
            } else {
                showDialog(DELETE_MULTIPLE_DIALOG, item, adapter);
            }
        }
    });
    // click button profile
    profileButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // call select dialog
            selectDialog(mSysApp, adapter);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) ListView(android.widget.ListView) Button(android.widget.Button) SparseBooleanArray(android.util.SparseBooleanArray) File(java.io.File)

Aggregations

View (android.view.View)11 AdapterView (android.widget.AdapterView)11 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)11 ListView (android.widget.ListView)9 TextView (android.widget.TextView)9 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)6 Intent (android.content.Intent)4 OnClickListener (android.view.View.OnClickListener)4 ImageView (android.widget.ImageView)4 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 ConfirmDialog (org.csploit.android.gui.dialogs.ConfirmDialog)2 ConfirmDialogListener (org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener)2 ErrorDialog (org.csploit.android.gui.dialogs.ErrorDialog)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 IntentFilter (android.content.IntentFilter)1 DataSetObserver (android.database.DataSetObserver)1