2017-10-17 13:13:35 +02:00
|
|
|
/* Copyright 2017 Thomas Schneider
|
|
|
|
*
|
2019-05-18 11:10:30 +02:00
|
|
|
* This file is a part of Fedilab
|
2017-10-17 13:13:35 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2019-05-18 11:10:30 +02:00
|
|
|
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
2017-10-17 13:13:35 +02:00
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
2019-05-18 11:10:30 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
2017-10-17 13:13:35 +02:00
|
|
|
* see <http://www.gnu.org/licenses>. */
|
2019-05-18 11:10:30 +02:00
|
|
|
package app.fedilab.android.activities;
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2018-01-06 17:13:18 +01:00
|
|
|
import android.Manifest;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2018-11-04 16:00:44 +01:00
|
|
|
import android.app.Activity;
|
2018-01-03 15:25:35 +01:00
|
|
|
import android.app.ActivityManager;
|
2019-07-03 17:28:17 +02:00
|
|
|
import android.content.BroadcastReceiver;
|
2019-07-12 17:23:31 +02:00
|
|
|
import android.content.ComponentName;
|
2019-07-03 17:28:17 +02:00
|
|
|
import android.content.Context;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
2019-07-03 17:28:17 +02:00
|
|
|
import android.content.IntentFilter;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.content.SharedPreferences;
|
2018-01-06 17:13:18 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2019-07-12 17:23:31 +02:00
|
|
|
import android.content.pm.ResolveInfo;
|
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;
|
2019-07-12 17:23:31 +02:00
|
|
|
import android.os.Parcelable;
|
2018-10-15 19:08:30 +02:00
|
|
|
import android.preference.PreferenceManager;
|
2019-06-11 19:38:26 +02:00
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import com.google.android.material.appbar.AppBarLayout;
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
|
|
import com.google.android.material.navigation.NavigationView;
|
|
|
|
import com.google.android.material.tabs.TabLayout;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.core.view.GravityCompat;
|
2019-07-03 17:28:17 +02:00
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
2019-06-11 19:38:26 +02:00
|
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
import androidx.drawerlayout.widget.DrawerLayout;
|
|
|
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
|
import androidx.appcompat.widget.SearchView;
|
|
|
|
import androidx.appcompat.widget.SwitchCompat;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
2019-08-17 16:14:47 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.util.Patterns;
|
|
|
|
import android.view.LayoutInflater;
|
2019-05-19 14:33:24 +02:00
|
|
|
import android.view.Menu;
|
2018-11-10 10:07:44 +01:00
|
|
|
import android.view.MenuItem;
|
2017-10-17 13:13:35 +02:00
|
|
|
import android.view.View;
|
|
|
|
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;
|
2019-05-05 12:41:45 +02:00
|
|
|
|
2019-05-19 14:33:24 +02:00
|
|
|
import java.lang.reflect.Method;
|
2017-10-17 13:13:35 +02:00
|
|
|
import java.util.ArrayList;
|
2019-05-09 19:03:02 +02:00
|
|
|
import java.util.Date;
|
2017-10-17 13:13:35 +02:00
|
|
|
import java.util.HashMap;
|
2017-12-20 09:33:32 +01:00
|
|
|
import java.util.List;
|
2019-07-19 18:04:47 +02:00
|
|
|
import java.util.Locale;
|
2019-05-09 19:03:02 +02:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2017-10-17 13:13:35 +02:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
2019-05-20 17:48:16 +02:00
|
|
|
import app.fedilab.android.BuildConfig;
|
2019-05-18 11:10:30 +02:00
|
|
|
import app.fedilab.android.client.APIResponse;
|
|
|
|
import app.fedilab.android.client.Entities.Account;
|
|
|
|
import app.fedilab.android.client.Entities.Filters;
|
2019-08-17 16:14:47 +02:00
|
|
|
import app.fedilab.android.client.Entities.Instance;
|
2019-05-18 11:10:30 +02:00
|
|
|
import app.fedilab.android.client.Entities.ManageTimelines;
|
|
|
|
import app.fedilab.android.client.Entities.Results;
|
|
|
|
import app.fedilab.android.client.Entities.Status;
|
|
|
|
import app.fedilab.android.client.Entities.TagTimeline;
|
|
|
|
import app.fedilab.android.client.Entities.Version;
|
|
|
|
import app.fedilab.android.fragments.DisplayAccountsFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayBookmarksFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayDraftsFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayFavoritesPeertubeFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayFiltersFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayFollowRequestSentFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayHowToFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayListsFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayNotificationsFragment;
|
|
|
|
import app.fedilab.android.fragments.DisplayPeertubeNotificationsFragment;
|
2019-05-26 18:05:27 +02:00
|
|
|
import app.fedilab.android.fragments.DisplayPlaylistsFragment;
|
2019-05-18 11:10:30 +02:00
|
|
|
import app.fedilab.android.fragments.DisplayStatusFragment;
|
|
|
|
import app.fedilab.android.fragments.SettingsPeertubeFragment;
|
|
|
|
import app.fedilab.android.fragments.TabLayoutNotificationsFragment;
|
|
|
|
import app.fedilab.android.fragments.TabLayoutScheduleFragment;
|
|
|
|
import app.fedilab.android.fragments.WhoToFollowFragment;
|
|
|
|
import app.fedilab.android.helper.CrossActions;
|
|
|
|
import app.fedilab.android.helper.Helper;
|
|
|
|
import app.fedilab.android.helper.MenuFloating;
|
|
|
|
import app.fedilab.android.services.BackupStatusService;
|
|
|
|
import app.fedilab.android.services.LiveNotificationService;
|
2019-08-30 17:41:15 +02:00
|
|
|
import app.fedilab.android.services.StopLiveNotificationReceiver;
|
2019-05-18 11:10:30 +02:00
|
|
|
import app.fedilab.android.sqlite.AccountDAO;
|
|
|
|
import app.fedilab.android.sqlite.Sqlite;
|
2019-08-18 17:17:47 +02:00
|
|
|
import app.fedilab.android.sqlite.TempMuteDAO;
|
2019-05-21 18:21:58 +02:00
|
|
|
import app.fedilab.android.sqlite.TimelineCacheDAO;
|
2019-05-18 11:10:30 +02:00
|
|
|
import app.fedilab.android.sqlite.TimelinesDAO;
|
2018-11-25 10:45:16 +01:00
|
|
|
import es.dmoral.toasty.Toasty;
|
2019-05-18 11:10:30 +02:00
|
|
|
import app.fedilab.android.R;
|
|
|
|
import app.fedilab.android.asynctasks.ManageFiltersAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.RetrieveAccountsAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.RetrieveInstanceAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.RetrieveMetaDataAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.RetrievePeertubeInformationAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.RetrieveRemoteDataAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.SyncTimelinesAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
|
|
|
import app.fedilab.android.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
|
|
|
import app.fedilab.android.interfaces.OnFilterActionInterface;
|
|
|
|
import app.fedilab.android.interfaces.OnRetrieveEmojiAccountInterface;
|
|
|
|
import app.fedilab.android.interfaces.OnRetrieveInstanceInterface;
|
|
|
|
import app.fedilab.android.interfaces.OnRetrieveMetaDataInterface;
|
|
|
|
import app.fedilab.android.interfaces.OnRetrieveRemoteAccountInterface;
|
|
|
|
import app.fedilab.android.interfaces.OnSyncTimelineInterface;
|
|
|
|
import app.fedilab.android.interfaces.OnUpdateAccountInfoInterface;
|
|
|
|
|
|
|
|
import static app.fedilab.android.asynctasks.ManageFiltersAsyncTask.action.GET_ALL_FILTER;
|
|
|
|
import static app.fedilab.android.helper.Helper.changeDrawableColor;
|
2018-10-17 18:20:03 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2017-12-12 18:17:01 +01:00
|
|
|
public abstract class BaseMainActivity extends BaseActivity
|
2019-06-19 18:48:41 +02:00
|
|
|
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface, OnRetrieveRemoteAccountInterface, OnRetrieveEmojiAccountInterface, OnFilterActionInterface, OnSyncTimelineInterface {
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2019-05-06 07:44:47 +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;
|
2018-09-25 18:37:03 +02:00
|
|
|
public static List<Filters> filters = new ArrayList<>();
|
2019-01-05 14:21:49 +01:00
|
|
|
public static int countNewStatus;
|
|
|
|
public static int countNewNotifications;
|
2017-10-17 13:13:35 +02:00
|
|
|
public static String lastHomeId = null, lastNotificationId = null;
|
2017-11-02 15:22:47 +01:00
|
|
|
private AppBarLayout appBar;
|
2017-12-28 17:25:36 +01:00
|
|
|
private String userId;
|
|
|
|
private String instance;
|
2018-08-14 11:10:49 +02:00
|
|
|
private PagerAdapter adapter;
|
2019-05-19 14:33:24 +02:00
|
|
|
private ImageView delete_instance, display_timeline;
|
2018-10-20 14:39:24 +02:00
|
|
|
public static String displayPeertube = null;
|
2018-11-03 14:45:55 +01:00
|
|
|
private int style;
|
2018-11-04 16:00:44 +01:00
|
|
|
private Activity activity;
|
2019-01-03 11:19:45 +01:00
|
|
|
public static UpdateAccountInfoAsyncTask.SOCIAL social;
|
2019-01-25 11:41:39 +01:00
|
|
|
private final int PICK_IMPORT = 5556;
|
2019-08-19 17:36:09 +02:00
|
|
|
public static List<ManageTimelines> timelines;
|
2019-08-19 18:30:47 +02:00
|
|
|
private BroadcastReceiver hidde_menu, update_topbar;
|
2018-12-06 19:05:29 +01:00
|
|
|
|
2019-08-19 13:57:17 +02:00
|
|
|
public static HashMap<Integer, Fragment> mPageReferenceMap;
|
2019-05-04 19:15:03 +02:00
|
|
|
private static boolean notificationChecked = false;
|
2019-06-04 11:02:15 +02:00
|
|
|
public static HashMap<String, Integer> poll_limits = new HashMap<>();
|
2019-08-17 16:14:47 +02:00
|
|
|
private Instance instanceClass;
|
2019-08-18 17:17:47 +02:00
|
|
|
public static List<String> mutedAccount = new ArrayList<>();
|
2019-08-18 18:20:48 +02:00
|
|
|
public static String regex_home, regex_local, regex_public;
|
|
|
|
public static boolean show_boosts, show_replies, show_art_nsfw;
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-22 18:13:44 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2019-05-18 11:10:30 +02:00
|
|
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
|
|
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
2019-05-18 11:10:30 +02:00
|
|
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
2019-02-08 15:07:46 +01:00
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
2019-01-03 11:19:45 +01:00
|
|
|
if( account == null){
|
|
|
|
Helper.logout(getApplicationContext());
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
2019-01-14 11:50:42 +01:00
|
|
|
|
|
|
|
//Update the static variable which manages account type
|
2019-01-27 10:40:09 +01:00
|
|
|
if( account.getSocial() == null || account.getSocial().equals("MASTODON"))
|
2019-01-14 11:50:42 +01:00
|
|
|
social = UpdateAccountInfoAsyncTask.SOCIAL.MASTODON;
|
|
|
|
else if( account.getSocial().equals("PEERTUBE"))
|
|
|
|
social = UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE;
|
|
|
|
else if( account.getSocial().equals("PIXELFED"))
|
|
|
|
social = UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED;
|
2019-01-27 10:40:09 +01:00
|
|
|
else if( account.getSocial().equals("PLEROMA"))
|
|
|
|
social = UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA;
|
2019-02-03 09:27:02 +01:00
|
|
|
else if( account.getSocial().equals("GNU"))
|
|
|
|
social = UpdateAccountInfoAsyncTask.SOCIAL.GNU;
|
2019-02-08 15:07:46 +01:00
|
|
|
else if( account.getSocial().equals("FRIENDICA"))
|
|
|
|
social = UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA;
|
2019-01-05 14:21:49 +01:00
|
|
|
countNewStatus = 0;
|
|
|
|
countNewNotifications = 0;
|
2019-01-03 11:19:45 +01:00
|
|
|
|
2019-08-18 18:20:48 +02:00
|
|
|
|
|
|
|
regex_home = sharedpreferences.getString(Helper.SET_FILTER_REGEX_HOME, null);
|
|
|
|
regex_local = sharedpreferences.getString(Helper.SET_FILTER_REGEX_LOCAL, null);
|
|
|
|
regex_public = sharedpreferences.getString(Helper.SET_FILTER_REGEX_PUBLIC, null);
|
|
|
|
show_art_nsfw = sharedpreferences.getBoolean(Helper.SET_ART_WITH_NSFW, false);
|
|
|
|
show_boosts = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true);
|
|
|
|
show_replies = sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true);
|
|
|
|
|
2019-08-19 13:57:17 +02:00
|
|
|
if( mPageReferenceMap == null ){
|
|
|
|
mPageReferenceMap = new HashMap<>();
|
|
|
|
}
|
2019-01-10 18:19:53 +01:00
|
|
|
if (!isTaskRoot()
|
|
|
|
&& getIntent().hasCategory(Intent.CATEGORY_LAUNCHER)
|
|
|
|
&& getIntent().getAction() != null
|
|
|
|
&& getIntent().getAction().equals(Intent.ACTION_MAIN)) {
|
|
|
|
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
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:
|
2019-07-20 15:15:47 +02:00
|
|
|
setTheme(R.style.AppTheme_NoActionBar_Fedilab);
|
2018-05-11 11:28:05 +02:00
|
|
|
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);
|
|
|
|
|
|
|
|
//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;
|
|
|
|
}
|
2018-11-04 16:00:44 +01:00
|
|
|
activity = this;
|
2017-10-17 13:13:35 +02:00
|
|
|
rateThisApp();
|
|
|
|
|
2019-01-07 19:16:15 +01:00
|
|
|
//Intialize Peertube information
|
2019-01-14 11:50:42 +01:00
|
|
|
//This task will allow to instance a static PeertubeInformation class
|
2019-01-07 19:16:15 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
|
|
|
|
try{
|
|
|
|
new RetrievePeertubeInformationAsyncTask(getApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}catch (Exception ignored){}
|
|
|
|
}
|
2019-01-14 11:50:42 +01:00
|
|
|
//For old Mastodon releases that can't pin, this support could be removed
|
2017-10-17 13:13:35 +02:00
|
|
|
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);
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2018-05-11 13:53:08 +02:00
|
|
|
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);
|
2018-12-15 11:23:27 +01:00
|
|
|
delete_instance = findViewById(R.id.delete_instance);
|
2019-05-19 14:33:24 +02:00
|
|
|
display_timeline = findViewById(R.id.display_timeline);
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_LIGHT) {
|
2019-06-11 19:38:26 +02:00
|
|
|
ImageView icon = toolbar_search.findViewById(R.id.search_button);
|
|
|
|
ImageView close = toolbar_search.findViewById(R.id.search_close_btn);
|
2018-11-03 12:06:44 +01:00
|
|
|
if( icon != null)
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon));
|
|
|
|
if( close != null)
|
|
|
|
close.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon));
|
2019-06-11 19:38:26 +02:00
|
|
|
EditText editText = toolbar_search.findViewById(R.id.search_src_text);
|
2018-11-05 07:47:16 +01:00
|
|
|
editText.setHintTextColor(getResources().getColor(R.color.dark_icon));
|
|
|
|
editText.setTextColor(getResources().getColor(R.color.dark_icon));
|
2018-12-15 11:23:27 +01:00
|
|
|
changeDrawableColor(BaseMainActivity.this,delete_instance, R.color.dark_icon);
|
2019-05-19 14:33:24 +02:00
|
|
|
changeDrawableColor(BaseMainActivity.this,display_timeline, R.color.dark_icon);
|
2018-11-03 12:06:44 +01:00
|
|
|
}
|
2019-05-19 14:33:24 +02:00
|
|
|
|
2017-10-21 16:56:17 +02:00
|
|
|
tabLayout = findViewById(R.id.tabLayout);
|
2018-12-15 11:23:27 +01:00
|
|
|
|
2018-10-17 19:06:25 +02:00
|
|
|
viewPager = findViewById(R.id.viewpager);
|
2018-11-03 17:02:44 +01:00
|
|
|
|
2019-05-19 14:33:24 +02:00
|
|
|
display_timeline.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
if( timelines == null || timelines.size() <= 0 ){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
PopupMenu popup = new PopupMenu(BaseMainActivity.this, display_timeline);
|
|
|
|
try {
|
|
|
|
@SuppressLint("PrivateApi") Method method = popup.getMenu().getClass().getDeclaredMethod("setOptionalIconsVisible", boolean.class);
|
|
|
|
method.setAccessible(true);
|
|
|
|
method.invoke(popup.getMenu(), true);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
int i = 0;
|
|
|
|
for (ManageTimelines tl : timelines) {
|
|
|
|
MenuItem item = null;
|
|
|
|
switch (tl.getType()){
|
|
|
|
case LIST:
|
|
|
|
item = popup.getMenu().add(0, 0, Menu.NONE, tl.getListTimeline().getTitle());
|
|
|
|
item.setIcon(R.drawable.ic_list_top_menu);
|
|
|
|
break;
|
|
|
|
case TAG:
|
|
|
|
String name = (tl.getTagTimeline().getDisplayname()!= null && tl.getTagTimeline().getDisplayname().length() > 0)?tl.getTagTimeline().getDisplayname():tl.getTagTimeline().getName();
|
|
|
|
item = popup.getMenu().add(0, 0, Menu.NONE, name);
|
|
|
|
item.setIcon(R.drawable.ic_label_top_menu);
|
|
|
|
break;
|
|
|
|
case INSTANCE:
|
|
|
|
item = popup.getMenu().add(0, 0, Menu.NONE, tl.getRemoteInstance().getHost());
|
|
|
|
switch (tl.getRemoteInstance().getType()) {
|
|
|
|
case "MASTODON":
|
|
|
|
item.setIcon(R.drawable.mastodon_icon_item);
|
|
|
|
break;
|
|
|
|
case "PEERTUBE":
|
|
|
|
item.setIcon(R.drawable.peertube_icon);
|
|
|
|
break;
|
|
|
|
case "GNU":
|
|
|
|
item.setIcon(R.drawable.ic_gnu_social);
|
|
|
|
break;
|
|
|
|
case "MISSKEY":
|
|
|
|
item.setIcon(R.drawable.misskey);
|
|
|
|
break;
|
|
|
|
case "PIXELFED":
|
|
|
|
item.setIcon(R.drawable.pixelfed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( item != null){
|
|
|
|
int finalI = i;
|
|
|
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
if( finalI < tabLayout.getTabCount() && tabLayout.getTabAt(finalI) != null) {
|
|
|
|
tabLayout.getTabAt(finalI).select();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
popup.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
|
|
|
navigationView.setNavigationItemSelectedListener(this);
|
2019-08-28 14:43:10 +02:00
|
|
|
Helper.hideMenuItem(BaseMainActivity.this, navigationView.getMenu());
|
2018-11-02 14:42:29 +01:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
toot = findViewById(R.id.toot);
|
2019-01-05 10:05:09 +01:00
|
|
|
tootShow();
|
2019-01-03 12:15:42 +01:00
|
|
|
delete_all = findViewById(R.id.delete_all);
|
|
|
|
add_new = findViewById(R.id.add_new);
|
2017-11-02 14:44:14 +01:00
|
|
|
|
2019-04-28 14:58:33 +02:00
|
|
|
main_app_container = findViewById(R.id.main_app_container);
|
2019-04-21 18:50:56 +02:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
2019-04-25 07:38:34 +02:00
|
|
|
new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2019-01-03 12:15:42 +01:00
|
|
|
|
|
|
|
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
|
|
|
|
TabLayout.Tab pTabsub = tabLayout.newTab();
|
|
|
|
TabLayout.Tab pTabOver = tabLayout.newTab();
|
|
|
|
TabLayout.Tab pTabTrend = tabLayout.newTab();
|
|
|
|
TabLayout.Tab pTabAdded = tabLayout.newTab();
|
|
|
|
TabLayout.Tab pTabLocal = tabLayout.newTab();
|
|
|
|
|
|
|
|
pTabsub.setCustomView(R.layout.tab_badge);
|
|
|
|
pTabOver.setCustomView(R.layout.tab_badge);
|
|
|
|
pTabTrend.setCustomView(R.layout.tab_badge);
|
|
|
|
pTabAdded.setCustomView(R.layout.tab_badge);
|
|
|
|
pTabLocal.setCustomView(R.layout.tab_badge);
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconSub = pTabsub.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
|
|
|
|
iconSub.setImageResource(R.drawable.ic_subscriptions);
|
|
|
|
|
2019-05-18 11:10:30 +02:00
|
|
|
if (theme == Helper.THEME_BLACK)
|
2019-01-03 12:15:42 +01:00
|
|
|
iconSub.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
|
|
|
else
|
|
|
|
iconSub.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN);
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconOver = pTabOver.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
iconOver.setImageResource(R.drawable.ic_overview);
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconTrend = pTabTrend.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
iconTrend.setImageResource(R.drawable.ic_trending_up);
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconAdded = pTabAdded.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
iconAdded.setImageResource(R.drawable.ic_recently_added);
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconLocal = pTabLocal.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
iconLocal.setImageResource(R.drawable.ic_home);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iconSub.setContentDescription(getString(R.string.subscriptions));
|
|
|
|
iconOver.setContentDescription(getString(R.string.overview));
|
|
|
|
iconTrend.setContentDescription(getString(R.string.trending));
|
|
|
|
iconAdded.setContentDescription(getString(R.string.recently_added));
|
|
|
|
iconLocal.setContentDescription(getString(R.string.local));
|
|
|
|
|
|
|
|
|
2019-05-18 11:10:30 +02:00
|
|
|
if (theme == Helper.THEME_LIGHT) {
|
2019-01-03 12:15:42 +01:00
|
|
|
iconSub.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconOver.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconTrend.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconAdded.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
|
|
|
} else {
|
|
|
|
iconSub.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconOver.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconTrend.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconAdded.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
|
|
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2018-10-17 18:20:03 +02:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
toot.setImageResource(R.drawable.ic_cloud_upload);
|
|
|
|
|
|
|
|
tabLayout.addTab(pTabsub);
|
|
|
|
tabLayout.addTab(pTabOver);
|
|
|
|
tabLayout.addTab(pTabTrend);
|
|
|
|
tabLayout.addTab(pTabAdded);
|
|
|
|
tabLayout.addTab(pTabLocal);
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-28 14:58:33 +02:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
adapter = new PagerAdapter
|
|
|
|
(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());
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
2019-01-03 11:19:45 +01:00
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2019-01-03 11:19:45 +01:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
2019-01-14 11:50:42 +01:00
|
|
|
tootShow();
|
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-01-14 11:50:42 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTabUnselected(TabLayout.Tab tab) {
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_LIGHT)
|
2019-01-14 11:50:42 +01:00
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
|
|
|
else
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTabReselected(TabLayout.Tab tab) {
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-01-14 11:50:42 +01:00
|
|
|
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);
|
2019-01-30 17:39:10 +01:00
|
|
|
if( viewPager.getAdapter() != null) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition());
|
|
|
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
displayStatusFragment.scrollToTop();
|
|
|
|
}
|
2019-01-14 11:50:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//Scroll to top when top bar is clicked for favourites/blocked/muted
|
|
|
|
toolbarTitle.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tabLayout.getSelectedTabPosition());
|
|
|
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
displayStatusFragment.scrollToTop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
|
|
|
|
TabLayout.Tab pfTabHome = tabLayout.newTab();
|
|
|
|
TabLayout.Tab pfTabLocal = tabLayout.newTab();
|
2019-01-15 16:36:30 +01:00
|
|
|
TabLayout.Tab pfTabNotification = tabLayout.newTab();
|
2019-01-15 15:41:30 +01:00
|
|
|
//TabLayout.Tab pfTabDiscover = tabLayout.newTab();
|
2019-01-14 11:50:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pfTabHome.setCustomView(R.layout.tab_badge);
|
|
|
|
pfTabLocal.setCustomView(R.layout.tab_badge);
|
2019-01-15 16:36:30 +01:00
|
|
|
pfTabNotification.setCustomView(R.layout.tab_badge);
|
2019-01-15 15:41:30 +01:00
|
|
|
//pfTabDiscover.setCustomView(R.layout.tab_badge);
|
2019-01-14 11:50:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconHome = pfTabHome.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
|
|
|
|
iconHome.setImageResource(R.drawable.ic_home);
|
|
|
|
|
2019-05-18 11:10:30 +02:00
|
|
|
if (theme == Helper.THEME_BLACK)
|
2019-01-14 11:50:42 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconLocal = pfTabLocal.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
iconLocal.setImageResource(R.drawable.ic_people);
|
|
|
|
|
|
|
|
|
2019-01-15 16:36:30 +01:00
|
|
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
|
|
|
ImageView iconNotif = pfTabNotification.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
iconNotif.setImageResource(R.drawable.ic_notifications);
|
|
|
|
|
2019-01-15 15:41:30 +01:00
|
|
|
/*@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
2019-01-14 11:50:42 +01:00
|
|
|
ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon);
|
2019-01-15 15:41:30 +01:00
|
|
|
iconDiscover.setImageResource(R.drawable.ic_people);*/
|
2019-01-14 11:50:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iconHome.setContentDescription(getString(R.string.home_menu));
|
2019-01-15 15:41:30 +01:00
|
|
|
// iconDiscover.setContentDescription(getString(R.string.overview));
|
2019-01-14 11:50:42 +01:00
|
|
|
iconLocal.setContentDescription(getString(R.string.local));
|
2019-01-15 16:36:30 +01:00
|
|
|
iconNotif.setContentDescription(getString(R.string.notifications));
|
2019-01-14 11:50:42 +01:00
|
|
|
|
2019-05-18 11:10:30 +02:00
|
|
|
if (theme == Helper.THEME_LIGHT) {
|
2019-01-14 11:50:42 +01:00
|
|
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
2019-01-15 15:41:30 +01:00
|
|
|
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
2019-01-14 11:50:42 +01:00
|
|
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
2019-01-15 16:36:30 +01:00
|
|
|
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
2019-01-14 11:50:42 +01:00
|
|
|
} else {
|
|
|
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-01-15 15:41:30 +01:00
|
|
|
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-01-14 11:50:42 +01:00
|
|
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-01-15 16:36:30 +01:00
|
|
|
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-01-14 11:50:42 +01:00
|
|
|
}
|
|
|
|
|
2019-01-16 11:33:18 +01:00
|
|
|
|
2019-01-14 11:50:42 +01:00
|
|
|
|
|
|
|
tabLayout.addTab(pfTabHome);
|
|
|
|
tabLayout.addTab(pfTabLocal);
|
2019-01-15 16:36:30 +01:00
|
|
|
tabLayout.addTab(pfTabNotification);
|
2019-01-15 15:41:30 +01:00
|
|
|
// tabLayout.addTab(pfTabDiscover);
|
2019-01-16 11:33:18 +01:00
|
|
|
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
|
|
|
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
2019-01-14 11:50:42 +01:00
|
|
|
|
|
|
|
adapter = new PagerAdapter
|
|
|
|
(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());
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2019-01-14 11:50:42 +01:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
tootShow();
|
2019-01-03 11:19:45 +01:00
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
2019-01-03 12:15:42 +01:00
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-01-03 12:15:42 +01:00
|
|
|
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);
|
2019-01-03 11:19:45 +01:00
|
|
|
|
2018-10-17 18:20:03 +02:00
|
|
|
}
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2018-11-02 14:42:29 +01:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
@Override
|
|
|
|
public void onTabUnselected(TabLayout.Tab tab) {
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_LIGHT)
|
2019-01-03 12:15:42 +01:00
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
|
|
|
else
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2019-01-03 12:15:42 +01:00
|
|
|
}
|
2019-01-02 14:22:57 +01:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
@Override
|
|
|
|
public void onTabReselected(TabLayout.Tab tab) {
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-01-03 12:15:42 +01:00
|
|
|
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);
|
|
|
|
}
|
2018-12-19 18:58:54 +01:00
|
|
|
}
|
2019-01-03 12:15:42 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
//Scroll to top when top bar is clicked for favourites/blocked/muted
|
|
|
|
toolbarTitle.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tabLayout.getSelectedTabPosition());
|
|
|
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
displayStatusFragment.scrollToTop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (theme == Helper.THEME_DARK) {
|
|
|
|
style = R.style.DialogDark;
|
|
|
|
} else if (theme == Helper.THEME_BLACK){
|
|
|
|
style = R.style.DialogBlack;
|
|
|
|
}else {
|
|
|
|
style = R.style.Dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_LIGHT){
|
2019-01-03 12:15:42 +01:00
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_home,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_notifications,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_direct_messages,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_people,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_public,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_color_lens,R.color.dark_icon);
|
|
|
|
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_subscriptions,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_overview,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_trending_up,R.color.dark_icon);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_recently_added,R.color.dark_icon);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
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_direct_messages,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_people,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_public,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_color_lens,R.color.dark_text);
|
|
|
|
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_subscriptions,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_overview,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_trending_up,R.color.dark_text);
|
|
|
|
changeDrawableColor(getApplicationContext(), R.drawable.ic_recently_added,R.color.dark_text);
|
|
|
|
}
|
|
|
|
|
2019-07-03 17:28:17 +02:00
|
|
|
boolean live_notification = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
|
|
|
|
|
|
|
if( live_notification && (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA))
|
2019-01-03 12:15:42 +01:00
|
|
|
startSreaming();
|
|
|
|
|
2019-07-03 17:28:17 +02:00
|
|
|
if( hidde_menu != null)
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(hidde_menu);
|
2019-08-19 18:30:47 +02:00
|
|
|
|
|
|
|
if( update_topbar != null)
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(update_topbar);
|
2019-07-03 17:28:17 +02:00
|
|
|
hidde_menu = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Bundle b = intent.getExtras();
|
|
|
|
assert b != null;
|
|
|
|
String menu = b.getString("menu");
|
|
|
|
if( menu != null){
|
|
|
|
if( menu.equals("hide_admin")){
|
|
|
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
|
|
|
MenuItem admin = navigationView.getMenu().findItem(R.id.nav_administration);
|
|
|
|
if( admin != null){
|
|
|
|
admin.setVisible(false);
|
|
|
|
}
|
|
|
|
}else if(menu.equals("show_admin")){
|
|
|
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
|
|
|
MenuItem admin = navigationView.getMenu().findItem(R.id.nav_administration);
|
|
|
|
if( admin != null){
|
|
|
|
admin.setVisible(true);
|
|
|
|
}
|
|
|
|
}else if(menu.equals("hide_news")){
|
|
|
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
|
|
|
MenuItem news = navigationView.getMenu().findItem(R.id.nav_news);
|
|
|
|
if( news != null){
|
|
|
|
news.setVisible(false);
|
|
|
|
}
|
|
|
|
}else if(menu.equals("show_news")){
|
|
|
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
|
|
|
MenuItem news = navigationView.getMenu().findItem(R.id.nav_news);
|
|
|
|
if( news != null){
|
|
|
|
news.setVisible(true);
|
|
|
|
}
|
|
|
|
}else if(menu.equals("show_list_button")){
|
|
|
|
displayTimelineMoreButton(true);
|
|
|
|
}else if(menu.equals("hide_list_button")){
|
|
|
|
displayTimelineMoreButton(false);
|
|
|
|
}else if(menu.equals("theme")){
|
|
|
|
recreate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
2019-08-19 18:30:47 +02:00
|
|
|
update_topbar = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
int position = 0;
|
|
|
|
if( tabLayout != null)
|
|
|
|
position = tabLayout.getSelectedTabPosition();
|
|
|
|
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}
|
|
|
|
};
|
2019-07-03 17:28:17 +02:00
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(hidde_menu, new IntentFilter(Helper.RECEIVE_HIDE_ITEM));
|
2019-08-19 18:30:47 +02:00
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(update_topbar, new IntentFilter(Helper.RECEIVE_UPDATE_TOPBAR));
|
2019-01-03 12:15:42 +01:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
2019-01-03 11:19:45 +01:00
|
|
|
public boolean onQueryTextSubmit(String query) {
|
|
|
|
//Hide keyboard
|
2019-05-18 11:10:30 +02:00
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
2019-01-03 11:19:45 +01:00
|
|
|
assert imm != null;
|
|
|
|
imm.hideSoftInputFromWindow(toolbar_search.getWindowToken(), 0);
|
|
|
|
String peertube = null;
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
query= query.replaceAll("^#+", "");
|
|
|
|
//It's not a peertube search
|
2019-05-08 16:22:19 +02:00
|
|
|
//Peertube search
|
|
|
|
if(tabLayout != null && timelines != null && (timelines.get(tabLayout.getSelectedTabPosition()).getType() == ManageTimelines.Type.PEERTUBE || (timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance() != null && timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance().getType().equals("PEERTUBE")))){
|
|
|
|
DisplayStatusFragment statusFragment;
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
2019-07-13 17:51:05 +02:00
|
|
|
String instance = "peertube.fedilab.app";
|
2019-05-08 16:22:19 +02:00
|
|
|
if(timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance() != null && timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance().getType().equals("PEERTUBE"))
|
|
|
|
instance = timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance().getHost();
|
|
|
|
bundle.putString("remote_instance", instance);
|
|
|
|
bundle.putString("instanceType", "PEERTUBE");
|
|
|
|
bundle.putString("search_peertube", query);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
String fragmentTag = "REMOTE_INSTANCE";
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
|
|
|
|
if( main_app_container.getVisibility() == View.GONE){
|
|
|
|
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
delete_instance.setVisibility(View.VISIBLE);
|
2019-06-25 18:29:08 +02:00
|
|
|
viewPager.setVisibility(View.GONE);
|
|
|
|
manageTimelineList(false);
|
|
|
|
tabLayout.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}else if ( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
|
|
|
DisplayStatusFragment statusFragment;
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
|
|
|
bundle.putString("remote_instance", instance);
|
|
|
|
bundle.putString("instanceType", "PEERTUBE");
|
|
|
|
bundle.putString("search_peertube", query);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
String fragmentTag = "REMOTE_INSTANCE";
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
|
|
|
|
if( main_app_container.getVisibility() == View.GONE){
|
|
|
|
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
delete_instance.setVisibility(View.VISIBLE);
|
2019-05-08 16:22:19 +02:00
|
|
|
viewPager.setVisibility(View.GONE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
2019-05-08 16:22:19 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}else{
|
2019-02-08 19:13:40 +01:00
|
|
|
if( social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
2019-05-08 12:24:15 +02:00
|
|
|
boolean isAccount = false;
|
|
|
|
if( query.split("@").length > 1 ){
|
|
|
|
isAccount = true;
|
|
|
|
}
|
2019-03-31 18:57:53 +02:00
|
|
|
if( (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
2019-05-08 16:22:19 +02:00
|
|
|
&& !query.contains("http://") && !query.contains("https://") && !isAccount){
|
2019-03-31 11:58:40 +02:00
|
|
|
Intent intent = new Intent(BaseMainActivity.this, SearchResultTabActivity.class);
|
|
|
|
intent.putExtra("search", query);
|
|
|
|
startActivity(intent);
|
|
|
|
}else{
|
|
|
|
Intent intent = new Intent(BaseMainActivity.this, SearchResultActivity.class);
|
|
|
|
intent.putExtra("search", query);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2019-02-03 19:18:04 +01:00
|
|
|
}else{
|
|
|
|
Intent intent = new Intent(BaseMainActivity.this, HashTagActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putString("tag", query.trim());
|
|
|
|
intent.putExtras(b);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2019-01-12 17:36:24 +01:00
|
|
|
toolbar_search.setQuery("", false);
|
|
|
|
toolbar_search.setIconified(true);
|
2019-01-03 11:19:45 +01:00
|
|
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
2019-01-03 11:19:45 +01:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
tabLayout.setVisibility(View.GONE);
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2019-01-03 11:19:45 +01:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
return false;
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
@Override
|
2019-01-03 11:19:45 +01:00
|
|
|
public boolean onQueryTextChange(String newText) {
|
|
|
|
return false;
|
2017-11-22 19:29:53 +01:00
|
|
|
}
|
|
|
|
});
|
2019-01-03 11:19:45 +01:00
|
|
|
//Hide/Close the searchview
|
2017-11-22 19:09:22 +01:00
|
|
|
|
2018-10-18 17:58:56 +02:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
toolbar_search.setOnCloseListener(new SearchView.OnCloseListener() {
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
2019-01-03 11:19:45 +01:00
|
|
|
public boolean onClose() {
|
|
|
|
if( main_app_container.getVisibility() == View.VISIBLE){
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
2019-01-03 11:19:45 +01:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
2018-12-05 17:51:28 +01:00
|
|
|
}else {
|
2019-01-03 11:19:45 +01:00
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2019-01-03 11:19:45 +01:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
2017-11-02 14:44:14 +01:00
|
|
|
}
|
2019-01-03 11:19:45 +01:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
//your code here
|
|
|
|
return false;
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2019-01-03 11:19:45 +01:00
|
|
|
});
|
|
|
|
toolbar_search.setOnSearchClickListener(new View.OnClickListener() {
|
2017-10-17 13:13:35 +02:00
|
|
|
@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);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
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);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
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);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2018-10-17 18:20:03 +02:00
|
|
|
delete_instance.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());
|
|
|
|
|
2019-04-22 13:16:35 +02:00
|
|
|
/*if( tabLayout.getTabAt(0) == null) {
|
2019-02-14 17:46:38 +01:00
|
|
|
Helper.logout(BaseMainActivity.this);
|
|
|
|
return;
|
|
|
|
}
|
2018-11-03 18:27:33 +01:00
|
|
|
tabLayout.getTabAt(0).select();
|
2019-04-22 13:16:35 +02:00
|
|
|
*/
|
2019-02-08 15:07:46 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
2019-01-03 18:12:24 +01:00
|
|
|
toot.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), TootActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
toot.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
CrossActions.doCrossReply(BaseMainActivity.this, null, null, false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2019-01-30 10:01:26 +01:00
|
|
|
}else if(social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
|
|
|
|
toot.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), PeertubeUploadActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
});
|
2019-01-03 18:12:24 +01:00
|
|
|
}
|
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) {
|
2019-06-11 19:38:26 +02:00
|
|
|
drawer.openDrawer(GravityCompat.START);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
});
|
2019-08-01 09:42:05 +02:00
|
|
|
Helper.loadPictureIcon(BaseMainActivity.this, account,iconbar);
|
2017-10-17 13:13:35 +02:00
|
|
|
headerLayout = navigationView.getHeaderView(0);
|
2018-10-17 19:06:25 +02:00
|
|
|
|
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());
|
|
|
|
|
2019-01-14 11:50:42 +01:00
|
|
|
if( social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
2019-01-03 18:12:24 +01:00
|
|
|
MenuItem action_about_instance = popup.getMenu().findItem(R.id.action_about_instance);
|
|
|
|
if( action_about_instance != null)
|
|
|
|
action_about_instance.setVisible(false);
|
|
|
|
MenuItem action_export = popup.getMenu().findItem(R.id.action_export);
|
|
|
|
if( action_export != null)
|
|
|
|
action_export.setVisible(false);
|
2019-08-17 16:20:24 +02:00
|
|
|
MenuItem action_send_invitation = popup.getMenu().findItem(R.id.action_send_invitation);
|
|
|
|
if( action_send_invitation != null)
|
|
|
|
action_send_invitation.setVisible(false);
|
2019-01-03 18:12:24 +01:00
|
|
|
}
|
2019-02-09 08:30:19 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
|
|
|
MenuItem action_size = popup.getMenu().findItem(R.id.action_size);
|
|
|
|
if (action_size != null)
|
|
|
|
action_size.setVisible(false);
|
|
|
|
}
|
2019-01-03 18:12:24 +01:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
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;
|
2019-01-29 11:56:01 +01:00
|
|
|
case R.id.action_logout_account:
|
2019-01-29 14:18:55 +01:00
|
|
|
Helper.logoutCurrentUser(BaseMainActivity.this);
|
2019-01-29 11:56:01 +01:00
|
|
|
return true;
|
2017-10-17 13:13:35 +02:00
|
|
|
case R.id.action_privacy:
|
2018-09-01 08:13:22 +02:00
|
|
|
Intent intent = new Intent(getApplicationContext(), PrivacyActivity.class);
|
2017-10-17 13:13:35 +02:00
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
case R.id.action_about_instance:
|
|
|
|
intent = new Intent(getApplicationContext(), InstanceActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
2019-08-17 16:14:47 +02:00
|
|
|
case R.id.action_send_invitation:
|
|
|
|
if( instanceClass != null){
|
|
|
|
if(instanceClass.isRegistration()){
|
|
|
|
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
|
|
|
String extra_text = getString(R.string.join_instance, Helper.getLiveInstance(getApplicationContext()),
|
|
|
|
"https://f-droid.org/en/packages/fr.gouv.etalab.mastodon/",
|
|
|
|
"https://play.google.com/store/apps/details?id=app.fedilab.android",
|
|
|
|
"https://fedilab.app/registration_helper/" + Helper.getLiveInstance(getApplicationContext()));
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
|
|
|
|
sendIntent.setType("text/plain");
|
|
|
|
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
|
|
|
|
}else{
|
|
|
|
Toasty.info(getApplicationContext(), getString(R.string.registration_closed), Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2017-10-17 13:13:35 +02:00
|
|
|
case R.id.action_cache:
|
2019-01-18 16:11:48 +01:00
|
|
|
new Helper.CacheTask(BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2017-10-17 13:13:35 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_size:
|
2019-05-18 11:10:30 +02:00
|
|
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2017-10-17 13:13:35 +02:00
|
|
|
int textSize = sharedpreferences.getInt(Helper.SET_TEXT_SIZE,110);
|
|
|
|
int iconSize = sharedpreferences.getInt(Helper.SET_ICON_SIZE,130);
|
|
|
|
|
2018-11-18 13:33:12 +01:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(BaseMainActivity.this, style);
|
2017-10-17 13:13:35 +02:00
|
|
|
builder.setTitle(R.string.text_size);
|
|
|
|
|
2019-08-18 17:41:10 +02:00
|
|
|
View popup_quick_settings = getLayoutInflater().inflate( R.layout.popup_text_size, new LinearLayout(getApplicationContext()), false );
|
2017-10-17 13:13:35 +02:00
|
|
|
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 ) {
|
2019-05-18 11:10:30 +02:00
|
|
|
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
2018-01-06 17:13:18 +01:00
|
|
|
} else {
|
|
|
|
Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class);
|
|
|
|
startService(backupIntent);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
Intent backupIntent = new Intent(BaseMainActivity.this, BackupStatusService.class);
|
|
|
|
startService(backupIntent);
|
|
|
|
}
|
|
|
|
return true;
|
2019-01-25 11:41:39 +01:00
|
|
|
|
|
|
|
case R.id.action_import_data:
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
|
if (ContextCompat.checkSelfPermission(BaseMainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
|
|
|
PackageManager.PERMISSION_GRANTED) {
|
|
|
|
ActivityCompat.requestPermissions(BaseMainActivity.this,
|
|
|
|
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
|
|
|
TootActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
2019-03-02 15:43:40 +01:00
|
|
|
intent.setType("*/*");
|
|
|
|
String[] mimetypes = {"*/*"};
|
2019-01-25 11:41:39 +01:00
|
|
|
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
|
|
|
|
startActivityForResult(intent, PICK_IMPORT);
|
|
|
|
}else {
|
2019-03-02 15:43:40 +01:00
|
|
|
intent.setType("*/*");
|
2019-01-25 11:41:39 +01:00
|
|
|
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
|
|
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_import));
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {pickIntent});
|
|
|
|
startActivityForResult(chooserIntent, PICK_IMPORT);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
case R.id.action_export_data:
|
2019-03-02 11:15:52 +01:00
|
|
|
if(Build.VERSION.SDK_INT >= 23 ){
|
|
|
|
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) {
|
2019-05-18 11:10:30 +02:00
|
|
|
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
2019-03-02 11:15:52 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2019-05-18 11:10:30 +02:00
|
|
|
Sqlite.exportDB(BaseMainActivity.this);
|
2019-01-25 11:41:39 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
2019-01-14 11:50:42 +01:00
|
|
|
if( social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
|
2019-01-03 18:12:24 +01:00
|
|
|
optionInfo.setVisibility(View.GONE);
|
2018-11-04 16:00:44 +01:00
|
|
|
MenuFloating.tags = new ArrayList<>();
|
2019-05-18 11:10:30 +02:00
|
|
|
Helper.updateHeaderAccountInfo(activity, 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);
|
2019-06-08 19:12:42 +02:00
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2019-05-20 17:48:16 +02:00
|
|
|
if (!BuildConfig.DONATIONS) {
|
|
|
|
MenuItem openCollectiveItem = navigationView.getMenu().findItem(R.id.nav_opencollective);
|
|
|
|
if( openCollectiveItem != null){
|
|
|
|
openCollectiveItem.setVisible(false);
|
|
|
|
}
|
2019-05-20 17:56:59 +02:00
|
|
|
MenuItem partnerShipItem = navigationView.getMenu().findItem(R.id.nav_partnership);
|
|
|
|
if( partnerShipItem != null){
|
|
|
|
partnerShipItem.setVisible(false);
|
|
|
|
}
|
2019-05-20 17:48:16 +02:00
|
|
|
}
|
2019-06-29 16:51:35 +02:00
|
|
|
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
2019-06-22 12:18:51 +02:00
|
|
|
MenuItem adminItem = navigationView.getMenu().findItem(R.id.nav_administration);
|
|
|
|
if( adminItem != null){
|
|
|
|
adminItem.setVisible(false);
|
|
|
|
}
|
2019-08-25 17:21:34 +02:00
|
|
|
MenuItem notificationArchive = navigationView.getMenu().findItem(R.id.nav_archive_notifications);
|
|
|
|
if( notificationArchive != null){
|
|
|
|
notificationArchive.setVisible(false);
|
|
|
|
}
|
|
|
|
|
2019-06-22 12:18:51 +02:00
|
|
|
}else{
|
|
|
|
boolean display_admin_menu = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userId + instance, false);
|
|
|
|
if( !display_admin_menu){
|
|
|
|
MenuItem adminItem = navigationView.getMenu().findItem(R.id.nav_administration);
|
|
|
|
if( adminItem != null){
|
|
|
|
adminItem.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) {
|
2019-05-18 11:10:30 +02:00
|
|
|
Helper.menuAccounts(BaseMainActivity.this);
|
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);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
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);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
|
|
|
}
|
2018-10-17 18:20:03 +02:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-08-24 14:15:08 +02:00
|
|
|
|
|
|
|
|
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);
|
2019-08-04 10:33:52 +02:00
|
|
|
if( !popupShown && (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)){
|
|
|
|
AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style);
|
2017-10-17 13:13:35 +02:00
|
|
|
LayoutInflater inflater = getLayoutInflater();
|
2019-08-18 17:41:10 +02:00
|
|
|
View dialogView = inflater.inflate(R.layout.popup_quick_settings, new LinearLayout(getApplicationContext()), false);
|
2019-03-02 11:15:52 +01:00
|
|
|
dialogBuilderOptin.setView(dialogView);
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2019-03-02 11:15:52 +01:00
|
|
|
//final SwitchCompat set_push_hometimeline = dialogView.findViewById(R.id.set_push_hometimeline);
|
2017-10-21 16:56:17 +02:00
|
|
|
final SwitchCompat set_push_notification = dialogView.findViewById(R.id.set_push_notification);
|
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_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
|
|
|
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
2019-07-04 12:14:26 +02:00
|
|
|
boolean notifif_notifications = !( !notif_follow && !notif_add && !notif_mention && !notif_share);
|
2019-03-02 11:15:52 +01:00
|
|
|
//set_push_hometimeline.setChecked(notif_hometimeline);
|
2017-10-17 13:13:35 +02:00
|
|
|
set_push_notification.setChecked(notifif_notifications);
|
|
|
|
|
2019-03-02 11:15:52 +01:00
|
|
|
dialogBuilderOptin.setTitle(R.string.settings_popup_title);
|
|
|
|
dialogBuilderOptin.setCancelable(false);
|
|
|
|
dialogBuilderOptin.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
2017-10-17 13:13:35 +02:00
|
|
|
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_MENTION, set_push_notification.isChecked());
|
|
|
|
editor.putBoolean(Helper.SET_NOTIF_SHARE, set_push_notification.isChecked());
|
2019-05-04 13:07:09 +02:00
|
|
|
editor.putBoolean(Helper.SET_NOTIF_POLL, set_push_notification.isChecked());
|
2017-10-17 13:13:35 +02:00
|
|
|
editor.putBoolean(Helper.SET_POPUP_PUSH, true);
|
|
|
|
editor.apply();
|
2019-06-04 15:01:26 +02:00
|
|
|
/*if( set_push_notification.isChecked() ){
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
|
|
|
intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName()));
|
|
|
|
startActivity(intent);
|
|
|
|
} catch (ActivityNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2019-02-06 18:03:47 +01:00
|
|
|
});
|
|
|
|
try {
|
2019-03-02 11:15:52 +01:00
|
|
|
dialogBuilderOptin.show();
|
2019-02-06 18:03:47 +01:00
|
|
|
}catch (Exception ignored){};
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
|
2019-01-10 11:51:25 +01:00
|
|
|
|
|
|
|
|
2018-10-17 19:06:25 +02:00
|
|
|
mamageNewIntent(getIntent());
|
2017-12-06 14:06:45 +01:00
|
|
|
|
2019-02-08 15:07:46 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
2019-01-11 16:39:01 +01:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
// Retrieves instance
|
|
|
|
new RetrieveInstanceAsyncTask(getApplicationContext(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
// Retrieves filters
|
2019-08-05 18:10:49 +02:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
|
|
|
new ManageFiltersAsyncTask(getApplicationContext(), GET_ALL_FILTER, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}
|
2019-01-03 12:15:42 +01:00
|
|
|
}
|
2019-05-20 17:48:16 +02:00
|
|
|
|
2019-05-21 18:21:58 +02:00
|
|
|
/* Clean cache for statuses */
|
|
|
|
AsyncTask.execute(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
Date date = new Date( System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10));
|
|
|
|
String dateString = Helper.dateToString(date);
|
|
|
|
new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString);
|
|
|
|
}
|
|
|
|
});
|
2019-05-20 17:48:16 +02:00
|
|
|
|
2019-08-18 17:17:47 +02:00
|
|
|
mutedAccount = new TempMuteDAO(getApplicationContext(), db).getAllTimeMuted(account);
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
2019-05-19 14:33:24 +02:00
|
|
|
private void manageTimelineList(boolean displayed){
|
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
|
|
boolean display_timeline_in_list = sharedpreferences.getBoolean(Helper.SET_DISPLAY_TIMELINE_IN_LIST, false);
|
|
|
|
if( !display_timeline_in_list){
|
|
|
|
display_timeline.setVisibility(View.GONE);
|
|
|
|
}else{
|
|
|
|
if( displayed){
|
|
|
|
display_timeline.setVisibility(View.VISIBLE);
|
|
|
|
}else{
|
|
|
|
display_timeline.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-14 13:42:13 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
protected abstract void rateThisApp();
|
|
|
|
|
|
|
|
|
|
|
|
@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){
|
2018-08-27 18:38:49 +02:00
|
|
|
|
|
|
|
if( intent == 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();
|
2019-06-05 14:35:42 +02:00
|
|
|
String userIdIntent, instanceIntent;
|
2019-05-18 11:10:30 +02:00
|
|
|
if( extras != null && extras.containsKey(Helper.INTENT_ACTION) ){
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2019-05-18 11:10:30 +02:00
|
|
|
userIdIntent = extras.getString(Helper.PREF_KEY_ID); //Id of the account in the intent
|
2019-06-05 14:35:42 +02:00
|
|
|
instanceIntent = extras.getString(Helper.PREF_INSTANCE);
|
2019-05-18 11:10:30 +02:00
|
|
|
if (extras.getInt(Helper.INTENT_ACTION) == Helper.NOTIFICATION_INTENT){
|
2019-06-05 14:35:42 +02:00
|
|
|
Helper.changeUser(BaseMainActivity.this, userIdIntent, instanceIntent,true); //Connects the account which is related to the notification
|
2019-05-18 11:10:30 +02:00
|
|
|
Helper.unCheckAllMenuItems(navigationView);
|
2019-05-04 19:15:03 +02:00
|
|
|
notificationChecked = true;
|
2019-05-18 11:10:30 +02:00
|
|
|
if( extras.getString(Helper.INTENT_TARGETED_ACCOUNT) != null ){
|
2018-01-06 14:07:49 +01:00
|
|
|
Intent intentShow = new Intent(BaseMainActivity.this, ShowAccountActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
2019-05-18 11:10:30 +02:00
|
|
|
b.putString("accountId", extras.getString(Helper.INTENT_TARGETED_ACCOUNT));
|
2018-01-06 14:07:49 +01:00
|
|
|
intentShow.putExtras(b);
|
|
|
|
startActivity(intentShow);
|
|
|
|
}
|
2019-05-18 11:10:30 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.RELOAD_MYVIDEOS){
|
2019-01-12 17:36:24 +01:00
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
|
|
|
bundle.putString("instanceType","PEERTUBE");
|
2019-05-18 11:10:30 +02:00
|
|
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-02-08 15:07:46 +01:00
|
|
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
|
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
2019-01-12 17:36:24 +01:00
|
|
|
bundle.putString("targetedid",account.getUsername());
|
|
|
|
bundle.putBoolean("ownvideos", true);
|
|
|
|
fragment.setArguments(bundle);
|
|
|
|
String fragmentTag = "MY_VIDEOS";
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, fragment, fragmentTag).commit();
|
|
|
|
}
|
2019-05-18 11:10:30 +02:00
|
|
|
else if( extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_INSTANCE){
|
|
|
|
String instance = extras.getString(Helper.INSTANCE_NAME);
|
2018-10-17 19:06:25 +02:00
|
|
|
DisplayStatusFragment statusFragment;
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
|
|
|
bundle.putString("remote_instance", instance);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
String fragmentTag = "REMOTE_INSTANCE";
|
|
|
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
|
|
|
|
main_app_container.setVisibility(View.VISIBLE);
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
delete_instance.setVisibility(View.VISIBLE);
|
|
|
|
viewPager.setVisibility(View.GONE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
2018-10-17 19:06:25 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
|
|
|
toolbarTitle.setText(instance);
|
2019-05-18 11:10:30 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.HOME_TIMELINE_INTENT){
|
2019-06-05 14:35:42 +02:00
|
|
|
Helper.changeUser(BaseMainActivity.this, userIdIntent, instanceIntent,false); //Connects the account which is related to the notification
|
2019-05-18 11:10:30 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.BACK_TO_SETTINGS){
|
|
|
|
Helper.unCheckAllMenuItems(navigationView);
|
2017-10-17 13:13:35 +02:00
|
|
|
navigationView.setCheckedItem(R.id.nav_settings);
|
|
|
|
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
|
|
|
toolbarTitle.setText(R.string.settings);
|
2019-05-18 11:10:30 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.BACK_TO_SETTINGS){
|
|
|
|
Helper.unCheckAllMenuItems(navigationView);
|
2019-01-06 15:36:01 +01:00
|
|
|
navigationView.setCheckedItem(R.id.nav_peertube_settings);
|
|
|
|
navigationView.getMenu().performIdentifierAction(R.id.nav_peertube_settings, 0);
|
|
|
|
toolbarTitle.setText(R.string.settings);
|
2019-05-18 11:10:30 +02:00
|
|
|
}else if (extras.getInt(Helper.INTENT_ACTION) == Helper.ADD_USER_INTENT){
|
2017-12-08 07:22:42 +01:00
|
|
|
this.recreate();
|
2019-05-18 11:10:30 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.BACKUP_INTENT){
|
2018-02-17 15:42:09 +01:00
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class);
|
|
|
|
startActivity(myIntent);
|
2019-08-25 17:21:34 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.BACKUP_NOTIFICATION_INTENT){
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, OwnerNotificationActivity.class);
|
|
|
|
startActivity(myIntent);
|
2019-08-28 14:43:10 +02:00
|
|
|
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.REDRAW_MENU){
|
|
|
|
Helper.hideMenuItem(BaseMainActivity.this, navigationView.getMenu());
|
2019-08-25 17:21:34 +02:00
|
|
|
}
|
|
|
|
else if( extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_TAG){
|
2019-04-27 11:51:19 +02:00
|
|
|
new SyncTimelinesAsyncTask(BaseMainActivity.this, -1, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2019-05-18 11:10:30 +02:00
|
|
|
} else if( extras.getInt(Helper.INTENT_ACTION) == Helper.REFRESH_TIMELINE){
|
2019-04-27 17:37:52 +02:00
|
|
|
int position = 0;
|
|
|
|
if( tabLayout != null)
|
|
|
|
position = tabLayout.getSelectedTabPosition();
|
|
|
|
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2019-05-18 11:10:30 +02:00
|
|
|
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_REMOTE) {
|
|
|
|
String url = extras.getString(Helper.SEARCH_URL);
|
2018-09-23 17:50:10 +02:00
|
|
|
intent.replaceExtras(new Bundle());
|
|
|
|
intent.setAction("");
|
|
|
|
intent.setData(null);
|
|
|
|
intent.setFlags(0);
|
2018-09-01 15:59:16 +02:00
|
|
|
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;
|
2018-08-14 11:47:26 +02:00
|
|
|
}
|
2018-09-01 15:59:16 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}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);
|
2019-05-18 11:10:30 +02:00
|
|
|
boolean shouldRetrieveMetaData = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE).getBoolean(Helper.SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL, true);
|
2019-03-23 10:09:25 +01:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
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
|
|
|
}
|
2019-03-23 10:09:25 +01:00
|
|
|
new RetrieveMetaDataAsyncTask(BaseMainActivity.this, shouldRetrieveMetaData, sharedSubject, sharedText, url,BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
2018-09-28 18:05:18 +02:00
|
|
|
} else if (type.startsWith("image/") || type.startsWith("video/")) {
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2018-09-01 18:24:01 +02:00
|
|
|
if( !TootActivity.active){
|
|
|
|
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
|
|
|
if (imageUri != null) {
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putParcelable("sharedUri", imageUri);
|
|
|
|
b.putInt("uriNumberMast", 1);
|
|
|
|
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
|
|
|
if (imageUri != null) {
|
|
|
|
intent = new Intent(getApplicationContext(), TootActivity.class);
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
|
intent .putExtra("imageUri", imageUri.toString());
|
|
|
|
startActivity(intent );
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2018-09-01 18:24:01 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null ) {
|
2018-09-28 18:05:18 +02:00
|
|
|
if (type.startsWith("image/") || type.startsWith("video/")) {
|
2017-10-17 13:13:35 +02:00
|
|
|
|
|
|
|
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();
|
2019-07-12 17:23:31 +02:00
|
|
|
|
|
|
|
if( url == null) {
|
|
|
|
intent.replaceExtras(new Bundle());
|
|
|
|
intent.setAction("");
|
|
|
|
intent.setData(null);
|
|
|
|
intent.setFlags(0);
|
2017-12-20 09:33:32 +01:00
|
|
|
return;
|
2019-07-12 17:23:31 +02:00
|
|
|
}
|
2017-12-20 09:33:32 +01:00
|
|
|
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;
|
|
|
|
}
|
2019-07-12 17:23:31 +02:00
|
|
|
if(!isUrl) {
|
|
|
|
intent.replaceExtras(new Bundle());
|
|
|
|
intent.setAction("");
|
|
|
|
intent.setData(null);
|
|
|
|
intent.setFlags(0);
|
2017-12-20 09:33:32 +01:00
|
|
|
return;
|
2019-07-12 17:23:31 +02:00
|
|
|
}
|
2017-12-20 09:33:32 +01:00
|
|
|
//Here we know that the intent contains a valid URL
|
2019-07-12 17:23:31 +02:00
|
|
|
if( !url.contains("medium.com")) {
|
|
|
|
new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, url, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
|
|
}else{
|
|
|
|
forwardToBrowser(intent);
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
intent.replaceExtras(new Bundle());
|
|
|
|
intent.setAction("");
|
|
|
|
intent.setData(null);
|
|
|
|
intent.setFlags(0);
|
|
|
|
}
|
|
|
|
|
2019-07-12 17:23:31 +02:00
|
|
|
private void forwardToBrowser(Intent i) {
|
|
|
|
Intent intent = new Intent();
|
|
|
|
intent.setAction(android.content.Intent.ACTION_VIEW);
|
|
|
|
intent.setDataAndType(i.getData(), i.getType());
|
|
|
|
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
|
|
|
|
ArrayList<Intent> targetIntents = new ArrayList<Intent>();
|
|
|
|
String thisPackageName = getApplicationContext().getPackageName();
|
|
|
|
for (ResolveInfo currentInfo : activities) {
|
|
|
|
String packageName = currentInfo.activityInfo.packageName;
|
|
|
|
if (!thisPackageName.equals(packageName)) {
|
|
|
|
Intent targetIntent = new Intent(android.content.Intent.ACTION_VIEW);
|
|
|
|
targetIntent.setDataAndType(intent.getData(),intent.getType());
|
|
|
|
targetIntent.setPackage(intent.getPackage());
|
|
|
|
targetIntent.setComponent(new ComponentName(packageName, currentInfo.activityInfo.name));
|
|
|
|
targetIntents.add(targetIntent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(targetIntents.size() > 0) {
|
|
|
|
Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), getString(R.string.open_with));
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[] {}));
|
|
|
|
startActivity(chooserIntent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
2017-10-21 16:56:17 +02:00
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
2019-04-22 19:10:07 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
} else {
|
2018-10-20 14:39:24 +02:00
|
|
|
displayPeertube = null;
|
2017-10-17 13:13:35 +02:00
|
|
|
//Hide search bar on back pressed
|
|
|
|
if( !toolbar_search.isIconified()){
|
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( viewPager.getVisibility() == View.VISIBLE){
|
2019-04-27 18:10:48 +02:00
|
|
|
super.onBackPressed();
|
2018-10-17 18:20:03 +02:00
|
|
|
} else {
|
2017-10-17 13:13:35 +02:00
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
2018-10-17 18:20:03 +02:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
2018-09-26 14:53:41 +02:00
|
|
|
delete_all.hide();
|
2018-10-20 12:22:35 +02:00
|
|
|
|
2018-09-26 14:53:41 +02:00
|
|
|
add_new.hide();
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2019-05-18 11:10:30 +02:00
|
|
|
Helper.unCheckAllMenuItems(navigationView);
|
2019-01-05 10:05:09 +01:00
|
|
|
tootShow();
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume(){
|
|
|
|
super.onResume();
|
2018-10-15 19:08:30 +02:00
|
|
|
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("isMainActivityRunning", true).apply();
|
2019-01-05 14:02:13 +01:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
//Proceeds to update of the authenticated account
|
2018-09-25 18:37:03 +02:00
|
|
|
if(Helper.isLoggedIn(getApplicationContext())) {
|
2019-01-03 10:23:31 +01:00
|
|
|
new UpdateAccountInfoByIDAsyncTask(getApplicationContext(), social, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2018-09-25 18:37:03 +02:00
|
|
|
}
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-05-09 19:03:02 +02:00
|
|
|
String datestr = sharedpreferences.getString(Helper.HOME_LAST_READ + userId + instance,null);
|
|
|
|
|
|
|
|
if( timelines != null && timelines.size() > 0 && mPageReferenceMap != null && datestr != null){
|
|
|
|
Date date = Helper.stringToDate(getApplicationContext(), datestr);
|
2019-05-11 12:51:13 +02:00
|
|
|
Date dateAllowed = new Date( System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(30));
|
2019-05-09 19:03:02 +02:00
|
|
|
//Refresh home if needed
|
2019-05-11 12:51:13 +02:00
|
|
|
if( dateAllowed.after(date) ) {
|
2019-05-09 19:03:02 +02:00
|
|
|
for (ManageTimelines tl : timelines) {
|
2019-08-24 17:33:10 +02:00
|
|
|
if (tl.getType() == ManageTimelines.Type.HOME && mPageReferenceMap != null && mPageReferenceMap.containsKey(tl.getPosition())) {
|
2019-05-09 19:03:02 +02:00
|
|
|
DisplayStatusFragment homeTimeline = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
|
|
|
|
if (homeTimeline != null) {
|
|
|
|
homeTimeline.retrieveMissingHome();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
2019-05-09 19:03:02 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
2019-05-09 19:03:02 +02:00
|
|
|
if( userId != null && instance != null) {
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-05-09 19:03:02 +02:00
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(Helper.HOME_LAST_READ + userId + instance, Helper.dateToString(new Date()));
|
|
|
|
editor.apply();
|
|
|
|
}
|
2018-10-15 19:08:30 +02:00
|
|
|
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("isMainActivityRunning", false).apply();
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDestroy(){
|
|
|
|
super.onDestroy();
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2018-10-15 19:08:30 +02:00
|
|
|
boolean backgroundProcess = sharedpreferences.getBoolean(Helper.SET_KEEP_BACKGROUND_PROCESS, true);
|
|
|
|
if(!backgroundProcess)
|
2019-08-30 17:41:15 +02:00
|
|
|
sendBroadcast(new Intent(getApplicationContext(), StopLiveNotificationReceiver.class));
|
2019-07-03 17:28:17 +02:00
|
|
|
if( hidde_menu != null)
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(hidde_menu);
|
2019-08-19 18:30:47 +02:00
|
|
|
if( update_topbar != null)
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(update_topbar);
|
2019-08-19 13:19:50 +02:00
|
|
|
if( mPageReferenceMap != null)
|
|
|
|
mPageReferenceMap = null;
|
2018-10-15 19:08:30 +02:00
|
|
|
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("isMainActivityRunning", false).apply();
|
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();
|
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;
|
2019-08-25 17:21:34 +02:00
|
|
|
}else if( id == R.id.nav_archive_notifications) {
|
|
|
|
Intent myIntent = new Intent(BaseMainActivity.this, OwnerNotificationActivity.class);
|
|
|
|
startActivity(myIntent);
|
|
|
|
return false;
|
2019-04-27 17:37:52 +02:00
|
|
|
}else if(id == R.id.nav_drag_timelines){
|
|
|
|
Intent intent = new Intent(getApplicationContext(), ReorderTimelinesActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2019-06-19 14:58:57 +02:00
|
|
|
}else if(id == R.id.nav_administration){
|
|
|
|
Intent intent = new Intent(getApplicationContext(), AdminActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2018-09-01 08:13:22 +02:00
|
|
|
} else if( id == R.id.nav_about) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2019-02-09 08:42:30 +01:00
|
|
|
}else if (id == R.id.nav_opencollective) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), OpencollectiveActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2019-01-07 16:44:19 +01:00
|
|
|
} else if( id == R.id.nav_upload) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), PeertubeUploadActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2018-09-01 08:13:22 +02:00
|
|
|
} else if( id == R.id.nav_partnership) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), PartnerShipActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2019-07-01 18:39:46 +02:00
|
|
|
}else if (id == R.id.nav_settings) {
|
|
|
|
Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2019-07-13 12:20:41 +02:00
|
|
|
} else if(id == R.id.nav_blocked_domains){
|
|
|
|
Intent intent = new Intent(getApplicationContext(), MutedInstanceActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return false;
|
2018-02-17 11:28:52 +01:00
|
|
|
}
|
2017-10-21 16:56:17 +02:00
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
2019-05-18 11:10:30 +02:00
|
|
|
Helper.unCheckAllMenuItems(navigationView);
|
2017-10-17 13:13:35 +02:00
|
|
|
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);
|
2018-10-17 18:20:03 +02:00
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
viewPager.setVisibility(View.GONE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(false);
|
2017-10-27 18:05:57 +02:00
|
|
|
tabLayout.setVisibility(View.GONE);
|
2017-10-17 13:13:35 +02:00
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
2018-10-17 18:20:03 +02:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
2017-11-02 15:22:47 +01:00
|
|
|
appBar.setExpanded(true);
|
2018-10-21 18:43:57 +02:00
|
|
|
if (id != R.id.nav_drafts && id != R.id.nav_bookmarks && id != R.id.nav_peertube ) {
|
2018-09-26 14:53:41 +02:00
|
|
|
delete_all.hide();
|
2017-10-30 07:54:02 +01:00
|
|
|
}else{
|
2018-09-26 14:53:41 +02:00
|
|
|
delete_all.show();
|
2017-10-30 07:54:02 +01:00
|
|
|
}
|
2019-06-23 14:43:35 +02:00
|
|
|
if( id != R.id.nav_list && id != R.id.nav_filters && id != R.id.nav_peertube_playlists && id != R.id.nav_blocked_domains){
|
2018-09-26 14:53:41 +02:00
|
|
|
add_new.hide();
|
2017-11-23 18:16:47 +01:00
|
|
|
}else{
|
2018-09-26 14:53:41 +02:00
|
|
|
add_new.show();
|
2017-11-23 18:16:47 +01:00
|
|
|
}
|
2019-07-01 18:39:46 +02:00
|
|
|
if (id == R.id.nav_peertube_settings) {
|
2019-01-06 15:36:01 +01:00
|
|
|
toot.hide();
|
|
|
|
SettingsPeertubeFragment settingsPeertubeFragment= new SettingsPeertubeFragment();
|
|
|
|
fragmentTag = "TABLAYOUT_PEERTUBE_SETTINGS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, settingsPeertubeFragment, fragmentTag).commit();
|
|
|
|
|
2019-01-24 15:44:01 +01:00
|
|
|
}else if (id == R.id.nav_peertube_notifications) {
|
|
|
|
toot.hide();
|
|
|
|
DisplayPeertubeNotificationsFragment displayPeertubeNotificationsFragment= new DisplayPeertubeNotificationsFragment();
|
|
|
|
fragmentTag = "PEERTUBE_NOTIFICATIONS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayPeertubeNotificationsFragment, fragmentTag).commit();
|
|
|
|
|
2019-01-16 11:33:18 +01:00
|
|
|
}else if (id == R.id.nav_favorites || id == R.id.nav_pixelfed_favorites) {
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
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();
|
2019-01-07 17:00:03 +01:00
|
|
|
} else if (id == R.id.nav_my_video) {
|
|
|
|
bundle = new Bundle();
|
|
|
|
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
2019-01-09 17:30:18 +01:00
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
2019-01-07 17:00:03 +01:00
|
|
|
bundle.putString("instanceType","PEERTUBE");
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
|
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
2019-02-08 15:07:46 +01:00
|
|
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
|
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
2019-01-07 17:00:03 +01:00
|
|
|
bundle.putString("targetedid",account.getUsername());
|
2019-01-07 19:16:15 +01:00
|
|
|
bundle.putBoolean("ownvideos", true);
|
2019-01-07 17:00:03 +01:00
|
|
|
fragment.setArguments(bundle);
|
|
|
|
fragmentTag = "MY_VIDEOS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, fragment, fragmentTag).commit();
|
2019-05-26 12:04:00 +02:00
|
|
|
} else if (id == R.id.nav_peertube_history) {
|
|
|
|
bundle = new Bundle();
|
|
|
|
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PEERTUBE_HISTORY);
|
|
|
|
bundle.putString("instanceType","PEERTUBE");
|
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
|
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
|
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
|
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
|
|
|
bundle.putString("targetedid",account.getUsername());
|
|
|
|
fragment.setArguments(bundle);
|
|
|
|
fragmentTag = "MY_HISTORY";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, fragment, fragmentTag).commit();
|
2019-06-08 18:55:30 +02:00
|
|
|
} else if (id == R.id.nav_news) {
|
|
|
|
toot.hide();
|
|
|
|
statusFragment = new DisplayStatusFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.NEWS);
|
|
|
|
statusFragment.setArguments(bundle);
|
|
|
|
fragmentTag = "NEWS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
|
2019-01-16 11:33:18 +01:00
|
|
|
} else if (id == R.id.nav_blocked || id == R.id.nav_pixelfed_blocked) {
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
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();
|
2018-09-29 09:58:46 +02:00
|
|
|
}else if (id == R.id.nav_how_to) {
|
|
|
|
toot.hide();
|
|
|
|
DisplayHowToFragment displayHowToFragment = new DisplayHowToFragment();
|
|
|
|
fragmentTag = "HOW_TO_VIDEOS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayHowToFragment, fragmentTag).commit();
|
2019-01-16 11:33:18 +01:00
|
|
|
}else if (id == R.id.nav_muted || id == R.id.nav_pixelfed_muted) {
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
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) {
|
2019-01-05 10:05:09 +01:00
|
|
|
tootShow();
|
2018-12-09 13:59:40 +01:00
|
|
|
TabLayoutScheduleFragment tabLayoutScheduleFragment = new TabLayoutScheduleFragment();
|
2017-10-17 13:13:35 +02:00
|
|
|
fragmentTag = "SCHEDULED";
|
|
|
|
fragmentManager.beginTransaction()
|
2018-12-09 13:59:40 +01:00
|
|
|
.replace(R.id.main_app_container, tabLayoutScheduleFragment, fragmentTag).commit();
|
2017-10-17 13:13:35 +02:00
|
|
|
}else if (id == R.id.nav_drafts) {
|
|
|
|
DisplayDraftsFragment displayDraftsFragment = new DisplayDraftsFragment();
|
|
|
|
fragmentTag = "DRAFTS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayDraftsFragment, fragmentTag).commit();
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
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();
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
2018-10-21 18:43:57 +02:00
|
|
|
}else if (id == R.id.nav_peertube) {
|
|
|
|
DisplayFavoritesPeertubeFragment displayFavoritesPeertubeFragment = new DisplayFavoritesPeertubeFragment();
|
|
|
|
fragmentTag = "BOOKMARKS_PEERTUBE";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayFavoritesPeertubeFragment, fragmentTag).commit();
|
|
|
|
toot.hide();
|
2017-10-17 13:13:35 +02:00
|
|
|
}else if( id == R.id.nav_follow_request){
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
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){
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
2017-12-13 18:04:29 +01:00
|
|
|
DisplayListsFragment displayListsFragment = new DisplayListsFragment();
|
|
|
|
fragmentTag = "LISTS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayListsFragment, fragmentTag).commit();
|
2019-07-24 10:05:15 +02:00
|
|
|
}else if(id == R.id.nav_group){
|
|
|
|
toot.hide();
|
|
|
|
accountsFragment = new DisplayAccountsFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.GROUPS);
|
|
|
|
accountsFragment.setArguments(bundle);
|
|
|
|
fragmentTag = "GROUPS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, accountsFragment, fragmentTag).commit();
|
2019-05-26 15:56:02 +02:00
|
|
|
}else if(id == R.id.nav_peertube_playlists){
|
|
|
|
toot.hide();
|
2019-05-26 18:05:27 +02:00
|
|
|
DisplayPlaylistsFragment displayPlaylistsFragment = new DisplayPlaylistsFragment();
|
2019-05-26 15:56:02 +02:00
|
|
|
fragmentTag = "PLAYLISTS";
|
|
|
|
fragmentManager.beginTransaction()
|
2019-05-26 18:05:27 +02:00
|
|
|
.replace(R.id.main_app_container, displayPlaylistsFragment, fragmentTag).commit();
|
2018-09-05 19:37:03 +02:00
|
|
|
}else if(id == R.id.nav_filters){
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
2018-09-05 19:37:03 +02:00
|
|
|
DisplayFiltersFragment displayFiltersFragment = new DisplayFiltersFragment();
|
|
|
|
fragmentTag = "FILTERS";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, displayFiltersFragment, fragmentTag).commit();
|
2018-09-10 19:21:42 +02:00
|
|
|
}else if(id == R.id.nav_who_to_follow){
|
2018-09-26 14:53:41 +02:00
|
|
|
toot.hide();
|
2018-09-10 19:21:42 +02:00
|
|
|
WhoToFollowFragment whoToFollowFragment = new WhoToFollowFragment();
|
|
|
|
fragmentTag = "WHO_TO_FOLLOW";
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.main_app_container, whoToFollowFragment, 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
public 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 {
|
2019-05-18 11:10:30 +02:00
|
|
|
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
2019-06-05 14:35:42 +02:00
|
|
|
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
2019-05-18 11:10:30 +02:00
|
|
|
Helper.updateHeaderAccountInfo(activity, account, headerLayout);
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode,
|
|
|
|
Intent data) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
2019-05-18 11:10:30 +02:00
|
|
|
if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) {
|
2019-01-25 11:41:39 +01:00
|
|
|
if (data == null || data.getData() == null) {
|
|
|
|
Toasty.error(getApplicationContext(),getString(R.string.toot_select_file_error),Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
2019-02-23 14:39:51 +01:00
|
|
|
String filename = Helper.getFilePathFromURI(getApplicationContext(), data.getData());
|
2019-05-18 11:10:30 +02:00
|
|
|
Sqlite.importDB(BaseMainActivity.this, filename);
|
2019-01-25 11:41:39 +01:00
|
|
|
|
2019-04-19 16:05:00 +02:00
|
|
|
}else if(requestCode == PICK_IMPORT ){
|
2019-03-02 15:43:40 +01:00
|
|
|
Toasty.error(getApplicationContext(),getString(R.string.toot_select_file_error),Toast.LENGTH_LONG).show();
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-20 17:48:16 +02:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
@Override
|
|
|
|
public void onRetrieveMetaData(boolean error, String sharedSubject, String sharedText, String image, String title, String description) {
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
if( !error) {
|
|
|
|
b.putString("image", image);
|
|
|
|
b.putString("title", title);
|
|
|
|
b.putString("description", description);
|
|
|
|
}
|
|
|
|
b.putString("sharedSubject", sharedSubject);
|
|
|
|
b.putString("sharedContent", sharedText);
|
|
|
|
CrossActions.doCrossShare(BaseMainActivity.this, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
2019-08-17 16:14:47 +02:00
|
|
|
|
|
|
|
instanceClass = apiResponse.getInstance();
|
2019-06-04 11:02:15 +02:00
|
|
|
poll_limits = apiResponse.getInstance().getPoll_limits();
|
2019-01-03 11:19:45 +01:00
|
|
|
Version currentVersion = new Version(apiResponse.getInstance().getVersion());
|
|
|
|
Version minVersion = new Version("1.6");
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-01-03 11:19:45 +01:00
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(Helper.INSTANCE_VERSION + userId + instance, apiResponse.getInstance().getVersion());
|
|
|
|
editor.apply();
|
|
|
|
Helper.canPin = (currentVersion.compareTo(minVersion) == 1 || currentVersion.equals(minVersion));
|
|
|
|
}
|
|
|
|
|
|
|
|
@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.putParcelable("account", accounts.get(0));
|
|
|
|
intent.putExtras(b);
|
|
|
|
startActivity(intent);
|
|
|
|
}else if( statuses != null && statuses.size() > 0){
|
|
|
|
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
|
|
|
|
Bundle b = new Bundle();
|
2019-01-13 10:53:46 +01:00
|
|
|
b.putParcelable("status", statuses.get(0));
|
2019-01-03 11:19:45 +01:00
|
|
|
intent.putExtras(b);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRetrieveEmojiAccount(Account account) {
|
|
|
|
TextView displayedName = headerLayout.findViewById(R.id.displayedName);
|
|
|
|
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActionDone(ManageFiltersAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
|
|
|
|
if( apiResponse != null && apiResponse.getFilters() != null && apiResponse.getFilters().size() > 0){
|
|
|
|
filters = apiResponse.getFilters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-19 14:33:24 +02:00
|
|
|
public void displayTimelineMoreButton(boolean displayed){
|
2019-07-04 11:38:09 +02:00
|
|
|
if (displayed) {
|
|
|
|
display_timeline.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
display_timeline.setVisibility(View.GONE);
|
2019-05-19 14:33:24 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-03 12:15:42 +01:00
|
|
|
|
2019-04-21 18:50:56 +02:00
|
|
|
@Override
|
2019-04-25 07:38:34 +02:00
|
|
|
public void syncedTimelines(List<ManageTimelines> manageTimelines, int position) {
|
2019-04-27 17:37:52 +02:00
|
|
|
ReorderTimelinesActivity.updated = false;
|
2019-06-17 11:23:13 +02:00
|
|
|
tabLayout = new ManageTimelines().createTabs(BaseMainActivity.this, tabLayout, manageTimelines);
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-04-21 18:50:56 +02:00
|
|
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
|
|
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
|
|
|
|
2019-05-19 14:33:24 +02:00
|
|
|
|
2019-04-21 18:50:56 +02:00
|
|
|
timelines = manageTimelines;
|
2019-04-25 07:38:34 +02:00
|
|
|
if( position >= manageTimelines.size()){
|
|
|
|
position = manageTimelines.size()-1;
|
|
|
|
}
|
2019-04-27 11:51:19 +02:00
|
|
|
if( position == -1)
|
|
|
|
position = (timelines.size()-1);
|
2019-04-25 07:38:34 +02:00
|
|
|
if( position < 0)
|
|
|
|
position = 0;
|
2019-05-08 15:05:54 +02:00
|
|
|
if( toolbarTitle != null)
|
|
|
|
toolbarTitle.setVisibility(View.GONE);
|
2019-04-25 18:40:10 +02:00
|
|
|
viewPager.setOffscreenPageLimit(2);
|
2019-04-21 18:50:56 +02:00
|
|
|
main_app_container = findViewById(R.id.main_app_container);
|
2019-06-17 11:23:13 +02:00
|
|
|
|
2019-05-08 16:33:39 +02:00
|
|
|
boolean iconOnly = true;
|
|
|
|
for(ManageTimelines tl: timelines){
|
|
|
|
if( tl.getType() == ManageTimelines.Type.INSTANCE || tl.getType() == ManageTimelines.Type.TAG || tl.getType() == ManageTimelines.Type.LIST){
|
|
|
|
iconOnly = false;
|
|
|
|
}
|
|
|
|
}
|
2019-05-19 14:33:24 +02:00
|
|
|
|
2019-05-08 16:33:39 +02:00
|
|
|
if( iconOnly && timelines.size() < 5){
|
|
|
|
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
|
|
|
}else{
|
|
|
|
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
|
|
|
}
|
2019-05-19 14:33:24 +02:00
|
|
|
|
|
|
|
boolean display_timeline_in_list = sharedpreferences.getBoolean(Helper.SET_DISPLAY_TIMELINE_IN_LIST, false);
|
|
|
|
displayTimelineMoreButton(display_timeline_in_list);
|
|
|
|
|
2019-06-17 11:23:13 +02:00
|
|
|
adapter = new PagerAdapter
|
|
|
|
(getSupportFragmentManager(), tabLayout.getTabCount());
|
2019-04-21 18:50:56 +02:00
|
|
|
viewPager.setAdapter(adapter);
|
2019-05-13 17:51:43 +02:00
|
|
|
|
2019-04-21 18:50:56 +02:00
|
|
|
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
|
|
|
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
|
|
@Override
|
|
|
|
public void onTabSelected(TabLayout.Tab tab) {
|
|
|
|
viewPager.setCurrentItem(tab.getPosition());
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2019-04-21 18:50:56 +02:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
2019-04-27 18:13:06 +02:00
|
|
|
if( manageTimelines.size() > tab.getPosition() && (manageTimelines.get(tab.getPosition()).getType() == ManageTimelines.Type.NOTIFICATION ||manageTimelines.get(tab.getPosition()).getType() == ManageTimelines.Type.ART || manageTimelines.get(tab.getPosition()).getType() == ManageTimelines.Type.PEERTUBE)) {
|
2019-04-21 18:50:56 +02:00
|
|
|
toot.hide();
|
|
|
|
}else {
|
|
|
|
tootShow();
|
|
|
|
}
|
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
2019-05-04 19:06:24 +02:00
|
|
|
TextView tv = tab.getCustomView().findViewById(R.id.host_name);
|
|
|
|
|
2019-04-21 18:50:56 +02:00
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-04-21 18:50:56 +02:00
|
|
|
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);
|
2019-05-04 19:06:24 +02:00
|
|
|
else if( tv != null){
|
|
|
|
tv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4));
|
|
|
|
}
|
2019-04-21 18:50:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTabUnselected(TabLayout.Tab tab) {
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
2019-05-04 19:06:24 +02:00
|
|
|
TextView tv = tab.getCustomView().findViewById(R.id.host_name);
|
2019-04-21 18:50:56 +02:00
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_LIGHT)
|
2019-04-21 18:50:56 +02:00
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
|
|
|
else
|
|
|
|
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
2019-05-04 19:06:24 +02:00
|
|
|
else if( tv != null){
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_LIGHT)
|
2019-05-04 19:06:24 +02:00
|
|
|
tv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon));
|
|
|
|
else
|
|
|
|
tv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_text));
|
|
|
|
}
|
2019-04-21 18:50:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTabReselected(TabLayout.Tab tab) {
|
|
|
|
if( viewPager.getVisibility() == View.GONE){
|
|
|
|
viewPager.setVisibility(View.VISIBLE);
|
2019-05-19 14:33:24 +02:00
|
|
|
manageTimelineList(true);
|
2019-04-21 18:50:56 +02:00
|
|
|
delete_instance.setVisibility(View.GONE);
|
|
|
|
Helper.switchLayout(BaseMainActivity.this);
|
|
|
|
main_app_container.setVisibility(View.GONE);
|
|
|
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
|
|
|
drawer.closeDrawer(GravityCompat.START);
|
|
|
|
}
|
2019-04-22 13:16:35 +02:00
|
|
|
if( manageTimelines.size() > tab.getPosition() && (manageTimelines.get(tab.getPosition()).getType() == ManageTimelines.Type.ART || manageTimelines.get(tab.getPosition()).getType() == ManageTimelines.Type.PEERTUBE)) {
|
2019-04-21 18:50:56 +02:00
|
|
|
toot.hide();
|
|
|
|
}else {
|
|
|
|
tootShow();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( viewPager.getAdapter() != null) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition());
|
2019-04-26 14:59:52 +02:00
|
|
|
ManageTimelines tl = timelines.get(tab.getPosition());
|
2019-04-21 18:50:56 +02:00
|
|
|
DisplayStatusFragment displayStatusFragment;
|
2019-04-26 14:59:52 +02:00
|
|
|
if (tl.getType() == ManageTimelines.Type.HOME) {
|
2019-04-21 18:50:56 +02:00
|
|
|
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
countNewStatus = 0;
|
|
|
|
updateHomeCounter();
|
|
|
|
displayStatusFragment.scrollToTop();
|
|
|
|
displayStatusFragment.updateLastReadToot();
|
2019-04-26 14:59:52 +02:00
|
|
|
} else if(tl.getType() == ManageTimelines.Type.NOTIFICATION) {
|
2019-04-21 18:50:56 +02:00
|
|
|
countNewNotifications = 0;
|
2019-08-31 10:22:40 +02:00
|
|
|
|
2019-04-21 18:50:56 +02:00
|
|
|
updateNotifCounter();
|
2019-07-18 17:37:29 +02:00
|
|
|
}else {
|
|
|
|
View tabCustom = tab.getCustomView();
|
|
|
|
if( tabCustom != null) {
|
|
|
|
TextView tabCountertCustom = tabCustom.findViewById(R.id.tab_counter);
|
2019-07-19 16:01:30 +02:00
|
|
|
if( tabCountertCustom != null) {
|
|
|
|
tabCountertCustom.setText(String.valueOf(0));
|
|
|
|
tabCountertCustom.setVisibility(View.GONE);
|
|
|
|
}
|
2019-07-18 17:37:29 +02:00
|
|
|
}
|
2019-04-21 18:50:56 +02:00
|
|
|
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
displayStatusFragment.scrollToTop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( tab.getCustomView() != null) {
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-04-21 18:50:56 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-04-25 07:38:34 +02:00
|
|
|
if( tabLayout.getTabCount() > position) {
|
|
|
|
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
|
|
|
if( tab != null) {
|
|
|
|
tab.select();
|
|
|
|
if( tab.getCustomView() != null){
|
|
|
|
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
|
|
|
if( icon != null){
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-04-25 07:38:34 +02:00
|
|
|
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);
|
|
|
|
}else{
|
|
|
|
TextView tv = tabLayout.getChildAt(0).findViewById(android.R.id.title);
|
|
|
|
if( tv != null)
|
2019-05-18 11:10:30 +02:00
|
|
|
if( theme == Helper.THEME_BLACK)
|
2019-04-25 07:38:34 +02:00
|
|
|
tv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon));
|
|
|
|
else
|
|
|
|
tv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-21 18:50:56 +02:00
|
|
|
//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();
|
|
|
|
}
|
|
|
|
//Scroll to top when top bar is clicked (THEME_MENU only)
|
|
|
|
} else {
|
|
|
|
int pos = tabLayout.getSelectedTabPosition();
|
|
|
|
if( viewPager.getAdapter() != null) {
|
|
|
|
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, pos);
|
2019-04-26 14:59:52 +02:00
|
|
|
ManageTimelines tl = timelines.get(pos);
|
|
|
|
if( tl.getType() != ManageTimelines.Type.NOTIFICATION){
|
|
|
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
|
|
displayStatusFragment.scrollToTop();
|
2019-04-21 18:50:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-05-04 19:15:03 +02:00
|
|
|
if( notificationChecked){
|
|
|
|
notificationChecked = false;
|
|
|
|
int i = 0;
|
|
|
|
for(ManageTimelines tl: timelines){
|
|
|
|
if( tl.getType() == ManageTimelines.Type.NOTIFICATION){
|
|
|
|
if( tabLayout.getTabAt(i) != null) {
|
|
|
|
tabLayout.getTabAt(i).select();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2019-04-21 18:50:56 +02:00
|
|
|
}
|
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
/**
|
2019-01-14 18:16:45 +01:00
|
|
|
* Page Adapter for Mastodon & Peertube & PixelFed
|
2019-01-03 11:19:45 +01:00
|
|
|
*/
|
|
|
|
public class PagerAdapter extends FragmentStatePagerAdapter {
|
|
|
|
int mNumOfTabs;
|
|
|
|
|
|
|
|
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
|
|
|
super(fm);
|
|
|
|
this.mNumOfTabs = NumOfTabs;
|
|
|
|
}
|
|
|
|
|
2019-08-05 18:42:37 +02:00
|
|
|
@Override
|
|
|
|
public Parcelable saveState() {
|
|
|
|
return null;
|
|
|
|
}
|
2019-01-03 11:19:45 +01:00
|
|
|
@Override
|
|
|
|
public Fragment getItem(int position) {
|
2019-02-08 15:07:46 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
2019-01-03 12:15:42 +01:00
|
|
|
//Remove the search bar
|
|
|
|
if (!toolbar_search.isIconified()) {
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
}
|
2019-04-22 13:16:35 +02:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
//Selection comes from another menu, no action to do
|
|
|
|
Bundle bundle = new Bundle();
|
2019-04-21 18:50:56 +02:00
|
|
|
ManageTimelines tl = null;
|
2019-04-22 13:16:35 +02:00
|
|
|
if( position < timelines.size())
|
|
|
|
tl = timelines.get(position);
|
2019-04-21 18:50:56 +02:00
|
|
|
if( tl == null)
|
|
|
|
return null;
|
2019-04-21 19:04:08 +02:00
|
|
|
if( tl.getType() != ManageTimelines.Type.NOTIFICATION){
|
|
|
|
DisplayStatusFragment displayStatusFragment = new DisplayStatusFragment();
|
|
|
|
RetrieveFeedsAsyncTask.Type type = ManageTimelines.transform(BaseMainActivity.this, tl.getType());
|
|
|
|
bundle.putSerializable("type", type);
|
2019-04-22 13:16:35 +02:00
|
|
|
|
2019-04-21 19:04:08 +02:00
|
|
|
if (tl.getType() == ManageTimelines.Type.TAG) {
|
|
|
|
TagTimeline ttl = tl.getTagTimeline();
|
|
|
|
bundle.putString("tag", ttl.getName());
|
|
|
|
if( ttl.isART() )
|
|
|
|
bundle.putString("instanceType","ART");
|
|
|
|
}else if (tl.getType() == ManageTimelines.Type.ART) {
|
|
|
|
bundle.putString("instanceType", "ART");
|
|
|
|
}else if (tl.getType() == ManageTimelines.Type.PEERTUBE) {
|
|
|
|
bundle.putString("instanceType", "PEERTUBE");
|
2019-07-13 17:51:05 +02:00
|
|
|
bundle.putString("remote_instance", "peertube.fedilab.app");
|
2019-04-21 19:04:08 +02:00
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
|
|
|
}else if( tl.getType() == ManageTimelines.Type.INSTANCE){
|
2019-05-25 12:37:50 +02:00
|
|
|
if( tl.getRemoteInstance().getFilteredWith() == null){
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
|
|
|
}else{
|
|
|
|
bundle.putString("currentfilter", tl.getRemoteInstance().getFilteredWith());
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE_FILTERED);
|
|
|
|
}
|
2019-04-21 19:04:08 +02:00
|
|
|
bundle.putString("remote_instance", tl.getRemoteInstance().getHost()!=null?tl.getRemoteInstance().getHost():"");
|
|
|
|
bundle.putString("instanceType", tl.getRemoteInstance().getType());
|
2019-04-22 13:16:35 +02:00
|
|
|
}else if( tl.getType() == ManageTimelines.Type.LIST){
|
|
|
|
bundle.putString("targetedid", tl.getListTimeline().getId());
|
2019-04-21 19:04:08 +02:00
|
|
|
}
|
2019-04-26 15:50:26 +02:00
|
|
|
bundle.putInt("timelineId", tl.getId());
|
2019-04-22 13:16:35 +02:00
|
|
|
displayStatusFragment.setArguments(bundle);
|
2019-08-19 17:36:09 +02:00
|
|
|
if( mPageReferenceMap == null){
|
|
|
|
mPageReferenceMap = new HashMap<>();
|
|
|
|
}
|
2019-04-22 18:13:44 +02:00
|
|
|
mPageReferenceMap.put(tl.getPosition(), displayStatusFragment);
|
2019-04-21 19:04:08 +02:00
|
|
|
return displayStatusFragment;
|
|
|
|
}else{
|
2019-04-26 14:59:52 +02:00
|
|
|
TabLayoutNotificationsFragment tabLayoutNotificationsFragment = new TabLayoutNotificationsFragment();
|
2019-08-19 17:36:09 +02:00
|
|
|
if( mPageReferenceMap == null){
|
|
|
|
mPageReferenceMap = new HashMap<>();
|
|
|
|
}
|
2019-04-26 14:59:52 +02:00
|
|
|
mPageReferenceMap.put(tl.getPosition(), tabLayoutNotificationsFragment);
|
2019-04-27 11:34:51 +02:00
|
|
|
return tabLayoutNotificationsFragment;
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2019-04-21 19:04:08 +02:00
|
|
|
|
2019-01-03 12:15:42 +01:00
|
|
|
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
|
|
|
|
//Remove the search bar
|
|
|
|
if( !toolbar_search.isIconified() ) {
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
}
|
|
|
|
//Selection comes from another menu, no action to do
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
|
|
|
if (position == 0) {
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PSUBSCRIPTIONS);
|
|
|
|
}else if( position == 1) {
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.POVERVIEW);
|
|
|
|
}else if( position == 2) {
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PTRENDING);
|
|
|
|
}else if( position == 3) {
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PRECENTLYADDED);
|
|
|
|
}else if( position == 4) {
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PLOCAL);
|
|
|
|
}
|
2019-01-03 14:23:13 +01:00
|
|
|
bundle.putString("instanceType","PEERTUBE");
|
2019-01-03 12:15:42 +01:00
|
|
|
fragment.setArguments(bundle);
|
|
|
|
return fragment;
|
2019-01-14 11:50:42 +01:00
|
|
|
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
|
|
|
|
//Remove the search bar
|
|
|
|
if( !toolbar_search.isIconified() ) {
|
|
|
|
toolbarTitle.setVisibility(View.VISIBLE);
|
|
|
|
tabLayout.setVisibility(View.VISIBLE);
|
|
|
|
toolbar_search.setIconified(true);
|
|
|
|
}
|
|
|
|
//Selection comes from another menu, no action to do
|
|
|
|
Bundle bundle = new Bundle();
|
2019-01-15 16:36:30 +01:00
|
|
|
|
2019-01-14 11:50:42 +01:00
|
|
|
if (position == 0) {
|
2019-01-15 16:36:30 +01:00
|
|
|
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
2019-01-14 11:50:42 +01:00
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_HOME);
|
2019-01-15 16:36:30 +01:00
|
|
|
bundle.putString("instanceType","PIXELFED");
|
|
|
|
fragment.setArguments(bundle);
|
|
|
|
return fragment;
|
2019-01-14 11:50:42 +01:00
|
|
|
}else if( position == 1) {
|
2019-01-15 16:36:30 +01:00
|
|
|
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
2019-01-14 11:50:42 +01:00
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_LOCAL);
|
2019-01-15 16:36:30 +01:00
|
|
|
bundle.putString("instanceType","PIXELFED");
|
|
|
|
fragment.setArguments(bundle);
|
|
|
|
return fragment;
|
|
|
|
}else if( position == 2){
|
|
|
|
DisplayNotificationsFragment fragment = new DisplayNotificationsFragment();
|
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_NOTIFICATION);
|
|
|
|
fragment.setArguments(bundle);
|
|
|
|
return fragment;
|
|
|
|
}
|
|
|
|
/*else if( position == 3) {
|
2019-01-14 11:50:42 +01:00
|
|
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_DISCOVER);
|
2019-01-15 15:41:30 +01:00
|
|
|
}*/
|
2019-01-15 16:36:30 +01:00
|
|
|
|
|
|
|
return null;
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2019-01-03 12:15:42 +01:00
|
|
|
return null;
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-10 11:51:25 +01:00
|
|
|
@Override
|
|
|
|
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
2019-08-22 19:27:08 +02:00
|
|
|
if( mPageReferenceMap != null) {
|
|
|
|
mPageReferenceMap.remove(position);
|
|
|
|
}else{
|
|
|
|
mPageReferenceMap = new HashMap<>();
|
|
|
|
}
|
2019-01-10 11:51:25 +01:00
|
|
|
super.destroyItem(container, position, object);
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
|
|
|
return mNumOfTabs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
public void updateHomeCounter(){
|
2019-05-24 15:37:56 +02:00
|
|
|
int i = 0;
|
|
|
|
if( timelines != null && timelines.size() > 0){
|
|
|
|
for(ManageTimelines tl: timelines){
|
|
|
|
if( tl.getType() == ManageTimelines.Type.HOME){
|
|
|
|
if( tabLayout.getTabCount() > i) {
|
|
|
|
View tabHome = tabLayout.getTabAt(i).getCustomView();
|
|
|
|
if( tabHome != null){
|
|
|
|
TextView tabCounterHome = tabHome.findViewById(R.id.tab_counter);
|
2019-07-19 18:04:47 +02:00
|
|
|
if(countNewStatus == Helper.TOOTS_PER_PAGE){
|
|
|
|
tabCounterHome.setText(String.format(Locale.getDefault(), "%d+", countNewStatus));
|
|
|
|
}else{
|
|
|
|
tabCounterHome.setText(String.valueOf(countNewStatus));
|
|
|
|
}
|
2019-05-24 15:37:56 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-21 09:12:10 +02:00
|
|
|
public void manageTab( RetrieveFeedsAsyncTask.Type type, int value){
|
2019-05-18 11:10:30 +02:00
|
|
|
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
2019-04-21 18:50:56 +02:00
|
|
|
List<ManageTimelines> tls = new TimelinesDAO(BaseMainActivity.this, db).getDisplayedTimelines();
|
|
|
|
for (ManageTimelines tl: tls){
|
|
|
|
if( type == ManageTimelines.transform(BaseMainActivity.this, tl.getType())){
|
|
|
|
View tabCustom = tabLayout.getTabAt(tl.getPosition()).getCustomView();
|
|
|
|
assert tabCustom != null;
|
|
|
|
TextView tabCountertCustom = tabCustom.findViewById(R.id.tab_counter);
|
|
|
|
tabCountertCustom.setText(String.valueOf(value));
|
|
|
|
if( value > 0){
|
|
|
|
tabCountertCustom.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCountertCustom.setVisibility(View.GONE);
|
|
|
|
}
|
2019-04-21 09:12:10 +02:00
|
|
|
break;
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
public void updateNotifCounter(){
|
2019-05-05 11:35:34 +02:00
|
|
|
if( timelines == null)
|
2017-10-17 13:13:35 +02:00
|
|
|
return;
|
2019-05-05 11:35:34 +02:00
|
|
|
int i = 0;
|
|
|
|
int position = -1;
|
|
|
|
for(ManageTimelines tl: timelines){
|
|
|
|
if( tl.getType() == ManageTimelines.Type.NOTIFICATION){
|
|
|
|
if( tabLayout.getTabAt(i) != null) {
|
|
|
|
position = i;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if( position == -1)
|
|
|
|
return;
|
|
|
|
View tabNotif = tabLayout.getTabAt(position).getCustomView();
|
2019-01-03 11:19:45 +01:00
|
|
|
if( tabNotif == null)
|
2017-12-20 09:33:32 +01:00
|
|
|
return;
|
2019-01-03 11:19:45 +01:00
|
|
|
TextView tabCounterNotif = tabNotif.findViewById(R.id.tab_counter);
|
2019-05-05 11:35:34 +02:00
|
|
|
if( tabCounterNotif == null)
|
|
|
|
return;
|
2019-07-19 18:04:47 +02:00
|
|
|
if(countNewNotifications == Helper.NOTIFICATIONS_PER_PAGE){
|
|
|
|
tabCounterNotif.setText(String.format(Locale.getDefault(), "%d+", countNewNotifications));
|
|
|
|
}else{
|
|
|
|
tabCounterNotif.setText(String.valueOf(countNewNotifications));
|
|
|
|
}
|
2019-01-03 11:19:45 +01:00
|
|
|
if( countNewNotifications > 0){
|
|
|
|
tabCounterNotif.setVisibility(View.VISIBLE);
|
|
|
|
}else {
|
|
|
|
tabCounterNotif.setVisibility(View.GONE);
|
2017-12-20 09:33:32 +01:00
|
|
|
}
|
2019-08-31 10:22:40 +02:00
|
|
|
try{
|
|
|
|
TabLayoutNotificationsFragment tabLayoutNotificationsFragment = (TabLayoutNotificationsFragment) mPageReferenceMap.get(position);
|
|
|
|
ViewPager notifViewPager = tabLayoutNotificationsFragment.getViewPager();
|
|
|
|
|
|
|
|
if( notifViewPager != null && notifViewPager.getAdapter() != null) {
|
|
|
|
DisplayNotificationsFragment displayNotificationsFragment = (DisplayNotificationsFragment) notifViewPager.getAdapter().instantiateItem(notifViewPager, 0);
|
|
|
|
displayNotificationsFragment.updateNotificationRead();
|
|
|
|
}
|
|
|
|
}catch (Exception ignored){}
|
|
|
|
|
2017-12-20 09:33:32 +01:00
|
|
|
}
|
|
|
|
|
2018-09-25 18:37:03 +02:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
public void startSreaming(){
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-01-03 11:19:45 +01:00
|
|
|
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
|
|
|
if( liveNotifications) {
|
2019-05-18 11:10:30 +02:00
|
|
|
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
2019-01-03 11:19:45 +01:00
|
|
|
assert manager != null;
|
|
|
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
|
|
|
if (LiveNotificationService.class.getName().equals(service.service.getClassName())) {
|
|
|
|
return;
|
2018-10-22 16:18:11 +02:00
|
|
|
}
|
|
|
|
}
|
2019-02-02 10:26:58 +01:00
|
|
|
try {
|
|
|
|
Intent streamingIntent = new Intent(this, LiveNotificationService.class);
|
|
|
|
startService(streamingIntent);
|
|
|
|
}catch(Exception ignored){}
|
2018-10-22 16:18:11 +02:00
|
|
|
}
|
2018-12-28 10:41:40 +01:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
}
|
2018-12-28 10:41:40 +01:00
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
public void manageFloatingButton(boolean display){
|
2019-05-18 11:10:30 +02:00
|
|
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
2019-02-08 15:07:46 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE ||social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA|| social == UpdateAccountInfoAsyncTask.SOCIAL.GNU|| social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
2019-01-05 10:05:09 +01:00
|
|
|
if (display) {
|
|
|
|
tootShow();
|
|
|
|
} else {
|
|
|
|
toot.hide();
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
toot.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void tootShow(){
|
2019-02-08 15:07:46 +01:00
|
|
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE ||social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA|| social == UpdateAccountInfoAsyncTask.SOCIAL.GNU|| social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
2019-01-05 10:05:09 +01:00
|
|
|
toot.show();
|
2019-01-03 11:19:45 +01:00
|
|
|
}else{
|
|
|
|
toot.hide();
|
2019-01-05 10:05:09 +01:00
|
|
|
}
|
|
|
|
}
|
2019-05-04 18:28:47 +02:00
|
|
|
|
2019-05-05 12:41:45 +02:00
|
|
|
|
2019-01-05 10:05:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-03 11:19:45 +01:00
|
|
|
public boolean getFloatingVisibility(){
|
|
|
|
return toot.getVisibility() == View.VISIBLE;
|
|
|
|
}
|
2017-10-17 13:13:35 +02:00
|
|
|
|
2018-12-28 10:41:40 +01:00
|
|
|
|
2017-10-27 18:05:57 +02:00
|
|
|
}
|