mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-08 19:21:35 +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;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -166,11 +165,7 @@ public class LocalNodeInfoFragment extends Fragment
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.share_node_id:
|
||||
Intent shareIntent = new Intent();
|
||||
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)));
|
||||
RestApi.shareNodeId(getActivity(), mNodeId.getText().toString());
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -138,6 +138,7 @@ public class NodeSettingsActivity extends PreferenceActivity implements
|
|||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -156,8 +157,12 @@ public class NodeSettingsActivity extends PreferenceActivity implements
|
|||
mSyncthingService.getApi().editNode(mNode, true);
|
||||
finish();
|
||||
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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.nutomic.syncthingandroid.syncthing;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
|
@ -692,4 +693,16 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener {
|
|||
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"?>
|
||||
<menu
|
||||
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
|
||||
android:id="@+id/share_node_id"
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
<?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
|
||||
android:id="@+id/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>
|
Loading…
Reference in a new issue