1 /* Copyright 2017 Braden Farmer
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 package com.farmerbb.taskbar.util;
18 import android.content.Context;
19 import android.content.Intent;
20 import android.net.Uri;
21 import android.os.Build;
23 import androidx.browser.customtabs.CustomTabsIntent;
24 import androidx.core.content.ContextCompat;
26 import com.farmerbb.taskbar.R;
27 import com.farmerbb.taskbar.activity.TaskerConditionActivity;
28 import com.mikepenz.foundation_icons_typeface_library.FoundationIcons;
29 import com.mikepenz.iconics.Iconics;
31 // Utility class meant for abstracting out all third-party dependencies.
32 // This allows the Android-x86 version of Taskbar to be built purely from AOSP source.
33 // TODO Do not make changes to this file without making corresponding changes to the Android-x86 version.
35 public class DependencyUtils {
37 private DependencyUtils() {}
39 public static CharSequence getKeyboardShortcutSummary(Context context) {
40 Iconics.registerFont(new FoundationIcons());
41 return new Iconics.IconicsBuilder()
43 .on(context.getString(R.string.tb_pref_description_keyboard_shortcut))
47 static ToastInterface createToast(Context context, String message, int length) {
48 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
49 return new ToastFrameworkImpl(context, message, length);
51 return new ToastCompatImpl(context, message, length);
54 public static void requestTaskerQuery(Context context) {
55 Intent query = new Intent(com.twofortyfouram.locale.api.Intent.ACTION_REQUEST_QUERY);
56 query.putExtra(com.twofortyfouram.locale.api.Intent.EXTRA_STRING_ACTIVITY_CLASS_NAME, TaskerConditionActivity.class.getName());
57 context.sendBroadcast(query);
60 public static void openChromeCustomTab(Context context, Uri uri) {
61 new CustomTabsIntent.Builder()
62 .setToolbarColor(ContextCompat.getColor(context, R.color.tb_colorPrimary))
63 .setSecondaryToolbarColor(ContextCompat.getColor(context, R.color.tb_main_activity_background))
64 .setStartAnimations(context, R.anim.tb_enter_from_right, R.anim.tb_exit_to_left)
65 .setExitAnimations(context, R.anim.tb_enter_from_left, R.anim.tb_exit_to_right)
67 .addDefaultShareMenuItem()
69 .launchUrl(context, uri);