blob: 98ebb55b0a021cfc903149db5792ed610eecdd94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*
* Copyright (c) 2012-2015 Arne Schwabe
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
*/
package de.blinkt.openvpn.fragments;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import de.blinkt.openvpn.R;
import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.api.AppRestrictions;
public class Settings_UserEditable extends KeyChainSettingsFragment implements View.OnClickListener {
private View mView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.settings_usereditable, container, false);
TextView messageView = (TextView) mView.findViewById(R.id.messageUserEdit);
messageView.setText(getString(R.string.message_no_user_edit, getPackageString(mProfile.mProfileCreator)));
initKeychainViews(this.mView);
return mView;
}
private String getPackageString(String packageName) {
if (AppRestrictions.PROFILE_CREATOR.equals(packageName))
return "Android Enterprise Management";
final PackageManager pm = getActivity().getPackageManager();
ApplicationInfo ai;
try {
ai = pm.getApplicationInfo(packageName, 0);
} catch (final PackageManager.NameNotFoundException e) {
ai = null;
}
final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");
return String.format("%s (%s)", applicationName, packageName);
}
@Override
protected void savePreferences() {
}
@Override
public void onResume() {
super.onResume();
mView.findViewById(R.id.keystore).setVisibility(View.GONE);
if (mProfile.mAuthenticationType == VpnProfile.TYPE_USERPASS_KEYSTORE ||
mProfile.mAuthenticationType == VpnProfile.TYPE_KEYSTORE)
mView.findViewById(R.id.keystore).setVisibility(View.VISIBLE);
}
}
|