Some improvements
This commit is contained in:
parent
3748c00f4f
commit
dfccf29f85
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -60,10 +60,10 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf
|
|||
private Context context;
|
||||
private AsyncTask<Void, Void, Void> asyncTask;
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,23 @@
|
|||
tools:context="fr.gouv.etalab.mastodon.activities.MainActivity"
|
||||
>
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/no_action_text"
|
||||
android:padding="10dp"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp"
|
||||
android:layout_gravity="center"
|
||||
android:textStyle="italic|bold"
|
||||
android:typeface="serif"
|
||||
android:text="@string/action_remote_instance_add"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/add_new_instance"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:textStyle="italic|bold"
|
||||
android:typeface="serif"
|
||||
android:text="@string/action_lists_empty_content"
|
||||
android:text="@string/action_list_add"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -595,6 +595,8 @@
|
|||
<string name="add_account_list_trunk">Adding accounts to the list</string>
|
||||
<string name="account_added_list_trunk">Accounts were added to the list</string>
|
||||
<string name="adding_account_list_trunk">Adding accounts to the list</string>
|
||||
<string name="action_list_add">You have not created a list yet. Click on the \"+\" button to add a new one.</string>
|
||||
<string name="action_remote_instance_add">You don\'t follow any remote instances. Click on the \"+\" button to add a new one.</string>
|
||||
|
||||
|
||||
<string-array translatable="false" name="proxy_type_choice">
|
||||
|
|
Loading…
Reference in New Issue