new Launch full OsmAnd dialog.
This commit is contained in:
parent
356fb356a6
commit
b7de821ee8
8 changed files with 162 additions and 6 deletions
74
OsmAnd/res/layout/dash_restore_osmand_fragment.xml
Normal file
74
OsmAnd/res/layout/dash_restore_osmand_fragment.xml
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_card"
|
||||
android:layout_marginTop="@dimen/dash_margin"
|
||||
android:layout_marginBottom="@dimen/dash_margin"
|
||||
android:layout_marginLeft="@dimen/dash_margin_h"
|
||||
android:layout_marginRight="@dimen/dash_margin_h"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/run_full_osmand_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dashSearchPaddingTop"
|
||||
android:layout_marginBottom="@dimen/dashSearchPaddingBot"
|
||||
android:layout_marginRight="@dimen/subHeaderMarginRight"
|
||||
android:layout_marginStart="@dimen/subHeaderMarginLeft"
|
||||
android:layout_marginLeft="@dimen/subHeaderMarginLeft"
|
||||
android:layout_marginEnd="@dimen/subHeaderMarginRight"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/run_full_osmand_header"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/run_full_osmand_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/subHeaderPadding"
|
||||
android:layout_marginBottom="@dimen/dashSearchPaddingBot"
|
||||
android:layout_marginRight="@dimen/subHeaderMarginRight"
|
||||
android:layout_marginStart="@dimen/subHeaderMarginLeft"
|
||||
android:layout_marginLeft="@dimen/subHeaderMarginLeft"
|
||||
android:layout_marginEnd="@dimen/subHeaderMarginRight"
|
||||
android:layout_weight="1"
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_full_osmand_btn"
|
||||
style="@style/DashboardGeneralButton"
|
||||
android:layout_width="0dp"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/shared_string_cancel"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/launch_full_osmand_btn"
|
||||
style="@style/DashboardGeneralButton"
|
||||
android:layout_width="0dp"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/shared_string_launch"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
<dimen name="subHeaderPadding">2dp</dimen>
|
||||
<dimen name="subHeaderMarginLeft">15dp</dimen>
|
||||
<dimen name = "subHeaderMarginRight">15dp</dimen>
|
||||
<dimen name="showAllButtonMarginRight">14dp</dimen>
|
||||
<dimen name="showAllButtonHeight">36dp</dimen>
|
||||
<dimen name="dashFavIconSize">28dp</dimen>
|
||||
|
|
|
@ -1162,6 +1162,7 @@
|
|||
<string name="shared_string_audio">Audio</string>
|
||||
<string name="shared_string_video">Video</string>
|
||||
<string name="shared_string_photo">Photo</string>
|
||||
<string name="shared_string_launch">Launch</string>
|
||||
<string name="route_points">Route points</string>
|
||||
<string name="track_segments">Track segments</string>
|
||||
<string name="track_points">Track points</string>
|
||||
|
@ -2963,4 +2964,6 @@
|
|||
<string name="wiki_article_not_found">Article not found</string>
|
||||
<string name="how_to_open_wiki_title">How to open Wikipedia articles?</string>
|
||||
<string name="test_voice_desrc">Tap a button and listen to the corresponding voice prompt to identify missing or faulty prompts.</string>
|
||||
<string name="run_full_osmand_msg">You are using {0} Map which is powered by OsmAnd. Do you want to launch OsmAnd full version?</string>
|
||||
<string name="run_full_osmand_header">Launch OsmAnd?</string>
|
||||
</resources>
|
||||
|
|
|
@ -37,6 +37,7 @@ import net.osmand.aidl.maplayer.AMapLayer;
|
|||
import net.osmand.aidl.maplayer.point.AMapPoint;
|
||||
import net.osmand.aidl.mapmarker.AMapMarker;
|
||||
import net.osmand.aidl.mapwidget.AMapWidget;
|
||||
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
||||
import net.osmand.aidl.plugins.PluginParams;
|
||||
import net.osmand.aidl.search.SearchResult;
|
||||
import net.osmand.aidl.tiles.ASqliteDbFile;
|
||||
|
@ -1914,8 +1915,8 @@ public class OsmandAidlApi {
|
|||
return app.getAppCustomization().setNavDrawerLogoWithParams(uri, packageName, intent);
|
||||
}
|
||||
|
||||
boolean setNavDrawerFooterWithParams(@NonNull String packageName, @Nullable String intent, @Nullable String appName) {
|
||||
return app.getAppCustomization().setNavDrawerFooterAction(packageName, intent, appName);
|
||||
boolean setNavDrawerFooterWithParams(@NonNull NavDrawerFooterParams params) {
|
||||
return app.getAppCustomization().setNavDrawerFooterParams(params);
|
||||
}
|
||||
|
||||
boolean restoreOsmand() {
|
||||
|
|
|
@ -808,8 +808,7 @@ public class OsmandAidlService extends Service {
|
|||
public boolean setNavDrawerFooterWithParams(NavDrawerFooterParams params)
|
||||
throws RemoteException {
|
||||
OsmandAidlApi api = getApi("setNavDrawerFooterParams");
|
||||
return api != null && api.setNavDrawerFooterWithParams(
|
||||
params.getPackageName(), params.getIntent(), params.getAppName());
|
||||
return api != null && api.setNavDrawerFooterWithParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,8 @@ import android.text.TextUtils;
|
|||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
|
||||
import net.osmand.aidl.navdrawer.NavDrawerHeaderParams;
|
||||
import net.osmand.aidl.plugins.PluginParams;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -46,6 +48,7 @@ public class OsmAndAppCustomization {
|
|||
|
||||
private Bitmap navDrawerLogo;
|
||||
private ArrayList<String> navDrawerParams;
|
||||
private NavDrawerFooterParams navDrawerFooterParams;
|
||||
|
||||
private Set<String> featuresEnabledIds = new HashSet<>();
|
||||
private Set<String> featuresDisabledIds = new HashSet<>();
|
||||
|
@ -240,6 +243,14 @@ public class OsmAndAppCustomization {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean setNavDrawerFooterParams(NavDrawerFooterParams params){
|
||||
navDrawerFooterParams = params;
|
||||
return true;
|
||||
}
|
||||
|
||||
public NavDrawerFooterParams getNavFooterParams(){
|
||||
return navDrawerFooterParams;
|
||||
}
|
||||
|
||||
public void setFeaturesEnabledIds(@NonNull Collection<String> ids) {
|
||||
featuresEnabledIds.clear();
|
||||
|
|
|
@ -51,7 +51,9 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.actions.OsmAndDialogs;
|
||||
import net.osmand.plus.activities.actions.OsmandRestoreOrExitDialog;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
|
||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||
|
@ -1089,8 +1091,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
footerLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(navDrawerLogoParams!=null) showReturnConfirmationDialog(navDrawerLogoParams.get(0));
|
||||
else restoreOsmand();
|
||||
if(navDrawerLogoParams!=null)
|
||||
mapActivity.closeDrawer();
|
||||
new OsmandRestoreOrExitDialog().show(mapActivity.getSupportFragmentManager(), "dialog");
|
||||
//showReturnConfirmationDialog(navDrawerLogoParams.get(0));
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package net.osmand.plus.activities.actions;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import java.text.MessageFormat;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
|
||||
public class OsmandRestoreOrExitDialog extends BottomSheetDialogFragment {
|
||||
|
||||
private String clientAppTitle = "";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater()
|
||||
.inflate(R.layout.dash_restore_osmand_fragment, container, false);
|
||||
try {
|
||||
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterParams().getAppName();
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
|
||||
String msg = MessageFormat.format(getString(R.string.run_full_osmand_msg), clientAppTitle);
|
||||
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||
Typeface typefaceReg = FontCache.getRobotoRegular(getActivity());
|
||||
TextView header = view.findViewById(R.id.run_full_osmand_header);
|
||||
header.setTypeface(typeface);
|
||||
|
||||
TextView message = view.findViewById(R.id.run_full_osmand_message);
|
||||
message.setTypeface(typefaceReg);
|
||||
message.setText(msg);
|
||||
|
||||
Button cancelBtn = view.findViewById(R.id.cancel_full_osmand_btn);
|
||||
cancelBtn.setTypeface(typeface);
|
||||
cancelBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
Button launchBtn = view.findViewById(R.id.launch_full_osmand_btn);
|
||||
launchBtn.setTypeface(typeface);
|
||||
launchBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
getMyApplication().getAppCustomization().restoreOsmand();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue