Skip to content

Commit

Permalink
Settings: Regulatory: Fullscreen instead of AlertDialog
Browse files Browse the repository at this point in the history
* Also adapt S style
* ScrollView -> NestedScrollView
* Remove unnecessary DialogInterface

Change-Id: I38dd316cce28104f42dd261982dea1bf2eb87eab
  • Loading branch information
ReallySnow authored and madmax7896 committed Sep 1, 2023
1 parent 56bdd75 commit cc7135e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
1 change: 1 addition & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3489,6 +3489,7 @@
android:name="RegulatoryInfoDisplayActivity"
android:label="@string/regulatory_labels"
android:exported="true"
android:theme="@style/Theme.SubSettingsBase"
android:enabled="@bool/config_show_regulatory_info">
<intent-filter>
<action android:name="android.settings.SHOW_REGULATORY_INFO" />
Expand Down
9 changes: 6 additions & 3 deletions res/layout/regulatory_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fillViewport="true" >

<ImageView
android:id="@+id/regulatoryInfo"
android:adjustViewBounds="true"
Expand All @@ -24,5 +27,5 @@
android:scaleType="centerCrop"
android:contentDescription="@string/regulatory_labels"
android:src="@drawable/regulatory_info" />
</ScrollView>

</androidx.core.widget.NestedScrollView>
27 changes: 4 additions & 23 deletions src/com/android/settings/RegulatoryInfoDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.android.settings;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand All @@ -31,7 +29,8 @@
import android.widget.TextView;

import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;

import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;

import java.util.Locale;

Expand All @@ -45,8 +44,7 @@
* or add a string resource named "regulatory_info_text" with an HTML version of the required
* information (text will be centered in the dialog).
*/
public class RegulatoryInfoDisplayActivity extends Activity implements
DialogInterface.OnDismissListener {
public class RegulatoryInfoDisplayActivity extends CollapsingToolbarBaseActivity {

private final String REGULATORY_INFO_RESOURCE = "regulatory_info";
private static final String DEFAULT_REGULATORY_INFO_FILEPATH =
Expand All @@ -60,11 +58,6 @@ public class RegulatoryInfoDisplayActivity extends Activity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.regulatory_labels)
.setOnDismissListener(this)
.setPositiveButton(android.R.string.ok, null /* onClickListener */);

boolean regulatoryInfoDrawableExists = false;

final String regulatoryInfoFile = getRegulatoryInfoImageFileName();
Expand Down Expand Up @@ -101,14 +94,7 @@ protected void onCreate(Bundle savedInstanceState) {
} else {
image.setImageResource(resId);
}
builder.setView(view);
builder.show();
} else if (regulatoryText.length() > 0) {
builder.setMessage(regulatoryText);
AlertDialog dialog = builder.show();
// we have to show the dialog first, or the setGravity() call will throw a NPE
TextView messageText = (TextView) dialog.findViewById(android.R.id.message);
messageText.setGravity(Gravity.CENTER);
setContentView(view);
} else {
// neither drawable nor text resource exists, finish activity
finish();
Expand Down Expand Up @@ -146,11 +132,6 @@ int getResourceId() {
return resId;
}

@Override
public void onDismiss(DialogInterface dialog) {
finish(); // close the activity
}

private String getCoo() {
return SystemProperties.get("ro.boot.hardware.coo", "");
}
Expand Down

0 comments on commit cc7135e

Please sign in to comment.