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.annotation.SuppressLint;
19 import android.content.Context;
20 import android.view.Gravity;
21 import android.widget.Toast;
23 import com.farmerbb.taskbar.R;
25 class ToastFrameworkImpl implements ToastInterface {
28 @SuppressLint("ShowToast")
29 ToastFrameworkImpl(Context context, String message, int length) {
30 int offset = context.getResources().getDimensionPixelSize(R.dimen.tb_toast_y_offset);
31 if(U.getCurrentApiVersion() > 29.0 && U.isDesktopModeActive(context)) {
32 offset = offset + U.getNavbarHeight(context);
35 toast = Toast.makeText(context, message, length);
36 toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL, 0, offset);
45 public void cancel() {