From 4462fec2a97fc522e06a532bcbb13120ca5423d7 Mon Sep 17 00:00:00 2001
From: nuclearfog <hatespirit666@gmail.com>
Date: Sun, 7 Feb 2021 10:51:15 +0100
Subject: [PATCH] added custom menu group icon

---
 .../twidda/activity/ListDetail.java           |  1 +
 .../twidda/activity/TweetActivity.java        |  8 +++++---
 .../twidda/activity/UserProfile.java          | 10 ++++++----
 .../twidda/backend/utils/AppStyles.java       | 19 +++++++++++++++++++
 app/src/main/res/drawable/group.xml           |  9 +++++++++
 5 files changed, 40 insertions(+), 7 deletions(-)
 create mode 100644 app/src/main/res/drawable/group.xml

diff --git a/app/src/main/java/org/nuclearfog/twidda/activity/ListDetail.java b/app/src/main/java/org/nuclearfog/twidda/activity/ListDetail.java
index f89e78ed..f7ce9311 100644
--- a/app/src/main/java/org/nuclearfog/twidda/activity/ListDetail.java
+++ b/app/src/main/java/org/nuclearfog/twidda/activity/ListDetail.java
@@ -150,6 +150,7 @@ public class ListDetail extends AppCompatActivity implements OnTabSelectedListen
     public boolean onCreateOptionsMenu(Menu m) {
         getMenuInflater().inflate(R.menu.userlist, m);
         AppStyles.setMenuIconColor(m, settings.getIconColor());
+        AppStyles.setOverflowIcon(toolbar, settings.getIconColor());
         return super.onCreateOptionsMenu(m);
     }
 
diff --git a/app/src/main/java/org/nuclearfog/twidda/activity/TweetActivity.java b/app/src/main/java/org/nuclearfog/twidda/activity/TweetActivity.java
index e108aed2..c4b2126e 100644
--- a/app/src/main/java/org/nuclearfog/twidda/activity/TweetActivity.java
+++ b/app/src/main/java/org/nuclearfog/twidda/activity/TweetActivity.java
@@ -101,6 +101,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
     private TextView tweet_api, tweetDate, tweetText, scrName, usrName, tweetLocName, sensitive_media;
     private Button ansButton, rtwButton, favButton, replyName, tweetLocGPS, retweeter;
     private ImageView profile_img, mediaButton;
+    private Toolbar toolbar;
     private Dialog deleteDialog;
 
     private GlobalSettings settings;
@@ -114,9 +115,9 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
     protected void onCreate(@Nullable Bundle b) {
         super.onCreate(b);
         setContentView(R.layout.page_tweet);
-        Toolbar tool = findViewById(R.id.tweet_toolbar);
         View root = findViewById(R.id.tweet_layout);
         ViewPager pager = findViewById(R.id.tweet_pager);
+        toolbar = findViewById(R.id.tweet_toolbar);
         ansButton = findViewById(R.id.tweet_answer);
         rtwButton = findViewById(R.id.tweet_retweet);
         favButton = findViewById(R.id.tweet_favorit);
@@ -166,8 +167,8 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
         tweetText.setMovementMethod(LinkAndScrollMovement.getInstance());
         tweetText.setLinkTextColor(settings.getHighlightColor());
         deleteDialog = DialogBuilder.create(this, DELETE_TWEET, this);
-        tool.setTitle("");
-        setSupportActionBar(tool);
+        toolbar.setTitle("");
+        setSupportActionBar(toolbar);
         AppStyles.setTheme(settings, root);
 
         retweeter.setOnClickListener(this);
@@ -222,6 +223,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
     @Override
     public boolean onCreateOptionsMenu(Menu m) {
         getMenuInflater().inflate(R.menu.tweet, m);
+        AppStyles.setOverflowIcon(toolbar, settings.getIconColor());
         return super.onCreateOptionsMenu(m);
     }
 
diff --git a/app/src/main/java/org/nuclearfog/twidda/activity/UserProfile.java b/app/src/main/java/org/nuclearfog/twidda/activity/UserProfile.java
index bb1feee9..a431da25 100644
--- a/app/src/main/java/org/nuclearfog/twidda/activity/UserProfile.java
+++ b/app/src/main/java/org/nuclearfog/twidda/activity/UserProfile.java
@@ -142,6 +142,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
     private Button following, follower;
     private ViewPager tabPages;
     private TabLayout tabLayout;
+    private Toolbar toolbar;
     private Dialog unfollowConfirm, blockConfirm, muteConfirm;
 
     @Nullable
@@ -154,7 +155,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
     protected void onCreate(@Nullable Bundle b) {
         super.onCreate(b);
         setContentView(R.layout.page_profile);
-        Toolbar tool = findViewById(R.id.profile_toolbar);
+        toolbar = findViewById(R.id.profile_toolbar);
         View root = findViewById(R.id.user_view);
         tabLayout = findViewById(R.id.profile_tab);
         user_bio = findViewById(R.id.bio);
@@ -178,7 +179,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
         user_location.setCompoundDrawablesWithIntrinsicBounds(R.drawable.userlocation, 0, 0, 0);
         user_website.setCompoundDrawablesWithIntrinsicBounds(R.drawable.link, 0, 0, 0);
         follow_back.setCompoundDrawablesWithIntrinsicBounds(R.drawable.followback, 0, 0, 0);
-        tool.setBackgroundColor(settings.getBackgroundColor() & TOOLBAR_TRANSPARENCY);
+        toolbar.setBackgroundColor(settings.getBackgroundColor() & TOOLBAR_TRANSPARENCY);
         username.setBackgroundColor(settings.getBackgroundColor() & TEXT_TRANSPARENCY);
         follow_back.setBackgroundColor(settings.getBackgroundColor() & TEXT_TRANSPARENCY);
         user_bio.setMovementMethod(LinkAndScrollMovement.getInstance());
@@ -186,8 +187,8 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
         AppStyles.setTheme(settings, root);
         user_website.setTextColor(settings.getHighlightColor());
 
-        tool.setTitle("");
-        setSupportActionBar(tool);
+        toolbar.setTitle("");
+        setSupportActionBar(toolbar);
         adapter = new FragmentAdapter(getSupportFragmentManager());
         tabPages.setAdapter(adapter);
         tabPages.setOffscreenPageLimit(2);
@@ -262,6 +263,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
     public boolean onCreateOptionsMenu(Menu m) {
         getMenuInflater().inflate(R.menu.profile, m);
         AppStyles.setMenuIconColor(m, settings.getIconColor());
+        AppStyles.setOverflowIcon(toolbar, settings.getIconColor());
         return super.onCreateOptionsMenu(m);
     }
 
diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java b/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java
index da90a104..148f75e9 100644
--- a/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java
+++ b/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java
@@ -24,7 +24,9 @@ import android.widget.TextView;
 import androidx.annotation.ArrayRes;
 import androidx.annotation.Nullable;
 import androidx.appcompat.content.res.AppCompatResources;
+import androidx.appcompat.widget.Toolbar;
 import androidx.cardview.widget.CardView;
+import androidx.core.content.res.ResourcesCompat;
 import androidx.viewpager.widget.ViewPager;
 
 import com.google.android.material.tabs.TabLayout;
@@ -214,7 +216,24 @@ public final class AppStyles {
         }
     }
 
+    /**
+     * set Toolbar overflow icon color
+     *
+     * @param toolbar Toolbar with overflow icon
+     * @param color   icon color
+     */
+    public static void setOverflowIcon(Toolbar toolbar, int color) {
+        Drawable groupIcon = ResourcesCompat.getDrawable(toolbar.getResources(), R.drawable.group, null);
+        setDrawableColor(groupIcon, color);
+        toolbar.setOverflowIcon(groupIcon);
+    }
 
+    /**
+     * sets progress circle color
+     *
+     * @param circle progress circle
+     * @param color  highlight color
+     */
     public static void setProgressColor(ProgressBar circle, int color) {
         Drawable icon = circle.getIndeterminateDrawable();
         if (icon != null) {
diff --git a/app/src/main/res/drawable/group.xml b/app/src/main/res/drawable/group.xml
new file mode 100644
index 00000000..61b33c7c
--- /dev/null
+++ b/app/src/main/res/drawable/group.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="20dp"
+    android:height="20dp"
+    android:viewportWidth="20"
+    android:viewportHeight="20">
+    <path
+        android:pathData="M10.001,7.8C8.786,7.8 7.8,8.785 7.8,10s0.986,2.2 2.201,2.2S12.2,11.215 12.2,10S11.216,7.8 10.001,7.8zM10.001,5.2C11.216,5.2 12.2,4.214 12.2,3s-0.984,-2.2 -2.199,-2.2S7.8,1.785 7.8,3S8.786,5.2 10.001,5.2zM10.001,14.8C8.786,14.8 7.8,15.785 7.8,17s0.986,2.2 2.201,2.2S12.2,18.215 12.2,17S11.216,14.8 10.001,14.8z"
+        android:fillColor="#FFFFFF" />
+</vector>