mirror of
https://github.com/gsantner/dandelion
synced 2024-11-25 22:02:08 +01:00
Lots of refactoring; Reworked Splash,PodSelectionActivity; Switch Pod; Clear settings;
This commit is contained in:
parent
ff39986715
commit
280f5ab1c3
20 changed files with 389 additions and 281 deletions
26
LICENSE.md
26
LICENSE.md
|
@ -1,18 +1,18 @@
|
||||||
First of all: I am not a developer. I understand a few basics and most of my work is done
|
# App
|
||||||
by copy and paste. This app is a fork of the original [Diaspora-Native-Webapp](https://github.com/martinchodev/Diaspora-Native-WebApp)
|
|
||||||
from "martinchodev" (who did most of the work -> big thanks to him), which is released under the GPL-license.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see http://www.gnu.org/licenses/.
|
along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
|
||||||
|
# Splashscreen-Images
|
||||||
The splashscreen images can be found on [flickr](https://www.flickr.com/photos/129581906@N06/sets/72157651933980136/with/16594947123/).
|
The splashscreen images can be found on [flickr](https://www.flickr.com/photos/129581906@N06/sets/72157651933980136/with/16594947123/).
|
||||||
|
|
|
@ -30,9 +30,9 @@ dependencies {
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
|
|
||||||
// Android standard libs
|
// Android standard libs
|
||||||
compile 'com.android.support:appcompat-v7:23.3.0'
|
compile 'com.android.support:appcompat-v7:23.4.0'
|
||||||
compile 'com.android.support:design:23.3.0'
|
compile 'com.android.support:design:23.4.0'
|
||||||
compile 'com.android.support:support-v4:23.3.0'
|
compile 'com.android.support:support-v4:23.4.0'
|
||||||
|
|
||||||
// More libraries
|
// More libraries
|
||||||
compile 'com.getbase:floatingactionbutton:1.9.1'
|
compile 'com.getbase:floatingactionbutton:1.9.1'
|
||||||
|
|
|
@ -31,10 +31,11 @@
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:label="@string/title_activity_pods"
|
android:label="@string/title_activity_pods"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
android:windowSoftInputMode="stateHidden" >
|
android:windowSoftInputMode="stateHidden" >
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.github.dfa.diaspora_android.activity.MainActivity"
|
android:name=".activity.MainActivity"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
|
|
|
@ -3,10 +3,14 @@ package com.github.dfa.diaspora_android;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.CookieSyncManager;
|
import android.webkit.CookieSyncManager;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
|
import com.github.dfa.diaspora_android.ui.CustomWebViewClient;
|
||||||
import com.github.dfa.diaspora_android.util.AvatarImageLoader;
|
import com.github.dfa.diaspora_android.util.AvatarImageLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +39,28 @@ public class App extends Application {
|
||||||
cookieManager.setAcceptCookie(true);
|
cookieManager.setAcceptCookie(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetPodData(@Nullable WebView webView){
|
||||||
|
if(webView != null){
|
||||||
|
webView.stopLoading();
|
||||||
|
webView.loadUrl("about:blank");
|
||||||
|
webView.clearFormData();
|
||||||
|
webView.clearHistory();
|
||||||
|
webView.clearCache(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear avatar image
|
||||||
|
new AvatarImageLoader(this).clearAvatarImage();
|
||||||
|
|
||||||
|
// Clear preferences
|
||||||
|
appSettings.clearPodSettings();
|
||||||
|
|
||||||
|
// Clear cookies
|
||||||
|
cookieManager.removeAllCookie();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
cookieManager.removeAllCookies(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public AppSettings getSettings() {
|
public AppSettings getSettings() {
|
||||||
return appSettings;
|
return appSettings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
This file is part of the Diaspora Native WebApp.
|
This file is part of the Diaspora for Android.
|
||||||
|
|
||||||
Diaspora Native WebApp is free software: you can redistribute it and/or modify
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Diaspora Native WebApp is distributed in the hope that it will be useful,
|
Diaspora for Android is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with the Diaspora Native WebApp.
|
along with the Diaspora for Android.
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@ -51,18 +51,15 @@ import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.CookieManager;
|
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
@ -75,10 +72,11 @@ import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
import com.github.dfa.diaspora_android.data.WebUserProfile;
|
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||||
import com.github.dfa.diaspora_android.listener.SoftKeyboardStateWatcher;
|
import com.github.dfa.diaspora_android.listener.SoftKeyboardStateWatcher;
|
||||||
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
|
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
|
||||||
import com.github.dfa.diaspora_android.ui.ContextMenuWebView;
|
import com.github.dfa.diaspora_android.ui.ContextMenuWebView;
|
||||||
|
import com.github.dfa.diaspora_android.ui.CustomWebViewClient;
|
||||||
import com.github.dfa.diaspora_android.util.Helpers;
|
import com.github.dfa.diaspora_android.util.Helpers;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -113,8 +111,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
private String mCameraPhotoPath;
|
private String mCameraPhotoPath;
|
||||||
private WebSettings webSettings;
|
private WebSettings webSettings;
|
||||||
private AppSettings appSettings;
|
private AppSettings appSettings;
|
||||||
private WebUserProfile webUserProfile;
|
private PodUserProfile podUserProfile;
|
||||||
private final Handler uiHandler = new Handler();
|
private final Handler uiHandler = new Handler();
|
||||||
|
private CustomWebViewClient webViewClient;
|
||||||
|
|
||||||
@BindView(R.id.swipe)
|
@BindView(R.id.swipe)
|
||||||
SwipeRefreshLayout swipeRefreshLayout;
|
SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
@ -151,7 +150,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
app = (App) getApplication();
|
app = (App) getApplication();
|
||||||
appSettings = app.getSettings();
|
appSettings = app.getSettings();
|
||||||
webUserProfile = new WebUserProfile(app, uiHandler, this);
|
podUserProfile = new PodUserProfile(app, uiHandler, this);
|
||||||
|
|
||||||
this.registerForContextMenu(webView);
|
this.registerForContextMenu(webView);
|
||||||
webView.setParentActivity(this);
|
webView.setParentActivity(this);
|
||||||
|
@ -216,37 +215,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
/*
|
/*
|
||||||
* WebViewClient
|
* WebViewClient
|
||||||
*/
|
*/
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
webViewClient = new CustomWebViewClient(app, swipeRefreshLayout, webView);
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
webView.setWebViewClient(webViewClient);
|
||||||
if (!url.contains(podDomain)) {
|
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
||||||
startActivity(i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
|
||||||
|
|
||||||
|
|
||||||
final CookieManager cookieManager = app.getCookieManager();
|
|
||||||
String cookies = cookieManager.getCookie(url);
|
|
||||||
Log.d(App.TAG, "All the cookies in a string:" + cookies);
|
|
||||||
|
|
||||||
if (cookies != null) {
|
|
||||||
cookieManager.setCookie(url, cookies);
|
|
||||||
cookieManager.setCookie("https://" + appSettings.getPodDomain(), cookies);
|
|
||||||
for (String c : cookies.split(";")) {
|
|
||||||
//Log.d(App.TAG, "Cookie: " + c.split("=")[0] + " Value:" + c.split("=")[1]);
|
|
||||||
}
|
|
||||||
//new ProfileFetchTask(app).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -842,6 +812,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
uiHandler.post(new Runnable() {
|
uiHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(menu == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
notificationCount = Integer.valueOf(webMessage);
|
notificationCount = Integer.valueOf(webMessage);
|
||||||
|
|
||||||
MenuItem item = menu.findItem(R.id.action_notifications);
|
MenuItem item = menu.findItem(R.id.action_notifications);
|
||||||
|
@ -875,8 +848,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void setUserProfile(final String webMessage) throws JSONException {
|
public void setUserProfile(final String webMessage) throws JSONException {
|
||||||
if (webUserProfile.isRefreshNeeded()) {
|
if (podUserProfile.isRefreshNeeded()) {
|
||||||
webUserProfile.parseJson(webMessage);
|
podUserProfile.parseJson(webMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,6 +858,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
uiHandler.post(new Runnable() {
|
uiHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(menu == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
conversationCount = Integer.valueOf(webMessage);
|
conversationCount = Integer.valueOf(webMessage);
|
||||||
|
|
||||||
MenuItem item = menu.findItem(R.id.action_conversations);
|
MenuItem item = menu.findItem(R.id.action_conversations);
|
||||||
|
@ -1038,23 +1014,15 @@ public class MainActivity extends AppCompatActivity
|
||||||
new AlertDialog.Builder(MainActivity.this)
|
new AlertDialog.Builder(MainActivity.this)
|
||||||
.setTitle(getString(R.string.confirmation))
|
.setTitle(getString(R.string.confirmation))
|
||||||
.setMessage(getString(R.string.change_pod_warning))
|
.setMessage(getString(R.string.change_pod_warning))
|
||||||
.setPositiveButton(getString(R.string.yes),
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.setPositiveButton(android.R.string.yes,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@TargetApi(11)
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
webView.clearCache(true);
|
app.resetPodData(webView);
|
||||||
dialog.cancel();
|
Helpers.animateToActivity(MainActivity.this, PodSelectionActivity.class, true);
|
||||||
Intent i = new Intent(MainActivity.this, PodSelectionActivity.class);
|
|
||||||
startActivity(i);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
.show();
|
||||||
@TargetApi(11)
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
This file is part of the Diaspora Native WebApp.
|
This file is part of the Diaspora for Android.
|
||||||
|
|
||||||
Diaspora Native WebApp is free software: you can redistribute it and/or modify
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Diaspora Native WebApp is distributed in the hope that it will be useful,
|
Diaspora for Android is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with the Diaspora Native WebApp.
|
along with the Diaspora for Android.
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,9 @@ import android.content.IntentFilter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -38,11 +40,9 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
|
@ -50,25 +50,24 @@ import com.github.dfa.diaspora_android.task.GetPodsService;
|
||||||
import com.github.dfa.diaspora_android.util.Helpers;
|
import com.github.dfa.diaspora_android.util.Helpers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
import butterknife.OnItemClick;
|
||||||
|
|
||||||
|
|
||||||
public class PodSelectionActivity extends AppCompatActivity {
|
public class PodSelectionActivity extends AppCompatActivity {
|
||||||
private BroadcastReceiver podListReceiver;
|
|
||||||
private App app;
|
private App app;
|
||||||
|
|
||||||
@BindView(R.id.podselection__edit_filter)
|
@BindView(R.id.podselection__edit_filter)
|
||||||
public EditText filter;
|
public EditText editFilter;
|
||||||
|
|
||||||
@BindView(R.id.podselection__listpods)
|
@BindView(R.id.podselection__listpods)
|
||||||
public ListView lv;
|
public ListView listPods;
|
||||||
|
|
||||||
private String podSelected = "";
|
|
||||||
|
|
||||||
|
@BindView(R.id.toolbar)
|
||||||
|
public Toolbar toolbar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -76,9 +75,19 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.podselection_activity);
|
setContentView(R.layout.podselection_activity);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
app = (App) getApplication();
|
app = (App) getApplication();
|
||||||
lv.setTextFilterEnabled(true);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
podListReceiver = new BroadcastReceiver() {
|
|
||||||
|
listPods.setTextFilterEnabled(true);
|
||||||
|
registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE));
|
||||||
|
|
||||||
|
if (!Helpers.isOnline(PodSelectionActivity.this)) {
|
||||||
|
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final BroadcastReceiver podListReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.hasExtra("pods")) {
|
if (intent.hasExtra("pods")) {
|
||||||
|
@ -86,27 +95,20 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
String[] pods = extras.getStringArray("pods");
|
String[] pods = extras.getStringArray("pods");
|
||||||
|
|
||||||
if (pods != null && pods.length > 0)
|
if (pods != null && pods.length > 0)
|
||||||
updateListview(pods);
|
setListedPods(pods);
|
||||||
else {
|
else {
|
||||||
Snackbar.make(lv, R.string.podlist_error, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(listPods, R.string.podlist_error, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE));
|
|
||||||
|
|
||||||
if (!Helpers.isOnline(PodSelectionActivity.this)) {
|
|
||||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.podselection__button_select_pod)
|
@OnClick(R.id.podselection__button_select_pod)
|
||||||
public void onButtonSelectPodClicked(View view) {
|
public void onButtonSelectPodClicked(View view) {
|
||||||
if (filter.getText().length() > 4 && filter.getText().toString().contains("")) {
|
if (editFilter.getText().length() > 4 && editFilter.getText().toString().contains("")) {
|
||||||
askConfirmation(filter.getText().toString());
|
showPodConfirmationDialog(editFilter.getText().toString());
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(lv, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(listPods, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,47 +120,51 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateListview(String[] allPods) {
|
private void setListedPods(String[] listedPodsArr) {
|
||||||
final ArrayList<String> podList = new ArrayList<>();
|
final ArrayList<String> listedPodsList = new ArrayList<>();
|
||||||
|
|
||||||
for (String pod : allPods) {
|
for (String pod : listedPodsArr) {
|
||||||
podList.add(pod.toLowerCase());
|
listedPodsList.add(pod.toLowerCase());
|
||||||
}
|
}
|
||||||
//Collections.sort(podList);
|
|
||||||
|
|
||||||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(
|
final ArrayAdapter<String> adapter = new ArrayAdapter<>(
|
||||||
PodSelectionActivity.this,
|
PodSelectionActivity.this,
|
||||||
android.R.layout.simple_list_item_1,
|
android.R.layout.simple_list_item_1,
|
||||||
podList);
|
listedPodsList);
|
||||||
lv.setAdapter(adapter);
|
listPods.setAdapter(adapter);
|
||||||
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
askConfirmation(((TextView) view).getText().toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
adapter.getFilter().filter(filter.getText());
|
adapter.getFilter().filter(editFilter.getText());
|
||||||
filter.addTextChangedListener(new TextWatcher() {
|
editFilter.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
(adapter).getFilter().filter(s.toString());
|
(adapter).getFilter().filter(s.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void askConfirmation(final String podDomain) {
|
@OnItemClick(R.id.podselection__listpods)
|
||||||
podSelected = podDomain;
|
public void onListPodsItemClicked(int position) {
|
||||||
|
showPodConfirmationDialog((String) listPods.getAdapter().getItem(position));
|
||||||
|
}
|
||||||
|
|
||||||
// Make link clickable
|
private void showPodConfirmationDialog(final String selectedPod) {
|
||||||
final SpannableString dialogMessage = new SpannableString(getString(R.string.confirm_pod, podDomain));
|
// Make a clickable link
|
||||||
|
final SpannableString dialogMessage = new SpannableString(getString(R.string.confirm_pod, selectedPod));
|
||||||
Linkify.addLinks(dialogMessage, Linkify.ALL);
|
Linkify.addLinks(dialogMessage, Linkify.ALL);
|
||||||
|
|
||||||
if (Helpers.isOnline(PodSelectionActivity.this)) {
|
// Check if online
|
||||||
|
if (!Helpers.isOnline(PodSelectionActivity.this)) {
|
||||||
|
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show dialog
|
||||||
new AlertDialog.Builder(PodSelectionActivity.this)
|
new AlertDialog.Builder(PodSelectionActivity.this)
|
||||||
.setTitle(getString(R.string.confirmation))
|
.setTitle(getString(R.string.confirmation))
|
||||||
.setMessage(dialogMessage)
|
.setMessage(dialogMessage)
|
||||||
|
@ -166,24 +172,20 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
onPodSelectionConfirmed();
|
onPodSelectionConfirmed(selectedPod);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||||
@TargetApi(11)
|
@TargetApi(11)
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
podSelected = "";
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPodSelectionConfirmed(){
|
public void onPodSelectionConfirmed(String selectedPod) {
|
||||||
app.getSettings().setPodDomain(podSelected);
|
app.getSettings().setPodDomain(selectedPod);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
try {
|
try {
|
||||||
CookieManager.getInstance().removeAllCookies(null);
|
CookieManager.getInstance().removeAllCookies(null);
|
||||||
|
@ -200,20 +202,16 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(PodSelectionActivity.this, MainActivity.class);
|
Helpers.animateToActivity(this, MainActivity.class, true);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
||||||
startActivity(intent);
|
|
||||||
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
Snackbar.make(lv, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
Snackbar.make(listPods, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.yes, new View.OnClickListener() {
|
.setAction(android.R.string.yes, new View.OnClickListener() {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
moveTaskToBack(true);
|
finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
|
@ -240,15 +238,13 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
startService(i);
|
startService(i);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
This file is part of the Diaspora Native WebApp.
|
This file is part of the Diaspora for Android.
|
||||||
|
|
||||||
Diaspora Native WebApp is free software: you can redistribute it and/or modify
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Diaspora Native WebApp is distributed in the hope that it will be useful,
|
Diaspora for Android is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with the Diaspora Native WebApp.
|
along with the Diaspora for Android.
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,74 +1,67 @@
|
||||||
/*
|
/*
|
||||||
This file is part of the Diaspora Native WebApp.
|
This file is part of the Diaspora for Android.
|
||||||
|
|
||||||
Diaspora Native WebApp is free software: you can redistribute it and/or modify
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Diaspora Native WebApp is distributed in the hope that it will be useful,
|
Diaspora for Android is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with the Diaspora Native WebApp.
|
along with the Diaspora for Android.
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.github.dfa.diaspora_android.activity;
|
package com.github.dfa.diaspora_android.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
|
import com.github.dfa.diaspora_android.util.Helpers;
|
||||||
|
|
||||||
import java.util.Timer;
|
import butterknife.BindView;
|
||||||
import java.util.TimerTask;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
private App app;
|
private App app;
|
||||||
|
|
||||||
|
@BindView(R.id.splash__splashimage)
|
||||||
|
public ImageView imgSplash;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.splash_activity);
|
setContentView(R.layout.splash_activity);
|
||||||
|
ButterKnife.bind(this);
|
||||||
app = (App) getApplication();
|
app = (App) getApplication();
|
||||||
|
|
||||||
ImageView imgSplash = (ImageView) findViewById(R.id.splash__splashimage);
|
|
||||||
|
|
||||||
TypedArray images = getResources().obtainTypedArray(R.array.splash_images);
|
TypedArray images = getResources().obtainTypedArray(R.array.splash_images);
|
||||||
int choice = (int) (Math.random() * images.length());
|
int choice = (int) (Math.random() * images.length());
|
||||||
imgSplash.setImageResource(images.getResourceId(choice, R.drawable.splashscreen1));
|
imgSplash.setImageResource(images.getResourceId(choice, R.drawable.splashscreen1));
|
||||||
images.recycle();
|
images.recycle();
|
||||||
|
|
||||||
int delay = getResources().getInteger(R.integer.splash_delay);
|
int delay = getResources().getInteger(R.integer.splash_delay);
|
||||||
Handler handler = new Handler();
|
new Handler().postDelayed(startActivityRunnable, delay);
|
||||||
handler.postDelayed(new Runnable() {
|
}
|
||||||
@Override
|
|
||||||
|
final Runnable startActivityRunnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
boolean hasPodDomain = app.getSettings().hasPodDomain();
|
||||||
Intent intent;
|
Helpers.animateToActivity(SplashActivity.this,
|
||||||
if (!app.getSettings().getPodDomain().equals("")) {
|
hasPodDomain ? MainActivity.class : PodSelectionActivity.class,
|
||||||
intent = new Intent(SplashActivity.this, MainActivity.class);
|
true
|
||||||
} else {
|
);
|
||||||
intent = new Intent(SplashActivity.this, PodSelectionActivity.class);
|
|
||||||
}
|
}
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
};
|
||||||
startActivity(intent);
|
|
||||||
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,92 +4,106 @@ import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by gsantner on 20.03.16. Part of Diaspora WebApp.
|
* Created by gsantner on 20.03.16. Part of Diaspora for Android.
|
||||||
*/
|
*/
|
||||||
public class AppSettings {
|
public class AppSettings {
|
||||||
private final SharedPreferences pref;
|
private final SharedPreferences prefApp;
|
||||||
|
private final SharedPreferences prefPod;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public AppSettings(Context context) {
|
public AppSettings(Context context) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
pref = this.context.getSharedPreferences("app", Context.MODE_PRIVATE);
|
prefApp = this.context.getSharedPreferences("app", Context.MODE_PRIVATE);
|
||||||
|
prefPod = this.context.getSharedPreferences("pod0", Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setString(String key, String value) {
|
public void clearPodSettings() {
|
||||||
|
prefPod.edit().clear().apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAppSettings() {
|
||||||
|
prefApp.edit().clear().apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setString(SharedPreferences pref, String key, String value) {
|
||||||
pref.edit().putString(key, value).apply();
|
pref.edit().putString(key, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInt(String key, int value) {
|
private void setInt(SharedPreferences pref, String key, int value) {
|
||||||
pref.edit().putInt(key, value).apply();
|
pref.edit().putInt(key, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBool(String key, boolean value) {
|
private void setBool(SharedPreferences pref, String key, boolean value) {
|
||||||
pref.edit().putBoolean(key, value).apply();
|
pref.edit().putBoolean(key, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Preferences
|
// Preferences
|
||||||
*/
|
*/
|
||||||
private static final String PREF_WEBUSERPROFILE_ID = "webUserProfile_guid";
|
public static class PREF {
|
||||||
private static final String PREF_IS_LOAD_IMAGES = "loadImages";
|
private static final String IS_LOAD_IMAGES = "loadImages";
|
||||||
private static final String PREF_MINIMUM_FONT_SIZE = "minimumFontSize";
|
private static final String MINIMUM_FONT_SIZE = "minimumFontSize";
|
||||||
private static final String PREF_AVATAR_URL = "webUserProfile_avatar";
|
private static final String PODUSERPROFILE_AVATAR_URL = "podUserProfile_avatar";
|
||||||
private static final String PREF_WEBUSERPROFILE_NAME = "webUserProfile_name";
|
private static final String PODUSERPROFILE_NAME = "podUserProfile_name";
|
||||||
private static final String PREF_PODDOMAIN = "podDomain";
|
private static final String PODUSERPROFILE_ID = "podUserProfile_guid";
|
||||||
|
private static final String PODDOMAIN = "podDomain";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Setters & Getters
|
// Setters & Getters
|
||||||
*/
|
*/
|
||||||
public String getProfileId() {
|
public String getProfileId() {
|
||||||
return pref.getString(PREF_WEBUSERPROFILE_ID, "");
|
return prefPod.getString(PREF.PODUSERPROFILE_ID, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfileId(String profileId) {
|
public void setProfileId(String profileId) {
|
||||||
setString(PREF_WEBUSERPROFILE_ID, profileId);
|
setString(prefPod, PREF.PODUSERPROFILE_ID,profileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isLoadImages() {
|
public boolean isLoadImages() {
|
||||||
return pref.getBoolean(PREF_IS_LOAD_IMAGES, true);
|
return prefApp.getBoolean(PREF.IS_LOAD_IMAGES, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadImages(boolean loadImages) {
|
public void setLoadImages(boolean loadImages) {
|
||||||
setBool(PREF_IS_LOAD_IMAGES, loadImages);
|
setBool(prefApp, PREF.IS_LOAD_IMAGES, loadImages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getMinimumFontSize() {
|
public int getMinimumFontSize() {
|
||||||
return pref.getInt(PREF_MINIMUM_FONT_SIZE, 8);
|
return prefApp.getInt(PREF.MINIMUM_FONT_SIZE, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinimumFontSize(int minimumFontSize) {
|
public void setMinimumFontSize(int minimumFontSize) {
|
||||||
setInt(PREF_MINIMUM_FONT_SIZE, minimumFontSize);
|
setInt(prefApp, PREF.MINIMUM_FONT_SIZE, minimumFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAvatarUrl() {
|
public String getAvatarUrl() {
|
||||||
return pref.getString(PREF_AVATAR_URL, "");
|
return prefPod.getString(PREF.PODUSERPROFILE_AVATAR_URL, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAvatarUrl(String avatarUrl) {
|
public void setAvatarUrl(String avatarUrl) {
|
||||||
setString(PREF_AVATAR_URL, avatarUrl);
|
setString(prefPod, PREF.PODUSERPROFILE_AVATAR_URL, avatarUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return pref.getString(PREF_WEBUSERPROFILE_NAME, "");
|
return prefPod.getString(PREF.PODUSERPROFILE_NAME, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
setString(PREF_WEBUSERPROFILE_NAME, name);
|
setString(prefPod, PREF.PODUSERPROFILE_NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPodDomain() {
|
public String getPodDomain() {
|
||||||
return pref.getString(PREF_PODDOMAIN, "");
|
return prefPod.getString(PREF.PODDOMAIN, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPodDomain(String podDomain) {
|
public void setPodDomain(String podDomain) {
|
||||||
setString(PREF_PODDOMAIN, podDomain);
|
setString(prefPod, PREF.PODDOMAIN, podDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasPodDomain(){
|
||||||
|
return !prefPod.getString(PREF.PODDOMAIN, "").equals("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by gsantner on 24.03.16. Part of Diaspora WebApp.
|
* Created by gsantner on 24.03.16. Part of Diaspora for Android.
|
||||||
*/
|
*/
|
||||||
public class WebUserProfile {
|
public class PodUserProfile {
|
||||||
private static final int MINIMUM_WEBUSERPROFILE_LOAD_TIMEDIFF = 5000;
|
private static final int MINIMUM_WEBUSERPROFILE_LOAD_TIMEDIFF = 5000;
|
||||||
|
|
||||||
private Handler callbackHandler;
|
private Handler callbackHandler;
|
||||||
|
@ -30,7 +30,7 @@ public class WebUserProfile {
|
||||||
private int unreadMessagesCount;
|
private int unreadMessagesCount;
|
||||||
|
|
||||||
|
|
||||||
public WebUserProfile(App app) {
|
public PodUserProfile(App app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
appSettings = app.getSettings();
|
appSettings = app.getSettings();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class WebUserProfile {
|
||||||
name = appSettings.getName();
|
name = appSettings.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebUserProfile(App app, Handler callbackHandler, WebUserProfileChangedListener listener) {
|
public PodUserProfile(App app, Handler callbackHandler, WebUserProfileChangedListener listener) {
|
||||||
this(app);
|
this(app);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.callbackHandler = callbackHandler;
|
this.callbackHandler = callbackHandler;
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.dfa.diaspora_android.listener;
|
package com.github.dfa.diaspora_android.listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by juergen on 25.03.16. Part of Diaspora WebApp.
|
* Created by juergen on 25.03.16. Part of Diaspora for Android.
|
||||||
* solution found on: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
|
* solution found on: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
This file is part of the Diaspora Native WebApp.
|
This file is part of the Diaspora for Android.
|
||||||
|
|
||||||
Diaspora Native WebApp is free software: you can redistribute it and/or modify
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Diaspora Native WebApp is distributed in the hope that it will be useful,
|
Diaspora for Android is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with the Diaspora Native WebApp.
|
along with the Diaspora for Android.
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class ImageDownloadTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import android.util.Log;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
import com.github.dfa.diaspora_android.data.WebUserProfile;
|
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -63,7 +63,7 @@ public class ProfileFetchTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
|
||||||
if (extractedProfileData != null) {
|
if (extractedProfileData != null) {
|
||||||
WebUserProfile profile = new WebUserProfile(app);
|
PodUserProfile profile = new PodUserProfile(app);
|
||||||
profile.parseJson(extractedProfileData);
|
profile.parseJson(extractedProfileData);
|
||||||
Log.d(App.TAG, "Extracted new_messages (service):" + profile.getUnreadMessagesCount());
|
Log.d(App.TAG, "Extracted new_messages (service):" + profile.getUnreadMessagesCount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.github.dfa.diaspora_android.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
import com.github.dfa.diaspora_android.App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Gregor Santner (gsantner) on 04.06.16.
|
||||||
|
*/
|
||||||
|
public class CustomWebViewClient extends WebViewClient {
|
||||||
|
private App app;
|
||||||
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
private WebView webView;
|
||||||
|
|
||||||
|
public CustomWebViewClient(App app, SwipeRefreshLayout swipeRefreshLayout, WebView webView) {
|
||||||
|
this.app = app;
|
||||||
|
this.swipeRefreshLayout = swipeRefreshLayout;
|
||||||
|
this.webView = webView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
if (!url.contains(app.getSettings().getPodDomain())) {
|
||||||
|
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
app.getApplicationContext().startActivity(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
super.onPageFinished(view, url);
|
||||||
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
|
final CookieManager cookieManager = app.getCookieManager();
|
||||||
|
String cookies = cookieManager.getCookie(url);
|
||||||
|
//Log.d(App.TAG, "All the cookies in a string:" + cookies);
|
||||||
|
|
||||||
|
if (cookies != null) {
|
||||||
|
cookieManager.setCookie(url, cookies);
|
||||||
|
cookieManager.setCookie("https://" + app.getSettings().getPodDomain(), cookies);
|
||||||
|
for (String c : cookies.split(";")) {
|
||||||
|
//Log.d(App.TAG, "Cookie: " + c.split("=")[0] + " Value:" + c.split("=")[1]);
|
||||||
|
}
|
||||||
|
//new ProfileFetchTask(app).execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.dfa.diaspora_android.ui;
|
package com.github.dfa.diaspora_android.ui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by juergen on 29.02.16. Part of Diaspora WebApp.
|
* Created by juergen on 29.02.16. Part of Diaspora for Android.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
|
@ -16,13 +16,14 @@ public class AvatarImageLoader {
|
||||||
private File avatarFile;
|
private File avatarFile;
|
||||||
|
|
||||||
public AvatarImageLoader(Context context) {
|
public AvatarImageLoader(Context context) {
|
||||||
avatarFile = new File(context.getFilesDir(), "avatar.png");
|
avatarFile = new File(context.getFilesDir(), "avatar0.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearAvatarImage() {
|
public boolean clearAvatarImage() {
|
||||||
if (isAvatarDownloaded()) {
|
if (isAvatarDownloaded()) {
|
||||||
avatarFile.delete();
|
return avatarFile.delete();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadToImageView(ImageView imageView) {
|
public boolean loadToImageView(ImageView imageView) {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
This file is part of the Diaspora Native WebApp.
|
This file is part of the Diaspora for Android.
|
||||||
|
|
||||||
Diaspora Native WebApp is free software: you can redistribute it and/or modify
|
Diaspora for Android is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Diaspora Native WebApp is distributed in the hope that it will be useful,
|
Diaspora for Android is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with the Diaspora Native WebApp.
|
along with the Diaspora for Android.
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@ -20,12 +20,17 @@
|
||||||
package com.github.dfa.diaspora_android.util;
|
package com.github.dfa.diaspora_android.util;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
import com.github.dfa.diaspora_android.R;
|
||||||
|
import com.github.dfa.diaspora_android.activity.MainActivity;
|
||||||
|
|
||||||
public class Helpers {
|
public class Helpers {
|
||||||
|
|
||||||
public static boolean isOnline(Context context) {
|
public static boolean isOnline(Context context) {
|
||||||
|
@ -34,6 +39,16 @@ public class Helpers {
|
||||||
return ni != null && ni.isConnectedOrConnecting();
|
return ni != null && ni.isConnectedOrConnecting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void animateToActivity(Activity from, Class to, boolean finishFromActivity) {
|
||||||
|
Intent intent = new Intent(from, to);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
from.startActivity(intent);
|
||||||
|
from.overridePendingTransition(R.anim.fadein, R.anim.fadeout);
|
||||||
|
if (finishFromActivity) {
|
||||||
|
from.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void hideTopBar(final WebView wv) {
|
public static void hideTopBar(final WebView wv) {
|
||||||
wv.loadUrl("javascript: ( function() {" +
|
wv.loadUrl("javascript: ( function() {" +
|
||||||
" if(document.getElementById('main_nav')) {" +
|
" if(document.getElementById('main_nav')) {" +
|
||||||
|
|
|
@ -1,5 +1,27 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
tools:context=".activity.PodSelectionActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
android:id="@+id/podsLayout"
|
android:id="@+id/podsLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -7,7 +29,8 @@
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
tools:context=".activity.PodSelectionActivity">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:showIn="@layout/podselection_activity">
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/podselection__listpods"
|
android:id="@+id/podselection__listpods"
|
||||||
|
@ -22,8 +45,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_toEndOf="@+id/textView"
|
||||||
android:layout_toLeftOf="@+id/podselection__button_select_pod"
|
android:layout_toLeftOf="@+id/podselection__button_select_pod"
|
||||||
android:layout_toStartOf="@+id/podselection__button_select_pod"
|
android:layout_toRightOf="@+id/textView"
|
||||||
android:hint="@string/filter_hint"
|
android:hint="@string/filter_hint"
|
||||||
android:inputType="textUri|textWebEditText" />
|
android:inputType="textUri|textWebEditText" />
|
||||||
|
|
||||||
|
@ -46,11 +70,25 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
|
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
|
android:autoLink="web"
|
||||||
android:text="@string/podlist_source_note"
|
android:text="@string/podlist_source_note"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
android:autoLink="web" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/podselection__listpods"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:layout_marginRight="0dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/prefix_https"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
|
@ -210,4 +210,5 @@
|
||||||
<string name="context_menu_open_external_browser">Open in external browser …</string>
|
<string name="context_menu_open_external_browser">Open in external browser …</string>
|
||||||
<string name="context_menu_copy_link">Copy link address to clipboard</string>
|
<string name="context_menu_copy_link">Copy link address to clipboard</string>
|
||||||
<string name="toast_saved_image_to_location">Saving image to</string>
|
<string name="toast_saved_image_to_location">Saving image to</string>
|
||||||
|
<string name="prefix_https" translatable="false">https://</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue