Refresh in WebViewActivity.

This commit is contained in:
Alex Ning 2021-10-10 22:12:31 +08:00
parent 43b9abd6ee
commit 9e5b5c78e2
2 changed files with 11 additions and 8 deletions

View File

@ -22,7 +22,6 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.r0adkll.slidr.Slidr;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -33,7 +32,6 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LollipopBugFixedWebView; import ml.docilealligator.infinityforreddit.customviews.LollipopBugFixedWebView;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
public class WebViewActivity extends BaseActivity { public class WebViewActivity extends BaseActivity {
@ -74,10 +72,6 @@ public class WebViewActivity extends BaseActivity {
applyCustomTheme(); applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
}
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setJavaScriptEnabled(true);
@ -131,6 +125,9 @@ public class WebViewActivity extends BaseActivity {
if (item.getItemId() == android.R.id.home) { if (item.getItemId() == android.R.id.home) {
finish(); finish();
return true; return true;
} else if (item.getItemId() == R.id.action_refresh_web_view_activity) {
webView.reload();
return true;
} else if (item.getItemId() == R.id.action_share_link_web_view_activity) { } else if (item.getItemId() == R.id.action_share_link_web_view_activity) {
try { try {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);

View File

@ -2,14 +2,20 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_share_link_web_view_activity" android:id="@+id/action_refresh_web_view_activity"
android:orderInCategory="1" android:orderInCategory="1"
android:title="@string/action_refresh"
app:showAsAction="never" />
<item
android:id="@+id/action_share_link_web_view_activity"
android:orderInCategory="2"
android:title="@string/action_share_link" android:title="@string/action_share_link"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_copy_link_web_view_activity" android:id="@+id/action_copy_link_web_view_activity"
android:orderInCategory="2" android:orderInCategory="3"
android:title="@string/action_copy_link" android:title="@string/action_copy_link"
app:showAsAction="never" /> app:showAsAction="never" />
</menu> </menu>