protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activityMain);

            _loadingLayout      = FindViewById <LinearLayout>(Resource.Id.layoutLoading);
            _emptyLayout        = FindViewById <LinearLayout>(Resource.Id.layoutEmpty);
            _disconnectedLayout = FindViewById <LinearLayout>(Resource.Id.layoutDisconnected);

            _retryButton        = FindViewById <MaterialButton>(Resource.Id.buttonRetry);
            _retryButton.Click += OnRetryClick;

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new ScrollingListLayoutCallback(Resources.Configuration.IsScreenRound);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _customIconCache = new CustomIconCache(this);

            _authListAdapter              = new AuthenticatorListAdapter(_customIconCache);
            _authListAdapter.ItemClick   += ItemClick;
            _authListAdapter.HasStableIds = true;
            _authList.SetAdapter(_authListAdapter);
        }
Exemple #2
0
        private void InitViews()
        {
            _loadingLayout = FindViewById <RelativeLayout>(Resource.Id.layoutLoading);
            _emptyLayout   = FindViewById <RelativeLayout>(Resource.Id.layoutEmpty);
            _offlineLayout = FindViewById <LinearLayout>(Resource.Id.layoutOffline);

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new AuthenticatorListLayoutCallback(this);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _authListAdapter              = new AuthenticatorListAdapter(_authSource, _customIconCache);
            _authListAdapter.ItemClick   += OnItemClick;
            _authListAdapter.HasStableIds = true;
            _authList.SetAdapter(_authListAdapter);

            var categoriesDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.drawerCategories);

            _categoryListAdapter = new CategoryListAdapter(this, _categoryCache);
            categoriesDrawer.SetAdapter(_categoryListAdapter);
            categoriesDrawer.ItemSelected += OnCategorySelected;
        }
Exemple #3
0
        private void InitAuthenticatorList()
        {
            var viewModePref = PreferenceManager.GetDefaultSharedPreferences(this)
                               .GetString("pref_viewMode", "default");

            var viewMode = viewModePref switch
            {
                "compact" => AuthenticatorListAdapter.ViewMode.Compact,
                "tile" => AuthenticatorListAdapter.ViewMode.Tile,
                _ => AuthenticatorListAdapter.ViewMode.Default
            };

            _authListAdapter = new AuthenticatorListAdapter(_authSource, _customIconSource, viewMode, IsDark)
            {
                HasStableIds = true
            };

            _authListAdapter.ItemClick       += OnAuthenticatorClick;
            _authListAdapter.MenuClick       += OnAuthenticatorOptionsClick;
            _authListAdapter.MovementStarted += delegate
            {
                _bottomAppBar.PerformHide();
            };

            _authListAdapter.MovementFinished += async delegate
            {
                RunOnUiThread(_bottomAppBar.PerformShow);
                await NotifyWearAppOfChange();
            };

            _authList.SetAdapter(_authListAdapter);

            var minColumnWidth = viewMode switch
            {
                AuthenticatorListAdapter.ViewMode.Compact => 300,
                AuthenticatorListAdapter.ViewMode.Tile => 170,
                _ => 340
            };

            var layout = new AutoGridLayoutManager(this, minColumnWidth);

            _authList.SetLayoutManager(layout);

            _authList.AddItemDecoration(new GridSpacingItemDecoration(this, layout, 8));
            _authList.HasFixedSize = true;

            var animation =
                AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fall_down);

            _authList.LayoutAnimation = animation;

            var callback    = new ReorderableListTouchHelperCallback(_authListAdapter, layout);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }
Exemple #4
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activityMain);

            try
            {
                await WearableClass.GetMessageClient(this).AddListenerAsync(this);
                await FindServerNode();
            }
            catch (ApiException) { }

            _loadingLayout = FindViewById <RelativeLayout>(Resource.Id.layoutLoading);
            _emptyLayout   = FindViewById <RelativeLayout>(Resource.Id.layoutEmpty);
            _offlineLayout = FindViewById <LinearLayout>(Resource.Id.layoutOffline);

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new ScrollingListLayoutCallback(Resources.Configuration.IsScreenRound);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _authCache       = new ListCache <WearAuthenticator>("authenticators", this);
            _categoryCache   = new ListCache <WearCategory>("categories", this);
            _customIconCache = new CustomIconCache(this);

            await _authCache.Init();

            _authSource = new AuthenticatorSource(_authCache);

            _authListAdapter              = new AuthenticatorListAdapter(_authSource, _customIconCache);
            _authListAdapter.ItemClick   += OnItemClick;
            _authListAdapter.HasStableIds = true;
            _authList.SetAdapter(_authListAdapter);

            if (_authCache.GetItems().Count > 0 || _serverNode == null)
            {
                UpdateViewState();
            }

            await _categoryCache.Init();

            var categoriesDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.drawerCategories);

            _categoryListAdapter = new CategoryListAdapter(this, _categoryCache);
            categoriesDrawer.SetAdapter(_categoryListAdapter);
            categoriesDrawer.ItemSelected += OnCategorySelected;

            await Refresh();
        }
        private void InitViews()
        {
            _loadingLayout = FindViewById <RelativeLayout>(Resource.Id.layoutLoading);
            _emptyLayout   = FindViewById <RelativeLayout>(Resource.Id.layoutEmpty);
            _offlineLayout = FindViewById <LinearLayout>(Resource.Id.layoutOffline);

            _authList = FindViewById <WearableRecyclerView>(Resource.Id.list);
            _authList.EdgeItemsCenteringEnabled = true;
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(12);
            _authList.SetItemAnimator(null);

            var layoutCallback = new AuthenticatorListLayoutCallback(this);

            _authList.SetLayoutManager(new WearableLinearLayoutManager(this, layoutCallback));

            _authListAdapter                = new AuthenticatorListAdapter(_authSource, _customIconCache);
            _authListAdapter.ItemClick     += OnItemClick;
            _authListAdapter.ItemLongClick += OnItemLongClick;
            _authListAdapter.HasStableIds   = true;
            _authListAdapter.DefaultAuth    = _preferences.DefaultAuth;
            _authList.SetAdapter(_authListAdapter);

            _categoryList        = FindViewById <WearableNavigationDrawerView>(Resource.Id.drawerCategories);
            _categoryListAdapter = new CategoryListAdapter(this, _categoryCache);
            _categoryList.SetAdapter(_categoryListAdapter);
            _categoryList.ItemSelected += OnCategorySelected;

            if (_authSource.CategoryId == null)
            {
                return;
            }

            var categoryPosition = _categoryCache.FindIndex(c => c.Id == _authSource.CategoryId) + 1;

            if (categoryPosition <= -1)
            {
                return;
            }

            _preventCategorySelectEvent = true;
            _categoryList.SetCurrentItem(categoryPosition, false);
        }
        private void InitAuthenticatorList()
        {
            var isCompact = PreferenceManager.GetDefaultSharedPreferences(this)
                            .GetBoolean("pref_compactMode", false);

            _authenticatorListAdapter = new AuthenticatorListAdapter(_authenticatorSource, IsDark, isCompact);

            _authenticatorListAdapter.ItemClick       += OnAuthenticatorClick;
            _authenticatorListAdapter.MenuClick       += OnAuthenticatorOptionsClick;
            _authenticatorListAdapter.MovementStarted += (sender, i) =>
            {
                _bottomAppBar.PerformHide();
            };
            _authenticatorListAdapter.MovementFinished += async(sender, i) =>
            {
                _bottomAppBar.PerformShow();
                await NotifyWearAppOfChange();
            };

            _authenticatorListAdapter.HasStableIds = true;

            _authList.SetAdapter(_authenticatorListAdapter);

            var layout = new AutoGridLayoutManager(this, 340);

            _authList.SetLayoutManager(layout);

            _authList.AddItemDecoration(new GridSpacingItemDecoration(this, layout, 8));
            _authList.HasFixedSize = true;

            var animation =
                AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fall_down);

            _authList.LayoutAnimation = animation;

            var callback    = new ReorderableListTouchHelperCallback(_authenticatorListAdapter, layout);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }