1 /* 2 * Copyright (C) 2023 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 package com.android.intentresolver.ui; 17 18 import android.content.Intent; 19 import android.provider.MediaStore; 20 21 import androidx.annotation.StringRes; 22 23 import com.android.intentresolver.R; 24 25 /** 26 * Provides a set of related resources for different use cases. 27 */ 28 public enum ActionTitle { 29 VIEW(Intent.ACTION_VIEW, 30 R.string.whichViewApplication, 31 R.string.whichViewApplicationNamed, 32 R.string.whichViewApplicationLabel), 33 EDIT(Intent.ACTION_EDIT, 34 R.string.whichEditApplication, 35 R.string.whichEditApplicationNamed, 36 R.string.whichEditApplicationLabel), 37 SEND(Intent.ACTION_SEND, 38 R.string.whichSendApplication, 39 R.string.whichSendApplicationNamed, 40 R.string.whichSendApplicationLabel), 41 SENDTO(Intent.ACTION_SENDTO, 42 R.string.whichSendToApplication, 43 R.string.whichSendToApplicationNamed, 44 R.string.whichSendToApplicationLabel), 45 SEND_MULTIPLE(Intent.ACTION_SEND_MULTIPLE, 46 R.string.whichSendApplication, 47 R.string.whichSendApplicationNamed, 48 R.string.whichSendApplicationLabel), 49 CAPTURE_IMAGE(MediaStore.ACTION_IMAGE_CAPTURE, 50 R.string.whichImageCaptureApplication, 51 R.string.whichImageCaptureApplicationNamed, 52 R.string.whichImageCaptureApplicationLabel), 53 DEFAULT(null, 54 R.string.whichApplication, 55 R.string.whichApplicationNamed, 56 R.string.whichApplicationLabel), 57 HOME(Intent.ACTION_MAIN, 58 R.string.whichHomeApplication, 59 R.string.whichHomeApplicationNamed, 60 R.string.whichHomeApplicationLabel); 61 62 // titles for layout that deals with http(s) intents 63 public static final int BROWSABLE_TITLE_RES = R.string.whichOpenLinksWith; 64 public static final int BROWSABLE_HOST_TITLE_RES = R.string.whichOpenHostLinksWith; 65 public static final int BROWSABLE_HOST_APP_TITLE_RES = R.string.whichOpenHostLinksWithApp; 66 public static final int BROWSABLE_APP_TITLE_RES = R.string.whichOpenLinksWithApp; 67 68 public final String action; 69 public final int titleRes; 70 public final int namedTitleRes; 71 public final @StringRes int labelRes; 72 ActionTitle(String action, int titleRes, int namedTitleRes, @StringRes int labelRes)73 ActionTitle(String action, int titleRes, int namedTitleRes, @StringRes int labelRes) { 74 this.action = action; 75 this.titleRes = titleRes; 76 this.namedTitleRes = namedTitleRes; 77 this.labelRes = labelRes; 78 } 79 forAction(String action)80 public static ActionTitle forAction(String action) { 81 for (ActionTitle title : values()) { 82 if (title != HOME && action != null && action.equals(title.action)) { 83 return title; 84 } 85 } 86 return DEFAULT; 87 } 88 } 89