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

Commit 8ca2fc10 authored by Jim Miller's avatar Jim Miller
Browse files

Remove unused keyguard code

This change removes the old keyguard code because it's obsolete and doesn't run
anymore.

Change-Id: I8ed93f507378a17cf834d2ee9284c098eb8efffe
parent cac9bbd7
Loading
Loading
Loading
Loading
+0 −245
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008 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.internal.widget;

import com.android.internal.R;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.graphics.Typeface;
import android.os.Handler;
import android.provider.Settings;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.lang.ref.WeakReference;
import java.text.DateFormatSymbols;
import java.util.Calendar;

/**
 * Displays the time
 */
public class DigitalClock extends RelativeLayout {

    private static final String SYSTEM = "/system/fonts/";
    private static final String SYSTEM_FONT_TIME_BACKGROUND = SYSTEM + "AndroidClock.ttf";
    private static final String SYSTEM_FONT_TIME_FOREGROUND = SYSTEM + "AndroidClock_Highlight.ttf";
    private final static String M12 = "h:mm";
    private final static String M24 = "kk:mm";

    private Calendar mCalendar;
    private String mFormat;
    private TextView mTimeDisplayBackground;
    private TextView mTimeDisplayForeground;
    private AmPm mAmPm;
    private ContentObserver mFormatChangeObserver;
    private int mAttached = 0; // for debugging - tells us whether attach/detach is unbalanced

    /* called by system on minute ticks */
    private final Handler mHandler = new Handler();
    private BroadcastReceiver mIntentReceiver;

    private static final Typeface sBackgroundFont;
    private static final Typeface sForegroundFont;

    static {
        sBackgroundFont = Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND);
        sForegroundFont = Typeface.createFromFile(SYSTEM_FONT_TIME_FOREGROUND);
    }

    private static class TimeChangedReceiver extends BroadcastReceiver {
        private WeakReference<DigitalClock> mClock;
        private Context mContext;

        public TimeChangedReceiver(DigitalClock clock) {
            mClock = new WeakReference<DigitalClock>(clock);
            mContext = clock.getContext();
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            // Post a runnable to avoid blocking the broadcast.
            final boolean timezoneChanged =
                    intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED);
            final DigitalClock clock = mClock.get();
            if (clock != null) {
                clock.mHandler.post(new Runnable() {
                    public void run() {
                        if (timezoneChanged) {
                            clock.mCalendar = Calendar.getInstance();
                        }
                        clock.updateTime();
                    }
                });
            } else {
                try {
                    mContext.unregisterReceiver(this);
                } catch (RuntimeException e) {
                    // Shouldn't happen
                }
            }
        }
    };

    static class AmPm {
        private TextView mAmPmTextView;
        private String mAmString, mPmString;

        AmPm(View parent, Typeface tf) {
            // No longer used, uncomment if we decide to use AM/PM indicator again
            // mAmPmTextView = (TextView) parent.findViewById(R.id.am_pm);
            if (mAmPmTextView != null && tf != null) {
                mAmPmTextView.setTypeface(tf);
            }

            String[] ampm = new DateFormatSymbols().getAmPmStrings();
            mAmString = ampm[0];
            mPmString = ampm[1];
        }

        void setShowAmPm(boolean show) {
            if (mAmPmTextView != null) {
                mAmPmTextView.setVisibility(show ? View.VISIBLE : View.GONE);
            }
        }

        void setIsMorning(boolean isMorning) {
            if (mAmPmTextView != null) {
                mAmPmTextView.setText(isMorning ? mAmString : mPmString);
            }
        }
    }

    private static class FormatChangeObserver extends ContentObserver {
        private WeakReference<DigitalClock> mClock;
        private Context mContext;
        public FormatChangeObserver(DigitalClock clock) {
            super(new Handler());
            mClock = new WeakReference<DigitalClock>(clock);
            mContext = clock.getContext();
        }
        @Override
        public void onChange(boolean selfChange) {
            DigitalClock digitalClock = mClock.get();
            if (digitalClock != null) {
                digitalClock.setDateFormat();
                digitalClock.updateTime();
            } else {
                try {
                    mContext.getContentResolver().unregisterContentObserver(this);
                } catch (RuntimeException e) {
                    // Shouldn't happen
                }
            }
        }
    }

    public DigitalClock(Context context) {
        this(context, null);
    }

    public DigitalClock(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        /* The time display consists of two tones. That's why we have two overlapping text views. */
        mTimeDisplayBackground = (TextView) findViewById(R.id.timeDisplayBackground);
        mTimeDisplayBackground.setTypeface(sBackgroundFont);
        mTimeDisplayBackground.setVisibility(View.INVISIBLE);

        mTimeDisplayForeground = (TextView) findViewById(R.id.timeDisplayForeground);
        mTimeDisplayForeground.setTypeface(sForegroundFont);
        mAmPm = new AmPm(this, null);
        mCalendar = Calendar.getInstance();

        setDateFormat();
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        mAttached++;

        /* monitor time ticks, time changed, timezone */
        if (mIntentReceiver == null) {
            mIntentReceiver = new TimeChangedReceiver(this);
            IntentFilter filter = new IntentFilter();
            filter.addAction(Intent.ACTION_TIME_TICK);
            filter.addAction(Intent.ACTION_TIME_CHANGED);
            filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
            mContext.registerReceiver(mIntentReceiver, filter);
        }

        /* monitor 12/24-hour display preference */
        if (mFormatChangeObserver == null) {
            mFormatChangeObserver = new FormatChangeObserver(this);
            mContext.getContentResolver().registerContentObserver(
                    Settings.System.CONTENT_URI, true, mFormatChangeObserver);
        }

        updateTime();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        mAttached--;

        if (mIntentReceiver != null) {
            mContext.unregisterReceiver(mIntentReceiver);
        }
        if (mFormatChangeObserver != null) {
            mContext.getContentResolver().unregisterContentObserver(
                    mFormatChangeObserver);
        }

        mFormatChangeObserver = null;
        mIntentReceiver = null;
    }

    void updateTime(Calendar c) {
        mCalendar = c;
        updateTime();
    }

    public void updateTime() {
        mCalendar.setTimeInMillis(System.currentTimeMillis());

        CharSequence newTime = DateFormat.format(mFormat, mCalendar);
        mTimeDisplayBackground.setText(newTime);
        mTimeDisplayForeground.setText(newTime);
        mAmPm.setIsMorning(mCalendar.get(Calendar.AM_PM) == 0);
    }

    private void setDateFormat() {
        mFormat = android.text.format.DateFormat.is24HourFormat(getContext())
            ? M24 : M12;
        mAmPm.setShowAmPm(mFormat.equals(M12));
    }
}
+0 −136
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/background_dark"
        >
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:layout_above="@+id/emergencyCallButton">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/topHeader"
                android:layout_width="match_parent"
                android:layout_height="64dip"
                android:layout_alignParentTop="true"
                android:layout_marginStart="4dip"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:gravity="center_vertical"
                android:drawableLeft="@drawable/ic_lock_idle_lock"
                android:drawablePadding="5dip"
                />

            <!-- spacer below header -->
            <View
                android:id="@+id/spacerTop"
                android:layout_width="match_parent"
                android:layout_height="1dip"
                android:layout_below="@id/topHeader"
                android:background="@drawable/divider_horizontal_dark"/>

            <TextView
                android:id="@+id/instructions"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/spacerTop"
                android:layout_marginTop="8dip"
                android:layout_marginStart="9dip"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:text="@android:string/lockscreen_glogin_instructions"
                />

            <EditText
                android:id="@+id/login"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/instructions"
                android:layout_marginTop="8dip"
                android:layout_marginStart="7dip"
                android:layout_marginEnd="7dip"
                android:hint="@android:string/lockscreen_glogin_username_hint"
                android:inputType="textEmailAddress"
                />

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/login"
                android:layout_marginTop="15dip"
                android:layout_marginStart="7dip"
                android:layout_marginEnd="7dip"
                android:inputType="textPassword"
                android:hint="@android:string/lockscreen_glogin_password_hint"
                android:nextFocusRight="@+id/ok"
                android:nextFocusDown="@+id/ok"
                />

            <!-- ok below password, aligned to right of screen -->
            <Button
                android:id="@+id/ok"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/password"
                android:layout_marginTop="7dip"
                android:layout_marginEnd="7dip"
                android:layout_alignParentEnd="true"
                android:text="@android:string/lockscreen_glogin_submit_button"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/ok"
                android:layout_marginTop="50dip"
                android:text="@android:string/lockscreen_glogin_account_recovery_hint"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:gravity="center_horizontal"
                />

        </RelativeLayout>
    </ScrollView>

    <!-- spacer above emergency call -->
    <View
        android:layout_width="match_parent"
        android:layout_height="1dip"
        android:layout_marginBottom="4dip"

        android:background="@drawable/divider_horizontal_dark"/>

    <!-- emergency call button at bottom center -->
    <Button
        android:id="@+id/emergencyCallButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:drawableLeft="@drawable/ic_emergency"
        android:drawablePadding="8dip"
        android:text="@android:string/lockscreen_emergency_call"
        android:visibility="gone"
        />

</LinearLayout>
+0 −218
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->

<!-- This is the general lock screen which shows information about the
  state of the device, as well as instructions on how to get past it
  depending on the state of the device.  It is the same for landscape
  and portrait.-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:gravity="bottom"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="15dip"
        android:layout_marginStart="15dip"
        android:layout_marginEnd="15dip"
        android:paddingTop="20dip"
        android:paddingBottom="20dip"
        android:background="@android:drawable/popup_full_dark"
        >

        <!-- when sim is present -->
        <TextView android:id="@+id/headerSimOk1"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center"
                  android:textSize="34sp"/>
        <TextView android:id="@+id/headerSimOk2"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center"
                  android:textSize="34sp"/>

        <!-- when sim is missing / locked -->
        <TextView android:id="@+id/headerSimBad1"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center"
                  android:text="@android:string/lockscreen_missing_sim_message"
                  android:textAppearance="?android:attr/textAppearanceLarge"/>
        <TextView android:id="@+id/headerSimBad2"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="7dip"
                  android:layout_marginBottom="7dip"
                  android:gravity="center"
                  android:text="@android:string/lockscreen_missing_sim_instructions"
                  android:textAppearance="?android:attr/textAppearanceSmall"/>

        <!-- spacer after carrier info / sim messages -->
        <View
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:layout_marginTop="8dip"
            android:background="@android:drawable/divider_horizontal_dark"/>

        <!-- time and date -->
        <TextView android:id="@+id/time"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center"
                  android:textSize="34sp"/>

        <TextView android:id="@+id/date"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center"
                  android:textSize="18sp"/>

        <!-- spacer after time and date -->
        <View
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:layout_marginBottom="8dip"
            android:background="@android:drawable/divider_horizontal_dark"
                />

        <!-- battery info -->
        <LinearLayout android:id="@+id/batteryInfo"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
              >

            <ImageView android:id="@+id/batteryInfoIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="6dip"
                android:baselineAligned="true"
                android:gravity="center"
            />

            <TextView android:id="@+id/batteryInfoText"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textSize="18sp"
                      android:gravity="center"
            />

        </LinearLayout>

        <!-- spacer after battery info -->
        <View android:id="@+id/batteryInfoSpacer"
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:layout_marginTop="8dip"
            android:layout_marginBottom="8dip"
            android:background="@android:drawable/divider_horizontal_dark"
                />

        <!-- next alarm info -->

        <LinearLayout android:id="@+id/nextAlarmInfo"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
              >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="6dip"
                android:baselineAligned="true"
                android:src="@android:drawable/ic_lock_idle_alarm"
                android:gravity="center"
            />

            <TextView android:id="@+id/nextAlarmText"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textSize="18sp"
                      android:gravity="center"
            />
        </LinearLayout>

        <!-- spacer after alarm info -->
        <View android:id="@+id/nextAlarmSpacer"
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:layout_marginTop="8dip"
            android:layout_marginBottom="8dip"
            android:background="@android:drawable/divider_horizontal_dark"/>

        <!-- lock icon with 'screen locked' message
             (shown when SIM card is present) -->
        <LinearLayout android:id="@+id/screenLockedInfo"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="6dip"
                android:baselineAligned="true"
                android:src="@android:drawable/ic_lock_idle_lock"
                android:gravity="center"
            />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18sp"
                android:text="@android:string/lockscreen_screen_locked"
                android:gravity="center"
                    />
        </LinearLayout>

        <!-- message about how to unlock
             (shown when SIM card is present) -->
        <TextView android:id="@+id/lockInstructions"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginBottom="5dip"
                  android:gravity="center"
                  android:textSize="14sp"/>


        <!-- emergency call button shown when sim is missing or PUKd -->
        <Button
            android:id="@+id/emergencyCallButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dip"
            android:layout_marginTop="5dip"
            android:layout_gravity="center_horizontal"
            android:drawableLeft="@drawable/ic_emergency"
            android:drawablePadding="8dip"
            android:text="@android:string/lockscreen_emergency_call"
           />

    </LinearLayout>
</LinearLayout>
+0 −184

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −187

File deleted.

Preview size limit exceeded, changes collapsed.

Loading