forked from jens/Automation
control media playback
This commit is contained in:
parent
abaa961d3a
commit
0f1a12d28f
@ -66,7 +66,6 @@
|
||||
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.Manifest.permission.MEDIA_CONTENT_CONTROL" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
@ -143,18 +142,6 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<!-- Operation: MediaControl -->
|
||||
|
||||
<service
|
||||
android:name=".Actions$MediaControlHelperNotificationListenerService"
|
||||
android:label="@string/actionMediaControl"
|
||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.notification.NotificationListenerService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity android:name=".ActivityManageRule" />
|
||||
<activity android:name=".ActivityManageActionTriggerUrl" />
|
||||
<activity android:name=".ActivityDisplayLongMessage" />
|
||||
@ -170,6 +157,7 @@
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -155,6 +155,7 @@
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -149,6 +149,7 @@
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -18,7 +18,7 @@ public class Action
|
||||
Rule parentRule = null;
|
||||
|
||||
public static final String actionParameter2Split = "ap2split";
|
||||
public static final String intentPairSeperator = "intPairSplit";
|
||||
public static final String intentPairSeparator = "intPairSplit";
|
||||
public static final String vibrateSeparator = ",";
|
||||
|
||||
public enum Action_Enum {
|
||||
@ -42,7 +42,7 @@ public class Action
|
||||
setDataConnection,
|
||||
speakText,
|
||||
playMusic,
|
||||
controlMediaPlayback,
|
||||
controlMediaPlayback,
|
||||
setScreenBrightness,
|
||||
playSound,
|
||||
vibrate,
|
||||
@ -277,7 +277,7 @@ public class Action
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.startOtherActivity))
|
||||
{
|
||||
returnString.append(": " + parameter2.replace(Action.intentPairSeperator, "/"));
|
||||
returnString.append(": " + parameter2.replace(Action.intentPairSeparator, "/"));
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.sendTextMessage))
|
||||
{
|
||||
|
@ -1036,7 +1036,7 @@ public class Actions
|
||||
// Pack intents
|
||||
for (int i = 3; i < params.length; i++)
|
||||
{
|
||||
String[] singleParam = params[i].split(Action.intentPairSeperator);
|
||||
String[] singleParam = params[i].split(Action.intentPairSeparator);
|
||||
|
||||
/*Class c = Class.forName(singleParam[0]);
|
||||
for(Method m : c.getMethods())
|
||||
@ -1493,16 +1493,7 @@ public class Actions
|
||||
break;
|
||||
}
|
||||
|
||||
// AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
// if (mAudioManager.isMusicActive())
|
||||
// {
|
||||
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
// return controlMediaPlaybackFromApi21(keyCode);
|
||||
// else
|
||||
// {
|
||||
return controlMediaByDispatch(keyCode);
|
||||
// return controlMediaPlaybackByBroadcast(keyCode);
|
||||
// }
|
||||
return controlMediaByDispatch(keyCode);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
@ -1515,63 +1506,6 @@ public class Actions
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean controlMediaPlaybackByBroadcast(int keyCode)
|
||||
{
|
||||
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
|
||||
context.sendOrderedBroadcast(intent, null);
|
||||
|
||||
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
|
||||
intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyCode);
|
||||
|
||||
context.sendOrderedBroadcast(intent, null);
|
||||
AutomationService.getInstance().sendBroadcast(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
static boolean controlMediaPlaybackFromApi21(int keyCode)
|
||||
{
|
||||
KeyEvent keyEvent_down = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
|
||||
KeyEvent keyEvent_up = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
|
||||
|
||||
ComponentName myNotificationListenerComponent = new ComponentName(context, MediaControlHelperNotificationListenerService.class);
|
||||
MediaSessionManager mediaSessionManager = ((MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE));
|
||||
|
||||
if (mediaSessionManager == null)
|
||||
{
|
||||
Log.e("controlMedia", "MediaSessionManager is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
List<MediaController> activeSessions = mediaSessionManager.getActiveSessions(myNotificationListenerComponent);
|
||||
if (activeSessions.size() > 0)
|
||||
{
|
||||
MediaController mediaController = activeSessions.get(0);
|
||||
mediaController.dispatchMediaButtonEvent(keyEvent_down);
|
||||
mediaController.dispatchMediaButtonEvent(keyEvent_up);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public static class MediaControlHelperNotificationListenerService extends NotificationListenerService
|
||||
{
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||
super.onNotificationPosted(sbn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationRemoved(StatusBarNotification sbn) {
|
||||
super.onNotificationRemoved(sbn);
|
||||
}
|
||||
}
|
||||
|
||||
private String getTransactionCode()
|
||||
{
|
||||
try
|
||||
|
@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ActivityControlCenter extends Activity
|
||||
{
|
||||
@ -347,7 +348,24 @@ public class ActivityControlCenter extends Activity
|
||||
systemInfoText.append("Device: " + android.os.Build.DEVICE + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Model: " + android.os.Build.MODEL + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Product: " + android.os.Build.PRODUCT + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Flavor: " + BuildConfig.FLAVOR);
|
||||
systemInfoText.append("Flavor: " + BuildConfig.FLAVOR + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Country: " + Miscellaneous.getUserCountry(Miscellaneous.getAnyContext()) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("OS language: " + Locale.getDefault().getDisplayName());
|
||||
|
||||
/*
|
||||
I've checked the Locale methods on my Android 4.1.2 device, and the results:
|
||||
|
||||
Locale.getDefault().getLanguage() ---> en
|
||||
Locale.getDefault().getISO3Language() ---> eng
|
||||
Locale.getDefault().getCountry() ---> US
|
||||
Locale.getDefault().getISO3Country() ---> USA
|
||||
Locale.getDefault().getDisplayCountry() ---> United States
|
||||
Locale.getDefault().getDisplayName() ---> English (United States)
|
||||
Locale.getDefault().toString() ---> en_US
|
||||
Locale.getDefault().getDisplayLanguage()---> English
|
||||
Locale.getDefault().toLanguageTag() ---> en-US
|
||||
*/
|
||||
|
||||
return systemInfoText.toString();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,112 @@
|
||||
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.RadioButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ActivityManageActionControlMedia extends Activity
|
||||
{
|
||||
RadioButton rbMediaPlayPause, rbMediaPlay, rbMediaPause, rbMediaStop, rbMediaPrevious, rbMediaNext;
|
||||
Button bSaveControlMediaAction;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_control_media);
|
||||
|
||||
rbMediaPlayPause = (RadioButton)findViewById(R.id.rbMediaPlayPause);
|
||||
rbMediaPlay = (RadioButton)findViewById(R.id.rbMediaPlay);
|
||||
rbMediaPause = (RadioButton)findViewById(R.id.rbMediaPause);
|
||||
rbMediaStop = (RadioButton)findViewById(R.id.rbMediaStop);
|
||||
rbMediaPrevious = (RadioButton)findViewById(R.id.rbMediaPrevious);
|
||||
rbMediaNext = (RadioButton)findViewById(R.id.rbMediaNext);
|
||||
|
||||
bSaveControlMediaAction = (Button)findViewById(R.id.bSaveControlMediaAction);
|
||||
|
||||
bSaveControlMediaAction.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(checkInput())
|
||||
{
|
||||
Intent answer = new Intent();
|
||||
|
||||
if(rbMediaPlayPause.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "0");
|
||||
else if(rbMediaPlay.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "1");
|
||||
else if(rbMediaPause.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "2");
|
||||
else if(rbMediaStop.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "3");
|
||||
else if(rbMediaPrevious.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "4");
|
||||
else if(rbMediaNext.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "5");
|
||||
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
String existing = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
|
||||
switch (existing)
|
||||
{
|
||||
case "0":
|
||||
rbMediaPlayPause.setChecked(true);
|
||||
break;
|
||||
case "1":
|
||||
rbMediaPlay.setChecked(true);
|
||||
break;
|
||||
case "2":
|
||||
rbMediaPause.setChecked(true);
|
||||
break;
|
||||
case "3":
|
||||
rbMediaStop.setChecked(true);
|
||||
break;
|
||||
case "4":
|
||||
rbMediaPrevious.setChecked(true);
|
||||
break;
|
||||
case "5":
|
||||
rbMediaNext.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean checkInput()
|
||||
{
|
||||
if(
|
||||
!rbMediaPlayPause.isChecked()
|
||||
&&
|
||||
!rbMediaPlay.isChecked()
|
||||
&&
|
||||
!rbMediaPause.isChecked()
|
||||
&&
|
||||
!rbMediaStop.isChecked()
|
||||
&&
|
||||
!rbMediaPrevious.isChecked()
|
||||
&&
|
||||
!rbMediaNext.isChecked()
|
||||
)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionControlMedia.this, getResources().getString(R.string.pleaseSelectActionValue), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -387,9 +387,9 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeperator))
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeperator), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
@ -403,9 +403,9 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeperator))
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeperator), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
@ -414,7 +414,7 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
return;
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeperator + etParameterName.getText().toString() + Action.intentPairSeperator + etParameterValue.getText().toString();
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
|
@ -116,6 +116,8 @@ public class ActivityManageRule extends Activity
|
||||
final static int requestCodeActionCreateNotificationEdit = 804;
|
||||
final static int requestCodeActionCloseNotificationAdd = 805;
|
||||
final static int requestCodeActionCloseNotificationEdit = 806;
|
||||
final static int requestCodeActionControlMediaAdd = 807;
|
||||
final static int requestCodeActionControlMediaEdit = 808;
|
||||
|
||||
public static ActivityManageRule getInstance()
|
||||
{
|
||||
@ -363,6 +365,11 @@ public class ActivityManageRule extends Activity
|
||||
activityEditVibrateIntent.putExtra("vibratePattern", a.getParameter2());
|
||||
startActivityForResult(activityEditVibrateIntent, requestCodeActionVibrateEdit);
|
||||
break;
|
||||
case controlMediaPlayback:
|
||||
Intent activityEditControlMediaIntent = new Intent(ActivityManageRule.this, ActivityManageActionControlMedia.class);
|
||||
activityEditControlMediaIntent.putExtra(ActivityManageRule.intentNameActionParameter2, a.getParameter2());
|
||||
startActivityForResult(activityEditControlMediaIntent, requestCodeActionControlMediaEdit);
|
||||
break;
|
||||
case createNotification:
|
||||
Intent activityEditCreateNotificationIntent = new Intent(ActivityManageRule.this, ActivityManageActionCreateNotification.class);
|
||||
String[] elements = a.getParameter2().split(Action.actionParameter2Split);
|
||||
@ -1416,6 +1423,16 @@ public class ActivityManageRule extends Activity
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionControlMediaAdd)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
newAction.setParentRule(ruleToEdit);
|
||||
newAction.setParameter2(data.getStringExtra(ActivityManageRule.intentNameActionParameter2));
|
||||
ruleToEdit.getActionSet().add(newAction);
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionCreateNotificationAdd)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
@ -1452,6 +1469,18 @@ public class ActivityManageRule extends Activity
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionControlMediaEdit)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||
|
||||
if(data.hasExtra(intentNameActionParameter2))
|
||||
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionCreateNotificationEdit)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
@ -1782,17 +1811,18 @@ public class ActivityManageRule extends Activity
|
||||
ruleToEdit.getActionSet().add(newAction);
|
||||
refreshActionList();
|
||||
}
|
||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.controlMediaPlayback.toString()))
|
||||
{
|
||||
newAction.setAction(Action_Enum.controlMediaPlayback);
|
||||
getActionControlMediaPlayback(ActivityManageRule.this).show();
|
||||
}
|
||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.vibrate.toString()))
|
||||
{
|
||||
newAction.setAction(Action_Enum.vibrate);
|
||||
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionVibrate.class);
|
||||
startActivityForResult(intent, requestCodeActionVibrateAdd);
|
||||
}
|
||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.controlMediaPlayback.toString()))
|
||||
{
|
||||
newAction.setAction(Action_Enum.controlMediaPlayback);
|
||||
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionControlMedia.class);
|
||||
startActivityForResult(intent, requestCodeActionControlMediaAdd);
|
||||
}
|
||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.createNotification.toString()))
|
||||
{
|
||||
newAction.setAction(Action_Enum.createNotification);
|
||||
@ -2030,34 +2060,6 @@ public class ActivityManageRule extends Activity
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
private AlertDialog getActionControlMediaPlayback(final Context myContext)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||
alertDialogBuilder.setTitle(myContext.getResources().getString(R.string.selectCommand));
|
||||
final String choices[] = {
|
||||
myContext.getString(R.string.playPause),
|
||||
myContext.getString(R.string.play),
|
||||
myContext.getString(R.string.pause),
|
||||
myContext.getString(R.string.stop),
|
||||
myContext.getString(R.string.previous),
|
||||
myContext.getString(R.string.next)
|
||||
};
|
||||
alertDialogBuilder.setItems(choices, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
newAction.setParameter2(String.valueOf(which));
|
||||
|
||||
ruleToEdit.getActionSet().add(newAction);
|
||||
refreshActionList();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
protected void refreshTriggerList()
|
||||
{
|
||||
Miscellaneous.logEvent("i", "ListView", "Attempting to update TriggerListView", 4);
|
||||
|
@ -530,7 +530,7 @@ public class ActivityPermissions extends Activity
|
||||
case playMusic:
|
||||
break;
|
||||
case controlMediaPlayback:
|
||||
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||
// addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||
// addToArrayListUnique(Manifest.permission.MEDIA_CONTENT_CONTROL, requiredPermissions);
|
||||
break;
|
||||
case sendTextMessage:
|
||||
|
@ -27,6 +27,7 @@ import android.os.IBinder;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
@ -84,6 +85,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
@ -1719,4 +1721,37 @@ public class Miscellaneous extends Service
|
||||
{
|
||||
return arraySearch(requestList.toArray(new String[requestList.size()]), needle, caseSensitive, matchFullLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ISO 3166-1 alpha-2 country code for this device (or null if not available)
|
||||
* @param context Context reference to get the TelephonyManager instance from
|
||||
* @return country code or null
|
||||
*/
|
||||
public static String getUserCountry(Context context) {
|
||||
try
|
||||
{
|
||||
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
final String simCountry = tm.getSimCountryIso();
|
||||
if (simCountry != null && simCountry.length() == 2)
|
||||
{ // SIM country code is available
|
||||
return simCountry.toLowerCase(Locale.US);
|
||||
}
|
||||
else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA)
|
||||
{ // device is not 3G (would be unreliable)
|
||||
String networkCountry = tm.getNetworkCountryIso();
|
||||
if (networkCountry != null && networkCountry.length() == 2)
|
||||
{ // network country code is available
|
||||
return networkCountry.toLowerCase(Locale.US);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SecurityException se)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
catch (Exception e)
|
||||
{ }
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1284,14 +1284,14 @@ public class XmlFileInterface
|
||||
{
|
||||
String newTag;
|
||||
|
||||
if(tag.contains(Action.intentPairSeperator)) // already has new format
|
||||
if(tag.contains(Action.intentPairSeparator)) // already has new format
|
||||
newTag = tag;
|
||||
else
|
||||
newTag = tag.replace("/", Action.intentPairSeperator);
|
||||
newTag = tag.replace("/", Action.intentPairSeparator);
|
||||
|
||||
String[] newTagPieces = newTag.split(";");
|
||||
|
||||
if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeperator)))
|
||||
if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeparator)))
|
||||
{
|
||||
newTag = Actions.dummyPackageString + ";" + newTag;
|
||||
newTagPieces = newTag.split(";");
|
||||
@ -1301,7 +1301,7 @@ public class XmlFileInterface
|
||||
newTag += ";" + ActivityManageActionStartActivity.startByActivityString;
|
||||
else if(newTagPieces.length >= 3)
|
||||
{
|
||||
if(newTagPieces[2].contains(Action.intentPairSeperator))
|
||||
if(newTagPieces[2].contains(Action.intentPairSeparator))
|
||||
newTag = newTagPieces[0] + ";" + newTagPieces[1] + ";" + ActivityManageActionStartActivity.startByActivityString + ";" + newTagPieces[2];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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:layout_span="2"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/actionMediaControl" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/actionMediaControlNotice" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPlayPause"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/playPause" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPlay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/play" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPause"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pause" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaStop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stop" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPrevious"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaNext"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/next" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveControlMediaAction"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -669,4 +669,25 @@
|
||||
<string name="notificationCloseActionExplanation">Wenn Sie keine Kriterien angeben, werden ALLE Benachrichtigungen geschlossen. Es wird also empfohlen, zumindest eine Anwendung zu spezifizieren und/oder Titel oder Text anzugeben.</string>
|
||||
<string name="profileWarning">Die Einstellungen, die Sie hier vornehmen, können dazu führen, dass Sie bestimmte Dinge auf Ihrem Telefon nicht mehr mitbekommen. Sie können sogar Ihren Wecker zum Schweigen bringen. Was auch immer Sie hier einstellen - es wird empfohlen, es zu testen.</string>
|
||||
<string name="ifString">falls</string>
|
||||
<string name="pleaseSelectActionValue">Bitte wählen Sie eine Aktion!</string>
|
||||
<string name="android.permission.MEDIA_CONTENT_CONTROL">Medien steuern</string>
|
||||
<string name="play">abspielen</string>
|
||||
<string name="stop">stop</string>
|
||||
<string name="next">nächster</string>
|
||||
<string name="previous">vorheriger</string>
|
||||
<string name="pause">pausieren</string>
|
||||
<string name="playPause">abspielen/pause umschalten</string>
|
||||
<string name="selectCommand">Kommando auswählen</string>
|
||||
<string name="unlocked">entsperrt</string>
|
||||
<string name="on">an</string>
|
||||
<string name="off">aus</string>
|
||||
<string name="actionMediaControlNotice">Bedenken Sie, daß diese Aktion nicht notwendigerweise mit allen Playern funktioniert. Und selbst, wenn es mit einem grundsätzlich funktioniert, müssen auch nicht alle der u.g. Kommandos funktionieren.</string>
|
||||
<string name="screenState">Bildschirm Status</string>
|
||||
<string name="actionMediaControl">Medien steuern</string>
|
||||
<string name="selectDesiredState">Bitte gewünschten Zustand wählen</string>
|
||||
<string name="screenIs">Bildschirm ist %1$s</string>
|
||||
<string name="sendEmailToDev">Email an Entwickler schicken</string>
|
||||
<string name="controlCenter">Steuerungszentrale</string>
|
||||
<string name="emailContactNotice">Email ist mein bevorzugtes Kommunikationsmittel, um Fehler zu melden, Fragen zu stellen or Vorschläge zu machen. Bitte gehen Sie für weitere Infos in die Steuerungszentrale.</string>
|
||||
<string name="featureCeasedToWorkLastWorkingAndroidVersion">Aufgrund Google\'s unendlicher Weisheit, ist die letzte Android Version, mit der diese Funktion noch funktioniert, die Version %1$s. Sie können es hier einrichten, aber vermutlich wird es keine Auswirkung haben.</string>
|
||||
</resources>
|
@ -668,4 +668,25 @@
|
||||
<string name="comparisonCaseInsensitive">Las comparaciones se realizan sin distinción de mayúsculas y minúsculas</string>
|
||||
<string name="profileWarning">La configuración que realice aquí puede hacer que ya no note ciertas cosas de su teléfono. Incluso puede silenciar su alarma de despertar. Así que hagas lo que hagas, se recomienda que lo pruebes.</string>
|
||||
<string name="ifString">si</string>
|
||||
<string name="on">encendido</string>
|
||||
<string name="off">apagado</string>
|
||||
<string name="unlocked">desbloqueado</string>
|
||||
<string name="play">reproducir</string>
|
||||
<string name="pause">pausar</string>
|
||||
<string name="previous">ultimo</string>
|
||||
<string name="next">proximo</string>
|
||||
<string name="stop">parar</string>
|
||||
<string name="android.permission.MEDIA_CONTENT_CONTROL">Controlar la reproducción de medios</string>
|
||||
<string name="actionMediaControl">Controlar la reproducción de medios</string>
|
||||
<string name="pleaseSelectActionValue">Por favor elije una acción!</string>
|
||||
<string name="playPause">alternar reproducir/pausar</string>
|
||||
<string name="selectCommand">Elije el comando</string>
|
||||
<string name="screenState">Estado de la pantalla</string>
|
||||
<string name="selectDesiredState">Elije el estado deseado</string>
|
||||
<string name="controlCenter">Centro de control</string>
|
||||
<string name="screenIs">pantalla esta %1$s</string>
|
||||
<string name="sendEmailToDev">Enviar email al desrollador</string>
|
||||
<string name="featureCeasedToWorkLastWorkingAndroidVersion">Debido a la infinita sabiduría de Google, la última versión de Android en la que se sabe que funciona esta función es %1$s. Puede configurarlo, pero probablemente no tendrá ningún efecto.</string>
|
||||
<string name="emailContactNotice">El correo electrónico es mi método preferido de contacto para informar errores, hacer preguntas o hacer propuestas. Vaya al centro de control para obtener más información.</string>
|
||||
<string name="actionMediaControlNotice">Ten en cuenta que esta acción puede no funcionar con TODOS los jugadores. E incluso si lo hace, no todos los botones funcionan necesariamente.</string>
|
||||
</resources>
|
@ -669,4 +669,25 @@
|
||||
<string name="notificationCloseActionExplanation">Se non specifichi alcun criterio, questa azione chiuderà TUTTE le notifiche. Quindi si consiglia di specificare almeno i criteri per almeno 1 di applicazione, titolo o testo.</string>
|
||||
<string name="profileWarning">Le impostazioni che fai qui possono far sì che tu non noti più certe cose dal tuo telefono. Possono anche mettere a tacere la sveglia. Quindi, qualunque cosa tu faccia, ti consigliamo di testarlo.</string>
|
||||
<string name="ifString">se</string>
|
||||
<string name="actionMediaControlNotice">Tieni presente che questa azione potrebbe non funzionare con TUTTI i giocatori là fuori. E anche se lo fa, non tutti i pulsanti funzionano necessariamente.</string>
|
||||
<string name="pleaseSelectActionValue">Seleziona un\'azione!</string>
|
||||
<string name="stop">fermarsi</string>
|
||||
<string name="android.permission.MEDIA_CONTENT_CONTROL">Controllare la riproduzione multimediale</string>
|
||||
<string name="next">prossimo</string>
|
||||
<string name="previous">precedente</string>
|
||||
<string name="pause">pausa</string>
|
||||
<string name="play">giocare</string>
|
||||
<string name="playPause">attiva/disattiva riproduzione/pausa</string>
|
||||
<string name="selectCommand">Seleziona comando</string>
|
||||
<string name="actionMediaControl">Controllare la riproduzione multimediale</string>
|
||||
<string name="featureCeasedToWorkLastWorkingAndroidVersion">A causa della saggezza infinita di Google, l\'ultima versione di Android su cui questa funzione è nota per funzionare è %1 $s. Puoi configurarlo, ma probabilmente non avrà alcun effetto.</string>
|
||||
<string name="screenState">Stato dello schermo</string>
|
||||
<string name="selectDesiredState">Seleziona lo stato desiderato</string>
|
||||
<string name="unlocked">Sbloccato</string>
|
||||
<string name="off">spento</string>
|
||||
<string name="on">attivo</string>
|
||||
<string name="screenIs">lo schermo è %1$s</string>
|
||||
<string name="sendEmailToDev">Invia email allo sviluppatore</string>
|
||||
<string name="controlCenter">Centro di controllo</string>
|
||||
<string name="emailContactNotice">L\'e-mail è il mio metodo di contatto preferito per segnalare bug, porre domande o fare proposte. Vai al centro di controllo per saperne di più.</string>
|
||||
</resources>
|
||||
|
@ -667,4 +667,25 @@
|
||||
<string name="comparisonCaseInsensitive">Vergelijkingen worden gedaan case-INsensitief</string>
|
||||
<string name="profileWarning">De instellingen die je hier maakt kunnen ervoor zorgen dat je bepaalde dingen niet meer van je telefoon merkt. Ze kunnen zelfs je wekker dempen. Dus wat je ook doet - het wordt aanbevolen om het te testen.</string>
|
||||
<string name="ifString">als</string>
|
||||
<string name="emailContactNotice">E-mail is mijn favoriete contactmethode om bugs te melden, vragen te stellen of voorstellen te doen. Ga naar het controlecentrum voor meer informatie.</string>
|
||||
<string name="controlCenter">Controlecentrum</string>
|
||||
<string name="sendEmailToDev">Stuur een e-mail naar de ontwikkelaar</string>
|
||||
<string name="screenIs">scherm is %1$s</string>
|
||||
<string name="on">op</string>
|
||||
<string name="off">af</string>
|
||||
<string name="unlocked">ontgrendeld</string>
|
||||
<string name="selectDesiredState">Selecteer de gewenste status</string>
|
||||
<string name="screenState">Schermstatus</string>
|
||||
<string name="featureCeasedToWorkLastWorkingAndroidVersion">Vanwege de oneindige wijsheid van Google is de laatste Android-versie waarvan bekend is dat deze functie werkt% 1 $ s. U kunt het configureren, maar het zal waarschijnlijk geen effect hebben.</string>
|
||||
<string name="actionMediaControl">Het afspelen van media regelen</string>
|
||||
<string name="selectCommand">Opdracht Selecteren</string>
|
||||
<string name="playPause">schakelaar afspelen/pauzeren</string>
|
||||
<string name="play">afspelen</string>
|
||||
<string name="pause">pauzeren</string>
|
||||
<string name="previous">vorig</string>
|
||||
<string name="next">volgend</string>
|
||||
<string name="android.permission.MEDIA_CONTENT_CONTROL">Het afspelen van media regelen</string>
|
||||
<string name="stop">stoppen</string>
|
||||
<string name="pleaseSelectActionValue">Selecteer een actie!</string>
|
||||
<string name="actionMediaControlNotice">Houd er rekening mee dat deze actie mogelijk niet werkt met ALLE spelers die er zijn. En zelfs als dat zo is, werkt niet elke knop noodzakelijkerwijs.</string>
|
||||
</resources>
|
||||
|
@ -782,6 +782,8 @@
|
||||
<string name="pause">pause</string>
|
||||
<string name="previous">previous</string>
|
||||
<string name="next">next</string>
|
||||
<string name="android.permission.MEDIA_CONTENT_CONTROL">Control media</string>
|
||||
<string name="android.permission.MEDIA_CONTENT_CONTROL">Control media playback</string>
|
||||
<string name="stop">stop</string>
|
||||
<string name="pleaseSelectActionValue">Please select an action!</string>
|
||||
<string name="actionMediaControlNotice">Keep in mind that this action may not work with ALL players out there. And even if it does, not every buttons does necessarily work.</string>
|
||||
</resources>
|
@ -1,6 +1,7 @@
|
||||
* New trigger: screen state (on/off)
|
||||
* New action: Create notification
|
||||
* New action: Close notification(s)
|
||||
* New action: Control media playback
|
||||
* Fixed: Translation bug in dutch variables text
|
||||
* Fixed: Variables were not replaced when sending text messages
|
||||
* Fixed: Service wouldn't always start after device is powered on
|
||||
* Fixed: Service wouldn't always start after device has been powered on
|
Loading…
Reference in New Issue
Block a user