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