import java.util.Date;
import java.util.List;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.widget.LinearLayout;
import android.widget.Space;
import android.widget.TextView;
private int cellStrength = -1;
- private View.OnClickListener ocl = view -> {
- Intent intent = new Intent("com.farmerbb.taskbar.TOGGLE_START_MENU");
- LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
- };
+ private View.OnClickListener ocl = view ->
+ U.sendBroadcast(context, TaskbarIntent.ACTION_TOGGLE_START_MENU);
private BroadcastReceiver showReceiver = new BroadcastReceiver() {
@Override
break;
}
- LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
- lbm.sendBroadcast(new Intent(TaskbarIntent.ACTION_HIDE_START_MENU));
- lbm.sendBroadcast(new Intent("com.farmerbb.taskbar.UPDATE_HOME_SCREEN_MARGINS"));
+ U.sendBroadcast(context, TaskbarIntent.ACTION_HIDE_START_MENU);
+ U.sendBroadcast(context, TaskbarIntent.ACTION_UPDATE_HOME_SCREEN_MARGINS);
if(altButtonConfig) {
button = layout.findViewById(R.id.hide_taskbar_button_alt);
layout.findViewById(R.id.square5).setBackgroundColor(accentColor);
layout.findViewById(R.id.square6).setBackgroundColor(accentColor);
- dashboardButton.setOnClickListener(v -> LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_DASHBOARD")));
+ dashboardButton.setOnClickListener(v ->
+ U.sendBroadcast(context, TaskbarIntent.ACTION_TOGGLE_DASHBOARD));
} else
dashboardButton.setVisibility(View.GONE);
U.showHideNavigationBar(context, false);
if(FreeformHackHelper.getInstance().isTouchAbsorberActive()) {
- lbm.sendBroadcast(new Intent("com.farmerbb.taskbar.FINISH_FREEFORM_ACTIVITY"));
+ U.sendBroadcast(context, TaskbarIntent.ACTION_FINISH_FREEFORM_ACTIVITY);
new Handler().postDelayed(() -> U.startTouchAbsorberActivity(context), 500);
}
- lbm.unregisterReceiver(showReceiver);
- lbm.unregisterReceiver(hideReceiver);
- lbm.unregisterReceiver(tempShowReceiver);
- lbm.unregisterReceiver(tempHideReceiver);
- lbm.unregisterReceiver(startMenuAppearReceiver);
- lbm.unregisterReceiver(startMenuDisappearReceiver);
-
- lbm.registerReceiver(showReceiver, new IntentFilter("com.farmerbb.taskbar.SHOW_TASKBAR"));
- lbm.registerReceiver(hideReceiver, new IntentFilter(TaskbarIntent.ACTION_HIDE_TASKBAR));
- lbm.registerReceiver(tempShowReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_SHOW_TASKBAR"));
- lbm.registerReceiver(tempHideReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_HIDE_TASKBAR"));
- lbm.registerReceiver(startMenuAppearReceiver, new IntentFilter("com.farmerbb.taskbar.START_MENU_APPEARING"));
- lbm.registerReceiver(startMenuDisappearReceiver, new IntentFilter("com.farmerbb.taskbar.START_MENU_DISAPPEARING"));
+ U.registerReceiver(context, showReceiver, TaskbarIntent.ACTION_SHOW_TASKBAR);
+ U.registerReceiver(context, hideReceiver, TaskbarIntent.ACTION_HIDE_TASKBAR);
+ U.registerReceiver(context, tempShowReceiver, TaskbarIntent.ACTION_TEMP_SHOW_TASKBAR);
+ U.registerReceiver(context, tempHideReceiver, TaskbarIntent.ACTION_TEMP_HIDE_TASKBAR);
+ U.registerReceiver(context, startMenuAppearReceiver, TaskbarIntent.ACTION_START_MENU_APPEARING);
+ U.registerReceiver(context, startMenuDisappearReceiver, TaskbarIntent.ACTION_START_MENU_DISAPPEARING);
startRefreshingRecents();
updateButton(false);
- new Handler().post(() -> LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.SHOW_START_MENU_SPACE")));
+ new Handler().post(() ->
+ U.sendBroadcast(context, TaskbarIntent.ACTION_SHOW_START_MENU_SPACE));
}
}
updateButton(true);
if(clearVariables) {
- LocalBroadcastManager
- .getInstance(context)
- .sendBroadcast(new Intent(TaskbarIntent.ACTION_HIDE_START_MENU));
- LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_DASHBOARD"));
+ U.sendBroadcast(context, TaskbarIntent.ACTION_HIDE_START_MENU);
+ U.sendBroadcast(context, TaskbarIntent.ACTION_HIDE_DASHBOARD);
}
- new Handler().post(() -> LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU_SPACE")));
+ new Handler().post(() ->
+ U.sendBroadcast(context, TaskbarIntent.ACTION_HIDE_START_MENU_SPACE));
}
}
} else if(pref.getBoolean("auto_hide_navbar", false))
U.showHideNavigationBar(context, true);
- LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
-
- lbm.unregisterReceiver(showReceiver);
- lbm.unregisterReceiver(hideReceiver);
- lbm.unregisterReceiver(tempShowReceiver);
- lbm.unregisterReceiver(tempHideReceiver);
- lbm.unregisterReceiver(startMenuAppearReceiver);
- lbm.unregisterReceiver(startMenuDisappearReceiver);
+ U.unregisterReceiver(context, showReceiver);
+ U.unregisterReceiver(context, hideReceiver);
+ U.unregisterReceiver(context, tempShowReceiver);
+ U.unregisterReceiver(context, tempHideReceiver);
+ U.unregisterReceiver(context, startMenuAppearReceiver);
+ U.unregisterReceiver(context, startMenuDisappearReceiver);
if(sysTrayEnabled) {
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return getDrawableForSysTray(id);
}
-
+
private Drawable getDrawableForSysTray(int id) {
Drawable drawable = null;
try {
drawable = ContextCompat.getDrawable(context, id);
} catch (Resources.NotFoundException e) { /* Gracefully fail */ }
-
+
if(drawable == null) return null;
drawable.setTint(U.getAccentColor(context));