Sha256: d17f0de619630a564e30c19532a6a97ef8ae2eb35bc8f301273a648e613c135a
Contents?: true
Size: 1.39 KB
Versions: 37
Compression:
Stored size: 1.39 KB
Contents
package sh.calaba.instrumentationbackend.actions.preferences; import sh.calaba.instrumentationbackend.InstrumentationBackend; import sh.calaba.instrumentationbackend.Result; import sh.calaba.instrumentationbackend.actions.Action; import android.content.SharedPreferences; /** * Allows writing of SharedPreferences. * * See Ruby API docs for more info: * https://github.com/calabash/calabash-android/blob/master/documentation/ruby_api.md * * @author Juan Delgado (juan@ustwo.co.uk) */ public class SetPreferences implements Action { @Override public Result execute(String... args) { SharedPreferences preferences = null; try{ preferences = PreferencesUtils.getPreferencesFromArgs(args, InstrumentationBackend.instrumentation.getTargetContext()); } catch(Exception e){ return Result.fromThrowable(e); } String[] parserdArgs = new String[args.length]; int totalArgs = args.length; int added = 0; for(int i = 0; i <totalArgs; i++){ String arg = args[i]; // ignoring SharedPreferences name and weird chars if(arg.equals(args[0]) || arg.equals("{") || arg.equals("}")){ continue; } parserdArgs[added++] = arg; } SharedPreferences.Editor editor = preferences.edit(); PreferencesUtils.setPreferences(editor, parserdArgs); editor.commit(); return Result.successResult(); } @Override public String key() { return "set_preferences"; } }
Version data entries
37 entries across 37 versions & 1 rubygems