[android] Added Base screen sharing options, created sharing options stub interface without core yet

This commit is contained in:
Dmitry Donskoy 2018-10-22 19:31:06 +03:00 committed by Aleksandr Zatsepin
parent 5fd58ee785
commit 8d9e397abd
20 changed files with 506 additions and 1 deletions

View file

@ -441,7 +441,7 @@
android:label="@string/subtittle_opt_out"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
<activity android:name="com.mapswithme.maps.ugc.routes.UgcRouteSharingOptionsActivity"/>
<service
android:name="com.mapswithme.maps.background.WorkerService"
android:permission="android.permission.BIND_JOB_SERVICE"

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:visibility="visible"
android:minHeight="@dimen/height_block_base"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@string/upload_and_publish_progress_text"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:background="?selectableItemBackground"
android:textAllCaps="true"
android:minHeight="@dimen/height_block_base"
android:gravity="center_vertical"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ProgressBar
android:gravity="center_vertical"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_width="@dimen/margin_base_plus"
android:layout_height="@dimen/margin_base_plus"/>
</LinearLayout>

View file

@ -0,0 +1,206 @@
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/MwmWidget.ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?colorPrimary"
android:gravity="end|center_vertical"
android:theme="@style/MwmWidget.ToolbarTheme"
tools:ignore="UnusedAttribute">
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/upload_and_publish_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:minHeight="@dimen/height_block_base"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/public_access"
android:paddingStart="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:paddingLeft="@dimen/margin_base"/>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/cardBackground">
<ImageView
android:id="@+id/upload_and_publish_image"
android:layout_width="@dimen/sharing_options_img_size"
android:layout_height="@dimen/sharing_options_img_size"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:tint="?colorAccent"
android:src="@drawable/ic_globe"
android:layout_marginTop="@dimen/margin_half_plus"
android:layout_marginBottom="@dimen/margin_half_plus"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginLeft="@dimen/margin_base"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_double_plus"
android:layout_marginStart="@dimen/margin_double_plus"
android:layout_toRightOf="@id/upload_and_publish_image"
android:layout_toEndOf="@id/upload_and_publish_image">
<TextView
android:id="@+id/upload_and_publish_text"
android:text="@string/upload_and_publish"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:background="?selectableItemBackground"
android:textColor="?colorAccent"
android:textAllCaps="true"
android:minHeight="@dimen/height_block_base"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<include
android:visibility="gone"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:id="@+id/upload_and_publish_progress_container"
layout="@layout/ugc_routes_progress_container"/>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:text="@string/upload_and_publish_desc"
android:paddingTop="@dimen/margin_half_double_plus"
android:paddingBottom="@dimen/margin_half_double_plus"/>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
<TextView
android:id="@+id/license_agreement_message"
android:minHeight="@dimen/downloader_status_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/margin_half_double_plus"
android:paddingBottom="@dimen/margin_half_double_plus"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
<LinearLayout
android:id="@+id/get_direct_link_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:minHeight="@dimen/height_block_base"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/limited_access"
android:paddingStart="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:paddingLeft="@dimen/margin_base"/>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/cardBackground">
<ImageView
android:id="@+id/get_direct_link_image"
android:layout_width="@dimen/sharing_options_img_size"
android:layout_height="@dimen/sharing_options_img_size"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:tint="?colorAccent"
android:src="@drawable/ic_link"
android:layout_marginTop="@dimen/margin_half_plus"
android:layout_marginBottom="@dimen/margin_half_plus"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginLeft="@dimen/margin_base"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/get_direct_link_image"
android:layout_toEndOf="@id/get_direct_link_image"
android:layout_marginLeft="@dimen/margin_double_plus"
android:layout_marginStart="@dimen/margin_double_plus">
<TextView
android:id="@+id/get_direct_link_text"
android:minHeight="@dimen/height_block_base"
android:text="@string/upload_and_get_direct_link"
android:background="?selectableItemBackground"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:textColor="?colorAccent"
android:textAllCaps="true"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"/>
<include
android:visibility="gone"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:id="@+id/get_direct_link_progress_container"
layout="@layout/ugc_routes_progress_container"/>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/get_direct_link_desc"
android:paddingRight="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:paddingTop="@dimen/margin_half_double_plus"
android:paddingBottom="@dimen/margin_half_double_plus"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<View
android:background="?android:attr/listDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/cardBackground">
<ImageView
android:layout_width="@dimen/height_block_base"
android:layout_height="@dimen/height_block_base"
android:src="@drawable/ic_done"/>
</RelativeLayout>

View file

@ -256,4 +256,5 @@
<dimen name="ads_removal_dialog_min_height">508dp</dimen>
<dimen name="ads_removal_pay_button_min_width">240dp</dimen>
<dimen name="dot_size">6dp</dimen>
<dimen name="sharing_options_img_size">18dp</dimen>
</resources>

View file

@ -2370,4 +2370,13 @@
<string name="type.wheelchair.limited">wheelchair-limited</string>
<string name="type.wheelchair.no">wheelchair-no</string>
<string name="type.wheelchair.yes">wheelchair-yes</string>
<string name="public_access">Public access</string>
<string name="limited_access">Limited access</string>
<string name="upload_and_publish_desc">This list will be uploaded in the public catalog at MAPS.ME as guide and will be easily shared with others</string>
<string name="upload_and_publish">Upload and publish</string>
<string name="upload_and_get_direct_link">Upload and get a direct link</string>
<string name="get_direct_link_desc">Anyone this the link will see your list</string>
<string name="upload_and_publish_progress_text">Publishing your guide…</string>
<string name="ugc_routes_user_agreement">&lt;b>PLEASE NOTE:&lt;/b> by proceeding, you accept the &lt;font color="#249cf2">&lt;a href="%1$s">license agreement&lt;/font>&lt;/a></string>
<string name="sharing_options">Sharing options</string>
</resources>

View file

@ -0,0 +1,36 @@
package com.mapswithme.maps;
import android.content.ActivityNotFoundException;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.view.MotionEvent;
import android.widget.TextView;
import android.widget.Toast;
public class DisabledBrowserMovementMethod extends LinkMovementMethod
{
private DisabledBrowserMovementMethod()
{
}
public static DisabledBrowserMovementMethod getInstance()
{
return new DisabledBrowserMovementMethod();
}
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event)
{
boolean result = true;
try
{
result = super.onTouchEvent(widget, buffer, event);
}
catch (ActivityNotFoundException e)
{
/* FIXME */
Toast.makeText(widget.getContext(), R.string.error_system_message, Toast.LENGTH_SHORT).show();
}
return result;
}
}

View file

@ -21,4 +21,10 @@ public class BaseMwmToolbarFragment extends BaseMwmFragment
{
return new ToolbarController(root, getActivity());
}
@NonNull
protected ToolbarController getToolbarController()
{
return mToolbarController;
}
}

View file

@ -0,0 +1,14 @@
package com.mapswithme.maps.ugc.routes;
import android.support.v4.app.Fragment;
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
public class UgcRouteSharingOptionsActivity extends BaseMwmFragmentActivity
{
@Override
protected Class<? extends Fragment> getFragmentClass()
{
return UgcSharingOptionsFragment.class;
}
}

View file

@ -0,0 +1,196 @@
package com.mapswithme.maps.ugc.routes;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mapswithme.maps.DisabledBrowserMovementMethod;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.auth.Authorizer;
import com.mapswithme.maps.auth.BaseMwmAuthorizationFragment;
import com.mapswithme.maps.dialog.AlertDialog;
import com.mapswithme.util.ConnectionState;
public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment
{
private static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog";
@SuppressWarnings("NullableProblems")
@NonNull
private Authorizer mAuthorizer;
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mAuthorizer = new Authorizer(this);
}
@Override
protected ToolbarController onCreateToolbarController(@NonNull View root)
{
return new ToolbarController(root);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState)
{
View root = inflater.inflate(R.layout.ugc_routes_sharing_options_frag, container, false);
initClickListeners(root);
TextView licenceAgreementText = root.findViewById(R.id.license_agreement_message);
String src = getResources().getString(R.string.ugc_routes_user_agreement,
/* FIXME */
Framework.nativeGetPrivacyPolicyLink());
Spanned spanned = Html.fromHtml(src);
licenceAgreementText.setMovementMethod(DisabledBrowserMovementMethod.getInstance());
licenceAgreementText.setText(spanned);
return root;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
getToolbarController().setTitle(R.string.sharing_options);
}
private void initClickListeners(View root)
{
View getDirectLinkView = root.findViewById(R.id.get_direct_link_text);
getDirectLinkView.setOnClickListener(directLinkListener -> onGetDirectLinkClicked());
View uploadAndPublishView = root.findViewById(R.id.upload_and_publish_text);
uploadAndPublishView.setOnClickListener(uploadListener -> onUploadAndPublishBtnClicked());
}
@Override
public void onStart()
{
super.onStart();
mAuthorizer.attach(this);
}
@Override
public void onStop()
{
super.onStop();
mAuthorizer.detach();
}
private void onUploadAndPublishBtnClicked()
{
if (isNetworkConnectionAbsent())
{
showNoNetworkConnectionDialog();
return;
}
if (hasAuthToken())
openTagsScreen();
else
requestAuth();
}
private void showNoNetworkConnectionDialog()
{
Fragment fragment = getFragmentManager().findFragmentByTag(NO_NETWORK_CONNECTION_DIALOG_TAG);
if (fragment != null)
return;
AlertDialog dialog = new AlertDialog.Builder()
.setTitleId(R.string.common_check_internet_connection_dialog_title)
.setMessageId(R.string.common_check_internet_connection_dialog)
.setPositiveBtnId(R.string.ok)
.build();
dialog.show(dialog, NO_NETWORK_CONNECTION_DIALOG_TAG);
}
private boolean isNetworkConnectionAbsent()
{
return !ConnectionState.isConnected();
}
private void requestAuth()
{
mAuthorizer.authorize();
}
private void openTagsScreen()
{
}
private boolean hasAuthToken()
{
return mAuthorizer.isAuthorized();
}
private void onGetDirectLinkClicked()
{
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
/*FIXME*/
if (requestCode == 1 && resultCode == Activity.RESULT_OK)
requestPublishing(data);
}
private void requestPublishing(@NonNull Intent data)
{
}
@Override
public void onAuthorizationFinish(boolean success)
{
}
@Override
public void onAuthorizationStart()
{
}
@Override
public void onSocialAuthenticationCancel(int type)
{
}
@Override
public void onSocialAuthenticationError(int type, @Nullable String error)
{
}
private class ToolbarController extends com.mapswithme.maps.widget.ToolbarController
{
public ToolbarController(View root)
{
super(root, UgcSharingOptionsFragment.this.getActivity());
}
@Override
public void onUpClick()
{
getActivity().finish();
}
}
}