mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Connect device button settings and logic
This commit is contained in:
parent
2553794cb1
commit
c58b980208
@ -30,14 +30,6 @@ import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -50,6 +42,15 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.cketti.library.changelog.ChangeLog;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -103,14 +104,6 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
launchDiscoveryActivity();
|
||||
}
|
||||
});
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.controlcenter_navigation_drawer_open, R.string.controlcenter_navigation_drawer_close);
|
||||
@ -132,6 +125,25 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
deviceListView.setAdapter(this.mGBDeviceAdapter);
|
||||
|
||||
//we need deviceList so fab logic moved to here
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
launchDiscoveryActivity();
|
||||
}
|
||||
});
|
||||
|
||||
if (GBApplication.getPrefs().getBoolean("display_add_device_fab", true)) {
|
||||
fab.show();
|
||||
} else {
|
||||
if (deviceList.isEmpty()) {
|
||||
fab.show();
|
||||
} else {
|
||||
fab.hide();
|
||||
}
|
||||
}
|
||||
|
||||
/* uncomment to enable fixed-swipe to reveal more actions
|
||||
|
||||
ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
|
||||
@ -253,6 +265,9 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
Intent blIntent = new Intent(this, AppBlacklistActivity.class);
|
||||
startActivity(blIntent);
|
||||
return true;
|
||||
case R.id.device_action_discover:
|
||||
launchDiscoveryActivity();
|
||||
return true;
|
||||
case R.id.action_quit:
|
||||
GBApplication.quit();
|
||||
return true;
|
||||
@ -276,8 +291,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
+ "color: " + AndroidUtils.getTextColorHex(getBaseContext()) + "; "
|
||||
+ "background-color: " + AndroidUtils.getBackgroundColorHex(getBaseContext()) + ";" +
|
||||
"}";
|
||||
return new ChangeLog(this, css);
|
||||
}
|
||||
return new ChangeLog(this, css);}
|
||||
private void launchDiscoveryActivity() {
|
||||
startActivity(new Intent(this, DiscoveryActivity.class));
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
<item android:id="@+id/action_blacklist"
|
||||
android:title="@string/title_activity_appblacklist"
|
||||
android:icon="@drawable/ic_block_black" />
|
||||
<item android:id="@+id/device_action_discover"
|
||||
android:title="@string/action_discover"
|
||||
android:icon="@drawable/ic_add" />
|
||||
|
||||
<item android:id="@+id/action_quit"
|
||||
android:title="@string/action_quit"
|
||||
|
@ -169,6 +169,11 @@
|
||||
<string name="pref_title_expose_hr">3rd party realtime HR access</string>
|
||||
<string name="pref_title_use_custom_font">Use custom font</string>
|
||||
<string name="pref_summary_use_custom_font">Enable this if your device has a custom font firmware for emoji support</string>
|
||||
|
||||
<string name="pref_display_add_device_fab">Connect new device button</string>
|
||||
<string name="pref_display_add_device_fab_on">Always visible</string>
|
||||
<string name="pref_display_add_device_fab_off">Visible only if no device is added</string>
|
||||
|
||||
<!-- HPlus Preferences -->
|
||||
<string name="pref_title_unit_system">Units</string>
|
||||
<string name="pref_title_timeformat">Time format</string>
|
||||
|
@ -18,6 +18,14 @@
|
||||
android:defaultValue="false"
|
||||
android:key="general_autocreconnect"
|
||||
android:title="@string/pref_title_general_autoreconnect" />
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="true"
|
||||
android:key="display_add_device_fab"
|
||||
android:summaryOff="@string/pref_display_add_device_fab_off"
|
||||
android:summaryOn="@string/pref_display_add_device_fab_on"
|
||||
android:title="@string/pref_display_add_device_fab" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="default"
|
||||
android:key="audio_player"
|
||||
|
Loading…
Reference in New Issue
Block a user