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;
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;
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;
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;
// 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;
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;
}
dashboardButton = layout.findViewById(R.id.dashboard_button);
navbarButtons = layout.findViewById(R.id.navbar_buttons);
- dashboardEnabled = pref.getBoolean("dashboard", context.getResources().getBoolean(R.bool.def_dashboard));
+ 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);
sysTrayEnabled = U.isSystemTrayEnabled(context);
if(sysTrayEnabled) {
- sysTrayLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.system_tray, null);
+ 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.taskbar_right) {
+ if(layoutId == R.layout.tb_taskbar_right) {
time = sysTrayLayout.findViewById(R.id.time_left);
sysTrayParams.gravity = Gravity.START;
} else {
time.setVisibility(View.VISIBLE);
sysTrayLayout.setLayoutParams(sysTrayParams);
- 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.isLibrary(context)) {
+ sysTrayLayout.setOnClickListener(v -> {
+ U.sendAccessibilityAction(context, AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS);
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) {
+ 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;
- });
+
+ 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;
+ });
+ }
}
sysTrayParentLayout = layout.findViewById(R.id.add_systray_here);
List<LauncherActivityInfo> launcherAppCache = new ArrayList<>();
int maxNumOfEntries = U.getMaxNumOfEntries(context);
int realNumOfPinnedApps = 0;
- boolean fullLength = pref.getBoolean("full_length", context.getResources().getBoolean(R.bool.def_full_length));
+ boolean fullLength = pref.getBoolean("full_length", context.getResources().getBoolean(R.bool.tb_def_full_length));
if(runningAppsOnly)
currentRunningAppIds.clear();
}
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;
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")) {
- 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 {
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 {
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();
}
}
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);
}
}
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);
ImageView cellular = sysTrayLayout.findViewById(R.id.cellular);
cellular.setImageDrawable(getCellularDrawable());
- 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(U.getAccentColor(context));
else
charging = "";
- String batRes = "ic_battery_" + charging + batDrawable + "_black_24dp";
+ String batRes = "tb_battery_" + charging + batDrawable;
int id = getResourceIdFor(batRes);
return applyTintTo(ContextCompat.getDrawable(context, id));
NetworkInfo ethernet = manager.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET);
if(ethernet != null && ethernet.isConnected())
- return applyTintTo(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())
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
- String wifiRes = "ic_signal_wifi_" + level + "_bar_black_24dp";
+ String wifiRes = "tb_signal_wifi_" + level + "_bar";
int id = getResourceIdFor(wifiRes);
return applyTintTo(ContextCompat.getDrawable(context, id));
private Drawable getBluetoothDrawable() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if(adapter != null && adapter.isEnabled())
- return applyTintTo(ContextCompat.getDrawable(context, R.drawable.ic_bluetooth_black_24dp));
+ return applyTintTo(ContextCompat.getDrawable(context, R.drawable.tb_bluetooth));
return null;
}
@TargetApi(Build.VERSION_CODES.M)
private Drawable getCellularDrawable() {
if(Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0)
- return applyTintTo(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";
+ String cellRes = "tb_signal_cellular_" + cellStrength + "_bar";
int id = getResourceIdFor(cellRes);
return applyTintTo(ContextCompat.getDrawable(context, id));
}
private int getResourceIdFor(String name) {
- String packageName = context.getResources().getResourcePackageName(R.mipmap.ic_launcher);
+ String packageName = context.getResources().getResourcePackageName(R.drawable.tb_dummy);
return context.getResources().getIdentifier(name, "drawable", packageName);
}
}