Skip to content

Commit

Permalink
show copy count in menu if sorting by copy count
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-mh committed Sep 11, 2023
1 parent 1b4d419 commit 49cc2fb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="?attr/colorOnSurface"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,36 @@

</LinearLayout>

<LinearLayout
android:id="@+id/layoutCopyCount"
android:visibility="gone"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp"
android:paddingTop="8dp"
android:layout_marginBottom="10dp"
android:background="@drawable/listitemborder"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:src="@drawable/baseline_content_copy_24"
android:tint="?attr/colorOnSurface"
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp"
android:layout_width="24dp"
android:layout_height="24dp"/>

<com.google.android.material.textview.MaterialTextView
android:id="@+id/textCopyCount"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceSubtitle1"/>

</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listMenu"
android:overScrollMode="never"
Expand Down
1 change: 1 addition & 0 deletions AuthenticatorPro.Droid/src/Activity/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ private void OnAuthenticatorMenuClicked(object sender, string secret)
var bundle = new Bundle();
bundle.PutInt("type", (int) auth.Type);
bundle.PutLong("counter", auth.Counter);
bundle.PutInt("copyCount", auth.CopyCount);

var fragment = new AuthenticatorMenuBottomSheet { Arguments = bundle };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class AuthenticatorMenuBottomSheet : BottomSheet
{
private AuthenticatorType _type;
private long _counter;
private long _copyCount;

public AuthenticatorMenuBottomSheet() : base(Resource.Layout.sheetAuthenticatorMenu, Resource.String.edit)
{
Expand All @@ -34,6 +35,7 @@ public override void OnCreate(Bundle savedInstanceState)

_type = (AuthenticatorType) Arguments.GetInt("type", 0);
_counter = Arguments.GetLong("counter", 0);
_copyCount = Arguments.GetInt("copyCount", 0);
}

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Expand All @@ -48,6 +50,16 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
view.FindViewById<LinearLayout>(Resource.Id.layoutCounter).Visibility = ViewStates.Visible;
}

var preferences = new PreferenceWrapper(RequireContext());

if (preferences.SortMode is SortMode.CopyCountAscending or SortMode.CopyCountDescending)
{
var copyCountText = view.FindViewById<MaterialTextView>(Resource.Id.textCopyCount);
copyCountText.Text = _copyCount.ToString();

view.FindViewById<LinearLayout>(Resource.Id.layoutCopyCount).Visibility = ViewStates.Visible;
}

var menu = view.FindViewById<RecyclerView>(Resource.Id.listMenu);
SetupMenu(menu,
new List<SheetMenuItem>
Expand Down

0 comments on commit 49cc2fb

Please sign in to comment.