Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b0611ce authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9f1edb0a,Iaba7077c

* changes:
  Make model & hardware UI full screen.
  Merge Copyable into Sliceable.
parents cf6757a7 8ae15142
Loading
Loading
Loading
Loading
+0 −65
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2017 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.
  -->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="24dp">

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/model_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/model_info" />
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/model_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/serial_number_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/status_serial_number" />
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/serial_number_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/hardware_rev_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/hardware_revision" />
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/hardware_rev_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>
</ScrollView>
 No newline at end of file
+52 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2019 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.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="hardware_info_screen"
    android:title="@string/hardware_info"
    settings:keywords="@string/keywords_model_and_hardware">

    <!-- Model -->
    <Preference
        android:key="hardware_info_device_model"
        android:title="@string/model_info"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.hardwareinfo.DeviceModelPreferenceController"
        settings:enableCopying="true"/>

    <!-- SerialNumber -->
    <Preference
        android:key="hardware_info_device_serial"
        android:title="@string/status_serial_number"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.hardwareinfo.SerialNumberPreferenceController"
        settings:enableCopying="true"/>

    <!-- Hardware revision -->
    <Preference
        android:key="hardware_info_device_revision"
        android:title="@string/hardware_revision"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.hardwareinfo.HardwareRevisionPreferenceController"
        settings:enableCopying="true"/>

</PreferenceScreen>
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -105,7 +105,8 @@
        settings:keywords="@string/keywords_model_and_hardware"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.DeviceModelPreferenceController"/>
        android:fragment="com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFragment"
        settings:controller="com.android.settings.deviceinfo.HardwareInfoPreferenceController"/>

    <!-- IMEI -->
    <Preference
+6 −2
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.slices.Copyable;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -50,7 +49,7 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.development.DevelopmentSettingsEnabler;

public class BuildNumberPreferenceController extends BasePreferenceController implements Copyable,
public class BuildNumberPreferenceController extends BasePreferenceController implements
        LifecycleObserver, OnStart {

    static final int TAPS_TO_BE_A_DEVELOPER = 7;
@@ -108,6 +107,11 @@ public class BuildNumberPreferenceController extends BasePreferenceController im
        return true;
    }

    @Override
    public boolean isCopyableSlice() {
        return true;
    }

    @Override
    public void copy() {
        final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
+0 −91
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.deviceinfo;

import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

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

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {

    public static final String TAG = "HardwareInfo";

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.DIALOG_SETTINGS_HARDWARE_INFO;
    }

    public static HardwareInfoDialogFragment newInstance() {
        final HardwareInfoDialogFragment fragment = new HardwareInfoDialogFragment();
        return fragment;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.hardware_info)
                .setPositiveButton(android.R.string.ok, null);
        final View content = LayoutInflater.from(builder.getContext())
                .inflate(R.layout.dialog_hardware_info, null /* parent */);
        // Model
        setText(content, R.id.model_label, R.id.model_value,
                DeviceModelPreferenceController.getDeviceModel());

        // Serial number
        setText(content, R.id.serial_number_label, R.id.serial_number_value, getSerialNumber());

        // Hardware rev
        setText(content, R.id.hardware_rev_label, R.id.hardware_rev_value,
                SystemProperties.get("ro.boot.hardware.revision"));

        return builder.setView(content).create();
    }

    @VisibleForTesting
    void setText(View content, int labelViewId, int valueViewId, String value) {
        if (content == null) {
            return;
        }
        final View labelView = content.findViewById(labelViewId);
        final TextView valueView = content.findViewById(valueViewId);
        if (!TextUtils.isEmpty(value)) {
            labelView.setVisibility(View.VISIBLE);
            valueView.setVisibility(View.VISIBLE);
            valueView.setText(value);
        } else {
            labelView.setVisibility(View.GONE);
            valueView.setVisibility(View.GONE);
        }
    }

    @VisibleForTesting
    String getSerialNumber() {
        return Build.getSerial();
    }
}
Loading