OSDN Git Service

625ca13fe2d04dfd39b8ee410e934d4b28be1c3a
[android-x86/packages-apps-Taskbar.git] / app / src / playstore / java / com / farmerbb / taskbar / util / DependencyUtils.java
1 /* Copyright 2017 Braden Farmer
2  *
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
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15
16 package com.farmerbb.taskbar.util;
17
18 import android.content.Context;
19 import android.content.Intent;
20 import android.os.Build;
21
22 import com.farmerbb.taskbar.R;
23 import com.farmerbb.taskbar.activity.TaskerConditionActivity;
24 import com.mikepenz.foundation_icons_typeface_library.FoundationIcons;
25 import com.mikepenz.iconics.Iconics;
26
27 // Utility class meant for abstracting out all third-party dependencies.
28 // This allows the Android-x86 version of Taskbar to be built purely from AOSP source.
29 // TODO Do not make changes to this file without making corresponding changes to the Android-x86 version.
30
31 public class DependencyUtils {
32
33     private DependencyUtils() {}
34
35     public static CharSequence getKeyboardShortcutSummary(Context context) {
36         Iconics.registerFont(new FoundationIcons());
37         return new Iconics.IconicsBuilder()
38                 .ctx(context)
39                 .on(context.getString(R.string.tb_pref_description_keyboard_shortcut))
40                 .build();
41     }
42
43     static ToastInterface createToast(Context context, String message, int length) {
44         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
45             return new ToastFrameworkImpl(context, message, length);
46         else
47             return new ToastCompatImpl(context, message, length);
48     }
49
50     public static void requestTaskerQuery(Context context) {
51         Intent query = new Intent(com.twofortyfouram.locale.api.Intent.ACTION_REQUEST_QUERY);
52         query.putExtra(com.twofortyfouram.locale.api.Intent.EXTRA_STRING_ACTIVITY_CLASS_NAME, TaskerConditionActivity.class.getName());
53         context.sendBroadcast(query);
54     }
55 }