Commit 69c3db37 authored by John Taylor's avatar John Taylor

Reworked the way the button layers show/hide to fit in with the action bar and...

Reworked the way the button layers show/hide to fit in with the action bar and navbar appear/disappear.  Moved the manual/auto button so it doesn't get hit by the nav buttons.
parent f4b82525
......@@ -55,3 +55,4 @@ dependencies {
androidTestCompile 'org.easymock:easymock:2.5.2'
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.stardroid"
android:installLocation="auto"
android:vmSafeMode="false">
<manifest package="com.google.android.stardroid"
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
android:vmSafeMode="false">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<!-- For Google Analytics -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<application android:label="@string/app_name"
android:icon="@drawable/skymap_logo"
android:name="StardroidApplication"
android:theme="@android:style/Theme.Holo">
<uses-feature
android:name="android.hardware.location.gps"
android:required="false"/>
<activity android:name=".activities.SplashScreenActivity"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
android:screenOrientation="nosensor"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"/>
<activity android:name=".activities.DynamicStarMapActivity"
android:theme="@android:style/Theme.Holo"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="nosensor"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
<application
android:name=".StardroidApplication"
android:icon="@drawable/skymap_logo"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo">
<activity
android:name=".activities.SplashScreenActivity"
android:label="@string/app_name"
android:screenOrientation="nosensor"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".activities.DynamicStarMapActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="nosensor"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
<activity
android:name=".activities.EditSettingsActivity"
android:theme="@android:style/Theme.Holo" />
<activity android:name=".activities.ImageGalleryActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
<activity android:name=".activities.ImageDisplayActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
android:theme="@android:style/Theme.Holo"/>
<activity
android:name=".activities.ImageGalleryActivity"
android:theme="@android:style/Theme.Holo"/>
<activity
android:name=".activities.ImageDisplayActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo"/>
<!-- Provides search suggestions. -->
<!-- TODO(johntaylor): What does syncable do? -->
<provider android:name="com.google.android.stardroid.search.SearchTermsProvider"
android:authorities="com.google.android.stardroid.searchterms"
android:syncable="false"/>
<provider
android:name=".search.SearchTermsProvider"
android:authorities="com.google.android.stardroid.searchterms"
android:syncable="false"/>
</application>
<supports-screens
android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
</manifest>
package com.google.android.stardroid.activities.util;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.google.android.stardroid.util.MiscUtil;
/**
* Manages the showing and hiding of controls and system UI in full screen mode.
*
* Created by johntaylor on 2/21/16.
*/
public class FullscreenControlsManager {
private static final String TAG = MiscUtil.getTag(FullscreenControlsManager.class);
/**
* Whether or not the system UI should be auto-hidden after
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
*/
private static final boolean AUTO_HIDE = true;
/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 1000;
/**
* Some older devices needs a small delay between UI widget updates
* and a change of the status and navigation bar.
*/
private static final int UI_ANIMATION_DELAY = 300;
private Activity mActivity;
private View mContentView;
private View[] mControlViews;
private boolean mVisible;
public FullscreenControlsManager(
Activity parentActivity, View contentView, View[] controlViews, View[] buttonViews) {
mActivity = parentActivity;
mVisible = true;
mControlViews = controlViews;
mContentView = contentView;
/*
// Set up the user interaction to manually show or hide the system UI.
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
*/
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
for (View buttonView : buttonViews) {
buttonView.setOnTouchListener(mDelayHideTouchListener);
}
}
public void toggleControls() {
Log.d(TAG, "Toggling the UI");
toggle();
}
/**
* Quickly exposes the controls so that the user knows they're there.
*/
public void flashTheControls() {
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(1000);
}
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};
private void toggle() {
if (mVisible) {
hide();
} else {
show();
}
}
private void hide() {
// Hide UI first
ActionBar actionBar = mActivity.getActionBar();
if (actionBar != null) {
actionBar.hide();
}
for (View controlView : mControlViews) {
controlView.setVisibility(View.GONE);
}
mVisible = false;
// Schedule a runnable to remove the status and navigation bar after a delay
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
}
private final Runnable mHidePart2Runnable = new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
// Delayed removal of status and navigation bar
// Note that some of these constants are new as of API 16 (Jelly Bean)
// and API 19 (KitKat). It is safe to use them, as they are inlined
// at compile-time and do nothing on earlier devices.
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
};
@SuppressLint("InlinedApi")
private void show() {
// Show the system bar
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mVisible = true;
// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}
private final Runnable mShowPart2Runnable = new Runnable() {
@Override
public void run() {
// Delayed display of UI elements
ActionBar actionBar = mActivity.getActionBar();
if (actionBar != null) {
actionBar.show();
}
for (View controlView : mControlViews) {
controlView.setVisibility(View.VISIBLE);
}
}
};
private final Handler mHideHandler = new Handler();
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide();
}
};
/**
* Schedules a call to hide() in [delay] milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
}
......@@ -18,9 +18,9 @@ import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import com.google.android.stardroid.activities.util.FullscreenControlsManager;
import com.google.android.stardroid.touch.Flinger.FlingListener;
import com.google.android.stardroid.util.MiscUtil;
import com.google.android.stardroid.views.WidgetFader;
/**
* Processes touch events and scrolls the screen in manual mode.
......@@ -29,12 +29,13 @@ import com.google.android.stardroid.views.WidgetFader;
*/
public class GestureInterpreter extends GestureDetector.SimpleOnGestureListener {
private static final String TAG = MiscUtil.getTag(GestureInterpreter.class);
private WidgetFader[] faders;
private FullscreenControlsManager fullscreenControlsManager;
private MapMover mapMover;
public GestureInterpreter(WidgetFader[] faders,
MapMover mapMover) {
this.faders = faders;
public GestureInterpreter(
FullscreenControlsManager fullscreenControlsManager,
MapMover mapMover) {
this.fullscreenControlsManager = fullscreenControlsManager;
this.mapMover = mapMover;
}
......@@ -61,10 +62,7 @@ public class GestureInterpreter extends GestureDetector.SimpleOnGestureListener
@Override
public boolean onSingleTapUp(MotionEvent e) {
Log.d(TAG, "Tap up");
// Bring up the controls
for (WidgetFader fader : faders) {
fader.keepActive();
}
fullscreenControlsManager.toggleControls();
return true;
}
......@@ -79,5 +77,4 @@ public class GestureInterpreter extends GestureDetector.SimpleOnGestureListener
Log.d(TAG, "Confirmed single tap");
return false;
}
}
......@@ -23,13 +23,13 @@ import android.view.animation.AlphaAnimation;
import android.widget.LinearLayout;
import com.google.android.stardroid.R;
import com.google.android.stardroid.views.WidgetFader.Fadeable;
/**
* Contains the provider buttons.
*/
public class ButtonLayerView extends LinearLayout implements Fadeable {
public class ButtonLayerView extends LinearLayout {
// TODO(jontayler): clear up the fade code which is no longer used.
private int fadeTime = 500;
public ButtonLayerView(Context context) {
......
// Copyright 2009 Google Inc.
//
// 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.google.android.stardroid.views;
import android.os.Handler;
/**
* Controls the appearance and disappearance of the widgets.
* Main purpose is to show the widgets when the screen is tapped, and
* then fade them away after a certain period of inactivity.
*/
public class WidgetFader implements Runnable {
public interface Fadeable {
void show();
void hide();
}
private Fadeable control;
private boolean visible;
private Handler handler;
private int showTimeMs = 1500;
public WidgetFader(Fadeable control) {
this.control = control;
this.handler = new Handler();
}
public WidgetFader(Fadeable controls, int showTimeMs) {
this.control = controls;
this.handler = new Handler();
this.showTimeMs = showTimeMs;
}
private void makeVisible() {
if (visible) return;
visible = true;
control.show();
}
public void keepActive() {
makeVisible();
handler.removeCallbacks(this);
handler.postDelayed(this, showTimeMs);
}
private void makeInactive() {
if (!visible) return;
visible = false;
control.hide();
}
public void run() {
makeInactive();
}
}
......@@ -170,9 +170,9 @@
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
android:layout_gravity="center_vertical">
<FrameLayout
android:id="@+id/zoom_and_manual_bar"
android:id="@+id/manual_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
......@@ -180,7 +180,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/layer_manual_auto_toggle"
android:layout_gravity="bottom|left"
android:layout_gravity="bottom|right"
android:orientation="vertical"
stardroid:fade_time="500">
<com.google.android.stardroid.views.PreferencesButton
......
......@@ -16,7 +16,7 @@
-->
<resources>
<declare-styleable name="ButtonLayerView">
<declare-styleable name="ButtonLayerView">
<attr name="fade_time" format="integer"/>
</declare-styleable>
<declare-styleable name="PreferencesButton">
......@@ -25,4 +25,13 @@
<attr name="image_off" format="reference"/>
<attr name="default_value" format="boolean"/>
</declare-styleable>
<!-- Declare custom theme attributes that allow changing which styles are
used for button bars depending on the API level.
?android:attr/buttonBarStyle is new as of API 11 so this is
necessary to support previous API levels. -->
<declare-styleable name="ButtonBarContainerTheme">
<attr name="metaButtonBarStyle" format="reference"/>
<attr name="metaButtonBarButtonStyle" format="reference"/>
</declare-styleable>
</resources>
<resources>
<color name="black_overlay">#66000000</color>
</resources>
......@@ -4,8 +4,8 @@
* Twice as many stars (down to magnitude 5.6)&lt;br/&gt;
* Star data fixes&lt;br/&gt;
* Planets are now rendered in the correct order (e.g. Jupiter behind Venus)&lt;br/&gt;
* Arabic translations (thanks xsoh on github)
* Minor bug fixes&lt;br/&gt;
* Arabic translations (thanks xsoh on github) &lt;br/&gt;
* Minor bug fixes
&lt;br/&gt;&lt;br/&gt;
&lt;big&gt;&lt;b&gt;Privacy Policy&lt;/b&gt;&lt;/big&gt;&lt;br/&gt;
This App uses Google Analytics to help analyse how people use it.
......
......@@ -9,7 +9,7 @@
<string name="go">Go!</string>
<string name="location_prefs">Location Settings</string>
<string name="force_gps_pref">Always use GPS</string>
<string name="force_gps_pref_hint" translation_description="this string continues from \'Always use GPS\'">if enabled, even if network location is available</string>
<string name="force_gps_pref_hint" translation_description="this string continues from \'Always use GPS\'">if enabled, even if network location is available</string>
<string name="no_use_gps_pref">Set location manually</string>
<string name="no_use_gps_pref_hint">Enter a place or a lat/long below</string>
<string name="location_placename">Place name</string>
......@@ -23,12 +23,13 @@
<string name="location_offer_to_enable_gps_title">Auto-location disabled</string>
<string name="location_set_auto">Location set from %1$s to %2$s</string>
<string name="location_unable_to_geocode">Unable to decode your location - perhaps your network isn\'t available?</string>
<string name="location_not_found_title" translation_description="dialog box title when location not found">Sorry</string>
<string name="location_not_found" translation_description="dialog message when placename not found">%s not found.</string>
<string name="location_not_found_title" translation_description="dialog box title when location not found">Sorry</string>
<string name="location_not_found" translation_description="dialog message when placename not found">%s not found.</string>
<string name="location_long_lat">Longitude:%1$s, Latitude:%2$s</string>
<string name="location_place_found">Place found. Setting latitude %1$f and longitude %2$f</string>
<string name="use_magnetic_correction">Use magnetic correction</string>
<string name="use_magnetic_correction_hint">Use knowledge of your location to correct orientation from magnetic north to true north</string><!-- This string is too long and currently unused -->
<string name="use_magnetic_correction_hint">Use knowledge of your location to correct orientation from magnetic north to true north</string>
<!-- This string is too long and currently unused -->
<string name="provider_prefs" translation_description="Dialog box title for a preferences dialog">Show...</string>
<string name="show_stars_pref">Stars</string>
<string name="show_constellations_pref">Constellations</string>
......@@ -45,9 +46,9 @@
<!-- Just in case we decide to have such a layer for the 4/24 launch -->
<string name="show_hubble_layer_pref">Hubble Images</string>
<string name="malformed_loc_error">Latitude or longitude setting isn\'t a number.</string>
<string name="dialog_accept" translation_description="accepting the licence agreement">Accept</string>
<string name="dialog_accept" translation_description="accepting the licence agreement">Accept</string>
<string name="dialog_decline" translation_description="declining the licence agreement">No Thanks</string>
<string name="menu_help" translation_description="menu item to show \'Help\' box">Help</string>
<string name="menu_help" translation_description="menu item to show \'Help\' box">Help</string>
<string name="help_dialog_title">Help for Sky Map</string>
<string name="eula_dialog_title">End User License Agreement</string>
<string name="set_manual">Switching to manual mode</string>
......@@ -62,7 +63,7 @@
<string name="west">WEST</string>
<string name="south">SOUTH</string>
<string name="search_label">Search the Sky</string>
<string name="search_hint" translation_description="an example search target">e.g. Mars</string>
<string name="search_hint" translation_description="an example search target">e.g. Mars</string>
<string name="no_search_title">No results</string>
<string name="no_search_results_text">No results were found.</string>
<string name="many_search_results_title">Did you mean?</string>
......@@ -71,17 +72,17 @@
<string name="found_target_text">Found %s.</string>
<string name="other" translation_description="A preference category (ie preferences that don't belong in any other category)">Other</string>
<string name="planetary_images">Show Planet Images</string>
<string name="menu_time" >Time Travel</string>
<string name="time_travel_start_message" >Traveling through time ...</string>
<string name="time_travel_start_message_alt" >Traveling through time to %s ...</string>
<string name="time_travel_close_message" >Back to the present ...</string>
<string name="menu_time">Time Travel</string>
<string name="time_travel_start_message">Traveling through time ...</string>
<string name="time_travel_start_message_alt">Traveling through time to %s ...</string>
<string name="time_travel_close_message">Back to the present ...</string>
<!-- -->
<string name="popular_dates_prompt" translation_description="Label for a list of dates the user can choose from">Popular dates</string>
<string name="custom_date_prompt" translation_description="Label telling the user to manually specify a date">Or select your own date</string>
<string name="change_date_prompt" >Change the date</string>
<string name="change_time_prompt" >Change the time</string>
<string name="change_date_prompt">Change the date</string>
<string name="change_time_prompt">Change the time</string>
<string name="now_visiting"
translation_description="used in time travel dialog to tell the user what time they are visiting, time formatted as yyyy.mm.dd at hh.mm.ss + timezone">
translation_description="used in time travel dialog to tell the user what time they are visiting, time formatted as yyyy.mm.dd at hh.mm.ss + timezone">
Now visiting: %s</string>
<string name="time_travel_label_past" translation_description="Label showing that we are in the past">Time Travel: Past</string>
<string name="time_travel_label_future" translation_description="Label showing that we are in the future">Time Travel: Future</string>
......@@ -106,7 +107,8 @@
<string name="gallery_image_search_btn">Find in sky</string>
<string name="gallery_image_back_btn">Back to gallery</string>
<string name="hubble_image_gallery_title">Sky Map Hubble Gallery</string>
<string name="hubble_image">Hubble Image</string><!-- TODO(johntaylor): currently unused -->
<string name="hubble_image">Hubble Image</string>
<!-- TODO(johntaylor): currently unused -->
<string name="search_target_found_message" translation_description="displayed when a search target has been located">You found:</string>
<string name="search_overlay_title" translation_description="title for search overlay">Point your phone toward the arrow</string>
......@@ -386,13 +388,13 @@
<string name="ngc5139" translation_description="Name of the Messier object NGC5139">NGC5139</string>
<string name="butterfly_cluster" translation_description="Name of the Messier object Butterfly Cluster">Butterfly Cluster</string>
<string name="scorpions_tail" translation_description="Name of the Messier object Scorpion\'s Tail">Scorpion\'s Tail</string>
<string name ="winnecke_4" translation_description="Name of the Messier object Winnecke 4">Winnecke 4</string>
<string name ="beehive_cluster" translation_description="Name of the Messier object Beehive Cluster">Beehive Cluster</string>
<string name ="praesepe" translation_description="Name of the Messier object Praesepe">Praesepe</string>
<string name ="seven_sisters" translation_description="Name of the Messier object Seven Sisters">Seven Sisters</string>
<string name ="space_station" translation_description="Name of the Internation Space Station">International Space Station</string>
<string name ="space_shuttle" translation_description="Name of the Space Shuttle">Space Shuttle</string>
<string name ="kml_load_error">Failed to load KML file</string>
<string name="winnecke_4" translation_description="Name of the Messier object Winnecke 4">Winnecke 4</string>
<string name="beehive_cluster" translation_description="Name of the Messier object Beehive Cluster">Beehive Cluster</string>
<string name="praesepe" translation_description="Name of the Messier object Praesepe">Praesepe</string>
<string name="seven_sisters" translation_description="Name of the Messier object Seven Sisters">Seven Sisters</string>
<string name="space_station" translation_description="Name of the Internation Space Station">International Space Station</string>
<string name="space_shuttle" translation_description="Name of the Space Shuttle">Space Shuttle</string>
<string name="kml_load_error">Failed to load KML file</string>
<string name="load_kml_dialog_title">Load KML</string>
<string name="load_kml_file">Load</string>
<string name="enable_analytics">Send usage statistics</string>
......@@ -407,4 +409,8 @@
<string name="orionids" translation_description="Meteor Shower">Orionids</string>
<string name="puppidvelids" translation_description="Meteor Shower">Puppid-Velids</string>
<string name="ursids" translation_description="Meteor Shower">Ursids</string>
<string name="title_activity_fullscreen">FullscreenActivity</string>
<string name="dummy_button">Dummy Button</string>
<string name="dummy_content">DUMMY\nCONTENT</string>
</resources>
<resources><style name="title" parent="text"><item name="android:textStyle">bold</item>
</style>
<style name="text"><item name="android:paddingLeft">5px</item>
</style>
<resources>
<style name="title" parent="text">
<item name="android:textStyle">bold</item>
</style>
<style name="text">
<item name="android:paddingLeft">5px</item>
</style>
<style name="FullscreenTheme" parent="@android:style/Theme.Holo">
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
<item name="android:background">@color/black_overlay</item>
</style>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment