Some changes

This commit is contained in:
Thomas 2020-06-17 18:20:35 +02:00
parent bfe8b22b7c
commit 6732e1dc72
16 changed files with 368 additions and 497 deletions

View File

@ -15,6 +15,7 @@
package app.fedilab.android.activities; package app.fedilab.android.activities;
import android.annotation.SuppressLint;
import android.app.DatePickerDialog; import android.app.DatePickerDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -260,27 +261,26 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
List<Entry> boostsEntry = new ArrayList<>(); List<Entry> boostsEntry = new ArrayList<>();
Iterator<Map.Entry<Long, Integer>> it = charts.getReblogs().entrySet().iterator();
Iterator it = charts.getReblogs().entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Long, Integer> pair = it.next();
boostsEntry.add(new Entry((long) pair.getKey(), (int) pair.getValue())); boostsEntry.add(new Entry(pair.getKey(), pair.getValue()));
it.remove(); it.remove();
} }
List<Entry> favEntry = new ArrayList<>(); List<Entry> favEntry = new ArrayList<>();
it = charts.getFavourites().entrySet().iterator(); it = charts.getFavourites().entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Long, Integer> pair = it.next();
favEntry.add(new Entry((long) pair.getKey(), (int) pair.getValue())); favEntry.add(new Entry(pair.getKey(), pair.getValue()));
it.remove(); it.remove();
} }
List<Entry> mentionEntry = new ArrayList<>(); List<Entry> mentionEntry = new ArrayList<>();
it = charts.getMentions().entrySet().iterator(); it = charts.getMentions().entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Long, Integer> pair = it.next();
mentionEntry.add(new Entry((long) pair.getKey(), (int) pair.getValue())); mentionEntry.add(new Entry(pair.getKey(), pair.getValue()));
it.remove(); it.remove();
} }
@ -288,8 +288,8 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
List<Entry> followEntry = new ArrayList<>(); List<Entry> followEntry = new ArrayList<>();
it = charts.getFollows().entrySet().iterator(); it = charts.getFollows().entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Long, Integer> pair = it.next();
followEntry.add(new Entry((long) pair.getKey(), (int) pair.getValue())); followEntry.add(new Entry(pair.getKey(), pair.getValue()));
it.remove(); it.remove();
} }
@ -482,6 +482,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
super.onDestroy(); super.onDestroy();
} }
@SuppressLint("ViewConstructor")
public static class CustomMarkerView extends MarkerView { public static class CustomMarkerView extends MarkerView {
private TextView tvContent; private TextView tvContent;
private MPPointF mOffset; private MPPointF mOffset;
@ -503,7 +504,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
@Override @Override
public MPPointF getOffset() { public MPPointF getOffset() {
if (mOffset == null) { if (mOffset == null) {
mOffset = new MPPointF(-(getWidth() / 2), -getHeight()); mOffset = new MPPointF(-((float)getWidth() / 2), -getHeight());
} }
return mOffset; return mOffset;
} }

View File

@ -67,6 +67,7 @@ import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.asynctasks.RetrieveStatsAsyncTask; import app.fedilab.android.asynctasks.RetrieveStatsAsyncTask;
import app.fedilab.android.client.APIResponse; import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.Account; import app.fedilab.android.client.Entities.Account;
import app.fedilab.android.client.Entities.Instance;
import app.fedilab.android.client.Entities.Statistics; import app.fedilab.android.client.Entities.Statistics;
import app.fedilab.android.client.Entities.Status; import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.StatusDrawerParams; import app.fedilab.android.client.Entities.StatusDrawerParams;
@ -522,11 +523,11 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
frequency.setText(getString(R.string.toot_per_day, df.format(statistics.getFrequency()))); frequency.setText(getString(R.string.toot_per_day, df.format(statistics.getFrequency())));
if (statistics.getTagsTrend() != null && statistics.getTagsTrend().size() > 0) { if (statistics.getTagsTrend() != null && statistics.getTagsTrend().size() > 0) {
Iterator it = statistics.getTagsTrend().entrySet().iterator(); Iterator<Map.Entry<String, Integer>> it = statistics.getTagsTrend().entrySet().iterator();
StringBuilder text = new StringBuilder(); StringBuilder text = new StringBuilder();
int i = 1; int i = 1;
while (it.hasNext() && i <= 10) { while (it.hasNext() && i <= 10) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, Integer> pair = it.next();
System.out.println(pair.getKey() + " = " + pair.getValue()); System.out.println(pair.getKey() + " = " + pair.getValue());
text.append(i).append(" - ").append(pair.getKey()).append("").append(pair.getValue()).append("\r\n"); text.append(i).append(" - ").append(pair.getKey()).append("").append(pair.getValue()).append("\r\n");
i++; i++;

View File

@ -639,26 +639,18 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override @Override
public void onConfigurationChanged(@NotNull Configuration newConfig) { public void onConfigurationChanged(@NotNull Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if (mode != Helper.VIDEO_MODE_WEBVIEW) { if (mode != Helper.VIDEO_MODE_WEBVIEW) {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
openFullscreenDialog(); openFullscreenDialog();
setFullscreen(FullScreenMediaController.fullscreen.ON); }
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { setFullscreen(FullScreenMediaController.fullscreen.ON);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
closeFullscreenDialog(); closeFullscreenDialog();
setFullscreen(FullScreenMediaController.fullscreen.OFF);
} }
change(); setFullscreen(FullScreenMediaController.fullscreen.OFF);
} else {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setFullscreen(FullScreenMediaController.fullscreen.ON);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setFullscreen(FullScreenMediaController.fullscreen.OFF);
}
change();
} }
change();
} }

View File

@ -80,7 +80,6 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
private String videoId; private String videoId;
private Account channel; private Account channel;
@SuppressWarnings("SuspiciousMethodCalls")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -168,12 +167,12 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
translations = new LinkedHashMap<>(peertubeInformation.getTranslations()); translations = new LinkedHashMap<>(peertubeInformation.getTranslations());
//Populate catgories //Populate catgories
String[] categoriesA = new String[categories.size()]; String[] categoriesA = new String[categories.size()];
Iterator it = categories.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
categoriesA[i] = (String) pair.getValue(); categoriesA[i] = pair.getValue();
else else
categoriesA[i] = translations.get(pair.getValue()); categoriesA[i] = translations.get(pair.getValue());
it.remove(); it.remove();
@ -189,9 +188,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
it = licences.entrySet().iterator(); it = licences.entrySet().iterator();
i = 0; i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
licensesA[i] = (String) pair.getValue(); licensesA[i] = pair.getValue();
else else
licensesA[i] = translations.get(pair.getValue()); licensesA[i] = translations.get(pair.getValue());
it.remove(); it.remove();
@ -204,12 +203,12 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
//Populate languages //Populate languages
String[] languagesA = new String[languages.size()]; String[] languagesA = new String[languages.size()];
it = languages.entrySet().iterator(); Iterator<Map.Entry<String, String>> itl = languages.entrySet().iterator();
i = 0; i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = itl.next();
if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
languagesA[i] = (String) pair.getValue(); languagesA[i] = pair.getValue();
else else
languagesA[i] = translations.get(pair.getValue()); languagesA[i] = translations.get(pair.getValue());
it.remove(); it.remove();
@ -225,9 +224,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
it = privacies.entrySet().iterator(); it = privacies.entrySet().iterator();
i = 0; i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
privaciesA[i] = (String) pair.getValue(); privaciesA[i] = pair.getValue();
else else
privaciesA[i] = translations.get(pair.getValue()); privaciesA[i] = translations.get(pair.getValue());
it.remove(); it.remove();
@ -347,9 +346,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
int languagePosition = 0; int languagePosition = 0;
if (languages.containsValue(language)) { if (languages.containsValue(language)) {
Iterator it = languages.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = languages.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = it.next();
if (pair.getValue().equals(language)) if (pair.getValue().equals(language))
break; break;
it.remove(); it.remove();
@ -358,9 +357,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
} }
int privacyPosition = 0; int privacyPosition = 0;
if (privacy != null && privacies.containsValue(privacy)) { if (privacy != null && privacies.containsValue(privacy)) {
Iterator it = privacies.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = privacies.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (pair.getValue().equals(privacy)) if (pair.getValue().equals(privacy))
break; break;
it.remove(); it.remove();
@ -369,9 +368,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
} }
int licensePosition = 0; int licensePosition = 0;
if (license != null && licences.containsValue(license)) { if (license != null && licences.containsValue(license)) {
Iterator it = licences.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = licences.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (pair.getValue().equals(license)) if (pair.getValue().equals(license))
break; break;
it.remove(); it.remove();
@ -380,9 +379,9 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
} }
int categoryPosition = 0; int categoryPosition = 0;
if (category != null && categories.containsValue(category)) { if (category != null && categories.containsValue(category)) {
Iterator it = categories.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (pair.getValue().equals(category)) if (pair.getValue().equals(category))
break; break;
it.remove(); it.remove();
@ -395,13 +394,13 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<Integer, String> privaciesCheck = new LinkedHashMap<>(peertubeInformation.getPrivacies()); LinkedHashMap<Integer, String> privaciesCheck = new LinkedHashMap<>(peertubeInformation.getPrivacies());
Iterator it = privaciesCheck.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = privaciesCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (i == position) { if (i == position) {
privacyToSend = new HashMap<>(); privacyToSend = new HashMap<>();
privacyToSend.put((Integer) pair.getKey(), (String) pair.getValue()); privacyToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
it.remove(); it.remove();
@ -418,13 +417,13 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<Integer, String> licensesCheck = new LinkedHashMap<>(peertubeInformation.getLicences()); LinkedHashMap<Integer, String> licensesCheck = new LinkedHashMap<>(peertubeInformation.getLicences());
Iterator it = licensesCheck.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = licensesCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (i == position) { if (i == position) {
licenseToSend = new HashMap<>(); licenseToSend = new HashMap<>();
licenseToSend.put((Integer) pair.getKey(), (String) pair.getValue()); licenseToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
it.remove(); it.remove();
@ -442,13 +441,13 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<Integer, String> categoriesCheck = new LinkedHashMap<>(peertubeInformation.getCategories()); LinkedHashMap<Integer, String> categoriesCheck = new LinkedHashMap<>(peertubeInformation.getCategories());
Iterator it = categoriesCheck.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = categoriesCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (i == position) { if (i == position) {
categoryToSend = new HashMap<>(); categoryToSend = new HashMap<>();
categoryToSend.put((Integer) pair.getKey(), (String) pair.getValue()); categoryToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
it.remove(); it.remove();
@ -467,13 +466,13 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<String, String> languagesCheck = new LinkedHashMap<>(peertubeInformation.getLanguages()); LinkedHashMap<String, String> languagesCheck = new LinkedHashMap<>(peertubeInformation.getLanguages());
Iterator it = languagesCheck.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = languagesCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = it.next();
if (i == position) { if (i == position) {
languageToSend = new HashMap<>(); languageToSend = new HashMap<>();
languageToSend.put((String) pair.getKey(), (String) pair.getValue()); languageToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
it.remove(); it.remove();
@ -491,13 +490,13 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<String, String> channelsCheck = new LinkedHashMap<>(channels); LinkedHashMap<String, String> channelsCheck = new LinkedHashMap<>(channels);
Iterator it = channelsCheck.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = channelsCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = it.next();
if (i == position) { if (i == position) {
channelToSend = new HashMap<>(); channelToSend = new HashMap<>();
channelToSend.put((String) pair.getKey(), (String) pair.getValue()); channelToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
@ -540,8 +539,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
List<String> tags = peertube.getTags(); List<String> tags = peertube.getTags();
if (tags != null && tags.size() > 0) { if (tags != null && tags.size() > 0) {
//noinspection ToArrayCallWithZeroLengthArrayArgument String[] tagsA = tags.toArray(new String[0]);
String[] tagsA = tags.toArray(new String[tags.size()]);
p_video_tags.setTags(tagsA); p_video_tags.setTags(tagsA);
} }
@ -578,12 +576,12 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
int channelPosition = 0; int channelPosition = 0;
if (channels.containsKey(channel.getUsername())) { if (channels.containsKey(channel.getUsername())) {
LinkedHashMap<String, String> channelsIterator = new LinkedHashMap<>(channels); LinkedHashMap<String, String> channelsIterator = new LinkedHashMap<>(channels);
Iterator it = channelsIterator.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = channelsIterator.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = it.next();
if (pair.getKey().equals(channel.getUsername())) { if (pair.getKey().equals(channel.getUsername())) {
channelToSend = new HashMap<>(); channelToSend = new HashMap<>();
channelToSend.put((String) pair.getKey(), (String) pair.getValue()); channelToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
it.remove(); it.remove();

View File

@ -194,7 +194,6 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
} }
@SuppressWarnings("SuspiciousMethodCalls")
@Override @Override
public void onRetrievePeertubeChannels(APIResponse apiResponse) { public void onRetrievePeertubeChannels(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) { if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
@ -237,12 +236,12 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies()); LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies());
//Populate privacies //Populate privacies
String[] privaciesA = new String[privacies.size()]; String[] privaciesA = new String[privacies.size()];
Iterator it = privacies.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = privacies.entrySet().iterator();
i = 0; i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
privaciesA[i] = (String) pair.getValue(); privaciesA[i] = pair.getValue();
else else
privaciesA[i] = translations.get(pair.getValue()); privaciesA[i] = translations.get(pair.getValue());
it.remove(); it.remove();
@ -258,13 +257,13 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<Integer, String> privaciesCheck = new LinkedHashMap<>(peertubeInformation.getPrivacies()); LinkedHashMap<Integer, String> privaciesCheck = new LinkedHashMap<>(peertubeInformation.getPrivacies());
Iterator it = privaciesCheck.entrySet().iterator(); Iterator<Map.Entry<Integer, String>> it = privaciesCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<Integer, String> pair = it.next();
if (i == position) { if (i == position) {
privacyToSend = new HashMap<>(); privacyToSend = new HashMap<>();
privacyToSend.put((Integer) pair.getKey(), (String) pair.getValue()); privacyToSend.put(pair.getKey(), pair.getValue());
break; break;
} }
it.remove(); it.remove();
@ -309,13 +308,13 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
LinkedHashMap<String, String> channelsCheck = new LinkedHashMap<>(channels); LinkedHashMap<String, String> channelsCheck = new LinkedHashMap<>(channels);
Iterator it = channelsCheck.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = channelsCheck.entrySet().iterator();
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = it.next();
if (i == position) { if (i == position) {
channelToSend = new HashMap<>(); channelToSend = new HashMap<>();
channelToSend.put((String) pair.getKey(), (String) pair.getValue()); channelToSend.put(pair.getKey(), pair.getValue());
break; break;
} }

View File

@ -357,11 +357,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (s.toString().length() == 0) if (s.toString().length() == 0)
currentCursorPosition[0] = 0; currentCursorPosition[0] = 0;
//Only check last 15 characters before cursor position to avoid lags //Only check last 15 characters before cursor position to avoid lags
if (currentCursorPosition[0] < searchDeep) { //Less than 15 characters are written before the cursor position //Less than 15 characters are written before the cursor position
searchLength[0] = currentCursorPosition[0]; searchLength[0] = Math.min(currentCursorPosition[0], searchDeep);
} else {
searchLength[0] = searchDeep;
}
int totalChar = countLength(social, toot_content); int totalChar = countLength(social, toot_content);

View File

@ -81,9 +81,6 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
case Helper.THEME_LIGHT: case Helper.THEME_LIGHT:
setTheme(R.style.AppTheme_NoActionBar_Fedilab); setTheme(R.style.AppTheme_NoActionBar_Fedilab);
break; break;
case Helper.THEME_DARK:
setTheme(R.style.AppThemeDark_NoActionBar);
break;
case Helper.THEME_BLACK: case Helper.THEME_BLACK:
setTheme(R.style.AppThemeBlack_NoActionBar); setTheme(R.style.AppThemeBlack_NoActionBar);
break; break;
@ -102,12 +99,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close); ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
toolbar_close.setOnClickListener(new View.OnClickListener() { toolbar_close.setOnClickListener(v -> finish());
@Override
public void onClick(View v) {
finish();
}
});
toolbar_title.setText(R.string.upload_video); toolbar_title.setText(R.string.upload_video);
} }
@ -140,7 +132,6 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
mainLoader.setVisibility(View.VISIBLE); mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
boolean isOnWifi = Helper.isOnWIFI(PlaylistsActivity.this);
peertubeAdapter = new PeertubeAdapter(Helper.getLiveInstance(PlaylistsActivity.this), false, this.peertubes); peertubeAdapter = new PeertubeAdapter(Helper.getLiveInstance(PlaylistsActivity.this), false, this.peertubes);
@ -181,16 +172,13 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
}); });
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { swipeRefreshLayout.setOnRefreshListener(() -> {
@Override max_id = null;
public void onRefresh() { firstLoad = true;
max_id = null; flag_loading = true;
firstLoad = true; swiped = true;
flag_loading = true; MainActivity.countNewStatus = 0;
swiped = true; new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
MainActivity.countNewStatus = 0;
new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}); });
new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -199,19 +187,16 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { if (item.getItemId() == android.R.id.home) {
case android.R.id.home: finish();
finish(); return true;
return true;
default:
return super.onOptionsItemSelected(item);
} }
return super.onOptionsItemSelected(item);
} }
@Override @Override
public void onActionDone(ManagePlaylistsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) { public void onActionDone(ManagePlaylistsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
mainLoader.setVisibility(View.GONE); mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE); nextElementLoader.setVisibility(View.GONE);
//Discards 404 - error which can often happen due to toots which have been deleted //Discards 404 - error which can often happen due to toots which have been deleted
@ -236,9 +221,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
if (swiped) { if (swiped) {
if (previousPosition > 0) { if (previousPosition > 0) {
for (int i = 0; i < previousPosition; i++) { this.peertubes.subList(0, previousPosition).clear();
this.peertubes.remove(0);
}
peertubeAdapter.notifyItemRangeRemoved(0, previousPosition); peertubeAdapter.notifyItemRangeRemoved(0, previousPosition);
} }
swiped = false; swiped = false;

View File

@ -60,13 +60,10 @@ public class ProxyActivity extends BaseActivity {
boolean enable_proxy = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false); boolean enable_proxy = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
final CheckBox set_enable_proxy = findViewById(R.id.enable_proxy); final CheckBox set_enable_proxy = findViewById(R.id.enable_proxy);
set_enable_proxy.setChecked(enable_proxy); set_enable_proxy.setChecked(enable_proxy);
set_enable_proxy.setOnClickListener(new View.OnClickListener() { set_enable_proxy.setOnClickListener(v -> {
@Override SharedPreferences.Editor editor = sharedpreferences.edit();
public void onClick(View v) { editor.putBoolean(Helper.SET_PROXY_ENABLED, set_enable_proxy.isChecked());
SharedPreferences.Editor editor = sharedpreferences.edit(); editor.apply();
editor.putBoolean(Helper.SET_PROXY_ENABLED, set_enable_proxy.isChecked());
editor.apply();
}
}); });
Button save = findViewById(R.id.set_proxy_save); Button save = findViewById(R.id.set_proxy_save);
@ -112,34 +109,29 @@ public class ProxyActivity extends BaseActivity {
} }
}); });
save.setOnClickListener(new View.OnClickListener() { save.setOnClickListener(view -> {
@Override String hostVal1 = host.getText().toString().trim();
public void onClick(View view) { String portVal1 = port.getText().toString().trim();
String hostVal = host.getText().toString().trim(); String proxy_loginVal = proxy_login.getText().toString().trim();
String portVal = port.getText().toString().trim(); String proxy_passwordVal = proxy_password.getText().toString().trim();
String proxy_loginVal = proxy_login.getText().toString().trim(); SharedPreferences.Editor editor = sharedpreferences.edit();
String proxy_passwordVal = proxy_password.getText().toString().trim(); editor.putString(Helper.SET_PROXY_HOST, hostVal1);
SharedPreferences.Editor editor = sharedpreferences.edit(); if (portVal1.matches("\\d+"))
editor.putString(Helper.SET_PROXY_HOST, hostVal); editor.putInt(Helper.SET_PROXY_PORT, Integer.parseInt(portVal1));
if (portVal.matches("\\d+")) editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal);
editor.putInt(Helper.SET_PROXY_PORT, Integer.parseInt(portVal)); editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal);
editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal); editor.apply();
editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal); finish();
editor.apply();
finish();
}
}); });
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { if (item.getItemId() == android.R.id.home) {
case android.R.id.home: finish();
finish(); return true;
return true;
default:
return super.onOptionsItemSelected(item);
} }
return super.onOptionsItemSelected(item);
} }

View File

@ -15,7 +15,6 @@
package app.fedilab.android.activities; package app.fedilab.android.activities;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
@ -33,7 +32,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.ImageView; import android.widget.ImageView;
@ -138,212 +136,174 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close); ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
ImageView add_remote_instance = actionBar.getCustomView().findViewById(R.id.add_remote_instance); ImageView add_remote_instance = actionBar.getCustomView().findViewById(R.id.add_remote_instance);
toolbar_close.setOnClickListener(new View.OnClickListener() { toolbar_close.setOnClickListener(v -> finish());
@Override
public void onClick(View v) {
finish();
}
});
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
add_remote_instance.setVisibility(View.VISIBLE); add_remote_instance.setVisibility(View.VISIBLE);
} else { } else {
add_remote_instance.setVisibility(View.GONE); add_remote_instance.setVisibility(View.GONE);
} }
add_remote_instance.setOnClickListener(new View.OnClickListener() { add_remote_instance.setOnClickListener(v -> {
@Override AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ReorderTimelinesActivity.this, style);
public void onClick(View v) { LayoutInflater inflater1 = getLayoutInflater();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ReorderTimelinesActivity.this, style); @SuppressLint("InflateParams") View dialogView = inflater1.inflate(R.layout.search_instance, null);
LayoutInflater inflater = getLayoutInflater(); dialogBuilder.setView(dialogView);
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.search_instance, null);
dialogBuilder.setView(dialogView);
AutoCompleteTextView instance_list = dialogView.findViewById(R.id.search_instance); AutoCompleteTextView instance_list = dialogView.findViewById(R.id.search_instance);
//Manage download of attachments //Manage download of attachments
RadioGroup radioGroup = dialogView.findViewById(R.id.set_attachment_group); RadioGroup radioGroup = dialogView.findViewById(R.id.set_attachment_group);
radioGroup.setOnCheckedChangeListener((group, checkedId) -> { radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
if (checkedId == R.id.twitter_accounts) { if (checkedId == R.id.twitter_accounts) {
instance_list.setHint(R.string.list_of_twitter_accounts); instance_list.setHint(R.string.list_of_twitter_accounts);
} else { } else {
instance_list.setHint(R.string.instance); instance_list.setHint(R.string.instance);
} }
}); });
instance_list.setFilters(new InputFilter[]{new InputFilter.LengthFilter(60)}); instance_list.setFilters(new InputFilter[]{new InputFilter.LengthFilter(60)});
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() { dialogBuilder.setPositiveButton(R.string.validate, (dialog, id) -> {
@Override SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
public void onClick(DialogInterface dialog, int id) { String instanceName = instance_list.getText().toString().trim().replace("@", "");
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); new Thread(() -> {
String instanceName = instance_list.getText().toString().trim().replace("@", ""); try {
new Thread(new Runnable() { if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance)
@Override new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/timelines/public?local=true", 10, null, null);
public void run() { else if (radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance)
try { new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/videos/", 10, null, null);
if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) else if (radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/timelines/public?local=true", 10, null, null); new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/timelines/public", 10, null, null);
else if (radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance) } else if (radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) {
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/videos/", 10, null, null); new HttpsConnection(ReorderTimelinesActivity.this, null).post("https://" + instanceName + "/api/notes/local-timeline", 10, null, null);
else if (radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) { } else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) {
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/timelines/public", 10, null, null); new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/statuses/public_timeline.json", 10, null, null);
} else if (radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) { }
new HttpsConnection(ReorderTimelinesActivity.this, null).post("https://" + instanceName + "/api/notes/local-timeline", 10, null, null); runOnUiThread(() -> {
} else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) { dialog.dismiss();
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/statuses/public_timeline.json", 10, null, null); if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) {
} new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MASTODON");
runOnUiThread(new Runnable() { } else if (radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance) {
public void run() { new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "PEERTUBE");
dialog.dismiss(); } else if (radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) { new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "PIXELFED");
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MASTODON"); } else if (radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) {
} else if (radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance) { new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MISSKEY");
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "PEERTUBE"); } else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) {
} else if (radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) { new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "GNU");
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "PIXELFED"); } else if (radioGroup.getCheckedRadioButtonId() == R.id.twitter_accounts) {
} else if (radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) { new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "NITTER");
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MISSKEY"); }
} else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) { if (timelines != null && adapter != null) {
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "GNU"); List<RemoteInstance> instance = new InstancesDAO(ReorderTimelinesActivity.this, db).getInstanceByName(instanceName);
} else if (radioGroup.getCheckedRadioButtonId() == R.id.twitter_accounts) { if (instance != null && instance.size() > 0) {
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "NITTER"); ManageTimelines manageTimelines = new ManageTimelines();
} manageTimelines.setRemoteInstance(instance.get(0));
if (timelines != null && adapter != null) { manageTimelines.setPosition(timelines.size());
List<RemoteInstance> instance = new InstancesDAO(ReorderTimelinesActivity.this, db).getInstanceByName(instanceName); manageTimelines.setDisplayed(true);
if (instance != null && instance.size() > 0) { manageTimelines.setType(ManageTimelines.Type.INSTANCE);
ManageTimelines manageTimelines = new ManageTimelines(); timelines.add(manageTimelines);
manageTimelines.setRemoteInstance(instance.get(0)); adapter.notifyItemInserted((timelines.size() - 1));
manageTimelines.setPosition(timelines.size());
manageTimelines.setDisplayed(true);
manageTimelines.setType(ManageTimelines.Type.INSTANCE);
timelines.add(manageTimelines);
adapter.notifyItemInserted((timelines.size() - 1));
}
updated = true;
}
}
});
} catch (final Exception e) {
e.printStackTrace();
runOnUiThread(new Runnable() {
public void run() {
Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show();
}
});
} }
updated = true;
} }
}).start(); });
} catch (final Exception e) {
e.printStackTrace();
runOnUiThread(() -> Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show());
} }
}); }).start();
AlertDialog alertDialog = dialogBuilder.create(); });
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { AlertDialog alertDialog = dialogBuilder.create();
@Override alertDialog.setOnDismissListener(dialogInterface -> {
public void onDismiss(DialogInterface dialogInterface) { //Hide keyboard
//Hide keyboard InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); assert imm != null;
assert imm != null; imm.hideSoftInputFromWindow(instance_list.getWindowToken(), 0);
imm.hideSoftInputFromWindow(instance_list.getWindowToken(), 0); });
} if (alertDialog.getWindow() != null)
}); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
if (alertDialog.getWindow() != null) alertDialog.show();
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
alertDialog.show();
instance_list.setOnItemClickListener(new AdapterView.OnItemClickListener() { instance_list.setOnItemClickListener((parent, view1, position, id) -> {
@Override });
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { instance_list.addTextChangedListener(new TextWatcher() {
String oldSearch = parent.getItemAtPosition(position).toString().trim(); @Override
} public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}); }
instance_list.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
} }
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (radioGroup.getCheckedRadioButtonId() != R.id.twitter_accounts) { if (radioGroup.getCheckedRadioButtonId() != R.id.twitter_accounts) {
Pattern host = Pattern.compile("([\\da-z\\.-]+\\.[a-z\\.]{2,12})"); Pattern host = Pattern.compile("([\\da-z.-]+\\.[a-z.]{2,12})");
Matcher matcher = host.matcher(s.toString().trim()); Matcher matcher = host.matcher(s.toString().trim());
if (s.toString().trim().length() == 0 || !matcher.find()) { if (s.toString().trim().length() == 0 || !matcher.find()) {
alertDialog.getButton( alertDialog.getButton(
AlertDialog.BUTTON_POSITIVE).setEnabled(false); AlertDialog.BUTTON_POSITIVE).setEnabled(false);
} else {
// Something into edit text. Enable the button.
alertDialog.getButton(
AlertDialog.BUTTON_POSITIVE).setEnabled(true);
}
if (s.length() > 2 && !isLoadingInstance) {
final String action = "/instances/search";
final HashMap<String, String> parameters = new HashMap<>();
parameters.put("q", s.toString().trim());
parameters.put("count", String.valueOf(1000));
parameters.put("name", String.valueOf(true));
isLoadingInstance = true;
if (oldSearch == null || !oldSearch.equals(s.toString().trim()))
new Thread(new Runnable() {
@Override
public void run() {
try {
final String response = new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
runOnUiThread(new Runnable() {
public void run() {
isLoadingInstance = false;
String[] instances;
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("instances");
if (jsonArray != null) {
int length = 0;
for (int i = 0; i < jsonArray.length(); i++) {
if (!jsonArray.getJSONObject(i).get("name").toString().contains("@") && jsonArray.getJSONObject(i).get("up").toString().equals("true"))
length++;
}
instances = new String[length];
int j = 0;
for (int i = 0; i < jsonArray.length(); i++) {
if (!jsonArray.getJSONObject(i).get("name").toString().contains("@") && jsonArray.getJSONObject(i).get("up").toString().equals("true")) {
instances[j] = jsonArray.getJSONObject(i).get("name").toString();
j++;
}
}
} else {
instances = new String[]{};
}
instance_list.setAdapter(null);
ArrayAdapter<String> adapter =
new ArrayAdapter<>(ReorderTimelinesActivity.this, android.R.layout.simple_list_item_1, instances);
instance_list.setAdapter(adapter);
if (instance_list.hasFocus() && !ReorderTimelinesActivity.this.isFinishing())
instance_list.showDropDown();
oldSearch = s.toString().trim();
} catch (JSONException ignored) {
isLoadingInstance = false;
}
}
});
} catch (HttpsConnection.HttpsConnectionException e) {
isLoadingInstance = false;
} catch (Exception e) {
isLoadingInstance = false;
}
}
}).start();
else
isLoadingInstance = false;
}
} else { } else {
// Something into edit text. Enable the button.
alertDialog.getButton( alertDialog.getButton(
AlertDialog.BUTTON_POSITIVE).setEnabled(true); AlertDialog.BUTTON_POSITIVE).setEnabled(true);
} }
if (s.length() > 2 && !isLoadingInstance) {
final String action = "/instances/search";
final HashMap<String, String> parameters = new HashMap<>();
parameters.put("q", s.toString().trim());
parameters.put("count", String.valueOf(1000));
parameters.put("name", String.valueOf(true));
isLoadingInstance = true;
if (oldSearch == null || !oldSearch.equals(s.toString().trim()))
new Thread(() -> {
try {
final String response = new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
runOnUiThread(() -> {
isLoadingInstance = false;
String[] instances;
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("instances");
int length = 0;
for (int i = 0; i < jsonArray.length(); i++) {
if (!jsonArray.getJSONObject(i).get("name").toString().contains("@") && jsonArray.getJSONObject(i).get("up").toString().equals("true"))
length++;
}
instances = new String[length];
int j = 0;
for (int i = 0; i < jsonArray.length(); i++) {
if (!jsonArray.getJSONObject(i).get("name").toString().contains("@") && jsonArray.getJSONObject(i).get("up").toString().equals("true")) {
instances[j] = jsonArray.getJSONObject(i).get("name").toString();
j++;
}
}
instance_list.setAdapter(null);
ArrayAdapter<String> adapter =
new ArrayAdapter<>(ReorderTimelinesActivity.this, android.R.layout.simple_list_item_1, instances);
instance_list.setAdapter(adapter);
if (instance_list.hasFocus() && !ReorderTimelinesActivity.this.isFinishing())
instance_list.showDropDown();
oldSearch = s.toString().trim();
} catch (JSONException ignored) {
isLoadingInstance = false;
}
});
} catch (Exception e) {
isLoadingInstance = false;
}
}).start();
else
isLoadingInstance = false;
}
} else {
alertDialog.getButton(
AlertDialog.BUTTON_POSITIVE).setEnabled(true);
} }
});
} }
});
}); });
toolbar_title.setText(R.string.action_reorder_timeline); toolbar_title.setText(R.string.action_reorder_timeline);
} }
@ -390,40 +350,34 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
break; break;
} }
undo_action.setPaintFlags(undo_action.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); undo_action.setPaintFlags(undo_action.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
Runnable runnable = new Runnable() { Runnable runnable = () -> {
@Override undo_container.setVisibility(View.GONE);
public void run() { SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
undo_container.setVisibility(View.GONE); switch (manageTimelines.getType()) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); case TAG:
switch (manageTimelines.getType()) { new SearchDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getTagTimeline().getName());
case TAG: new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines);
new SearchDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getTagTimeline().getName()); break;
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines); case INSTANCE:
break; new InstancesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getRemoteInstance().getHost());
case INSTANCE: new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines);
new InstancesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines.getRemoteInstance().getHost()); break;
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(manageTimelines); case LIST:
break; timeline = manageTimelines;
case LIST: new ManageListsAsyncTask(ReorderTimelinesActivity.this, ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
timeline = manageTimelines; new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(timeline);
new ManageListsAsyncTask(ReorderTimelinesActivity.this, ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); refresh_list = true;
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(timeline); break;
refresh_list = true;
break;
}
updated = true;
} }
updated = true;
}; };
Handler handler = new Handler(); Handler handler = new Handler();
handler.postDelayed(runnable, 4000); handler.postDelayed(runnable, 4000);
undo_action.setOnClickListener(new View.OnClickListener() { undo_action.setOnClickListener(v -> {
@Override timelines.add(position, manageTimelines);
public void onClick(View v) { adapter.notifyItemInserted(position);
timelines.add(position, manageTimelines); undo_container.setVisibility(View.GONE);
adapter.notifyItemInserted(position); handler.removeCallbacks(runnable);
undo_container.setVisibility(View.GONE);
handler.removeCallbacks(runnable);
}
}); });
} }

View File

@ -545,14 +545,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if ((MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) && account.getFields() != null && account.getFields().size() > 0) { if ((MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) && account.getFields() != null && account.getFields().size() > 0) {
LinkedHashMap<String, String> fields = account.getFields(); LinkedHashMap<String, String> fields = account.getFields();
LinkedHashMap<String, Boolean> fieldsVerified = account.getFieldsVerified(); LinkedHashMap<String, Boolean> fieldsVerified = account.getFieldsVerified();
Iterator it = fields.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = fields.entrySet().iterator();
int i = 1; int i = 1;
LinearLayout fields_container = findViewById(R.id.fields_container); LinearLayout fields_container = findViewById(R.id.fields_container);
if (fields_container != null) if (fields_container != null)
fields_container.setVisibility(View.VISIBLE); fields_container.setVisibility(View.VISIBLE);
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, String> pair = it.next();
String label = (String) pair.getKey(); String label = pair.getKey();
if (label != null && fieldsVerified != null && fieldsVerified.containsKey(label)) { if (label != null && fieldsVerified != null && fieldsVerified.containsKey(label)) {
boolean verified = fieldsVerified.get(label); boolean verified = fieldsVerified.get(label);
@ -962,24 +962,20 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
LinkedHashMap<String, Boolean> fieldsVerified = account.getFieldsVerified(); LinkedHashMap<String, Boolean> fieldsVerified = account.getFieldsVerified();
if (account.getFieldsSpan() != null && account.getFieldsSpan().size() > 0) { if (account.getFieldsSpan() != null && account.getFieldsSpan().size() > 0) {
HashMap<SpannableString, SpannableString> fieldsSpan = account.getFieldsSpan(); HashMap<SpannableString, SpannableString> fieldsSpan = account.getFieldsSpan();
Iterator it = fieldsSpan.entrySet().iterator();
Iterator<Map.Entry<SpannableString, SpannableString>> it = fieldsSpan.entrySet().iterator();
int i = 1; int i = 1;
LinearLayout fields_container = findViewById(R.id.fields_container); LinearLayout fields_container = findViewById(R.id.fields_container);
if (fields_container != null) if (fields_container != null)
fields_container.setVisibility(View.VISIBLE); fields_container.setVisibility(View.VISIBLE);
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<SpannableString, SpannableString> pair = it.next();
SpannableString label = (SpannableString) pair.getKey(); SpannableString label = pair.getKey();
SpannableString value = (SpannableString) pair.getValue(); SpannableString value = pair.getValue();
LinearLayout field; LinearLayout field;
TextView labelView; TextView labelView;
TextView valueView; TextView valueView;
switch (i) { switch (i) {
case 1:
field = findViewById(R.id.field1);
labelView = findViewById(R.id.label1);
valueView = findViewById(R.id.value1);
break;
case 2: case 2:
field = findViewById(R.id.field2); field = findViewById(R.id.field2);
labelView = findViewById(R.id.label2); labelView = findViewById(R.id.label2);
@ -1166,7 +1162,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
tags = new ArrayList<>(featuredTagsSet); tags = new ArrayList<>(featuredTagsSet);
} }
tags.add(0, getString(R.string.no_tags)); tags.add(0, getString(R.string.no_tags));
String[] tagsString = tags.toArray(new String[tags.size()]); String[] tagsString = tags.toArray(new String[0]);
List<String> finalTags = tags; List<String> finalTags = tags;
String tag = sharedpreferences.getString(Helper.SET_FEATURED_TAG_ACTION, null); String tag = sharedpreferences.getString(Helper.SET_FEATURED_TAG_ACTION, null);
int checkedposition = 0; int checkedposition = 0;

View File

@ -19,7 +19,6 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -70,40 +69,34 @@ public class TagCacheActivity extends BaseActivity {
EditText tag_add = findViewById(R.id.tag_add); EditText tag_add = findViewById(R.id.tag_add);
ImageButton save_tag = findViewById(R.id.save_tag); ImageButton save_tag = findViewById(R.id.save_tag);
save_tag.setOnClickListener(new View.OnClickListener() { save_tag.setOnClickListener(v -> {
@Override if (tag_add.getText() != null && tag_add.getText().toString().trim().replaceAll("#", "").length() > 0) {
public void onClick(View v) { String tagToInsert = tag_add.getText().toString().trim().replaceAll("#", "");
if (tag_add.getText() != null && tag_add.getText().toString().trim().replaceAll("\\#", "").length() > 0) { boolean isPresent = new TagsCacheDAO(TagCacheActivity.this, db).isPresent(tagToInsert);
String tagToInsert = tag_add.getText().toString().trim().replaceAll("\\#", ""); if (isPresent)
boolean isPresent = new TagsCacheDAO(TagCacheActivity.this, db).isPresent(tagToInsert); Toasty.warning(TagCacheActivity.this, getString(R.string.tags_already_stored), Toast.LENGTH_LONG).show();
if (isPresent) else {
Toasty.warning(TagCacheActivity.this, getString(R.string.tags_already_stored), Toast.LENGTH_LONG).show(); new TagsCacheDAO(TagCacheActivity.this, db).insert(tagToInsert);
else { int position = tags.size();
new TagsCacheDAO(TagCacheActivity.this, db).insert(tagToInsert); tags.add(tagToInsert);
int position = tags.size(); Toasty.success(TagCacheActivity.this, getString(R.string.tags_stored), Toast.LENGTH_LONG).show();
tags.add(tagToInsert); tag_add.setText("");
Toasty.success(TagCacheActivity.this, getString(R.string.tags_stored), Toast.LENGTH_LONG).show(); tagsEditAdapter.notifyItemInserted(position);
tag_add.setText("");
tagsEditAdapter.notifyItemInserted(position);
}
} }
} }
}); });
setTitle(R.string.manage_tags); setTitle(R.string.manage_tags);
AsyncTask.execute(new Runnable() { AsyncTask.execute(() -> {
@Override
public void run() {
List<String> tagsTemp = new TagsCacheDAO(TagCacheActivity.this, db).getAll(); List<String> tagsTemp = new TagsCacheDAO(TagCacheActivity.this, db).getAll();
if (tagsTemp != null) if (tagsTemp != null)
tags = tagsTemp; tags = tagsTemp;
if (tags != null) { if (tags != null) {
tagsEditAdapter = new TagsEditAdapter(tags); tagsEditAdapter = new TagsEditAdapter(tags);
tag_list.setAdapter(tagsEditAdapter); tag_list.setAdapter(tagsEditAdapter);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(TagCacheActivity.this); LinearLayoutManager mLayoutManager = new LinearLayoutManager(TagCacheActivity.this);
tag_list.setLayoutManager(mLayoutManager); tag_list.setLayoutManager(mLayoutManager);
}
} }
}); });

View File

@ -436,11 +436,8 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (s.toString().length() == 0) if (s.toString().length() == 0)
currentCursorPosition[0] = 0; currentCursorPosition[0] = 0;
//Only check last 15 characters before cursor position to avoid lags //Only check last 15 characters before cursor position to avoid lags
if (currentCursorPosition[0] < searchDeep) { //Less than 15 characters are written before the cursor position //Less than 15 characters are written before the cursor position
searchLength[0] = currentCursorPosition[0]; searchLength[0] = Math.min(currentCursorPosition[0], searchDeep);
} else {
searchLength[0] = searchDeep;
}
int totalChar = countLength(social, toot_content, toot_cw_content); int totalChar = countLength(social, toot_content, toot_cw_content);
@ -894,12 +891,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (s.toString().length() == 0) if (s.toString().length() == 0)
currentCursorPosition = 0; currentCursorPosition = 0;
//Only check last 15 characters before cursor position to avoid lags //Only check last 15 characters before cursor position to avoid lags
int searchLength; int searchLength = Math.min(currentCursorPosition, searchDeep);
if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position
searchLength = currentCursorPosition;
} else {
searchLength = searchDeep;
}
int totalChar = countLength(wysiwyg, toot_cw_content); int totalChar = countLength(wysiwyg, toot_cw_content);
toot_space_left.setText(String.valueOf(totalChar)); toot_space_left.setText(String.valueOf(totalChar));
if (currentCursorPosition - (searchLength - 1) < 0 || currentCursorPosition == 0 || currentCursorPosition > s.toString().length()) if (currentCursorPosition - (searchLength - 1) < 0 || currentCursorPosition == 0 || currentCursorPosition > s.toString().length())
@ -1018,6 +1010,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (tootReply.getAccount() != null && tootReply.getAccount().getMoved_to_account() != null) { if (tootReply.getAccount() != null && tootReply.getAccount().getMoved_to_account() != null) {
warning_message.setVisibility(View.VISIBLE); warning_message.setVisibility(View.VISIBLE);
} }
assert tootReply.getAccount() != null;
new RetrieveRelationshipAsyncTask(TootActivity.this, tootReply.getAccount().getId(), TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(TootActivity.this, tootReply.getAccount().getId(), TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
if (scheduledstatus != null) if (scheduledstatus != null)
@ -1333,11 +1326,11 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) { if (successfullyUploadedFiles != null && successfullyUploadedFiles.size() > 0) {
Iterator it = filesMap.entrySet().iterator(); Iterator<Map.Entry<String, Uri>> it = filesMap.entrySet().iterator();
Uri fileName = null; Uri fileName = null;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, Uri> pair = it.next();
fileName = (Uri) pair.getValue(); fileName = pair.getValue();
it.remove(); it.remove();
} }
if (fileName != null) { if (fileName != null) {
@ -1373,11 +1366,11 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
imageView.setImageBitmap(resource); imageView.setImageBitmap(resource);
if (displayWYSIWYG()) { if (displayWYSIWYG()) {
url_for_media = finalUrl; url_for_media = finalUrl;
Iterator it = filesMap.entrySet().iterator(); Iterator<Map.Entry<String, Uri>> it = filesMap.entrySet().iterator();
String fileName = null; String fileName = null;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next(); Map.Entry<String, Uri> pair = it.next();
fileName = (String) pair.getKey(); fileName = pair.getKey();
it.remove(); it.remove();
} }
if (fileName != null && fileName.contains("fedilabins_")) { if (fileName != null && fileName.contains("fedilabins_")) {
@ -3220,9 +3213,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} }
}); });
imageView.setTag(attachment.getId()); imageView.setTag(attachment.getId());
imageView.setOnClickListener(view -> { imageView.setOnClickListener(view -> imageView.setOnClickListener(view1 -> showAddDescription(attachment)));
imageView.setOnClickListener(view1 -> showAddDescription(attachment));
});
imageView.setOnLongClickListener(view -> { imageView.setOnLongClickListener(view -> {
showRemove(imageView.getId()); showRemove(imageView.getId());
return false; return false;
@ -3352,12 +3343,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
ownerTootVisibility = 1; ownerTootVisibility = 1;
break; break;
} }
int tootVisibility; int tootVisibility = Math.min(ownerTootVisibility, initialTootVisibility);
if (ownerTootVisibility >= initialTootVisibility) {
tootVisibility = initialTootVisibility;
} else {
tootVisibility = ownerTootVisibility;
}
switch (tootVisibility) { switch (tootVisibility) {
case 4: case 4:
visibility = "public"; visibility = "public";

View File

@ -126,9 +126,7 @@ public class WebviewConnectActivity extends BaseActivity {
clearCookies(WebviewConnectActivity.this); clearCookies(WebviewConnectActivity.this);
webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setJavaScriptEnabled(true);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT); String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
if (user_agent != null) { webView.getSettings().setUserAgentString(user_agent);
webView.getSettings().setUserAgentString(user_agent);
}
if (android.os.Build.VERSION.SDK_INT >= 21) { if (android.os.Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true); CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
} else { } else {

View File

@ -79,9 +79,6 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
case Helper.THEME_LIGHT: case Helper.THEME_LIGHT:
setTheme(R.style.AppTheme_NoActionBar_Fedilab); setTheme(R.style.AppTheme_NoActionBar_Fedilab);
break; break;
case Helper.THEME_DARK:
setTheme(R.style.AppThemeDark_NoActionBar);
break;
case Helper.THEME_BLACK: case Helper.THEME_BLACK:
setTheme(R.style.AppThemeBlack_NoActionBar); setTheme(R.style.AppThemeBlack_NoActionBar);
break; break;
@ -146,51 +143,41 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
} }
Button follow_accounts_select = findViewById(R.id.follow_accounts_select); Button follow_accounts_select = findViewById(R.id.follow_accounts_select);
follow_accounts_select.setOnClickListener(new View.OnClickListener() { follow_accounts_select.setOnClickListener(v -> {
@Override if (follow_accounts_select.getText().equals(getString(R.string.select_all))) {
public void onClick(View v) { follow_accounts_select.setText(R.string.unselect_all);
if (follow_accounts_select.getText().equals(getString(R.string.select_all))) { } else {
follow_accounts_select.setText(R.string.unselect_all); follow_accounts_select.setText(R.string.select_all);
for (TrunkAccount trunkAccount : trunkAccounts) {
trunkAccount.setChecked(true);
}
whoToFollowAccountsAdapter.notifyDataSetChanged();
} else {
follow_accounts_select.setText(R.string.select_all);
for (TrunkAccount trunkAccount : trunkAccounts) {
trunkAccount.setChecked(false);
}
whoToFollowAccountsAdapter.notifyDataSetChanged();
}
} }
for (TrunkAccount trunkAccount : trunkAccounts) {
trunkAccount.setChecked(false);
}
whoToFollowAccountsAdapter.notifyDataSetChanged();
}); });
Button follow_accounts = findViewById(R.id.follow_accounts); Button follow_accounts = findViewById(R.id.follow_accounts);
follow_accounts.setOnClickListener(new View.OnClickListener() { follow_accounts.setOnClickListener(v -> {
@Override follow_accounts.setEnabled(false);
public void onClick(View v) { follow_accounts_select.setEnabled(false);
follow_accounts.setEnabled(false); progess_action.setVisibility(View.VISIBLE);
follow_accounts_select.setEnabled(false); toFollowdId = new ArrayList<>();
progess_action.setVisibility(View.VISIBLE); for (TrunkAccount trunkAccount : trunkAccounts) {
toFollowdId = new ArrayList<>(); if (trunkAccount.isChecked()) {
for (TrunkAccount trunkAccount : trunkAccounts) { toFollowdId.add(trunkAccount.getAcct());
if (trunkAccount.isChecked()) {
toFollowdId.add(trunkAccount.getAcct());
}
} }
if (toFollowdId.size() > 0) { }
Account account = new Account(); if (toFollowdId.size() > 0) {
String[] val = toFollowdId.get(0).split("@"); Account account = new Account();
progess_action.setText(getString(R.string.follow_trunk, toFollowdId.get(0))); String[] val = toFollowdId.get(0).split("@");
if (val.length > 1) { progess_action.setText(getString(R.string.follow_trunk, toFollowdId.get(0)));
account.setAcct(val[0]); if (val.length > 1) {
account.setInstance(val[1]); account.setAcct(val[0]);
new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); account.setInstance(val[1]);
} else { new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Toasty.error(WhoToFollowActivity.this, getString(R.string.toast_impossible_to_follow), Toast.LENGTH_LONG).show(); } else {
follow_accounts.setEnabled(true); Toasty.error(WhoToFollowActivity.this, getString(R.string.toast_impossible_to_follow), Toast.LENGTH_LONG).show();
follow_accounts_select.setEnabled(true); follow_accounts.setEnabled(true);
progess_action.setVisibility(View.GONE); follow_accounts_select.setEnabled(true);
} progess_action.setVisibility(View.GONE);
} }
} }
}); });
@ -199,13 +186,11 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { if (item.getItemId() == android.R.id.home) {
case android.R.id.home: finish();
finish(); return true;
return true;
default:
return super.onOptionsItemSelected(item);
} }
return super.onOptionsItemSelected(item);
} }
@Override @Override
@ -237,6 +222,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.CREATE_LIST, null, null, null, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.CREATE_LIST, null, null, null, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
Account account = new Account(); Account account = new Account();
assert followedId != null;
String[] val = toFollowdId.get(followedId.size()).split("@"); String[] val = toFollowdId.get(followedId.size()).split("@");
progess_action.setText(getString(R.string.follow_trunk, toFollowdId.get(followedId.size()))); progess_action.setText(getString(R.string.follow_trunk, toFollowdId.get(followedId.size())));
if (val.length > 1) { if (val.length > 1) {
@ -253,7 +239,6 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
List<app.fedilab.android.client.Entities.List> lists = apiResponse.getLists(); List<app.fedilab.android.client.Entities.List> lists = apiResponse.getLists();
if (lists != null && lists.size() > 0 && actionType == ManageListsAsyncTask.action.CREATE_LIST) { if (lists != null && lists.size() > 0 && actionType == ManageListsAsyncTask.action.CREATE_LIST) {
String[] accountsId = followedId.toArray(new String[0]);
progess_action.setText(R.string.add_account_list_trunk); progess_action.setText(R.string.add_account_list_trunk);
listId = lists.get(0).getId(); listId = lists.get(0).getId();
listTitle = lists.get(0).getTitle(); listTitle = lists.get(0).getTitle();
@ -264,18 +249,14 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
if (accountListId.size() >= followedId.size() - 1) { if (accountListId.size() >= followedId.size() - 1) {
progess_action.setText(R.string.account_added_list_trunk); progess_action.setText(R.string.account_added_list_trunk);
Handler handler = new Handler(); Handler handler = new Handler();
handler.postDelayed(new Runnable() { handler.postDelayed(() -> {
@Override Intent intent = new Intent(WhoToFollowActivity.this, ListActivity.class);
public void run() { Bundle b = new Bundle();
Intent intent = new Intent(WhoToFollowActivity.this, ListActivity.class); b.putString("id", listId);
Bundle b = new Bundle(); b.putString("title", listTitle);
b.putString("id", listId); intent.putExtras(b);
b.putString("title", listTitle); startActivity(intent);
intent.putExtras(b); finish();
startActivity(intent);
finish();
}
}, 1000); }, 1000);
} else { } else {

View File

@ -266,7 +266,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
} }
List<String> array = Arrays.asList(getResources().getStringArray(R.array.settings_theme)); List<String> array = Arrays.asList(getResources().getStringArray(R.array.settings_theme));
CharSequence[] entries = array.toArray(new CharSequence[array.size()]); CharSequence[] entries = array.toArray(new CharSequence[0]);
CharSequence[] entryValues = new CharSequence[3]; CharSequence[] entryValues = new CharSequence[3];
final SharedPreferences sharedpref = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); final SharedPreferences sharedpref = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpref.getInt(Helper.SET_THEME, Helper.THEME_DARK); int theme = sharedpref.getInt(Helper.SET_THEME, Helper.THEME_DARK);

View File

@ -1538,7 +1538,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
if (featuredTagsSet != null) { if (featuredTagsSet != null) {
tags = new ArrayList<>(featuredTagsSet); tags = new ArrayList<>(featuredTagsSet);
} }
String[] tagsString = tags.toArray(new String[tags.size()]); String[] tagsString = tags.toArray(new String[0]);
set_featured_tags.setTags(tagsString); set_featured_tags.setTags(tagsString);
set_featured_tags.setTagsListener(new TagsEditText.TagsEditListener() { set_featured_tags.setTagsListener(new TagsEditText.TagsEditListener() {