mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-09 19:53:33 +00:00
Share node id from node settings.
This commit is contained in:
parent
505673bf71
commit
505ec379b6
5 changed files with 31 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
||||||
package com.nutomic.syncthingandroid.gui;
|
package com.nutomic.syncthingandroid.gui;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActionBarDrawerToggle;
|
import android.support.v4.app.ActionBarDrawerToggle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -166,11 +165,7 @@ public class LocalNodeInfoFragment extends Fragment
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.share_node_id:
|
case R.id.share_node_id:
|
||||||
Intent shareIntent = new Intent();
|
RestApi.shareNodeId(getActivity(), mNodeId.getText().toString());
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
|
||||||
shareIntent.setType("text/plain");
|
|
||||||
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mNodeId.getText().toString());
|
|
||||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.send_node_id_to)));
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
|
@ -138,6 +138,7 @@ public class NodeSettingsActivity extends PreferenceActivity implements
|
||||||
@Override
|
@Override
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
menu.findItem(R.id.create).setVisible(getIntent().getAction().equals(ACTION_CREATE));
|
menu.findItem(R.id.create).setVisible(getIntent().getAction().equals(ACTION_CREATE));
|
||||||
|
menu.findItem(R.id.share_node_id).setVisible(getIntent().getAction().equals(ACTION_EDIT));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,9 +157,13 @@ public class NodeSettingsActivity extends PreferenceActivity implements
|
||||||
mSyncthingService.getApi().editNode(mNode, true);
|
mSyncthingService.getApi().editNode(mNode, true);
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
case R.id.share_node_id:
|
||||||
|
RestApi.shareNodeId(this, mNode.NodeID);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nutomic.syncthingandroid.syncthing;
|
package com.nutomic.syncthingandroid.syncthing;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -692,4 +693,16 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener {
|
||||||
return mAvailableCount.get() == TOTAL_STARTUP_CALLS;
|
return mAvailableCount.get() == TOTAL_STARTUP_CALLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shares the given node id via Intent. Must be called from an Activity.
|
||||||
|
*/
|
||||||
|
public static void shareNodeId(Activity activity, String id) {
|
||||||
|
Intent shareIntent = new Intent();
|
||||||
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
shareIntent.setType("text/plain");
|
||||||
|
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, id);
|
||||||
|
activity.startActivity(Intent.createChooser(
|
||||||
|
shareIntent, activity.getString(R.string.send_node_id_to)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu
|
<menu
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/share_node_id"
|
android:id="@+id/share_node_id"
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/create"
|
android:id="@+id/create"
|
||||||
android:title="@string/create" />
|
android:title="@string/create" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/share_node_id"
|
||||||
|
android:icon="@android:drawable/ic_menu_share"
|
||||||
|
android:title="@string/share_node_id"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in a new issue