mirror of
https://github.com/gsantner/dandelion
synced 2025-12-15 08:41:10 +01:00
Code auto reformatting; Update TR, PodList
This commit is contained in:
parent
110598ea85
commit
71d8b886f6
70 changed files with 450 additions and 364 deletions
|
|
@ -28,8 +28,6 @@ import android.webkit.CookieSyncManager;
|
|||
import android.webkit.WebView;
|
||||
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
|
||||
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.AvatarImageLoader;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ import butterknife.ButterKnife;
|
|||
* Activity that holds some fragments that show information about the app in a tab layout
|
||||
*/
|
||||
public class AboutActivity extends ThemedActivity
|
||||
implements IntellihideToolbarActivityListener {
|
||||
implements IntellihideToolbarActivityListener {
|
||||
|
||||
private SectionsPagerAdapter mSectionsPagerAdapter;
|
||||
private ViewPager mViewPager;
|
||||
|
|
@ -108,7 +108,7 @@ implements IntellihideToolbarActivityListener {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(getAppSettings().isIntellihideToolbars()) {
|
||||
if (getAppSettings().isIntellihideToolbars()) {
|
||||
this.enableToolbarHiding();
|
||||
} else {
|
||||
this.disableToolbarHiding();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.ActionMenuView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.KeyEvent;
|
||||
|
|
@ -69,19 +68,18 @@ import com.github.dfa.diaspora_android.fragment.HashtagListFragment;
|
|||
import com.github.dfa.diaspora_android.fragment.PodSelectionFragment;
|
||||
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
|
||||
import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
|
||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||
import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver;
|
||||
import com.github.dfa.diaspora_android.ui.BadgeDrawable;
|
||||
import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.CustomTabHelpers.CustomTabActivityHelper;
|
||||
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
|
||||
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||
import com.github.dfa.diaspora_android.util.WebHelper;
|
||||
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class MainActivity extends ThemedActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener,
|
||||
|
|
@ -183,7 +181,7 @@ public class MainActivity extends ThemedActivity
|
|||
@Override
|
||||
public void setTitle(int rId) {
|
||||
CustomFragment top = getTopFragment();
|
||||
if(top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
||||
if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
||||
MainActivity.this.setTitle(rId);
|
||||
}
|
||||
}
|
||||
|
|
@ -191,7 +189,7 @@ public class MainActivity extends ThemedActivity
|
|||
@Override
|
||||
public void setTitle(String title) {
|
||||
CustomFragment top = getTopFragment();
|
||||
if(top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
||||
if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
|
||||
MainActivity.this.setTitle(title);
|
||||
}
|
||||
}
|
||||
|
|
@ -199,6 +197,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
if (!appSettings.hasPod()) {
|
||||
AppLog.d(this, "We have no pod. Show PodSelectionFragment");
|
||||
updateNavigationViewEntryVisibilities();
|
||||
showFragment(getFragment(PodSelectionFragment.TAG));
|
||||
} else {
|
||||
AppLog.d(this, "Pod found. Handle intents.");
|
||||
|
|
@ -248,6 +247,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Show DiasporaStreamFragment if necessary and load URL url
|
||||
*
|
||||
* @param url URL to load in the DiasporaStreamFragment
|
||||
*/
|
||||
public void openDiasporaUrl(String url) {
|
||||
|
|
@ -261,12 +261,13 @@ public class MainActivity extends ThemedActivity
|
|||
* Get an instance of the CustomFragment with the tag fragmentTag.
|
||||
* If there was no instance so far, create a new one and add it to the FragmentManagers pool.
|
||||
* If there is no Fragment with the corresponding Tag, return the top fragment.
|
||||
*
|
||||
* @param fragmentTag tag
|
||||
* @return corresponding Fragment
|
||||
*/
|
||||
protected CustomFragment getFragment(String fragmentTag) {
|
||||
CustomFragment fragment = (CustomFragment) fm.findFragmentByTag(fragmentTag);
|
||||
if(fragment != null) {
|
||||
if (fragment != null) {
|
||||
return fragment;
|
||||
} else {
|
||||
switch (fragmentTag) {
|
||||
|
|
@ -287,8 +288,8 @@ public class MainActivity extends ThemedActivity
|
|||
fm.beginTransaction().add(psf, fragmentTag).commit();
|
||||
return psf;
|
||||
default:
|
||||
AppLog.e(this,"Invalid Fragment Tag: "+fragmentTag
|
||||
+"\nAdd Fragments Tag to getFragment()'s switch case.");
|
||||
AppLog.e(this, "Invalid Fragment Tag: " + fragmentTag
|
||||
+ "\nAdd Fragments Tag to getFragment()'s switch case.");
|
||||
return getTopFragment();
|
||||
}
|
||||
}
|
||||
|
|
@ -296,12 +297,13 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Show the Fragment fragment in R.id.fragment_container. If the fragment was already visible, do nothing.
|
||||
*
|
||||
* @param fragment Fragment to show
|
||||
*/
|
||||
protected void showFragment(CustomFragment fragment) {
|
||||
AppLog.v(this, "showFragment()");
|
||||
CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container);
|
||||
if(currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
|
||||
if (currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
|
||||
AppLog.v(this, "Fragment was not visible. Replace it.");
|
||||
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
||||
invalidateOptionsMenu();
|
||||
|
|
@ -380,13 +382,14 @@ public class MainActivity extends ThemedActivity
|
|||
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities());
|
||||
|
||||
// Top bar
|
||||
if (appSettings.getPod() == null) {
|
||||
if (!appSettings.hasPod()) {
|
||||
navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forward incoming intents to handleIntent()
|
||||
*
|
||||
* @param intent incoming
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -397,6 +400,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Handle intents and execute intent specific actions
|
||||
*
|
||||
* @param intent intent to get handled
|
||||
*/
|
||||
private void handleIntent(Intent intent) {
|
||||
|
|
@ -421,7 +425,7 @@ public class MainActivity extends ThemedActivity
|
|||
return;
|
||||
} else {
|
||||
loadUrl = intent.getDataString();
|
||||
AppLog.v(this, "Intent has a delicious URL for us: "+loadUrl);
|
||||
AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl);
|
||||
}
|
||||
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
|
||||
AppLog.v(this, "Reset pod data and show PodSelectionFragment");
|
||||
|
|
@ -457,23 +461,25 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Handle activity results
|
||||
*
|
||||
* @param requestCode reqCode
|
||||
* @param resultCode resCode
|
||||
* @param data data
|
||||
* @param resultCode resCode
|
||||
* @param data data
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
AppLog.v(this, "onActivityResult(): "+requestCode);
|
||||
AppLog.v(this, "onActivityResult(): " + requestCode);
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fragment which is currently displayed in R.id.fragment_container
|
||||
*
|
||||
* @return top fragment or null if there is none displayed
|
||||
*/
|
||||
private CustomFragment getTopFragment() {
|
||||
Fragment top = fm.findFragmentById(R.id.fragment_container);
|
||||
if(top != null) {
|
||||
if (top != null) {
|
||||
return (CustomFragment) top;
|
||||
}
|
||||
return null;
|
||||
|
|
@ -490,12 +496,12 @@ public class MainActivity extends ThemedActivity
|
|||
return;
|
||||
}
|
||||
CustomFragment top = getTopFragment();
|
||||
if(top != null) {
|
||||
if (top != null) {
|
||||
AppLog.v(this, "Top Fragment is not null");
|
||||
if(!top.onBackPressed()) {
|
||||
if (!top.onBackPressed()) {
|
||||
AppLog.v(this, "Top Fragment.onBackPressed was false");
|
||||
AppLog.v(this, "BackStackEntryCount: "+fm.getBackStackEntryCount());
|
||||
if(fm.getBackStackEntryCount()>0) {
|
||||
AppLog.v(this, "BackStackEntryCount: " + fm.getBackStackEntryCount());
|
||||
if (fm.getBackStackEntryCount() > 0) {
|
||||
fm.popBackStack();
|
||||
} else {
|
||||
snackbarExitApp.show();
|
||||
|
|
@ -552,6 +558,7 @@ public class MainActivity extends ThemedActivity
|
|||
/**
|
||||
* Clear and repopulate top and bottom toolbar.
|
||||
* Also add menu items of the displayed fragment
|
||||
*
|
||||
* @param menu top toolbar
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -564,9 +571,9 @@ public class MainActivity extends ThemedActivity
|
|||
toolbarBottom.setVisibility(View.VISIBLE);
|
||||
|
||||
CustomFragment top = getTopFragment();
|
||||
if(top != null) {
|
||||
if (top != null) {
|
||||
//Are we displaying a Fragment other than PodSelectionFragment?
|
||||
if(!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
||||
if (!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
||||
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
||||
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
|
||||
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
|
||||
|
|
@ -582,6 +589,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Set the notification and messages counter in the top toolbar
|
||||
*
|
||||
* @param menu menu
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -604,6 +612,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Handle clicks on the optionsmenu
|
||||
*
|
||||
* @param item item
|
||||
* @return boolean
|
||||
*/
|
||||
|
|
@ -702,6 +711,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Update the profile name in the navigation slider
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -712,6 +722,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Update the profile picture in the navigation slider
|
||||
*
|
||||
* @param avatarUrl url of the new profile pic
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -722,6 +733,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Handle hashtag clicks. Open the new-post-url and inject the clicked hashtag into the post-editor
|
||||
*
|
||||
* @param intent intent
|
||||
*/
|
||||
private void handleHashtag(Intent intent) {
|
||||
|
|
@ -736,6 +748,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Open the new-post-url and inject text that was shared into the app into the post editors text field
|
||||
*
|
||||
* @param intent shareTextIntent
|
||||
*/
|
||||
private void handleSendText(Intent intent) {
|
||||
|
|
@ -794,6 +807,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Share an image shared to the app via diaspora
|
||||
*
|
||||
* @param intent shareImageIntent
|
||||
*/
|
||||
//TODO: Implement some day
|
||||
|
|
@ -810,6 +824,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Invalidate the top toolbar to update the notification counter
|
||||
*
|
||||
* @param notificationCount new notification count
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -821,6 +836,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Invalidate the top toolbar to update the unread messages counter
|
||||
*
|
||||
* @param unreadMessageCount new unread messages count
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -832,8 +848,8 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
@Override
|
||||
public void onCustomTabsConnected() {
|
||||
if(customTabsSession == null) {
|
||||
AppLog.i(this, "CustomTabs warmup: "+customTabActivityHelper.warmup(0));
|
||||
if (customTabsSession == null) {
|
||||
AppLog.i(this, "CustomTabs warmup: " + customTabActivityHelper.warmup(0));
|
||||
customTabsSession = customTabActivityHelper.getSession();
|
||||
}
|
||||
}
|
||||
|
|
@ -953,8 +969,9 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* React to results of requestPermission
|
||||
* @param requestCode resCode
|
||||
* @param permissions requested permissions
|
||||
*
|
||||
* @param requestCode resCode
|
||||
* @param permissions requested permissions
|
||||
* @param grantResults granted results
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -978,6 +995,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Return the string that will be shared into the new-post-editor
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getTextToBeShared() {
|
||||
|
|
@ -986,6 +1004,7 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
/**
|
||||
* Set the string that will be shared into the new-post-editor
|
||||
*
|
||||
* @param textToBeShared
|
||||
*/
|
||||
public void setTextToBeShared(String textToBeShared) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
|||
public abstract class ThemedActivity extends AppCompatActivity {
|
||||
|
||||
protected AppSettings getAppSettings() {
|
||||
return ((App)getApplication()).getSettings();
|
||||
return ((App) getApplication()).getSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -48,6 +48,7 @@ public abstract class ThemedActivity extends AppCompatActivity {
|
|||
updateRecentAppColor();
|
||||
applyColorToViews();
|
||||
}
|
||||
|
||||
protected abstract void applyColorToViews();
|
||||
|
||||
/**
|
||||
|
|
@ -64,10 +65,10 @@ public abstract class ThemedActivity extends AppCompatActivity {
|
|||
* Update primary color in recent apps overview
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void updateRecentAppColor(){
|
||||
private void updateRecentAppColor() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
BitmapDrawable drawable = ((BitmapDrawable) getDrawable(R.drawable.ic_launcher));
|
||||
if(drawable != null) {
|
||||
if (drawable != null) {
|
||||
setTaskDescription(new ActivityManager.TaskDescription(
|
||||
getResources().getString(R.string.app_name),
|
||||
drawable.getBitmap(),
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl;
|
||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
|
@ -264,6 +264,7 @@ public class AppSettings {
|
|||
public void setProxyHttpHost(String value) {
|
||||
setString(prefApp, R.string.pref_key__http_proxy_host, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default value: 0
|
||||
*
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ package com.github.dfa.diaspora_android.data;
|
|||
|
||||
import android.os.Handler;
|
||||
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.Log;
|
||||
|
||||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
|
@ -128,7 +126,7 @@ public class PodUserProfile {
|
|||
|
||||
isWebUserProfileLoaded = true;
|
||||
} catch (JSONException e) {
|
||||
AppLog.d(this, e.getMessage());
|
||||
AppLog.d(this, e.getMessage());
|
||||
isWebUserProfileLoaded = false;
|
||||
}
|
||||
lastLoaded = System.currentTimeMillis();
|
||||
|
|
@ -173,6 +171,7 @@ public class PodUserProfile {
|
|||
|
||||
/**
|
||||
* Sets the avatar, returns true if this was a new one, false if already the old one
|
||||
*
|
||||
* @param avatarUrl url
|
||||
* @return true if new avatar url
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ import com.github.dfa.diaspora_android.App;
|
|||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.activity.MainActivity;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||
import com.github.dfa.diaspora_android.ui.ContextMenuWebView;
|
||||
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.ProxyHandler;
|
||||
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
||||
import com.github.dfa.diaspora_android.webview.CustomWebViewClient;
|
||||
import com.github.dfa.diaspora_android.webview.ProgressBarWebChromeClient;
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ public class BrowserFragment extends ThemedFragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
AppLog.d(this, "onCreateView()");
|
||||
if(rootLayout == null) {
|
||||
if (rootLayout == null) {
|
||||
rootLayout = inflater.inflate(R.layout.browser__fragment, container, false);
|
||||
}
|
||||
return rootLayout;
|
||||
|
|
@ -89,21 +89,21 @@ public class BrowserFragment extends ThemedFragment {
|
|||
AppLog.d(this, "onViewCreated()");
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
if(this.appSettings == null) {
|
||||
if (this.appSettings == null) {
|
||||
this.appSettings = ((App) getActivity().getApplication()).getSettings();
|
||||
}
|
||||
|
||||
if(this.webView == null) {
|
||||
if (this.webView == null) {
|
||||
this.webView = (ContextMenuWebView) view.findViewById(R.id.webView);
|
||||
this.applyWebViewSettings();
|
||||
ProxyHandler.getInstance().addWebView(webView);
|
||||
}
|
||||
|
||||
if(this.progressBar == null) {
|
||||
if (this.progressBar == null) {
|
||||
this.progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||
}
|
||||
|
||||
if(pendingUrl != null) {
|
||||
if (pendingUrl != null) {
|
||||
loadUrl(pendingUrl);
|
||||
pendingUrl = null;
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ public class BrowserFragment extends ThemedFragment {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if(webView != null) {
|
||||
if (webView != null) {
|
||||
webSettings.setMinimumFontSize(appSettings.getMinimumFontSize());
|
||||
webSettings.setLoadsImagesAutomatically(appSettings.isLoadImages());
|
||||
}
|
||||
|
|
@ -188,8 +188,8 @@ public class BrowserFragment extends ThemedFragment {
|
|||
|
||||
String fileSaveName = hasToShareScreenshot ? ".DfA_share.jpg" : String.format("DfA_%s.jpg", dateFormat.format(dateNow));
|
||||
if (!fileSaveDirectory.exists()) {
|
||||
if(!fileSaveDirectory.mkdirs()) {
|
||||
AppLog.w(this, "Could not mkdir "+fileSaveDirectory.getAbsolutePath());
|
||||
if (!fileSaveDirectory.mkdirs()) {
|
||||
AppLog.w(this, "Could not mkdir " + fileSaveDirectory.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ public class BrowserFragment extends ThemedFragment {
|
|||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if(webView.canGoBack()) {
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -256,17 +256,17 @@ public class BrowserFragment extends ThemedFragment {
|
|||
}
|
||||
|
||||
public void loadUrl(String url) {
|
||||
if(getWebView() != null) {
|
||||
AppLog.v(this, "loadUrl(): load "+url);
|
||||
if (getWebView() != null) {
|
||||
AppLog.v(this, "loadUrl(): load " + url);
|
||||
getWebView().loadUrlNew(url);
|
||||
} else {
|
||||
AppLog.v(this, "loadUrl(): WebView null: Set pending url to "+url);
|
||||
AppLog.v(this, "loadUrl(): WebView null: Set pending url to " + url);
|
||||
pendingUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
if(getWebView() != null) {
|
||||
if (getWebView() != null) {
|
||||
return getWebView().getUrl();
|
||||
} else {
|
||||
return pendingUrl;
|
||||
|
|
@ -275,7 +275,7 @@ public class BrowserFragment extends ThemedFragment {
|
|||
|
||||
public void reloadUrl() {
|
||||
AppLog.v(this, "reloadUrl()");
|
||||
if(getWebView() != null) {
|
||||
if (getWebView() != null) {
|
||||
getWebView().reload();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public abstract class CustomFragment extends Fragment {
|
|||
|
||||
/**
|
||||
* We have an optionsMenu
|
||||
*
|
||||
* @param savedInstanceState state
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -44,13 +45,15 @@ public abstract class CustomFragment extends Fragment {
|
|||
|
||||
/**
|
||||
* Return the tag used to identify the Fragment.
|
||||
*
|
||||
* @return tag
|
||||
*/
|
||||
public abstract String getFragmentTag();
|
||||
|
||||
/**
|
||||
* Add fragment-dependent options to the bottom options toolbar
|
||||
* @param menu bottom menu
|
||||
*
|
||||
* @param menu bottom menu
|
||||
* @param inflater inflater
|
||||
*/
|
||||
public abstract void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater);
|
||||
|
|
@ -58,6 +61,7 @@ public abstract class CustomFragment extends Fragment {
|
|||
/**
|
||||
* Return true if the fragment reacted to a back button press, false else.
|
||||
* In case the fragment returned false, the parent activity should handle the backPress.
|
||||
*
|
||||
* @return did we react to the back press?
|
||||
*/
|
||||
public abstract boolean onBackPressed();
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ import com.github.dfa.diaspora_android.App;
|
|||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.activity.MainActivity;
|
||||
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||
import com.github.dfa.diaspora_android.webview.DiasporaStreamWebChromeClient;
|
||||
import com.github.dfa.diaspora_android.webview.FileUploadWebChromeClient;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
|
||||
import com.github.dfa.diaspora_android.util.Helpers;
|
||||
import com.github.dfa.diaspora_android.util.WebHelper;
|
||||
import com.github.dfa.diaspora_android.webview.DiasporaStreamWebChromeClient;
|
||||
import com.github.dfa.diaspora_android.webview.FileUploadWebChromeClient;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
|
|
@ -79,9 +79,9 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.addJavascriptInterface(new JavaScriptInterface(), "AndroidBridge");
|
||||
if(((MainActivity)getActivity()).getTextToBeShared() != null) {
|
||||
if (((MainActivity) getActivity()).getTextToBeShared() != null) {
|
||||
loadUrl(urls.getNewPostUrl());
|
||||
} else if(webView.getUrl() == null) {
|
||||
} else if (webView.getUrl() == null) {
|
||||
loadUrl(urls.getStreamUrl());
|
||||
}
|
||||
}
|
||||
|
|
@ -98,11 +98,11 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
AppLog.d(this, "onActivityResult(): "+requestCode);
|
||||
AppLog.d(this, "onActivityResult(): " + requestCode);
|
||||
switch (requestCode) {
|
||||
case MainActivity.INPUT_FILE_REQUEST_CODE_NEW:
|
||||
case MainActivity.INPUT_FILE_REQUEST_CODE_OLD:
|
||||
AppLog.v(this, "INPUT_FILE_REQUEST_CODE: "+requestCode);
|
||||
AppLog.v(this, "INPUT_FILE_REQUEST_CODE: " + requestCode);
|
||||
onImageUploadResult(requestCode, resultCode, data);
|
||||
return;
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
AppLog.d(this, "StreamFragment.onOptionsItemSelected()");
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_reload: {
|
||||
if(WebHelper.isOnline(getContext())) {
|
||||
if (WebHelper.isOnline(getContext())) {
|
||||
reloadUrl();
|
||||
return true;
|
||||
} else {
|
||||
|
|
@ -226,18 +226,19 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
protected DiasporaStreamWebChromeClient.SharedTextCallback sharedTextCallback = new DiasporaStreamWebChromeClient.SharedTextCallback() {
|
||||
@Override
|
||||
public String getSharedText() {
|
||||
return ((MainActivity)getActivity()).getTextToBeShared();
|
||||
return ((MainActivity) getActivity()).getTextToBeShared();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSharedText(String shared) {
|
||||
((MainActivity)getActivity()).setTextToBeShared(shared);
|
||||
((MainActivity) getActivity()).setTextToBeShared(shared);
|
||||
}
|
||||
};
|
||||
|
||||
protected FileUploadWebChromeClient.FileUploadCallback fileUploadCallback = new FileUploadWebChromeClient.FileUploadCallback() {
|
||||
@Override
|
||||
public boolean imageUpload(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
|
||||
if(Build.VERSION.SDK_INT >= 23) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
int hasWRITE_EXTERNAL_STORAGE = getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (hasWRITE_EXTERNAL_STORAGE != PackageManager.PERMISSION_GRANTED) {
|
||||
if (!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
|
|
@ -261,7 +262,8 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
}
|
||||
}
|
||||
AppLog.v(this, "onOpenFileChooser");
|
||||
if (imageUploadFilePathCallbackNew != null) imageUploadFilePathCallbackNew.onReceiveValue(null);
|
||||
if (imageUploadFilePathCallbackNew != null)
|
||||
imageUploadFilePathCallbackNew.onReceiveValue(null);
|
||||
imageUploadFilePathCallbackNew = filePathCallback;
|
||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) {
|
||||
|
|
@ -271,7 +273,7 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
photoFile = Helpers.createImageFile();
|
||||
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
|
||||
} catch (IOException ex) {
|
||||
AppLog.e(this, "ERROR creating temp file: "+ ex.toString());
|
||||
AppLog.e(this, "ERROR creating temp file: " + ex.toString());
|
||||
// Error occurred while creating the File
|
||||
Snackbar.make(webView, R.string.unable_to_load_image, Snackbar.LENGTH_LONG).show();
|
||||
return false;
|
||||
|
|
@ -321,7 +323,7 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
@SuppressWarnings("unused")
|
||||
@JavascriptInterface
|
||||
public void setUserProfile(final String webMessage) throws JSONException {
|
||||
PodUserProfile pup = ((App)getActivity().getApplication()).getPodUserProfile();
|
||||
PodUserProfile pup = ((App) getActivity().getApplication()).getPodUserProfile();
|
||||
AppLog.v(this, "StreamFragment.JavaScriptInterface.setUserProfile()");
|
||||
if (pup.isRefreshNeeded()) {
|
||||
AppLog.v(this, "PodUserProfile needs refresh; Try to parse JSON");
|
||||
|
|
@ -334,7 +336,7 @@ public class DiasporaStreamFragment extends BrowserFragment {
|
|||
@SuppressWarnings("unused")
|
||||
@JavascriptInterface
|
||||
public void contentHasBeenShared() {
|
||||
((MainActivity)getActivity()).setTextToBeShared(null);
|
||||
((MainActivity) getActivity()).setTextToBeShared(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ public class HashtagListFragment extends CustomFragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
int itemPosition = followedTagsRecyclerView.getChildLayoutPosition(view);
|
||||
if(itemPosition > -1 && itemPosition < followedTags.length) {
|
||||
if (itemPosition > -1 && itemPosition < followedTags.length) {
|
||||
String tag = followedTags[itemPosition];
|
||||
((MainActivity)getActivity()).openDiasporaUrl(urls.getSearchTagsUrl(tag));
|
||||
((MainActivity) getActivity()).openDiasporaUrl(urls.getSearchTagsUrl(tag));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O
|
|||
|
||||
MainActivity mainActivity = (MainActivity) getActivity();
|
||||
DiasporaUrlHelper urlHelper = new DiasporaUrlHelper(appSettings);
|
||||
mainActivity.openDiasporaUrl(urlHelper.getSignInUrl());
|
||||
mainActivity.invalidateOptionsMenu();
|
||||
mainActivity.openDiasporaUrl(urlHelper.getSignInUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
|
|||
|
||||
public abstract class ThemedFragment extends CustomFragment {
|
||||
protected AppSettings getAppSettings() {
|
||||
return ((App)getActivity().getApplication()).getSettings();
|
||||
return ((App) getActivity().getApplication()).getSettings();
|
||||
}
|
||||
|
||||
protected abstract void applyColorToViews();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class OpenExternalLinkReceiver extends BroadcastReceiver {
|
|||
String sUrl = receiveIntent.getStringExtra(MainActivity.EXTRA_URL);
|
||||
url = Uri.parse(sUrl);
|
||||
} catch (Exception _ignored) {
|
||||
AppLog.v(this, "Could not open Chrome Custom Tab (bad URL)");
|
||||
AppLog.v(this, "Could not open Chrome Custom Tab (bad URL)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,16 +27,12 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import com.github.dfa.diaspora_android.data.DiasporaPodList;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,9 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
|
@ -80,7 +77,7 @@ public class ImageDownloadTask extends AsyncTask<String, Void, Bitmap> {
|
|||
connection.disconnect();
|
||||
|
||||
} catch (Exception e) {
|
||||
AppLog.e(this, e.getMessage());
|
||||
AppLog.e(this, e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
|
|
|
|||
|
|
@ -20,13 +20,11 @@ package com.github.dfa.diaspora_android.task;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.Log;
|
||||
import android.webkit.CookieManager;
|
||||
|
||||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -62,7 +60,7 @@ public class ProfileFetchTask extends AsyncTask<Void, Void, Void> {
|
|||
String extractedProfileData = null;
|
||||
final CookieManager cookieManager = app.getCookieManager();
|
||||
String cookies = cookieManager.getCookie(urls.getPodUrl());
|
||||
AppLog.d(this, cookies);
|
||||
AppLog.d(this, cookies);
|
||||
|
||||
HttpsURLConnection connection;
|
||||
InputStream inStream;
|
||||
|
|
@ -88,10 +86,10 @@ public class ProfileFetchTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
}
|
||||
|
||||
try{
|
||||
try {
|
||||
br.close();
|
||||
inStream.close();
|
||||
} catch (IOException e){/*Nothing*/}
|
||||
} catch (IOException e) {/*Nothing*/}
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
|
|
@ -103,7 +101,7 @@ public class ProfileFetchTask extends AsyncTask<Void, Void, Void> {
|
|||
if (extractedProfileData != null) {
|
||||
PodUserProfile profile = new PodUserProfile(app);
|
||||
profile.parseJson(extractedProfileData);
|
||||
AppLog.d(this, "Extracted new_messages (service):" + profile.getUnreadMessagesCount());
|
||||
AppLog.d(this, "Extracted new_messages (service):" + profile.getUnreadMessagesCount());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ package com.github.dfa.diaspora_android.task;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.Log;
|
||||
import android.webkit.CookieManager;
|
||||
|
||||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -79,13 +77,13 @@ public class StatisticsFetchTask extends AsyncTask<Void, Void, Void> {
|
|||
BufferedReader br = new BufferedReader(new InputStreamReader(inStream));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
AppLog.d(this, "STATS: "+line);
|
||||
AppLog.d(this, "STATS: " + line);
|
||||
}
|
||||
|
||||
try{
|
||||
try {
|
||||
br.close();
|
||||
inStream.close();
|
||||
} catch (IOException e){/*Nothing*/}
|
||||
} catch (IOException e) {/*Nothing*/}
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class BottomBarBehavior extends CoordinatorLayout.Behavior<LinearLayout>
|
|||
if (defaultDependencyTop == -1) {
|
||||
defaultDependencyTop = dependency.getTop();
|
||||
}
|
||||
if(dependency.getTop()<0)
|
||||
if (dependency.getTop() < 0)
|
||||
child.setTranslationY(-dependency.getTop() + defaultDependencyTop);
|
||||
else
|
||||
child.setTranslationY(defaultDependencyTop);
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public class ContextMenuWebView extends NestedWebView {
|
|||
}
|
||||
}
|
||||
|
||||
public void loadUrlNew(String url){
|
||||
public void loadUrlNew(String url) {
|
||||
stopLoading();
|
||||
loadUrl(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,16 +64,16 @@ public class HtmlTextView extends TextView {
|
|||
/**
|
||||
* Linkify, format markdown and escape the displayed text.
|
||||
*/
|
||||
private void init(){
|
||||
private void init() {
|
||||
formatHtmlAndCustomTags();
|
||||
}
|
||||
|
||||
public void setTextFormatted(String text){
|
||||
public void setTextFormatted(String text) {
|
||||
setText(text);
|
||||
formatHtmlAndCustomTags();
|
||||
}
|
||||
|
||||
private void formatHtmlAndCustomTags(){
|
||||
private void formatHtmlAndCustomTags() {
|
||||
setText(new SpannableString(Html.fromHtml(getText().toString())));
|
||||
Linkify.TransformFilter filter = new Linkify.TransformFilter() {
|
||||
public final String transformUrl(final Matcher match, String url) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import android.support.design.widget.AppBarLayout;
|
|||
|
||||
public interface IntellihideToolbarActivityListener {
|
||||
int toolbarDefaultScrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP;
|
||||
|
||||
void enableToolbarHiding();
|
||||
|
||||
void disableToolbarHiding();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,12 +153,12 @@ public class PodSelectionDialog extends AppCompatDialogFragment {
|
|||
public boolean checkInputs() {
|
||||
boolean ok = true;
|
||||
String s = editPodAddress.getText().toString();
|
||||
if(TextUtils.isEmpty(s) || s.length() < 3){
|
||||
if (TextUtils.isEmpty(s) || s.length() < 3) {
|
||||
editPodAddress.setError(getString(R.string.missing_value));
|
||||
ok = false;
|
||||
}
|
||||
s = editPodName.getText().toString();
|
||||
if(TextUtils.isEmpty(s) || s.length() < 3){
|
||||
if (TextUtils.isEmpty(s) || s.length() < 3) {
|
||||
editPodName.setError(getString(R.string.missing_value));
|
||||
ok = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.dfa.diaspora_android.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import android.support.customtabs.CustomTabsClient;
|
|||
import android.support.customtabs.CustomTabsIntent;
|
||||
import android.support.customtabs.CustomTabsServiceConnection;
|
||||
import android.support.customtabs.CustomTabsSession;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -43,10 +42,10 @@ public class CustomTabActivityHelper {
|
|||
/**
|
||||
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView
|
||||
*
|
||||
* @param activity The host activity
|
||||
* @param activity The host activity
|
||||
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available
|
||||
* @param uri the Uri to be opened
|
||||
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available
|
||||
* @param uri the Uri to be opened
|
||||
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available
|
||||
*/
|
||||
public static void openCustomTab(Activity activity,
|
||||
CustomTabsIntent customTabsIntent,
|
||||
|
|
@ -68,6 +67,7 @@ public class CustomTabActivityHelper {
|
|||
|
||||
/**
|
||||
* Unbinds the Activity from the Custom Tabs Service
|
||||
*
|
||||
* @param activity the activity that is connected to the service
|
||||
*/
|
||||
public void unbindCustomTabsService(Activity activity) {
|
||||
|
|
@ -93,6 +93,7 @@ public class CustomTabActivityHelper {
|
|||
|
||||
/**
|
||||
* Register a Callback to be called when connected or disconnected from the Custom Tabs Service
|
||||
*
|
||||
* @param connectionCallback
|
||||
*/
|
||||
public void setConnectionCallback(ConnectionCallback connectionCallback) {
|
||||
|
|
@ -101,6 +102,7 @@ public class CustomTabActivityHelper {
|
|||
|
||||
/**
|
||||
* Binds the Activity to the Custom Tabs Service
|
||||
*
|
||||
* @param activity the activity to be binded to the service
|
||||
*/
|
||||
public void bindCustomTabsService(Activity activity) {
|
||||
|
|
@ -161,9 +163,8 @@ public class CustomTabActivityHelper {
|
|||
*/
|
||||
public interface CustomTabFallback {
|
||||
/**
|
||||
*
|
||||
* @param activity The Activity that wants to open the Uri
|
||||
* @param uri The uri to be opened by the fallback
|
||||
* @param uri The uri to be opened by the fallback
|
||||
*/
|
||||
void openUri(Activity activity, Uri uri);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import android.content.pm.ResolveInfo;
|
|||
import android.net.Uri;
|
||||
import android.support.customtabs.CustomTabsService;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
|
||||
|
|
@ -47,13 +46,14 @@ public class CustomTabsHelper {
|
|||
|
||||
private static String sPackageNameToUse;
|
||||
|
||||
private CustomTabsHelper() {}
|
||||
private CustomTabsHelper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes through all apps that handle VIEW intents and have a warmup service. Picks
|
||||
* the one chosen by the user if there is one, otherwise makes a best effort to return a
|
||||
* valid package name.
|
||||
*
|
||||
* <p>
|
||||
* This is <strong>not</strong> threadsafe.
|
||||
*
|
||||
* @param context {@link Context} to use for accessing {@link PackageManager}.
|
||||
|
|
@ -107,6 +107,7 @@ public class CustomTabsHelper {
|
|||
|
||||
/**
|
||||
* Used to check whether there is a specialized handler for a given intent.
|
||||
*
|
||||
* @param intent The intent to check with.
|
||||
* @return Whether there is a specialized handler for the given intent.
|
||||
*/
|
||||
|
|
@ -127,7 +128,7 @@ public class CustomTabsHelper {
|
|||
return true;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
AppLog.e(TAG, "Runtime exception while getting specialized handlers");
|
||||
AppLog.e(TAG, "Runtime exception while getting specialized handlers");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package com.github.dfa.diaspora_android.util;
|
|||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
|
||||
import com.github.dfa.diaspora_android.data.PodAspect;
|
||||
|
||||
|
|
@ -68,7 +67,7 @@ public class DiasporaUrlHelper {
|
|||
*/
|
||||
public String getPodUrl() {
|
||||
DiasporaPod pod = settings.getPod();
|
||||
if (pod != null){
|
||||
if (pod != null) {
|
||||
return pod.getPodUrl().getBaseUrl();
|
||||
}
|
||||
return "http://127.0.0.1";
|
||||
|
|
@ -215,6 +214,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a url that points to the statistics page of the pod.
|
||||
*
|
||||
* @return https://(pod-domain.tld)/statistics
|
||||
*/
|
||||
public String getStatisticsUrl() {
|
||||
|
|
@ -223,6 +223,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a url that points to the sign in page of the pod.
|
||||
*
|
||||
* @return https://(pod-domain.tld)/users/sign_in
|
||||
*/
|
||||
public String getSignInUrl() {
|
||||
|
|
@ -231,6 +232,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a url that points to the personal settings page of the pod.
|
||||
*
|
||||
* @return https://(pod-domain.tld)/user/edit
|
||||
*/
|
||||
public String getPersonalSettingsUrl() {
|
||||
|
|
@ -239,6 +241,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a url that points to the manage tags page of the pod.
|
||||
*
|
||||
* @return https://(pod-domain.tld)/tag_followings/manage
|
||||
*/
|
||||
public String getManageTagsUrl() {
|
||||
|
|
@ -247,6 +250,7 @@ public class DiasporaUrlHelper {
|
|||
|
||||
/**
|
||||
* Return a url that points to the manage tags page of the pod.
|
||||
*
|
||||
* @return https://(pod-domain.tld)/contacts
|
||||
*/
|
||||
public String getManageContactsUrl() {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,9 @@ public class Log extends Observable {
|
|||
private Log() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private Log(AppSettings appSettings) {
|
||||
if(appSettings != null) {
|
||||
if (appSettings != null) {
|
||||
//TODO: Store/Restore logBuffer between app starts
|
||||
logBuffer = new ArrayList<>();
|
||||
} else {
|
||||
|
|
@ -55,17 +56,17 @@ public class Log extends Observable {
|
|||
}
|
||||
|
||||
public static Log getInstance() {
|
||||
if(instance == null) instance = new Log();
|
||||
if (instance == null) instance = new Log();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static Log getInstance(AppSettings appSettings) {
|
||||
if(instance == null) instance = new Log(appSettings);
|
||||
if (instance == null) instance = new Log(appSettings);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static String time() {
|
||||
return getInstance().dateFormat.format(new Date())+": ";
|
||||
return getInstance().dateFormat.format(new Date()) + ": ";
|
||||
}
|
||||
|
||||
public static void d(String tag, String msg) {
|
||||
|
|
@ -116,23 +117,23 @@ public class Log extends Observable {
|
|||
|
||||
public synchronized static String getLogBuffer() {
|
||||
String out = "";
|
||||
for(String s : getInstance().logBuffer) {
|
||||
for (String s : getInstance().logBuffer) {
|
||||
out = out + s + "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private void notifyLogBufferChanged() {
|
||||
if(observers == null) return;
|
||||
for(Observer o : observers) {
|
||||
if(o != null) {
|
||||
if (observers == null) return;
|
||||
for (Observer o : observers) {
|
||||
if (o != null) {
|
||||
o.update(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void addLogEntry(String msg) {
|
||||
logBuffer.add(time()+msg);
|
||||
logBuffer.add(time() + msg);
|
||||
while (logBuffer.size() > MAX_BUFFER_SIZE) {
|
||||
logBuffer.remove(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ProxyHandler {
|
|||
}
|
||||
|
||||
public static ProxyHandler getInstance() {
|
||||
if(instance == null) {
|
||||
if (instance == null) {
|
||||
instance = new ProxyHandler();
|
||||
}
|
||||
return instance;
|
||||
|
|
@ -77,7 +77,7 @@ public class ProxyHandler {
|
|||
|
||||
public void addWebView(WebView wv) {
|
||||
AppLog.d(this, "AddWebView");
|
||||
if(wv != null && !webViews.contains(wv)) {
|
||||
if (wv != null && !webViews.contains(wv)) {
|
||||
webViews.add(wv);
|
||||
updateWebViewProxySettings(wv, wv.getContext());
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ public class ProxyHandler {
|
|||
StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
|
||||
StrictMode.ThreadPolicy tmp = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(tmp);
|
||||
if(appSettings.isProxyEnabled()) {
|
||||
if (appSettings.isProxyEnabled()) {
|
||||
if (wv != null) {
|
||||
try {
|
||||
WebkitProxy.setProxy(MainActivity.class.getName(), context.getApplicationContext(), wv, appSettings.getProxyHost(), appSettings.getProxyPort());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.dfa.diaspora_android.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -29,7 +29,6 @@ import android.webkit.WebView;
|
|||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.data.DiasporaPodList;
|
||||
import com.github.dfa.diaspora_android.data.PodAspect;
|
||||
import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||
|
||||
|
|
@ -47,14 +46,14 @@ public class WebHelper {
|
|||
return ni != null && ni.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
public static String replaceUrlWithMarkdown(String url){
|
||||
if( url != null && URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)){
|
||||
public static String replaceUrlWithMarkdown(String url) {
|
||||
if (url != null && URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) {
|
||||
return "<" + url + ">";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public static String escapeHtmlText(String text){
|
||||
public static String escapeHtmlText(String text) {
|
||||
text = Html.escapeHtml(text);
|
||||
text = text.replace("\n", " ");
|
||||
return text;
|
||||
|
|
@ -96,7 +95,7 @@ public class WebHelper {
|
|||
"})();");
|
||||
}
|
||||
|
||||
public static void shareTextIntoWebView(final WebView webView, String sharedText){
|
||||
public static void shareTextIntoWebView(final WebView webView, String sharedText) {
|
||||
sharedText = sharedText.replace("'", "'").replace("\"", """);
|
||||
webView.loadUrl("javascript:(function() { " +
|
||||
" document.documentElement.style.paddingBottom = '500px';" +
|
||||
|
|
@ -146,7 +145,7 @@ public class WebHelper {
|
|||
"<a href='%s/followed_tags' style='color: #000000; text-decoration: none;'><b>%s</b></a>",
|
||||
pod0BaseUrl, app.getString(R.string.all_tags)));
|
||||
sb.append("<hr style='height:5px;' />");
|
||||
for (String tag: profile.getFollowedTags()) {
|
||||
for (String tag : profile.getFollowedTags()) {
|
||||
sb.append("<span style='margin-left: 30px; '></span>» ");
|
||||
sb.append(String.format(Locale.getDefault(),
|
||||
"<a href='%s/tags/%s' style='color: #000000; text-decoration: none;'>#%s</a>",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import com.github.dfa.diaspora_android.R;
|
|||
*/
|
||||
public class ColorPalette {
|
||||
|
||||
public static int[] getAccentColors(Context context){
|
||||
public static int[] getAccentColors(Context context) {
|
||||
return new int[]{
|
||||
ContextCompat.getColor(context, R.color.md_red_500),
|
||||
ContextCompat.getColor(context, R.color.md_purple_500),
|
||||
|
|
@ -30,7 +30,7 @@ public class ColorPalette {
|
|||
};
|
||||
}
|
||||
|
||||
public static int getObscuredColor(int c){
|
||||
public static int getObscuredColor(int c) {
|
||||
float[] hsv = new float[3];
|
||||
int color = c;
|
||||
Color.colorToHSV(color, hsv);
|
||||
|
|
@ -39,14 +39,14 @@ public class ColorPalette {
|
|||
return color;
|
||||
}
|
||||
|
||||
public static int getTransparentColor(int color, int alpha){
|
||||
return ColorUtils.setAlphaComponent(color, alpha);
|
||||
public static int getTransparentColor(int color, int alpha) {
|
||||
return ColorUtils.setAlphaComponent(color, alpha);
|
||||
}
|
||||
|
||||
public static int[] getTransparencyShadows(int color) {
|
||||
int[] shadows = new int[10];
|
||||
for (int i=0; i<10;i++)
|
||||
shadows[i]= (ColorPalette.getTransparentColor(color, ((100-(i*10))*255) /100));
|
||||
for (int i = 0; i < 10; i++)
|
||||
shadows[i] = (ColorPalette.getTransparentColor(color, ((100 - (i * 10)) * 255) / 100));
|
||||
return shadows;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,51 +47,52 @@ public class ThemeHelper {
|
|||
}
|
||||
|
||||
public static ThemeHelper getInstance(AppSettings appSettings) {
|
||||
if(instance == null) {
|
||||
if (instance == null) {
|
||||
instance = new ThemeHelper(appSettings);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static ThemeHelper getInstance() {
|
||||
if(instance == null) throw new IllegalStateException("ThemeHelper must be initialized using getInstance(AppSettings) before it can be used!");
|
||||
if (instance == null)
|
||||
throw new IllegalStateException("ThemeHelper must be initialized using getInstance(AppSettings) before it can be used!");
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void updateEditTextColor(EditText editText) {
|
||||
if(editText != null) {
|
||||
if (editText != null) {
|
||||
editText.setHighlightColor(getInstance().appSettings.getAccentColor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateCheckBoxColor(CheckBox checkBox) {
|
||||
if(checkBox != null) {
|
||||
if (checkBox != null) {
|
||||
checkBox.setHighlightColor(getInstance().appSettings.getAccentColor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateTabLayoutColor(TabLayout tabLayout) {
|
||||
if(tabLayout != null) {
|
||||
if (tabLayout != null) {
|
||||
tabLayout.setBackgroundColor(getInstance().appSettings.getPrimaryColor());
|
||||
tabLayout.setSelectedTabIndicatorColor(getInstance().appSettings.getAccentColor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateTextViewColor(TextView textView) {
|
||||
if(textView != null) {
|
||||
if (textView != null) {
|
||||
textView.setHighlightColor(getInstance().appSettings.getAccentColor());
|
||||
textView.setLinkTextColor(getInstance().appSettings.getAccentColor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateToolbarColor(Toolbar toolbar) {
|
||||
if(toolbar != null) {
|
||||
if (toolbar != null) {
|
||||
toolbar.setBackgroundColor(getInstance().appSettings.getPrimaryColor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateActionMenuViewColor(ActionMenuView actionMenuView) {
|
||||
if(actionMenuView != null) {
|
||||
if (actionMenuView != null) {
|
||||
actionMenuView.setBackgroundColor(getInstance().appSettings.getPrimaryColor());
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +106,7 @@ public class ThemeHelper {
|
|||
}
|
||||
|
||||
public static void setPrimaryColorAsBackground(View view) {
|
||||
if(view != null) {
|
||||
if (view != null) {
|
||||
view.setBackgroundColor(getPrimaryColor());
|
||||
}
|
||||
}
|
||||
|
|
@ -115,13 +116,13 @@ public class ThemeHelper {
|
|||
}
|
||||
|
||||
public static void updateActionBarColor(ActionBar actionBar) {
|
||||
if(actionBar != null) {
|
||||
if (actionBar != null) {
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(getInstance().appSettings.getPrimaryColor()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateProgressBarColor(ProgressBar progressBar) {
|
||||
if(progressBar != null && progressBar.getProgressDrawable() != null) {
|
||||
if (progressBar != null && progressBar.getProgressDrawable() != null) {
|
||||
progressBar.getProgressDrawable().setColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public class DiasporaStreamWebChromeClient extends FileUploadWebChromeClient {
|
|||
|
||||
public interface SharedTextCallback {
|
||||
String getSharedText();
|
||||
|
||||
void setSharedText(String shared);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ public class FileUploadWebChromeClient extends ProgressBarWebChromeClient {
|
|||
|
||||
//For Android 4.1/4.2 only. DO NOT REMOVE!
|
||||
@SuppressWarnings("unused")
|
||||
protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
|
||||
{
|
||||
protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
|
||||
fileUploadCallback.legacyImageUpload(uploadMsg, acceptType, capture);
|
||||
}
|
||||
|
||||
|
|
@ -54,6 +53,7 @@ public class FileUploadWebChromeClient extends ProgressBarWebChromeClient {
|
|||
|
||||
public interface FileUploadCallback {
|
||||
boolean imageUpload(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams);
|
||||
|
||||
void legacyImageUpload(ValueCallback<Uri> uploadMsg, String acceptType, String capture);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue