forked from mirrors/Fedilab
Some changes
This commit is contained in:
parent
d77dd2c349
commit
66161f4eb3
31 changed files with 261 additions and 588 deletions
|
@ -167,6 +167,8 @@
|
|||
android:scheme="fedilab" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".mastodon.activities.StatusHistoryActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
|
@ -371,6 +373,10 @@
|
|||
</receiver>
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".peertube.activities.PeertubeMainActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
|
||||
<activity
|
||||
android:name=".peertube.activities.PeertubeActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
|
|
|
@ -39,7 +39,7 @@ import es.dmoral.toasty.Toasty;
|
|||
|
||||
public class MainApplication extends MultiDexApplication {
|
||||
|
||||
|
||||
public static String UPLOAD_CHANNEL_ID = "upload_info_peertube";
|
||||
private static MainApplication app;
|
||||
private WebView webView;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ package app.fedilab.android.peertube.activities;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static app.fedilab.android.peertube.activities.MainActivity.badgeCount;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.badgeCount;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -44,8 +44,8 @@ import com.google.android.material.tabs.TabLayout;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityAccountBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseActivity;
|
||||
import app.fedilab.android.databinding.ActivityAccountPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.AccountData.Account;
|
||||
import app.fedilab.android.peertube.fragment.DisplayAccountsFragment;
|
||||
|
@ -57,15 +57,15 @@ import app.fedilab.android.peertube.sqlite.AccountDAO;
|
|||
import app.fedilab.android.peertube.sqlite.Sqlite;
|
||||
|
||||
|
||||
public class AccountActivity extends BaseActivity {
|
||||
public class AccountActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private ActivityAccountBinding binding;
|
||||
private ActivityAccountPeertubeBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityAccountBinding.inflate(getLayoutInflater());
|
||||
binding = ActivityAccountPeertubeBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
if (getSupportActionBar() != null)
|
||||
|
|
|
@ -30,16 +30,15 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.data.PlaylistData.Playlist;
|
||||
import app.fedilab.android.peertube.client.data.VideoPlaylistData;
|
||||
import app.fedilab.android.peertube.drawer.PlaylistAdapter;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.PlaylistsVM;
|
||||
|
||||
|
||||
public class AllLocalPlaylistsActivity extends BaseActivity implements PlaylistAdapter.AllPlaylistRemoved {
|
||||
public class AllLocalPlaylistsActivity extends BaseBarActivity implements PlaylistAdapter.AllPlaylistRemoved {
|
||||
|
||||
|
||||
PlaylistAdapter playlistAdapter;
|
||||
|
@ -50,9 +49,8 @@ public class AllLocalPlaylistsActivity extends BaseActivity implements PlaylistA
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_all_playlist);
|
||||
setContentView(R.layout.activity_all_playlist_peertube);
|
||||
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
|
|
@ -55,25 +55,24 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityAllPlaylistPeertubeBinding;
|
||||
import app.fedilab.android.databinding.AddPlaylistPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.ChannelData;
|
||||
import app.fedilab.android.peertube.client.data.PlaylistData.Playlist;
|
||||
import app.fedilab.android.peertube.client.entities.Item;
|
||||
import app.fedilab.android.peertube.client.entities.PlaylistParams;
|
||||
import app.fedilab.android.peertube.databinding.ActivityAllPlaylistBinding;
|
||||
import app.fedilab.android.peertube.databinding.AddPlaylistBinding;
|
||||
import app.fedilab.android.peertube.drawer.PlaylistAdapter;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.ChannelsVM;
|
||||
import app.fedilab.android.peertube.viewmodel.PlaylistsVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class AllPlaylistsActivity extends BaseActivity implements PlaylistAdapter.AllPlaylistRemoved {
|
||||
public class AllPlaylistsActivity extends BaseBarActivity implements PlaylistAdapter.AllPlaylistRemoved {
|
||||
|
||||
|
||||
private static final int PICK_AVATAR = 467;
|
||||
|
@ -84,16 +83,15 @@ public class AllPlaylistsActivity extends BaseActivity implements PlaylistAdapte
|
|||
private Playlist playlistToEdit;
|
||||
private List<ChannelData.Channel> myChannels;
|
||||
private ChannelData.Channel selectedChannel;
|
||||
private AddPlaylistBinding bindingDialog;
|
||||
private AddPlaylistPeertubeBinding bindingDialog;
|
||||
private Uri inputData;
|
||||
private ActivityAllPlaylistBinding binding;
|
||||
private ActivityAllPlaylistPeertubeBinding binding;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
binding = ActivityAllPlaylistBinding.inflate(getLayoutInflater());
|
||||
binding = ActivityAllPlaylistPeertubeBinding.inflate(getLayoutInflater());
|
||||
View viewRoot = binding.getRoot();
|
||||
setContentView(viewRoot);
|
||||
|
||||
|
@ -163,7 +161,7 @@ public class AllPlaylistsActivity extends BaseActivity implements PlaylistAdapte
|
|||
|
||||
playlistToEdit = playlistParam;
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(AllPlaylistsActivity.this);
|
||||
bindingDialog = AddPlaylistBinding.inflate(LayoutInflater.from(AllPlaylistsActivity.this), null, false);
|
||||
bindingDialog = AddPlaylistPeertubeBinding.inflate(LayoutInflater.from(AllPlaylistsActivity.this), null, false);
|
||||
dialogBuilder.setView(bindingDialog.getRoot());
|
||||
|
||||
dialogBuilder.setView(bindingDialog.getRoot());
|
||||
|
|
|
@ -38,20 +38,19 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityInstancePickerPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.data.InstanceData;
|
||||
import app.fedilab.android.peertube.client.entities.InstanceParams;
|
||||
import app.fedilab.android.peertube.databinding.ActivityInstancePickerBinding;
|
||||
import app.fedilab.android.peertube.drawer.InstanceAdapter;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.RoundedBackgroundSpan;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.InstancesVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class InstancePickerActivity extends BaseActivity {
|
||||
public class InstancePickerActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
boolean[] checkedItemsCategory;
|
||||
|
@ -62,16 +61,15 @@ public class InstancePickerActivity extends BaseActivity {
|
|||
String[] itemsLabelLanguage;
|
||||
InstanceParams instanceParams;
|
||||
private InstancesVM viewModel;
|
||||
private ActivityInstancePickerBinding binding;
|
||||
private ActivityInstancePickerPeertubeBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
binding = ActivityInstancePickerBinding.inflate(getLayoutInflater());
|
||||
binding = ActivityInstancePickerPeertubeBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
binding.loader.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package app.fedilab.android.peertube.activities;
|
||||
/* Copyright 2020 Thomas Schneider
|
||||
*
|
||||
* This file is a part of TubeLab
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.peertube.client.data.PlaylistData;
|
||||
import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class LocalPlaylistsActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_playlists);
|
||||
|
||||
|
||||
PlaylistData.Playlist playlist;
|
||||
Bundle b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
playlist = b.getParcelable("playlist");
|
||||
if (playlist == null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Toasty.error(LocalPlaylistsActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
setTitle(playlist.getDisplayName());
|
||||
if (savedInstanceState == null) {
|
||||
DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.VIDEOS_IN_LOCAL_PLAYLIST);
|
||||
bundle.putSerializable("playlistId", playlist.getUuid());
|
||||
displayVideosFragment.setArguments(bundle);
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.add(R.id.nav_host_fragment, displayVideosFragment).commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,50 +28,38 @@ import android.util.Patterns;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.peertube.BuildConfig;
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityLoginPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.InstanceData;
|
||||
import app.fedilab.android.peertube.client.data.PluginData;
|
||||
import app.fedilab.android.peertube.client.entities.AcadInstances;
|
||||
import app.fedilab.android.peertube.client.entities.Oauth;
|
||||
import app.fedilab.android.peertube.client.entities.OauthParams;
|
||||
import app.fedilab.android.peertube.client.entities.Token;
|
||||
import app.fedilab.android.peertube.client.entities.WellKnownNodeinfo;
|
||||
import app.fedilab.android.peertube.client.mastodon.RetrofitMastodonAPI;
|
||||
import app.fedilab.android.peertube.databinding.ActivityLoginBinding;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperAcadInstance;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
public class LoginActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private static String client_id;
|
||||
private static String client_secret;
|
||||
private ActivityLoginBinding binding;
|
||||
private String acadInstance;
|
||||
private ActivityLoginPeertubeBinding binding;
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityLoginBinding.inflate(getLayoutInflater());
|
||||
binding = ActivityLoginPeertubeBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
|
@ -95,9 +83,7 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
|
||||
|
||||
if (BuildConfig.full_instances && BuildConfig.instance_switcher) {
|
||||
binding.loginInstanceContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
binding.loginInstanceContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
if (Helper.isTablet(LoginActivity.this)) {
|
||||
|
@ -115,172 +101,46 @@ public class LoginActivity extends BaseActivity {
|
|||
binding.loginPasswdContainer.setLayoutParams(layoutParamsP);
|
||||
}
|
||||
|
||||
if (!BuildConfig.full_instances) {
|
||||
|
||||
binding.loginUidContainer.setVisibility(View.GONE);
|
||||
binding.loginPasswdContainer.setVisibility(View.GONE);
|
||||
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||
binding.createAnAccountPeertube.setVisibility(View.GONE);
|
||||
binding.instancePickerTitle.setVisibility(View.VISIBLE);
|
||||
binding.instancePicker.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
List<AcadInstances> acadInstances = AcadInstances.getInstances();
|
||||
String[] academiesKey = new String[acadInstances.size()];
|
||||
String[] academiesValue = new String[acadInstances.size()];
|
||||
String acad = HelperInstance.getLiveInstance(LoginActivity.this);
|
||||
int position = 0;
|
||||
int i = 0;
|
||||
for (AcadInstances ac : acadInstances) {
|
||||
academiesKey[i] = ac.getName();
|
||||
academiesValue[i] = ac.getUrl();
|
||||
if (ac.getUrl().compareTo(acad) == 0) {
|
||||
position = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ArrayAdapter<String> adapterChannel = new ArrayAdapter<>(LoginActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, academiesKey);
|
||||
binding.instancePicker.setAdapter(adapterChannel);
|
||||
binding.instancePicker.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
acadInstance = academiesValue[position];
|
||||
binding.loginUidContainer.setVisibility(View.GONE);
|
||||
binding.loginPasswdContainer.setVisibility(View.GONE);
|
||||
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||
binding.createAnAccountPeertube.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
binding.instancePicker.setSelection(position, true);
|
||||
}
|
||||
if (BuildConfig.allow_remote_connections) {
|
||||
binding.loginInstance.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (!hasFocus) {
|
||||
if (binding.loginInstance.getText() != null) {
|
||||
new Thread(() -> {
|
||||
String testInstance = binding.loginInstance.getText().toString().trim();
|
||||
if (testInstance.length() == 0) {
|
||||
return;
|
||||
}
|
||||
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
|
||||
if (BuildConfig.allow_remote_connections) {
|
||||
instanceNodeInfo = new RetrofitPeertubeAPI(LoginActivity.this, testInstance, null).getNodeInfo();
|
||||
}
|
||||
if (instanceNodeInfo != null &&
|
||||
(instanceNodeInfo.getSoftware().getName().toUpperCase().trim().compareTo("MASTODON") == 0 ||
|
||||
instanceNodeInfo.getSoftware().getName().toUpperCase().trim().compareTo("PLEROMA") == 0)
|
||||
) {
|
||||
connectToFediverse(testInstance, instanceNodeInfo);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
binding.loginButton.setOnClickListener(v -> {
|
||||
if (!BuildConfig.full_instances && AcadInstances.isOpenId(acadInstance)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
InstanceData.InstanceConfig instanceConfig = new RetrofitPeertubeAPI(LoginActivity.this).getConfigInstance();
|
||||
PluginData.Plugin plugin = instanceConfig.getPlugin();
|
||||
List<PluginData.PluginInfo> pluginInfos = plugin.getRegistered();
|
||||
String openIdVersion = "0.0.7";
|
||||
for (PluginData.PluginInfo pluginInfo : pluginInfos) {
|
||||
if (pluginInfo.getName().toLowerCase().contains("openid")) {
|
||||
openIdVersion = pluginInfo.getVersion();
|
||||
}
|
||||
}
|
||||
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, acadInstance, null).oauthClient(null, null, null, null);
|
||||
if (oauth == null) {
|
||||
runOnUiThread(() -> {
|
||||
binding.loginButton.setEnabled(true);
|
||||
Toasty.error(LoginActivity.this, getString(R.string.client_error), Toast.LENGTH_LONG).show();
|
||||
});
|
||||
return;
|
||||
}
|
||||
client_id = oauth.getClient_id();
|
||||
client_secret = oauth.getClient_secret();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.CLIENT_ID, client_id);
|
||||
editor.putString(Helper.CLIENT_SECRET, client_secret);
|
||||
editor.apply();
|
||||
Intent intent = new Intent(LoginActivity.this, WebviewConnectActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("url", "https://" + acadInstance + "/plugins/auth-openid-connect/" + openIdVersion + "/auth/openid-connect");
|
||||
intent.putExtras(b);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
runOnUiThread(() -> {
|
||||
binding.loginButton.setEnabled(true);
|
||||
Toasty.error(LoginActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
});
|
||||
}
|
||||
|
||||
}).start();
|
||||
} else {
|
||||
if (binding.loginUid.getText() != null && binding.loginUid.getText().toString().contains("@") && !Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.email_error)).show();
|
||||
return;
|
||||
}
|
||||
binding.loginButton.setEnabled(false);
|
||||
String instance;
|
||||
if (!BuildConfig.full_instances) {
|
||||
String[] emailArray = binding.loginUid.getText().toString().split("@");
|
||||
if (emailArray.length > 1 && !Arrays.asList(HelperAcadInstance.valideEmails).contains(emailArray[1])) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.email_error_domain, emailArray[1])).show();
|
||||
binding.loginButton.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
instance = HelperInstance.getLiveInstance(LoginActivity.this);
|
||||
} else {
|
||||
if (binding.loginInstance.getText() == null || binding.loginInstance.getText().toString().trim().length() == 0) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
||||
binding.loginButton.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
instance = binding.loginInstance.getText().toString().trim().toLowerCase();
|
||||
}
|
||||
|
||||
if (instance.startsWith("http")) {
|
||||
try {
|
||||
URL url = new URL(instance);
|
||||
instance = url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (instance.endsWith("/")) {
|
||||
try {
|
||||
URL url = new URL("https://" + instance);
|
||||
instance = url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!Patterns.WEB_URL.matcher("https://" + instance).matches()) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
||||
binding.loginButton.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
String finalInstance = instance;
|
||||
new Thread(() -> {
|
||||
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
|
||||
if (BuildConfig.allow_remote_connections) {
|
||||
instanceNodeInfo = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).getNodeInfo();
|
||||
}
|
||||
connectToFediverse(finalInstance, instanceNodeInfo);
|
||||
}).start();
|
||||
if (binding.loginUid.getText() != null && binding.loginUid.getText().toString().contains("@") && !Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.email_error)).show();
|
||||
return;
|
||||
}
|
||||
binding.loginButton.setEnabled(false);
|
||||
String instance;
|
||||
if (binding.loginInstance.getText() == null || binding.loginInstance.getText().toString().trim().length() == 0) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
||||
binding.loginButton.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
instance = binding.loginInstance.getText().toString().trim().toLowerCase();
|
||||
|
||||
if (instance.startsWith("http")) {
|
||||
try {
|
||||
URL url = new URL(instance);
|
||||
instance = url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (instance.endsWith("/")) {
|
||||
try {
|
||||
URL url = new URL("https://" + instance);
|
||||
instance = url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!Patterns.WEB_URL.matcher("https://" + instance).matches()) {
|
||||
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
||||
binding.loginButton.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
String finalInstance = instance;
|
||||
new Thread(() -> {
|
||||
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
|
||||
connectToFediverse(finalInstance, instanceNodeInfo);
|
||||
}).start();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -356,17 +216,11 @@ public class LoginActivity extends BaseActivity {
|
|||
return;
|
||||
}
|
||||
proceedLogin(token, finalInstance, software.compareTo("PEERTUBE") == 0 ? null : software);
|
||||
} catch (final Exception | Error e) {
|
||||
} catch (final Exception e) {
|
||||
oauthParams.setUsername(binding.loginUid.getText().toString().toLowerCase().trim());
|
||||
try {
|
||||
if (software.compareTo("PEERTUBE") == 0) {
|
||||
Token token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams);
|
||||
proceedLogin(token, finalInstance, software.compareTo("PEERTUBE") == 0 ? null : software);
|
||||
}
|
||||
} catch (Error error) {
|
||||
Error.displayError(LoginActivity.this, error);
|
||||
error.printStackTrace();
|
||||
runOnUiThread(() -> binding.loginButton.setEnabled(true));
|
||||
if (software.compareTo("PEERTUBE") == 0) {
|
||||
Token token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams);
|
||||
proceedLogin(token, finalInstance, software.compareTo("PEERTUBE") == 0 ? null : software);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ package app.fedilab.android.peertube.activities;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static app.fedilab.android.peertube.activities.MainActivity.PICK_INSTANCE_SURF;
|
||||
import static app.fedilab.android.peertube.activities.MainActivity.showRadioButtonDialogFullInstances;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.PICK_INSTANCE_SURF;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.showRadioButtonDialogFullInstances;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -32,31 +32,29 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityManageInstancesPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.InstanceData;
|
||||
import app.fedilab.android.peertube.databinding.ActivityManageInstancesBinding;
|
||||
import app.fedilab.android.peertube.drawer.AboutInstanceAdapter;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.sqlite.Sqlite;
|
||||
import app.fedilab.android.peertube.sqlite.StoredInstanceDAO;
|
||||
import app.fedilab.android.peertube.viewmodel.InfoInstanceVM;
|
||||
|
||||
|
||||
public class ManageInstancesActivity extends BaseActivity implements AboutInstanceAdapter.AllInstancesRemoved {
|
||||
public class ManageInstancesActivity extends BaseBarActivity implements AboutInstanceAdapter.AllInstancesRemoved {
|
||||
|
||||
private ActivityManageInstancesBinding binding;
|
||||
private ActivityManageInstancesPeertubeBinding binding;
|
||||
private List<InstanceData.AboutInstance> aboutInstances;
|
||||
private AboutInstanceAdapter aboutInstanceAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityManageInstancesBinding.inflate(getLayoutInflater());
|
||||
binding = ActivityManageInstancesPeertubeBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
if (getSupportActionBar() != null) {
|
||||
|
|
|
@ -34,17 +34,16 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.entities.OauthParams;
|
||||
import app.fedilab.android.peertube.client.entities.Token;
|
||||
import app.fedilab.android.peertube.client.mastodon.RetrofitMastodonAPI;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class MastodonWebviewConnectActivity extends BaseActivity {
|
||||
public class MastodonWebviewConnectActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private WebView webView;
|
||||
|
@ -79,7 +78,6 @@ public class MastodonWebviewConnectActivity extends BaseActivity {
|
|||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_webview_connect);
|
||||
Bundle b = getIntent().getExtras();
|
||||
|
|
|
@ -47,22 +47,21 @@ import com.bumptech.glide.request.RequestOptions;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityMyAccountSettingsPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.entities.NotificationSettings;
|
||||
import app.fedilab.android.peertube.client.entities.UserMe;
|
||||
import app.fedilab.android.peertube.client.entities.UserSettings;
|
||||
import app.fedilab.android.peertube.databinding.ActivityMyAccountSettingsBinding;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.worker.WorkHelper;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
public class MyAccountActivity extends BaseActivity {
|
||||
public class MyAccountActivity extends BaseBarActivity {
|
||||
|
||||
private static final int PICK_IMAGE = 466;
|
||||
ActivityMyAccountSettingsBinding binding;
|
||||
ActivityMyAccountSettingsPeertubeBinding binding;
|
||||
private Uri inputData;
|
||||
private String fileName;
|
||||
private NotificationSettings notificationSettings;
|
||||
|
@ -70,23 +69,22 @@ public class MyAccountActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityMyAccountSettingsBinding.inflate(getLayoutInflater());
|
||||
binding = ActivityMyAccountSettingsPeertubeBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (MainActivity.userMe == null) {
|
||||
if (PeertubeMainActivity.userMe == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
setTitle(String.format("@%s", MainActivity.userMe.getUsername()));
|
||||
binding.displayname.setText(MainActivity.userMe.getAccount().getDisplayName());
|
||||
binding.description.setText(MainActivity.userMe.getAccount().getDescription());
|
||||
setTitle(String.format("@%s", PeertubeMainActivity.userMe.getUsername()));
|
||||
binding.displayname.setText(PeertubeMainActivity.userMe.getAccount().getDisplayName());
|
||||
binding.description.setText(PeertubeMainActivity.userMe.getAccount().getDescription());
|
||||
|
||||
notificationSettings = MainActivity.userMe.getNotificationSettings();
|
||||
notificationSettings = PeertubeMainActivity.userMe.getNotificationSettings();
|
||||
initializeValues(notificationSettings.getAbuseStateChange(), binding.notifAbuseAcceptedApp, binding.notifAbuseAcceptedMail);
|
||||
initializeValues(notificationSettings.getAbuseNewMessage(), binding.notifAbuseReceivedApp, binding.notifAbuseReceivedMail);
|
||||
initializeValues(notificationSettings.getCommentMention(), binding.notifVideoMentionApp, binding.notifVideoMentionMail);
|
||||
|
@ -97,7 +95,7 @@ public class MyAccountActivity extends BaseActivity {
|
|||
initializeValues(notificationSettings.getNewCommentOnMyVideo(), binding.notifNewCommentApp, binding.notifNewCommentMail);
|
||||
initializeValues(notificationSettings.getNewVideoFromSubscription(), binding.notifNewVideoApp, binding.notifNewVideoMail);
|
||||
|
||||
Helper.loadAvatar(MyAccountActivity.this, MainActivity.userMe.getAccount(), binding.profilePicture);
|
||||
Helper.loadAvatar(MyAccountActivity.this, PeertubeMainActivity.userMe.getAccount(), binding.profilePicture);
|
||||
String[] refresh_array = getResources().getStringArray(R.array.refresh_time);
|
||||
ArrayAdapter<String> refreshArray = new ArrayAdapter<>(MyAccountActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, refresh_array);
|
||||
|
@ -193,7 +191,7 @@ public class MyAccountActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_my_account, menu);
|
||||
getMenuInflater().inflate(R.menu.main_my_account_peertube, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -220,10 +218,10 @@ public class MyAccountActivity extends BaseActivity {
|
|||
try {
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(MyAccountActivity.this);
|
||||
UserMe.AvatarResponse avatarResponse = api.updateUser(userSettings);
|
||||
MainActivity.userMe.getAccount().setDisplayName(binding.displayname.getText().toString().trim());
|
||||
MainActivity.userMe.getAccount().setDescription(binding.description.getText().toString().trim());
|
||||
PeertubeMainActivity.userMe.getAccount().setDisplayName(binding.displayname.getText().toString().trim());
|
||||
PeertubeMainActivity.userMe.getAccount().setDescription(binding.description.getText().toString().trim());
|
||||
if (avatarResponse != null && avatarResponse.getAvatar() != null) {
|
||||
MainActivity.userMe.getAccount().setAvatar(avatarResponse.getAvatar());
|
||||
PeertubeMainActivity.userMe.getAccount().setAvatar(avatarResponse.getAvatar());
|
||||
}
|
||||
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
|
|
@ -120,7 +120,9 @@ import java.util.Objects;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.fedilab.android.peertube.BasePeertubeActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.databinding.ActivityPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.BuildConfig;
|
||||
import app.fedilab.android.peertube.Matomo;
|
||||
import app.fedilab.android.peertube.R;
|
||||
|
@ -141,14 +143,12 @@ import app.fedilab.android.peertube.client.entities.PlaylistExist;
|
|||
import app.fedilab.android.peertube.client.entities.Report;
|
||||
import app.fedilab.android.peertube.client.entities.UserSettings;
|
||||
import app.fedilab.android.peertube.client.mastodon.RetrofitMastodonAPI;
|
||||
import app.fedilab.android.peertube.databinding.ActivityPeertubeBinding;
|
||||
import app.fedilab.android.peertube.drawer.CommentListAdapter;
|
||||
import app.fedilab.android.peertube.drawer.MenuAdapter;
|
||||
import app.fedilab.android.peertube.drawer.MenuItemAdapter;
|
||||
import app.fedilab.android.peertube.helper.CacheDataSourceFactory;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.sqlite.AccountDAO;
|
||||
import app.fedilab.android.peertube.sqlite.Sqlite;
|
||||
import app.fedilab.android.peertube.viewmodel.CaptionsVM;
|
||||
|
@ -164,7 +164,7 @@ import app.fedilab.android.peertube.webview.MastalabWebViewClient;
|
|||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class PeertubeActivity extends BasePeertubeActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction {
|
||||
public class PeertubeActivity extends BaseBarActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction {
|
||||
|
||||
public static String video_id;
|
||||
public static List<String> playedVideos = new ArrayList<>();
|
||||
|
@ -220,9 +220,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = super.binding;
|
||||
videoOrientationType = videoOrientation.LANDSCAPE;
|
||||
max_id = "0";
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
|
|
@ -48,7 +48,9 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityPeertubeEditBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.ChannelData.Channel;
|
||||
|
@ -57,10 +59,7 @@ import app.fedilab.android.peertube.client.data.VideoData.Video;
|
|||
import app.fedilab.android.peertube.client.entities.Item;
|
||||
import app.fedilab.android.peertube.client.entities.ItemStr;
|
||||
import app.fedilab.android.peertube.client.entities.VideoParams;
|
||||
import app.fedilab.android.peertube.databinding.ActivityPeertubeEditBinding;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.ChannelsVM;
|
||||
import app.fedilab.android.peertube.viewmodel.MyVideoVM;
|
||||
import app.fedilab.android.peertube.viewmodel.PostActionsVM;
|
||||
|
@ -68,7 +67,7 @@ import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
|||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class PeertubeEditUploadActivity extends BaseActivity {
|
||||
public class PeertubeEditUploadActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private final int PICK_IMAGE = 50378;
|
||||
|
@ -87,7 +86,6 @@ public class PeertubeEditUploadActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityPeertubeEditBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
|
@ -637,7 +635,7 @@ public class PeertubeEditUploadActivity extends BaseActivity {
|
|||
|
||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse) {
|
||||
Intent intent = new Intent(PeertubeEditUploadActivity.this, MainActivity.class);
|
||||
Intent intent = new Intent(PeertubeEditUploadActivity.this, PeertubeMainActivity.class);
|
||||
intent.putExtra(Helper.INTENT_ACTION, Helper.RELOAD_MYVIDEOS);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
|
|
@ -46,7 +46,6 @@ import androidx.viewpager.widget.PagerAdapter;
|
|||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.kobakei.ratethisapp.RateThisApp;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -59,7 +58,9 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.AboutActivity;
|
||||
import app.fedilab.android.databinding.ActivityMainPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseActivity;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.AccountData.Account;
|
||||
import app.fedilab.android.peertube.client.data.InstanceData;
|
||||
|
@ -75,7 +76,6 @@ import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
|||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperAcadInstance;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.PlaylistExportHelper;
|
||||
import app.fedilab.android.peertube.helper.SwitchAccountHelper;
|
||||
import app.fedilab.android.peertube.services.RetrieveInfoService;
|
||||
import app.fedilab.android.peertube.sqlite.AccountDAO;
|
||||
|
@ -85,7 +85,7 @@ import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
|||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
||||
public abstract class PeertubeMainActivity extends BaseActivity {
|
||||
|
||||
|
||||
public static int PICK_INSTANCE = 5641;
|
||||
|
@ -100,32 +100,25 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||
= item -> {
|
||||
int itemId = item.getItemId();
|
||||
String type = null;
|
||||
if (itemId == R.id.navigation_discover) {
|
||||
setTitleCustom(R.string.title_discover);
|
||||
binding.viewpager.setCurrentItem(3);
|
||||
type = HelperAcadInstance.DISCOVER;
|
||||
} else if (itemId == R.id.navigation_subscription) {
|
||||
binding.viewpager.setCurrentItem(4);
|
||||
setTitleCustom(R.string.subscriptions);
|
||||
type = HelperAcadInstance.SUBSCRIPTIONS;
|
||||
} else if (itemId == R.id.navigation_trending) {
|
||||
setTitleCustom(R.string.title_trending);
|
||||
binding.viewpager.setCurrentItem(2);
|
||||
type = HelperAcadInstance.TRENDING;
|
||||
} else if (itemId == R.id.navigation_recently_added) {
|
||||
setTitleCustom(R.string.title_recently_added);
|
||||
binding.viewpager.setCurrentItem(1);
|
||||
type = HelperAcadInstance.RECENTLY_ADDED;
|
||||
} else if (itemId == R.id.navigation_local) {
|
||||
setTitleCustom(R.string.title_local);
|
||||
binding.viewpager.setCurrentItem(0);
|
||||
type = HelperAcadInstance.LOCAL;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) {
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -166,7 +159,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
} else {
|
||||
activity.runOnUiThread(() -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent(activity, MainActivity.class);
|
||||
Intent intent = new Intent(activity, PeertubeMainActivity.class);
|
||||
activity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
@ -191,6 +184,8 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
alert.show();
|
||||
}
|
||||
|
||||
protected abstract void rateThisApp();
|
||||
|
||||
private void setTitleCustom(int titleRId) {
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
TextView mTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
|
@ -206,14 +201,11 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
binding = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = super.binding;
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
@ -253,16 +245,16 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
mostLikedFragment.setArguments(bundle);
|
||||
|
||||
overviewFragment = new DisplayOverviewFragment();
|
||||
if (!Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (!Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
binding.viewpager.setAdapter(mPagerAdapter);
|
||||
} else {
|
||||
new Thread(() -> {
|
||||
badgeCount = new RetrofitPeertubeAPI(MainActivity.this).unreadNotifications();
|
||||
badgeCount = new RetrofitPeertubeAPI(PeertubeMainActivity.this).unreadNotifications();
|
||||
invalidateOptionsMenu();
|
||||
}).start();
|
||||
}
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
binding.viewpager.setOffscreenPageLimit(5);
|
||||
} else {
|
||||
binding.viewpager.setOffscreenPageLimit(4);
|
||||
|
@ -301,7 +293,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
|
||||
setTitleCustom(R.string.title_discover);
|
||||
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
binding.navView.inflateMenu(R.menu.bottom_nav_menu_connected_peertube);
|
||||
refreshToken();
|
||||
|
||||
|
@ -317,25 +309,15 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
peertubeInformation.setTranslations(new LinkedHashMap<>());
|
||||
startInForeground();
|
||||
|
||||
if (BuildConfig.google_restriction && BuildConfig.full_instances) {
|
||||
RateThisApp.onCreate(this);
|
||||
RateThisApp.showRateDialogIfNeeded(this);
|
||||
}
|
||||
if (!BuildConfig.full_instances) {
|
||||
PlaylistExportHelper.manageIntentUrl(MainActivity.this, getIntent());
|
||||
}
|
||||
rateThisApp();
|
||||
|
||||
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
|
||||
int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), BuildConfig.cast_enabled);
|
||||
if (search_cast == 1) {
|
||||
super.discoverCast();
|
||||
}
|
||||
//Instance
|
||||
if (HelperInstance.getLiveInstance(MainActivity.this) == null) {
|
||||
Intent intent = new Intent(MainActivity.this, InstancePickerActivity.class);
|
||||
if (HelperInstance.getLiveInstance(PeertubeMainActivity.this) == null) {
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, InstancePickerActivity.class);
|
||||
startActivityForResult(intent, PICK_INSTANCE);
|
||||
}
|
||||
}
|
||||
|
@ -362,14 +344,14 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
private void refreshToken() {
|
||||
new Thread(() -> {
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String tokenStr = Helper.getToken(MainActivity.this);
|
||||
String instance = HelperInstance.getLiveInstance(MainActivity.this);
|
||||
String tokenStr = Helper.getToken(PeertubeMainActivity.this);
|
||||
String instance = HelperInstance.getLiveInstance(PeertubeMainActivity.this);
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instanceShar = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
String userIdShar = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(MainActivity.this, db).getAccountByToken(tokenStr);
|
||||
Account account = new AccountDAO(PeertubeMainActivity.this, db).getAccountByToken(tokenStr);
|
||||
if (account == null) {
|
||||
account = new AccountDAO(MainActivity.this, db).getAccountByIdInstance(userIdShar, instanceShar);
|
||||
account = new AccountDAO(PeertubeMainActivity.this, db).getAccountByIdInstance(userIdShar, instanceShar);
|
||||
}
|
||||
if (account != null) {
|
||||
Account finalAccount = account;
|
||||
|
@ -380,23 +362,23 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
oauthParams.setRefresh_token(account.getRefresh_token());
|
||||
oauthParams.setAccess_token(account.getToken());
|
||||
try {
|
||||
Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
||||
Token token = new RetrofitPeertubeAPI(PeertubeMainActivity.this).manageToken(oauthParams);
|
||||
if (token == null) {
|
||||
return;
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
//To avoid a token issue with subscriptions, adding fragment is done when the token is refreshed.
|
||||
new Handler().post(() -> {
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
binding.viewpager.setAdapter(mPagerAdapter);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
userMe = new RetrofitPeertubeAPI(MainActivity.this, instance, token.getAccess_token()).verifyCredentials();
|
||||
userMe = new RetrofitPeertubeAPI(PeertubeMainActivity.this, instance, token.getAccess_token()).verifyCredentials();
|
||||
if (userMe != null && userMe.getAccount() != null) {
|
||||
new AccountDAO(MainActivity.this, db).updateAccount(userMe.getAccount());
|
||||
new AccountDAO(PeertubeMainActivity.this, db).updateAccount(userMe.getAccount());
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||
|
@ -417,7 +399,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
editor.apply();
|
||||
}
|
||||
}
|
||||
instanceConfig = new RetrofitPeertubeAPI(MainActivity.this).getConfigInstance();
|
||||
instanceConfig = new RetrofitPeertubeAPI(PeertubeMainActivity.this).getConfigInstance();
|
||||
} catch (Error error) {
|
||||
runOnUiThread(() -> {
|
||||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
|
||||
|
@ -425,7 +407,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
alt_bld.setMessage(R.string.refresh_token_failed_message);
|
||||
alt_bld.setNegativeButton(R.string.action_logout, (dialog, id) -> {
|
||||
dialog.dismiss();
|
||||
Helper.logoutCurrentUser(MainActivity.this, finalAccount);
|
||||
Helper.logoutCurrentUser(PeertubeMainActivity.this, finalAccount);
|
||||
});
|
||||
alt_bld.setPositiveButton(R.string._retry, (dialog, id) -> {
|
||||
dialog.dismiss();
|
||||
|
@ -443,7 +425,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_menu, menu);
|
||||
getMenuInflater().inflate(R.menu.main_menu_peertube, menu);
|
||||
|
||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) myActionMenuItem.getActionView();
|
||||
|
@ -453,13 +435,13 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
Pattern link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})(\\?start=(\\d+[hH])?(\\d+[mM])?(\\d+[sS])?)?$");
|
||||
Matcher matcherLink = link.matcher(query.trim());
|
||||
if (matcherLink.find()) {
|
||||
Intent intent = new Intent(MainActivity.this, PeertubeActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, PeertubeActivity.class);
|
||||
intent.setData(Uri.parse(query.trim()));
|
||||
startActivity(intent);
|
||||
myActionMenuItem.collapseActionView();
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent(MainActivity.this, SearchActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, SearchActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
String search = query.trim();
|
||||
b.putString("search", search);
|
||||
|
@ -487,7 +469,6 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
MenuItem sepiaSearchItem = menu.findItem(R.id.action_sepia_search);
|
||||
MenuItem incognitoItem = menu.findItem(R.id.action_incognito);
|
||||
MenuItem accountItem = menu.findItem(R.id.action_account);
|
||||
MenuItem donateItem = menu.findItem(R.id.action_donate);
|
||||
MenuItem changeInstanceItem = menu.findItem(R.id.action_change_instance);
|
||||
|
||||
FrameLayout rootView = (FrameLayout) accountItem.getActionView();
|
||||
|
@ -502,13 +483,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
redCircle.setVisibility(View.GONE);
|
||||
}
|
||||
TooltipCompat.setTooltipText(accountItem.getActionView(), getText(R.string.account));
|
||||
if (BuildConfig.FLAVOR.compareTo("google_full") == 0) {
|
||||
donateItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (!BuildConfig.instance_switcher) {
|
||||
changeInstanceItem.setVisible(false);
|
||||
}
|
||||
switch (typeOfConnection) {
|
||||
case UNKNOWN:
|
||||
accountItem.setVisible(false);
|
||||
|
@ -523,10 +498,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
case REMOTE_ACCOUNT:
|
||||
case NORMAL:
|
||||
accountItem.setVisible(true);
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (!BuildConfig.full_instances) {
|
||||
changeInstanceItem.setVisible(false);
|
||||
}
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
uploadItem.setVisible(true);
|
||||
myVideosItem.setVisible(true);
|
||||
playslistItem.setVisible(true);
|
||||
|
@ -540,7 +512,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
} else {
|
||||
uploadItem.setVisible(false);
|
||||
myVideosItem.setVisible(false);
|
||||
playslistItem.setVisible(!BuildConfig.full_instances);
|
||||
playslistItem.setVisible(false);
|
||||
historyItem.setVisible(false);
|
||||
settingsItem.setVisible(true);
|
||||
mostLikedItem.setVisible(true);
|
||||
|
@ -559,10 +531,6 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!BuildConfig.sepia_search) {
|
||||
sepiaSearchItem.setVisible(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -571,9 +539,9 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
new Thread(() -> {
|
||||
try {
|
||||
typeOfConnection = TypeOfConnection.NORMAL;
|
||||
if (!Helper.canMakeAction(MainActivity.this)) {
|
||||
if (!Helper.canMakeAction(PeertubeMainActivity.this)) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accounts = new AccountDAO(MainActivity.this, db).getAllAccount();
|
||||
List<Account> accounts = new AccountDAO(PeertubeMainActivity.this, db).getAllAccount();
|
||||
if (accounts != null && accounts.size() > 0) {
|
||||
//The user is not authenticated and there accounts in db. That means the user is surfing some other instances
|
||||
typeOfConnection = TypeOfConnection.SURFING;
|
||||
|
@ -601,52 +569,48 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
String type = null;
|
||||
String action = "TIMELINE";
|
||||
if (item.getItemId() == R.id.action_change_instance) {
|
||||
if (BuildConfig.full_instances) {
|
||||
Intent intent = new Intent(MainActivity.this, ManageInstancesActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
|
||||
} else {
|
||||
showRadioButtonDialog();
|
||||
}
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, ManageInstancesActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
|
||||
action = "CHANGE_INSTANCE";
|
||||
type = "";
|
||||
} else if (item.getItemId() == R.id.action_settings) {
|
||||
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_account) {
|
||||
Intent intent;
|
||||
if (typeOfConnection == TypeOfConnection.SURFING) {
|
||||
SwitchAccountHelper.switchDialog(MainActivity.this, false);
|
||||
SwitchAccountHelper.switchDialog(PeertubeMainActivity.this, false);
|
||||
} else {
|
||||
if (Helper.canMakeAction(MainActivity.this)) {
|
||||
intent = new Intent(MainActivity.this, AccountActivity.class);
|
||||
if (Helper.canMakeAction(PeertubeMainActivity.this)) {
|
||||
intent = new Intent(PeertubeMainActivity.this, AccountActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
|
||||
} else {
|
||||
intent = new Intent(MainActivity.this, LoginActivity.class);
|
||||
intent = new Intent(PeertubeMainActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (item.getItemId() == R.id.action_upload) {
|
||||
Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, PeertubeUploadActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_myvideos) {
|
||||
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, VideosTimelineActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("type", TimelineVM.TimelineType.MY_VIDEOS);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
type = HelperAcadInstance.MYVIDEOS;
|
||||
} else if (item.getItemId() == R.id.action_history) {
|
||||
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, VideosTimelineActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("type", TimelineVM.TimelineType.HISTORY);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
type = HelperAcadInstance.HISTORY;
|
||||
} else if (item.getItemId() == R.id.action_most_liked) {
|
||||
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, VideosTimelineActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("type", TimelineVM.TimelineType.MOST_LIKED);
|
||||
intent.putExtras(bundle);
|
||||
|
@ -654,20 +618,17 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
type = HelperAcadInstance.MOSTLIKED;
|
||||
} else if (item.getItemId() == R.id.action_playlist) {
|
||||
Intent intent;
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
intent = new Intent(MainActivity.this, AllPlaylistsActivity.class);
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
intent = new Intent(PeertubeMainActivity.this, AllPlaylistsActivity.class);
|
||||
} else {
|
||||
intent = new Intent(MainActivity.this, AllLocalPlaylistsActivity.class);
|
||||
intent = new Intent(PeertubeMainActivity.this, AllLocalPlaylistsActivity.class);
|
||||
}
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_sepia_search) {
|
||||
Intent intent = new Intent(MainActivity.this, SepiaSearchActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, SepiaSearchActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_about) {
|
||||
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_donate) {
|
||||
Intent intent = new Intent(MainActivity.this, DonationActivity.class);
|
||||
Intent intent = new Intent(PeertubeMainActivity.this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_incognito) {
|
||||
item.setChecked(!item.isChecked());
|
||||
|
@ -679,7 +640,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
UserSettings userSettings = new UserSettings();
|
||||
userSettings.setVideosHistoryEnabled(item.isChecked());
|
||||
try {
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(MainActivity.this);
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(PeertubeMainActivity.this);
|
||||
api.updateUser(userSettings);
|
||||
} catch (Exception | Error e) {
|
||||
e.printStackTrace();
|
||||
|
@ -687,9 +648,6 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
}).start();
|
||||
return false;
|
||||
}
|
||||
if (type != null) {
|
||||
Matomo.sendScreen(MainActivity.this, action, type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -704,8 +662,6 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
if (extras.getInt(Helper.INTENT_ACTION) == Helper.ADD_USER_INTENT) {
|
||||
recreate();
|
||||
}
|
||||
} else if (!BuildConfig.full_instances) {
|
||||
PlaylistExportHelper.manageIntentUrl(MainActivity.this, intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -716,7 +672,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
|
||||
alt_bld.setTitle(R.string.instance_choice);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String acad = HelperInstance.getLiveInstance(MainActivity.this);
|
||||
String acad = HelperInstance.getLiveInstance(PeertubeMainActivity.this);
|
||||
int i = 0;
|
||||
List<AcadInstances> acadInstances = AcadInstances.getInstances();
|
||||
String[] academiesKey = new String[acadInstances.size()];
|
||||
|
@ -775,7 +731,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
@NotNull
|
||||
@Override
|
||||
public Fragment getItem(final int position) {
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return locaFragment;
|
||||
|
@ -805,7 +761,7 @@ public class MainActivity extends app.fedilab.android.activities.MainActivity {
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
return 5;
|
||||
} else {
|
||||
return 4;
|
|
@ -14,7 +14,7 @@ package app.fedilab.android.peertube.activities;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static app.fedilab.android.peertube.activities.MainActivity.PICK_INSTANCE;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.PICK_INSTANCE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -31,22 +31,18 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.fedilab.android.peertube.BuildConfig;
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityRegisterPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.entities.AccountCreation;
|
||||
import app.fedilab.android.peertube.databinding.ActivityRegisterPeertubeBinding;
|
||||
import app.fedilab.android.peertube.helper.HelperAcadInstance;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
public class PeertubeRegisterActivity extends BaseActivity {
|
||||
public class PeertubeRegisterActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private String instance;
|
||||
|
@ -56,7 +52,6 @@ public class PeertubeRegisterActivity extends BaseActivity {
|
|||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityRegisterPeertubeBinding.inflate(getLayoutInflater());
|
||||
View mainView = binding.getRoot();
|
||||
|
@ -66,14 +61,8 @@ public class PeertubeRegisterActivity extends BaseActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
if (BuildConfig.full_instances && BuildConfig.instance_switcher) {
|
||||
binding.loginInstanceContainer.setVisibility(View.VISIBLE);
|
||||
binding.titleLoginInstance.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||
binding.titleLoginInstance.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
binding.loginInstanceContainer.setVisibility(View.VISIBLE);
|
||||
binding.titleLoginInstance.setVisibility(View.VISIBLE);
|
||||
|
||||
binding.username.setOnFocusChangeListener((view, focused) -> {
|
||||
if (!focused && binding.username.getText() != null) {
|
||||
|
@ -134,12 +123,7 @@ public class PeertubeRegisterActivity extends BaseActivity {
|
|||
return;
|
||||
}
|
||||
String[] emailArray = binding.email.getText().toString().split("@");
|
||||
if (!BuildConfig.full_instances) {
|
||||
if (emailArray.length > 1 && !Arrays.asList(HelperAcadInstance.valideEmails).contains(emailArray[1])) {
|
||||
Toasty.error(PeertubeRegisterActivity.this, getString(R.string.email_error_domain, emailArray[1])).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (binding.password.getText().toString().trim().length() < 8) {
|
||||
Toasty.error(PeertubeRegisterActivity.this, getString(R.string.password_too_short)).show();
|
||||
|
@ -151,20 +135,16 @@ public class PeertubeRegisterActivity extends BaseActivity {
|
|||
}
|
||||
binding.signup.setEnabled(false);
|
||||
|
||||
if (BuildConfig.full_instances) {
|
||||
if (binding.loginInstance.getText() != null) {
|
||||
instance = binding.loginInstance.getText().toString();
|
||||
} else {
|
||||
instance = "";
|
||||
}
|
||||
binding.loginInstance.setOnFocusChangeListener((view1, focus) -> {
|
||||
if (!focus) {
|
||||
setTextAgreement();
|
||||
}
|
||||
});
|
||||
if (binding.loginInstance.getText() != null) {
|
||||
instance = binding.loginInstance.getText().toString();
|
||||
} else {
|
||||
instance = HelperInstance.getLiveInstance(PeertubeRegisterActivity.this);
|
||||
instance = "";
|
||||
}
|
||||
binding.loginInstance.setOnFocusChangeListener((view1, focus) -> {
|
||||
if (!focus) {
|
||||
setTextAgreement();
|
||||
}
|
||||
});
|
||||
if (instance != null) {
|
||||
instance = instance.toLowerCase().trim();
|
||||
}
|
||||
|
@ -262,16 +242,9 @@ public class PeertubeRegisterActivity extends BaseActivity {
|
|||
String content_agreement = null;
|
||||
agreement_text.setMovementMethod(null);
|
||||
agreement_text.setText(null);
|
||||
if (BuildConfig.full_instances) {
|
||||
if (binding.loginInstance.getText() != null) {
|
||||
content_agreement = getString(R.string.agreement_check_peertube,
|
||||
"<a href='https://" + binding.loginInstance.getText().toString() + "/about/instance#terms-section' >" + tos + "</a>"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
content_agreement = getString(R.string.agreement_check,
|
||||
"<a href='https://apps.education.fr/cgu#peertube' >" + serverrules + "</a>",
|
||||
"<a href='https://apps.education.fr/bonnes-pratiques/' >" + tos + "</a>"
|
||||
if (binding.loginInstance.getText() != null) {
|
||||
content_agreement = getString(R.string.agreement_check_peertube,
|
||||
"<a href='https://" + binding.loginInstance.getText().toString() + "/about/instance#terms-section' >" + tos + "</a>"
|
||||
);
|
||||
}
|
||||
agreement_text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
|
|
@ -14,7 +14,8 @@ package app.fedilab.android.peertube.activities;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static app.fedilab.android.peertube.activities.MainActivity.userMe;
|
||||
import static app.fedilab.android.MainApplication.UPLOAD_CHANNEL_ID;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.userMe;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.DataType.MY_CHANNELS;
|
||||
import static app.fedilab.android.peertube.helper.Helper.peertubeInformation;
|
||||
|
||||
|
@ -53,22 +54,21 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.android.peertube.BaseFedilabTube;
|
||||
import app.fedilab.android.peertube.BuildConfig;
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.BuildConfig;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityPeertubeUploadBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.ChannelData;
|
||||
import app.fedilab.android.peertube.client.entities.UserMe;
|
||||
import app.fedilab.android.peertube.databinding.ActivityPeertubeUploadBinding;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.ChannelsVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class PeertubeUploadActivity extends BaseActivity {
|
||||
public class PeertubeUploadActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 724;
|
||||
|
@ -83,7 +83,6 @@ public class PeertubeUploadActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
@ -413,6 +412,6 @@ public class PeertubeUploadActivity extends BaseActivity {
|
|||
clearOnAction
|
||||
);
|
||||
|
||||
return new UploadNotificationConfig(BaseFedilabTube.UPLOAD_CHANNEL_ID, ringToneEnabled, progress, success, error, cancelled);
|
||||
return new UploadNotificationConfig(UPLOAD_CHANNEL_ID, ringToneEnabled, progress, success, error, cancelled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,31 +21,29 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.data.PlaylistData;
|
||||
import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.PlaylistExportHelper;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class PlaylistsActivity extends BaseActivity {
|
||||
public class PlaylistsActivity extends BaseBarActivity {
|
||||
|
||||
private final int PICK_IMPORT = 5556;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_playlists);
|
||||
setContentView(R.layout.activity_playlists_peertube);
|
||||
|
||||
|
||||
PlaylistData.Playlist playlist;
|
||||
|
|
|
@ -29,26 +29,24 @@ import com.google.android.material.tabs.TabLayout;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.peertube.databinding.ActivitySearchResultBinding;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivitySearchResultPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.fragment.DisplayChannelsFragment;
|
||||
import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class SearchActivity extends BaseActivity {
|
||||
public class SearchActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private String search;
|
||||
private ActivitySearchResultBinding binding;
|
||||
private ActivitySearchResultPeertubeBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivitySearchResultBinding.inflate(getLayoutInflater());
|
||||
binding = ActivitySearchResultPeertubeBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
|
|
|
@ -39,16 +39,15 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivitySepiaSearchBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.entities.SepiaSearch;
|
||||
import app.fedilab.android.peertube.databinding.ActivitySepiaSearchBinding;
|
||||
import app.fedilab.android.peertube.fragment.DisplaySepiaSearchFragment;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
|
||||
|
||||
public class SepiaSearchActivity extends BaseActivity {
|
||||
public class SepiaSearchActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private SepiaSearch sepiaSearchVideo, sepiaSearchChannel;
|
||||
|
@ -58,7 +57,6 @@ public class SepiaSearchActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivitySepiaSearchBinding.inflate(getLayoutInflater());
|
||||
View rootView = binding.getRoot();
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package app.fedilab.android.peertube.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import app.fedilab.android.peertube.fragment.SettingsFragment;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
|
||||
/* Copyright 2020 Thomas Schneider
|
||||
*
|
||||
* This file is a part of TubeLab
|
||||
|
@ -22,12 +15,17 @@ import app.fedilab.android.peertube.helper.Theme;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
public class SettingsActivity extends BaseActivity {
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.fragment.SettingsFragment;
|
||||
|
||||
public class SettingsActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
|
|
@ -46,22 +46,21 @@ import com.google.android.material.tabs.TabLayout;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.AccountData;
|
||||
import app.fedilab.android.peertube.fragment.DisplayChannelsFragment;
|
||||
import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.AccountsVM;
|
||||
import app.fedilab.android.peertube.viewmodel.PostActionsVM;
|
||||
import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class ShowAccountActivity extends BaseActivity {
|
||||
public class ShowAccountActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private ViewPager mPager;
|
||||
|
@ -75,9 +74,8 @@ public class ShowAccountActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_show_account);
|
||||
setContentView(R.layout.activity_show_account_peertube);
|
||||
setTitle("");
|
||||
Bundle b = getIntent().getExtras();
|
||||
subscriber_count = findViewById(R.id.subscriber_count);
|
||||
|
@ -105,7 +103,7 @@ public class ShowAccountActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_account, menu);
|
||||
getMenuInflater().inflate(R.menu.main_account_peertube, menu);
|
||||
if (!Helper.isLoggedIn(ShowAccountActivity.this)) {
|
||||
menu.findItem(R.id.action_mute).setVisible(false);
|
||||
}
|
||||
|
@ -124,7 +122,7 @@ public class ShowAccountActivity extends BaseActivity {
|
|||
} else if (item.getItemId() == R.id.action_report) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ShowAccountActivity.this);
|
||||
LayoutInflater inflater1 = getLayoutInflater();
|
||||
View dialogView = inflater1.inflate(R.layout.popup_report, new LinearLayout(ShowAccountActivity.this), false);
|
||||
View dialogView = inflater1.inflate(R.layout.popup_report_peertube, new LinearLayout(ShowAccountActivity.this), false);
|
||||
dialogBuilder.setView(dialogView);
|
||||
EditText report_content = dialogView.findViewById(R.id.report_content);
|
||||
dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
||||
|
|
|
@ -15,7 +15,7 @@ package app.fedilab.android.peertube.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
|
||||
import static app.fedilab.android.peertube.activities.MainActivity.TypeOfConnection.SURFING;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.TypeOfConnection.SURFING;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.FOLLOW;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.MUTE;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
|
||||
|
@ -43,7 +43,6 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
@ -59,18 +58,17 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityShowChannelBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.data.AccountData;
|
||||
import app.fedilab.android.peertube.client.data.ChannelData.Channel;
|
||||
import app.fedilab.android.peertube.databinding.ActivityShowChannelBinding;
|
||||
import app.fedilab.android.peertube.drawer.OwnAccountsAdapter;
|
||||
import app.fedilab.android.peertube.fragment.DisplayAccountsFragment;
|
||||
import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.sqlite.AccountDAO;
|
||||
import app.fedilab.android.peertube.sqlite.Sqlite;
|
||||
import app.fedilab.android.peertube.viewmodel.ChannelsVM;
|
||||
|
@ -80,7 +78,7 @@ import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
|||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class ShowChannelActivity extends BaseActivity {
|
||||
public class ShowChannelActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private Map<String, Boolean> relationship;
|
||||
|
@ -93,7 +91,6 @@ public class ShowChannelActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityShowChannelBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
@ -119,7 +116,7 @@ public class ShowChannelActivity extends BaseActivity {
|
|||
viewModel.get(sepiaSearch ? peertubeInstance : null, CHANNEL, channelAcct == null ? channel.getAcct() : channelAcct).observe(ShowChannelActivity.this, this::manageViewAccounts);
|
||||
manageChannel();
|
||||
|
||||
if (MainActivity.typeOfConnection == MainActivity.TypeOfConnection.SURFING) {
|
||||
if (PeertubeMainActivity.typeOfConnection == SURFING) {
|
||||
binding.accountFollow.setText(getString(R.string.action_follow));
|
||||
binding.accountFollow.setEnabled(true);
|
||||
new Thread(() -> {
|
||||
|
@ -160,7 +157,7 @@ public class ShowChannelActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_account, menu);
|
||||
getMenuInflater().inflate(R.menu.main_account_peertube, menu);
|
||||
if (!Helper.isLoggedIn(ShowChannelActivity.this) || sepiaSearch) {
|
||||
menu.findItem(R.id.action_mute).setVisible(false);
|
||||
}
|
||||
|
@ -178,7 +175,7 @@ public class ShowChannelActivity extends BaseActivity {
|
|||
} else if (item.getItemId() == R.id.action_report) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ShowChannelActivity.this);
|
||||
LayoutInflater inflater1 = getLayoutInflater();
|
||||
View dialogView = inflater1.inflate(R.layout.popup_report, new LinearLayout(ShowChannelActivity.this), false);
|
||||
View dialogView = inflater1.inflate(R.layout.popup_report_peertube, new LinearLayout(ShowChannelActivity.this), false);
|
||||
dialogBuilder.setView(dialogView);
|
||||
EditText report_content = dialogView.findViewById(R.id.report_content);
|
||||
dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
||||
|
@ -348,13 +345,13 @@ public class ShowChannelActivity extends BaseActivity {
|
|||
|
||||
//Manages the visibility of the button
|
||||
private void manageButtonVisibility() {
|
||||
if (relationship == null || MainActivity.typeOfConnection == SURFING || channel == null)
|
||||
if (relationship == null || PeertubeMainActivity.typeOfConnection == SURFING || channel == null)
|
||||
return;
|
||||
binding.accountFollow.setEnabled(true);
|
||||
Boolean isFollowing = relationship.get(channel.getAcct());
|
||||
if (isFollowing != null && isFollowing) {
|
||||
binding.accountFollow.setText(R.string.action_unfollow);
|
||||
binding.accountFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowChannelActivity.this, R.color.red_1)));
|
||||
binding.accountFollow.setBackgroundTintList(ColorStateList.valueOf(Helper.getAttColor(ShowChannelActivity.this, R.attr.colorError)));
|
||||
doAction = action.UNFOLLOW;
|
||||
} else {
|
||||
binding.accountFollow.setText(R.string.action_follow);
|
||||
|
|
|
@ -33,17 +33,16 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityVideosTimelineBinding;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.APIResponse;
|
||||
import app.fedilab.android.peertube.databinding.ActivityVideosTimelineBinding;
|
||||
import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
||||
|
||||
|
||||
public class VideosTimelineActivity extends BaseActivity {
|
||||
public class VideosTimelineActivity extends BaseBarActivity {
|
||||
|
||||
private TimelineVM.TimelineType type;
|
||||
private DisplayVideosFragment displayVideosFragment;
|
||||
|
@ -51,7 +50,6 @@ public class VideosTimelineActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
ActivityVideosTimelineBinding binding = ActivityVideosTimelineBinding.inflate(getLayoutInflater());
|
||||
View mainView = binding.getRoot();
|
||||
|
@ -126,7 +124,7 @@ public class VideosTimelineActivity extends BaseActivity {
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
if (type == HISTORY) {
|
||||
getMenuInflater().inflate(R.menu.main_history, menu);
|
||||
getMenuInflater().inflate(R.menu.main_history_peertube, menu);
|
||||
return true;
|
||||
} else {
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
|
|
@ -34,17 +34,16 @@ import androidx.core.content.ContextCompat;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
import app.fedilab.android.peertube.webview.CustomWebview;
|
||||
import app.fedilab.android.peertube.webview.MastalabWebChromeClient;
|
||||
import app.fedilab.android.peertube.webview.MastalabWebViewClient;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class WebviewActivity extends BaseActivity {
|
||||
public class WebviewActivity extends BaseBarActivity {
|
||||
|
||||
private String url;
|
||||
private boolean peertubeLink;
|
||||
|
@ -54,9 +53,8 @@ public class WebviewActivity extends BaseActivity {
|
|||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_webview);
|
||||
setContentView(R.layout.activity_webview_peertube);
|
||||
Bundle b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
url = b.getString("url", null);
|
||||
|
|
|
@ -37,17 +37,15 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import java.net.URL;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import app.fedilab.android.peertube.BuildConfig;
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.activities.BaseBarActivity;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.android.peertube.client.entities.OauthParams;
|
||||
import app.fedilab.android.peertube.client.entities.Token;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.Theme;
|
||||
|
||||
|
||||
public class WebviewConnectActivity extends BaseActivity {
|
||||
public class WebviewConnectActivity extends BaseBarActivity {
|
||||
|
||||
|
||||
private WebView webView;
|
||||
|
@ -75,7 +73,6 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Theme.setTheme(this, HelperInstance.getLiveInstance(this), false);
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
WebView.setWebContentsDebuggingEnabled(true);
|
||||
|
@ -102,7 +99,6 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
webView.getSettings().setAllowContentAccess(true);
|
||||
webView.getSettings().setLoadsImagesAutomatically(true);
|
||||
webView.getSettings().setSupportMultipleWindows(false);
|
||||
webView.getSettings().setAppCacheEnabled(true);
|
||||
webView.getSettings().setDatabaseEnabled(true);
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
webView.getSettings().setMediaPlaybackRequiresUserGesture(true);
|
||||
|
@ -130,7 +126,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
//Avoid to load first page for academic instances & openid
|
||||
if (!BuildConfig.full_instances && url.contains("/client")) {
|
||||
if (url.contains("/client")) {
|
||||
view.stopLoading();
|
||||
}
|
||||
}
|
||||
|
@ -156,12 +152,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
oauthParams.setPassword(externalAuthToken);
|
||||
String instance = new URL(url).getHost();
|
||||
Token token = null;
|
||||
try {
|
||||
token = new RetrofitPeertubeAPI(WebviewConnectActivity.this, instance, null).manageToken(oauthParams);
|
||||
} catch (Error error) {
|
||||
error.printStackTrace();
|
||||
Error.displayError(WebviewConnectActivity.this, error);
|
||||
}
|
||||
token = new RetrofitPeertubeAPI(WebviewConnectActivity.this, instance, null).manageToken(oauthParams);
|
||||
if (token != null) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
||||
|
|
|
@ -27,6 +27,7 @@ import app.fedilab.android.peertube.client.data.NotificationData;
|
|||
import app.fedilab.android.peertube.client.data.PlaylistData;
|
||||
import app.fedilab.android.peertube.client.data.VideoData;
|
||||
import app.fedilab.android.peertube.client.data.VideoPlaylistData.VideoPlaylist;
|
||||
import app.fedilab.android.peertube.client.entities.Error;
|
||||
import app.fedilab.android.peertube.client.entities.OverviewVideo;
|
||||
import app.fedilab.android.peertube.client.entities.PlaylistExist;
|
||||
import app.fedilab.android.peertube.client.entities.Rating;
|
||||
|
|
|
@ -19,7 +19,7 @@ import android.os.Handler;
|
|||
import android.os.Looper;
|
||||
import android.widget.Toast;
|
||||
|
||||
import app.fedilab.android.peertube.R;
|
||||
import app.fedilab.android.R;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||
|
|
5
app/src/main/res/anim/slide_in_up.xml
Normal file
5
app/src/main/res/anim/slide_in_up.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_mediumAnimTime"
|
||||
android:fromYDelta="100%p"
|
||||
android:toYDelta="0%p" />
|
5
app/src/main/res/anim/slide_in_up_down.xml
Normal file
5
app/src/main/res/anim/slide_in_up_down.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_longAnimTime"
|
||||
android:fromYDelta="0%p"
|
||||
android:toYDelta="100%p" />
|
4
app/src/main/res/anim/slide_out_up.xml
Normal file
4
app/src/main/res/anim/slide_out_up.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_mediumAnimTime"
|
||||
android:fromYDelta="0%p" />
|
|
@ -66,10 +66,4 @@
|
|||
android:icon="@drawable/ic_baseline_info_24"
|
||||
android:title="@string/about_the_app"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_donate"
|
||||
android:icon="@drawable/ic_baseline_attach_money_24"
|
||||
android:title="@string/make_a_donation"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
||||
|
|
Loading…
Reference in a new issue