mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Outline specific error fragment for hotspot
This commit is contained in:
committed by
Torsten Grote
parent
6cd70e0e7f
commit
e39c99fd6c
@@ -10,7 +10,6 @@ import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
import org.briarproject.briar.android.activity.BriarActivity;
|
||||
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
|
||||
import org.briarproject.briar.android.fragment.ErrorFragment;
|
||||
import org.briarproject.briar.android.hotspot.HotspotState.HotspotError;
|
||||
import org.briarproject.briar.android.hotspot.HotspotState.HotspotStarted;
|
||||
|
||||
@@ -62,9 +61,14 @@ public class HotspotActivity extends BriarActivity
|
||||
showFragment(fm, new HotspotFragment(), tag);
|
||||
}
|
||||
} else if (hotspotState instanceof HotspotError) {
|
||||
// TODO: handle rotation gracefully. If we just use
|
||||
// fm.findFragmentByTag(HotspotErrorFragment.TAG) == null)
|
||||
// we might hide multiple errors. Maybe we could update the
|
||||
// error message of the existing fragment in that case
|
||||
String error = ((HotspotError) hotspotState).getError();
|
||||
Fragment f = ErrorFragment.newInstance(error);
|
||||
showFragment(getSupportFragmentManager(), f, ErrorFragment.TAG);
|
||||
Fragment f = HotspotErrorFragment.newInstance(error);
|
||||
showFragment(getSupportFragmentManager(), f,
|
||||
HotspotErrorFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.briarproject.briar.android.hotspot;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.fragment.BaseFragment;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class HotspotErrorFragment extends BaseFragment {
|
||||
|
||||
public static final String TAG = HotspotErrorFragment.class.getName();
|
||||
|
||||
private static final String ERROR_MSG = "errorMessage";
|
||||
|
||||
public static HotspotErrorFragment newInstance(String message) {
|
||||
HotspotErrorFragment f = new HotspotErrorFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ERROR_MSG, message);
|
||||
f.setArguments(args);
|
||||
return f;
|
||||
}
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle args = getArguments();
|
||||
if (args == null) throw new AssertionError();
|
||||
errorMessage = args.getString(ERROR_MSG);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View v = inflater
|
||||
.inflate(R.layout.fragment_hotspot_error, container, false);
|
||||
TextView msg = v.findViewById(R.id.errorMessageDetail);
|
||||
msg.setText(errorMessage);
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user