Этот коммит содержится в:
Anton Tananaev
2015-09-03 15:16:20 +12:00
родитель 603e7bb3e0
Коммит 140a3ebece
6 изменённых файлов: 78 добавлений и 5 удалений
+9 -1
Просмотреть файл
@@ -2,10 +2,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<application
android:label="@string/app_name_hidden"
android:label="@string/hidden_app_name"
tools:replace="label">
<receiver android:name=".DialLaunchReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
+6 -3
Просмотреть файл
@@ -16,13 +16,16 @@
android:label="@string/app_name"
android:theme="@style/TraccarTheme">
<activity android:name=".MainActivity"
android:launchMode="singleTask">
<activity android:name=".MainActivity" android:launchMode="singleTask" />
<activity-alias
android:name=".Launcher"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</activity-alias>
<activity android:name=".StatusActivity"/>
+37
Просмотреть файл
@@ -0,0 +1,37 @@
/*
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.traccar.client;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class DialLaunchReceiver extends BroadcastReceiver {
private static final String LAUNCHER_NUMBER = "8722227"; // TRACCAR
@Override
public void onReceive(Context context, Intent intent) {
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (phoneNumber.equals(LAUNCHER_NUMBER)) {
setResultData(null);
Intent appIntent = new Intent(context, MainActivity.class);
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(appIntent);
}
}
}
+21
Просмотреть файл
@@ -18,6 +18,7 @@ package org.traccar.client;
import android.Manifest;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -59,6 +60,11 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (BuildConfig.HIDDEN_APP) {
removeLauncherIcon();
}
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
addPreferencesFromResource(R.xml.preferences);
initPreferences();
@@ -68,6 +74,21 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
}
}
private void removeLauncherIcon() {
ComponentName componentName = new ComponentName(getPackageName(), getPackageName() + ".Launcher");
PackageManager packageManager = getPackageManager();
if (packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
packageManager.setComponentEnabledSetting(
componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.hidden_alert));
builder.setPositiveButton(android.R.string.ok, null);
builder.show();
}
}
private boolean hasPermission(String permission) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
return true;
+3 -1
Просмотреть файл
@@ -2,7 +2,6 @@
<resources>
<string name="app_name">Traccar Client</string>
<string name="app_name_hidden">Device Settings</string>
<string name="app_logo">Traccar</string>
<string name="settings_id_title">Device identifier</string>
@@ -41,4 +40,7 @@
<string name="status_location_update">Location update</string>
<string name="status_connectivity_change">Connectivity change</string>
<string name="hidden_app_name">Device Settings</string>
<string name="hidden_alert">The app has been hidden from the phone launcher. To open it again please dial 8722227 (TRACCAR).</string>
</resources>