diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceFederatedActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceFederatedActivity.java index 4f5c7c91d..721eafadd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceFederatedActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceFederatedActivity.java @@ -44,6 +44,7 @@ import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -84,6 +85,7 @@ public class InstanceFederatedActivity extends BaseActivity { boolean isLoadingInstance = false; private AutoCompleteTextView instance_list; private String oldSearch; + private RelativeLayout no_action; @Override protected void onCreate(Bundle savedInstanceState) { @@ -108,6 +110,7 @@ public class InstanceFederatedActivity extends BaseActivity { setContentView(R.layout.activity_federated); + no_action = findViewById(R.id.no_action); FloatingActionButton federated_timeline_close = findViewById(R.id.federated_timeline_close); federated_timeline_close.setOnClickListener(new View.OnClickListener() { @@ -341,7 +344,9 @@ public class InstanceFederatedActivity extends BaseActivity { for( int j = 0 ; j < tabCount ; j++){ attacheDelete(j); } - + if( tabCount == 0){ + no_action.setVisibility(View.VISIBLE); + } //Hide the default title if( getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); @@ -521,6 +526,7 @@ public class InstanceFederatedActivity extends BaseActivity { bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE); bundle.putString("remote_instance", tabLayout.getTabAt(position).getText().toString()); statusFragment.setArguments(bundle); + no_action.setVisibility(View.GONE); return statusFragment; } @@ -533,38 +539,4 @@ public class InstanceFederatedActivity extends BaseActivity { } - - - @SuppressWarnings("ConstantConditions") - public void updateTimeLine(RetrieveFeedsAsyncTask.Type type, int value){ - int position = tabLayout.getSelectedTabPosition(); - View tabLocal = tabLayout.getTabAt(position).getCustomView(); - assert tabLocal != null; - TextView tabCounter = tabLocal.findViewById(R.id.tab_counter); - tabCounter.setText(String.valueOf(value)); - if( value > 0){ - tabCounter.setVisibility(View.VISIBLE); - }else { - tabCounter.setVisibility(View.GONE); - } - } - - - public void startSreaming(){ - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); - if( liveNotifications) { - ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - assert manager != null; - for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { - if (LiveNotificationService.class.getName().equals(service.service.getClassName())) { - return; - } - } - Intent streamingIntent = new Intent(this, LiveNotificationService.class); - startService(streamingIntent); - } - - } - } \ No newline at end of file diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayListsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayListsFragment.java index 1b8929936..46a845eba 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayListsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayListsFragment.java @@ -60,10 +60,10 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf private Context context; private AsyncTask asyncTask; private List lists; - private TextView no_action_text; private RelativeLayout mainLoader; private FloatingActionButton add_new; private ListAdapter listAdapter; + private RelativeLayout textviewNoAction; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -76,8 +76,7 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf ListView lv_lists = rootView.findViewById(R.id.lv_lists); - RelativeLayout textviewNoAction = rootView.findViewById(R.id.no_action); - no_action_text = rootView.findViewById(R.id.no_action_text); + textviewNoAction = rootView.findViewById(R.id.no_action); mainLoader = rootView.findViewById(R.id.loader); RelativeLayout nextElementLoader = rootView.findViewById(R.id.loading_next_items); mainLoader.setVisibility(View.VISIBLE); @@ -85,7 +84,6 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf lists = new ArrayList<>(); listAdapter = new ListAdapter(context, lists, textviewNoAction); lv_lists.setAdapter(listAdapter); - no_action_text.setVisibility(View.GONE); asyncTask = new ManageListsAsyncTask(context, ManageListsAsyncTask.action.GET_LIST, null, null, null, null, DisplayListsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); try { add_new = ((MainActivity) context).findViewById(R.id.add_new); @@ -170,9 +168,9 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf if (apiResponse.getLists() != null && apiResponse.getLists().size() > 0) { this.lists.addAll(apiResponse.getLists()); listAdapter.notifyDataSetChanged(); - + textviewNoAction.setVisibility(View.GONE); } else { - no_action_text.setVisibility(View.VISIBLE); + textviewNoAction.setVisibility(View.VISIBLE); } }else if( actionType == ManageListsAsyncTask.action.CREATE_LIST){ if (apiResponse.getLists() != null && apiResponse.getLists().size() > 0) { @@ -186,9 +184,13 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf context.startActivity(intent); this.lists.add(0, apiResponse.getLists().get(0)); listAdapter.notifyDataSetChanged(); + textviewNoAction.setVisibility(View.GONE); }else{ Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show(); } + }else if( actionType == ManageListsAsyncTask.action.DELETE_LIST){ + if( this.lists.size() == 0) + textviewNoAction.setVisibility(View.VISIBLE); } } } diff --git a/app/src/main/res/layout/activity_federated.xml b/app/src/main/res/layout/activity_federated.xml index ff7949932..9dfc11584 100644 --- a/app/src/main/res/layout/activity_federated.xml +++ b/app/src/main/res/layout/activity_federated.xml @@ -81,7 +81,23 @@ tools:context="fr.gouv.etalab.mastodon.activities.MainActivity" > - + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f8b148d3..9308b01c6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -595,6 +595,8 @@ Adding accounts to the list Accounts were added to the list Adding accounts to the list + You have not created a list yet. Click on the \"+\" button to add a new one. + You don\'t follow any remote instances. Click on the \"+\" button to add a new one.