Add in settings
This commit is contained in:
parent
bd721b5044
commit
3ebd97e3bc
|
@ -16,6 +16,9 @@ package app.fedilab.android.activities;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
@ -147,8 +150,30 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
|
|||
|
||||
@Override
|
||||
public void onAdminAction(APIResponse apiResponse) {
|
||||
if( apiResponse == null || apiResponse.getError() != null){
|
||||
Toasty.error(getApplicationContext(), getString(R.string.toast_error),Toast.LENGTH_LONG).show();
|
||||
if( apiResponse.getError() != null){
|
||||
if( apiResponse.getError().getStatusCode() == 403){
|
||||
AlertDialog.Builder builderInner;
|
||||
builderInner = new AlertDialog.Builder(AccountReportActivity.this, R.style.AdminDialog);
|
||||
builderInner.setTitle(R.string.reconnect_account);
|
||||
builderInner.setMessage(R.string.reconnect_account_message);
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
Intent intent = new Intent(AccountReportActivity.this, LoginActivity.class);
|
||||
intent.putExtra("admin", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
}else{
|
||||
Toasty.error(AccountReportActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if( apiResponse.getAccountAdmins() != null && apiResponse.getAccountAdmins().size() > 0) {
|
||||
|
|
|
@ -1085,7 +1085,20 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
partnerShipItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||
MenuItem adminItem = navigationView.getMenu().findItem(R.id.nav_administration);
|
||||
if( adminItem != null){
|
||||
adminItem.setVisible(false);
|
||||
}
|
||||
}else{
|
||||
boolean display_admin_menu = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userId + instance, false);
|
||||
if( !display_admin_menu){
|
||||
MenuItem adminItem = navigationView.getMenu().findItem(R.id.nav_administration);
|
||||
if( adminItem != null){
|
||||
adminItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
LinearLayout owner_container = headerLayout.findViewById(R.id.main_header_container);
|
||||
owner_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -97,6 +97,7 @@ import java.util.List;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.fedilab.android.activities.AccountReportActivity;
|
||||
import app.fedilab.android.client.API;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Account;
|
||||
|
@ -2361,7 +2362,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
popup.getMenu().findItem(R.id.action_schedule_boost).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
|
||||
}
|
||||
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||
popup.getMenu().findItem(R.id.action_admin).setVisible(false);
|
||||
}else{
|
||||
boolean display_admin_statuses = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_STATUSES + userId + Helper.getLiveInstance(context), false);
|
||||
if( !display_admin_statuses){
|
||||
popup.getMenu().findItem(R.id.action_admin).setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean custom_sharing = sharedpreferences.getBoolean(Helper.SET_CUSTOM_SHARING, false);
|
||||
if( custom_sharing && status.getVisibility().equals("public"))
|
||||
|
@ -2393,7 +2401,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
break;
|
||||
case R.id.action_schedule_boost:
|
||||
scheduleBoost(status);
|
||||
|
||||
return true;
|
||||
case R.id.action_admin:
|
||||
String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
|
||||
Intent intent = new Intent(context, AccountReportActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("account_id", account_id);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_info:
|
||||
tootInformation(status);
|
||||
|
|
|
@ -342,6 +342,41 @@ public class SettingsFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
|
||||
boolean display_admin_menu = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userId + instance, false);
|
||||
|
||||
final CheckBox set_display_admin_menu = rootView.findViewById(R.id.set_display_admin_menu);
|
||||
set_display_admin_menu.setChecked(display_admin_menu);
|
||||
set_display_admin_menu.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userId + instance, set_display_admin_menu.isChecked());
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
boolean display_admin_statuses = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_STATUSES + userId + instance, false);
|
||||
|
||||
final CheckBox set_display_admin_statuses = rootView.findViewById(R.id.set_display_admin_statuses);
|
||||
set_display_admin_statuses.setChecked(display_admin_statuses);
|
||||
set_display_admin_statuses.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_DISPLAY_ADMIN_STATUSES + userId + instance, set_display_admin_statuses.isChecked());
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||
LinearLayout admin_container = rootView.findViewById(R.id.admin_container);
|
||||
if( admin_container != null){
|
||||
admin_container.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
boolean show_media_urls = sharedpreferences.getBoolean(Helper.SET_MEDIA_URLS, false);
|
||||
final CheckBox set_auto_add_media_url = rootView.findViewById(R.id.set_auto_add_media_url);
|
||||
|
@ -1022,8 +1057,7 @@ public class SettingsFragment extends Fragment {
|
|||
|
||||
LinearLayout toot_visibility_container = rootView.findViewById(R.id.toot_visibility_container);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||
|
||||
final Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
final ImageView set_toot_visibility = rootView.findViewById(R.id.set_toot_visibility);
|
||||
if( theme == Helper.THEME_DARK){
|
||||
|
|
|
@ -349,6 +349,9 @@ public class Helper {
|
|||
public static final String SET_DISPLAY_TIMELINE_IN_LIST = "set_display_timeline_in_list";
|
||||
public static final String SET_ONION_SCHEME = "set_onion_scheme";
|
||||
public static final String SET_REMEMBER_POSITION_HOME = "set_remember_position";
|
||||
public static final String SET_DISPLAY_ADMIN_MENU = "set_display_admin_menu";
|
||||
public static final String SET_DISPLAY_ADMIN_STATUSES = "set_display_admin_statuses";
|
||||
|
||||
public static final int S_NO = 0;
|
||||
static final int S_512KO = 1;
|
||||
public static final int S_1MO = 2;
|
||||
|
|
|
@ -155,6 +155,54 @@
|
|||
android:text="@string/set_display_news_from_fedilab"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/admin_container">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?colorAccent" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/administration"
|
||||
android:textColor="?colorAccent"
|
||||
android:textSize="16sp" />
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?colorAccent" />
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_display_admin_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_display_admin_menu"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_display_admin_statuses"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_display_admin_toot"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -158,6 +158,59 @@
|
|||
android:text="@string/set_display_news_from_fedilab"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/admin_container">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?colorAccent" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/administration"
|
||||
android:textColor="?colorAccent"
|
||||
android:textSize="16sp" />
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?colorAccent" />
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_display_admin_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_display_admin_menu"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_display_admin_statuses"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_display_admin_toot"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
android:title="@string/bookmark_add"
|
||||
android:actionLayout="@layout/bookmark_layout"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_admin"
|
||||
android:title="@string/administration"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_info"
|
||||
android:title="@string/information"
|
||||
|
|
|
@ -1070,6 +1070,8 @@
|
|||
<string name="account_disabled">The account is disabled!</string>
|
||||
<string name="account_undisabled">The account is no longer disabled!</string>
|
||||
<string name="account_warned">The account has been warned!</string>
|
||||
<string name="set_display_admin_menu">Display the admin menu</string>
|
||||
<string name="set_display_admin_toot">Display the admin feature in statuses</string>
|
||||
<plurals name="number_of_vote">
|
||||
<item quantity="one">%d vote</item>
|
||||
<item quantity="other">%d votes</item>
|
||||
|
|
Loading…
Reference in New Issue