Search in sources :

Example 16 with SharedPreferences

use of android.content.SharedPreferences in project SimplifyReader by chentao0707.

the class BeepManager method updatePrefs.

private synchronized void updatePrefs() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    playBeep = shouldBeep(prefs, activity);
    vibrate = true;
    if (playBeep && mediaPlayer == null) {
        // The volume on STREAM_SYSTEM is not adjustable, and users found it
        // too loud,
        // so we now play on the music stream.
        activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
        mediaPlayer = buildMediaPlayer(activity);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 17 with SharedPreferences

use of android.content.SharedPreferences in project clutchandroid by clutchio.

the class ClutchAPIClient method setup.

public static void setup(Context inContext, String inAppKey, String inRpcUrl) {
    context = inContext;
    client = AndroidHttpClient.newInstance("Clutch-Android", context);
    try {
        versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "Could not get bundle version");
        e.printStackTrace();
    }
    appKey = inAppKey;
    rpcUrl = inRpcUrl;
    SharedPreferences prefs = context.getSharedPreferences("clutchab" + context.getPackageName(), Context.MODE_PRIVATE);
    fakeGUID = prefs.getString("fakeGUID", null);
    if (fakeGUID == null) {
        fakeGUID = ClutchUtils.getUUID();
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString("fakeGUID", fakeGUID);
        editor.commit();
    }
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) SharedPreferences(android.content.SharedPreferences)

Example 18 with SharedPreferences

use of android.content.SharedPreferences in project cw-omnibus by commonsguy.

the class AbstractCPProxy method onCreate.

@Override
public boolean onCreate() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    if (prefs.getBoolean(PREFS_FIRST_RUN, true)) {
        SharedPreferences.Editor editor = prefs.edit().putBoolean(PREFS_FIRST_RUN, false);
        HashMap<PackageInfo, ArrayList<PermissionLint>> entries = PermissionUtils.checkCustomPermissions(getContext());
        for (Map.Entry<PackageInfo, ArrayList<PermissionLint>> entry : entries.entrySet()) {
            if (!"com.commonsware.android.cpproxy.consumer".equals(entry.getKey().packageName)) {
                tainted = true;
                break;
            }
        }
        editor.putBoolean(PREFS_TAINTED, tainted).apply();
    } else {
        tainted = prefs.getBoolean(PREFS_TAINTED, true);
    }
    return (true);
}
Also used : SharedPreferences(android.content.SharedPreferences) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with SharedPreferences

use of android.content.SharedPreferences in project cw-omnibus by commonsguy.

the class FreecarTileService method onClick.

@Override
public void onClick() {
    super.onClick();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String cnFlat = prefs.getString(PREF_TO_LAUNCH, null);
    if (cnFlat != null) {
        ComponentName cn = ComponentName.unflattenFromString(cnFlat);
        try {
            ActivityInfo info = getPackageManager().getActivityInfo(cn, 0);
            ActivityInfo.WindowLayout layout = info.windowLayout;
            Intent i = new Intent().setComponent(cn).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Point size = new Point();
            getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getSize(size);
            if (layout == null) {
                size.x = size.x / 2;
                size.y = size.y / 2;
            } else {
                if (layout.widthFraction > 0.0f) {
                    size.x = Math.max(layout.minWidth, (int) (size.x * layout.widthFraction));
                } else {
                    size.x = layout.width;
                }
                if (layout.heightFraction > 0.0f) {
                    size.y = Math.max(layout.minHeight, (int) (size.y * layout.heightFraction));
                } else {
                    size.y = layout.height;
                }
            }
            ActivityOptions opts = ActivityOptions.makeBasic().setLaunchBounds(new Rect(0, 0, size.x, size.y));
            startActivity(i, opts.toBundle());
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "Exception trying to launch activity", e);
            toast(R.string.msg_sorry);
        }
    } else {
        toast(R.string.msg_choose);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Rect(android.graphics.Rect) SharedPreferences(android.content.SharedPreferences) ComponentName(android.content.ComponentName) Intent(android.content.Intent) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 20 with SharedPreferences

use of android.content.SharedPreferences 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)

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