forked from jens/Automation
copy to clipboard action
This commit is contained in:
parent
ebb0724b28
commit
7c42250e13
@ -176,6 +176,7 @@
|
|||||||
<activity android:name=".ActivityManageActionMakePhoneCall" />
|
<activity android:name=".ActivityManageActionMakePhoneCall" />
|
||||||
<activity android:name=".ActivityManageActionSetVariable" />
|
<activity android:name=".ActivityManageActionSetVariable" />
|
||||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||||
|
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ActivityMainTabLayout"
|
android:name=".ActivityMainTabLayout"
|
||||||
|
@ -174,6 +174,7 @@
|
|||||||
<activity android:name=".ActivityManageMakePhoneCall" />
|
<activity android:name=".ActivityManageMakePhoneCall" />
|
||||||
<activity android:name=".ActivityManageActionSetVariable" />
|
<activity android:name=".ActivityManageActionSetVariable" />
|
||||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||||
|
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ActivityMainTabLayout"
|
android:name=".ActivityMainTabLayout"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
|
@ -160,6 +160,7 @@
|
|||||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||||
<activity android:name=".ActivityManageActionSetVariable" />
|
<activity android:name=".ActivityManageActionSetVariable" />
|
||||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||||
|
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ActivityMainTabLayout"
|
android:name=".ActivityMainTabLayout"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
@ -55,6 +55,7 @@ public class Action
|
|||||||
setVariable,
|
setVariable,
|
||||||
startPhoneCall,
|
startPhoneCall,
|
||||||
stopPhoneCall,
|
stopPhoneCall,
|
||||||
|
copyToClipboard,
|
||||||
sendTextMessage;
|
sendTextMessage;
|
||||||
|
|
||||||
public String getFullName(Context context)
|
public String getFullName(Context context)
|
||||||
@ -137,6 +138,8 @@ public class Action
|
|||||||
return context.getResources().getString(R.string.startPhoneCall);
|
return context.getResources().getString(R.string.startPhoneCall);
|
||||||
case stopPhoneCall:
|
case stopPhoneCall:
|
||||||
return context.getResources().getString(R.string.endPhoneCall);
|
return context.getResources().getString(R.string.endPhoneCall);
|
||||||
|
case copyToClipboard:
|
||||||
|
return context.getResources().getString(R.string.copyTextToClipboard);
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
@ -302,6 +305,8 @@ public class Action
|
|||||||
case stopPhoneCall:
|
case stopPhoneCall:
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.endPhoneCall));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.endPhoneCall));
|
||||||
break;
|
break;
|
||||||
|
case copyToClipboard:
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.copyTextToClipboard));
|
||||||
default:
|
default:
|
||||||
returnString.append(action.toString());
|
returnString.append(action.toString());
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -2297,4 +2299,12 @@ public class Actions
|
|||||||
mgr.endCall();
|
mgr.endCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void copyToClipboard(Context context, String text)
|
||||||
|
{
|
||||||
|
ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText(text, url);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.jens.automation2;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class ActivityManageActionCopyToClipboard extends Activity
|
||||||
|
{
|
||||||
|
private Button bSaveCopyToClipboard;
|
||||||
|
private EditText etCopyToClipboard;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
this.setContentView(R.layout.activity_manage_action_copy_to_clipboard);
|
||||||
|
|
||||||
|
bSaveCopyToClipboard = (Button) findViewById(R.id.bSaveCopyToClipboard);
|
||||||
|
etCopyToClipboard = (EditText)findViewById(R.id.etCopyToClipboard);
|
||||||
|
|
||||||
|
bSaveCopyToClipboard.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
if(StringUtils.isEmpty(etCopyToClipboard.getText().toString()))
|
||||||
|
{
|
||||||
|
Toast.makeText(ActivityManageActionCopyToClipboard.this, getResources().getString(R.string.enterText), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Intent response = new Intent();
|
||||||
|
response.putExtra(ActivityManageRule.intentNameActionParameter2, etCopyToClipboard.getText().toString());
|
||||||
|
setResult(RESULT_OK, response);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||||
|
{
|
||||||
|
String text = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2);
|
||||||
|
etCopyToClipboard.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -139,6 +139,8 @@ public class ActivityManageRule extends Activity
|
|||||||
final static int requestCodeActionSetVariableEdit = 826;
|
final static int requestCodeActionSetVariableEdit = 826;
|
||||||
final static int requestCodeTriggerCheckVariableAdd = 827;
|
final static int requestCodeTriggerCheckVariableAdd = 827;
|
||||||
final static int requestCodeTriggerCheckVariableEdit = 828;
|
final static int requestCodeTriggerCheckVariableEdit = 828;
|
||||||
|
final static int requestCodeActionCopyTextToClipboardAdd = 829;
|
||||||
|
final static int requestCodeActionCopyTextToClipboardEdit = 830;
|
||||||
|
|
||||||
public static ActivityManageRule getInstance()
|
public static ActivityManageRule getInstance()
|
||||||
{
|
{
|
||||||
@ -469,6 +471,12 @@ public class ActivityManageRule extends Activity
|
|||||||
actionPlaySoundIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
actionPlaySoundIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundEdit);
|
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundEdit);
|
||||||
break;
|
break;
|
||||||
|
case copyToClipboard:
|
||||||
|
Intent actionCopyToClipboardIntent = new Intent(context, ActivityManageActionCopyToClipboard.class);
|
||||||
|
actionCopyToClipboardIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
|
actionCopyToClipboardIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
|
startActivityForResult(actionCopyToClipboardIntent, requestCodeActionCopyTextToClipboardEdit);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Miscellaneous.logEvent("w", "Edit action", "Editing of action type " + a.getAction().toString() + " not implemented, yet.", 4);
|
Miscellaneous.logEvent("w", "Edit action", "Editing of action type " + a.getAction().toString() + " not implemented, yet.", 4);
|
||||||
break;
|
break;
|
||||||
@ -2016,6 +2024,17 @@ public class ActivityManageRule extends Activity
|
|||||||
this.refreshTriggerList();
|
this.refreshTriggerList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(requestCode == requestCodeActionCopyTextToClipboardAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newAction.setParentRule(ruleToEdit);
|
||||||
|
newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AlertDialog getActionTypeDialog()
|
protected AlertDialog getActionTypeDialog()
|
||||||
@ -2310,6 +2329,12 @@ public class ActivityManageRule extends Activity
|
|||||||
Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class);
|
Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class);
|
||||||
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundAdd);
|
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundAdd);
|
||||||
}
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.copyToClipboard.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.copyToClipboard);
|
||||||
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCopyToClipboard.class);
|
||||||
|
startActivityForResult(intent, requestCodeActionCopyTextToClipboardAdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/textToCopy" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etCopyToClipboard"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="textShortMessage|textMultiLine" >
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTextMessageAnnotations"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:text="@string/textMessageAnnotations" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLegend"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/urlLegend" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/attachment" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bSaveCopyToClipboard"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -880,4 +880,6 @@
|
|||||||
<string name="displayLanguage">Display language</string>
|
<string name="displayLanguage">Display language</string>
|
||||||
<string name="displayLanguageSummary">Set a custom language for the application</string>
|
<string name="displayLanguageSummary">Set a custom language for the application</string>
|
||||||
<string name="wifiMonitoringAlsoRequiresThis">This permission is also required if the trigger is using the current wifi connection.</string>
|
<string name="wifiMonitoringAlsoRequiresThis">This permission is also required if the trigger is using the current wifi connection.</string>
|
||||||
|
<string name="copyTextToClipboard">Copy text to clipboard</string>
|
||||||
|
<string name="textToCopy">Text to copy</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user