Still cleaning
This commit is contained in:
parent
84e832e19c
commit
a1121fc6ce
|
@ -14,7 +14,6 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package app.fedilab.android.activities;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -39,6 +38,8 @@ import androidx.viewpager.widget.ViewPager;
|
|||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import app.fedilab.android.fragments.DisplayAdminAccountsFragment;
|
||||
|
@ -63,7 +64,6 @@ public class AdminActivity extends BaseActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
|
||||
setTheme(R.style.AppAdminTheme);
|
||||
|
||||
|
@ -79,12 +79,7 @@ public class AdminActivity extends BaseActivity {
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
toolbar_title.setText(String.format(getString(R.string.administration) + " %s", Helper.getLiveInstance(getApplicationContext())));
|
||||
}
|
||||
setContentView(R.layout.activity_admin);
|
||||
|
@ -99,76 +94,165 @@ public class AdminActivity extends BaseActivity {
|
|||
|
||||
|
||||
final LinearLayout tabStrip = (LinearLayout) admin_tablayout.getChildAt(0);
|
||||
tabStrip.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
PopupMenu popup = new PopupMenu(AdminActivity.this, tabStrip.getChildAt(0));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_admin_reports, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemUnresolved = menu.findItem(R.id.action_unresolved_reports);
|
||||
tabStrip.getChildAt(0).setOnLongClickListener(v -> {
|
||||
PopupMenu popup = new PopupMenu(AdminActivity.this, tabStrip.getChildAt(0));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_admin_reports, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemUnresolved = menu.findItem(R.id.action_unresolved_reports);
|
||||
|
||||
|
||||
itemUnresolved.setChecked(unresolved);
|
||||
itemUnresolved.setChecked(unresolved);
|
||||
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
popup.setOnDismissListener(menu12 -> {
|
||||
FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(displayAdminReportsFragment);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("unresolved", unresolved);
|
||||
displayAdminReportsFragment.setArguments(bundle);
|
||||
fragTransaction.attach(displayAdminReportsFragment);
|
||||
fragTransaction.commit();
|
||||
});
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(displayAdminReportsFragment);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("unresolved", unresolved);
|
||||
displayAdminReportsFragment.setArguments(bundle);
|
||||
fragTransaction.attach(displayAdminReportsFragment);
|
||||
fragTransaction.commit();
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (item.getItemId() == R.id.action_unresolved_reports) {
|
||||
unresolved = !unresolved;
|
||||
}
|
||||
itemUnresolved.setChecked(unresolved);
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
return true;
|
||||
}
|
||||
if (item.getItemId() == R.id.action_unresolved_reports) {
|
||||
unresolved = !unresolved;
|
||||
}
|
||||
itemUnresolved.setChecked(unresolved);
|
||||
return false;
|
||||
});
|
||||
popup.show();
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
tabStrip.getChildAt(1).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
PopupMenu popup = new PopupMenu(AdminActivity.this, tabStrip.getChildAt(1));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_admin_accounts, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemLocal = menu.findItem(R.id.action_local);
|
||||
final MenuItem itemRemote = menu.findItem(R.id.action_remote);
|
||||
final MenuItem itemActive = menu.findItem(R.id.action_active);
|
||||
final MenuItem itemPending = menu.findItem(R.id.action_pending);
|
||||
final MenuItem itemDisabled = menu.findItem(R.id.action_disabled);
|
||||
final MenuItem itemSilenced = menu.findItem(R.id.action_silenced);
|
||||
final MenuItem itemSuspended = menu.findItem(R.id.action_suspended);
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
itemSilenced.setVisible(false);
|
||||
itemPending.setVisible(false);
|
||||
itemSuspended.setVisible(false);
|
||||
tabStrip.getChildAt(1).setOnLongClickListener(v -> {
|
||||
PopupMenu popup = new PopupMenu(AdminActivity.this, tabStrip.getChildAt(1));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_admin_accounts, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemLocal = menu.findItem(R.id.action_local);
|
||||
final MenuItem itemRemote = menu.findItem(R.id.action_remote);
|
||||
final MenuItem itemActive = menu.findItem(R.id.action_active);
|
||||
final MenuItem itemPending = menu.findItem(R.id.action_pending);
|
||||
final MenuItem itemDisabled = menu.findItem(R.id.action_disabled);
|
||||
final MenuItem itemSilenced = menu.findItem(R.id.action_silenced);
|
||||
final MenuItem itemSuspended = menu.findItem(R.id.action_suspended);
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
itemSilenced.setVisible(false);
|
||||
itemPending.setVisible(false);
|
||||
itemSuspended.setVisible(false);
|
||||
}
|
||||
|
||||
itemLocal.setChecked(local);
|
||||
itemRemote.setChecked(remote);
|
||||
itemActive.setChecked(active);
|
||||
itemPending.setChecked(pending);
|
||||
itemDisabled.setChecked(disabled);
|
||||
itemSilenced.setChecked(silenced);
|
||||
itemSuspended.setChecked(suspended);
|
||||
|
||||
popup.setOnDismissListener(menu1 -> {
|
||||
FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(displayAdminAccountsFragment);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("local", local);
|
||||
bundle.putBoolean("remote", remote);
|
||||
bundle.putBoolean("active", active);
|
||||
bundle.putBoolean("pending", pending);
|
||||
bundle.putBoolean("disabled", disabled);
|
||||
bundle.putBoolean("silenced", silenced);
|
||||
bundle.putBoolean("suspended", suspended);
|
||||
displayAdminAccountsFragment.setArguments(bundle);
|
||||
fragTransaction.attach(displayAdminAccountsFragment);
|
||||
fragTransaction.commit();
|
||||
|
||||
});
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_local:
|
||||
if (!local) {
|
||||
remote = false;
|
||||
local = true;
|
||||
}
|
||||
break;
|
||||
case R.id.action_remote:
|
||||
if (!remote) {
|
||||
remote = true;
|
||||
local = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_active:
|
||||
if (!active) {
|
||||
active = true;
|
||||
pending = false;
|
||||
disabled = false;
|
||||
silenced = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_pending:
|
||||
if (!pending) {
|
||||
pending = true;
|
||||
active = false;
|
||||
disabled = false;
|
||||
silenced = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_disabled:
|
||||
if (!disabled) {
|
||||
disabled = true;
|
||||
active = false;
|
||||
pending = false;
|
||||
silenced = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_silenced:
|
||||
if (!silenced) {
|
||||
silenced = true;
|
||||
active = false;
|
||||
pending = false;
|
||||
disabled = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_suspended:
|
||||
if (!suspended) {
|
||||
suspended = true;
|
||||
active = false;
|
||||
pending = false;
|
||||
disabled = false;
|
||||
silenced = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
itemLocal.setChecked(local);
|
||||
|
@ -178,115 +262,10 @@ public class AdminActivity extends BaseActivity {
|
|||
itemDisabled.setChecked(disabled);
|
||||
itemSilenced.setChecked(silenced);
|
||||
itemSuspended.setChecked(suspended);
|
||||
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(displayAdminAccountsFragment);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("local", local);
|
||||
bundle.putBoolean("remote", remote);
|
||||
bundle.putBoolean("active", active);
|
||||
bundle.putBoolean("pending", pending);
|
||||
bundle.putBoolean("disabled", disabled);
|
||||
bundle.putBoolean("silenced", silenced);
|
||||
bundle.putBoolean("suspended", suspended);
|
||||
displayAdminAccountsFragment.setArguments(bundle);
|
||||
fragTransaction.attach(displayAdminAccountsFragment);
|
||||
fragTransaction.commit();
|
||||
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_local:
|
||||
if (!local) {
|
||||
remote = false;
|
||||
local = true;
|
||||
}
|
||||
break;
|
||||
case R.id.action_remote:
|
||||
if (!remote) {
|
||||
remote = true;
|
||||
local = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_active:
|
||||
if (!active) {
|
||||
active = true;
|
||||
pending = false;
|
||||
disabled = false;
|
||||
silenced = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_pending:
|
||||
if (!pending) {
|
||||
pending = true;
|
||||
active = false;
|
||||
disabled = false;
|
||||
silenced = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_disabled:
|
||||
if (!disabled) {
|
||||
disabled = true;
|
||||
active = false;
|
||||
pending = false;
|
||||
silenced = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_silenced:
|
||||
if (!silenced) {
|
||||
silenced = true;
|
||||
active = false;
|
||||
pending = false;
|
||||
disabled = false;
|
||||
suspended = false;
|
||||
}
|
||||
break;
|
||||
case R.id.action_suspended:
|
||||
if (!suspended) {
|
||||
suspended = true;
|
||||
active = false;
|
||||
pending = false;
|
||||
disabled = false;
|
||||
silenced = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
itemLocal.setChecked(local);
|
||||
itemRemote.setChecked(remote);
|
||||
itemActive.setChecked(active);
|
||||
itemPending.setChecked(pending);
|
||||
itemDisabled.setChecked(disabled);
|
||||
itemSilenced.setChecked(silenced);
|
||||
itemSuspended.setChecked(suspended);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
popup.show();
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
|
@ -334,33 +313,31 @@ public class AdminActivity extends BaseActivity {
|
|||
private class AdminPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
AdminPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
switch (position) {
|
||||
case 0:
|
||||
displayAdminReportsFragment = new DisplayAdminReportsFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean("unresolved", unresolved);
|
||||
displayAdminReportsFragment.setArguments(bundle);
|
||||
return displayAdminReportsFragment;
|
||||
case 1:
|
||||
displayAdminAccountsFragment = new DisplayAdminAccountsFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean("local", local);
|
||||
bundle.putBoolean("remote", remote);
|
||||
bundle.putBoolean("active", active);
|
||||
bundle.putBoolean("pending", pending);
|
||||
bundle.putBoolean("disabled", disabled);
|
||||
bundle.putBoolean("silenced", silenced);
|
||||
bundle.putBoolean("suspended", suspended);
|
||||
displayAdminAccountsFragment.setArguments(bundle);
|
||||
return displayAdminAccountsFragment;
|
||||
Bundle bundle;
|
||||
if (position == 0) {
|
||||
displayAdminReportsFragment = new DisplayAdminReportsFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean("unresolved", unresolved);
|
||||
displayAdminReportsFragment.setArguments(bundle);
|
||||
return displayAdminReportsFragment;
|
||||
}
|
||||
return null;
|
||||
displayAdminAccountsFragment = new DisplayAdminAccountsFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean("local", local);
|
||||
bundle.putBoolean("remote", remote);
|
||||
bundle.putBoolean("active", active);
|
||||
bundle.putBoolean("pending", pending);
|
||||
bundle.putBoolean("disabled", disabled);
|
||||
bundle.putBoolean("silenced", silenced);
|
||||
bundle.putBoolean("suspended", suspended);
|
||||
displayAdminAccountsFragment.setArguments(bundle);
|
||||
return displayAdminAccountsFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -72,9 +72,6 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
case Helper.THEME_LIGHT:
|
||||
setTheme(R.style.AppTheme_Fedilab);
|
||||
break;
|
||||
case Helper.THEME_DARK:
|
||||
setTheme(R.style.AppThemeDark);
|
||||
break;
|
||||
case Helper.THEME_BLACK:
|
||||
setTheme(R.style.AppThemeBlack);
|
||||
break;
|
||||
|
@ -113,12 +110,7 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
toolbar_title.setText(search);
|
||||
}
|
||||
setTitle(search);
|
||||
|
@ -198,9 +190,10 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -223,7 +216,7 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
bundle.putSerializable("tag", search);
|
||||
displayStatusFragment.setArguments(bundle);
|
||||
return displayStatusFragment;
|
||||
case 3:
|
||||
default:
|
||||
displayStatusFragment = new DisplayStatusFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.SEARCH);
|
||||
|
@ -231,7 +224,6 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
displayStatusFragment.setArguments(bundle);
|
||||
return displayStatusFragment;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ package app.fedilab.android.activities;
|
|||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
@ -87,16 +86,13 @@ public class SettingsActivity extends BaseActivity {
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (needRestart) {
|
||||
showDialog();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
toolbar_close.setOnClickListener(v -> {
|
||||
if (needRestart) {
|
||||
showDialog();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
});
|
||||
toolbar_title.setText(R.string.settings);
|
||||
}
|
||||
|
@ -161,24 +157,16 @@ public class SettingsActivity extends BaseActivity {
|
|||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this);
|
||||
dialogBuilder.setMessage(R.string.restart_message);
|
||||
dialogBuilder.setTitle(R.string.apply_changes);
|
||||
dialogBuilder.setPositiveButton(R.string.restart, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Intent mStartActivity = new Intent(getApplicationContext(), MainActivity.class);
|
||||
int mPendingIntentId = 123456;
|
||||
PendingIntent mPendingIntent = PendingIntent.getActivity(getApplicationContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
assert mgr != null;
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
dialogBuilder.setPositiveButton(R.string.restart, (dialog, id) -> {
|
||||
Intent mStartActivity = new Intent(getApplicationContext(), MainActivity.class);
|
||||
int mPendingIntentId = 123456;
|
||||
PendingIntent mPendingIntent = PendingIntent.getActivity(getApplicationContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
assert mgr != null;
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
System.exit(0);
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.no, (dialog, id) -> dialog.dismiss());
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
|
@ -195,10 +183,10 @@ public class SettingsActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
private static class SettingsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
SettingsPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -1487,7 +1487,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -146,62 +146,51 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
ImageView media_save = getSupportActionBar().getCustomView().findViewById(R.id.media_save);
|
||||
ImageView media_share = getSupportActionBar().getCustomView().findViewById(R.id.media_share);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
media_save.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int position = mPager.getCurrentItem();
|
||||
Attachment attachment = attachments.get(position);
|
||||
if( attachment.getType().compareTo("image") == 0 ){
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), false);
|
||||
}
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
media_save.setOnClickListener(view12 -> {
|
||||
int position = mPager.getCurrentItem();
|
||||
Attachment attachment = attachments.get(position);
|
||||
if( attachment.getType().compareTo("image") == 0 ){
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), false);
|
||||
}
|
||||
}else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
downloadID = -1;
|
||||
}
|
||||
} else {
|
||||
Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), false);
|
||||
}
|
||||
}else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
downloadID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
media_share.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int position = mPager.getCurrentItem();
|
||||
Attachment attachment = attachments.get(position);
|
||||
if( attachment.getType().compareTo("image") == 0 ){
|
||||
Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), true);
|
||||
}else if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio") || attachment.getType().toLowerCase().equals("gifv")) {
|
||||
downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
}
|
||||
Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
downloadID = -1;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
media_share.setOnClickListener(view1 -> {
|
||||
int position = mPager.getCurrentItem();
|
||||
Attachment attachment = attachments.get(position);
|
||||
if( attachment.getType().compareTo("image") == 0 ){
|
||||
Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), true);
|
||||
}else if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio") || attachment.getType().toLowerCase().equals("gifv")) {
|
||||
downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
}
|
||||
} else {
|
||||
downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -227,12 +216,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
media_description.setText(description);
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
media_description.setVisibility(View.GONE);
|
||||
}
|
||||
}, med_desc_timeout);
|
||||
handler.postDelayed(() -> media_description.setVisibility(View.GONE), med_desc_timeout);
|
||||
|
||||
} else {
|
||||
media_description.setVisibility(View.GONE);
|
||||
|
@ -254,12 +238,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
media_description.setText(description);
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
media_description.setVisibility(View.GONE);
|
||||
}
|
||||
}, med_desc_timeout);
|
||||
handler.postDelayed(() -> media_description.setVisibility(View.GONE), med_desc_timeout);
|
||||
|
||||
} else {
|
||||
media_description.setVisibility(View.GONE);
|
||||
|
@ -316,12 +295,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
media_description.setText(description);
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
media_description.setVisibility(View.GONE);
|
||||
}
|
||||
}, med_desc_timeout);
|
||||
handler.postDelayed(() -> media_description.setVisibility(View.GONE), med_desc_timeout);
|
||||
|
||||
} else {
|
||||
media_description.setVisibility(View.GONE);
|
||||
|
@ -435,7 +409,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -29,6 +29,8 @@ import androidx.viewpager.widget.ViewPager;
|
|||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
|
@ -134,27 +136,26 @@ public class TootInfoActivity extends BaseActivity {
|
|||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
switch (position) {
|
||||
case 0:
|
||||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.REBLOGGED);
|
||||
bundle.putString("targetedid", toot_id);
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
case 1:
|
||||
displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FAVOURITED);
|
||||
bundle.putString("targetedid", toot_id);
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
if (position == 0) {
|
||||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.REBLOGGED);
|
||||
bundle.putString("targetedid", toot_id);
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
}
|
||||
return null;
|
||||
DisplayAccountsFragment displayAccountsFragment;
|
||||
displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FAVOURITED);
|
||||
bundle.putString("targetedid", toot_id);
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public class TabLayoutNotificationsFragment extends Fragment {
|
|||
int mNumOfTabs;
|
||||
|
||||
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
this.mNumOfTabs = NumOfTabs;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TabLayoutScheduleFragment extends Fragment {
|
|||
int mNumOfTabs;
|
||||
|
||||
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
this.mNumOfTabs = NumOfTabs;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TabLayoutTootsFragment extends Fragment {
|
|||
int mNumOfTabs;
|
||||
|
||||
private PagerAdapter(FragmentManager fm, int NumOfTabs) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
this.mNumOfTabs = NumOfTabs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue