Commit 3068af9c authored by Mudar Noufal's avatar Mudar Noufal

material-tap-target-prompt, for layers fabMenu

Explain on first usage that some sections have a filter button
parent 7f995a92
......@@ -74,6 +74,8 @@ dependencies {
compile('com.mikepenz:aboutlibraries:5.8.0@aar') {
transitive = true
}
compile 'uk.co.samuelwall:material-tap-target-prompt:1.4.3'
// API and GeoJSON
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
......
......@@ -213,4 +213,15 @@ public class UserPrefs implements
edit().putLong(key, updatedAt.getTime())
.apply();
}
public boolean shouldDisplayLayersShowcase() {
final boolean isFirst = mPrefs.getBoolean(SHOWCASE_LAYERS, true);
if (isFirst) {
edit().putBoolean(SHOWCASE_LAYERS, false)
.apply();
}
return isFirst;
}
}
......@@ -30,15 +30,21 @@ import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import com.github.clans.fab.FloatingActionButton;
import com.mikepenz.aboutlibraries.LibsBuilder;
import ca.mudar.mtlaucasou.Const;
import ca.mudar.mtlaucasou.R;
import ca.mudar.mtlaucasou.data.UserPrefs;
import ca.mudar.mtlaucasou.model.MapType;
import ca.mudar.mtlaucasou.util.IntentUtils;
import ca.mudar.mtlaucasou.util.LangUtils;
import ca.mudar.mtlaucasou.util.LogUtils;
import ca.mudar.mtlaucasou.util.MapUtils;
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt;
import static ca.mudar.mtlaucasou.util.LogUtils.makeLogTag;
......@@ -179,4 +185,40 @@ public abstract class BaseActivity extends AppCompatActivity implements
sendIntent.setType(SEND_INTENT_TYPE);
startActivity(sendIntent);
}
/**
* Show tip about using the layers filter menu
*
* @param type
*/
protected void showcaseMapLayers(@MapType String type) {
if (MapUtils.isMultiLayerMapType(type) &&
UserPrefs.getInstance(getApplicationContext()).shouldDisplayLayersShowcase()) {
// TODO remove this when issue fixed
// Ref: https://github.com/sjwall/MaterialTapTargetPrompt/issues/15
// Toggle the fabMenu dummy button
final FloatingActionButton dummy = (FloatingActionButton) findViewById(R.id.dummy_fab_menu);
dummy.setColorNormal(MapUtils.getMapTypeColor(getApplicationContext(), type));
dummy.setColorPressed(MapUtils.getMapTypeColor(getApplicationContext(), type));
dummy.setVisibility(View.VISIBLE);
new MaterialTapTargetPrompt.Builder(this)
.setTarget(dummy)
.setPrimaryText(R.string.showcase_map_layers_title)
.setBackgroundColourFromRes(R.color.color_primary_dark)
.setSecondaryText(R.string.showcase_map_layers_desc)
.setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
dummy.setVisibility(View.GONE);
}
@Override
public void onHidePromptComplete() {
// ignore
}
})
.show();
}
}
}
......@@ -223,7 +223,9 @@ public class MainActivity extends BaseActivity implements
mBottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes final int tabId) {
setMapType(NavigUtils.getMapTypeByTabId(tabId), BOTTOM_BAR_ANIM_DURATION);
final @MapType String mapType = NavigUtils.getMapTypeByTabId(tabId);
showcaseMapLayers(mapType);
setMapType(mapType, BOTTOM_BAR_ANIM_DURATION);
}
});
......
......@@ -3,6 +3,17 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<com.github.clans.fab.FloatingActionButton
android:id="@+id/dummy_fab_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="@dimen/fab_margin"
android:layout_marginEnd="@dimen/fab_margin"
android:src="@drawable/ic_map_layers"
android:visibility="gone"
app:fab_size="normal" />
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/fab_menu"
style="@style/FabMenu"
......
......@@ -100,6 +100,10 @@
<string name="prefs_permissions_summary">Choisir Permissions &gt; activer Localisation</string>
<string name="prefs_version_title">Version</string>
<!--Showcase/Tips-->
<string name="showcase_map_layers_title">Couches cartographiques</string>
<string name="showcase_map_layers_desc">Vous pouvez choisir les catégories affichées sur la carte</string>
<!--Units-->
<string name="placemark_distance_iso">%.1f km</string>
<string name="placemark_distance_iso_min">&lt; 100 m</string>
......
......@@ -28,6 +28,7 @@
<!--Material Colors-->
<color name="white">#ffffff</color>
<color name="white_transp">#00ffffff</color>
<color name="white_transp_80">#d0ffffff</color>
<!--<color name="deep_orange_900">#BF360C</color>-->
<!--<color name="orange_500">#FF9800</color>-->
......
......@@ -100,6 +100,10 @@
<string name="prefs_permissions_summary">Select Permissions &gt; enable Location</string>
<string name="prefs_version_title">Version</string>
<!--Showcase/Tips-->
<string name="showcase_map_layers_title">Map layers</string>
<string name="showcase_map_layers_desc">Tap to select categories visible on the map</string>
<!--Units-->
<string name="placemark_distance_iso">%.1f km</string>
<string name="placemark_distance_iso_min">&lt; 100 m</string>
......
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