1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-06-17 17:14:54 +02:00
dandelion/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java

1019 lines
39 KiB
Java
Raw Normal View History

2016-03-03 17:46:31 +01:00
/*
This file is part of the Diaspora for Android.
2016-03-03 17:46:31 +01:00
Diaspora for Android is free software: you can redistribute it and/or modify
2016-03-03 17:46:31 +01:00
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Diaspora for Android is distributed in the hope that it will be useful,
2016-03-03 17:46:31 +01:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Diaspora for Android.
2016-03-03 17:46:31 +01:00
If not, see <http://www.gnu.org/licenses/>.
*/
2016-03-29 19:38:50 +02:00
package com.github.dfa.diaspora_android.activity;
2016-03-03 17:46:31 +01:00
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.drawable.LayerDrawable;
2016-03-03 17:46:31 +01:00
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
2016-09-21 22:49:37 +02:00
import android.support.customtabs.CustomTabsSession;
2016-07-31 15:16:22 +02:00
import android.support.design.widget.AppBarLayout;
2016-03-03 17:46:31 +01:00
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.LocalBroadcastManager;
2016-03-03 17:46:31 +01:00
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;
2016-03-03 17:46:31 +01:00
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
2016-03-03 17:46:31 +01:00
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
2016-03-03 17:46:31 +01:00
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
import android.widget.RelativeLayout;
2016-03-03 17:46:31 +01:00
import android.widget.TextView;
import android.widget.Toast;
2016-03-03 17:46:31 +01:00
2016-03-29 19:38:50 +02:00
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.PodUserProfile;
2016-09-28 21:43:25 +02:00
import com.github.dfa.diaspora_android.fragment.BrowserFragment;
import com.github.dfa.diaspora_android.fragment.CustomFragment;
2016-09-28 21:43:25 +02:00
import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment;
2016-09-30 23:15:10 +02:00
import com.github.dfa.diaspora_android.fragment.HashtagListFragment;
import com.github.dfa.diaspora_android.fragment.PodSelectionFragment;
2016-03-29 19:38:50 +02:00
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
2016-10-10 17:47:04 +02:00
import com.github.dfa.diaspora_android.util.ProxyHandler;
import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver;
import com.github.dfa.diaspora_android.ui.BadgeDrawable;
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
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;
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
import com.github.dfa.diaspora_android.util.theming.ThemeHelper;
2016-08-07 14:29:52 +02:00
import com.github.dfa.diaspora_android.util.WebHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
2016-03-03 17:46:31 +01:00
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
public class MainActivity extends ThemedActivity
implements NavigationView.OnNavigationItemSelectedListener,
WebUserProfileChangedListener,
CustomTabActivityHelper.ConnectionCallback,
IntellihideToolbarActivityListener {
2016-03-03 17:46:31 +01:00
public static final int REQUEST_CODE_ASK_PERMISSIONS = 123;
public static final int REQUEST_CODE__ACCESS_EXTERNAL_STORAGE = 124;
public static final int INPUT_FILE_REQUEST_CODE_NEW = 1;
public static final int INPUT_FILE_REQUEST_CODE_OLD = 2;
public static final String ACTION_OPEN_URL = "com.github.dfa.diaspora_android.MainActivity.open_url";
public static final String ACTION_OPEN_EXTERNAL_URL = "com.github.dfa.diaspora_android.MainActivity.open_external_url";
public static final String ACTION_CHANGE_ACCOUNT = "com.github.dfa.diaspora_android.MainActivity.change_account";
2016-07-26 22:52:26 +02:00
public static final String ACTION_CLEAR_CACHE = "com.github.dfa.diaspora_android.MainActivity.clear_cache";
public static final String ACTION_UPDATE_TITLE_FROM_URL = "com.github.dfa.diaspora_android.MainActivity.set_title";
2016-06-18 15:53:49 +02:00
public static final String URL_MESSAGE = "URL_MESSAGE";
public static final String EXTRA_URL = "com.github.dfa.diaspora_android.extra_url";
public static final String CONTENT_HASHTAG = "content://com.github.dfa.diaspora_android.mainactivity/";
2016-03-24 13:56:30 +01:00
private App app;
private CustomTabActivityHelper customTabActivityHelper;
2016-03-24 11:58:28 +01:00
private AppSettings appSettings;
private DiasporaUrlHelper urls;
private PodUserProfile podUserProfile;
private final Handler uiHandler = new Handler();
private OpenExternalLinkReceiver brOpenExternalLink;
private BroadcastReceiver brSetTitle;
private Snackbar snackbarExitApp;
2016-06-24 13:31:01 +02:00
private Snackbar snackbarNoInternet;
private FragmentManager fm;
2016-09-21 22:49:37 +02:00
private CustomTabsSession customTabsSession;
/**
* UI Bindings
*/
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
@BindView(R.id.main__appbar)
AppBarLayout appBarLayout;
@BindView(R.id.main__topbar)
Toolbar toolbarTop;
@BindView(R.id.main__bottombar)
ActionMenuView toolbarBottom;
@BindView(R.id.fragment_container)
FrameLayout fragmentContainer;
@BindView(R.id.main__navigaion_view)
2016-06-04 21:46:54 +02:00
NavigationView navView;
@BindView(R.id.main__navdrawer)
2016-06-04 21:46:54 +02:00
DrawerLayout navDrawer;
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
RelativeLayout navDrawerLayout;
LinearLayout navProfilePictureArea;
2016-06-05 01:42:10 +02:00
// NavHeader cannot be bound by Butterknife
private TextView navheaderTitle;
private TextView navheaderDescription;
private ImageView navheaderImage;
private String textToBeShared;
2016-03-03 17:46:31 +01:00
/**
* END UI Bindings
*/
2016-03-03 17:46:31 +01:00
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppLog.v(this, "onCreate()");
2016-03-03 17:46:31 +01:00
// Bind UI
2016-06-04 11:11:51 +02:00
setContentView(R.layout.main__activity);
ButterKnife.bind(this);
if ((app = (App) getApplication()) == null) AppLog.e(this, "App is null!");
if ((appSettings = app.getSettings()) == null) AppLog.e(this, "AppSettings is null!");
if ((podUserProfile = app.getPodUserProfile()) == null)
AppLog.e(this, "PodUserProfile is null!");
2016-06-05 17:25:11 +02:00
podUserProfile.setCallbackHandler(uiHandler);
podUserProfile.setListener(this);
urls = new DiasporaUrlHelper(appSettings);
customTabActivityHelper = new CustomTabActivityHelper();
2016-09-21 22:49:37 +02:00
customTabActivityHelper.setConnectionCallback(this);
2016-10-10 17:47:04 +02:00
ProxyHandler.getInstance().updateProxySettings(this);
2016-03-03 17:46:31 +01:00
fm = getSupportFragmentManager();
setupUI();
2016-09-11 13:05:26 +02:00
brOpenExternalLink = new OpenExternalLinkReceiver(this);
brSetTitle = new UpdateTitleReceiver(app, urls, new UpdateTitleReceiver.TitleCallback() {
@Override
public void setTitle(int rId) {
CustomFragment top = getTopFragment();
if(top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
MainActivity.this.setTitle(rId);
}
}
@Override
public void setTitle(String title) {
CustomFragment top = getTopFragment();
if(top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
MainActivity.this.setTitle(title);
}
}
});
2016-10-07 04:29:32 +02:00
if (!appSettings.hasPod()) {
AppLog.d(this, "We have no pod. Show PodSelectionFragment");
showFragment(getFragment(PodSelectionFragment.TAG));
2016-09-28 21:43:25 +02:00
} else {
AppLog.d(this, "Pod found. Handle intents.");
//Handle intent
Intent intent = getIntent();
if (intent != null && intent.getAction() != null) {
handleIntent(intent);
} else {
openDiasporaUrl(urls.getStreamUrl());
}
2016-09-28 21:43:25 +02:00
}
}
/**
* Setup the user interface. Set up both toolbars and initialize the snackbars.
* Initialize the navigation drawer and apply intellihide settings.
*/
private void setupUI() {
AppLog.i(this, "setupUI()");
// Setup toolbar
setSupportActionBar(toolbarTop);
toolbarBottom.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
2016-09-28 21:43:25 +02:00
CustomFragment top = getTopFragment();
return MainActivity.this.onOptionsItemSelected(item) || (top != null && top.onOptionsItemSelected(item));
2016-03-25 18:25:59 +01:00
}
});
2016-06-07 19:13:37 +02:00
setTitle(R.string.app_name);
2016-03-25 18:25:59 +01:00
//Setup snackbar
snackbarExitApp = Snackbar
.make(fragmentContainer, R.string.confirm_exit, Snackbar.LENGTH_LONG)
.setAction(android.R.string.yes, new View.OnClickListener() {
@Override
public void onClick(View view) {
2016-07-31 15:16:22 +02:00
finish();
moveTaskToBack(true);
}
});
snackbarNoInternet = Snackbar.make(fragmentContainer, R.string.no_internet, Snackbar.LENGTH_LONG);
// Load app settings
setupNavigationSlider();
AppLog.v(this, "UI successfully set up");
}
2016-09-28 21:43:25 +02:00
/**
* Show DiasporaStreamFragment if necessary and load URL url
* @param url URL to load in the DiasporaStreamFragment
*/
2016-09-30 23:15:10 +02:00
public void openDiasporaUrl(String url) {
2016-09-22 23:40:35 +02:00
AppLog.v(this, "openDiasporaUrl()");
2016-09-28 21:43:25 +02:00
DiasporaStreamFragment streamFragment = (DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG);
showFragment(streamFragment);
streamFragment.loadUrl(url);
}
2016-09-28 21:43:25 +02:00
/**
* 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.
2016-09-28 21:43:25 +02:00
* @param fragmentTag tag
* @return corresponding Fragment
*/
protected CustomFragment getFragment(String fragmentTag) {
CustomFragment fragment = (CustomFragment) fm.findFragmentByTag(fragmentTag);
if(fragment != null) {
2016-09-28 21:43:25 +02:00
return fragment;
} else {
switch (fragmentTag) {
case DiasporaStreamFragment.TAG:
DiasporaStreamFragment dsf = new DiasporaStreamFragment();
fm.beginTransaction().add(dsf, fragmentTag).commit();
return dsf;
case BrowserFragment.TAG:
BrowserFragment bf = new BrowserFragment();
fm.beginTransaction().add(bf, fragmentTag).commit();
return bf;
2016-09-30 23:15:10 +02:00
case HashtagListFragment.TAG:
HashtagListFragment hlf = new HashtagListFragment();
fm.beginTransaction().add(hlf, fragmentTag).commit();
return hlf;
case PodSelectionFragment.TAG:
PodSelectionFragment psf = new PodSelectionFragment();
fm.beginTransaction().add(psf, fragmentTag).commit();
return psf;
2016-09-28 21:43:25 +02:00
default:
AppLog.e(this,"Invalid Fragment Tag: "+fragmentTag
+"\nAdd Fragments Tag to getFragment()'s switch case.");
return getTopFragment();
2016-09-28 21:43:25 +02:00
}
}
}
/**
* 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) {
2016-09-29 19:44:42 +02:00
AppLog.v(this, "showFragment()");
2016-09-28 21:43:25 +02:00
CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container);
if(currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) {
2016-09-29 19:44:42 +02:00
AppLog.v(this, "Fragment was not visible. Replace it.");
2016-09-28 21:43:25 +02:00
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
2016-09-29 19:44:42 +02:00
invalidateOptionsMenu();
2016-09-28 21:43:25 +02:00
} else {
2016-09-29 19:44:42 +02:00
AppLog.v(this, "Fragment was already visible. Do nothing.");
}
}
/**
* Initialize the navigation slider
*/
private void setupNavigationSlider() {
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
2016-06-04 21:46:54 +02:00
this, navDrawer, toolbarTop, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
navDrawer.addDrawerListener(toggle);
toggle.syncState();
2016-06-04 21:46:54 +02:00
//NavigationView navView = ButterKnife.findById(this, R.id.nav_view);
navView.setNavigationItemSelectedListener(this);
2016-06-04 21:46:54 +02:00
View navHeader = navView.getHeaderView(0);
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
navProfilePictureArea = ButterKnife.findById(navHeader, R.id.nav_profile_picture);
navDrawerLayout = ButterKnife.findById(navHeader, R.id.nav_drawer);
//Handle clicks on profile picture
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
navProfilePictureArea.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
navDrawer.closeDrawer(GravityCompat.START);
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getProfileUrl());
} else {
snackbarNoInternet.show();
}
}
});
navheaderTitle = ButterKnife.findById(navHeader, R.id.navheader_title);
navheaderDescription = ButterKnife.findById(navHeader, R.id.podselection__podupti_notice);
navheaderImage = ButterKnife.findById(navHeader, R.id.navheader_user_image);
if (!appSettings.getName().equals("")) {
navheaderTitle.setText(appSettings.getName());
}
if (appSettings.getPod() != null) {
navheaderDescription.setText(appSettings.getPod().getName());
}
String avatarUrl = appSettings.getAvatarUrl();
if (!avatarUrl.equals("")) {
//Display app launcher icon instead of default avatar asset
//(Which would by the way not load because of missing pod domain prefix in the url)
if (avatarUrl.startsWith("/assets/user/default")) {
AppLog.v(this, "Avatar appears to be an asset. Display launcher icon instead (avatarUrl=" + avatarUrl + ")");
navheaderImage.setImageResource(R.drawable.ic_launcher);
} else {
// Try to load image
if (!app.getAvatarImageLoader().loadToImageView(navheaderImage)) {
// If not yet loaded, start download
AppLog.v(this, "Avatar not cached. Start download: " + avatarUrl);
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
}
}
}
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
updateNavigationViewEntryVisibilities();
}
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
protected void updateNavigationViewEntryVisibilities() {
Menu navMenu = navView.getMenu();
navMenu.findItem(R.id.nav_exit).setVisible(appSettings.isVisibleInNavExit());
navMenu.findItem(R.id.nav_activities).setVisible(appSettings.isVisibleInNavActivities());
navMenu.findItem(R.id.nav_aspects).setVisible(appSettings.isVisibleInNavAspects());
navMenu.findItem(R.id.nav_commented).setVisible(appSettings.isVisibleInNavCommented());
navMenu.findItem(R.id.nav_followed_tags).setVisible(appSettings.isVisibleInNavFollowed_tags());
2016-09-28 21:43:25 +02:00
navMenu.findItem(R.id.nav_about).setVisible(appSettings.isVisibleInNavHelp_license());
navMenu.findItem(R.id.nav_liked).setVisible(appSettings.isVisibleInNavLiked());
navMenu.findItem(R.id.nav_mentions).setVisible(appSettings.isVisibleInNavMentions());
navMenu.findItem(R.id.nav_profile).setVisible(appSettings.isVisibleInNavProfile());
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities());
// Top bar
if (appSettings.getPod() == null) {
navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), false);
}
}
/**
* Forward incoming intents to handleIntent()
* @param intent incoming
*/
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(intent);
}
/**
* Handle intents and execute intent specific actions
* @param intent intent to get handled
*/
private void handleIntent(Intent intent) {
AppLog.i(this, "handleIntent()");
if (intent == null) {
AppLog.v(this, "Intent was null");
return;
}
String action = intent.getAction();
String type = intent.getType();
String loadUrl = null;
AppLog.v(this, "Action: " + action + " Type: " + type);
if (Intent.ACTION_MAIN.equals(action)) {
loadUrl = urls.getStreamUrl();
} else if (ACTION_OPEN_URL.equals(action)) {
loadUrl = intent.getStringExtra(URL_MESSAGE);
} else if (Intent.ACTION_VIEW.equals(action) && intent.getDataString() != null) {
Uri data = intent.getData();
if (data != null && data.toString().startsWith(CONTENT_HASHTAG)) {
handleHashtag(intent);
return;
} else {
loadUrl = intent.getDataString();
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");
appSettings.setPod(null);
2016-09-28 21:43:25 +02:00
app.resetPodData(((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView());
showFragment(getFragment(PodSelectionFragment.TAG));
} else if (ACTION_CLEAR_CACHE.equals(action)) {
AppLog.v(this, "Clear WebView cache");
2016-09-28 21:43:25 +02:00
((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView().clearCache(true);
} else if (Intent.ACTION_SEND.equals(action) && type != null) {
switch (type) {
case "text/plain":
if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
handleSendSubject(intent);
} else {
handleSendText(intent);
}
break;
case "image/*":
handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method
break;
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
/* TODO: Implement and add filter to manifest */
return;
}
if (loadUrl != null) {
navDrawer.closeDrawers();
openDiasporaUrl(loadUrl);
}
}
2016-03-03 17:46:31 +01:00
/**
* Handle activity results
* @param requestCode reqCode
* @param resultCode resCode
* @param data data
*/
2016-03-03 17:46:31 +01:00
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
AppLog.v(this, "onActivityResult(): "+requestCode);
2016-09-07 23:55:25 +02:00
super.onActivityResult(requestCode, resultCode, data);
2016-03-03 17:46:31 +01:00
}
/**
* Return the fragment which is currently displayed in R.id.fragment_container
* @return top fragment or null if there is none displayed
*/
2016-09-28 21:43:25 +02:00
private CustomFragment getTopFragment() {
Fragment top = fm.findFragmentById(R.id.fragment_container);
if(top != null) {
2016-09-28 21:43:25 +02:00
return (CustomFragment) top;
}
return null;
2016-03-03 17:46:31 +01:00
}
/**
* Handle presses on the back button
*/
2016-03-03 17:46:31 +01:00
@Override
public void onBackPressed() {
AppLog.v(this, "onBackPressed()");
2016-06-04 21:46:54 +02:00
if (navDrawer.isDrawerOpen(navView)) {
navDrawer.closeDrawer(navView);
return;
}
2016-09-28 21:43:25 +02:00
CustomFragment top = getTopFragment();
if(top != null) {
2016-09-22 23:40:35 +02:00
AppLog.v(this, "Top Fragment is not null");
if(!top.onBackPressed()) {
2016-09-22 23:40:35 +02:00
AppLog.v(this, "Top Fragment.onBackPressed was false");
AppLog.v(this, "BackStackEntryCount: "+fm.getBackStackEntryCount());
if(fm.getBackStackEntryCount()>0) {
2016-09-28 21:43:25 +02:00
fm.popBackStack();
} else {
snackbarExitApp.show();
}
return;
} else {
2016-09-22 23:40:35 +02:00
AppLog.v(this, "Top Fragment.onBackPressed was true");
return;
}
2016-08-07 11:39:20 +02:00
}
if (!snackbarExitApp.isShown()) {
snackbarExitApp.show();
2016-03-03 17:46:31 +01:00
}
}
@Override
protected void onStart() {
super.onStart();
customTabActivityHelper.bindCustomTabsService(this);
}
@Override
protected void onStop() {
super.onStop();
customTabActivityHelper.unbindCustomTabsService(this);
}
2016-03-03 17:46:31 +01:00
@Override
protected void onPause() {
AppLog.v(this, "onPause()");
AppLog.v(this, "Unregister BroadcastReceivers");
LocalBroadcastManager.getInstance(this).unregisterReceiver(brSetTitle);
LocalBroadcastManager.getInstance(this).unregisterReceiver(brOpenExternalLink);
2016-03-03 17:46:31 +01:00
super.onPause();
}
@Override
protected void onResume() {
AppLog.v(this, "onResume()");
super.onResume();
AppLog.v(this, "Register BroadcastReceivers");
LocalBroadcastManager.getInstance(this).registerReceiver(brSetTitle, new IntentFilter(ACTION_UPDATE_TITLE_FROM_URL));
LocalBroadcastManager.getInstance(this).registerReceiver(brOpenExternalLink, new IntentFilter(ACTION_OPEN_EXTERNAL_URL));
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
this.appSettings = getAppSettings();
if (appSettings.isIntellihideToolbars()) {
this.enableToolbarHiding();
} else {
this.disableToolbarHiding();
}
updateNavigationViewEntryVisibilities();
}
/**
* Clear and repopulate top and bottom toolbar.
* Also add menu items of the displayed fragment
* @param menu top toolbar
* @return boolean
*/
2016-03-03 17:46:31 +01:00
@Override
public boolean onCreateOptionsMenu(Menu menu) {
AppLog.v(this, "onCreateOptionsMenu()");
//Clear the menus
2016-09-29 19:44:42 +02:00
menu.clear();
toolbarBottom.getMenu().clear();
toolbarBottom.setVisibility(View.VISIBLE);
2016-09-29 19:44:42 +02:00
CustomFragment top = getTopFragment();
if(top != null) {
//Are we displaying a Fragment other than PodSelectionFragment?
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());
}
//PodSelectionFragment
else {
//Hide bottom toolbar
toolbarBottom.setVisibility(View.GONE);
}
2016-09-29 19:44:42 +02:00
}
2016-03-03 17:46:31 +01:00
return true;
}
/**
* Set the notification and messages counter in the top toolbar
* @param menu menu
* @return boolean
*/
2016-03-03 17:46:31 +01:00
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem item;
updateNavigationViewEntryVisibilities();
2016-10-07 04:29:32 +02:00
if ((item = menu.findItem(R.id.action_notifications)) != null) {
LayerDrawable icon = (LayerDrawable) item.getIcon();
BadgeDrawable.setBadgeCount(this, icon, podUserProfile.getNotificationCount());
}
if ((item = menu.findItem(R.id.action_conversations)) != null) {
LayerDrawable icon = (LayerDrawable) item.getIcon();
BadgeDrawable.setBadgeCount(this, icon, podUserProfile.getUnreadMessagesCount());
2016-03-03 17:46:31 +01:00
}
return super.onPrepareOptionsMenu(menu);
}
/**
* Handle clicks on the optionsmenu
* @param item item
* @return boolean
*/
2016-03-03 17:46:31 +01:00
@Override
public boolean onOptionsItemSelected(MenuItem item) {
AppLog.i(this, "onOptionsItemSelected()");
switch (item.getItemId()) {
case R.id.action_notifications: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getNotificationsUrl());
return true;
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
return false;
}
2016-03-03 17:46:31 +01:00
}
case R.id.action_conversations: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getConversationsUrl());
return true;
} else {
snackbarNoInternet.show();
return false;
}
}
case R.id.action_exit: {
moveTaskToBack(true);
2016-07-31 15:16:22 +02:00
finish();
return true;
}
case R.id.action_compose: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getNewPostUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
return true;
}
case R.id.action_search: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
2016-09-21 12:36:42 +02:00
View layout = getLayoutInflater().inflate(R.layout.ui__dialog_search__people_tags, null, false);
final EditText input = (EditText) layout.findViewById(R.id.dialog_search__input);
final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
String query = input.getText().toString().trim().replaceAll((which == DialogInterface.BUTTON_NEGATIVE ? "\\*" : "\\#"), "");
if (query.equals("")) {
Snackbar.make(fragmentContainer, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
} else {
openDiasporaUrl(which == DialogInterface.BUTTON_NEGATIVE ? urls.getSearchPeopleUrl(query) : urls.getSearchTagsUrl(query));
}
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}
};
final android.support.v7.app.AlertDialog dialog = new android.support.v7.app.AlertDialog.Builder(this)
.setView(layout).setTitle(R.string.search_alert_title)
.setCancelable(true)
.setPositiveButton(R.string.search_alert_tag, clickListener)
.setNegativeButton(R.string.search_alert_people, clickListener)
.create();
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
dialog.hide();
clickListener.onClick(null, 0);
return true;
}
return false;
}
});
// Popup keyboard
dialog.show();
input.requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
return true;
}
2016-03-03 17:46:31 +01:00
}
2016-06-04 17:56:08 +02:00
2016-03-03 17:46:31 +01:00
return super.onOptionsItemSelected(item);
}
/**
* Update the profile name in the navigation slider
* @param name name
*/
@Override
public void onUserProfileNameChanged(String name) {
AppLog.i(this, "onUserProfileNameChanged()");
navheaderTitle.setText(name);
}
/**
* Update the profile picture in the navigation slider
* @param avatarUrl url of the new profile pic
*/
@Override
public void onUserProfileAvatarChanged(String avatarUrl) {
AppLog.i(this, "onUserProfileAvatarChanged()");
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
}
/**
* 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) {
AppLog.v(this, "handleHashtag()");
try {
setSharedTexts(null, intent.getData().toString().split("/")[3]);
} catch (Exception e) {
AppLog.e(this, e.toString());
}
openDiasporaUrl(urls.getNewPostUrl());
}
/**
* 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) {
AppLog.v(this, "handleSendText()");
try {
setSharedTexts(null, intent.getStringExtra(Intent.EXTRA_TEXT));
openDiasporaUrl(urls.getNewPostUrl());
} catch (Exception e) {
AppLog.e(this, e.toString());
}
}
/**
* Handle sent text + subject
*
* @param intent intent
*/
private void handleSendSubject(Intent intent) {
AppLog.v(this, "handleSendSubject()");
try {
setSharedTexts(intent.getStringExtra(Intent.EXTRA_SUBJECT), intent.getStringExtra(Intent.EXTRA_TEXT));
openDiasporaUrl(urls.getNewPostUrl());
} catch (Exception e) {
AppLog.e(this, e.toString());
}
}
2016-08-07 14:29:52 +02:00
/**
* TODO: MOVE
* Set sharedText variable to escaped and formatted subject + body.
* If subject is null, only the body will be set. Else the subject will be set as header.
* Depending on whether the user has the setting isAppendSharedViaApp set, a reference to
* the app will be added at the bottom
*
* @param sharedSubject post subject or null
* @param sharedBody post text
*/
private void setSharedTexts(String sharedSubject, String sharedBody) {
AppLog.i(this, "setSharedTexts()");
String body = WebHelper.replaceUrlWithMarkdown(sharedBody);
if (appSettings.isAppendSharedViaApp()) {
AppLog.v(this, "Append app reference to shared text");
body = body + "\n\n" + getString(R.string.shared_by_diaspora_android);
}
final String escapedBody = WebHelper.escapeHtmlText(body);
if (sharedSubject != null) {
AppLog.v(this, "Append subject to shared text");
String escapedSubject = WebHelper.escapeHtmlText(WebHelper.replaceUrlWithMarkdown(sharedSubject));
AppLog.v(this, "Set shared text; Subject: \"" + escapedSubject + "\" Body: \"" + escapedBody + "\"");
textToBeShared = "**" + escapedSubject + "** " + escapedBody;
} else {
AppLog.v(this, "Set shared text; Subject: \"" + sharedSubject + "\" Body: \"" + sharedBody + "\"");
textToBeShared = escapedBody;
}
}
/**
* Share an image shared to the app via diaspora
* @param intent shareImageIntent
*/
//TODO: Implement some day
private void handleSendImage(Intent intent) {
AppLog.i(this, "handleSendImage()");
final Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) {
AppLog.v(this, "imageUri is not null. Handle shared image");
} else {
AppLog.w(this, "imageUri is null. Cannot precede.");
}
Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show();
}
/**
* Invalidate the top toolbar to update the notification counter
* @param notificationCount new notification count
*/
@Override
public void onNotificationCountChanged(int notificationCount) {
AppLog.i(this, "onNotificationCountChanged()");
2016-08-07 11:39:20 +02:00
// Count saved in PodUserProfile
invalidateOptionsMenu();
}
/**
* Invalidate the top toolbar to update the unread messages counter
* @param unreadMessageCount new unread messages count
*/
@Override
public void onUnreadMessageCountChanged(int unreadMessageCount) {
AppLog.i(this, "onUnreadMessageCountChanged()");
2016-08-07 11:39:20 +02:00
// Count saved in PodUserProfile
invalidateOptionsMenu();
}
2016-09-21 22:49:37 +02:00
@Override
public void onCustomTabsConnected() {
if(customTabsSession == null) {
AppLog.i(this, "CustomTabs warmup: "+customTabActivityHelper.warmup(0));
2016-09-21 22:49:37 +02:00
customTabsSession = customTabActivityHelper.getSession();
}
}
@Override
public void onCustomTabsDisconnected() {
}
2016-03-03 17:46:31 +01:00
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
AppLog.v(this, "onNavigationItemsSelected()");
2016-03-03 17:46:31 +01:00
// Handle navigation view item clicks here.
switch (item.getItemId()) {
case R.id.nav_stream: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getStreamUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
2016-03-03 17:46:31 +01:00
}
break;
2016-03-03 17:46:31 +01:00
2016-08-10 17:47:21 +02:00
case R.id.nav_profile: {
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getProfileUrl());
2016-08-10 17:47:21 +02:00
} else {
snackbarNoInternet.show();
}
}
break;
case R.id.nav_followed_tags: {
2016-09-30 23:15:10 +02:00
showFragment(getFragment(HashtagListFragment.TAG));
2016-03-03 17:46:31 +01:00
}
break;
2016-03-03 17:46:31 +01:00
//TODO: Replace with fragment
case R.id.nav_aspects: {
2016-09-28 21:43:25 +02:00
DiasporaStreamFragment stream = (DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG);
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(DiasporaUrlHelper.URL_BLANK);
2016-09-28 21:43:25 +02:00
WebHelper.showAspectList(stream.getWebView(), app);
setTitle(R.string.aspects);
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
2016-03-03 17:46:31 +01:00
}
break;
2016-03-03 17:46:31 +01:00
case R.id.nav_activities: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getActivityUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
2016-03-03 17:46:31 +01:00
}
break;
2016-03-03 17:46:31 +01:00
case R.id.nav_liked: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getLikedPostsUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
2016-03-03 17:46:31 +01:00
}
break;
2016-03-03 17:46:31 +01:00
case R.id.nav_commented: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getCommentedUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
2016-03-03 17:46:31 +01:00
}
break;
2016-03-03 17:46:31 +01:00
case R.id.nav_mentions: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getMentionsUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
break;
2016-03-03 17:46:31 +01:00
}
case R.id.nav_public: {
2016-08-07 14:29:52 +02:00
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getPublicUrl());
} else {
2016-06-24 13:31:01 +02:00
snackbarNoInternet.show();
}
break;
}
case R.id.nav_exit: {
moveTaskToBack(true);
finish();
break;
}
2016-03-03 17:46:31 +01:00
case R.id.nav_settings: {
startActivity(new Intent(this, SettingsActivity.class));
}
break;
2016-03-08 15:42:02 +01:00
2016-09-28 21:43:25 +02:00
case R.id.nav_about: {
startActivity(new Intent(MainActivity.this, AboutActivity.class));
2016-03-08 15:42:02 +01:00
}
break;
2016-03-03 17:46:31 +01:00
}
2016-07-31 15:16:22 +02:00
navDrawer.closeDrawer(GravityCompat.START);
2016-03-03 17:46:31 +01:00
return true;
}
/**
* React to results of requestPermission
* @param requestCode resCode
* @param permissions requested permissions
* @param grantResults granted results
*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case REQUEST_CODE__ACCESS_EXTERNAL_STORAGE:
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
AppLog.i(this, "onRequestPermissionsResult: Permission to access external storage granted");
Toast.makeText(this, R.string.permission_granted_try_again, Toast.LENGTH_SHORT).show();
} else {
AppLog.w(this, "onRequestPermissionsResult: Permission to access external storage denied");
Toast.makeText(this, R.string.permission_denied, Toast.LENGTH_SHORT).show();
}
return;
default:
super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
}
}
/**
* Return the string that will be shared into the new-post-editor
* @return String
*/
public String getTextToBeShared() {
return textToBeShared;
}
/**
* Set the string that will be shared into the new-post-editor
* @param textToBeShared
*/
public void setTextToBeShared(String textToBeShared) {
this.textToBeShared = textToBeShared;
}
Proxy tor preset Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2 Fix view intent Update TR; Update buildToolsVersion -> 24.0.2 Update ISSUE_TEMPLATE.md Update README.md Switch ic_launcher back to png Replace blowball image on splash with character Reworked UI using Fragments Merge branch 'master' into rework_fragments Update README.md Fixed top/bottom menu entry population Added HashtagFragment Moved WebClients and ChromeClients to webview package Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment Merge branch 'master' into rework_fragments Handle Intent.Action.Main in handleIntent() Update strings-about.xml Fixed image sharing to other apps Get title for image sharing dialog from resources instead of using hardcoded string. Also do not show multiple permission dialogs stacked Removed test Fragments and old SplashActivity related stuff Merge branch 'master' into rework_fragments Added some documentation to MainActivity Fixed clear webview cache. Thanks @di72nn Only set window title depending on webviews content, when DiasporaStreamFragment is displayed (do not overwrite other fragments title when the webview loads in the background) Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Proxy tor preset Reworked custom themes Set customtab color Do not open load the stream when clicked on toolbar Added note about customtabs and proxys. Fixes #77 Resolved merge conflicts Removed duplicate method getAppSettings Fixed default color was id instead of color value bug Update TR Some improvements of code quality Moved colorpicker repo up Fixed applying of settings Fixed bug causing ClassCastException Moved ThemeHelper and ColorPalette to util.theming Added missing license headers to source files Merge branch 'master' into proper-themes Apply nav-slider entry visibilities in onResume SettingsActivity: Switched to Toolbar and fixed toolbar color issue Fixed BrowserFragment reloading in onResume and added credits to LeafPic Added reference to ColorPicker in 3rd party licenses and updated support libraries Merged master Fixed applying proxy settings Merged master proxy changes Fixed nav slider layout color issue Merge branch 'proper-themes' of github.com:Diaspora-for-Android/diaspora-android into proper-themes
2016-10-13 16:56:31 +02:00
@Override
protected void applyColorToViews() {
ThemeHelper.updateToolbarColor(toolbarTop);
ThemeHelper.updateActionMenuViewColor(toolbarBottom);
navDrawerLayout.setBackgroundColor(appSettings.getPrimaryColor());
navProfilePictureArea.setBackgroundColor(appSettings.getPrimaryColor());
}
@Override
public void enableToolbarHiding() {
AppLog.d(this, "Enable Intellihide");
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
//scroll|enterAlways|snap
params.setScrollFlags(toolbarDefaultScrollFlags);
appBarLayout.setExpanded(true, true);
}
@Override
public void disableToolbarHiding() {
AppLog.d(this, "Disable Intellihide");
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
params.setScrollFlags(0); // clear all scroll flags
appBarLayout.setExpanded(true, true);
}
2016-10-13 17:51:35 +02:00
}