mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Remove the legacy ControlCenter and its usages. Add New GUI to the changelog.
This commit is contained in:
parent
183d89dc47
commit
0ac77fc0a4
@ -1,6 +1,7 @@
|
|||||||
###Changelog
|
###Changelog
|
||||||
|
|
||||||
###Version 0.18.0 (next)
|
###Version 0.18.0
|
||||||
|
* All new GUI for the control center
|
||||||
* Add Portuguese pt_PT and pt_BR translations
|
* Add Portuguese pt_PT and pt_BR translations
|
||||||
* Add Czech translation
|
* Add Czech translation
|
||||||
* Add Hebrew translation and transliteration
|
* Add Hebrew translation and transliteration
|
||||||
|
@ -37,18 +37,19 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/GadgetbridgeTheme">
|
android:theme="@style/GadgetbridgeTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ControlCenter"
|
android:name=".activities.ControlCenterv2"
|
||||||
android:label="@string/title_activity_controlcenter">
|
android:label="@string/title_activity_controlcenter"
|
||||||
|
android:theme="@style/GadgetbridgeTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.SettingsActivity"
|
android:name=".activities.SettingsActivity"
|
||||||
android:label="@string/title_activity_settings"
|
android:label="@string/title_activity_settings"
|
||||||
android:parentActivityName=".activities.ControlCenter" />
|
android:parentActivityName=".activities.ControlCenterv2" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".devices.miband.MiBandPreferencesActivity"
|
android:name=".devices.miband.MiBandPreferencesActivity"
|
||||||
android:label="@string/preferences_miband_settings"
|
android:label="@string/preferences_miband_settings"
|
||||||
@ -57,7 +58,7 @@
|
|||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:name=".activities.appmanager.AppManagerActivity"
|
android:name=".activities.appmanager.AppManagerActivity"
|
||||||
android:label="@string/title_activity_appmanager"
|
android:label="@string/title_activity_appmanager"
|
||||||
android:parentActivityName=".activities.ControlCenter" />
|
android:parentActivityName=".activities.ControlCenterv2" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.AppBlacklistActivity"
|
android:name=".activities.AppBlacklistActivity"
|
||||||
android:label="@string/title_activity_appblacklist"
|
android:label="@string/title_activity_appblacklist"
|
||||||
@ -65,7 +66,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.FwAppInstallerActivity"
|
android:name=".activities.FwAppInstallerActivity"
|
||||||
android:label="@string/title_activity_fw_app_insaller"
|
android:label="@string/title_activity_fw_app_insaller"
|
||||||
android:parentActivityName=".activities.ControlCenter">
|
android:parentActivityName=".activities.ControlCenterv2">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
@ -303,19 +304,19 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.DebugActivity"
|
android:name=".activities.DebugActivity"
|
||||||
android:label="@string/title_activity_debug"
|
android:label="@string/title_activity_debug"
|
||||||
android:parentActivityName=".activities.ControlCenter"
|
android:parentActivityName=".activities.ControlCenterv2"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.DbManagementActivity"
|
android:name=".activities.DbManagementActivity"
|
||||||
android:label="@string/title_activity_db_management"
|
android:label="@string/title_activity_db_management"
|
||||||
android:parentActivityName=".activities.ControlCenter"
|
android:parentActivityName=".activities.ControlCenterv2"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.DiscoveryActivity"
|
android:name=".activities.DiscoveryActivity"
|
||||||
android:label="@string/title_activity_discovery"
|
android:label="@string/title_activity_discovery"
|
||||||
android:parentActivityName=".activities.ControlCenter" />
|
android:parentActivityName=".activities.ControlCenterv2" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.AndroidPairingActivity"
|
android:name=".activities.AndroidPairingActivity"
|
||||||
android:label="@string/title_activity_android_pairing" />
|
android:label="@string/title_activity_android_pairing" />
|
||||||
@ -328,7 +329,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.charts.ChartsActivity"
|
android:name=".activities.charts.ChartsActivity"
|
||||||
android:label="@string/title_activity_charts"
|
android:label="@string/title_activity_charts"
|
||||||
android:parentActivityName=".activities.ControlCenter" />
|
android:parentActivityName=".activities.ControlCenterv2" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ConfigureAlarms"
|
android:name=".activities.ConfigureAlarms"
|
||||||
android:label="@string/title_activity_set_alarm"
|
android:label="@string/title_activity_set_alarm"
|
||||||
@ -340,7 +341,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activities.VibrationActivity"
|
android:name=".activities.VibrationActivity"
|
||||||
android:label="@string/title_activity_vibration"
|
android:label="@string/title_activity_vibration"
|
||||||
android:parentActivityName=".activities.ControlCenter" />
|
android:parentActivityName=".activities.ControlCenterv2" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name=".contentprovider.PebbleContentProvider"
|
android:name=".contentprovider.PebbleContentProvider"
|
||||||
@ -377,7 +378,7 @@
|
|||||||
android:parentActivityName=".activities.appmanager.AppManagerActivity">
|
android:parentActivityName=".activities.appmanager.AppManagerActivity">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter" />
|
android:value="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2" />
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
@ -385,16 +386,7 @@
|
|||||||
<data android:scheme="gadgetbridge" />
|
<data android:scheme="gadgetbridge" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name=".activities.ControlCenterv2"
|
|
||||||
android:label="@string/title_activity_controlcenter"
|
|
||||||
android:theme="@style/GadgetbridgeTheme.NoActionBar">
|
|
||||||
<intent-filter>
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,451 +0,0 @@
|
|||||||
/* Copyright (C) 2015-2017 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
|
||||||
Gobbetti, Lem Dulfo
|
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
|
||||||
|
|
||||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Gadgetbridge is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
|
||||||
import android.view.ContextMenu;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.cketti.library.changelog.ChangeLog;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapter;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
|
||||||
|
|
||||||
public class ControlCenter extends GBActivity {
|
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ControlCenter.class);
|
|
||||||
|
|
||||||
private TextView hintTextView;
|
|
||||||
private FloatingActionButton fab;
|
|
||||||
private ImageView background;
|
|
||||||
|
|
||||||
private SwipeRefreshLayout swipeLayout;
|
|
||||||
private GBDeviceAdapter mGBDeviceAdapter;
|
|
||||||
private DeviceManager deviceManager;
|
|
||||||
/**
|
|
||||||
* Temporary field for the context menu
|
|
||||||
*/
|
|
||||||
private GBDevice selectedDevice;
|
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
switch (action) {
|
|
||||||
case GBApplication.ACTION_QUIT:
|
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
case DeviceManager.ACTION_DEVICES_CHANGED:
|
|
||||||
refreshPairedDevices();
|
|
||||||
GBDevice selectedDevice = deviceManager.getSelectedDevice();
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
refreshBusyState(selectedDevice);
|
|
||||||
enableSwipeRefresh(selectedDevice);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void refreshBusyState(GBDevice dev) {
|
|
||||||
if (dev != null && dev.isBusy()) {
|
|
||||||
swipeLayout.setRefreshing(true);
|
|
||||||
} else {
|
|
||||||
boolean wasBusy = swipeLayout.isRefreshing();
|
|
||||||
if (wasBusy) {
|
|
||||||
swipeLayout.setRefreshing(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_controlcenter);
|
|
||||||
|
|
||||||
deviceManager = ((GBApplication)getApplication()).getDeviceManager();
|
|
||||||
|
|
||||||
hintTextView = (TextView) findViewById(R.id.hintTextView);
|
|
||||||
ListView deviceListView = (ListView) findViewById(R.id.deviceListView);
|
|
||||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
|
||||||
background = (ImageView) findViewById(R.id.no_items_bg);
|
|
||||||
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
launchDiscoveryActivity();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final List<GBDevice> deviceList = deviceManager.getDevices();
|
|
||||||
mGBDeviceAdapter = new GBDeviceAdapter(this, deviceList);
|
|
||||||
deviceListView.setAdapter(this.mGBDeviceAdapter);
|
|
||||||
deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView parent, View v, int position, long id) {
|
|
||||||
GBDevice gbDevice = mGBDeviceAdapter.getItem(position);
|
|
||||||
if (gbDevice.isInitialized()) {
|
|
||||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
|
||||||
Class<? extends Activity> primaryActivity = coordinator.getPrimaryActivity();
|
|
||||||
if (primaryActivity != null) {
|
|
||||||
Intent startIntent = new Intent(ControlCenter.this, primaryActivity);
|
|
||||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, gbDevice);
|
|
||||||
startActivity(startIntent);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GBApplication.deviceService().connect(gbDevice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.controlcenter_swipe_layout);
|
|
||||||
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
|
||||||
fetchActivityData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerForContextMenu(deviceListView);
|
|
||||||
|
|
||||||
IntentFilter filterLocal = new IntentFilter();
|
|
||||||
filterLocal.addAction(GBApplication.ACTION_QUIT);
|
|
||||||
filterLocal.addAction(DeviceManager.ACTION_DEVICES_CHANGED);
|
|
||||||
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
|
|
||||||
|
|
||||||
refreshPairedDevices();
|
|
||||||
/*
|
|
||||||
* Ask for permission to intercept notifications on first run.
|
|
||||||
*/
|
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
|
||||||
if (prefs.getBoolean("firstrun", true)) {
|
|
||||||
prefs.getPreferences().edit().putBoolean("firstrun", false).apply();
|
|
||||||
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
|
||||||
startActivity(enableIntent);
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
checkAndRequestPermissions();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangeLog cl = new ChangeLog(this);
|
|
||||||
if (cl.isFirstRun()) {
|
|
||||||
cl.getLogDialog().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
GBApplication.deviceService().start();
|
|
||||||
|
|
||||||
enableSwipeRefresh(deviceManager.getSelectedDevice());
|
|
||||||
if (GB.isBluetoothEnabled() && deviceList.isEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
||||||
startActivity(new Intent(this, DiscoveryActivity.class));
|
|
||||||
} else {
|
|
||||||
GBApplication.deviceService().requestDeviceInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
|
||||||
AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
|
||||||
selectedDevice = mGBDeviceAdapter.getItem(acmi.position);
|
|
||||||
if (selectedDevice != null && selectedDevice.isBusy()) {
|
|
||||||
// no context menu when device is busy
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getMenuInflater().inflate(R.menu.controlcenter_context, menu);
|
|
||||||
|
|
||||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(selectedDevice);
|
|
||||||
if (!coordinator.supportsActivityDataFetching()) {
|
|
||||||
menu.removeItem(R.id.controlcenter_fetch_activity_data);
|
|
||||||
}
|
|
||||||
if (!coordinator.supportsScreenshots()) {
|
|
||||||
menu.removeItem(R.id.controlcenter_take_screenshot);
|
|
||||||
}
|
|
||||||
if (!coordinator.supportsAlarmConfiguration()) {
|
|
||||||
menu.removeItem(R.id.controlcenter_configure_alarms);
|
|
||||||
}
|
|
||||||
if (!coordinator.supportsActivityTracking()) {
|
|
||||||
menu.removeItem(R.id.controlcenter_start_sleepmonitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedDevice.getState() == GBDevice.State.NOT_CONNECTED) {
|
|
||||||
menu.removeItem(R.id.controlcenter_disconnect);
|
|
||||||
}
|
|
||||||
if (!selectedDevice.isInitialized()) {
|
|
||||||
menu.removeItem(R.id.controlcenter_find_device);
|
|
||||||
menu.removeItem(R.id.controlcenter_fetch_activity_data);
|
|
||||||
menu.removeItem(R.id.controlcenter_configure_alarms);
|
|
||||||
menu.removeItem(R.id.controlcenter_take_screenshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.setHeaderTitle(selectedDevice.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableSwipeRefresh(GBDevice device) {
|
|
||||||
if (device == null) {
|
|
||||||
swipeLayout.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
|
||||||
boolean enable = coordinator.allowFetchActivityData(device);
|
|
||||||
swipeLayout.setEnabled(enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchActivityData() {
|
|
||||||
GBDevice selectedDevice = deviceManager.getSelectedDevice();
|
|
||||||
if (selectedDevice == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (selectedDevice.isInitialized()) {
|
|
||||||
GBApplication.deviceService().onFetchActivityData();
|
|
||||||
} else {
|
|
||||||
swipeLayout.setRefreshing(false);
|
|
||||||
GB.toast(this, getString(R.string.device_not_connected), Toast.LENGTH_SHORT, GB.ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.controlcenter_start_sleepmonitor:
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
Intent startIntent;
|
|
||||||
startIntent = new Intent(ControlCenter.this, ChartsActivity.class);
|
|
||||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
|
|
||||||
startActivity(startIntent);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.controlcenter_fetch_activity_data:
|
|
||||||
fetchActivityData();
|
|
||||||
return true;
|
|
||||||
case R.id.controlcenter_disconnect:
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
selectedDevice = null;
|
|
||||||
GBApplication.deviceService().disconnect();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.controlcenter_find_device:
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
findDevice(true);
|
|
||||||
ProgressDialog.show(
|
|
||||||
this,
|
|
||||||
getString(R.string.control_center_find_lost_device),
|
|
||||||
getString(R.string.control_center_cancel_to_stop_vibration),
|
|
||||||
true, true,
|
|
||||||
new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
findDevice(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.controlcenter_configure_alarms:
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
Intent startIntent;
|
|
||||||
startIntent = new Intent(ControlCenter.this, ConfigureAlarms.class);
|
|
||||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
|
|
||||||
startActivity(startIntent);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.controlcenter_take_screenshot:
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
GBApplication.deviceService().onScreenshotReq();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.controlcenter_delete_device:
|
|
||||||
if (selectedDevice != null) {
|
|
||||||
confirmDeleteDevice(selectedDevice);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onContextItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void findDevice(boolean start) {
|
|
||||||
GBApplication.deviceService().onFindDevice(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_settings:
|
|
||||||
Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
|
||||||
startActivity(settingsIntent);
|
|
||||||
return true;
|
|
||||||
case R.id.action_debug:
|
|
||||||
Intent debugIntent = new Intent(this, DebugActivity.class);
|
|
||||||
startActivity(debugIntent);
|
|
||||||
return true;
|
|
||||||
case R.id.action_db_management:
|
|
||||||
Intent dbIntent = new Intent(this, DbManagementActivity.class);
|
|
||||||
startActivity(dbIntent);
|
|
||||||
return true;
|
|
||||||
case R.id.action_quit:
|
|
||||||
GBApplication.quit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void launchDiscoveryActivity() {
|
|
||||||
startActivity(new Intent(this, DiscoveryActivity.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void confirmDeleteDevice(final GBDevice gbDevice) {
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setTitle(getString(R.string.controlcenter_delete_device_name, gbDevice.getName()))
|
|
||||||
.setMessage(R.string.controlcenter_delete_device_dialogmessage)
|
|
||||||
.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
try {
|
|
||||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
|
||||||
if (coordinator != null) {
|
|
||||||
coordinator.deleteDevice(selectedDevice);
|
|
||||||
}
|
|
||||||
DeviceHelper.getInstance().removeBond(selectedDevice);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
GB.toast(ControlCenter.this, "Error deleting device: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex);
|
|
||||||
} finally {
|
|
||||||
selectedDevice = null;
|
|
||||||
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
|
||||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshPairedDevices() {
|
|
||||||
List<GBDevice> deviceList = deviceManager.getDevices();
|
|
||||||
GBDevice connectedDevice = null;
|
|
||||||
|
|
||||||
for (GBDevice device : deviceList) {
|
|
||||||
if (device.isConnected() || device.isConnecting()) {
|
|
||||||
connectedDevice = device;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deviceList.isEmpty()) {
|
|
||||||
background.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
background.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connectedDevice != null) {
|
|
||||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(connectedDevice);
|
|
||||||
hintTextView.setText(coordinator.getTapString());
|
|
||||||
} else if (!deviceList.isEmpty()) {
|
|
||||||
hintTextView.setText(R.string.tap_a_device_to_connect);
|
|
||||||
}
|
|
||||||
|
|
||||||
mGBDeviceAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
|
||||||
private void checkAndRequestPermissions() {
|
|
||||||
List<String> wantedPermissions = new ArrayList<>();
|
|
||||||
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.BLUETOOTH);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.BLUETOOTH_ADMIN);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.READ_CONTACTS);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.CALL_PHONE);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.READ_PHONE_STATE);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.PROCESS_OUTGOING_CALLS) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.PROCESS_OUTGOING_CALLS);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.READ_SMS);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.SEND_SMS);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_DENIED)
|
|
||||||
wantedPermissions.add(Manifest.permission.READ_CALENDAR);
|
|
||||||
|
|
||||||
if (!wantedPermissions.isEmpty())
|
|
||||||
ActivityCompat.requestPermissions(this, wantedPermissions.toArray(new String[wantedPermissions.size()]), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
/* Copyright (C) 2015-2017 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
|
||||||
Gobbetti, João Paulo Barraca, Lem Dulfo
|
|
||||||
|
|
||||||
This file is part of Gadgetbridge.
|
|
||||||
|
|
||||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Gadgetbridge is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
package nodomain.freeyourgadget.gadgetbridge.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapter for displaying GBDevice instances.
|
|
||||||
*/
|
|
||||||
public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
public GBDeviceAdapter(Context context, List<GBDevice> deviceList) {
|
|
||||||
super(context, 0, deviceList);
|
|
||||||
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View view, ViewGroup parent) {
|
|
||||||
final GBDevice device = getItem(position);
|
|
||||||
|
|
||||||
if (view == null) {
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context
|
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
|
|
||||||
view = inflater.inflate(R.layout.device_item, parent, false);
|
|
||||||
}
|
|
||||||
TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status);
|
|
||||||
TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
|
|
||||||
final ListView deviceInfoList = (ListView) view.findViewById(R.id.device_item_infos);
|
|
||||||
ItemWithDetailsAdapter infoAdapter = new ItemWithDetailsAdapter(context, device.getDeviceInfos());
|
|
||||||
infoAdapter.setHorizontalAlignment(true);
|
|
||||||
deviceInfoList.setAdapter(infoAdapter);
|
|
||||||
TextView batteryLabel = (TextView) view.findViewById(R.id.battery_label);
|
|
||||||
TextView batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status);
|
|
||||||
final ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
|
||||||
ImageView deviceInfoView = (ImageView) view.findViewById(R.id.device_info_image);
|
|
||||||
ProgressBar busyIndicator = (ProgressBar) view.findViewById(R.id.device_busy_indicator);
|
|
||||||
|
|
||||||
deviceNameLabel.setText(getUniqueDeviceName(device));
|
|
||||||
|
|
||||||
if (device.isBusy()) {
|
|
||||||
deviceStatusLabel.setText(device.getBusyTask());
|
|
||||||
busyIndicator.setVisibility(View.VISIBLE);
|
|
||||||
batteryLabel.setVisibility(View.INVISIBLE);
|
|
||||||
batteryStatusLabel.setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
|
||||||
deviceStatusLabel.setText(device.getStateString());
|
|
||||||
busyIndicator.setVisibility(View.INVISIBLE);
|
|
||||||
batteryLabel.setVisibility(View.VISIBLE);
|
|
||||||
batteryStatusLabel.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean showInfoIcon = device.hasDeviceInfos() && !device.isBusy();
|
|
||||||
deviceInfoView.setVisibility(showInfoIcon ? View.VISIBLE : View.GONE);
|
|
||||||
deviceInfoView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (deviceInfoList.getVisibility() == View.VISIBLE) {
|
|
||||||
deviceInfoList.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
ArrayAdapter adapter = (ArrayAdapter) deviceInfoList.getAdapter();
|
|
||||||
adapter.clear();
|
|
||||||
List<ItemWithDetails> infos = device.getDeviceInfos();
|
|
||||||
Collections.sort(infos);
|
|
||||||
adapter.addAll(infos);
|
|
||||||
justifyListViewHeightBasedOnChildren(deviceInfoList);
|
|
||||||
deviceInfoList.setVisibility(View.VISIBLE);
|
|
||||||
deviceInfoList.setFocusable(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
short batteryLevel = device.getBatteryLevel();
|
|
||||||
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
|
||||||
batteryLabel.setText("BAT:");
|
|
||||||
batteryStatusLabel.setText(device.getBatteryLevel() + "%");
|
|
||||||
BatteryState batteryState = device.getBatteryState();
|
|
||||||
if (BatteryState.BATTERY_LOW.equals(batteryState)) {
|
|
||||||
batteryLabel.setTextColor(Color.RED);
|
|
||||||
batteryStatusLabel.setTextColor(Color.RED);
|
|
||||||
} else {
|
|
||||||
batteryLabel.setTextColor(ContextCompat.getColor(getContext(), R.color.secondarytext));
|
|
||||||
batteryStatusLabel.setTextColor(ContextCompat.getColor(getContext(), R.color.secondarytext));
|
|
||||||
|
|
||||||
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
|
|
||||||
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
|
|
||||||
batteryStatusLabel.append(" CHG");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
batteryLabel.setText("");
|
|
||||||
batteryStatusLabel.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device.isConnected()) {
|
|
||||||
deviceImageView.setImageResource(device.getType().getIcon());
|
|
||||||
} else {
|
|
||||||
deviceImageView.setImageResource(device.getType().getDisabledIcon());
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void justifyListViewHeightBasedOnChildren(ListView listView) {
|
|
||||||
ArrayAdapter adapter = (ArrayAdapter) listView.getAdapter();
|
|
||||||
|
|
||||||
if (adapter == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ViewGroup vg = listView;
|
|
||||||
int totalHeight = 0;
|
|
||||||
for (int i = 0; i < adapter.getCount(); i++) {
|
|
||||||
View listItem = adapter.getView(i, null, vg);
|
|
||||||
listItem.measure(0, 0);
|
|
||||||
totalHeight += listItem.getMeasuredHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewGroup.LayoutParams par = listView.getLayoutParams();
|
|
||||||
par.height = totalHeight + (listView.getDividerHeight() * (adapter.getCount() - 1));
|
|
||||||
listView.setLayoutParams(par);
|
|
||||||
listView.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getUniqueDeviceName(GBDevice device) {
|
|
||||||
String deviceName = device.getName();
|
|
||||||
if (!isUniqueDeviceName(device, deviceName)) {
|
|
||||||
if (device.getModel() != null) {
|
|
||||||
deviceName = deviceName + " " + device.getModel();
|
|
||||||
if (!isUniqueDeviceName(device, deviceName)) {
|
|
||||||
deviceName = deviceName + " " + device.getShortAddress();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
deviceName = deviceName + " " + device.getShortAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return deviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isUniqueDeviceName(GBDevice device, String deviceName) {
|
|
||||||
for (int i = 0; i < getCount(); i++) {
|
|
||||||
GBDevice item = getItem(i);
|
|
||||||
if (item == device) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (deviceName.equals(item.getName())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,7 +26,7 @@ import android.support.annotation.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter;
|
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample;
|
import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||||
@ -114,7 +114,7 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Activity> getPairingActivity() {
|
public Class<? extends Activity> getPairingActivity() {
|
||||||
return ControlCenter.class;
|
return ControlCenterv2.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter;
|
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.DiscoveryActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.DiscoveryActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.GBActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.GBActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||||
@ -219,7 +219,7 @@ public class MiBandPairingActivity extends GBActivity {
|
|||||||
Prefs prefs = GBApplication.getPrefs();
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
prefs.getPreferences().edit().putString(MiBandConst.PREF_MIBAND_ADDRESS, macAddress).apply();
|
prefs.getPreferences().edit().putString(MiBandConst.PREF_MIBAND_ADDRESS, macAddress).apply();
|
||||||
}
|
}
|
||||||
Intent intent = new Intent(this, ControlCenter.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
|
@ -23,7 +23,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -36,7 +35,7 @@ import java.util.List;
|
|||||||
import de.greenrobot.dao.query.Query;
|
import de.greenrobot.dao.query.Query;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter;
|
import nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.DiscoveryActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.DiscoveryActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.GBActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.GBActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||||
@ -184,7 +183,7 @@ public class PebblePairingActivity extends GBActivity {
|
|||||||
unregisterReceiver(mBondingReceiver);
|
unregisterReceiver(mBondingReceiver);
|
||||||
|
|
||||||
if (pairedSuccessfully) {
|
if (pairedSuccessfully) {
|
||||||
Intent intent = new Intent(this, ControlCenter.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
|
||||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/no_items_bg"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:src="@drawable/gadgetbridge_img" />
|
|
||||||
|
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
|
||||||
android:id="@+id/controlcenter_swipe_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingBottom="0px"
|
|
||||||
android:paddingLeft="0px"
|
|
||||||
android:paddingRight="0px"
|
|
||||||
android:paddingTop="0px">
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:id="@+id/deviceListView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_above="@+id/hintTextView"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_centerHorizontal="true" />
|
|
||||||
</android.support.v4.widget.SwipeRefreshLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/fab"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:src="@drawable/ic_add_white"
|
|
||||||
app:elevation="6dp"
|
|
||||||
app:pressedTranslationZ="12dp"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:layout_marginRight="10dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/hintTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_above="@id/fab"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="@color/secondarytext"
|
|
||||||
android:textStyle="italic"
|
|
||||||
android:text="@string/tap_connected_device_for_app_mananger" />
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -2,7 +2,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter">
|
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/scrollView2"
|
android:id="@+id/scrollView2"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter">
|
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/scrollView"
|
android:id="@+id/scrollView"
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?android:attr/activatedBackgroundIndicator"
|
|
||||||
android:columnCount="2"
|
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/device_image"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:contentDescription="@string/candidate_item_device_image"
|
|
||||||
tools:src="@drawable/ic_device_pebble" />
|
|
||||||
|
|
||||||
<GridLayout
|
|
||||||
android:layout_gravity="fill_horizontal"
|
|
||||||
android:background="?android:attr/activatedBackgroundIndicator"
|
|
||||||
android:columnCount="3"
|
|
||||||
android:paddingBottom="2dp"
|
|
||||||
android:paddingTop="3dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/device_name"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:typeface="sans"
|
|
||||||
tools:text="My Pebble Watch" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/battery_label"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingLeft="7sp"
|
|
||||||
android:paddingRight="7sp"
|
|
||||||
android:textColor="@color/secondarytext"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="BAT" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/device_info_image"
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:layout_gravity="center_vertical|right"
|
|
||||||
android:layout_rowSpan="2"
|
|
||||||
android:clickable="true"
|
|
||||||
android:contentDescription="@string/candidate_item_device_image"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:src="@drawable/ic_information_outline_grey600_24dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/device_status"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="fill_horizontal"
|
|
||||||
android:gravity="start|bottom"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="@string/connecting" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/battery_status"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:gravity="start|bottom"
|
|
||||||
android:paddingLeft="7sp"
|
|
||||||
android:paddingRight="7sp"
|
|
||||||
android:textColor="@color/secondarytext"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="100% CHG" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/device_busy_indicator"
|
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
|
||||||
android:layout_width="140dp"
|
|
||||||
android:layout_height="4dp"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:visibility="visible"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
</GridLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:id="@+id/device_item_infos"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_columnSpan="2"
|
|
||||||
android:layout_gravity="fill"
|
|
||||||
android:layout_marginStart="@dimen/widget_margin"
|
|
||||||
android:gravity="fill_horizontal"
|
|
||||||
android:paddingLeft="36dp"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</GridLayout>
|
|
@ -1,32 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_fetch_activity_data"
|
|
||||||
android:icon="@drawable/ic_action_fetch_activity_data"
|
|
||||||
android:title="@string/controlcenter_fetch_activity_data"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_start_sleepmonitor"
|
|
||||||
android:icon="@drawable/ic_activity_graphs"
|
|
||||||
android:title="@string/controlcenter_start_activitymonitor"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_configure_alarms"
|
|
||||||
android:icon="@drawable/ic_device_set_alarms"
|
|
||||||
android:title="@string/controlcenter_start_configure_alarms"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_find_device"
|
|
||||||
android:icon="@drawable/ic_action_find_lost_device"
|
|
||||||
android:title="@string/controlcenter_find_device"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_take_screenshot"
|
|
||||||
android:icon="@drawable/ic_screenshot"
|
|
||||||
android:title="@string/controlcenter_take_screenshot"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_delete_device"
|
|
||||||
android:icon="@drawable/ic_remove_device"
|
|
||||||
android:title="@string/controlcenter_delete_device"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/controlcenter_disconnect"
|
|
||||||
android:title="@string/controlcenter_disconnect"/>
|
|
||||||
</menu>
|
|
@ -1,16 +0,0 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenter">
|
|
||||||
<item android:id="@+id/action_settings" android:title="@string/action_settings"
|
|
||||||
android:orderInCategory="100" app:showAsAction="never" />
|
|
||||||
<item android:id="@+id/action_debug" android:title="@string/action_debug"
|
|
||||||
android:orderInCategory="100" app:showAsAction="never" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_db_management"
|
|
||||||
android:title="@string/action_db_management"
|
|
||||||
android:orderInCategory="100"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item android:id="@+id/action_quit" android:title="@string/action_quit"
|
|
||||||
android:orderInCategory="100" app:showAsAction="never" />
|
|
||||||
</menu>
|
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<changelog>
|
<changelog>
|
||||||
<release version="0.18.0" versioncode="87">
|
<release version="0.18.0" versioncode="87">
|
||||||
|
<change>All new GUI for the control center</change>
|
||||||
<change>Add Portuguese pt_PT and pt_BR translations</change>
|
<change>Add Portuguese pt_PT and pt_BR translations</change>
|
||||||
<change>Add Czech translation</change>
|
<change>Add Czech translation</change>
|
||||||
<change>Add Hebrew translation and transliteration</change>
|
<change>Add Hebrew translation and transliteration</change>
|
||||||
|
Loading…
Reference in New Issue
Block a user