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

Unverified Commit eedb190e authored by Danny Baumann's avatar Danny Baumann Committed by Michael Bestas
Browse files

Give speed dial entry editor a sane layout.

Change-Id: Ia882540fc66f10fd0b7c5ca8d86ef31ad783a856
parent 5c0ab46b
Loading
Loading
Loading
Loading
+21 −61
Original line number Diff line number Diff line
@@ -29,26 +29,18 @@
-->

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

    <LinearLayout
    android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1.0"
        android:gravity="center_vertical"
        android:baselineAligned="false"
        android:paddingStart="10dip"
        android:paddingEnd="10dip">
    android:layout_height="wrap_content"
    android:padding="24dp"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/edit_container"
            android:layout_width="0dip"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
            android:layout_weight="1.0"
            android:orientation="vertical"
            android:hint="@string/input_number"
        android:layout_weight="1"
        android:minEms="12"
        android:hint="@string/speed_dial_input_hint"
        android:inputType="phone"
        android:singleLine="true" />

@@ -56,40 +48,8 @@
        android:id="@+id/select_contact"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
            android:padding="10dip"
        android:layout_marginStart="8dp"
        android:layout_toEndOf="@+id/edit_container"
        android:src="@drawable/ic_person_24dp" />
    </LinearLayout>

    <View
        android:background="?android:dividerHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="1dip" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/btn_cancel"
            android:focusable="true"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.0"
            android:text="@string/speed_dial_cancel"
            style="?android:attr/buttonBarButtonStyle" />

        <View
            android:background="?android:dividerHorizontal"
            android:layout_width="1dip"
            android:layout_height="fill_parent" />

        <Button
            android:id="@+id/btn_complete"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.0"
            android:text="@string/speed_dial_ok"
            style="?android:attr/buttonBarButtonStyle" />
    </LinearLayout>
</LinearLayout>
+0 −3
Original line number Diff line number Diff line
@@ -291,9 +291,6 @@
    <string name="dialog_speed_dial_airplane_mode_message">关飞行模式后使用快速拨号</string>
    <string name="yes"></string>
    <string name="no"></string>
    <string name="input_number">"输入号码"</string>
    <string name="speed_dial_cancel">"取消"</string>
    <string name="speed_dial_ok">"确定"</string>
    <string name="call_log_show_all_slots">"所有 SIM 卡"</string>
    <string name="call_log_all_calls_header">"所有通话"</string>
    <string name="calllog_search_hint">"搜索通话记录"</string>
+2 −0
Original line number Diff line number Diff line
@@ -44,4 +44,6 @@
    <string name="cyngn_reverse_lookup_provider_name">Cyngn Chinese (CN)</string>
    <string name="cyngn_reverse_lookup_provider_value" translatable="false">CyngnChinese</string>

    <string name="speed_dial_edit_title">Edit speed dial <xliff:g id="index" example="2">%1$d</xliff:g></string>
    <string name="speed_dial_input_hint">Please enter a number</string>
</resources>
+0 −6
Original line number Diff line number Diff line
@@ -1126,12 +1126,6 @@ e mode.</string>

    <string name="no">No</string>

    <string name="input_number">Input Number</string>

    <string name="speed_dial_cancel">Cancel</string>

    <string name="speed_dial_ok">OK</string>

    <string name="call_log_show_all_slots">All SIMs</string>

    <string name="call_log_all_calls_header">All calls</string>
+55 −62
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.telecom.TelecomManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
@@ -76,7 +77,7 @@ import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
import java.util.List;

public class SpeedDialListActivity extends ListActivity implements
        AdapterView.OnItemClickListener, PopupMenu.OnMenuItemClickListener {
        View.OnClickListener, AdapterView.OnItemClickListener, PopupMenu.OnMenuItemClickListener {
    private static final String TAG = "SpeedDial";
    private static final String ACTION_ADD_VOICEMAIL =
            "com.android.phone.CallFeaturesSetting.ADD_VOICEMAIL";
@@ -138,8 +139,7 @@ public class SpeedDialListActivity extends ListActivity implements
    private int mInitialPickNumber;
    private SpeedDialAdapter mAdapter;
    private AlertDialog mAddSpeedDialDialog;
    private EditText mEditNumber;
    private Button mCompleteButton;
    private EditText mNumberEditor;

    private static final int PICK_CONTACT_RESULT = 0;

@@ -189,7 +189,7 @@ public class SpeedDialListActivity extends ListActivity implements
            return;
        }
        outState.putInt(SAVE_CLICKED_POS, mItemPosition);
        outState.putString(SPEAD_DIAL_NUMBER, mEditNumber.getText().toString());
        outState.putString(SPEAD_DIAL_NUMBER, mNumberEditor.getText().toString());
    }

    @Override
@@ -265,81 +265,74 @@ public class SpeedDialListActivity extends ListActivity implements
        return record;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.select_contact) {
            pickContact(mPickNumber);
            if (mAddSpeedDialDialog != null && mAddSpeedDialDialog.isShowing()) {
                mAddSpeedDialDialog.dismiss();
            }
            mAddSpeedDialDialog = null;
        }
    }

    private void showAddSpeedDialDialog(final int number) {
        mPickNumber = number;
        mItemPosition = number;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.speed_dial_settings);

        View contentView = LayoutInflater.from(this).inflate(
                R.layout.add_speed_dial_dialog, null);
        builder.setView(contentView);
        ImageButton pickContacts = (ImageButton) contentView
                .findViewById(R.id.select_contact);
        pickContacts.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pickContact(number);
                dismissDialog();
            }
        });
        mEditNumber = (EditText) contentView.findViewById(R.id.edit_container);
        if (null != mRecords.get(number)) {
            mEditNumber.setText(SpeedDialUtils.getNumber(this, number));
        contentView.findViewById(R.id.select_contact).setOnClickListener(this);

        mNumberEditor = (EditText) contentView.findViewById(R.id.edit_container);
        if (mRecords.get(number) != null) {
            mNumberEditor.setText(SpeedDialUtils.getNumber(this, number));
        }
        if (mConfigChanged && !mInputNumber.isEmpty()) {
            mEditNumber.setText(mInputNumber);
            mNumberEditor.setText(mInputNumber);
            mConfigChanged = false;
            mInputNumber = "";
        }
        Button cancelButton = (Button) contentView
                .findViewById(R.id.btn_cancel);
        cancelButton.setOnClickListener(new View.OnClickListener() {

        final DialogInterface.OnDismissListener dismissCb =
                new DialogInterface.OnDismissListener() {
            @Override
            public void onClick(View v) {
                dismissDialog();
            public void onDismiss(DialogInterface dialog) {
                mAddSpeedDialDialog = null;
            }
        });
        mCompleteButton = (Button) contentView.findViewById(R.id.btn_complete);
        mCompleteButton.setOnClickListener(new View.OnClickListener() {
        };

        final DialogInterface.OnClickListener okCb = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mEditNumber.getText().toString().isEmpty()) {
                    dismissDialog();
            public void onClick(DialogInterface dialog, int which) {
                final String editedNumber = mNumberEditor.getText() != null
                        ? mNumberEditor.getText().toString() : null;
                if (TextUtils.isEmpty(editedNumber)) {
                    return;
                }
                saveSpeedDial();
                dismissDialog();
            }
        });
        mAddSpeedDialDialog = builder.create();
        mAddSpeedDialDialog.show();
    }

    private void saveSpeedDial() {
        String number = mEditNumber.getText().toString();
        Record record = null;
        if (number != null) {
                Uri uri = Uri.withAppendedPath(
                        ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
                    Uri.encode(number));
            record = getRecordFromQuery(uri, LOOKUP_PROJECTION);
                        Uri.encode(editedNumber));
                Record record = getRecordFromQuery(uri, LOOKUP_PROJECTION);
                if (record == null) {
                record = new Record(number);
                record.normalizedNumber = number;
            }
                    record = new Record(editedNumber);
                    record.normalizedNumber = editedNumber;
                }
        if (record != null) {
            SpeedDialUtils.saveNumber(this, mPickNumber,
                    record.normalizedNumber);
                SpeedDialUtils.saveNumber(SpeedDialListActivity.this,
                        mPickNumber, record.normalizedNumber);
                mRecords.put(mPickNumber, record);
                mAdapter.notifyDataSetChanged();
            }
    }
        };

    private void dismissDialog() {
        if (null != mAddSpeedDialDialog && mAddSpeedDialDialog.isShowing()) {
            mAddSpeedDialDialog.dismiss();
        }
        mAddSpeedDialDialog = new AlertDialog.Builder(this)
                .setTitle(getString(R.string.speed_dial_edit_title, number))
                .setView(contentView)
                .setOnDismissListener(dismissCb)
                .setNegativeButton(android.R.string.cancel, null)
                .setPositiveButton(android.R.string.ok, okCb)
                .show();
    }

    @Override