mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Rename tab fragments
and remove redundant NonNull annotations
This commit is contained in:
@@ -38,8 +38,8 @@ import org.briarproject.briar.android.attachment.media.MediaModule;
|
||||
import org.briarproject.briar.android.conversation.glide.BriarModelLoader;
|
||||
import org.briarproject.briar.android.hotspot.AbstractTabsFragment;
|
||||
import org.briarproject.briar.android.hotspot.HotspotIntroFragment;
|
||||
import org.briarproject.briar.android.hotspot.HotspotManualFragment;
|
||||
import org.briarproject.briar.android.hotspot.HotspotQrFragment;
|
||||
import org.briarproject.briar.android.hotspot.ManualHotspotFragment;
|
||||
import org.briarproject.briar.android.hotspot.QrHotspotFragment;
|
||||
import org.briarproject.briar.android.logging.CachingLogHandler;
|
||||
import org.briarproject.briar.android.login.SignInReminderReceiver;
|
||||
import org.briarproject.briar.android.removabledrive.ChooserFragment;
|
||||
@@ -224,9 +224,9 @@ public interface AndroidComponent
|
||||
|
||||
void inject(AbstractTabsFragment abstractTabsFragment);
|
||||
|
||||
void inject(HotspotQrFragment hotspotQrFragment);
|
||||
void inject(QrHotspotFragment qrHotspotFragment);
|
||||
|
||||
void inject(HotspotManualFragment hotspotManualFragment);
|
||||
void inject(ManualHotspotFragment manualHotspotFragment);
|
||||
|
||||
void inject(ChooserFragment chooserFragment);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.briarproject.briar.R;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
@@ -34,6 +33,8 @@ import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
@ParametersNotNullByDefault
|
||||
public abstract class AbstractTabsFragment extends Fragment {
|
||||
|
||||
static String ARG_FOR_WIFI_CONNECT = "forWifiConnect";
|
||||
|
||||
@Inject
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
@@ -61,8 +62,7 @@ public abstract class AbstractTabsFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onViewCreated(@NonNull View view,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
TabAdapter tabAdapter = new TabAdapter(this);
|
||||
ViewPager2 viewPager = view.findViewById(R.id.pager);
|
||||
viewPager.setAdapter(tabAdapter);
|
||||
@@ -118,7 +118,6 @@ public abstract class AbstractTabsFragment extends Fragment {
|
||||
super(fragment);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
if (position == 0) return getFirstFragment();
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.briarproject.briar.android.activity.BriarActivity;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
@@ -56,7 +55,7 @@ public class HotspotActivity extends BriarActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -18,8 +17,7 @@ public class HotspotFragment extends AbstractTabsFragment {
|
||||
public final static String TAG = HotspotFragment.class.getName();
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
// no need to call into the ViewModel here
|
||||
connectedButton.setOnClickListener(v -> {
|
||||
@@ -36,12 +34,12 @@ public class HotspotFragment extends AbstractTabsFragment {
|
||||
|
||||
@Override
|
||||
protected Fragment getFirstFragment() {
|
||||
return HotspotManualFragment.newInstance(true);
|
||||
return ManualHotspotFragment.newInstance(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Fragment getSecondFragment() {
|
||||
return HotspotQrFragment.newInstance(true);
|
||||
return QrHotspotFragment.newInstance(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,22 +19,23 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.hotspot.AbstractTabsFragment.ARG_FOR_WIFI_CONNECT;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class HotspotManualFragment extends Fragment {
|
||||
public class ManualHotspotFragment extends Fragment {
|
||||
|
||||
public final static String TAG = HotspotManualFragment.class.getName();
|
||||
public final static String TAG = ManualHotspotFragment.class.getName();
|
||||
|
||||
@Inject
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private HotspotViewModel viewModel;
|
||||
|
||||
static HotspotManualFragment newInstance(boolean forWifiConnect) {
|
||||
HotspotManualFragment f = new HotspotManualFragment();
|
||||
static ManualHotspotFragment newInstance(boolean forWifiConnect) {
|
||||
ManualHotspotFragment f = new ManualHotspotFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("forWifiConnect", forWifiConnect);
|
||||
bundle.putBoolean(ARG_FOR_WIFI_CONNECT, forWifiConnect);
|
||||
f.setArguments(bundle);
|
||||
return f;
|
||||
}
|
||||
@@ -65,7 +66,7 @@ public class HotspotManualFragment extends Fragment {
|
||||
TextView passwordView = v.findViewById(R.id.passwordView);
|
||||
TextView altView = v.findViewById(R.id.altView);
|
||||
|
||||
if (requireArguments().getBoolean("forWifiConnect")) {
|
||||
if (requireArguments().getBoolean(ARG_FOR_WIFI_CONNECT)) {
|
||||
manualIntroView.setText(R.string.hotspot_manual_wifi);
|
||||
ssidLabelView.setText(R.string.hotspot_manual_wifi_ssid);
|
||||
// TODO observe state in ViewModel and get info from there instead
|
||||
@@ -19,22 +19,23 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.hotspot.AbstractTabsFragment.ARG_FOR_WIFI_CONNECT;
|
||||
|
||||
@MethodsNotNullByDefault
|
||||
@ParametersNotNullByDefault
|
||||
public class HotspotQrFragment extends Fragment {
|
||||
public class QrHotspotFragment extends Fragment {
|
||||
|
||||
public final static String TAG = HotspotQrFragment.class.getName();
|
||||
public final static String TAG = QrHotspotFragment.class.getName();
|
||||
|
||||
@Inject
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private HotspotViewModel viewModel;
|
||||
|
||||
static HotspotQrFragment newInstance(boolean forWifiConnect) {
|
||||
HotspotQrFragment f = new HotspotQrFragment();
|
||||
static QrHotspotFragment newInstance(boolean forWifiConnect) {
|
||||
QrHotspotFragment f = new QrHotspotFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("forWifiConnect", forWifiConnect);
|
||||
bundle.putBoolean(ARG_FOR_WIFI_CONNECT, forWifiConnect);
|
||||
f.setArguments(bundle);
|
||||
return f;
|
||||
}
|
||||
@@ -57,7 +58,7 @@ public class HotspotQrFragment extends Fragment {
|
||||
TextView qrIntroView = v.findViewById(R.id.qrIntroView);
|
||||
ImageView qrCodeView = v.findViewById(R.id.qrCodeView);
|
||||
|
||||
if (requireArguments().getBoolean("forWifiConnect")) {
|
||||
if (requireArguments().getBoolean(ARG_FOR_WIFI_CONNECT)) {
|
||||
qrIntroView.setText(R.string.hotspot_qr_wifi);
|
||||
// TODO observe state in ViewModel and get QR code from there
|
||||
} else {
|
||||
@@ -6,7 +6,6 @@ import android.view.View;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -19,20 +18,19 @@ public class WebsiteFragment extends AbstractTabsFragment {
|
||||
public final static String TAG = WebsiteFragment.class.getName();
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
connectedButton.setVisibility(GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Fragment getFirstFragment() {
|
||||
return HotspotManualFragment.newInstance(false);
|
||||
return ManualHotspotFragment.newInstance(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Fragment getSecondFragment() {
|
||||
return HotspotQrFragment.newInstance(false);
|
||||
return QrHotspotFragment.newInstance(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="12dp"
|
||||
android:height="12dp"
|
||||
android:width="8dp"
|
||||
android:height="8dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
Reference in New Issue
Block a user