Some cleaning

This commit is contained in:
stom79 2017-10-28 11:02:37 +02:00
parent b5e59398a2
commit 10bd9cc499
9 changed files with 64 additions and 72 deletions

View File

@ -218,9 +218,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
swiped = false;
}
if( accounts != null && accounts.size() > 0) {
for(Account tmpAccount: accounts){
this.accounts.add(tmpAccount);
}
this.accounts.addAll(accounts);
accountsListAdapter.notifyDataSetChanged();
}
swipeRefreshLayout.setRefreshing(false);

View File

@ -47,10 +47,10 @@ public class DisplayDraftsFragment extends Fragment {
View rootView = inflater.inflate(R.layout.fragment_drafts, container, false);
context = getContext();
ListView lv_draft_toots = (ListView) rootView.findViewById(R.id.lv_draft_toots);
ListView lv_draft_toots = rootView.findViewById(R.id.lv_draft_toots);
RelativeLayout mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
RelativeLayout textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
RelativeLayout mainLoader = rootView.findViewById(R.id.loader);
RelativeLayout textviewNoAction = rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();

View File

@ -72,14 +72,14 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr
flag_loading = true;
swiped = false;
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer);
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
accountPerPage = sharedpreferences.getInt(Helper.SET_ACCOUNTS_PER_PAGE, 40);
lv_accounts = (ListView) rootView.findViewById(R.id.lv_accounts);
no_action_text = (TextView) rootView.findViewById(R.id.no_action_text);
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
nextElementLoader = (RelativeLayout) rootView.findViewById(R.id.loading_next_accounts);
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
lv_accounts = rootView.findViewById(R.id.lv_accounts);
no_action_text = rootView.findViewById(R.id.no_action_text);
mainLoader = rootView.findViewById(R.id.loader);
nextElementLoader = rootView.findViewById(R.id.loading_next_accounts);
textviewNoAction = rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
accountsFollowRequestAdapter = new AccountsFollowRequestAdapter(context, this.accounts);
@ -116,7 +116,6 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr
asyncTask = new RetrieveFollowRequestSentAsyncTask(context, max_id, DisplayFollowRequestSentFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
swipeRefreshLayout.setColorSchemeResources(R.color.mastodonC4,
R.color.mastodonC2,
R.color.mastodonC3);
@ -177,9 +176,7 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr
swiped = false;
}
if( accounts != null && accounts.size() > 0) {
for(Account tmpAccount: accounts){
this.accounts.add(tmpAccount);
}
this.accounts.addAll(accounts);
accountsFollowRequestAdapter.notifyDataSetChanged();
}
swipeRefreshLayout.setRefreshing(false);

View File

@ -65,11 +65,11 @@ public class DisplayScheduledTootsFragment extends Fragment implements OnRetriev
View rootView = inflater.inflate(R.layout.fragment_scheduled_toots, container, false);
context = getContext();
lv_scheduled_toots = (ListView) rootView.findViewById(R.id.lv_scheduled_toots);
lv_scheduled_toots = rootView.findViewById(R.id.lv_scheduled_toots);
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
warning_battery_message = (TextView) rootView.findViewById(R.id.warning_battery_message);
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
mainLoader = rootView.findViewById(R.id.loader);
warning_battery_message = rootView.findViewById(R.id.warning_battery_message);
textviewNoAction = rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
//Removes all scheduled toots that have sent
@ -90,7 +90,7 @@ public class DisplayScheduledTootsFragment extends Fragment implements OnRetriev
//Battery saver is one and user never asked to stop showing the message
changeDrawableColor(context, R.drawable.ic_action_warning, R.color.mastodonC4);
changeDrawableColor(context, R.drawable.ic_cancel, R.color.mastodonC4);
if( powerManager.isPowerSaveMode() && sharedpreferences.getBoolean(Helper.SHOW_BATTERY_SAVER_MESSAGE,true)){
if( powerManager != null && powerManager.isPowerSaveMode() && sharedpreferences.getBoolean(Helper.SHOW_BATTERY_SAVER_MESSAGE,true)){
warning_battery_message.setVisibility(View.VISIBLE);
}else {
warning_battery_message.setVisibility(View.GONE);

View File

@ -24,7 +24,6 @@ import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View File

@ -69,7 +69,6 @@ public class SettingsFragment extends Fragment {
private Context context;
private static final int ACTIVITY_CHOOSE_FILE = 411;
private TextView set_folder;
int count = 0;
int count2 = 0;
@Override
@ -83,7 +82,7 @@ public class SettingsFragment extends Fragment {
boolean auto_store = sharedpreferences.getBoolean(Helper.SET_AUTO_STORE, true);
final CheckBox set_auto_store = (CheckBox) rootView.findViewById(R.id.set_auto_store);
final CheckBox set_auto_store = rootView.findViewById(R.id.set_auto_store);
set_auto_store.setChecked(auto_store);
set_auto_store.setOnClickListener(new View.OnClickListener() {
@Override
@ -97,7 +96,7 @@ public class SettingsFragment extends Fragment {
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
final CheckBox set_show_error_messages = (CheckBox) rootView.findViewById(R.id.set_show_error_messages);
final CheckBox set_show_error_messages = rootView.findViewById(R.id.set_show_error_messages);
set_show_error_messages.setChecked(show_error_messages);
set_show_error_messages.setOnClickListener(new View.OnClickListener() {
@ -110,7 +109,7 @@ public class SettingsFragment extends Fragment {
});
boolean show_media_urls = sharedpreferences.getBoolean(Helper.SET_MEDIA_URLS, true);
final CheckBox set_auto_add_media_url = (CheckBox) rootView.findViewById(R.id.set_auto_add_media_url);
final CheckBox set_auto_add_media_url = rootView.findViewById(R.id.set_auto_add_media_url);
set_auto_add_media_url.setChecked(show_media_urls);
set_auto_add_media_url.setOnClickListener(new View.OnClickListener() {
@ -123,9 +122,9 @@ public class SettingsFragment extends Fragment {
});
boolean preview_reply = sharedpreferences.getBoolean(Helper.SET_PREVIEW_REPLIES, false);
final CheckBox set_preview_reply = (CheckBox) rootView.findViewById(R.id.set_preview_reply);
final LinearLayout set_preview_reply_pp_container = (LinearLayout) rootView.findViewById(R.id.set_preview_reply_pp_container);
final SwitchCompat set_preview_reply_pp = (SwitchCompat) rootView.findViewById(R.id.set_preview_reply_pp);
final CheckBox set_preview_reply = rootView.findViewById(R.id.set_preview_reply);
final LinearLayout set_preview_reply_pp_container = rootView.findViewById(R.id.set_preview_reply_pp_container);
final SwitchCompat set_preview_reply_pp = rootView.findViewById(R.id.set_preview_reply_pp);
set_preview_reply.setChecked(preview_reply);
set_preview_reply.setOnClickListener(new View.OnClickListener() {
@ -159,7 +158,7 @@ public class SettingsFragment extends Fragment {
});
boolean notif_validation = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, true);
final CheckBox set_share_validation = (CheckBox) rootView.findViewById(R.id.set_share_validation);
final CheckBox set_share_validation = rootView.findViewById(R.id.set_share_validation);
set_share_validation.setChecked(notif_validation);
set_share_validation.setOnClickListener(new View.OnClickListener() {
@ -172,7 +171,7 @@ public class SettingsFragment extends Fragment {
});
boolean notif_validation_fav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false);
final CheckBox set_share_validation_fav = (CheckBox) rootView.findViewById(R.id.set_share_validation_fav);
final CheckBox set_share_validation_fav = rootView.findViewById(R.id.set_share_validation_fav);
set_share_validation_fav.setChecked(notif_validation_fav);
set_share_validation_fav.setOnClickListener(new View.OnClickListener() {
@ -186,7 +185,7 @@ public class SettingsFragment extends Fragment {
boolean multiaccount_actions = sharedpreferences.getBoolean(Helper.SET_ALLOW_CROSS_ACTIONS, true);
final CheckBox set_multiaccount_actions = (CheckBox) rootView.findViewById(R.id.set_multiaccount_actions);
final CheckBox set_multiaccount_actions = rootView.findViewById(R.id.set_multiaccount_actions);
set_multiaccount_actions.setChecked(multiaccount_actions);
set_multiaccount_actions.setOnClickListener(new View.OnClickListener() {
@ -199,7 +198,7 @@ public class SettingsFragment extends Fragment {
});
boolean display_local = sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true);
final CheckBox set_display_local = (CheckBox) rootView.findViewById(R.id.set_display_local);
final CheckBox set_display_local = rootView.findViewById(R.id.set_display_local);
set_display_local.setChecked(display_local);
set_display_local.setOnClickListener(new View.OnClickListener() {
@ -217,7 +216,7 @@ public class SettingsFragment extends Fragment {
boolean display_global = sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true);
final CheckBox set_display_global = (CheckBox) rootView.findViewById(R.id.set_display_global);
final CheckBox set_display_global = rootView.findViewById(R.id.set_display_global);
set_display_global.setChecked(display_global);
set_display_global.setOnClickListener(new View.OnClickListener() {
@ -233,9 +232,9 @@ public class SettingsFragment extends Fragment {
}
});
final CheckBox set_embedded_browser = (CheckBox) rootView.findViewById(R.id.set_embedded_browser);
final LinearLayout set_javascript_container = (LinearLayout) rootView.findViewById(R.id.set_javascript_container);
final SwitchCompat set_javascript = (SwitchCompat) rootView.findViewById(R.id.set_javascript);
final CheckBox set_embedded_browser = rootView.findViewById(R.id.set_embedded_browser);
final LinearLayout set_javascript_container = rootView.findViewById(R.id.set_javascript_container);
final SwitchCompat set_javascript = rootView.findViewById(R.id.set_javascript);
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
if( !embedded_browser){
@ -268,8 +267,8 @@ public class SettingsFragment extends Fragment {
}
});
final LinearLayout set_cookies_container = (LinearLayout) rootView.findViewById(R.id.set_cookies_container);
final SwitchCompat set_cookies = (SwitchCompat) rootView.findViewById(R.id.set_cookies);
final LinearLayout set_cookies_container = rootView.findViewById(R.id.set_cookies_container);
final SwitchCompat set_cookies = rootView.findViewById(R.id.set_cookies);
boolean cookies = sharedpreferences.getBoolean(Helper.SET_COOKIES, false);
set_cookies.setChecked(cookies);
@ -288,7 +287,7 @@ public class SettingsFragment extends Fragment {
}
final String targeted_folder = sharedpreferences.getString(Helper.SET_FOLDER_RECORD, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
set_folder = (TextView) rootView.findViewById(R.id.set_folder);
set_folder = rootView.findViewById(R.id.set_folder);
set_folder.setText(targeted_folder);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
set_folder.setOnClickListener(new View.OnClickListener() {
@ -300,11 +299,11 @@ public class SettingsFragment extends Fragment {
}
});
}else {
LinearLayout file_chooser = (LinearLayout) rootView.findViewById(R.id.file_chooser);
LinearLayout file_chooser = rootView.findViewById(R.id.file_chooser);
file_chooser.setVisibility(View.GONE);
}
final SwitchCompat set_night_mode = (SwitchCompat) rootView.findViewById(R.id.set_night_mode);
final SwitchCompat set_night_mode = rootView.findViewById(R.id.set_night_mode);
set_night_mode.setChecked(theme == Helper.THEME_DARK);
set_night_mode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -326,8 +325,8 @@ public class SettingsFragment extends Fragment {
});
// NSFW Timeout
SeekBar nsfwTimeoutSeekBar = (SeekBar) rootView.findViewById(R.id.set_nsfw_timeout);
final TextView set_nsfw_timeout_value = (TextView) rootView.findViewById(R.id.set_nsfw_timeout_value);
SeekBar nsfwTimeoutSeekBar = rootView.findViewById(R.id.set_nsfw_timeout);
final TextView set_nsfw_timeout_value = rootView.findViewById(R.id.set_nsfw_timeout_value);
nsfwTimeoutSeekBar.setMax(30);
@ -354,11 +353,11 @@ public class SettingsFragment extends Fragment {
LinearLayout toot_visibility_container = (LinearLayout) rootView.findViewById(R.id.toot_visibility_container);
LinearLayout toot_visibility_container = rootView.findViewById(R.id.toot_visibility_container);
String prefKeyOauthTokenT = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
final Account account = new AccountDAO(context, db).getAccountByToken(prefKeyOauthTokenT);
final ImageView set_toot_visibility = (ImageView) rootView.findViewById(R.id.set_toot_visibility);
final ImageView set_toot_visibility = rootView.findViewById(R.id.set_toot_visibility);
//Only displayed for non locked accounts
if (account != null && !account.isLocked()) {
String tootVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), "public");
@ -435,7 +434,7 @@ public class SettingsFragment extends Fragment {
});
final Spinner translation_layout_spinner = (Spinner) rootView.findViewById(R.id.translation_layout_spinner);
final Spinner translation_layout_spinner = rootView.findViewById(R.id.translation_layout_spinner);
ArrayAdapter<CharSequence> adapterTrans = ArrayAdapter.createFromResource(getActivity(),
R.array.settings_translation, android.R.layout.simple_spinner_item);
translation_layout_spinner.setAdapter(adapterTrans);
@ -460,7 +459,7 @@ public class SettingsFragment extends Fragment {
});
boolean trans_forced = sharedpreferences.getBoolean(Helper.SET_TRANS_FORCED, false);
final CheckBox set_trans_forced = (CheckBox) rootView.findViewById(R.id.set_trans_forced);
final CheckBox set_trans_forced = rootView.findViewById(R.id.set_trans_forced);
set_trans_forced.setChecked(trans_forced);
set_trans_forced.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -20,7 +20,6 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
@ -72,9 +71,9 @@ public class SettingsNotificationsFragment extends Fragment {
}
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
final SwitchCompat switchCompatNotify = (SwitchCompat) rootView.findViewById(R.id.set_notify);
final SwitchCompat switchCompatNotify = rootView.findViewById(R.id.set_notify);
switchCompatNotify.setChecked(notify);
final LinearLayout notification_settings = (LinearLayout) rootView.findViewById(R.id.notification_settings);
final LinearLayout notification_settings = rootView.findViewById(R.id.notification_settings);
if( notify)
notification_settings.setVisibility(View.VISIBLE);
else
@ -109,19 +108,19 @@ public class SettingsNotificationsFragment extends Fragment {
final String time_to = sharedpreferences.getString(Helper.SET_TIME_TO, "22:00");
final CheckBox set_notif_follow = (CheckBox) rootView.findViewById(R.id.set_notif_follow);
final CheckBox set_notif_follow_add = (CheckBox) rootView.findViewById(R.id.set_notif_follow_add);
final CheckBox set_notif_follow_ask = (CheckBox) rootView.findViewById(R.id.set_notif_follow_ask);
final CheckBox set_notif_follow_mention = (CheckBox) rootView.findViewById(R.id.set_notif_follow_mention);
final CheckBox set_notif_follow_share = (CheckBox) rootView.findViewById(R.id.set_notif_follow_share);
final CheckBox set_notif_follow = rootView.findViewById(R.id.set_notif_follow);
final CheckBox set_notif_follow_add = rootView.findViewById(R.id.set_notif_follow_add);
final CheckBox set_notif_follow_ask = rootView.findViewById(R.id.set_notif_follow_ask);
final CheckBox set_notif_follow_mention = rootView.findViewById(R.id.set_notif_follow_mention);
final CheckBox set_notif_follow_share = rootView.findViewById(R.id.set_notif_follow_share);
final CheckBox set_notif_hometimeline = (CheckBox) rootView.findViewById(R.id.set_notif_hometimeline);
final CheckBox set_notif_hometimeline = rootView.findViewById(R.id.set_notif_hometimeline);
final SwitchCompat switchCompatWIFI = (SwitchCompat) rootView.findViewById(R.id.set_wifi_only);
final SwitchCompat switchCompatSilent = (SwitchCompat) rootView.findViewById(R.id.set_silence);
final SwitchCompat switchCompatWIFI = rootView.findViewById(R.id.set_wifi_only);
final SwitchCompat switchCompatSilent = rootView.findViewById(R.id.set_silence);
final Button settings_time_from = (Button) rootView.findViewById(R.id.settings_time_from);
final Button settings_time_to = (Button) rootView.findViewById(R.id.settings_time_to);
final Button settings_time_from = rootView.findViewById(R.id.settings_time_from);
final Button settings_time_to = rootView.findViewById(R.id.settings_time_to);
settings_time_from.setText(time_from);
settings_time_to.setText(time_to);
@ -250,8 +249,8 @@ public class SettingsNotificationsFragment extends Fragment {
}
});
final Spinner led_colour_spinner = (Spinner) rootView.findViewById(R.id.led_colour_spinner);
final TextView ledLabel = (TextView) rootView.findViewById(R.id.set_led_colour_label);
final Spinner led_colour_spinner = rootView.findViewById(R.id.led_colour_spinner);
final TextView ledLabel = rootView.findViewById(R.id.set_led_colour_label);
switchCompatSilent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override

View File

@ -47,8 +47,8 @@ public class SettingsOptimizationFragment extends Fragment {
//Status per page
SeekBar statusSeekBar = (SeekBar) rootView.findViewById(R.id.set_toots_per_page);
final TextView set_toots_page_value = (TextView) rootView.findViewById(R.id.set_toots_page_value);
SeekBar statusSeekBar = rootView.findViewById(R.id.set_toots_per_page);
final TextView set_toots_page_value = rootView.findViewById(R.id.set_toots_page_value);
statusSeekBar.setMax(30);
int tootPerPage = sharedpreferences.getInt(Helper.SET_TOOTS_PER_PAGE, 40);
statusSeekBar.setProgress(tootPerPage-10);
@ -69,8 +69,8 @@ public class SettingsOptimizationFragment extends Fragment {
});
//Accounts per page
SeekBar accountsSeekBar = (SeekBar) rootView.findViewById(R.id.set_accounts_per_page);
final TextView set_accounts_page_value = (TextView) rootView.findViewById(R.id.set_accounts_page_value);
SeekBar accountsSeekBar = rootView.findViewById(R.id.set_accounts_per_page);
final TextView set_accounts_page_value = rootView.findViewById(R.id.set_accounts_page_value);
accountsSeekBar.setMax(30);
int accountsPerPage = sharedpreferences.getInt(Helper.SET_ACCOUNTS_PER_PAGE, 40);
accountsSeekBar.setProgress(accountsPerPage-10);
@ -92,8 +92,8 @@ public class SettingsOptimizationFragment extends Fragment {
//Notifications per page
SeekBar notificationsSeekBar = (SeekBar) rootView.findViewById(R.id.set_notifications_per_page);
final TextView set_notifications_page_value = (TextView) rootView.findViewById(R.id.set_notifications_page_value);
SeekBar notificationsSeekBar = rootView.findViewById(R.id.set_notifications_per_page);
final TextView set_notifications_page_value = rootView.findViewById(R.id.set_notifications_page_value);
notificationsSeekBar.setMax(20);
int notificationsPerPage = sharedpreferences.getInt(Helper.SET_NOTIFICATIONS_PER_PAGE, 15);
notificationsSeekBar.setProgress(notificationsPerPage-10);
@ -114,7 +114,7 @@ public class SettingsOptimizationFragment extends Fragment {
});
//Manage download of attachments
RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.set_attachment_group);
RadioGroup radioGroup = rootView.findViewById(R.id.set_attachment_group);
int attachmentAction = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
switch (attachmentAction){
case Helper.ATTACHMENT_ALWAYS:

View File

@ -39,11 +39,11 @@ public class TabLayoutSettingsFragment extends Fragment {
Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.tablayout_settings, container, false);
TabLayout tabLayout = (TabLayout) inflatedView.findViewById(R.id.tabLayout);
TabLayout tabLayout = inflatedView.findViewById(R.id.tabLayout);
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.settings)));
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.notifications)));
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.optimization)));
final ViewPager viewPager = (ViewPager) inflatedView.findViewById(R.id.viewpager);
final ViewPager viewPager = inflatedView.findViewById(R.id.viewpager);
viewPager.setAdapter(new PagerAdapter
(getChildFragmentManager(), tabLayout.getTabCount()));