InjectedSetting.java revision e2921c9566e34fd95b864cca247ff71cf9b30752
1/*
2 * Copyright (C) 2013 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
17package com.android.settings.location;
18
19import android.content.Intent;
20
21/**
22 * Specifies a setting that is being injected into Settings > Location > Location services.
23 *
24 * @see android.location.SettingInjectorService
25 */
26class InjectedSetting {
27
28    /**
29     * Package for the subclass of {@link android.location.SettingInjectorService} and for the
30     * settings activity.
31     */
32    public final String packageName;
33
34    /**
35     * Class name for the subclass of {@link android.location.SettingInjectorService} that
36     * specifies dynamic values for the location setting.
37     */
38    public final String className;
39
40    /**
41     * The {@link android.preference.Preference#getTitle()} value.
42     */
43    public final String title;
44
45    /**
46     * The {@link android.preference.Preference#getIcon()} value.
47     */
48    public final int iconId;
49
50    /**
51     * The activity to launch to allow the user to modify the settings value. Assumed to be in the
52     * {@link #packageName} package.
53     */
54    public final String settingsActivity;
55
56    public InjectedSetting(String packageName, String className,
57            String title, int iconId, String settingsActivity) {
58        this.packageName = packageName;
59        this.className = className;
60        this.title = title;
61        this.iconId = iconId;
62        this.settingsActivity = settingsActivity;
63    }
64
65    @Override
66    public String toString() {
67        return "InjectedSetting{" +
68                "mPackageName='" + packageName + '\'' +
69                ", mClassName='" + className + '\'' +
70                ", label=" + title +
71                ", iconId=" + iconId +
72                ", settingsActivity='" + settingsActivity + '\'' +
73                '}';
74    }
75
76    /**
77     * Returns the intent to start the {@link #className} service.
78     */
79    public Intent getServiceIntent() {
80        Intent intent = new Intent();
81        intent.setClassName(packageName, className);
82        return intent;
83    }
84}
85