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); setFullscreen(FullScreenMediaController.fullscreen.ON);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
closeFullscreenDialog(); closeFullscreenDialog();
}
setFullscreen(FullScreenMediaController.fullscreen.OFF); setFullscreen(FullScreenMediaController.fullscreen.OFF);
} }
change(); change();
} else {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setFullscreen(FullScreenMediaController.fullscreen.ON);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setFullscreen(FullScreenMediaController.fullscreen.OFF);
}
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
public void onRefresh() {
max_id = null; max_id = null;
firstLoad = true; firstLoad = true;
flag_loading = true; flag_loading = true;
swiped = true; swiped = true;
MainActivity.countNewStatus = 0; 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); 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
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_PROXY_ENABLED, set_enable_proxy.isChecked()); editor.putBoolean(Helper.SET_PROXY_ENABLED, set_enable_proxy.isChecked());
editor.apply(); 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 portVal = port.getText().toString().trim();
String proxy_loginVal = proxy_login.getText().toString().trim(); String proxy_loginVal = proxy_login.getText().toString().trim();
String proxy_passwordVal = proxy_password.getText().toString().trim(); String proxy_passwordVal = proxy_password.getText().toString().trim();
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.SET_PROXY_HOST, hostVal); editor.putString(Helper.SET_PROXY_HOST, hostVal1);
if (portVal.matches("\\d+")) if (portVal1.matches("\\d+"))
editor.putInt(Helper.SET_PROXY_PORT, Integer.parseInt(portVal)); editor.putInt(Helper.SET_PROXY_PORT, Integer.parseInt(portVal1));
editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal); editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal);
editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal); editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal);
editor.apply(); editor.apply();
finish(); 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,23 +136,16 @@ 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
public void onClick(View v) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ReorderTimelinesActivity.this, style); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ReorderTimelinesActivity.this, style);
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater1 = getLayoutInflater();
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.search_instance, null); @SuppressLint("InflateParams") View dialogView = inflater1.inflate(R.layout.search_instance, null);
dialogBuilder.setView(dialogView); dialogBuilder.setView(dialogView);
AutoCompleteTextView instance_list = dialogView.findViewById(R.id.search_instance); AutoCompleteTextView instance_list = dialogView.findViewById(R.id.search_instance);
@ -168,14 +159,10 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
} }
}); });
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
public void onClick(DialogInterface dialog, int id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String instanceName = instance_list.getText().toString().trim().replace("@", ""); String instanceName = instance_list.getText().toString().trim().replace("@", "");
new Thread(new Runnable() { new Thread(() -> {
@Override
public void run() {
try { try {
if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_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?local=true", 10, null, null);
@ -188,8 +175,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
} else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) { } else if (radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) {
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/statuses/public_timeline.json", 10, null, null); new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/statuses/public_timeline.json", 10, null, null);
} }
runOnUiThread(new Runnable() { runOnUiThread(() -> {
public void run() {
dialog.dismiss(); dialog.dismiss();
if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) { if (radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance) {
new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MASTODON"); new InstancesDAO(ReorderTimelinesActivity.this, db).insertInstance(instanceName, "MASTODON");
@ -217,39 +203,25 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
} }
updated = true; updated = true;
} }
}
}); });
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
runOnUiThread(new Runnable() { runOnUiThread(() -> Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show());
public void run() {
Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show();
}
});
}
} }
}).start(); }).start();
}
}); });
AlertDialog alertDialog = dialogBuilder.create(); AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { alertDialog.setOnDismissListener(dialogInterface -> {
@Override
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) if (alertDialog.getWindow() != null)
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
alertDialog.show(); 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) {
String oldSearch = parent.getItemAtPosition(position).toString().trim();
}
}); });
instance_list.addTextChangedListener(new TextWatcher() { instance_list.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -264,7 +236,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
@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(
@ -283,19 +255,15 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
isLoadingInstance = true; isLoadingInstance = true;
if (oldSearch == null || !oldSearch.equals(s.toString().trim())) if (oldSearch == null || !oldSearch.equals(s.toString().trim()))
new Thread(new Runnable() { new Thread(() -> {
@Override
public void run() {
try { try {
final String response = new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN); 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() { runOnUiThread(() -> {
public void run() {
isLoadingInstance = false; isLoadingInstance = false;
String[] instances; String[] instances;
try { try {
JSONObject jsonObject = new JSONObject(response); JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("instances"); JSONArray jsonArray = jsonObject.getJSONArray("instances");
if (jsonArray != null) {
int length = 0; int length = 0;
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
if (!jsonArray.getJSONObject(i).get("name").toString().contains("@") && jsonArray.getJSONObject(i).get("up").toString().equals("true")) if (!jsonArray.getJSONObject(i).get("name").toString().contains("@") && jsonArray.getJSONObject(i).get("up").toString().equals("true"))
@ -309,9 +277,6 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
j++; j++;
} }
} }
} else {
instances = new String[]{};
}
instance_list.setAdapter(null); instance_list.setAdapter(null);
ArrayAdapter<String> adapter = ArrayAdapter<String> adapter =
new ArrayAdapter<>(ReorderTimelinesActivity.this, android.R.layout.simple_list_item_1, instances); new ArrayAdapter<>(ReorderTimelinesActivity.this, android.R.layout.simple_list_item_1, instances);
@ -323,15 +288,11 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
} catch (JSONException ignored) { } catch (JSONException ignored) {
isLoadingInstance = false; isLoadingInstance = false;
} }
}
}); });
} catch (HttpsConnection.HttpsConnectionException e) {
isLoadingInstance = false;
} catch (Exception e) { } catch (Exception e) {
isLoadingInstance = false; isLoadingInstance = false;
} }
}
}).start(); }).start();
else else
isLoadingInstance = false; isLoadingInstance = false;
@ -343,7 +304,6 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
} }
}); });
}
}); });
toolbar_title.setText(R.string.action_reorder_timeline); toolbar_title.setText(R.string.action_reorder_timeline);
} }
@ -390,9 +350,7 @@ 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
public void run() {
undo_container.setVisibility(View.GONE); undo_container.setVisibility(View.GONE);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
switch (manageTimelines.getType()) { switch (manageTimelines.getType()) {
@ -412,18 +370,14 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
break; 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
public void onClick(View v) {
timelines.add(position, manageTimelines); timelines.add(position, manageTimelines);
adapter.notifyItemInserted(position); adapter.notifyItemInserted(position);
undo_container.setVisibility(View.GONE); undo_container.setVisibility(View.GONE);
handler.removeCallbacks(runnable); 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,11 +69,9 @@ 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) {
String tagToInsert = tag_add.getText().toString().trim().replaceAll("\\#", "");
boolean isPresent = new TagsCacheDAO(TagCacheActivity.this, db).isPresent(tagToInsert); boolean isPresent = new TagsCacheDAO(TagCacheActivity.this, db).isPresent(tagToInsert);
if (isPresent) if (isPresent)
Toasty.warning(TagCacheActivity.this, getString(R.string.tags_already_stored), Toast.LENGTH_LONG).show(); Toasty.warning(TagCacheActivity.this, getString(R.string.tags_already_stored), Toast.LENGTH_LONG).show();
@ -87,13 +84,10 @@ public class TagCacheActivity extends BaseActivity {
tagsEditAdapter.notifyItemInserted(position); 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)
@ -104,7 +98,6 @@ public class TagCacheActivity extends BaseActivity {
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,28 +143,19 @@ 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
public void onClick(View v) {
if (follow_accounts_select.getText().equals(getString(R.string.select_all))) { if (follow_accounts_select.getText().equals(getString(R.string.select_all))) {
follow_accounts_select.setText(R.string.unselect_all); follow_accounts_select.setText(R.string.unselect_all);
for (TrunkAccount trunkAccount : trunkAccounts) {
trunkAccount.setChecked(true);
}
whoToFollowAccountsAdapter.notifyDataSetChanged();
} else { } else {
follow_accounts_select.setText(R.string.select_all); follow_accounts_select.setText(R.string.select_all);
}
for (TrunkAccount trunkAccount : trunkAccounts) { for (TrunkAccount trunkAccount : trunkAccounts) {
trunkAccount.setChecked(false); trunkAccount.setChecked(false);
} }
whoToFollowAccountsAdapter.notifyDataSetChanged(); 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
public void onClick(View v) {
follow_accounts.setEnabled(false); follow_accounts.setEnabled(false);
follow_accounts_select.setEnabled(false); follow_accounts_select.setEnabled(false);
progess_action.setVisibility(View.VISIBLE); progess_action.setVisibility(View.VISIBLE);
@ -192,20 +180,17 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
progess_action.setVisibility(View.GONE); progess_action.setVisibility(View.GONE);
} }
} }
}
}); });
} }
@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,9 +249,7 @@ 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
public void run() {
Intent intent = new Intent(WhoToFollowActivity.this, ListActivity.class); Intent intent = new Intent(WhoToFollowActivity.this, ListActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("id", listId); b.putString("id", listId);
@ -274,8 +257,6 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
intent.putExtras(b); intent.putExtras(b);
startActivity(intent); startActivity(intent);
finish(); 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() {