[android] Add feedback fab (#6765)

[android] Add feedback fab

Signed-off-by: Saptak Manna <saptakmanna100@gmail.com>
This commit is contained in:
Mr. 17 2023-12-07 18:56:21 +05:30 committed by GitHub
parent 62be2f9aeb
commit 2f9f1c6d6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 40 deletions

View file

@ -2,21 +2,21 @@ package app.organicmaps.help;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import app.organicmaps.R;
import app.organicmaps.WebContainerDelegate;
import app.organicmaps.base.BaseMwmFragment;
import app.organicmaps.util.Constants;
import app.organicmaps.util.Utils;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
public class FaqFragment extends BaseMwmFragment
{
@ -63,14 +63,24 @@ public class FaqFragment extends BaseMwmFragment
}
};
TextView feedback = root.findViewById(R.id.feedback);
feedback.setOnClickListener(v -> new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
FloatingActionButton feedbackFab = root.findViewById(R.id.feedback_fab);
feedbackFab.setOnClickListener(v -> new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
.setTitle(R.string.feedback)
.setNegativeButton(R.string.cancel, null)
.setItems(new CharSequence[]{getString(R.string.feedback_general), getString(R.string.report_a_bug)},
mDialogClickListener)
.setItems(new CharSequence[] { getString(R.string.feedback_general), getString(R.string.report_a_bug) },
mDialogClickListener)
.show());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
root.findViewById(R.id.webview).setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
if (scrollY > oldScrollY)
feedbackFab.hide();
else
feedbackFab.show();
});
}
return root;
}
}

View file

@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z" />
</vector>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.floatingactionbutton.FloatingActionButton
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/feedback_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/feedback"
app:tint="?android:textColorPrimaryInverse"
android:src="@drawable/ic_feedback"
android:clickable="true"
android:focusable="true"
app:fabSize="normal" />

View file

@ -1,40 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
android:layout_height="0dp"
android:layout_weight="1">
<app.organicmaps.widget.ObservableWebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<ProgressBar
android:id="@+id/progress"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<include layout="@layout/shadow_top"/>
<include layout="@layout/shadow_bottom"/>
</FrameLayout>
<FrameLayout
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/feedback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/margin_base"
android:text="@string/feedback"
android:textAppearance="@style/MwmTextAppearance.Button"
android:background="?clickableBackground"/>
android:layout_height="wrap_content"
android:visibility="gone" />
<ProgressBar
android:id="@+id/progress"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<include
layout="@layout/feedback_fab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/margin_base" />
<include layout="@layout/shadow_top" />
<include layout="@layout/shadow_bottom" />
</FrameLayout>
</LinearLayout>
</LinearLayout>