2017-10-17 13:13:35 +02:00
|
|
|
/* Copyright 2017 Thomas Schneider
|
|
|
|
*
|
|
|
|
* This file is a part of Mastalab
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Mastalab is distributed in the hope that it will be useful, 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 Mastalab; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
package fr.gouv.etalab.mastodon.activities;
|
|
|
|
|
2018-01-06 17:13:18 +01:00
|
|
|
import android.Manifest;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2018-01-03 15:25:35 +01:00
|
|
|
import android.app.ActivityManager;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.content.SharedPreferences;
|
2018-01-06 17:13:18 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.AsyncTask;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.annotation.NonNull;
|
2017-11-02 15:22:47 +01:00
|
|
|
import android.support.design.widget.AppBarLayout;
|
2017-10-27 18:05:57 +02:00
|
|
|
import android.support.design.widget.FloatingActionButton;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.support.design.widget.TabLayout;
|
2018-01-06 17:13:18 +01:00
|
|
|
import android.support.v4.app.ActivityCompat;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
|
import android.support.v4.content.ContextCompat;
|
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
|
import android.support.v7.widget.PopupMenu;
|
|
|
|
import android.support.v7.widget.SearchView;
|
|
|
|
import android.support.v7.widget.SwitchCompat;
|
2018-05-13 15:50:48 +02:00
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.TextWatcher;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.util.Patterns;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.View;
|
|
|
|
import android.support.design.widget.NavigationView;
|
|
|
|
import android.support.v4.view.GravityCompat;
|
|
|
|
import android.support.v4.widget.DrawerLayout;
|
|
|
|
import android.support.v7.app.ActionBarDrawerToggle;
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2017-11-22 19:09:22 +01:00
|
|
|
import android.widget.EditText;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
import android.widget.SeekBar;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
2017-12-20 09:33:32 +01:00
|
|
|
import java.util.List;
|
2017-10-17 13:13:35 +02:00
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Stack;
|
|
|
|
import java.util.regex.Matcher;
|
2018-05-13 15:50:48 +02:00
|
|
|
import java.util.regex.Pattern;
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2017-11-12 08:33:24 +01:00
|
|
|
import fr.gouv.etalab.mastodon.R;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveInstanceAsyncTask;
|
|
|
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMetaDataAsyncTask;
|
2017-12-20 09:33:32 +01:00
|
|
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteDataAsyncTask;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
|
|
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
|
|
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
|
|
|
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
2017-12-20 09:33:32 +01:00
|
|
|
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
|
|
|
import fr.gouv.etalab.mastodon.client.Entities.Version;
|
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
2018-02-15 15:27:46 +01:00
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayBookmarksFragment;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayDraftsFragment;
|
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayFollowRequestSentFragment;
|
2017-12-13 18:04:29 +01:00
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayListsFragment;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayNotificationsFragment;
|
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayScheduledTootsFragment;
|
2017-11-23 18:16:47 +01:00
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplaySearchFragment;
|
2018-08-16 11:03:20 +02:00
|
|
|
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
|
|
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
|
|
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMetaDataInterface;
|
2017-12-20 09:33:32 +01:00
|
|
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.interfaces.OnUpdateAccountInfoInterface;
|
2018-01-06 17:13:18 +01:00
|
|
|
import fr.gouv.etalab.mastodon.services.BackupStatusService;
|
2017-11-12 08:33:24 +01:00
|
|
|
import fr.gouv.etalab.mastodon.services.LiveNotificationService;
|
2017-10-17 13:13:35 +02:00
|
|
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
|
|
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
|
|
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
|
|
|
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
|
|
|
import fr.gouv.etalab.mastodon.fragments.TabLayoutSettingsFragment;
|
|
|
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
|
|
|
|
2017-12-08 07:22:42 +01:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.ADD_USER_INTENT;
|
2018-02-17 15:42:09 +01:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.BACKUP_INTENT;
|
2017-10-17 13:13:35 +02:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_USER_INTENT;
|
2018-01-06 17:13:18 +01:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
2017-10-17 13:13:35 +02:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
2018-01-06 14:07:49 +01:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_TARGETED_ACCOUNT;
|
2017-10-17 13:13:35 +02:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
|
2018-08-14 11:47:26 +02:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.SEARCH_KEYWORD;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.SEARCH_TAG;
|
2018-05-11 13:53:08 +02:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK;
|
2017-10-17 13:13:35 +02:00
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.unCheckAllMenuItems;
|
|
|
|
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
|
|
|
|
import android.support.v4.app.FragmentStatePagerAdapter;
|
|
|
|
|
|
|
|
|
2017-12-12 18:17:01 +01:00
|
|
|
public abstract class BaseMainActivity extends BaseActivity
|
2017-12-20 09:33:32 +01:00
|
|
|
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface, OnRetrieveRemoteAccountInterface {
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2017-11-23 18:16:47 +01:00
|
|
|
private FloatingActionButton toot, delete_all, add_new;
|
2017-10-17 13:13:35 +02:00
|
|
|
private HashMap<String, String> tagTile = new HashMap<>();
|
|
|
|
private HashMap<String, Integer> tagItem = new HashMap<>();
|
|
|
|
private TextView toolbarTitle;
|
|
|
|
private SearchView toolbar_search;
|
|
|
|
private View headerLayout;
|
|
|
|
public static String currentLocale;
|
|
|
|
private TabLayout tabLayout;
|
|
|
|
private ViewPager viewPager;
|
|
|
|
private RelativeLayout main_app_container;
|
|
|
|
private Stack<Integer> stackBack = new Stack<>();
|
|
|
|
|
|
|
|
private DisplayStatusFragment homeFragment, federatedFragment, localFragment;
|
|
|
|
private DisplayNotificationsFragment notificationsFragment;
|
|
|
|
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
2018-01-02 10:58:29 +01:00
|
|
|
private static BroadcastReceiver receive_data, receive_federated_data, receive_local_data;
|
2017-10-17 13:13:35 +02:00
|
|
|
private boolean display_local, display_global;
|
|
|
|
public static int countNewStatus = 0;
|
|
|
|
public static int countNewNotifications = 0;
|
|
|
|
private String userIdService;
|
|
|
|
public static String lastHomeId = null, lastNotificationId = null;
|
|
|
|
boolean notif_follow, notif_add, notif_mention, notif_share, show_boosts, show_replies;
|
2017-11-22 19:09:22 +01:00
|
|
|
String show_filtered;
|
2017-11-02 15:22:47 +01:00
|
|
|
private AppBarLayout appBar;
|
2017-11-11 07:26:52 +01:00
|
|
|
private static boolean activityPaused;
|
2017-12-06 16:45:07 +01:00
|
|
|
private String bookmark;
|
2017-12-28 17:25:36 +01:00
|
|
|
private String userId;
|
|
|
|
private String instance;
|
2018-08-14 11:10:49 +02:00
|
|
|
public int countPage;
|
|
|
|
private PagerAdapter adapter;
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
|
|
|
|
|
|
|
|
|
|
|
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
2018-05-11 11:28:05 +02:00
|
|
|
switch (theme){
|
|
|
|
case Helper.THEME_LIGHT:
|
|
|
|
setTheme(R.style.AppTheme_NoActionBar);
|
|
|
|
break;
|
|
|
|
case Helper.THEME_DARK:
|
|
|
|
setTheme(R.style.AppThemeDark_NoActionBar);
|
|
|
|
break;
|
|
|
|
case Helper.THEME_BLACK:
|
|
|
|
setTheme(R.style.AppThemeBlack_NoActionBar);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
setTheme(R.style.AppThemeDark_NoActionBar);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
|
|
display_local = sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true);
|
|
|
|
display_global = sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true);
|
|
|
|
|
|
|
|
//Test if user is still log in
|
|
|
|
if( ! Helper.isLoggedIn(getApplicationContext())) {
|
|
|
|
//It is not, the user is redirected to the login page
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rateThisApp();
|
|
|
|
|
|
|
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
|
|
Helper.canPin = false;
|
|
|
|
Helper.fillMapEmoji(getApplicationContext());
|
|
|
|
//Here, the user is authenticated
|
2017-11-02 15:22:47 +01:00
|
|
|
appBar = findViewById(R.id.appBar);
|
2017-10-21 16:56:17 +02:00
|
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
2018-05-11 13:53:08 +02:00
|
|
|
if( theme == THEME_BLACK)
|
|
|
|
toolbar.setBackgroundColor(ContextCompat.getColor(BaseMainActivity.this, R.color.black));
|
2017-10-17 13:13:35 +02:00
|
|
|
setSupportActionBar(toolbar);
|
2017-10-21 16:56:17 +02:00
|
|
|
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
|
|
|
toolbar_search = toolbar.findViewById(R.id.toolbar_search);
|
|
|
|
tabLayout = findViewById(R.id.tabLayout);
|
2017-10-17 13:13:35 +02:00
|
|
|
TabLayout.Tab tabHome = tabLayout.newTab();
|
|
|
|
TabLayout.Tab tabNotif = tabLayout.newTab();
|
|
|
|
TabLayout.Tab tabLocal = tabLayout.newTab();
|
|
|
|
TabLayout.Tab tabPublic = tabLayout.newTab();
|
|
|
|
tabHome.setCustomView(R.layout.tab_badge);
|
|
|
|
tabNotif.setCustomView(R.layout.tab_badge);
|
|
|
|
tabLocal.setCustomView(R.layout.tab_badge);
|
|
|
|
tabPublic.setCustomView(R.layout.tab_badge);
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
2017-10-21 16:56:17 +02:00
|
|
|
ImageView iconHome = tabHome.getCustomView().findViewById(R.id.tab_icon);
|
2017-10-17 13:13:35 +02:00
|
|
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2017-10-28 14:32:18 +02:00
|
|
|
iconHome.setImageResource(R.drawable.ic_home);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2018-05-11 13:53:08 +02:00
|
|
|
if( theme == THEME_BLACK)
|
|
|
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
|
|
|
else
|
|
|
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN);
|
2017-11-02 14:44:14 +01:00
|
|
|
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
2017-10-21 16:56:17 +02:00
|
|
|
ImageView iconNotif = tabNotif.getCustomView().findViewById(R.id.tab_icon);
|
2017-10-17 13:13:35 +02:00
|
|
|
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2017-10-28 14:32:18 +02:00
|
|
|
iconNotif.setImageResource(R.drawable.ic_notifications);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
2017-10-21 16:56:17 +02:00
|
|
|
ImageView iconLocal = tabLocal.getCustomView().findViewById(R.id.tab_icon);
|
2017-10-17 13:13:35 +02:00
|
|
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2017-10-28 14:32:18 +02:00
|
|
|
iconLocal.setImageResource(R.drawable.ic_people);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
2017-10-21 16:56:17 +02:00
|
|
|
ImageView iconGlobal = tabPublic.getCustomView().findViewById(R.id.tab_icon);
|
2017-10-17 13:13:35 +02:00
|
|
|
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2017-10-28 14:32:18 +02:00
|
|
|
iconGlobal.setImageResource(R.drawable.ic_public);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2018-08-20 19:00:20 +02:00
|
|
|
FloatingActionButton federatedTimelines = findViewById(R.id.federated_timeline);
|
|
|
|
|
|
|
|
federatedTimelines.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), InstanceFederatedActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-28 14:32:18 +02:00
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_home,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_notifications,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_people,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_public,R.color.dark_text);
|
2018-01-03 15:25:35 +01:00
|
|
|
startSreaming();
|
2017-10-17 13:13:35 +02:00
|
|
|
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
|
|
|
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
|
|
|
|
2018-08-19 14:54:36 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
tabLayout.addTab(tabHome);
|
|
|
|
tabLayout.addTab(tabNotif);
|
|
|
|
if( display_local)
|
|
|
|
tabLayout.addTab(tabLocal);
|
|
|
|
if( display_global)
|
|
|
|
tabLayout.addTab(tabPublic);
|
2018-08-19 14:54:36 +02:00
|
|
|
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
//Display filter for notification when long pressing the tab
|
|
|
|
final LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
|
|
|
tabStrip.getChildAt(1).setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
//Only shown if the tab has focus
|
|
|
|
if( notificationsFragment != null && notificationsFragment.getUserVisibleHint()){
|
|
|
|
PopupMenu popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(1));
|
|
|
|
popup.getMenuInflater()
|
|
|
|
.inflate(R.menu.option_filter_notifications, popup.getMenu());
|
|
|
|
Menu menu = popup.getMenu();
|
|
|
|
final MenuItem itemFavourite = menu.findItem(R.id.action_favorite);
|
|
|
|
final MenuItem itemFollow = menu.findItem(R.id.action_follow);
|
|
|
|
final MenuItem itemMention = menu.findItem(R.id.action_mention);
|
|
|
|
final MenuItem itemBoost = menu.findItem(R.id.action_boost);
|
2017-11-01 10:09:04 +01:00
|
|
|
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, true);
|
|
|
|
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD_FILTER, true);
|
|
|
|
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true);
|
|
|
|
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true);
|
2017-10-17 13:13:35 +02:00
|
|
|
itemFavourite.setChecked(notif_add);
|
|
|
|
itemFollow.setChecked(notif_follow);
|
|
|
|
itemMention.setChecked(notif_mention);
|
|
|
|
itemBoost.setChecked(notif_share);
|
|
|
|
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
|
|
|
@Override
|
|
|
|
public void onDismiss(PopupMenu menu) {
|
|
|
|
if( notificationsFragment != null)
|
|
|
|
notificationsFragment.refreshAll();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
|
|
item.setActionView(new View(getApplicationContext()));
|
|
|
|
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_favorite:
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
notif_add = !notif_add;
|
2017-11-01 10:09:04 +01:00
|
|
|
editor.putBoolean(Helper.SET_NOTIF_ADD_FILTER, notif_add);
|
2017-10-17 13:13:35 +02:00
|
|
|
itemFavourite.setChecked(notif_add);
|
|
|
|
editor.apply();
|
|
|
|
break;
|
|
|
|
case R.id.action_follow:
|
|
|
|
editor = sharedpreferences.edit();
|
|
|
|
notif_follow = !notif_follow;
|
2017-11-01 10:09:04 +01:00
|
|
|
editor.putBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, notif_follow);
|
2017-10-17 13:13:35 +02:00
|
|
|
itemFollow.setChecked(notif_follow);
|
|
|
|
editor.apply();
|
|
|
|
break;
|
|
|
|
case R.id.action_mention:
|
|
|
|
editor = sharedpreferences.edit();
|
|
|
|
notif_mention = !notif_mention;
|
2017-11-01 10:09:04 +01:00
|
|
|
editor.putBoolean(Helper.SET_NOTIF_MENTION_FILTER, notif_mention);
|
2017-10-17 13:13:35 +02:00
|
|
|
itemMention.setChecked(notif_mention);
|
|
|
|
editor.apply();
|
|
|
|
break;
|
|
|
|
case R.id.action_boost:
|
|
|
|
editor = sharedpreferences.edit();
|
|
|
|
notif_share = !notif_share;
|
2017-11-01 10:09:04 +01:00
|
|
|
editor.putBoolean(Helper.SET_NOTIF_SHARE_FILTER, notif_share);
|
2017-10-17 13:13:35 +02:00
|
|
|
itemBoost.setChecked(notif_share);
|
|
|
|
editor.apply();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
popup.show();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
tabStrip.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
2017-11-22 19:29:53 +01:00
|
|
|
return manageFilters(tabStrip, sharedpreferences);
|
|
|
|
}
|
|
|
|
});
|
2017-11-22 19:09:22 +01:00
|
|
|
|
2017-11-22 19:29:53 +01:00
|
|
|
if( tabStrip.getChildCount() > 2)
|
|
|
|
tabStrip.getChildAt(2).setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
return manageFilters(tabStrip, sharedpreferences);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if( tabStrip.getChildCount() == 4)
|
|
|
|
tabStrip.getChildAt(3).setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
return manageFilters(tabStrip, sharedpreferences);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-11-22 19:29:53 +01:00
|
|
|
|
2017-10-21 16:56:17 +02:00
|
|
|
viewPager = findViewById(R.id.viewpager);
|
2018-08-14 11:10:49 +02:00
|
|
|
countPage = 2;
|
2017-10-17 13:13:35 +02:00
|
|
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
|
|
|
|
countPage++;
|
|
|
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true))
|
|
|
|
countPage++;
|
|
|
|
viewPager.setOffscreenPageLimit(countPage);
|
2017-10-21 16:56:17 +02:00
|
|
|
main_app_container = findViewById(R.id.main_app_container);
|
2018-08-14 11:10:49 +02:00
|
|
|
adapter = new PagerAdapter
|
2017-10-17 13:13:35 +02:00
|
|
|
(getSupportFragmentManager(), tabLayout.getTabCount());
|
|
|
|
viewPager.setAdapter(adapter);
|
|
|
|
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
|
|
|
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
|
|
@Override
|
|
|
|
public void onTabSelected(TabLayout.Tab tab) {
|
|
|
|
viewPager.setCurrentItem(tab.getPosition());
|
|
|
|
if (stackBack.empty())
|
|
|
|
stackBack.push(0);
|
|
|
|
if (stackBack.contains(tab.getPosition())) {
|
|
|
|
stackBack.remove(stackBack.indexOf(tab.getPosition()));
|
|
|
|
stackBack.push(tab.getPosition());
|
|
|
|
} else {
|
|
|
|
stackBack.push(tab.getPosition());
|
|
|
|
}
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
2017-10-27 18:05:57 +02:00
|
|
|
if( tab.getPosition() != 1 )
|
|
|
|
toot.setVisibility(View.VISIBLE);
|
|
|
|
else
|
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-21 16:56:17 +02:00
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
2017-10-17 13:13:35 +02:00
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
2017-11-02 14:44:14 +01:00
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2018-05-11 13:53:08 +02:00
|
|
|
if( theme == THEME_BLACK)
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
|
|
|
else
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN);
|
|
|
|
|
2017-11-02 14:44:14 +01:00
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTabUnselected(TabLayout.Tab tab) {
|
2017-11-02 14:44:14 +01:00
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.white), PorterDuff.Mode.SRC_IN);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTabReselected(TabLayout.Tab tab) {
|
|
|
|
if( viewPager.getVisibility() == View.GONE){
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
2017-10-21 16:56:17 +02:00
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
2017-10-17 13:13:35 +02:00
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
}
|
2017-10-27 18:05:57 +02:00
|
|
|
if( tab.getPosition() != 1 )
|
|
|
|
toot.setVisibility(View.VISIBLE);
|
|
|
|
else
|
|
|
|
toot.setVisibility(View.GONE);
|
2017-11-11 14:39:33 +01:00
|
|
|
if( viewPager.getAdapter() != null) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition());
|
|
|
|
switch (tab.getPosition()) {
|
|
|
|
case 0:
|
|
|
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
countNewStatus = 0;
|
|
|
|
updateHomeCounter();
|
2017-10-17 13:13:35 +02:00
|
|
|
displayStatusFragment.scrollToTop();
|
2017-11-11 14:39:33 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (display_local)
|
|
|
|
updateTimeLine(RetrieveFeedsAsyncTask.Type.LOCAL, 0);
|
|
|
|
else if (display_global)
|
|
|
|
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
|
|
|
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
2017-10-26 09:06:24 +02:00
|
|
|
displayStatusFragment.scrollToTop();
|
2017-11-11 14:39:33 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
2017-10-17 13:13:35 +02:00
|
|
|
displayStatusFragment.scrollToTop();
|
2017-11-11 14:39:33 +01:00
|
|
|
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
|
|
|
countNewNotifications = 0;
|
|
|
|
updateNotifCounter();
|
2017-10-17 13:13:35 +02:00
|
|
|
displayNotificationsFragment.scrollToTop();
|
2017-11-11 14:39:33 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-08-19 14:54:36 +02:00
|
|
|
refreshSearchTab();
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2017-10-17 13:13:35 +02:00
|
|
|
navigationView.setNavigationItemSelectedListener(this);
|
|
|
|
|
|
|
|
|
|
|
|
//Scroll to top when top bar is clicked for favourites/blocked/muted
|
|
|
|
toolbarTitle.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
if( navigationView.getMenu().findItem(R.id.nav_favorites) != null && navigationView.getMenu().findItem(R.id.nav_favorites).isChecked()){
|
|
|
|
DisplayStatusFragment faveFrag = (DisplayStatusFragment) fragmentManager.findFragmentByTag("FAVOURITES");
|
|
|
|
if (faveFrag != null && faveFrag.isVisible()) {
|
|
|
|
faveFrag.scrollToTop();
|
|
|
|
}
|
|
|
|
} else if (navigationView.getMenu().findItem(R.id.nav_blocked) != null && navigationView.getMenu().findItem(R.id.nav_blocked).isChecked()) {
|
|
|
|
DisplayAccountsFragment blockFrag = (DisplayAccountsFragment) fragmentManager.findFragmentByTag("BLOCKS");
|
|
|
|
|
|
|
|
if (blockFrag != null && blockFrag.isVisible()) {
|
|
|
|
blockFrag.scrollToTop();
|
|
|
|
}
|
|
|
|
} else if (navigationView.getMenu().findItem(R.id.nav_muted) != null && navigationView.getMenu().findItem(R.id.nav_muted).isChecked()) {
|
|
|
|
DisplayAccountsFragment muteFrag = (DisplayAccountsFragment) fragmentManager.findFragmentByTag("MUTED");
|
|
|
|
|
|
|
|
if (muteFrag != null && muteFrag.isVisible()) {
|
|
|
|
muteFrag.scrollToTop();
|
|
|
|
}
|
2017-10-27 18:05:57 +02:00
|
|
|
//Scroll to top when top bar is clicked (THEME_MENU only)
|
2017-10-17 13:13:35 +02:00
|
|
|
} else {
|
|
|
|
int pos = tabLayout.getSelectedTabPosition();
|
2017-11-11 14:39:33 +01:00
|
|
|
if( viewPager.getAdapter() != null) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, pos);
|
|
|
|
switch (pos) {
|
|
|
|
case 0:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
2017-10-17 13:13:35 +02:00
|
|
|
displayStatusFragment.scrollToTop();
|
2017-11-11 14:39:33 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
2017-10-17 13:13:35 +02:00
|
|
|
displayNotificationsFragment.scrollToTop();
|
2017-11-11 14:39:33 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onQueryTextSubmit(String query) {
|
|
|
|
//Hide keyboard
|
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
2017-10-27 15:34:53 +02:00
|
|
|
assert imm != null;
|
2017-10-17 13:13:35 +02:00
|
|
|
imm.hideSoftInputFromWindow(toolbar_search.getWindowToken(), 0);
|
|
|
|
Intent intent = new Intent(BaseMainActivity.this, SearchResultActivity.class);
|
2017-11-27 10:03:08 +01:00
|
|
|
query= query.replaceAll("^#+", "");
|
2017-10-17 13:13:35 +02:00
|
|
|
intent.putExtra("search", query);
|
|
|
|
startActivity(intent);
|
|
|
|
toolbar_search.setQuery("", false);
|
|
|
|
toolbar_search.setIconified(true);
|
2018-08-14 13:42:13 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public boolean onQueryTextChange(String newText) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//Hide/Close the searchview
|
|
|
|
|
|
|
|
|
|
|
|
toolbar_search.setOnCloseListener(new SearchView.OnCloseListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onClose() {
|
|
|
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
//your code here
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
toolbar_search.setOnSearchClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
if( toolbar_search.isIconified()){
|
|
|
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//Hide the default title
|
2018-05-11 13:53:08 +02:00
|
|
|
if( getSupportActionBar() != null) {
|
2017-10-17 13:13:35 +02:00
|
|
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
2018-05-11 13:53:08 +02:00
|
|
|
getSupportActionBar().getThemedContext().setTheme(R.style.AppThemeBlack);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
//Defines the current locale of the device in a static variable
|
|
|
|
currentLocale = Helper.currentLocale(getApplicationContext());
|
|
|
|
|
2017-10-27 18:05:57 +02:00
|
|
|
toot = findViewById(R.id.toot);
|
2017-10-30 07:54:02 +01:00
|
|
|
delete_all = findViewById(R.id.delete_all);
|
2017-11-23 18:16:47 +01:00
|
|
|
add_new = findViewById(R.id.add_new);
|
2017-10-17 13:13:35 +02:00
|
|
|
toot.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), TootActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-12-28 17:25:36 +01:00
|
|
|
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
|
|
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
|
|
|
|
2017-12-06 16:45:07 +01:00
|
|
|
//Get the previous bookmark value
|
2017-12-08 19:36:26 +01:00
|
|
|
//If null try to use the LAST_HOMETIMELINE_MAX_ID
|
2017-12-28 17:25:36 +01:00
|
|
|
String lastHomeTimeline = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId + instance, null);
|
|
|
|
bookmark = sharedpreferences.getString(Helper.BOOKMARK_ID + userId + instance, lastHomeTimeline);
|
2017-10-17 13:13:35 +02:00
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
2017-11-18 14:10:53 +01:00
|
|
|
if( account == null){
|
|
|
|
Helper.logout(getApplicationContext());
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
//Image loader configuration
|
|
|
|
|
2017-10-21 16:56:17 +02:00
|
|
|
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
|
|
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
|
|
|
toggle.setDrawerIndicatorEnabled(false);
|
2017-10-21 16:56:17 +02:00
|
|
|
ImageView iconbar = toolbar.findViewById(R.id.iconbar);
|
2017-10-17 13:13:35 +02:00
|
|
|
iconbar.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
drawer.openDrawer(Gravity.START);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Helper.loadPictureIcon(BaseMainActivity.this, account.getAvatar(),iconbar);
|
|
|
|
headerLayout = navigationView.getHeaderView(0);
|
|
|
|
mamageNewIntent(getIntent());
|
2017-10-21 16:56:17 +02:00
|
|
|
final ImageView menuMore = headerLayout.findViewById(R.id.header_option_menu);
|
2017-10-17 13:13:35 +02:00
|
|
|
menuMore.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
PopupMenu popup = new PopupMenu(BaseMainActivity.this, menuMore);
|
|
|
|
popup.getMenuInflater()
|
|
|
|
.inflate(R.menu.main, popup.getMenu());
|
|
|
|
|
|
|
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_logout:
|
|
|
|
Helper.logout(getApplicationContext());
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
finish();
|
|
|
|
return true;
|
|
|
|
case R.id.action_about:
|
|
|
|
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
case R.id.action_privacy:
|
|
|
|
intent = new Intent(getApplicationContext(), PrivacyActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
case R.id.action_about_instance:
|
|
|
|
intent = new Intent(getApplicationContext(), InstanceActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
case R.id.action_cache:
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(BaseMainActivity.this);
|
|
|
|
builder.setTitle(R.string.cache_title);
|
|
|
|
long sizeCache = Helper.cacheSize(getCacheDir());
|
|
|
|
float cacheSize = 0;
|
|
|
|
if( sizeCache > 0 ) {
|
2018-08-14 11:47:26 +02:00
|
|
|
cacheSize = (float) sizeCache / 1000000.0f;
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
final float finalCacheSize = cacheSize;
|
|
|
|
builder.setMessage(getString(R.string.cache_message, String.format("%s %s", String.format(Locale.getDefault(), "%.2f", cacheSize), getString(R.string.cache_units))))
|
|
|
|
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// continue with delete
|
|
|
|
try {
|
|
|
|
String path = getCacheDir().getPath();
|
|
|
|
File dir = new File(path);
|
|
|
|
if (dir.isDirectory()) {
|
|
|
|
Helper.deleteDir(dir);
|
|
|
|
}
|
|
|
|
} catch (Exception ignored) {}
|
|
|
|
Toast.makeText(BaseMainActivity.this, getString(R.string.toast_cache_clear,String.format("%s %s", String.format(Locale.getDefault(), "%.2f", finalCacheSize), getString(R.string.cache_units))), Toast.LENGTH_LONG).show();
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
|
|
.show();
|
|
|
|
return true;
|
|
|
|
case R.id.action_size:
|
|
|
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
|
|
int textSize = sharedpreferences.getInt(Helper.SET_TEXT_SIZE,110);
|
|
|
|
int iconSize = sharedpreferences.getInt(Helper.SET_ICON_SIZE,130);
|
|
|
|
|
|
|
|
builder = new AlertDialog.Builder(BaseMainActivity.this);
|
|
|
|
builder.setTitle(R.string.text_size);
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams") View popup_quick_settings = getLayoutInflater().inflate( R.layout.popup_text_size, null );
|
|
|
|
builder.setView(popup_quick_settings);
|
|
|
|
|
2017-10-21 16:56:17 +02:00
|
|
|
SeekBar set_text_size = popup_quick_settings.findViewById(R.id.set_text_size);
|
|
|
|
SeekBar set_icon_size = popup_quick_settings.findViewById(R.id.set_icon_size);
|
|
|
|
final TextView set_text_size_value = popup_quick_settings.findViewById(R.id.set_text_size_value);
|
|
|
|
final TextView set_icon_size_value = popup_quick_settings.findViewById(R.id.set_icon_size_value);
|
2017-10-17 13:13:35 +02:00
|
|
|
set_text_size_value.setText(String.format("%s%%",String.valueOf(textSize)));
|
|
|
|
set_icon_size_value.setText(String.format("%s%%",String.valueOf(iconSize)));
|
|
|
|
|
|
|
|
set_text_size.setMax(20);
|
|
|
|
set_icon_size.setMax(20);
|
|
|
|
|
|
|
|
set_text_size.setProgress(((textSize-80)/5));
|
|
|
|
set_icon_size.setProgress(((iconSize-80)/5));
|
|
|
|
|
|
|
|
set_text_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onStopTrackingTouch(SeekBar seekBar) {}
|
|
|
|
@Override
|
|
|
|
public void onStartTrackingTouch(SeekBar seekBar) {}
|
|
|
|
@Override
|
|
|
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
|
|
|
|
|
|
int value = 80 + progress*5;
|
|
|
|
set_text_size_value.setText(String.format("%s%%",String.valueOf(value)));
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putInt(Helper.SET_TEXT_SIZE, value);
|
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
set_icon_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onStopTrackingTouch(SeekBar seekBar) {}
|
|
|
|
@Override
|
|
|
|
public void onStartTrackingTouch(SeekBar seekBar) {}
|
|
|
|
@Override
|
|
|
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
|
|
int value = 80 + progress*5;
|
|
|
|
set_icon_size_value.setText(String.format("%s%%",String.valueOf(value)));
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putInt(Helper.SET_ICON_SIZE, value);
|
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
BaseMainActivity.this.recreate();
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
|
|
.show();
|
|
|
|
return true;
|
2018-01-20 09:46:28 +01:00
|
|
|
case R.id.action_proxy:
|
|
|
|
intent = new Intent(getApplicationContext(), ProxyActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
2018-01-06 17:13:18 +01:00
|
|
|
case R.id.action_export:
|
|
|
|
if(Build.VERSION.SDK_INT >= 23 ){
|
|
|
|
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) {
|
|
|
|
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_REQUEST_CODE);
|
|
|
|
} else {
|
|
|
|
Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class);
|
|
|
|
backupIntent.putExtra("userId", userId);
|
|
|
|
startService(backupIntent);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class);
|
|
|
|
backupIntent.putExtra("userId", userId);
|
|
|
|
startService(backupIntent);
|
|
|
|
}
|
|
|
|
return true;
|
2017-10-17 13:13:35 +02:00
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
popup.show();
|
|
|
|
}
|
|
|
|
});
|
2017-11-25 11:01:34 +01:00
|
|
|
final ImageView optionInfo = headerLayout.findViewById(R.id.header_option_info);
|
|
|
|
optionInfo.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), InstanceHealthActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
});
|
2017-12-02 11:02:25 +01:00
|
|
|
updateHeaderAccountInfo(BaseMainActivity.this, account, headerLayout);
|
2017-10-17 13:13:35 +02:00
|
|
|
//Locked account can see follow request
|
|
|
|
if (account.isLocked()) {
|
|
|
|
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
|
|
|
|
} else {
|
|
|
|
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
|
|
|
}
|
|
|
|
|
2017-12-13 18:04:29 +01:00
|
|
|
//Check instance release for lists
|
|
|
|
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userId + instance, null);
|
|
|
|
if (instanceVersion != null) {
|
|
|
|
Version currentVersion = new Version(instanceVersion);
|
|
|
|
Version minVersion = new Version("2.1");
|
|
|
|
if (currentVersion.compareTo(minVersion) == 1 || currentVersion.equals(minVersion)) {
|
|
|
|
navigationView.getMenu().findItem(R.id.nav_list).setVisible(true);
|
|
|
|
} else {
|
|
|
|
navigationView.getMenu().findItem(R.id.nav_list).setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-21 16:56:17 +02:00
|
|
|
LinearLayout owner_container = headerLayout.findViewById(R.id.main_header_container);
|
2017-10-17 13:13:35 +02:00
|
|
|
owner_container.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
menuAccounts(BaseMainActivity.this);
|
|
|
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-11-05 20:04:38 +01:00
|
|
|
// Asked once for notification opt-in
|
2017-10-17 13:13:35 +02:00
|
|
|
boolean popupShown = sharedpreferences.getBoolean(Helper.SET_POPUP_PUSH, false);
|
|
|
|
if(!popupShown){
|
|
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseMainActivity.this);
|
|
|
|
LayoutInflater inflater = getLayoutInflater();
|
|
|
|
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.popup_quick_settings, null);
|
|
|
|
dialogBuilder.setView(dialogView);
|
|
|
|
|
2017-10-21 16:56:17 +02:00
|
|
|
final SwitchCompat set_push_hometimeline = dialogView.findViewById(R.id.set_push_hometimeline);
|
|
|
|
final SwitchCompat set_push_notification = dialogView.findViewById(R.id.set_push_notification);
|
2018-01-20 10:23:05 +01:00
|
|
|
boolean notif_hometimeline = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, false);
|
2017-10-17 13:13:35 +02:00
|
|
|
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
|
|
|
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
|
|
|
boolean notif_ask = sharedpreferences.getBoolean(Helper.SET_NOTIF_ASK, true);
|
|
|
|
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
|
|
|
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
|
|
|
boolean notifif_notifications = !( !notif_follow && !notif_add && !notif_ask && !notif_mention && !notif_share);
|
|
|
|
set_push_hometimeline.setChecked(notif_hometimeline);
|
|
|
|
set_push_notification.setChecked(notifif_notifications);
|
|
|
|
|
|
|
|
dialogBuilder.setTitle(R.string.settings_popup_title);
|
|
|
|
dialogBuilder.setCancelable(false);
|
|
|
|
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_FOLLOW, set_push_notification.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_ADD, set_push_notification.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_ASK, set_push_notification.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_MENTION, set_push_notification.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_SHARE, set_push_notification.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_HOMETIMELINE, set_push_hometimeline.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_POPUP_PUSH, true);
|
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
}).show();
|
|
|
|
}
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
|
2018-01-02 10:58:29 +01:00
|
|
|
if( receive_data != null)
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_data);
|
2017-12-06 14:06:45 +01:00
|
|
|
receive_data = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Bundle b = intent.getExtras();
|
|
|
|
Helper.EventStreaming eventStreaming = (Helper.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
|
|
|
assert b != null;
|
|
|
|
userIdService = b.getString("userIdService", null);
|
|
|
|
if( userIdService != null && userIdService.equals(userId)) {
|
|
|
|
if (eventStreaming == Helper.EventStreaming.NOTIFICATION) {
|
|
|
|
Notification notification = b.getParcelable("data");
|
|
|
|
if (notificationsFragment != null) {
|
|
|
|
notificationsFragment.refresh(notification);
|
|
|
|
}
|
|
|
|
} else if (eventStreaming == Helper.EventStreaming.UPDATE) {
|
|
|
|
Status status = b.getParcelable("data");
|
|
|
|
if (homeFragment != null) {
|
|
|
|
homeFragment.refresh(status);
|
|
|
|
}
|
|
|
|
} else if (eventStreaming == Helper.EventStreaming.DELETE) {
|
|
|
|
//noinspection unused
|
|
|
|
String id = b.getString("id");
|
|
|
|
if (notificationsFragment != null) {
|
|
|
|
//noinspection StatementWithEmptyBody
|
|
|
|
if (notificationsFragment.getUserVisibleHint()) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateNotifCounter();
|
|
|
|
updateHomeCounter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-08-19 14:54:36 +02:00
|
|
|
|
2017-12-06 14:06:45 +01:00
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(receive_data, new IntentFilter(Helper.RECEIVE_DATA));
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
// Retrieves instance
|
|
|
|
new RetrieveInstanceAsyncTask(getApplicationContext(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}
|
|
|
|
|
2018-08-14 11:10:49 +02:00
|
|
|
public void refreshSearchTab(){
|
|
|
|
Helper.addSearchTag(BaseMainActivity.this, tabLayout, adapter);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2018-08-14 13:42:13 +02:00
|
|
|
public void removeSearchTab(String tag){
|
|
|
|
Helper.removeSearchTag(tag, tabLayout, adapter);
|
|
|
|
int allTabCount = tabLayout.getTabCount();
|
|
|
|
if( allTabCount == countPage){
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
protected abstract void rateThisApp();
|
|
|
|
|
|
|
|
|
2017-11-22 19:29:53 +01:00
|
|
|
private boolean manageFilters(LinearLayout tabStrip, final SharedPreferences sharedpreferences){
|
|
|
|
//Only shown if the tab has focus
|
|
|
|
if(
|
|
|
|
(homeFragment != null && homeFragment.getUserVisibleHint()) ||
|
|
|
|
(federatedFragment != null && federatedFragment.getUserVisibleHint()) ||
|
|
|
|
(localFragment != null && localFragment.getUserVisibleHint())
|
|
|
|
){
|
|
|
|
PopupMenu popup = null;
|
|
|
|
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
|
|
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(0));
|
|
|
|
else if(localFragment != null && localFragment.getUserVisibleHint())
|
|
|
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(2));
|
|
|
|
else if(federatedFragment != null && federatedFragment.getUserVisibleHint()){
|
|
|
|
if( !display_local && display_global)
|
|
|
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(2));
|
|
|
|
else
|
|
|
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(3));
|
|
|
|
}
|
|
|
|
if( popup == null)
|
|
|
|
return true;
|
|
|
|
popup.getMenuInflater()
|
|
|
|
.inflate(R.menu.option_filter_toots, popup.getMenu());
|
|
|
|
Menu menu = popup.getMenu();
|
|
|
|
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
|
|
|
|
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
|
|
|
|
final MenuItem itemFilter = menu.findItem(R.id.action_filter);
|
|
|
|
if((federatedFragment != null && federatedFragment.getUserVisibleHint()) ||
|
|
|
|
(localFragment != null && localFragment.getUserVisibleHint())){
|
|
|
|
itemShowBoosts.setVisible(false);
|
|
|
|
itemShowReplies.setVisible(false);
|
|
|
|
itemFilter.setVisible(true);
|
|
|
|
}else {
|
|
|
|
itemShowBoosts.setVisible(true);
|
|
|
|
itemShowReplies.setVisible(true);
|
|
|
|
itemFilter.setVisible(true);
|
|
|
|
}
|
|
|
|
show_boosts = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true);
|
|
|
|
show_replies = sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true);
|
|
|
|
|
|
|
|
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
|
|
|
show_filtered = sharedpreferences.getString(Helper.SET_FILTER_REGEX_HOME, null);
|
|
|
|
if(localFragment != null && localFragment.getUserVisibleHint())
|
|
|
|
show_filtered = sharedpreferences.getString(Helper.SET_FILTER_REGEX_LOCAL, null);
|
|
|
|
if(federatedFragment != null && federatedFragment.getUserVisibleHint())
|
|
|
|
show_filtered = sharedpreferences.getString(Helper.SET_FILTER_REGEX_PUBLIC, null);
|
|
|
|
|
|
|
|
itemShowBoosts.setChecked(show_boosts);
|
|
|
|
itemShowReplies.setChecked(show_replies);
|
|
|
|
if( show_filtered != null && show_filtered.length() > 0){
|
|
|
|
itemFilter.setTitle(show_filtered);
|
|
|
|
}
|
|
|
|
|
|
|
|
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
|
|
|
@Override
|
|
|
|
public void onDismiss(PopupMenu menu) {
|
|
|
|
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
|
|
|
homeFragment.refreshFilter();
|
|
|
|
if(localFragment != null && localFragment.getUserVisibleHint())
|
|
|
|
localFragment.refreshFilter();
|
|
|
|
if(federatedFragment != null && federatedFragment.getUserVisibleHint())
|
|
|
|
federatedFragment.refreshFilter();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
|
|
item.setActionView(new View(getApplicationContext()));
|
|
|
|
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
final SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_show_boosts:
|
|
|
|
show_boosts = !show_boosts;
|
|
|
|
editor.putBoolean(Helper.SET_SHOW_BOOSTS, show_boosts);
|
|
|
|
itemShowBoosts.setChecked(show_boosts);
|
|
|
|
editor.apply();
|
|
|
|
break;
|
|
|
|
case R.id.action_show_replies:
|
|
|
|
show_replies = !show_replies;
|
|
|
|
editor.putBoolean(Helper.SET_SHOW_REPLIES, show_replies);
|
|
|
|
itemShowReplies.setChecked(show_replies);
|
|
|
|
editor.apply();
|
|
|
|
break;
|
|
|
|
case R.id.action_filter:
|
|
|
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseMainActivity.this);
|
|
|
|
LayoutInflater inflater = getLayoutInflater();
|
|
|
|
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.filter_regex, null);
|
|
|
|
dialogBuilder.setView(dialogView);
|
|
|
|
final EditText editText = dialogView.findViewById(R.id.filter_regex);
|
2018-05-13 15:50:48 +02:00
|
|
|
Toast alertRegex = Toast.makeText(BaseMainActivity.this, R.string.alert_regex, Toast.LENGTH_LONG);
|
|
|
|
editText.addTextChangedListener(new TextWatcher() {
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
try {
|
|
|
|
//noinspection ResultOfMethodCallIgnored
|
|
|
|
Pattern.compile("(" + s.toString() + ")", Pattern.CASE_INSENSITIVE);
|
|
|
|
}catch (Exception e){
|
|
|
|
if( !alertRegex.getView().isShown()){
|
|
|
|
alertRegex.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2017-11-22 19:29:53 +01:00
|
|
|
if( show_filtered != null) {
|
|
|
|
editText.setText(show_filtered);
|
|
|
|
editText.setSelection(editText.getText().toString().length());
|
|
|
|
}
|
|
|
|
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
itemFilter.setTitle(editText.getText().toString().trim());
|
|
|
|
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
|
|
|
editor.putString(Helper.SET_FILTER_REGEX_HOME, editText.getText().toString().trim());
|
|
|
|
if(localFragment != null && localFragment.getUserVisibleHint())
|
|
|
|
editor.putString(Helper.SET_FILTER_REGEX_LOCAL, editText.getText().toString().trim());
|
|
|
|
if(federatedFragment != null && federatedFragment.getUserVisibleHint())
|
|
|
|
editor.putString(Helper.SET_FILTER_REGEX_PUBLIC, editText.getText().toString().trim());
|
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
AlertDialog alertDialog = dialogBuilder.create();
|
|
|
|
alertDialog.show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
popup.show();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
mamageNewIntent(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manages new intents
|
|
|
|
* @param intent Intent - intent related to a notification in top bar
|
|
|
|
*/
|
2017-10-27 15:34:53 +02:00
|
|
|
private void mamageNewIntent(Intent intent){
|
2017-10-17 13:13:35 +02:00
|
|
|
if( intent == null || intent.getExtras() == null )
|
2017-10-27 15:34:53 +02:00
|
|
|
return;
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
String action = intent.getAction();
|
|
|
|
String type = intent.getType();
|
|
|
|
Bundle extras = intent.getExtras();
|
|
|
|
String userIdIntent;
|
|
|
|
if( extras.containsKey(INTENT_ACTION) ){
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2017-10-17 13:13:35 +02:00
|
|
|
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
|
|
|
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
|
|
|
|
changeUser(BaseMainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
|
|
|
unCheckAllMenuItems(navigationView);
|
|
|
|
if( tabLayout.getTabAt(1) != null)
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
tabLayout.getTabAt(1).select();
|
2018-01-06 14:07:49 +01:00
|
|
|
if( extras.getString(INTENT_TARGETED_ACCOUNT) != null ){
|
|
|
|
Intent intentShow = new Intent(BaseMainActivity.this, ShowAccountActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putString("accountId", extras.getString(INTENT_TARGETED_ACCOUNT));
|
|
|
|
intentShow.putExtras(b);
|
|
|
|
startActivity(intentShow);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){
|
|
|
|
changeUser(BaseMainActivity.this, userIdIntent, true); //Connects the account which is related to the notification
|
|
|
|
}else if( extras.getInt(INTENT_ACTION) == CHANGE_THEME_INTENT){
|
|
|
|
unCheckAllMenuItems(navigationView);
|
|
|
|
navigationView.setCheckedItem(R.id.nav_settings);
|
|
|
|
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
|
|
|
toolbarTitle.setText(R.string.settings);
|
|
|
|
}else if( extras.getInt(INTENT_ACTION) == CHANGE_USER_INTENT){
|
|
|
|
unCheckAllMenuItems(navigationView);
|
|
|
|
if( tabLayout.getTabAt(0) != null)
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
tabLayout.getTabAt(0).select();
|
|
|
|
if( !toolbar_search.isIconified() ) {
|
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
}
|
2017-12-08 07:22:42 +01:00
|
|
|
}else if (extras.getInt(INTENT_ACTION) == ADD_USER_INTENT){
|
|
|
|
this.recreate();
|
2018-02-17 15:42:09 +01:00
|
|
|
}else if( extras.getInt(INTENT_ACTION) == BACKUP_INTENT){
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class);
|
|
|
|
startActivity(myIntent);
|
2018-08-14 11:47:26 +02:00
|
|
|
}else if(extras.getInt(INTENT_ACTION) == SEARCH_TAG){
|
|
|
|
String keyword = extras.getString(SEARCH_KEYWORD);
|
|
|
|
if( keyword != null){
|
2018-08-14 13:42:13 +02:00
|
|
|
adapter = new PagerAdapter
|
|
|
|
(getSupportFragmentManager(), tabLayout.getTabCount());
|
|
|
|
viewPager.setAdapter(adapter);
|
2018-08-14 11:47:26 +02:00
|
|
|
for(int i = 0; i < tabLayout.getTabCount() ; i++ ){
|
2018-08-19 14:54:36 +02:00
|
|
|
if( tabLayout.getTabAt(i).getText() != null && tabLayout.getTabAt(i).getText().equals(keyword.trim())){
|
2018-08-14 11:47:26 +02:00
|
|
|
tabLayout.getTabAt(i).select();
|
2018-08-19 14:54:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-08-14 11:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}else if( Intent.ACTION_SEND.equals(action) && type != null ) {
|
|
|
|
if ("text/plain".equals(type)) {
|
2018-08-16 12:08:38 +02:00
|
|
|
String url = null;
|
2017-10-17 13:13:35 +02:00
|
|
|
String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
|
|
|
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
|
|
|
if (sharedText != null) {
|
|
|
|
/* Some apps don't send the URL as the first part of the EXTRA_TEXT,
|
|
|
|
the BBC News app being one such, in this case find where the URL
|
|
|
|
is and strip that out into sharedText.
|
|
|
|
*/
|
|
|
|
Matcher matcher;
|
|
|
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
|
|
|
|
matcher = Patterns.WEB_URL.matcher(sharedText);
|
|
|
|
else
|
|
|
|
matcher = Helper.urlPattern.matcher(sharedText);
|
|
|
|
while (matcher.find()){
|
|
|
|
int matchStart = matcher.start(1);
|
|
|
|
int matchEnd = matcher.end();
|
2017-11-22 10:45:13 +01:00
|
|
|
if(matchStart < matchEnd && sharedText.length() >= matchEnd)
|
2018-08-16 12:08:38 +02:00
|
|
|
url = sharedText.substring(matchStart, matchEnd);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2018-08-16 12:08:38 +02:00
|
|
|
new RetrieveMetaDataAsyncTask(BaseMainActivity.this, sharedSubject, sharedText, url,BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (type.startsWith("image/")) {
|
|
|
|
|
|
|
|
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
|
|
|
|
|
|
|
if (imageUri != null) {
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putParcelable("sharedUri", imageUri);
|
2017-12-02 08:39:01 +01:00
|
|
|
b.putInt("uriNumberMast", 1);
|
2018-08-16 11:03:20 +02:00
|
|
|
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null ) {
|
|
|
|
if (type.startsWith("image/")) {
|
|
|
|
|
|
|
|
ArrayList<Uri> imageList = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
|
|
|
if (imageList != null) {
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putParcelableArrayList("sharedUri", imageList);
|
2017-12-02 08:39:01 +01:00
|
|
|
b.putInt("uriNumberMast", imageList.size());
|
2018-08-16 11:03:20 +02:00
|
|
|
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
2017-12-20 09:33:32 +01:00
|
|
|
}else if (Intent.ACTION_VIEW.equals(action)) {
|
|
|
|
String url = intent.getDataString();
|
|
|
|
if( url == null)
|
|
|
|
return;
|
|
|
|
Matcher matcher;
|
|
|
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
|
|
|
|
matcher = Patterns.WEB_URL.matcher(url);
|
|
|
|
else
|
|
|
|
matcher = Helper.urlPattern.matcher(url);
|
|
|
|
boolean isUrl = false;
|
|
|
|
while (matcher.find()){
|
|
|
|
isUrl = true;
|
|
|
|
}
|
|
|
|
if(!isUrl)
|
|
|
|
return;
|
|
|
|
//Here we know that the intent contains a valid URL
|
|
|
|
new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, url, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
intent.replaceExtras(new Bundle());
|
|
|
|
intent.setAction("");
|
|
|
|
intent.setData(null);
|
|
|
|
intent.setFlags(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
2017-10-21 16:56:17 +02:00
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
2017-10-17 13:13:35 +02:00
|
|
|
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
} else {
|
|
|
|
//Hide search bar on back pressed
|
|
|
|
if( !toolbar_search.isIconified()){
|
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( viewPager.getVisibility() == View.VISIBLE){
|
|
|
|
if (stackBack.size() > 1) {
|
|
|
|
stackBack.pop();
|
|
|
|
viewPager.setCurrentItem(stackBack.lastElement());
|
|
|
|
}else {
|
|
|
|
super.onBackPressed();
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
2017-10-30 07:54:02 +01:00
|
|
|
delete_all.setVisibility(View.GONE);
|
2017-11-23 18:16:47 +01:00
|
|
|
add_new.setVisibility(View.GONE);
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2017-10-17 13:13:35 +02:00
|
|
|
unCheckAllMenuItems(navigationView);
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.VISIBLE);
|
|
|
|
switch (viewPager.getCurrentItem()){
|
|
|
|
case 1:
|
|
|
|
toot.setVisibility(View.GONE);
|
|
|
|
break;
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume(){
|
|
|
|
super.onResume();
|
|
|
|
BaseMainActivity.activityResumed();
|
|
|
|
updateNotifCounter();
|
|
|
|
updateHomeCounter();
|
|
|
|
//Proceeds to update of the authenticated account
|
|
|
|
if(Helper.isLoggedIn(getApplicationContext()))
|
|
|
|
new UpdateAccountInfoByIDAsyncTask(getApplicationContext(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
if( lastHomeId != null && homeFragment != null){
|
|
|
|
homeFragment.retrieveMissingToots(lastHomeId);
|
|
|
|
}
|
|
|
|
if( lastNotificationId != null && notificationsFragment != null){
|
|
|
|
notificationsFragment.retrieveMissingNotifications(lastNotificationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStart(){
|
|
|
|
super.onStart();
|
2018-01-02 10:58:29 +01:00
|
|
|
if( receive_federated_data != null)
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_federated_data);
|
2017-10-17 13:13:35 +02:00
|
|
|
receive_federated_data = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Bundle b = intent.getExtras();
|
2017-10-27 15:34:53 +02:00
|
|
|
assert b != null;
|
2017-10-17 13:13:35 +02:00
|
|
|
userIdService = b.getString("userIdService", null);
|
|
|
|
if( userIdService != null && userIdService.equals(userId)) {
|
|
|
|
Status status = b.getParcelable("data");
|
|
|
|
if (federatedFragment != null) {
|
|
|
|
federatedFragment.refresh(status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-01-02 10:58:29 +01:00
|
|
|
if( receive_local_data != null)
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_local_data);
|
2017-10-17 13:13:35 +02:00
|
|
|
receive_local_data = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Bundle b = intent.getExtras();
|
2017-10-27 15:34:53 +02:00
|
|
|
assert b != null;
|
2017-10-17 13:13:35 +02:00
|
|
|
userIdService = b.getString("userIdService", null);
|
|
|
|
if( userIdService != null && userIdService.equals(userId)) {
|
|
|
|
Status status = b.getParcelable("data");
|
|
|
|
if (localFragment != null) {
|
|
|
|
localFragment.refresh(status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(receive_federated_data, new IntentFilter(Helper.RECEIVE_FEDERATED_DATA));
|
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(receive_local_data, new IntentFilter(Helper.RECEIVE_LOCAL_DATA));
|
2018-08-14 11:10:49 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStop(){
|
|
|
|
super.onStop();
|
|
|
|
if( receive_federated_data != null)
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_federated_data);
|
|
|
|
if( receive_local_data != null)
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_local_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
BaseMainActivity.activityPaused();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDestroy(){
|
|
|
|
super.onDestroy();
|
2017-12-06 14:06:45 +01:00
|
|
|
if( receive_data != null)
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_data);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("StatementWithEmptyBody")
|
|
|
|
@Override
|
|
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
|
|
// Handle navigation view item clicks here.
|
|
|
|
int id = item.getItemId();
|
2017-10-30 07:54:02 +01:00
|
|
|
if (id == R.id.nav_remote_follow) {
|
2017-10-17 13:13:35 +02:00
|
|
|
Intent remoteFollow = new Intent(getApplicationContext(), RemoteFollowActivity.class);
|
|
|
|
startActivity(remoteFollow);
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-17 11:28:52 +01:00
|
|
|
if( id == R.id.nav_archive) {
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2017-10-17 13:13:35 +02:00
|
|
|
unCheckAllMenuItems(navigationView);
|
|
|
|
item.setChecked(true);
|
|
|
|
//Remove the search bar
|
2017-10-30 07:54:02 +01:00
|
|
|
if (!toolbar_search.isIconified()) {
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
}
|
|
|
|
toolbarTitle.setText(item.getTitle());
|
|
|
|
DisplayStatusFragment statusFragment;
|
|
|
|
DisplayAccountsFragment accountsFragment;
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
String fragmentTag = null;
|
|
|
|
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
2017-11-02 15:22:47 +01:00
|
|
|
appBar.setExpanded(true);
|
2018-02-15 15:27:46 +01:00
|
|
|
if (id != R.id.nav_drafts && id != R.id.nav_bookmarks ) {
|
2017-10-30 07:54:02 +01:00
|
|
|
delete_all.setVisibility(View.GONE);
|
|
|
|
}else{
|
|
|
|
delete_all.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2017-12-14 16:14:24 +01:00
|
|
|
if( id != R.id.nav_search && id != R.id.nav_list){
|
2017-11-23 18:16:47 +01:00
|
|
|
add_new.setVisibility(View.GONE);
|
|
|
|
}else{
|
|
|
|
add_new.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
if (id == R.id.nav_settings) {
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
TabLayoutSettingsFragment tabLayoutSettingsFragment= new TabLayoutSettingsFragment();
|
|
|
|
fragmentTag = "TABLAYOUT_SETTINGS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).commit();
|
|
|
|
|
|
|
|
} else if (id == R.id.nav_favorites) {
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.FAVOURITES);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
fragmentTag = "FAVOURITES";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
|
|
|
|
} else if (id == R.id.nav_blocked) {
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
accountsFragment = new DisplayAccountsFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.BLOCKED);
|
|
|
|
accountsFragment.setArguments(bundle);
|
|
|
|
fragmentTag = "BLOCKS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, accountsFragment, fragmentTag).commit();
|
|
|
|
}else if (id == R.id.nav_muted) {
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
accountsFragment = new DisplayAccountsFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.MUTED);
|
|
|
|
accountsFragment.setArguments(bundle);
|
|
|
|
fragmentTag = "MUTED";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, accountsFragment, fragmentTag).commit();
|
|
|
|
}else if (id == R.id.nav_scheduled) {
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
DisplayScheduledTootsFragment displayScheduledTootsFragment = new DisplayScheduledTootsFragment();
|
|
|
|
fragmentTag = "SCHEDULED";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayScheduledTootsFragment, fragmentTag).commit();
|
|
|
|
}else if (id == R.id.nav_drafts) {
|
|
|
|
DisplayDraftsFragment displayDraftsFragment = new DisplayDraftsFragment();
|
|
|
|
fragmentTag = "DRAFTS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayDraftsFragment, fragmentTag).commit();
|
2017-10-30 07:54:02 +01:00
|
|
|
toot.setVisibility(View.GONE);
|
2018-02-15 15:27:46 +01:00
|
|
|
}else if (id == R.id.nav_bookmarks) {
|
|
|
|
DisplayBookmarksFragment displayBookmarksFragment = new DisplayBookmarksFragment();
|
|
|
|
fragmentTag = "BOOKMARKS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayBookmarksFragment, fragmentTag).commit();
|
|
|
|
toot.setVisibility(View.GONE);
|
2017-11-23 18:16:47 +01:00
|
|
|
}else if (id == R.id.nav_search) {
|
|
|
|
DisplaySearchFragment displaySearchFragment = new DisplaySearchFragment();
|
|
|
|
fragmentTag = "SEARCH";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displaySearchFragment, fragmentTag).commit();
|
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
}else if( id == R.id.nav_follow_request){
|
2017-10-27 18:05:57 +02:00
|
|
|
toot.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
DisplayFollowRequestSentFragment followRequestSentFragment = new DisplayFollowRequestSentFragment();
|
|
|
|
fragmentTag = "FOLLOW_REQUEST_SENT";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, followRequestSentFragment, fragmentTag).commit();
|
2017-12-13 18:04:29 +01:00
|
|
|
}else if(id == R.id.nav_list){
|
|
|
|
toot.setVisibility(View.GONE);
|
|
|
|
DisplayListsFragment displayListsFragment = new DisplayListsFragment();
|
|
|
|
fragmentTag = "LISTS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayListsFragment, fragmentTag).commit();
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
|
2017-10-21 16:56:17 +02:00
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
2017-10-17 13:13:35 +02:00
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void populateTitleWithTag(String tag, String title, int index){
|
|
|
|
if( tag == null)
|
|
|
|
return;
|
|
|
|
if ( tagTile.get(tag) == null)
|
|
|
|
tagTile.put(tag, title);
|
|
|
|
if ( tagItem.get(tag) == null)
|
|
|
|
tagItem.put(tag, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setTitle(CharSequence title) {
|
|
|
|
if(toolbarTitle != null )
|
|
|
|
toolbarTitle.setText(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdateAccountInfo(boolean error) {
|
|
|
|
if( error){
|
|
|
|
//An error occurred, the user is redirected to the login page
|
|
|
|
Helper.logout(getApplicationContext());
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
finish();
|
|
|
|
}else {
|
|
|
|
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
2017-12-02 11:02:25 +01:00
|
|
|
updateHeaderAccountInfo(BaseMainActivity.this, account, headerLayout);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode,
|
|
|
|
Intent data) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
2017-10-21 16:56:17 +02:00
|
|
|
//noinspection StatementWithEmptyBody
|
2017-10-17 13:13:35 +02:00
|
|
|
if (requestCode == ERROR_DIALOG_REQUEST_CODE) {
|
|
|
|
// Adding a fragment via GooglePlayServicesUtil.showErrorDialogFragment
|
|
|
|
// before the instance state is restored throws an error. So instead,
|
|
|
|
// set a flag here, which will cause the fragment to delay until
|
|
|
|
// onPostResume.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2018-08-16 12:08:38 +02:00
|
|
|
public void onRetrieveMetaData(boolean error, String sharedSubject, String sharedText, String image, String title, String description) {
|
|
|
|
Bundle b = new Bundle();
|
2017-10-17 13:13:35 +02:00
|
|
|
if( !error) {
|
2018-08-16 12:08:38 +02:00
|
|
|
b.putString("image", image);
|
|
|
|
b.putString("title", title);
|
|
|
|
b.putString("description", description);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2018-08-16 12:08:38 +02:00
|
|
|
b.putString("sharedSubject", sharedSubject);
|
|
|
|
b.putString("sharedContent", sharedText);
|
|
|
|
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRetrieveInstance(APIResponse apiResponse) {
|
|
|
|
if( apiResponse.getError() != null){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( apiResponse.getInstance() == null || apiResponse.getInstance().getVersion() == null || apiResponse.getInstance().getVersion().trim().length() == 0)
|
|
|
|
return;
|
|
|
|
Version currentVersion = new Version(apiResponse.getInstance().getVersion());
|
|
|
|
Version minVersion = new Version("1.6");
|
2017-10-27 10:38:22 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
2017-11-03 15:18:25 +01:00
|
|
|
editor.putString(Helper.INSTANCE_VERSION + userId + instance, apiResponse.getInstance().getVersion());
|
2017-10-27 10:38:22 +02:00
|
|
|
editor.apply();
|
2017-10-17 13:13:35 +02:00
|
|
|
Helper.canPin = (currentVersion.compareTo(minVersion) == 1 || currentVersion.equals(minVersion));
|
|
|
|
}
|
|
|
|
|
2017-12-06 16:45:07 +01:00
|
|
|
public String getBookmark() {
|
|
|
|
return bookmark;
|
|
|
|
}
|
|
|
|
|
2017-12-08 06:46:23 +01:00
|
|
|
public void setBookmark(@SuppressWarnings("SameParameterValue") String bookmark) {
|
2017-12-06 16:45:07 +01:00
|
|
|
this.bookmark = bookmark;
|
|
|
|
}
|
|
|
|
|
2017-12-20 09:33:32 +01:00
|
|
|
@Override
|
|
|
|
public void onRetrieveRemoteAccount(Results results) {
|
|
|
|
if (results == null)
|
|
|
|
return;
|
|
|
|
List<Account> accounts = results.getAccounts();
|
|
|
|
List<Status> statuses = results.getStatuses();
|
|
|
|
if( accounts !=null && accounts.size() > 0){
|
|
|
|
Intent intent = new Intent(BaseMainActivity.this, ShowAccountActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putString("accountId", accounts.get(0).getId());
|
|
|
|
intent.putExtras(b);
|
|
|
|
startActivity(intent);
|
|
|
|
}else if( statuses != null && statuses.size() > 0){
|
|
|
|
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putString("statusId", statuses.get(0).getId());
|
|
|
|
intent.putExtras(b);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Page Adapter for settings
|
|
|
|
*/
|
2018-08-14 11:10:49 +02:00
|
|
|
public class PagerAdapter extends FragmentStatePagerAdapter {
|
2017-10-17 13:13:35 +02:00
|
|
|
int mNumOfTabs;
|
|
|
|
|
|
|
|
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
|
|
|
super(fm);
|
|
|
|
this.mNumOfTabs = NumOfTabs;
|
|
|
|
}
|
|
|
|
|
2018-08-14 13:42:13 +02:00
|
|
|
public void removeTabPage() {
|
2018-08-14 11:10:49 +02:00
|
|
|
this.mNumOfTabs--;
|
|
|
|
notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addTabPage(String title) {
|
|
|
|
TabLayout.Tab tab = tabLayout.newTab();
|
|
|
|
tab.setText(title);
|
|
|
|
this.mNumOfTabs++;
|
|
|
|
notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
|
|
|
public Fragment getItem(int position) {
|
|
|
|
//Remove the search bar
|
|
|
|
if( !toolbar_search.isIconified() ) {
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
}
|
|
|
|
//Selection comes from another menu, no action to do
|
|
|
|
DisplayStatusFragment statusFragment;
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
if (position == 0) {
|
|
|
|
homeFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.HOME);
|
|
|
|
homeFragment.setArguments(bundle);
|
|
|
|
return homeFragment;
|
|
|
|
}else if( position == 1) {
|
|
|
|
notificationsFragment = new DisplayNotificationsFragment();
|
|
|
|
return notificationsFragment;
|
|
|
|
}else if( position == 2 && display_local) {
|
2017-10-27 18:05:57 +02:00
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.LOCAL);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
return statusFragment;
|
2018-08-14 11:10:49 +02:00
|
|
|
}else if(position == 2 && display_global){
|
2017-10-27 18:05:57 +02:00
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
return statusFragment;
|
2018-08-14 11:10:49 +02:00
|
|
|
}else if (position == 3 && display_global && display_local){
|
2017-10-17 13:13:35 +02:00
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
return statusFragment;
|
2018-08-14 11:10:49 +02:00
|
|
|
}else{ //Here it's a search fragment
|
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.TAG);
|
|
|
|
if( tabLayout.getTabAt(position) != null && tabLayout.getTabAt(position).getText() != null)
|
|
|
|
bundle.putString("tag", tabLayout.getTabAt(position).getText().toString());
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
return statusFragment;
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-11 14:39:33 +01:00
|
|
|
@NonNull
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
|
|
|
public Object instantiateItem(ViewGroup container, int position) {
|
|
|
|
Fragment createdFragment = (Fragment) super.instantiateItem(container, position);
|
|
|
|
// save the appropriate reference depending on position
|
|
|
|
switch (position) {
|
|
|
|
case 0:
|
|
|
|
homeFragment = (DisplayStatusFragment) createdFragment;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
notificationsFragment = (DisplayNotificationsFragment) createdFragment;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if ( !display_local && display_global)
|
|
|
|
federatedFragment = (DisplayStatusFragment) createdFragment;
|
|
|
|
if( display_local)
|
|
|
|
localFragment = (DisplayStatusFragment) createdFragment;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if( display_local && display_global)
|
|
|
|
federatedFragment = (DisplayStatusFragment) createdFragment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return createdFragment;
|
|
|
|
}
|
2018-08-14 11:10:49 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
|
|
|
public int getCount() {
|
|
|
|
return mNumOfTabs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateHomeCounter(){
|
|
|
|
if( tabLayout.getTabAt(0) == null )
|
|
|
|
return;
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
View tabHome = tabLayout.getTabAt(0).getCustomView();
|
|
|
|
if( tabHome == null)
|
|
|
|
return;
|
2017-10-21 16:56:17 +02:00
|
|
|
TextView tabCounterHome = tabHome.findViewById(R.id.tab_counter);
|
2017-10-17 13:13:35 +02:00
|
|
|
tabCounterHome.setText(String.valueOf(countNewStatus));
|
|
|
|
if( countNewStatus> 0){
|
|
|
|
//New data are available
|
|
|
|
//The fragment is not displayed, so the counter is displayed
|
|
|
|
tabCounterHome.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCounterHome.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-27 15:34:53 +02:00
|
|
|
@SuppressWarnings("ConstantConditions")
|
2017-10-25 13:45:22 +02:00
|
|
|
public void updateTimeLine(RetrieveFeedsAsyncTask.Type type, int value){
|
|
|
|
if( type == RetrieveFeedsAsyncTask.Type.LOCAL){
|
|
|
|
if( tabLayout.getTabAt(2) != null && display_local){
|
|
|
|
View tabLocal = tabLayout.getTabAt(2).getCustomView();
|
2017-10-27 15:34:53 +02:00
|
|
|
assert tabLocal != null;
|
2017-10-25 13:45:22 +02:00
|
|
|
TextView tabCounterLocal = tabLocal.findViewById(R.id.tab_counter);
|
|
|
|
tabCounterLocal.setText(String.valueOf(value));
|
|
|
|
if( value > 0){
|
|
|
|
tabCounterLocal.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCounterLocal.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC){
|
|
|
|
if( tabLayout.getTabAt(3) != null && display_local){
|
|
|
|
View tabPublic = tabLayout.getTabAt(3).getCustomView();
|
2017-10-27 15:34:53 +02:00
|
|
|
assert tabPublic != null;
|
2017-10-25 13:45:22 +02:00
|
|
|
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
|
|
|
tabCounterPublic.setText(String.valueOf(value));
|
|
|
|
if( value > 0){
|
|
|
|
tabCounterPublic.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCounterPublic.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}else if( tabLayout.getTabAt(2) != null && !display_local && display_global){
|
|
|
|
View tabPublic = tabLayout.getTabAt(2).getCustomView();
|
2017-10-27 15:34:53 +02:00
|
|
|
assert tabPublic != null;
|
2017-10-25 13:45:22 +02:00
|
|
|
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
|
|
|
tabCounterPublic.setText(String.valueOf(value));
|
|
|
|
if( value > 0){
|
|
|
|
tabCounterPublic.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCounterPublic.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
public void updateNotifCounter(){
|
|
|
|
if(tabLayout.getTabAt(1) == null)
|
|
|
|
return;
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
View tabNotif = tabLayout.getTabAt(1).getCustomView();
|
|
|
|
if( tabNotif == null)
|
|
|
|
return;
|
2017-10-21 16:56:17 +02:00
|
|
|
TextView tabCounterNotif = tabNotif.findViewById(R.id.tab_counter);
|
2017-10-17 13:13:35 +02:00
|
|
|
tabCounterNotif.setText(String.valueOf(countNewNotifications));
|
|
|
|
if( countNewNotifications > 0){
|
|
|
|
tabCounterNotif.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCounterNotif.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void activityResumed() {
|
2017-11-11 07:26:52 +01:00
|
|
|
activityPaused = false;
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void activityPaused() {
|
2017-11-11 07:26:52 +01:00
|
|
|
activityPaused = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean activityState(){
|
|
|
|
return activityPaused;
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
2017-11-12 08:33:24 +01:00
|
|
|
|
2018-01-03 15:25:35 +01:00
|
|
|
public void startSreaming(){
|
2017-11-12 08:33:24 +01:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
|
|
|
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
2018-01-22 15:48:40 +01:00
|
|
|
if( liveNotifications) {
|
2018-01-03 15:25:35 +01:00
|
|
|
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
|
|
|
assert manager != null;
|
|
|
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
|
|
|
if (LiveNotificationService.class.getName().equals(service.service.getClassName())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Intent streamingIntent = new Intent(this, LiveNotificationService.class);
|
2017-12-29 11:21:24 +01:00
|
|
|
startService(streamingIntent);
|
2017-11-12 08:33:24 +01:00
|
|
|
}
|
2017-12-29 11:21:24 +01:00
|
|
|
|
2017-11-11 10:05:37 +01:00
|
|
|
}
|
2017-12-06 16:56:59 +01:00
|
|
|
|
|
|
|
public DisplayStatusFragment getHomeFragment(){
|
|
|
|
return homeFragment;
|
|
|
|
}
|
2017-10-27 18:05:57 +02:00
|
|
|
}
|