OSDN Git Service

Bugfixes for Bliss OS + implement alternative solution for hiding navbar
[android-x86/packages-apps-Taskbar.git] / app / src / main / java / com / farmerbb / taskbar / ui / TaskbarController.java
index a8aa6ec..1e781fe 100644 (file)
@@ -34,13 +34,15 @@ import android.content.pm.LauncherActivityInfo;
 import android.content.pm.LauncherApps;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Color;
 import android.graphics.Point;
 import android.graphics.Typeface;
+import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
-import android.net.Uri;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.BatteryManager;
@@ -48,13 +50,14 @@ import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.PowerManager;
+import android.os.Process;
 import android.os.SystemClock;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.provider.Settings;
 import android.speech.RecognizerIntent;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.graphics.ColorUtils;
+import androidx.core.content.ContextCompat;
+import androidx.core.graphics.ColorUtils;
 import android.telephony.PhoneStateListener;
 import android.telephony.SignalStrength;
 import android.telephony.TelephonyManager;
@@ -79,7 +82,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
-import android.support.v4.content.LocalBroadcastManager;
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
 import android.widget.LinearLayout;
 import android.widget.Space;
 import android.widget.TextView;
@@ -90,9 +93,9 @@ import com.farmerbb.taskbar.activity.MainActivity;
 import com.farmerbb.taskbar.R;
 import com.farmerbb.taskbar.activity.HomeActivity;
 import com.farmerbb.taskbar.activity.InvisibleActivityFreeform;
+import com.farmerbb.taskbar.activity.SecondaryHomeActivity;
 import com.farmerbb.taskbar.util.AppEntry;
 import com.farmerbb.taskbar.util.DisplayInfo;
-import com.farmerbb.taskbar.util.FeatureFlags;
 import com.farmerbb.taskbar.util.FreeformHackHelper;
 import com.farmerbb.taskbar.util.IconCache;
 import com.farmerbb.taskbar.util.LauncherHelper;
@@ -112,6 +115,8 @@ public class TaskbarController implements UIController {
     private FrameLayout dashboardButton;
     private LinearLayout navbarButtons;
     private LinearLayout sysTrayLayout;
+    private FrameLayout sysTrayParentLayout;
+    private TextView time;
 
     private Handler handler;
     private Handler handler2;
@@ -133,7 +138,7 @@ public class TaskbarController implements UIController {
     private String sortOrder = "false";
     private boolean runningAppsOnly = false;
 
-    private int layoutId = R.layout.taskbar_left;
+    private int layoutId = R.layout.tb_taskbar_left;
     private int currentTaskbarPosition = 0;
     private boolean showHideAutomagically = false;
     private boolean positionIsVertical = false;
@@ -215,7 +220,7 @@ public class TaskbarController implements UIController {
     public void onCreateHost(UIHost host) {
         SharedPreferences pref = U.getSharedPreferences(context);
         if(pref.getBoolean("taskbar_active", false) || LauncherHelper.getInstance().isOnHomeScreen()) {
-            if(U.canDrawOverlays(context, host instanceof HomeActivityDelegate))
+            if(U.canDrawOverlays(context))
                 drawTaskbar(host);
             else {
                 pref.edit().putBoolean("taskbar_active", false).apply();
@@ -243,42 +248,42 @@ public class TaskbarController implements UIController {
         // Determine where to show the taskbar on screen
         switch(U.getTaskbarPosition(context)) {
             case "bottom_left":
-                layoutId = R.layout.taskbar_left;
+                layoutId = R.layout.tb_taskbar_left;
                 params.gravity = Gravity.BOTTOM | Gravity.LEFT;
                 positionIsVertical = false;
                 break;
             case "bottom_vertical_left":
-                layoutId = R.layout.taskbar_vertical;
+                layoutId = R.layout.tb_taskbar_vertical;
                 params.gravity = Gravity.BOTTOM | Gravity.LEFT;
                 positionIsVertical = true;
                 break;
             case "bottom_right":
-                layoutId = R.layout.taskbar_right;
+                layoutId = R.layout.tb_taskbar_right;
                 params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
                 positionIsVertical = false;
                 break;
             case "bottom_vertical_right":
-                layoutId = R.layout.taskbar_vertical;
+                layoutId = R.layout.tb_taskbar_vertical;
                 params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
                 positionIsVertical = true;
                 break;
             case "top_left":
-                layoutId = R.layout.taskbar_left;
+                layoutId = R.layout.tb_taskbar_left;
                 params.gravity = Gravity.TOP | Gravity.LEFT;
                 positionIsVertical = false;
                 break;
             case "top_vertical_left":
-                layoutId = R.layout.taskbar_top_vertical;
+                layoutId = R.layout.tb_taskbar_top_vertical;
                 params.gravity = Gravity.TOP | Gravity.LEFT;
                 positionIsVertical = true;
                 break;
             case "top_right":
-                layoutId = R.layout.taskbar_right;
+                layoutId = R.layout.tb_taskbar_right;
                 params.gravity = Gravity.TOP | Gravity.RIGHT;
                 positionIsVertical = false;
                 break;
             case "top_vertical_right":
-                layoutId = R.layout.taskbar_top_vertical;
+                layoutId = R.layout.tb_taskbar_top_vertical;
                 params.gravity = Gravity.TOP | Gravity.RIGHT;
                 positionIsVertical = true;
                 break;
@@ -310,34 +315,45 @@ public class TaskbarController implements UIController {
 
         switch(pref.getString("start_button_image", U.getDefaultStartButtonImage(context))) {
             case "default":
-                startButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.all_apps_button_icon));
-                padding = context.getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding);
+                startButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.tb_all_apps_button_icon));
+                padding = context.getResources().getDimensionPixelSize(R.dimen.tb_app_drawer_icon_padding);
                 break;
             case "app_logo":
                 Drawable drawable;
 
                 if(U.isBlissOs(context)) {
-                    drawable = ContextCompat.getDrawable(context, R.drawable.bliss);
+                    drawable = ContextCompat.getDrawable(context, R.drawable.tb_bliss);
                     drawable.setTint(accentColor);
-                } else
-                    drawable = ContextCompat.getDrawable(context, R.mipmap.ic_launcher);
+                } else {
+                    LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
+                    LauncherActivityInfo info = launcherApps.getActivityList(context.getPackageName(), Process.myUserHandle()).get(0);
+                    drawable = IconCache.getInstance(context).getIcon(context, context.getPackageManager(), info);
+                }
 
                 startButton.setImageDrawable(drawable);
-                padding = context.getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding_alt);
+                padding = context.getResources().getDimensionPixelSize(R.dimen.tb_app_drawer_icon_padding_alt);
                 break;
             case "custom":
-                File file = new File(context.getFilesDir() + "/images", "custom_image");
+                File file = new File(context.getFilesDir() + "/tb_images", "custom_image");
                 if(file.exists()) {
-                    try {
-                        startButton.setImageURI(Uri.fromFile(file));
-                    } catch (Exception e) {
-                        U.showToastLong(context, R.string.error_reading_custom_start_image);
-                        startButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.all_apps_button_icon));
-                    }
+                    Handler handler = new Handler();
+                    new Thread(() -> {
+                        Bitmap bitmap = BitmapFactory.decodeFile(file.getPath());
+                        handler.post(() -> {
+                            if(bitmap != null) {
+                                BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), bitmap);
+                                bitmapDrawable.setFilterBitmap(bitmap.getWidth() * bitmap.getHeight() > 2000);
+                                startButton.setImageDrawable(bitmapDrawable);
+                            } else {
+                                U.showToastLong(context, R.string.tb_error_reading_custom_start_image);
+                                startButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.tb_all_apps_button_icon));
+                            }
+                        });
+                    }).start();
                 } else
-                    startButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.all_apps_button_icon));
+                    startButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.tb_all_apps_button_icon));
 
-                padding = context.getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding);
+                padding = context.getResources().getDimensionPixelSize(R.dimen.tb_app_drawer_icon_padding);
                 break;
         }
 
@@ -356,7 +372,7 @@ public class TaskbarController implements UIController {
             return false;
         });
 
-        refreshInterval = (int) (Float.parseFloat(pref.getString("refresh_frequency", "2")) * 1000);
+        refreshInterval = (int) (Float.parseFloat(pref.getString("refresh_frequency", "1")) * 1000);
         if(refreshInterval == 0)
             refreshInterval = 100;
 
@@ -410,7 +426,7 @@ public class TaskbarController implements UIController {
         dashboardButton = layout.findViewById(R.id.dashboard_button);
         navbarButtons = layout.findViewById(R.id.navbar_buttons);
 
-        dashboardEnabled = pref.getBoolean("dashboard", false);
+        dashboardEnabled = pref.getBoolean("dashboard", context.getResources().getBoolean(R.bool.tb_def_dashboard));
         if(dashboardEnabled) {
             layout.findViewById(R.id.square1).setBackgroundColor(accentColor);
             layout.findViewById(R.id.square2).setBackgroundColor(accentColor);
@@ -537,16 +553,58 @@ public class TaskbarController implements UIController {
         if(!navbarButtonsEnabled)
             navbarButtons.setVisibility(View.GONE);
 
-        sysTrayEnabled = FeatureFlags.SYSTEM_TRAY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !positionIsVertical;
+        sysTrayEnabled = U.isSystemTrayEnabled(context);
 
         if(sysTrayEnabled) {
-            sysTrayLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.system_tray, null);
-            sysTrayLayout.setLayoutParams(new FrameLayout.LayoutParams(
+            sysTrayLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.tb_system_tray, null);
+
+            FrameLayout.LayoutParams sysTrayParams = new FrameLayout.LayoutParams(
                     FrameLayout.LayoutParams.WRAP_CONTENT,
-                    context.getResources().getDimensionPixelSize(R.dimen.icon_size)
-            ));
+                    context.getResources().getDimensionPixelSize(R.dimen.tb_icon_size)
+            );
+
+            if(layoutId == R.layout.tb_taskbar_right) {
+                time = sysTrayLayout.findViewById(R.id.time_left);
+                sysTrayParams.gravity = Gravity.START;
+            } else {
+                time = sysTrayLayout.findViewById(R.id.time_right);
+                sysTrayParams.gravity = Gravity.END;
+            }
+
+            time.setVisibility(View.VISIBLE);
+            sysTrayLayout.setLayoutParams(sysTrayParams);
+
+            if(!U.isLibrary(context)) {
+                sysTrayLayout.setOnClickListener(v -> {
+                    U.sendAccessibilityAction(context, AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS);
+                    if(U.shouldCollapse(context, false))
+                        hideTaskbar(true);
+                });
+
+                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+                    sysTrayLayout.setOnLongClickListener(v -> {
+                        U.sendAccessibilityAction(context, AccessibilityService.GLOBAL_ACTION_QUICK_SETTINGS);
+                        if(U.shouldCollapse(context, false))
+                            hideTaskbar(true);
+
+                        return true;
+                    });
+
+                    sysTrayLayout.setOnGenericMotionListener((view, motionEvent) -> {
+                        if(motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
+                                && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
+                            U.sendAccessibilityAction(context, AccessibilityService.GLOBAL_ACTION_QUICK_SETTINGS);
+                            if (U.shouldCollapse(context, false))
+                                hideTaskbar(true);
+                        }
+                        return true;
+                    });
+                }
+            }
 
-            ((FrameLayout) layout.findViewById(R.id.add_systray_here)).addView(sysTrayLayout);
+            sysTrayParentLayout = layout.findViewById(R.id.add_systray_here);
+            sysTrayParentLayout.setVisibility(View.VISIBLE);
+            sysTrayParentLayout.addView(sysTrayLayout);
 
             TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
             manager.listen(listener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
@@ -653,7 +711,7 @@ public class TaskbarController implements UIController {
         List<LauncherActivityInfo> launcherAppCache = new ArrayList<>();
         int maxNumOfEntries = U.getMaxNumOfEntries(context);
         int realNumOfPinnedApps = 0;
-        boolean fullLength = pref.getBoolean("full_length", false);
+        boolean fullLength = pref.getBoolean("full_length", context.getResources().getBoolean(R.bool.tb_def_full_length));
 
         if(runningAppsOnly)
             currentRunningAppIds.clear();
@@ -748,6 +806,8 @@ public class TaskbarController implements UIController {
                             if(!(eventCache.getPackageName().contains(BuildConfig.BASE_APPLICATION_ID)
                                     && !eventCache.getClassName().equals(MainActivity.class.getCanonicalName())
                                     && !eventCache.getClassName().equals(HomeActivity.class.getCanonicalName())
+                                    && !eventCache.getClassName().equals(HomeActivityDelegate.class.getCanonicalName())
+                                    && !eventCache.getClassName().equals(SecondaryHomeActivity.class.getCanonicalName())
                                     && !eventCache.getClassName().equals(InvisibleActivityFreeform.class.getCanonicalName())))
                                 currentForegroundApp = eventCache.getPackageName();
                         }
@@ -869,7 +929,7 @@ public class TaskbarController implements UIController {
                 }
 
                 if(!shouldRedrawTaskbar && runningAppsOnly) {
-                    for(int i = 0; i < finalApplicationIds.size(); i++) {
+                    for(int i = 0; i < currentRunningAppIds.size(); i++) {
                         if(!currentRunningAppIds.get(i).equals(prevRunningAppIds.get(i))) {
                             shouldRedrawTaskbar = true;
                             break;
@@ -918,16 +978,16 @@ public class TaskbarController implements UIController {
                     if(numOfEntries > 0 || fullLength) {
                         ViewGroup.LayoutParams params = scrollView.getLayoutParams();
                         DisplayInfo display = U.getDisplayInfo(context, true);
-                        int recentsSize = context.getResources().getDimensionPixelSize(R.dimen.icon_size) * numOfEntries;
+                        int recentsSize = context.getResources().getDimensionPixelSize(R.dimen.tb_icon_size) * numOfEntries;
                         float maxRecentsSize = fullLength ? Float.MAX_VALUE : recentsSize;
 
                         if(U.getTaskbarPosition(context).contains("vertical")) {
-                            int maxScreenSize = display.height
+                            int maxScreenSize = Math.max(0, display.height
                                     - U.getStatusBarHeight(context)
-                                    - U.getBaseTaskbarSize(context);
+                                    - U.getBaseTaskbarSize(context));
 
                             params.height = (int) Math.min(maxRecentsSize, maxScreenSize)
-                                    + context.getResources().getDimensionPixelSize(R.dimen.divider_size);
+                                    + context.getResources().getDimensionPixelSize(R.dimen.tb_divider_size);
 
                             if(fullLength) {
                                 try {
@@ -955,10 +1015,10 @@ public class TaskbarController implements UIController {
                                 } catch (NullPointerException e) { /* Gracefully fail */ }
                             }
                         } else {
-                            int maxScreenSize = display.width - U.getBaseTaskbarSize(context);
+                            int maxScreenSize = Math.max(0, display.width - U.getBaseTaskbarSize(context));
 
                             params.width = (int) Math.min(maxRecentsSize, maxScreenSize)
-                                    + context.getResources().getDimensionPixelSize(R.dimen.divider_size);
+                                    + context.getResources().getDimensionPixelSize(R.dimen.tb_divider_size);
 
                             if(fullLength) {
                                 try {
@@ -1048,7 +1108,7 @@ public class TaskbarController implements UIController {
         if(userInitiated && Build.BRAND.equalsIgnoreCase("essential")) {
             SharedPreferences pref = U.getSharedPreferences(context);
             if(!pref.getBoolean("grip_rejection_toast_shown", false)) {
-                U.showToastLong(context, R.string.essential_phone_grip_rejection);
+                U.showToastLong(context, R.string.tb_essential_phone_grip_rejection);
                 pref.edit().putBoolean("grip_rejection_toast_shown", true).apply();
             }
         }
@@ -1079,7 +1139,7 @@ public class TaskbarController implements UIController {
                 scrollView.setVisibility(View.INVISIBLE);
 
             if(sysTrayEnabled)
-                sysTrayLayout.setVisibility(View.VISIBLE);
+                sysTrayParentLayout.setVisibility(View.VISIBLE);
 
             shouldRefreshRecents = true;
             startRefreshingRecents();
@@ -1113,7 +1173,7 @@ public class TaskbarController implements UIController {
                 scrollView.setVisibility(View.GONE);
 
             if(sysTrayEnabled)
-                sysTrayLayout.setVisibility(View.GONE);
+                sysTrayParentLayout.setVisibility(View.GONE);
 
             shouldRefreshRecents = false;
             if(thread != null) thread.interrupt();
@@ -1123,8 +1183,10 @@ public class TaskbarController implements UIController {
 
             updateButton(true);
 
-            LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));
-            LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_DASHBOARD"));
+            if(clearVariables) {
+                LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));
+                LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_DASHBOARD"));
+            }
 
             new Handler().post(() -> LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU_SPACE")));
         }
@@ -1260,7 +1322,7 @@ public class TaskbarController implements UIController {
         SharedPreferences pref = U.getSharedPreferences(context);
         boolean hide = pref.getBoolean("invisible_button", false);
 
-        if(button != null) button.setText(context.getString(isCollapsed ? R.string.right_arrow : R.string.left_arrow));
+        if(button != null) button.setText(context.getString(isCollapsed ? R.string.tb_right_arrow : R.string.tb_left_arrow));
         if(layout != null) layout.setAlpha(isCollapsed && hide ? 0 : 1);
     }
 
@@ -1274,7 +1336,7 @@ public class TaskbarController implements UIController {
 
             currentTaskbarPosition = 0;
 
-            if(U.canDrawOverlays(context, host instanceof HomeActivityDelegate))
+            if(U.canDrawOverlays(context))
                 drawTaskbar(host);
             else {
                 SharedPreferences pref = U.getSharedPreferences(context);
@@ -1286,7 +1348,7 @@ public class TaskbarController implements UIController {
     }
 
     private View getView(List<AppEntry> list, int position) {
-        View convertView = View.inflate(context, R.layout.icon, null);
+        View convertView = View.inflate(context, R.layout.tb_icon, null);
 
         final AppEntry entry = list.get(position);
         final SharedPreferences pref = U.getSharedPreferences(context);
@@ -1294,7 +1356,7 @@ public class TaskbarController implements UIController {
         ImageView imageView = convertView.findViewById(R.id.icon);
         ImageView imageView2 = convertView.findViewById(R.id.shortcut_icon);
         imageView.setImageDrawable(entry.getIcon(context));
-        imageView2.setBackgroundColor(pref.getInt("accent_color", context.getResources().getInteger(R.integer.translucent_white)));
+        imageView2.setBackgroundColor(U.getAccentColor(context));
 
         String taskbarPosition = U.getTaskbarPosition(context);
         if(pref.getBoolean("shortcut_icon", true)) {
@@ -1497,32 +1559,25 @@ public class TaskbarController implements UIController {
     }
 
     private void updateSystemTray() {
-        if(sysTrayLayout == null || isScreenOff()) return;
-
-        int accentColor = U.getAccentColor(context);
+        if(!sysTrayEnabled || isScreenOff()) return;
 
         handler.post(() -> {
             ImageView battery = sysTrayLayout.findViewById(R.id.battery);
             battery.setImageDrawable(getBatteryDrawable());
-            battery.setColorFilter(accentColor);
 
             ImageView wifi = sysTrayLayout.findViewById(R.id.wifi);
             wifi.setImageDrawable(getWifiDrawable());
-            wifi.setColorFilter(accentColor);
 
             ImageView bluetooth = sysTrayLayout.findViewById(R.id.bluetooth);
             bluetooth.setImageDrawable(getBluetoothDrawable());
-            bluetooth.setColorFilter(accentColor);
 
             ImageView cellular = sysTrayLayout.findViewById(R.id.cellular);
             cellular.setImageDrawable(getCellularDrawable());
-            cellular.setColorFilter(accentColor);
 
-            TextView time = sysTrayLayout.findViewById(R.id.time);
-            time.setText(context.getString(R.string.systray_clock,
+            time.setText(context.getString(R.string.tb_systray_clock,
                     DateFormat.getTimeFormat(context).format(new Date()),
                     DateFormat.getDateFormat(context).format(new Date())));
-            time.setTextColor(accentColor);
+            time.setTextColor(U.getAccentColor(context));
         });
     }
 
@@ -1531,34 +1586,44 @@ public class TaskbarController implements UIController {
         BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
         int batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
 
+        if(batLevel == Integer.MIN_VALUE)
+            return null;
+
+        IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+        Intent batteryStatus = context.registerReceiver(null, ifilter);
+
+        int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+        boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
+                status == BatteryManager.BATTERY_STATUS_FULL;
+
         String batDrawable;
-        if(batLevel <= 10)
+        if(batLevel < 10 && !isCharging)
             batDrawable = "alert";
-        else if(batLevel <= 20)
+        else if(batLevel < 25)
             batDrawable = "20";
-        else if(batLevel <= 30)
+        else if(batLevel < 40)
             batDrawable = "30";
-        else if(batLevel <= 50)
+        else if(batLevel < 55)
             batDrawable = "50";
-        else if(batLevel <= 60)
+        else if(batLevel < 70)
             batDrawable = "60";
-        else if(batLevel <= 80)
+        else if(batLevel < 85)
             batDrawable = "80";
-        else if(batLevel <= 90)
+        else if(batLevel < 95)
             batDrawable = "90";
         else
             batDrawable = "full";
 
         String charging;
-        if(bm.isCharging())
+        if(isCharging)
             charging = "charging_";
         else
             charging = "";
 
-        String batRes = "ic_battery_" + charging + batDrawable + "_black_24dp";
-        int id = context.getResources().getIdentifier(batRes, "drawable", BuildConfig.APPLICATION_ID);
+        String batRes = "tb_battery_" + charging + batDrawable;
+        int id = getResourceIdFor(batRes);
 
-        return ContextCompat.getDrawable(context, id);
+        return applyTintTo(ContextCompat.getDrawable(context, id));
     }
 
     @TargetApi(Build.VERSION_CODES.M)
@@ -1567,7 +1632,7 @@ public class TaskbarController implements UIController {
 
         NetworkInfo ethernet = manager.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET);
         if(ethernet != null && ethernet.isConnected())
-            return ContextCompat.getDrawable(context, R.drawable.ic_settings_ethernet_black_24dp);
+            return applyTintTo(ContextCompat.getDrawable(context, R.drawable.tb_settings_ethernet));
 
         NetworkInfo wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
         if(wifi == null || !wifi.isConnected())
@@ -1579,16 +1644,16 @@ public class TaskbarController implements UIController {
         WifiInfo wifiInfo = wifiManager.getConnectionInfo();
         int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
 
-        String wifiRes = "ic_signal_wifi_" + level + "_bar_black_24dp";
-        int id = context.getResources().getIdentifier(wifiRes, "drawable", BuildConfig.APPLICATION_ID);
+        String wifiRes = "tb_signal_wifi_" + level + "_bar";
+        int id = getResourceIdFor(wifiRes);
 
-        return ContextCompat.getDrawable(context, id);
+        return applyTintTo(ContextCompat.getDrawable(context, id));
     }
 
     private Drawable getBluetoothDrawable() {
         BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
         if(adapter != null && adapter.isEnabled())
-            return ContextCompat.getDrawable(context, R.drawable.ic_bluetooth_black_24dp);
+            return applyTintTo(ContextCompat.getDrawable(context, R.drawable.tb_bluetooth));
 
         return null;
     }
@@ -1596,14 +1661,26 @@ public class TaskbarController implements UIController {
     @TargetApi(Build.VERSION_CODES.M)
     private Drawable getCellularDrawable() {
         if(Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0)
-            return ContextCompat.getDrawable(context, R.drawable.ic_airplanemode_active_black_24dp);
+            return applyTintTo(ContextCompat.getDrawable(context, R.drawable.tb_airplanemode_active));
 
         if(cellStrength == -1)
             return null;
 
-        String cellRes = "ic_signal_cellular_" + cellStrength + "_bar_black_24dp";
-        int id = context.getResources().getIdentifier(cellRes, "drawable", BuildConfig.APPLICATION_ID);
+        String cellRes = "tb_signal_cellular_" + cellStrength + "_bar";
+        int id = getResourceIdFor(cellRes);
+
+        return applyTintTo(ContextCompat.getDrawable(context, id));
+    }
+    
+    private Drawable applyTintTo(Drawable drawable) {
+        if(drawable == null) return null;
+
+        drawable.setTint(U.getAccentColor(context));
+        return drawable;
+    }
 
-        return ContextCompat.getDrawable(context, id);
+    private int getResourceIdFor(String name) {
+        String packageName = context.getResources().getResourcePackageName(R.drawable.tb_dummy);
+        return context.getResources().getIdentifier(name, "drawable", packageName);
     }
 }