Fix regulatory information dialog appearance

Bug 7081675

Replace RegulatoryInfoFragment with a custom preference so that the info
shows up properly in a dialog. DialogFragments do not appear
as dialogs when instantiated from preference XML files.

Change-Id: Icbdf73bd5b1d14f28a01d7b9cb0f37d90340eb46
diff --git a/res/layout/regulatory_info.xml b/res/layout/regulatory_info.xml
index e4999a4..dc1efe8 100755
--- a/res/layout/regulatory_info.xml
+++ b/res/layout/regulatory_info.xml
@@ -14,6 +14,8 @@
      limitations under the License.
 -->
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:adjustViewBounds="true"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:scaleType="centerCrop"
     android:src="@drawable/regulatory_info"/>
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index 4fabc9d..03f1e78 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -89,9 +89,8 @@
         </PreferenceScreen>
         -->
 
-        <Preference android:key="regulatory_info"
-                android:title="@string/regulatory_information"
-                android:fragment="com.android.settings.RegulatoryInfoFragment"/>
+        <com.android.settings.RegulatoryInfoPreference android:key="regulatory_info"
+                android:title="@string/regulatory_information" />
 
         <!-- Device hardware model -->
         <Preference android:key="device_model" 
diff --git a/src/com/android/settings/RegulatoryInfoFragment.java b/src/com/android/settings/RegulatoryInfoFragment.java
deleted file mode 100644
index 7ee13bf..0000000
--- a/src/com/android/settings/RegulatoryInfoFragment.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings;
-
-import android.app.DialogFragment;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.android.settings.R;
-
-/**
- * {@link DialogFragment} that displays regulatory information.
- * "About phone" will show a preference that displays this fragment when
- * clicked if R.bool.config_show_regulatory_info is true.
- */
-public class RegulatoryInfoFragment extends DialogFragment {
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.regulatory_info, container, false);
-    }
-}
diff --git a/src/com/android/settings/RegulatoryInfoPreference.java b/src/com/android/settings/RegulatoryInfoPreference.java
new file mode 100644
index 0000000..f1a6b77
--- /dev/null
+++ b/src/com/android/settings/RegulatoryInfoPreference.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import android.content.Context;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+
+/**
+ * {@link DialogPreference} that displays regulatory information. "About phone"
+ * will show a "Regulatory information" preference if
+ * R.bool.config_show_regulatory_info is true.
+ */
+public class RegulatoryInfoPreference extends DialogPreference {
+
+    public RegulatoryInfoPreference(Context context, AttributeSet attrs) {
+        super(context, attrs, com.android.internal.R.attr.preferenceStyle);
+        setDialogLayoutResource(R.layout.regulatory_info);
+    }
+}