diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee1f422..dc0dd57 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -69,6 +69,11 @@ android:configChanges="orientation|screenSize" android:label="@string/app_name" android:windowSoftInputMode="stateAlwaysHidden" /> + diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java index 09662a6..412a1e4 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java @@ -51,6 +51,7 @@ public class MainActivity extends AppCompatActivity { @Override public boolean onCreateOptionsMenu(@NotNull Menu menu) { getMenuInflater().inflate(R.menu.main_menu, menu); + MenuItem myActionMenuItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) myActionMenuItem.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @@ -73,6 +74,14 @@ public class MainActivity extends AppCompatActivity { return false; } }); + + MenuItem uploadItem = menu.findItem(R.id.action_upload); + if( Helper.isLoggedIn(MainActivity.this)) { + uploadItem.setVisible(true); + }else{ + uploadItem.setVisible(false); + } + return true; } @@ -87,7 +96,11 @@ public class MainActivity extends AppCompatActivity { startActivity(intent); return true; } - + if (item.getItemId() == R.id.action_upload) { + Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class); + startActivity(intent); + return true; + } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 3a37a99..6369bb0 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -93,7 +93,6 @@ import es.dmoral.toasty.Toasty; import static app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask.action.GET_PLAYLIST; import static app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask.action.GET_PLAYLIST_FOR_VIDEO; -import static app.fedilab.fedilabtube.helper.Helper.changeDrawableColor; import static app.fedilab.fedilabtube.helper.Helper.getAttColor; import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; @@ -209,8 +208,6 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee peertube_information_container.setVisibility(View.VISIBLE); } }); - String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT); - webview_video.getSettings().setUserAgentString(user_agent); webview_video.getSettings().setAllowFileAccess(true); webview_video.setWebChromeClient(mastalabWebChromeClient); webview_video.getSettings().setDomStorageEnabled(true); @@ -515,12 +512,11 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee if (mode == Helper.VIDEO_MODE_DIRECT) { - String userAgent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT); int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); ProgressiveMediaSource videoSource; if (video_cache == 0) { DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this, - Util.getUserAgent(PeertubeActivity.this, userAgent), null); + Util.getUserAgent(PeertubeActivity.this, null), null); videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory) .createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService()))); } else { @@ -698,12 +694,11 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this); playerView.setPlayer(player); loader.setVisibility(View.GONE); - String userAgent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT); int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); ProgressiveMediaSource videoSource; if (video_cache == 0) { DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this, - Util.getUserAgent(PeertubeActivity.this, userAgent), null); + Util.getUserAgent(PeertubeActivity.this, null), null); videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory) .createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService()))); } else { diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java index 82cce0a..39abb8d 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java @@ -14,20 +14,16 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.provider.OpenableColumns; -import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; -import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -84,18 +80,7 @@ public class PeertubeUploadActivity extends AppCompatActivity implements OnRetri if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - assert inflater != null; - View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PeertubeUploadActivity.this), false); - actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); - ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close); - TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); - toolbar_close.setOnClickListener(v -> finish()); - toolbar_title.setText(R.string.upload_video); - } + setContentView(R.layout.activity_peertube_upload); set_upload_file = findViewById(R.id.set_upload_file); @@ -113,7 +98,6 @@ public class PeertubeUploadActivity extends AppCompatActivity implements OnRetri } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); @@ -162,6 +146,16 @@ public class PeertubeUploadActivity extends AppCompatActivity implements OnRetri } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override public void onRetrievePeertubeComments(APIResponse apiResponse) { @@ -261,18 +255,10 @@ public class PeertubeUploadActivity extends AppCompatActivity implements OnRetri } Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - intent.setType("*/*"); - String[] mimetypes = {"video/*"}; - intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); - startActivityForResult(intent, PICK_IVDEO); - } else { - intent.setType("video/*"); - Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); - Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_image)); - chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent}); - startActivityForResult(chooserIntent, PICK_IVDEO); - } + intent.setType("*/*"); + String[] mimetypes = {"video/*"}; + intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); + startActivityForResult(intent, PICK_IVDEO); }); diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java index acf944c..7a389b5 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java @@ -37,6 +37,9 @@ public class RetrievePeertubeChannelsAsyncTask extends AsyncTask> map = httpsURLConnection.getHeaderFields(); - for (Map.Entry> entry : map.entrySet()) { - if (entry.toString().toLowerCase().startsWith("location")) { - Matcher matcher = Helper.urlPattern.matcher(entry.toString()); - if (matcher.find()) { - redirect = matcher.group(1); - } - } - } - } - httpsURLConnection.getInputStream().close(); - if (redirect != null && redirect.compareTo(urlConnection) != 0) { - URL redirectURL = new URL(redirect); - String host = redirectURL.getHost(); - String protocol = redirectURL.getProtocol(); - if (protocol == null || host == null) { - redirect = null; - } - } - return redirect; - } catch (IOException | NoSuchAlgorithmException | KeyManagementException e) { - e.printStackTrace(); - } - return null; - } - public String get(String urlConnection) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException { @@ -246,7 +195,6 @@ public class HttpsConnection { httpsURLConnection.setRequestProperty("http.keepAlive", "false"); httpsURLConnection.setRequestProperty("Content-Type", "application/json"); httpsURLConnection.setRequestProperty("Accept", "application/json"); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setRequestMethod("GET"); httpsURLConnection.setDefaultUseCaches(true); @@ -307,7 +255,6 @@ public class HttpsConnection { httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); else httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setDoOutput(true); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); @@ -353,117 +300,6 @@ public class HttpsConnection { } - String postJson(String urlConnection, int timeout, JsonObject jsonObject, String token) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException { - - URL url = new URL(urlConnection); - byte[] postDataBytes; - postDataBytes = jsonObject.toString().getBytes(StandardCharsets.UTF_8); - - if (proxy != null) - httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); - else - httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); - httpsURLConnection.setConnectTimeout(timeout * 1000); - httpsURLConnection.setDoOutput(true); - httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); - httpsURLConnection.setRequestProperty("Content-Type", "application/json"); - httpsURLConnection.setRequestProperty("Accept", "application/json"); - httpsURLConnection.setRequestMethod("POST"); - if (token != null && !token.startsWith("Basic ")) - httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token); - else if (token != null && token.startsWith("Basic ")) - httpsURLConnection.setRequestProperty("Authorization", token); - httpsURLConnection.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length)); - - - httpsURLConnection.getOutputStream().write(postDataBytes); - String response; - if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) { - getSinceMaxId(); - response = converToString(httpsURLConnection.getInputStream()); - } else { - String error = null; - if (httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); - if (stream == null) { - stream = httpsURLConnection.getInputStream(); - } - try (Scanner scanner = new Scanner(stream)) { - scanner.useDelimiter("\\Z"); - if (scanner.hasNext()) { - error = scanner.next(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - int responseCode = httpsURLConnection.getResponseCode(); - try { - httpsURLConnection.getInputStream().close(); - } catch (Exception ignored) { - } - throw new HttpsConnectionException(responseCode, error); - } - getSinceMaxId(); - httpsURLConnection.getInputStream().close(); - return response; - } - - @SuppressWarnings("SameParameterValue") - String postMisskey(String urlConnection, int timeout, JSONObject paramaters, String token) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException { - URL url = new URL(urlConnection); - byte[] postDataBytes = paramaters.toString().getBytes(StandardCharsets.UTF_8); - - if (proxy != null) - httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); - else - httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); - httpsURLConnection.setConnectTimeout(timeout * 1000); - httpsURLConnection.setDoOutput(true); - httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); - httpsURLConnection.setRequestMethod("POST"); - if (token != null && !token.startsWith("Basic ")) - httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token); - else if (token != null && token.startsWith("Basic ")) - httpsURLConnection.setRequestProperty("Authorization", token); - httpsURLConnection.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length)); - - - httpsURLConnection.getOutputStream().write(postDataBytes); - String response; - if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) { - getSinceMaxId(); - response = converToString(httpsURLConnection.getInputStream()); - } else { - String error = null; - if (httpsURLConnection.getErrorStream() != null) { - InputStream stream = httpsURLConnection.getErrorStream(); - if (stream == null) { - stream = httpsURLConnection.getInputStream(); - } - try (Scanner scanner = new Scanner(stream)) { - scanner.useDelimiter("\\Z"); - if (scanner.hasNext()) { - error = scanner.next(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - int responseCode = httpsURLConnection.getResponseCode(); - try { - httpsURLConnection.getInputStream().close(); - } catch (Exception ignored) { - } - throw new HttpsConnectionException(responseCode, error); - } - getSinceMaxId(); - httpsURLConnection.getInputStream().close(); - return response; - } - /*** * Download method which works for http and https connections @@ -480,7 +316,6 @@ public class HttpsConnection { httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); else httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); int responseCode = httpsURLConnection.getResponseCode(); // always check HTTP response code first @@ -546,7 +381,6 @@ public class HttpsConnection { else httpsURLConnection = (HttpsURLConnection) url.openConnection(); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); int responseCode = httpsURLConnection.getResponseCode(); // always check HTTP response code first if (responseCode == HttpURLConnection.HTTP_OK) { @@ -649,15 +483,9 @@ public class HttpsConnection { httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); else httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - httpsURLConnection.setRequestMethod("PATCH"); - } else { - httpsURLConnection.setRequestProperty("X-HTTP-Method-Override", "PATCH"); - httpsURLConnection.setRequestMethod("POST"); - } + httpsURLConnection.setRequestMethod("PATCH"); if (token != null && !token.startsWith("Basic ")) httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token); else if (token != null && token.startsWith("Basic ")) @@ -734,7 +562,6 @@ public class HttpsConnection { httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); else httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); if (token != null && !token.startsWith("Basic ")) @@ -806,7 +633,6 @@ public class HttpsConnection { httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy); else httpsURLConnection = (HttpsURLConnection) url.openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); if (token != null && !token.startsWith("Basic ")) httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token); diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java index f80eac6..6e60683 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java @@ -33,9 +33,6 @@ import app.fedilab.fedilabtube.client.entities.Account; import app.fedilab.fedilabtube.client.entities.AccountCreation; import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.client.entities.Instance; -import app.fedilab.fedilabtube.client.entities.InstanceNodeInfo; -import app.fedilab.fedilabtube.client.entities.InstanceReg; -import app.fedilab.fedilabtube.client.entities.NodeInfo; import app.fedilab.fedilabtube.client.entities.Peertube; import app.fedilab.fedilabtube.client.entities.PeertubeAccountNotification; import app.fedilab.fedilabtube.client.entities.PeertubeActorFollow; @@ -462,7 +459,7 @@ public class PeertubeAPI { * @param resobj JSONObject * @return Peertube */ - private static List parseSinglePeertubeComments(Context context, String instance, JSONObject resobj) { + private static List parseSinglePeertubeComments(String instance, JSONObject resobj) { List statuses = new ArrayList<>(); try { JSONArray jsonArray = resobj.getJSONArray("data"); @@ -761,100 +758,6 @@ public class PeertubeAPI { return account; } - public InstanceNodeInfo displayNodeInfo(String domain) { - - String response; - InstanceNodeInfo instanceNodeInfo = new InstanceNodeInfo(); - if (domain.startsWith("http://")) { - domain = domain.replace("http://", ""); - } - if (domain.startsWith("https://")) { - domain = domain.replace("https://", ""); - } - try { - response = new HttpsConnection(context).get("https://" + domain + "/.well-known/nodeinfo", 30, null, null); - JSONArray jsonArray = new JSONObject(response).getJSONArray("links"); - ArrayList nodeInfos = new ArrayList<>(); - try { - int i = 0; - while (i < jsonArray.length()) { - - JSONObject resobj = jsonArray.getJSONObject(i); - NodeInfo nodeInfo = new NodeInfo(); - nodeInfo.setHref(resobj.getString("href")); - nodeInfo.setRel(resobj.getString("rel")); - i++; - nodeInfos.add(nodeInfo); - } - if (nodeInfos.size() > 0) { - NodeInfo nodeInfo = nodeInfos.get(nodeInfos.size() - 1); - response = new HttpsConnection(context).get(nodeInfo.getHref(), 30, null, null); - JSONObject resobj = new JSONObject(response); - JSONObject jsonObject = resobj.getJSONObject("software"); - String name = jsonObject.getString("name").toUpperCase(); - if (name.compareTo("CORGIDON") == 0) { - name = "MASTODON"; - } - instanceNodeInfo.setName(name); - instanceNodeInfo.setVersion(jsonObject.getString("version")); - instanceNodeInfo.setOpenRegistrations(resobj.getBoolean("openRegistrations")); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } catch (IOException | JSONException | NoSuchAlgorithmException | KeyManagementException e) { - e.printStackTrace(); - try { - response = new HttpsConnection(context).get("https://" + domain + "/api/v1/instance", 30, null, null); - JSONObject jsonObject = new JSONObject(response); - instanceNodeInfo.setName("MASTODON"); - instanceNodeInfo.setVersion(jsonObject.getString("version")); - instanceNodeInfo.setOpenRegistrations(true); - } catch (IOException e1) { - instanceNodeInfo.setConnectionError(true); - e1.printStackTrace(); - } catch (NoSuchAlgorithmException | JSONException | KeyManagementException e1) { - e1.printStackTrace(); - } catch (HttpsConnection.HttpsConnectionException e1) { - if (e1.getStatusCode() == 404 || e1.getStatusCode() == 501) { - instanceNodeInfo.setName("GNU"); - instanceNodeInfo.setVersion("unknown"); - instanceNodeInfo.setOpenRegistrations(true); - e1.printStackTrace(); - } else { - instanceNodeInfo.setName("MASTODON"); - instanceNodeInfo.setVersion("3.0"); - instanceNodeInfo.setOpenRegistrations(false); - } - } - } catch (HttpsConnection.HttpsConnectionException e) { - try { - response = new HttpsConnection(context).get("https://" + domain + "/api/v1/instance", 30, null, null); - JSONObject jsonObject = new JSONObject(response); - instanceNodeInfo.setName("MASTODON"); - instanceNodeInfo.setVersion(jsonObject.getString("version")); - instanceNodeInfo.setOpenRegistrations(true); - } catch (IOException e1) { - instanceNodeInfo.setConnectionError(true); - e1.printStackTrace(); - } catch (NoSuchAlgorithmException | JSONException | KeyManagementException e1) { - e1.printStackTrace(); - } catch (HttpsConnection.HttpsConnectionException e1) { - if (e1.getStatusCode() == 404 || e1.getStatusCode() == 501) { - instanceNodeInfo.setName("GNU"); - instanceNodeInfo.setVersion("unknown"); - instanceNodeInfo.setOpenRegistrations(true); - e1.printStackTrace(); - } else { - instanceNodeInfo.setName("MASTODON"); - instanceNodeInfo.setVersion("3.0"); - instanceNodeInfo.setOpenRegistrations(false); - } - } - e.printStackTrace(); - } - return instanceNodeInfo; - } public APIResponse createAccount(AccountCreation accountCreation) { apiResponse = new APIResponse(); @@ -1721,7 +1624,7 @@ public class PeertubeAPI { HttpsConnection httpsConnection = new HttpsConnection(context); String response = httpsConnection.get(String.format("https://" + instance + "/api/v1/videos/%s/comment-threads", videoId), 10, null, null); JSONObject jsonObject = new JSONObject(response); - statuses = parseSinglePeertubeComments(context, instance, jsonObject); + statuses = parseSinglePeertubeComments(instance, jsonObject); } catch (HttpsConnection.HttpsConnectionException e) { setError(e.getStatusCode(), e); } catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) { @@ -1788,54 +1691,6 @@ public class PeertubeAPI { return peertubeNotifications; } - /** - * Parse json response for several instance reg - * - * @param jsonArray JSONArray - * @return List - */ - private List parseInstanceReg(JSONArray jsonArray) { - - List instanceRegs = new ArrayList<>(); - try { - int i = 0; - while (i < jsonArray.length()) { - JSONObject resobj = jsonArray.getJSONObject(i); - InstanceReg instanceReg = parseInstanceReg(resobj); - i++; - instanceRegs.add(instanceReg); - } - } catch (JSONException e) { - e.printStackTrace(); - } - return instanceRegs; - } - - /** - * Parse json response an unique instance for registering - * - * @param resobj JSONObject - * @return InstanceReg - */ - private InstanceReg parseInstanceReg(JSONObject resobj) { - InstanceReg instanceReg = new InstanceReg(); - try { - instanceReg.setDomain(resobj.getString("host")); - instanceReg.setVersion(resobj.getString("version")); - instanceReg.setDescription(resobj.getString("shortDescription")); - instanceReg.setLanguage(resobj.getString("country")); - instanceReg.setCategory(""); - instanceReg.setProxied_thumbnail(""); - instanceReg.setTotal_users(resobj.getInt("totalUsers")); - instanceReg.setTotalInstanceFollowers(resobj.getInt("totalInstanceFollowers")); - instanceReg.setTotalInstanceFollowing(resobj.getInt("totalInstanceFollowing")); - instanceReg.setLast_week_users(0); - instanceReg.setCountry(resobj.getString("country")); - } catch (JSONException e) { - e.printStackTrace(); - } - return instanceReg; - } /** * Parse json response for several howto diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/CacheDataSourceFactory.java b/app/src/main/java/app/fedilab/fedilabtube/helper/CacheDataSourceFactory.java index 974c47e..bdea944 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/CacheDataSourceFactory.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/CacheDataSourceFactory.java @@ -28,12 +28,11 @@ public class CacheDataSourceFactory implements DataSource.Factory { this.context = context; this.maxFileSize = 5 * 1024 * 1024; SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - String userAgent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT); DefaultBandwidthMeter.Builder bandwidthMeterBuilder = new DefaultBandwidthMeter.Builder(context); DefaultBandwidthMeter bandwidthMeter = bandwidthMeterBuilder.build(); defaultDatasourceFactory = new DefaultDataSourceFactory(this.context, bandwidthMeter, - new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter)); + new DefaultHttpDataSourceFactory(null, bandwidthMeter)); } public static SimpleCache getInstance(Context context) { diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java index 3b69533..5a4f538 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java @@ -13,7 +13,6 @@ import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; @@ -78,7 +77,6 @@ public class Helper { public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)"); public static final String SET_CUSTOM_USER_AGENT = "set_custom_user_agent"; public static final String SET_VIDEO_CACHE = "set_video_cache"; - public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0"; //Proxy public static final String SET_PROXY_ENABLED = "set_proxy_enabled"; public static final String SET_PROXY_TYPE = "set_proxy_type"; @@ -493,8 +491,6 @@ public class Helper { webView.getSettings().setLoadsImagesAutomatically(true); webView.getSettings().setSupportMultipleWindows(false); webView.getSettings().setMediaPlaybackRequiresUserGesture(true); - String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT); - webView.getSettings().setUserAgentString(user_agent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptThirdPartyCookies(webView, false); diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index cd9d178..4087787 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -78,7 +78,7 @@ android:id="@+id/login_uid" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="@string/username" + android:hint="@string/email_address" android:inputType="textEmailAddress" android:singleLine="true" /> diff --git a/app/src/main/res/layout/activity_peertube_upload.xml b/app/src/main/res/layout/activity_peertube_upload.xml index 17ae71e..24c505d 100644 --- a/app/src/main/res/layout/activity_peertube_upload.xml +++ b/app/src/main/res/layout/activity_peertube_upload.xml @@ -1,5 +1,4 @@ -