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);
}
}
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();
}
}
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);
}
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);
}
}
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;
}
});
}
Aggregations