mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 09:58:08 +00:00
Merge pull request #2 from LukeStonehm/master
Use 'ActionBarDrawerToggle'
This commit is contained in:
commit
278a358b71
@ -161,4 +161,7 @@
|
|||||||
<string name="findmyphone_title">Find My Phone</string>
|
<string name="findmyphone_title">Find My Phone</string>
|
||||||
<string name="findmyphone_description">Rings this phone so you can find it.</string>
|
<string name="findmyphone_description">Rings this phone so you can find it.</string>
|
||||||
<string name="findmyphone_found">Found</string>
|
<string name="findmyphone_found">Found</string>
|
||||||
|
|
||||||
|
<string name="open">Open</string>
|
||||||
|
<string name="close">Close</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -13,6 +13,7 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -39,6 +40,7 @@ public class MaterialActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private NavigationView mNavigationView;
|
private NavigationView mNavigationView;
|
||||||
private DrawerLayout mDrawerLayout;
|
private DrawerLayout mDrawerLayout;
|
||||||
|
private ActionBarDrawerToggle mDrawerToggle;
|
||||||
|
|
||||||
private String mCurrentDevice;
|
private String mCurrentDevice;
|
||||||
|
|
||||||
@ -57,10 +59,19 @@ public class MaterialActivity extends AppCompatActivity {
|
|||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
|
|
||||||
|
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
|
||||||
|
mDrawerLayout, /* DrawerLayout object */
|
||||||
|
R.string.open, /* "open drawer" description */
|
||||||
|
R.string.close /* "close drawer" description */
|
||||||
|
);
|
||||||
|
|
||||||
|
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||||
|
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||||
|
mDrawerToggle.syncState();
|
||||||
|
|
||||||
String deviceName = DeviceHelper.getDeviceName(this);
|
String deviceName = DeviceHelper.getDeviceName(this);
|
||||||
TextView nameView = (TextView) mDrawerLayout.findViewById(R.id.device_name);
|
TextView nameView = (TextView) mDrawerLayout.findViewById(R.id.device_name);
|
||||||
@ -96,7 +107,7 @@ public class MaterialActivity extends AppCompatActivity {
|
|||||||
Log.i("MaterialActivity", "Loading selected device from saved activity state");
|
Log.i("MaterialActivity", "Loading selected device from saved activity state");
|
||||||
savedDevice = savedInstanceState.getString(STATE_SELECTED_DEVICE);
|
savedDevice = savedInstanceState.getString(STATE_SELECTED_DEVICE);
|
||||||
} else {
|
} else {
|
||||||
Log.i("MaterialActivity","Loading selected device from persistent storage");
|
Log.i("MaterialActivity", "Loading selected device from persistent storage");
|
||||||
savedDevice = preferences.getString(STATE_SELECTED_DEVICE, null);
|
savedDevice = preferences.getString(STATE_SELECTED_DEVICE, null);
|
||||||
}
|
}
|
||||||
onDeviceSelected(savedDevice);
|
onDeviceSelected(savedDevice);
|
||||||
@ -195,7 +206,7 @@ public class MaterialActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
preferences.edit().putString(STATE_SELECTED_DEVICE, mCurrentDevice).apply();
|
preferences.edit().putString(STATE_SELECTED_DEVICE, mCurrentDevice).apply();
|
||||||
|
|
||||||
for(HashMap.Entry<MenuItem, String> entry : mMapMenuToDeviceId.entrySet()) {
|
for (HashMap.Entry<MenuItem, String> entry : mMapMenuToDeviceId.entrySet()) {
|
||||||
boolean selected = TextUtils.equals(entry.getValue(), deviceId); //null-safe
|
boolean selected = TextUtils.equals(entry.getValue(), deviceId); //null-safe
|
||||||
entry.getKey().setChecked(selected);
|
entry.getKey().setChecked(selected);
|
||||||
}
|
}
|
||||||
@ -232,8 +243,7 @@ public class MaterialActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode)
|
switch (requestCode) {
|
||||||
{
|
|
||||||
case RESULT_NEEDS_RELOAD:
|
case RESULT_NEEDS_RELOAD:
|
||||||
BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
|
BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user