WIP: More work on UI for initial swap screen.
This commit is contained in:
parent
4a8ff47fce
commit
a48deb9160
BIN
F-Droid/res/drawable-hdpi/ic_network_wifi_white.png
Normal file
BIN
F-Droid/res/drawable-hdpi/ic_network_wifi_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 786 B |
BIN
F-Droid/res/drawable-mdpi/ic_network_wifi_white.png
Normal file
BIN
F-Droid/res/drawable-mdpi/ic_network_wifi_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 538 B |
BIN
F-Droid/res/drawable-xhdpi/ic_network_wifi_white.png
Normal file
BIN
F-Droid/res/drawable-xhdpi/ic_network_wifi_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
F-Droid/res/drawable-xxhdpi/ic_network_wifi_white.png
Normal file
BIN
F-Droid/res/drawable-xxhdpi/ic_network_wifi_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
F-Droid/res/drawable-xxxhdpi/ic_network_wifi_white.png
Normal file
BIN
F-Droid/res/drawable-xxxhdpi/ic_network_wifi_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
F-Droid/res/drawable/ic_network_wifi_white.png
Normal file
BIN
F-Droid/res/drawable/ic_network_wifi_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 538 B |
@ -2,22 +2,173 @@
|
||||
|
||||
<org.fdroid.fdroid.views.swap.StartSwapView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_info_white"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_description"
|
||||
android:text="@string/swap_introduction"
|
||||
style="@style/SwapTheme.StartSwap.MainText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:padding="20dp"
|
||||
android:paddingStart="30dp"
|
||||
android:paddingEnd="30dp"
|
||||
android:textAlignment="center"
|
||||
tools:text="Connect and trade apps with people near you."
|
||||
android:textSize="18sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bluetooth_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:weightSum="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
tools:src="@drawable/ic_bluetooth_white" />
|
||||
|
||||
<TextView
|
||||
android:paddingStart="15dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Visible via Bluetooth"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/device_id_bluetooth"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="SP-120"
|
||||
android:layout_weight="1.00"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/switch_bluetooth" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:weightSum="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
tools:src="@drawable/ic_network_wifi_white" />
|
||||
|
||||
<LinearLayout
|
||||
android:paddingStart="15dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Not visible via WiFi"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="wifi network name"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Device Name"
|
||||
android:layout_weight="1.00"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/switch_wifi" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingEnd="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingTop="35dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="People Nearby"
|
||||
android:layout_weight="1.00"/>
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:indeterminate="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Can't find who you're looking for?" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_start_swap"
|
||||
android:text="@string/swap_start"
|
||||
style="@style/SwapTheme.StartSwap.StartButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"/>
|
||||
android:layout_weight="1.00"
|
||||
android:drawableStart="@drawable/ic_launcher"
|
||||
tools:text="SEND F-DROID"
|
||||
android:gravity="start|center_vertical" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.00"
|
||||
android:drawableStart="@drawable/ic_launcher"
|
||||
tools:text="SCAN QR CODE"
|
||||
android:gravity="start|center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</org.fdroid.fdroid.views.swap.StartSwapView>
|
@ -317,8 +317,6 @@
|
||||
<string name="open_qr_code_scanner">Open QR Scanner</string>
|
||||
<string name="swap_welcome">Welcome to F-Droid!</string>
|
||||
<string name="swap_confirm_connect">Do you want to get apps from %1$s now?</string>
|
||||
<string name="swap_introduction">Your mobile device becomes an app store with Swap!</string>
|
||||
<string name="swap_start">START A SWAP</string>
|
||||
<string name="swap_reciprocate_failed">An error occurred while attempting to swap with another device. We will still try to get apps from them, but they may not be able to get apps from us.</string>
|
||||
<string name="swap_tap_to_select_apps">Tap to select the apps you want to swap.</string>
|
||||
<string name="swap_dont_show_again">Don\'t show this again</string>
|
||||
@ -333,4 +331,5 @@
|
||||
<string name="wifi_warning_personal">Best bet</string>
|
||||
<string name="swap_choose_apps">Choose Apps</string>
|
||||
<string name="swap_scan_qr">Scan QR Code</string>
|
||||
<string name="swap_nearby">Nearby Swap</string>
|
||||
</resources>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.fdroid.fdroid.localrepo;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -222,4 +223,37 @@ public class SwapManager {
|
||||
public boolean isEnabled() {
|
||||
return service != null && service.isEnabled();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Interacting with Bluetooth adapter
|
||||
// ==========================================
|
||||
|
||||
@Nullable /* Emulators tend not to have bluetooth adapters. */
|
||||
private final BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
public boolean isBluetoothDiscoverable() {
|
||||
return bluetooth != null &&
|
||||
bluetooth.getScanMode() == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE;
|
||||
}
|
||||
|
||||
public void ensureBluetoothDiscoverable() {
|
||||
|
||||
if (bluetooth == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bluetooth.isEnabled()) {
|
||||
if (!bluetooth.enable()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (bluetooth.isEnabled()) {
|
||||
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
||||
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
|
||||
context.startActivity(discoverableIntent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,24 @@
|
||||
package org.fdroid.fdroid.views.swap;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.compat.SwitchCompat;
|
||||
import org.fdroid.fdroid.localrepo.SwapManager;
|
||||
|
||||
public class StartSwapView extends LinearLayout implements SwapWorkflowActivity.InnerView {
|
||||
@ -45,16 +52,51 @@ public class StartSwapView extends LinearLayout implements SwapWorkflowActivity.
|
||||
return (SwapWorkflowActivity)getContext();
|
||||
}
|
||||
|
||||
private SwapManager getManager() {
|
||||
return getActivity().getState();
|
||||
}
|
||||
|
||||
@Nullable /* Emulators typically don't have bluetooth adapters */
|
||||
private final BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
private TextView viewBluetoothId;
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
findViewById(R.id.button_start_swap).setOnClickListener(new View.OnClickListener() {
|
||||
if (bluetooth != null) {
|
||||
|
||||
viewBluetoothId = (TextView)findViewById(R.id.device_id_bluetooth);
|
||||
viewBluetoothId.setText(bluetooth.getName());
|
||||
|
||||
Switch bluetoothSwitch = ((Switch) findViewById(R.id.switch_bluetooth));
|
||||
bluetoothSwitch.setChecked(getManager().isBluetoothDiscoverable());
|
||||
bluetoothSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getActivity().showSelectApps();
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
getManager().ensureBluetoothDiscoverable();
|
||||
} else {
|
||||
// disableBluetooth();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
findViewById(R.id.bluetooth_info).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
((Switch)findViewById(R.id.switch_wifi)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
enableWifi();
|
||||
} else {
|
||||
disableWifi();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -85,6 +127,19 @@ public class StartSwapView extends LinearLayout implements SwapWorkflowActivity.
|
||||
|
||||
@Override
|
||||
public String getToolbarTitle() {
|
||||
return getResources().getString(R.string.swap_start);
|
||||
return getResources().getString(R.string.swap_nearby);
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// Wifi stuff
|
||||
// ========================================================================
|
||||
|
||||
private void enableWifi() {
|
||||
|
||||
}
|
||||
|
||||
private void disableWifi() {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user