mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
Removed buggy swipe refresh layout and added reload button to top toolbar
This commit is contained in:
parent
e1b02c42d2
commit
9ecf55ca82
9 changed files with 38 additions and 56 deletions
|
@ -45,7 +45,6 @@ import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.ActionMenuView;
|
import android.support.v7.widget.ActionMenuView;
|
||||||
|
@ -73,6 +72,7 @@ import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
/**
|
/**
|
||||||
* UI Bindings
|
* UI Bindings
|
||||||
*/
|
*/
|
||||||
@BindView(R.id.swipe)
|
@BindView(R.id.content_layout)
|
||||||
SwipeRefreshLayout swipeRefreshLayout;
|
RelativeLayout contentLayout;
|
||||||
|
|
||||||
@BindView(R.id.progressBar)
|
@BindView(R.id.progressBar)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
@ -206,7 +206,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
//Setup snackbar
|
//Setup snackbar
|
||||||
snackbarExitApp = Snackbar
|
snackbarExitApp = Snackbar
|
||||||
.make(swipeRefreshLayout, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
.make(contentLayout, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
||||||
.setAction(android.R.string.yes, new View.OnClickListener() {
|
.setAction(android.R.string.yes, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -215,18 +215,18 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
snackbarNewNotification = Snackbar
|
snackbarNewNotification = Snackbar
|
||||||
.make(swipeRefreshLayout, R.string.new_notifications, Snackbar.LENGTH_LONG)
|
.make(contentLayout, R.string.new_notifications, Snackbar.LENGTH_LONG)
|
||||||
.setAction(android.R.string.yes, new View.OnClickListener() {
|
.setAction(android.R.string.yes, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (Helpers.isOnline(MainActivity.this)) {
|
if (Helpers.isOnline(MainActivity.this)) {
|
||||||
webView.loadUrl("https://" + podDomain + "/notifications");
|
webView.loadUrl("https://" + podDomain + "/notifications");
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(contentLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
snackbarNoInternet = Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG);
|
snackbarNoInternet = Snackbar.make(contentLayout, R.string.no_internet, Snackbar.LENGTH_LONG);
|
||||||
|
|
||||||
// Load app settings
|
// Load app settings
|
||||||
setupNavigationSlider();
|
setupNavigationSlider();
|
||||||
|
@ -234,9 +234,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
||||||
podDomain = appSettings.getPodDomain();
|
podDomain = appSettings.getPodDomain();
|
||||||
|
|
||||||
swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary,
|
|
||||||
R.color.fab_big);
|
|
||||||
|
|
||||||
String url = "https://" + podDomain;
|
String url = "https://" + podDomain;
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
if (Helpers.isOnline(MainActivity.this)) {
|
if (Helpers.isOnline(MainActivity.this)) {
|
||||||
|
@ -291,20 +288,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
/*
|
/*
|
||||||
* WebViewClient
|
* WebViewClient
|
||||||
*/
|
*/
|
||||||
webViewClient = new CustomWebViewClient(app, swipeRefreshLayout, webView);
|
webViewClient = new CustomWebViewClient(app, webView);
|
||||||
webView.setWebViewClient(webViewClient);
|
webView.setWebViewClient(webViewClient);
|
||||||
|
|
||||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
|
||||||
if (Helpers.isOnline(MainActivity.this)) {
|
|
||||||
webView.reload();
|
|
||||||
} else {
|
|
||||||
snackbarNoInternet.show();
|
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WebChromeClient
|
* WebChromeClient
|
||||||
|
@ -345,7 +331,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
|
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
// Error occurred while creating the File
|
// Error occurred while creating the File
|
||||||
Snackbar.make(swipeRefreshLayout, R.string.unable_to_load_image, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(contentLayout, R.string.unable_to_load_image, Snackbar.LENGTH_LONG).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,6 +620,16 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case R.id.action_reload: {
|
||||||
|
if(Helpers.isOnline(MainActivity.this)) {
|
||||||
|
webView.reload();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
snackbarNoInternet.show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case R.id.action_exit: {
|
case R.id.action_exit: {
|
||||||
moveTaskToBack(true);
|
moveTaskToBack(true);
|
||||||
finish();
|
finish();
|
||||||
|
@ -701,7 +697,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
String cleanTag = inputTag.replaceAll(wasClickedOnSearchForPeople ? "\\*" : "\\#", "");
|
String cleanTag = inputTag.replaceAll(wasClickedOnSearchForPeople ? "\\*" : "\\#", "");
|
||||||
// this validate the input data for tagfind
|
// this validate the input data for tagfind
|
||||||
if (cleanTag == null || cleanTag.equals("")) {
|
if (cleanTag == null || cleanTag.equals("")) {
|
||||||
Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(contentLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
|
||||||
} else { // User have added a search tag
|
} else { // User have added a search tag
|
||||||
if (wasClickedOnSearchForPeople) {
|
if (wasClickedOnSearchForPeople) {
|
||||||
webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag);
|
webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag);
|
||||||
|
@ -785,7 +781,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasToShareScreenshot) {
|
if (!hasToShareScreenshot) {
|
||||||
Snackbar.make(swipeRefreshLayout, getString(R.string.share__toast_screenshot) + " " + fileSaveName, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(contentLayout, getString(R.string.share__toast_screenshot) + " " + fileSaveName, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap bitmap;
|
Bitmap bitmap;
|
||||||
|
|
|
@ -21,7 +21,6 @@ package com.github.dfa.diaspora_android.ui;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
@ -30,12 +29,10 @@ import com.github.dfa.diaspora_android.App;
|
||||||
|
|
||||||
public class CustomWebViewClient extends WebViewClient {
|
public class CustomWebViewClient extends WebViewClient {
|
||||||
private App app;
|
private App app;
|
||||||
private SwipeRefreshLayout swipeRefreshLayout;
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
|
|
||||||
public CustomWebViewClient(App app, SwipeRefreshLayout swipeRefreshLayout, WebView webView) {
|
public CustomWebViewClient(App app, WebView webView) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.swipeRefreshLayout = swipeRefreshLayout;
|
|
||||||
this.webView = webView;
|
this.webView = webView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,18 +46,8 @@ public class CustomWebViewClient extends WebViewClient {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
||||||
super.onPageStarted(view, url, favicon);
|
|
||||||
swipeRefreshLayout.setEnabled(true);
|
|
||||||
if(url.contains(app.getSettings().getPodDomain()+"/conversations/") || url.endsWith("status_messages/new") || url.equals("about:blank")){
|
|
||||||
swipeRefreshLayout.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
|
||||||
|
|
||||||
final CookieManager cookieManager = app.getCookieManager();
|
final CookieManager cookieManager = app.getCookieManager();
|
||||||
String cookies = cookieManager.getCookie(url);
|
String cookies = cookieManager.getCookie(url);
|
||||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_refresh_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_refresh_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 387 B |
BIN
app/src/main/res/drawable-mdpi/ic_refresh_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_refresh_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 254 B |
BIN
app/src/main/res/drawable-xhdpi/ic_refresh_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_refresh_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 509 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_refresh_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_refresh_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 734 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_refresh_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_refresh_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 967 B |
|
@ -2,29 +2,22 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout 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"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/content_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
tools:context=".activity.MainActivity"
|
tools:context=".activity.MainActivity"
|
||||||
tools:showIn="@layout/main__app_bar">
|
tools:showIn="@layout/main__app_bar">
|
||||||
|
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
<com.github.dfa.diaspora_android.ui.ContextMenuWebView
|
||||||
android:id="@+id/swipe"
|
android:id="@+id/webView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="fill_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
<com.github.dfa.diaspora_android.ui.ContextMenuWebView
|
android:layout_alignParentRight="true"
|
||||||
android:id="@+id/webView"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_width="fill_parent"
|
android:layout_centerVertical="true" />
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_centerVertical="true" />
|
|
||||||
|
|
||||||
</android.support.v4.widget.SwipeRefreshLayout>
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
|
|
|
@ -15,4 +15,10 @@
|
||||||
android:title="@string/conversations"
|
android:title="@string/conversations"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_reload"
|
||||||
|
android:icon="@drawable/ic_refresh_white_24dp"
|
||||||
|
android:title="@string/reload"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
Loading…
Reference in a new issue