Search in sources :

Example 1 with SharedPreferences

use of android.content.SharedPreferences in project android by cSploit.

the class ExploitFinder 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);
    Target t = System.getCurrentTarget();
    if (!t.hasOpenPorts())
        new FinishDialog(getString(R.string.warning), getString(R.string.no_open_ports), this).show();
    else if (!t.hasOpenPortsWithService())
        new FinishDialog(getString(R.string.warning), getString(R.string.no_infos_on_target), this).show();
    mSearchFloatingActionButton = (FloatingActionButton) findViewById(R.id.searchToggleButton);
    mSearchProgress = (ProgressBar) findViewById(R.id.searchActivity);
    mListView = (ListView) findViewById(android.R.id.list);
    mAdapter = new ExploitAdapter();
    UIThread = this;
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(listener);
    mSearchFloatingActionButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (buttonPlayed) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
}
Also used : Target(org.csploit.android.net.Target) SharedPreferences(android.content.SharedPreferences) FinishDialog(org.csploit.android.gui.dialogs.FinishDialog) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 2 with SharedPreferences

use of android.content.SharedPreferences in project android by cSploit.

the class Inspector 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);
    mStartButton = (FloatingActionButton) findViewById(R.id.inspectToggleButton);
    mActivity = (ProgressBar) findViewById(R.id.inspectActivity);
    TextView mDeviceName = (TextView) findViewById(R.id.deviceName);
    mDeviceType = (TextView) findViewById(R.id.deviceType);
    mDeviceOS = (TextView) findViewById(R.id.deviceOS);
    mDeviceServices = (TextView) findViewById(R.id.deviceServices);
    mFocusedScan = System.getCurrentTarget().hasOpenPorts();
    mDeviceName.setText(System.getCurrentTarget().toString());
    if (System.getCurrentTarget().getDeviceType() != null)
        mDeviceType.setText(System.getCurrentTarget().getDeviceType());
    if (System.getCurrentTarget().getDeviceOS() != null)
        mDeviceOS.setText(System.getCurrentTarget().getDeviceOS());
    empty = getText(R.string.unknown).toString();
    // yep, we're on main thread here
    write_services();
    mStartButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mRunning) {
                setStoppedState();
            } else {
                setStartedState();
            }
        }
    });
    mReceiver = new Receiver(System.getCurrentTarget());
}
Also used : SharedPreferences(android.content.SharedPreferences) OnClickListener(android.view.View.OnClickListener) InspectionReceiver(org.csploit.android.tools.NMap.InspectionReceiver) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with SharedPreferences

use of android.content.SharedPreferences in project persistence by casidiablo.

the class PersistencePreferenceActivity method addFieldsToHierarchy.

private void addFieldsToHierarchy(PrefsFactory prefsFactory, List<PrefMetadata> fields) {
    // add each field to the preference screen
    for (PrefMetadata metadata : fields) {
        // define a default value
        boolean hasDefault = !"".equals(metadata.getDefaultValue());
        // depending on the type of the field, create different kind of preferences
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        Class<?> type = metadata.getType();
        String key = metadata.getKey();
        String defaultValue = metadata.getDefaultValue();
        android.preference.Preference preference = null;
        if (prefsFactory != null) {
            preference = prefsFactory.getPreference(key);
        }
        if (preference == null) {
            if (type == boolean.class || type == Boolean.class) {
                preference = new SmartCheckBoxPreference(this);
                boolean checked = prefs.getBoolean(key, hasDefault ? Boolean.parseBoolean(defaultValue) : false);
                ((CheckBoxPreference) preference).setChecked(checked);
            } else if (type == int.class || type == Integer.class || type == long.class || type == Long.class) {
                if (type == long.class || type == Long.class) {
                    long value = prefs.getLong(key, hasDefault ? Long.parseLong(defaultValue) : 0L);
                    preference = new SmartEditTextPreference(this, long.class, String.valueOf(value));
                    ((EditTextPreference) preference).setText(String.valueOf(value));
                } else {
                    int value = prefs.getInt(key, hasDefault ? Integer.parseInt(defaultValue) : 0);
                    preference = new SmartEditTextPreference(this, int.class, String.valueOf(value));
                    ((EditTextPreference) preference).setText(String.valueOf(value));
                }
                setEditTextType(preference, InputType.TYPE_CLASS_NUMBER);
            } else if (type == float.class || type == Float.class || type == double.class || type == Double.class) {
                float def = hasDefault ? ((Double) Double.parseDouble(defaultValue)).floatValue() : 0.0f;
                float value = prefs.getFloat(key, def);
                preference = new SmartEditTextPreference(this, float.class, String.valueOf(value));
                ((EditTextPreference) preference).setText(String.valueOf(value));
                setEditTextType(preference, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            } else if (type == String.class) {
                String def = hasDefault ? defaultValue : null;
                if (metadata.getEntries() != 0 && metadata.getEntryValues() != 0) {
                    preference = new ListPreference(this);
                } else {
                    preference = new SmartEditTextPreference(this, String.class, def);
                    ((EditTextPreference) preference).setText(def);
                }
            }
        }
        if (preference == null) {
            continue;
        }
        // if a preference was created, add it to the preference screen
        preference.setKey(key);
        int title = metadata.getTitle();
        if (title != 0) {
            preference.setTitle(title);
        }
        if (metadata.getSummary() != 0) {
            preference.setSummary(metadata.getSummary());
        }
        if (!"".equals(metadata.getDependency())) {
            mDependencies.put(preference, metadata.getDependency());
        }
        if (preference instanceof SmartEditTextPreference) {
            SmartEditTextPreference pref = (SmartEditTextPreference) preference;
            int dialogTitle = metadata.getDialogTitle();
            if (dialogTitle != 0) {
                pref.setDialogTitle(dialogTitle);
            }
            int dialogIcon = metadata.getDialogIcon();
            if (dialogIcon != 0) {
                pref.setDialogIcon(dialogIcon);
            }
            int dialogMessage = metadata.getDialogMessage();
            if (dialogMessage != 0) {
                pref.setDialogMessage(dialogMessage);
            }
        } else if (preference instanceof ListPreference) {
            ListPreference pref = (ListPreference) preference;
            pref.setEntries(metadata.getEntries());
            pref.setEntryValues(metadata.getEntryValues());
        }
        getPreferenceScreen().addPreference(preference);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) android.preference(android.preference)

Example 4 with SharedPreferences

use of android.content.SharedPreferences in project Launcher3 by chislon.

the class LauncherProvider method justLoadedOldDb.

/**
     * @param Should we load the old db for upgrade? first run only.
     */
public synchronized boolean justLoadedOldDb() {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = getContext().getSharedPreferences(spKey, Context.MODE_PRIVATE);
    boolean loadedOldDb = false || sJustLoadedFromOldDb;
    sJustLoadedFromOldDb = false;
    if (sp.getBoolean(UPGRADED_FROM_OLD_DATABASE, false)) {
        SharedPreferences.Editor editor = sp.edit();
        editor.remove(UPGRADED_FROM_OLD_DATABASE);
        editor.commit();
        loadedOldDb = true;
    }
    return loadedOldDb;
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 5 with SharedPreferences

use of android.content.SharedPreferences in project UltimateAndroid by cymcsg.

the class NavigationDrawerFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Read in the flag indicating whether or not the user has demonstrated awareness of the
    // drawer. See PREF_USER_LEARNED_DRAWER for details.
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
    if (savedInstanceState != null) {
        mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
        mFromSavedInstanceState = true;
    }
    // Select either the default item (0) or the last selected item.
    selectItem(mCurrentSelectedPosition);
}
Also used : SharedPreferences(android.content.SharedPreferences)

Aggregations

SharedPreferences (android.content.SharedPreferences)1653 Intent (android.content.Intent)206 View (android.view.View)101 Editor (android.content.SharedPreferences.Editor)100 TextView (android.widget.TextView)64 Context (android.content.Context)56 File (java.io.File)56 PendingIntent (android.app.PendingIntent)55 IOException (java.io.IOException)55 ArrayList (java.util.ArrayList)52 Bundle (android.os.Bundle)40 JSONObject (org.json.JSONObject)40 JSONException (org.json.JSONException)39 DialogInterface (android.content.DialogInterface)37 SuppressLint (android.annotation.SuppressLint)33 AdapterView (android.widget.AdapterView)32 ImageView (android.widget.ImageView)32 ListView (android.widget.ListView)32 ComponentName (android.content.ComponentName)31 AlertDialog (android.app.AlertDialog)26