Steve McKay | fefcd70 | 2015-08-20 16:19:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.documentsui; |
| 18 | |
Ben Kwa | c469334 | 2015-09-30 10:00:10 -0700 | [diff] [blame] | 19 | import static com.android.internal.util.Preconditions.checkNotNull; |
| 20 | |
| 21 | import android.app.Activity; |
Ben Kwa | 9192318 | 2015-08-27 16:06:33 -0700 | [diff] [blame] | 22 | import android.content.Context; |
Ben Kwa | c469334 | 2015-09-30 10:00:10 -0700 | [diff] [blame] | 23 | import android.support.design.widget.Snackbar; |
| 24 | import android.view.View; |
Ben Kwa | 9192318 | 2015-08-27 16:06:33 -0700 | [diff] [blame] | 25 | |
Steve McKay | 4d0255f | 2015-09-25 16:02:56 -0700 | [diff] [blame] | 26 | /** @hide */ |
Steve McKay | fefcd70 | 2015-08-20 16:19:38 +0000 | [diff] [blame] | 27 | public final class Shared { |
Steve McKay | 459bc2b | 2015-09-16 15:07:31 -0700 | [diff] [blame] | 28 | public static final boolean DEBUG = true; |
Steve McKay | fefcd70 | 2015-08-20 16:19:38 +0000 | [diff] [blame] | 29 | public static final String TAG = "Documents"; |
Steve McKay | 4d0255f | 2015-09-25 16:02:56 -0700 | [diff] [blame] | 30 | public static final String EXTRA_STACK = "com.android.documentsui.STACK"; |
Ben Kwa | 9192318 | 2015-08-27 16:06:33 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Generates a formatted quantity string. |
| 34 | */ |
| 35 | public static final String getQuantityString(Context context, int resourceId, int quantity) { |
| 36 | return context.getResources().getQuantityString(resourceId, quantity, quantity); |
| 37 | } |
Ben Kwa | c469334 | 2015-09-30 10:00:10 -0700 | [diff] [blame] | 38 | |
| 39 | public static final Snackbar makeSnackbar(Activity activity, int messageId, int duration) { |
| 40 | return makeSnackbar(activity, activity.getResources().getText(messageId), duration); |
| 41 | } |
| 42 | |
| 43 | public static final Snackbar makeSnackbar(Activity activity, CharSequence message, int duration) |
| 44 | { |
| 45 | final View view = checkNotNull(activity.findViewById(R.id.coordinator_layout)); |
| 46 | return Snackbar.make(view, message, duration); |
| 47 | } |
Steve McKay | fefcd70 | 2015-08-20 16:19:38 +0000 | [diff] [blame] | 48 | } |