Cleaning code 1

NTFY_avoid_429
Thomas 11 months ago
parent 25e42fc7da
commit 5cca26e0c4

@ -150,7 +150,6 @@ public class LoginActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
setContentView(new FrameLayout(this)); setContentView(new FrameLayout(this));
FragmentLoginMain fragmentLoginMain = new FragmentLoginMain(); FragmentLoginMain fragmentLoginMain = new FragmentLoginMain();
Helper.addFragment(getSupportFragmentManager(), android.R.id.content, fragmentLoginMain, null, null, null); Helper.addFragment(getSupportFragmentManager(), android.R.id.content, fragmentLoginMain, null, null, null);

@ -27,6 +27,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity; import app.fedilab.android.activities.MainActivity;
@ -134,12 +135,12 @@ public class AccountReportActivity extends BaseBarActivity {
binding.reject.setOnClickListener(view -> adminVM.reject(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.REJECT))); binding.reject.setOnClickListener(view -> adminVM.reject(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.REJECT)));
binding.allow.setOnClickListener(view -> adminVM.approve(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.APPROVE))); binding.allow.setOnClickListener(view -> adminVM.approve(MainActivity.currentInstance, MainActivity.currentToken, account_id).observe(this, account -> fillReport(account, actionType.APPROVE)));
binding.warn.setOnClickListener(view -> { binding.warn.setOnClickListener(view -> {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "none", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked()); adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "none", null, null, Objects.requireNonNull(binding.comment.getText()).toString().trim(), binding.emailUser.isChecked());
fillReport(accountAdmin, actionType.NONE); fillReport(accountAdmin, actionType.NONE);
}); });
binding.silence.setOnClickListener(view -> { binding.silence.setOnClickListener(view -> {
if (!accountAdmin.silenced) { if (!accountAdmin.silenced) {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "silence", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked()); adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "silence", null, null, Objects.requireNonNull(binding.comment.getText()).toString().trim(), binding.emailUser.isChecked());
accountAdmin.silenced = true; accountAdmin.silenced = true;
fillReport(accountAdmin, actionType.SILENCE); fillReport(accountAdmin, actionType.SILENCE);
} else { } else {
@ -148,7 +149,7 @@ public class AccountReportActivity extends BaseBarActivity {
}); });
binding.disable.setOnClickListener(view -> { binding.disable.setOnClickListener(view -> {
if (!accountAdmin.disabled) { if (!accountAdmin.disabled) {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "disable", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked()); adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "disable", null, null, Objects.requireNonNull(binding.comment.getText()).toString().trim(), binding.emailUser.isChecked());
accountAdmin.disabled = true; accountAdmin.disabled = true;
fillReport(accountAdmin, actionType.DISABLE); fillReport(accountAdmin, actionType.DISABLE);
} else { } else {
@ -158,7 +159,7 @@ public class AccountReportActivity extends BaseBarActivity {
binding.suspend.setOnClickListener(view -> { binding.suspend.setOnClickListener(view -> {
if (!accountAdmin.suspended) { if (!accountAdmin.suspended) {
adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "suspend", null, null, binding.comment.getText().toString().trim(), binding.emailUser.isChecked()); adminVM.performAction(MainActivity.currentInstance, MainActivity.currentToken, account_id, "suspend", null, null, Objects.requireNonNull(binding.comment.getText()).toString().trim(), binding.emailUser.isChecked());
accountAdmin.suspended = true; accountAdmin.suspended = true;
fillReport(accountAdmin, actionType.SUSPEND); fillReport(accountAdmin, actionType.SUSPEND);
} else { } else {
@ -170,35 +171,21 @@ public class AccountReportActivity extends BaseBarActivity {
if (type != null) { if (type != null) {
String message = null; String message = null;
switch (type) { switch (type) {
case SILENCE: case SILENCE -> message = getString(R.string.account_silenced);
message = getString(R.string.account_silenced); case UNSILENCE -> message = getString(R.string.account_unsilenced);
break; case DISABLE -> message = getString(R.string.account_disabled);
case UNSILENCE: case ENABLE -> message = getString(R.string.account_undisabled);
message = getString(R.string.account_unsilenced); case SUSPEND -> message = getString(R.string.account_suspended);
break; case UNSUSPEND -> message = getString(R.string.account_unsuspended);
case DISABLE: case NONE -> message = getString(R.string.account_warned);
message = getString(R.string.account_disabled); case APPROVE -> {
break;
case ENABLE:
message = getString(R.string.account_undisabled);
break;
case SUSPEND:
message = getString(R.string.account_suspended);
break;
case UNSUSPEND:
message = getString(R.string.account_unsuspended);
break;
case NONE:
message = getString(R.string.account_warned);
break;
case APPROVE:
binding.allowRejectGroup.setVisibility(View.GONE); binding.allowRejectGroup.setVisibility(View.GONE);
message = getString(R.string.account_approved); message = getString(R.string.account_approved);
break; }
case REJECT: case REJECT -> {
binding.allowRejectGroup.setVisibility(View.GONE); binding.allowRejectGroup.setVisibility(View.GONE);
message = getString(R.string.account_rejected); message = getString(R.string.account_rejected);
break; }
} }
if (message != null) { if (message != null) {
Toasty.success(AccountReportActivity.this, message, Toast.LENGTH_LONG).show(); Toasty.success(AccountReportActivity.this, message, Toast.LENGTH_LONG).show();

@ -73,73 +73,73 @@ public class BaseActivity extends AppCompatActivity {
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
switch (currentNightMode) { switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO: case Configuration.UI_MODE_NIGHT_NO -> {
String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT"); String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT");
switch (defaultLight) { switch (defaultLight) {
case "LIGHT": case "LIGHT" -> {
setTheme(R.style.AppTheme); setTheme(R.style.AppTheme);
currentThemeId = R.style.AppTheme; currentThemeId = R.style.AppTheme;
break; }
case "SOLARIZED_LIGHT": case "SOLARIZED_LIGHT" -> {
setTheme(R.style.SolarizedAppTheme); setTheme(R.style.SolarizedAppTheme);
currentThemeId = R.style.SolarizedAppTheme; currentThemeId = R.style.SolarizedAppTheme;
break; }
} }
break; }
case Configuration.UI_MODE_NIGHT_YES: case Configuration.UI_MODE_NIGHT_YES -> {
String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK"); String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK");
switch (defaultDark) { switch (defaultDark) {
case "DARK": case "DARK" -> {
setTheme(R.style.AppTheme); setTheme(R.style.AppTheme);
currentThemeId = R.style.AppTheme; currentThemeId = R.style.AppTheme;
break; }
case "SOLARIZED_DARK": case "SOLARIZED_DARK" -> {
setTheme(R.style.SolarizedAppTheme); setTheme(R.style.SolarizedAppTheme);
currentThemeId = R.style.SolarizedAppTheme; currentThemeId = R.style.SolarizedAppTheme;
break; }
case "BLACK": case "BLACK" -> {
setTheme(R.style.BlackAppTheme); setTheme(R.style.BlackAppTheme);
currentThemeId = R.style.BlackAppTheme; currentThemeId = R.style.BlackAppTheme;
break; }
case "DRACULA": case "DRACULA" -> {
setTheme(R.style.DraculaAppTheme); setTheme(R.style.DraculaAppTheme);
currentThemeId = R.style.DraculaAppTheme; currentThemeId = R.style.DraculaAppTheme;
break; }
} }
break; }
} }
} else { } else {
switch (currentTheme) { switch (currentTheme) {
case "LIGHT": case "LIGHT" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.AppTheme); setTheme(R.style.AppTheme);
currentThemeId = R.style.AppTheme; currentThemeId = R.style.AppTheme;
break; }
case "DARK": case "DARK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.AppTheme); setTheme(R.style.AppTheme);
currentThemeId = R.style.AppTheme; currentThemeId = R.style.AppTheme;
break; }
case "SOLARIZED_LIGHT": case "SOLARIZED_LIGHT" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.SolarizedAppTheme); setTheme(R.style.SolarizedAppTheme);
currentThemeId = R.style.SolarizedAppTheme; currentThemeId = R.style.SolarizedAppTheme;
break; }
case "SOLARIZED_DARK": case "SOLARIZED_DARK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.SolarizedAppTheme); setTheme(R.style.SolarizedAppTheme);
currentThemeId = R.style.SolarizedAppTheme; currentThemeId = R.style.SolarizedAppTheme;
break; }
case "BLACK": case "BLACK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.BlackAppTheme); setTheme(R.style.BlackAppTheme);
currentThemeId = R.style.BlackAppTheme; currentThemeId = R.style.BlackAppTheme;
break; }
case "DRACULA": case "DRACULA" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.DraculaAppTheme); setTheme(R.style.DraculaAppTheme);
currentThemeId = R.style.DraculaAppTheme; currentThemeId = R.style.DraculaAppTheme;
break; }
} }
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

@ -68,62 +68,50 @@ public class BaseBarActivity extends AppCompatActivity {
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
switch (currentNightMode) { switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO: case Configuration.UI_MODE_NIGHT_NO -> {
String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT"); String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT");
switch (defaultLight) { switch (defaultLight) {
case "LIGHT": case "LIGHT" -> setTheme(R.style.AppThemeBar);
setTheme(R.style.AppThemeBar); case "SOLARIZED_LIGHT" -> setTheme(R.style.SolarizedAppThemeBar);
break;
case "SOLARIZED_LIGHT":
setTheme(R.style.SolarizedAppThemeBar);
break;
} }
break; }
case Configuration.UI_MODE_NIGHT_YES: case Configuration.UI_MODE_NIGHT_YES -> {
String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK"); String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK");
switch (defaultDark) { switch (defaultDark) {
case "DARK": case "DARK" -> setTheme(R.style.AppThemeBar);
setTheme(R.style.AppThemeBar); case "SOLARIZED_DARK" -> setTheme(R.style.SolarizedAppThemeBar);
break; case "BLACK" -> setTheme(R.style.BlackAppThemeBar);
case "SOLARIZED_DARK": case "DRACULA" -> setTheme(R.style.DraculaAppThemeBar);
setTheme(R.style.SolarizedAppThemeBar);
break;
case "BLACK":
setTheme(R.style.BlackAppThemeBar);
break;
case "DRACULA":
setTheme(R.style.DraculaAppThemeBar);
break;
} }
break; }
} }
} else { } else {
switch (currentTheme) { switch (currentTheme) {
case "LIGHT": case "LIGHT" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.AppThemeBar); setTheme(R.style.AppThemeBar);
break; }
case "DARK": case "DARK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.AppThemeBar); setTheme(R.style.AppThemeBar);
break; }
case "SOLARIZED_LIGHT": case "SOLARIZED_LIGHT" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.SolarizedAppThemeBar); setTheme(R.style.SolarizedAppThemeBar);
break; }
case "SOLARIZED_DARK": case "SOLARIZED_DARK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.SolarizedAppThemeBar); setTheme(R.style.SolarizedAppThemeBar);
break; }
case "BLACK": case "BLACK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.BlackAppThemeBar); setTheme(R.style.BlackAppThemeBar);
break; }
case "DRACULA": case "DRACULA" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.DraculaAppThemeBar); setTheme(R.style.DraculaAppThemeBar);
break; }
} }
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

@ -69,62 +69,50 @@ public class BaseTransparentActivity extends AppCompatActivity {
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
switch (currentNightMode) { switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO: case Configuration.UI_MODE_NIGHT_NO -> {
String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT"); String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT");
switch (defaultLight) { switch (defaultLight) {
case "LIGHT": case "LIGHT" -> setTheme(R.style.Transparent);
setTheme(R.style.Transparent); case "SOLARIZED_LIGHT" -> setTheme(R.style.TransparentSolarized);
break;
case "SOLARIZED_LIGHT":
setTheme(R.style.TransparentSolarized);
break;
} }
break; }
case Configuration.UI_MODE_NIGHT_YES: case Configuration.UI_MODE_NIGHT_YES -> {
String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK"); String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK");
switch (defaultDark) { switch (defaultDark) {
case "DARK": case "DARK" -> setTheme(R.style.Transparent);
setTheme(R.style.Transparent); case "SOLARIZED_DARK" -> setTheme(R.style.TransparentSolarized);
break; case "BLACK" -> setTheme(R.style.TransparentBlack);
case "SOLARIZED_DARK": case "DRACULA" -> setTheme(R.style.TransparentDracula);
setTheme(R.style.TransparentSolarized);
break;
case "BLACK":
setTheme(R.style.TransparentBlack);
break;
case "DRACULA":
setTheme(R.style.TransparentDracula);
break;
} }
break; }
} }
} else { } else {
switch (currentTheme) { switch (currentTheme) {
case "LIGHT": case "LIGHT" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.Transparent); setTheme(R.style.Transparent);
break; }
case "DARK": case "DARK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.Transparent); setTheme(R.style.Transparent);
break; }
case "SOLARIZED_LIGHT": case "SOLARIZED_LIGHT" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.TransparentSolarized); setTheme(R.style.TransparentSolarized);
break; }
case "SOLARIZED_DARK": case "SOLARIZED_DARK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.TransparentSolarized); setTheme(R.style.TransparentSolarized);
break; }
case "BLACK": case "BLACK" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.TransparentBlack); setTheme(R.style.TransparentBlack);
break; }
case "DRACULA": case "DRACULA" -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.TransparentDracula); setTheme(R.style.TransparentDracula);
break; }
} }
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

@ -226,7 +226,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
Description description = binding.chart.getDescription(); Description description = binding.chart.getDescription();
description.setEnabled(false); description.setEnabled(false);
CustomMarkerView mv = new CustomMarkerView(CheckHomeCacheActivity.this, R.layout.custom_marker_view_layout); CustomMarkerView mv = new CustomMarkerView(CheckHomeCacheActivity.this, R.layout.custom_marker_view_layout);
binding.chart.setMarkerView(mv); binding.chart.setMarker(mv);
binding.chart.invalidate(); binding.chart.invalidate();
}); });
@ -391,7 +391,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
Description description = binding.chart2.getDescription(); Description description = binding.chart2.getDescription();
description.setEnabled(true); description.setEnabled(true);
CustomMarkerView2 mv = new CustomMarkerView2(CheckHomeCacheActivity.this, R.layout.custom_marker_view_layout); CustomMarkerView2 mv = new CustomMarkerView2(CheckHomeCacheActivity.this, R.layout.custom_marker_view_layout);
binding.chart2.setMarkerView(mv); binding.chart2.setMarker(mv);
binding.chart2.invalidate(); binding.chart2.invalidate();
}); });
@ -450,7 +450,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
@Override @Override
public void refreshContent(Entry e, Highlight highlight) { public void refreshContent(Entry e, Highlight highlight) {
if (xVals.size() > (int) e.getX()) { if (xVals.size() > (int) e.getX()) {
tvContent.setText(getString(R.string.messages, (int) e.getY()) + "\r\n" + xVals.get((int) e.getX())); tvContent.setText(getString(R.string.messages, (int) e.getY()));
} }
// this will perform necessary layouting // this will perform necessary layouting
@ -496,7 +496,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
text += dateDiffFull(timelineCacheLogsListToAnalyse.get((int) e.getX()).created_at); text += dateDiffFull(timelineCacheLogsListToAnalyse.get((int) e.getX()).created_at);
tvContent.setText(text); tvContent.setText(text);
} else { } else {
tvContent.setText(getString(R.string.messages, (int) e.getY()) + "\r\n" + xVals2.get((int) e.getX())); tvContent.setText(getString(R.string.messages, (int) e.getY()));
} }
} }

@ -22,11 +22,11 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -34,7 +34,6 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -96,6 +95,31 @@ public class AdminActionActivity extends BaseBarActivity {
binding.accounts.setOnClickListener(v -> displayTimeline(ACCOUNT)); binding.accounts.setOnClickListener(v -> displayTimeline(ACCOUNT));
binding.domains.setOnClickListener(v -> displayTimeline(DOMAIN)); binding.domains.setOnClickListener(v -> displayTimeline(DOMAIN));
getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (canGoBack) {
canGoBack = false;
ThemeHelper.slideViewsToRight(binding.fragmentContainer, binding.buttonContainer, () -> {
if (fragmentAdminReport != null) {
fragmentAdminReport.onDestroyView();
fragmentAdminReport = null;
}
if (fragmentAdminAccount != null) {
fragmentAdminAccount.onDestroyView();
fragmentAdminAccount = null;
}
if (fragmentAdminDomain != null) {
fragmentAdminDomain.onDestroyView();
fragmentAdminDomain = null;
}
setTitle(R.string.administration);
invalidateOptionsMenu();
});
}
}
});
} }
private void displayTimeline(AdminEnum type) { private void displayTimeline(AdminEnum type) {
@ -141,15 +165,9 @@ public class AdminActionActivity extends BaseBarActivity {
}); });
} }
switch (type) { switch (type) {
case REPORT: case REPORT -> setTitle(R.string.reports);
setTitle(R.string.reports); case ACCOUNT -> setTitle(R.string.accounts);
break; case DOMAIN -> setTitle(R.string.domains);
case ACCOUNT:
setTitle(R.string.accounts);
break;
case DOMAIN:
setTitle(R.string.domains);
break;
} }
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
@ -165,7 +183,7 @@ public class AdminActionActivity extends BaseBarActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) { if (item.getItemId() == android.R.id.home) {
onBackPressed(); getOnBackPressedDispatcher().onBackPressed();
return true; return true;
} else if (item.getItemId() == R.id.action_filter) { } else if (item.getItemId() == R.id.action_filter) {
if (getTitle().toString().equalsIgnoreCase(getString(R.string.accounts))) { if (getTitle().toString().equalsIgnoreCase(getString(R.string.accounts))) {
@ -326,31 +344,6 @@ public class AdminActionActivity extends BaseBarActivity {
} }
} }
@Override
public void onBackPressed() {
if (canGoBack) {
canGoBack = false;
ThemeHelper.slideViewsToRight(binding.fragmentContainer, binding.buttonContainer, () -> {
if (fragmentAdminReport != null) {
fragmentAdminReport.onDestroyView();
fragmentAdminReport = null;
}
if (fragmentAdminAccount != null) {
fragmentAdminAccount.onDestroyView();
fragmentAdminAccount = null;
}
if (fragmentAdminDomain != null) {
fragmentAdminDomain.onDestroyView();
fragmentAdminDomain = null;
}
setTitle(R.string.administration);
invalidateOptionsMenu();
});
} else {
super.onBackPressed();
}
}
public enum AdminEnum { public enum AdminEnum {
@SerializedName("REPORT") @SerializedName("REPORT")

@ -30,6 +30,8 @@ import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.Objects;
import app.fedilab.android.BuildConfig; import app.fedilab.android.BuildConfig;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity; import app.fedilab.android.activities.MainActivity;
@ -98,9 +100,9 @@ public class AdminDomainBlockActivity extends BaseBarActivity {
binding.rejectReports.setOnCheckedChangeListener((compoundButton, checked) -> adminDomainBlock.reject_reports = checked); binding.rejectReports.setOnCheckedChangeListener((compoundButton, checked) -> adminDomainBlock.reject_reports = checked);
adminVM = new ViewModelProvider(AdminDomainBlockActivity.this).get(AdminVM.class); adminVM = new ViewModelProvider(AdminDomainBlockActivity.this).get(AdminVM.class);
binding.saveChanges.setOnClickListener(v -> { binding.saveChanges.setOnClickListener(v -> {
adminDomainBlock.domain = binding.domain.getText().toString().trim(); adminDomainBlock.domain = Objects.requireNonNull(binding.domain.getText()).toString().trim();
adminDomainBlock.public_comment = binding.publicComment.getText().toString().trim(); adminDomainBlock.public_comment = Objects.requireNonNull(binding.publicComment.getText()).toString().trim();
adminDomainBlock.private_comment = binding.privateComment.getText().toString().trim(); adminDomainBlock.private_comment = Objects.requireNonNull(binding.privateComment.getText()).toString().trim();
adminVM.createOrUpdateDomainBlock(MainActivity.currentInstance, MainActivity.currentToken, adminDomainBlock) adminVM.createOrUpdateDomainBlock(MainActivity.currentInstance, MainActivity.currentToken, adminDomainBlock)
.observe(AdminDomainBlockActivity.this, adminDomainBlockResult -> { .observe(AdminDomainBlockActivity.this, adminDomainBlockResult -> {
if (adminDomainBlockResult != null) { if (adminDomainBlockResult != null) {

@ -248,9 +248,6 @@ public class AdminReportActivity extends BaseBarActivity {
}); });
//Retrieve relationship with the connected account
List<String> accountListToCheck = new ArrayList<>();
accountListToCheck.add(account.id);
//Animate emojis //Animate emojis
if (account.emojis != null && account.emojis.size() > 0) { if (account.emojis != null && account.emojis.size() > 0) {
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false); boolean disableAnimatedEmoji = sharedpreferences.getBoolean(getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false);

Loading…
Cancel
Save