Ejemplo n.º 1
0
        private bool OpenAutoExecEntries(Database db)
        {
            string thisDevice = KeeAutoExecExt.ThisDeviceId;

            foreach (var autoOpenItem in KeeAutoExecExt.GetAutoExecItems(db.KpDatabase))
            {
                if (!autoOpenItem.Enabled)
                {
                    continue;
                }
                if (!KeeAutoExecExt.IsDeviceEnabled(autoOpenItem, thisDevice, out _))
                {
                    continue;
                }
                IOConnectionInfo dbIoc;
                if (KeeAutoExecExt.TryGetDatabaseIoc(autoOpenItem, out dbIoc) &&
                    App.Kp2a.TryGetDatabase(dbIoc) == null &&
                    App.Kp2a.AttemptedToOpenBefore(dbIoc) == false
                    )
                {
                    if (KeeAutoExecExt.AutoOpenEntry(this, autoOpenItem, false))
                    {
                        LaunchingOther = true;
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
            public void Update()
            {
                string thisDevice = KeeAutoExecExt.ThisDeviceId;

                _displayedDatabases = App.Kp2a.OpenDatabases.ToList();
                _autoExecItems      = App.Kp2a.OpenDatabases
                                      .SelectMany(db => KeeAutoExecExt.GetAutoExecItems(db.KpDatabase))
                                      .Where(item =>
                                             item.Visible
                                             &&
                                             KeeAutoExecExt.IsDeviceEnabled(item, thisDevice, out _)
                                             &&
                                             !_displayedDatabases.Any(displayedDb =>
                {
                    IOConnectionInfo itemIoc;
                    return(KeeAutoExecExt.TryGetDatabaseIoc(item, out itemIoc) &&
                           displayedDb.Ioc.IsSameFileAs(itemIoc));
                }))
                                      .ToList();
            }
        private bool OpenAutoExecEntries(Database db)
        {
            try
            {
                string thisDevice = KeeAutoExecExt.ThisDeviceId;
                foreach (var autoOpenItem in KeeAutoExecExt.GetAutoExecItems(db.KpDatabase))
                {
                    if (!autoOpenItem.Enabled)
                    {
                        continue;
                    }
                    if (!KeeAutoExecExt.IsDeviceEnabled(autoOpenItem, thisDevice, out _))
                    {
                        continue;
                    }
                    if (!IsValidIoc(autoOpenItem))
                    {
                        continue;
                    }

                    IOConnectionInfo dbIoc;
                    if (KeeAutoExecExt.TryGetDatabaseIoc(autoOpenItem, out dbIoc) &&
                        App.Kp2a.TryGetDatabase(dbIoc) == null &&
                        App.Kp2a.AttemptedToOpenBefore(dbIoc) == false
                        )
                    {
                        if (KeeAutoExecExt.AutoOpenEntry(this, autoOpenItem, false, new ActivityLaunchModeRequestCode(ReqCodeOpenNewDb)))
                        {
                            LaunchingOther = true;
                            return(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Kp2aLog.LogUnexpectedError(e);
            }

            return(false);
        }
Ejemplo n.º 4
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                if (cursorInflater == null)
                {
                    cursorInflater = (LayoutInflater)_context.GetSystemService(Context.LayoutInflaterService);
                }

                View view;

                if (convertView == null)
                {
                    // if it's not recycled, initialize some attributes

                    view = cursorInflater.Inflate(Resource.Layout.child_db_config_row, parent, false);


                    view.FindViewById <Button>(Resource.Id.child_db_enable_on_this_device).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnEnable(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };

                    view.FindViewById <Button>(Resource.Id.child_db_disable_on_this_device).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnDisable(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };


                    view.FindViewById <Button>(Resource.Id.child_db_edit).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnEdit(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };


                    view.FindViewById <Button>(Resource.Id.child_db_open).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnOpen(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };


                    view.FindViewById <Button>(Resource.Id.child_db_enable_a_copy_for_this_device).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnEnableCopy(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };
                }
                else
                {
                    view = convertView;
                }


                var iv           = view.FindViewById <ImageView>(Resource.Id.child_db_icon);
                var autoExecItem = _displayedChildDatabases[position];
                var pw           = autoExecItem.Entry;

                SprContext ctx = new SprContext(pw, App.Kp2a.FindDatabaseForElement(pw).KpDatabase, SprCompileFlags.All);

                string deviceId = KeeAutoExecExt.ThisDeviceId;

                view.FindViewById <TextView>(Resource.Id.child_db_title).Text =
                    SprEngine.Compile(pw.Strings.GetSafe(PwDefs.TitleField).ReadString(), ctx);

                view.FindViewById <TextView>(Resource.Id.child_db_url).Text =
                    _context.GetString(Resource.String.entry_url) + ": " + SprEngine.Compile(pw.Strings.GetSafe(PwDefs.UrlField).ReadString(), ctx);

                bool deviceEnabledExplict;
                bool deviceEnabled = KeeAutoExecExt.IsDeviceEnabled(autoExecItem, deviceId, out deviceEnabledExplict);

                deviceEnabled &= deviceEnabledExplict;


                if (!autoExecItem.Enabled)
                {
                    view.FindViewById <TextView>(Resource.Id.child_db_enabled_here).Text =
                        _context.GetString(Resource.String.plugin_disabled);
                }
                else
                {
                    view.FindViewById <TextView>(Resource.Id.child_db_enabled_here).Text =
                        _context.GetString(Resource.String.child_db_enabled_on_this_device) + ": " +
                        (!deviceEnabledExplict ?
                         _context.GetString(Resource.String.unspecified)
                            :
                         ((autoExecItem.Enabled && deviceEnabled)
                                ? _context.GetString(Resource.String.yes)
                                : _context.GetString(Resource.String.no)));
                }

                view.FindViewById(Resource.Id.child_db_enable_on_this_device).Visibility  = !deviceEnabled && autoExecItem.Enabled ? ViewStates.Visible : ViewStates.Gone;
                view.FindViewById(Resource.Id.child_db_disable_on_this_device).Visibility = (deviceEnabled || !deviceEnabledExplict) && autoExecItem.Enabled ? ViewStates.Visible : ViewStates.Gone;
                view.FindViewById(Resource.Id.child_db_enable_a_copy_for_this_device_container).Visibility = !deviceEnabled && autoExecItem.Enabled ? ViewStates.Visible : ViewStates.Gone;
                view.FindViewById(Resource.Id.child_db_edit).Visibility = deviceEnabledExplict || !autoExecItem.Enabled  ? ViewStates.Visible : ViewStates.Gone;
                IOConnectionInfo ioc;

                if ((KeeAutoExecExt.TryGetDatabaseIoc(autoExecItem, out ioc)) && App.Kp2a.TryGetDatabase(ioc) == null)
                {
                    view.FindViewById(Resource.Id.child_db_open).Visibility = ViewStates.Visible;
                }
                else
                {
                    view.FindViewById(Resource.Id.child_db_open).Visibility = ViewStates.Gone;
                }


                Database db = App.Kp2a.FindDatabaseForElement(pw);

                bool isExpired = pw.Expires && pw.ExpiryTime < DateTime.Now;

                if (isExpired)
                {
                    db.DrawableFactory.AssignDrawableTo(iv, _context, db.KpDatabase, PwIcon.Expired, PwUuid.Zero, false);
                }
                else
                {
                    db.DrawableFactory.AssignDrawableTo(iv, _context, db.KpDatabase, pw.IconId, pw.CustomIconUuid, false);
                }



                view.Tag = position.ToString();

                return(view);
            }