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

Commit 057d88c7 authored by Laszlo David's avatar Laszlo David Committed by Gerrit Code Review
Browse files

Make the settings menu accessible on every tab

Change-Id: Ieb7fdf09e4369701868c52a327aca458c01ed49c
parent 6f5d7914
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -80,4 +80,34 @@
        android:layout_weight="2"
        android:layout_width="match_parent"
        android:layout_height="0dip" />

    <FrameLayout
        android:id="@+id/stopwatch_footer"
        android:background="@drawable/footer_bg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <View
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:background="#28ffffff" />
        <LinearLayout
            android:id="@+id/stopwatch_buttons"
            android:gravity="bottom"
            android:layout_width="match_parent"
            android:layout_height="@dimen/button_footer_height" >
            <Space
                android:layout_height="match_parent"
                android:layout_width="0dip"
                android:layout_weight="1"/>
            <ImageButton
                android:id="@+id/menu_button"
                android:contentDescription="@string/button_menu"
                style="?android:attr/actionOverflowButtonStyle"
                android:background="@drawable/item_background"
                android:onClick="clockButtonsOnClick"
                android:layout_gravity="right"
                android:layout_width="64dip"
                android:layout_height="match_parent" />
         </LinearLayout>
    </FrameLayout>
</com.android.deskclock.CircleButtonsLinearLayout>
 No newline at end of file
+15 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@
               <Button
                    android:id="@+id/timer_cancel"
                    android:text="@string/timer_cancel"
                    android:layout_width="match_parent"
                    android:layout_width="wrap_content"
                    style="@style/button"
                    android:layout_weight="1"
                    android:background="@drawable/item_background"
@@ -93,11 +93,24 @@
               <Button
                    android:id="@+id/timer_start"
                    android:text="@string/timer_start"
                    android:layout_width="match_parent"
                    android:layout_width="wrap_content"
                    style="@style/button"
                    android:layout_weight="1"
                    android:background="@drawable/item_background"
                    android:layout_height="wrap_content" />
               <Space
                   android:layout_height="match_parent"
                   android:layout_width="0dip"
                   android:layout_weight="1"/>
               <ImageButton
                   android:id="@+id/menu_button"
                   android:contentDescription="@string/button_menu"
                   style="?android:attr/actionOverflowButtonStyle"
                   android:background="@drawable/item_background"
                   android:onClick="clockButtonsOnClick"
                   android:layout_gravity="right"
                   android:layout_width="64dip"
                   android:layout_height="match_parent" />
              </LinearLayout>
           </FrameLayout>
    </LinearLayout>
+35 −7
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.os.Handler;
@@ -85,6 +86,15 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe

    private int mSelectedTab;

    private OnSharedPreferenceChangeListener preferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
            if (SettingsActivity.KEY_KEEP_DISPLAY_ON_STOPWATCH.equals(key)) {
                refreshKeepScreenOn();
            }
        }
    };

    @Override
    public void onNewIntent(Intent newIntent) {
        super.onNewIntent(newIntent);
@@ -103,6 +113,16 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
        }
    }

    private void refreshKeepScreenOn() {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        if (mTabsAdapter.mPager.getCurrentItem() == STOPWATCH_TAB_INDEX
                && prefs.getBoolean(SettingsActivity.KEY_KEEP_DISPLAY_ON_STOPWATCH, true)) {
            getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
        } else {
            getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    }

    private void initViews() {

        if (mTabsAdapter == null) {
@@ -157,6 +177,9 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
        }
        initViews();
        setHomeTimeZone();

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        prefs.registerOnSharedPreferenceChangeListener(preferenceChangeListener);
    }

    @Override
@@ -192,6 +215,13 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        prefs.unregisterOnSharedPreferenceChangeListener(preferenceChangeListener);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
@@ -250,6 +280,10 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
        if (help != null) {
            Utils.prepareHelpMenuItem(this, help);
        }
        MenuItem nightMode = menu.findItem(R.id.menu_item_night_mode);
        if (nightMode != null) {
            nightMode.setVisible(mTabsAdapter.mPager.getCurrentItem() == CLOCK_TAB_INDEX);
        }
        popupMenu.show();
    }

@@ -357,13 +391,7 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            TabInfo info = (TabInfo)tab.getTag();
            mPager.setCurrentItem(info.getPosition());
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
            if (info.getPosition() == STOPWATCH_TAB_INDEX
                    && prefs.getBoolean(SettingsActivity.KEY_KEEP_DISPLAY_ON_STOPWATCH, true)) {
                getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
            } else {
                getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
            }
            refreshKeepScreenOn();
        }

        @Override