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

Commit 9f31b973 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android Git Automerger
Browse files

am 1d7417de: Merge "Disable DeskClock\'s dock behavior." into ics-mr1

* commit '1d7417de':
  Disable DeskClock's dock behavior.
parents 94890c93 1d7417de
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DESK_DOCK" />
            </intent-filter>
        </activity>

@@ -88,13 +87,6 @@
            </intent-filter>
        </receiver>

        <receiver android:name="DeskClock$DeskClockReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.DOCK_EVENT" />
            </intent-filter>
        </receiver>

        <activity android:name="HandleSetAlarm"
                android:theme="@android:style/Theme.NoDisplay"
                android:excludeFromRecents="true"
+1 −75
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ import java.util.Date;
import java.util.Random;

/**
 * DeskClock clock view for desk docks.
 * A clock. On your desk.
 */
public class DeskClock extends Activity {
    private static final boolean DEBUG = false;
@@ -79,9 +79,6 @@ public class DeskClock extends Activity {
    // in.
    private static final boolean USE_BATTERY_DISPLAY = false;

    // Intent to broadcast for dock settings.
    private static final String DOCK_SETTINGS_ACTION = "com.android.settings.DOCK_SETTINGS";

    // Delay before engaging the burn-in protection mode (green-on-black).
    private final long SCREEN_SAVER_TIMEOUT = 5 * 60 * 1000; // 5 min

@@ -114,8 +111,6 @@ public class DeskClock extends Activity {
    private int mBatteryLevel = -1;
    private boolean mPluggedIn = false;

    private boolean mLaunchedFromDock = false;

    private Random mRNG;

    private PendingIntent mMidnightIntent;
@@ -132,45 +127,10 @@ public class DeskClock extends Activity {
                    intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0),
                    intent.getIntExtra(BatteryManager.EXTRA_STATUS, BATTERY_STATUS_UNKNOWN),
                    intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0));
            } else if (UiModeManager.ACTION_EXIT_DESK_MODE.equals(action)) {
                if (mLaunchedFromDock) {
                    // moveTaskToBack(false);
                    finish();
                }
                mLaunchedFromDock = false;
            } else if (Intent.ACTION_DOCK_EVENT.equals(action)) {
                if (DEBUG) Log.d(LOG_TAG, "dock event extra "
                        + intent.getExtras().getInt(Intent.EXTRA_DOCK_STATE));
                if (mLaunchedFromDock && intent.getExtras().getInt(Intent.EXTRA_DOCK_STATE,
                        Intent.EXTRA_DOCK_STATE_UNDOCKED) == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
                    finish();
                    mLaunchedFromDock = false;
                }
            }
        }
    };

    public static class DeskClockReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) {
                Bundle extras = intent.getExtras();
                int state = extras
                        .getInt(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED);
                if (state == Intent.EXTRA_DOCK_STATE_DESK
                        || state == Intent.EXTRA_DOCK_STATE_LE_DESK
                        || state == Intent.EXTRA_DOCK_STATE_HE_DESK) {
                    Intent clockIntent = new Intent();
                    clockIntent.setClass(context, DeskClock.class);
                    clockIntent.addCategory(Intent.CATEGORY_DESK_DOCK);
                    clockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(clockIntent);
                }
            }
        }

    }

    private final Handler mHandy = new Handler() {
        @Override
        public void handleMessage(Message m) {
@@ -422,8 +382,6 @@ public class DeskClock extends Activity {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_DATE_CHANGED);
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
        filter.addAction(Intent.ACTION_DOCK_EVENT);
        filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE);
        filter.addAction(ACTION_MIDNIGHT);
        registerReceiver(mIntentReceiver, filter);
    }
@@ -476,11 +434,6 @@ public class DeskClock extends Activity {
        setWakeLock(mPluggedIn);

        scheduleScreenSaver();

        final boolean launchedFromDock
            = getIntent().hasCategory(Intent.CATEGORY_DESK_DOCK);

        mLaunchedFromDock = launchedFromDock;
    }

    @Override
@@ -558,33 +511,6 @@ public class DeskClock extends Activity {
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_item_dock_settings:
                startActivity(new Intent(DOCK_SETTINGS_ACTION));
                return true;
            default:
                return false;
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.desk_clock_menu, menu);
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        // Only show the "Dock settings" menu item if the device supports it.
        boolean isDockSupported =
                (getPackageManager().resolveActivity(new Intent(DOCK_SETTINGS_ACTION), 0) != null);
        menu.findItem(R.id.menu_item_dock_settings).setVisible(isDockSupported);
        return super.onPrepareOptionsMenu(menu);
    }

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);