Fixed notification error and warning fixes
This commit is contained in:
parent
be7ab36d13
commit
509fbd6293
@ -42,9 +42,6 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
|
||||||
})
|
|
||||||
|
|
||||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||||
compile 'com.android.support:design:25.3.1'
|
compile 'com.android.support:design:25.3.1'
|
||||||
|
@ -10,6 +10,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.content.pm.ShortcutManager;
|
import android.content.pm.ShortcutManager;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
@ -27,7 +28,7 @@ import org.itxtech.daedalus.util.RulesResolver;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +80,7 @@ public class Daedalus extends Application {
|
|||||||
|
|
||||||
public static String hostsPath;
|
public static String hostsPath;
|
||||||
public static String dnsmasqPath;
|
public static String dnsmasqPath;
|
||||||
public static String configPath;
|
private static String configPath;
|
||||||
|
|
||||||
private static Daedalus instance = null;
|
private static Daedalus instance = null;
|
||||||
private static SharedPreferences prefs;
|
private static SharedPreferences prefs;
|
||||||
@ -118,7 +119,7 @@ public class Daedalus extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final int REQUEST_EXTERNAL_STORAGE = 1;
|
public static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||||
public static String[] PERMISSIONS_STORAGE = {
|
public static final String[] PERMISSIONS_STORAGE = {
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
};
|
};
|
||||||
@ -218,14 +219,20 @@ public class Daedalus extends Application {
|
|||||||
.setLongLabel(notice)
|
.setLongLabel(notice)
|
||||||
.setShortLabel(notice)
|
.setShortLabel(notice)
|
||||||
.setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher))
|
.setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher))
|
||||||
.setIntent(new Intent(context, MainActivity.class).setAction(Intent.ACTION_VIEW).putExtra(MainActivity.LAUNCH_ACTION, activate ? MainActivity.LAUNCH_ACTION_ACTIVATE : MainActivity.LAUNCH_ACTION_DEACTIVATE))
|
.setIntent(new Intent(context, MainActivity.class).setAction(Intent.ACTION_VIEW)
|
||||||
|
.putExtra(MainActivity.LAUNCH_ACTION, activate ? MainActivity.LAUNCH_ACTION_ACTIVATE : MainActivity.LAUNCH_ACTION_DEACTIVATE))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(SHORTCUT_SERVICE);
|
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(SHORTCUT_SERVICE);
|
||||||
shortcutManager.addDynamicShortcuts(Arrays.asList(info));
|
shortcutManager.addDynamicShortcuts(Collections.singletonList(info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void donate() {
|
||||||
|
instance.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://qr.alipay.com/a6x07022gffiehykicipv1a"))
|
||||||
|
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK));
|
||||||
|
}
|
||||||
|
|
||||||
public static Daedalus getInstance() {
|
public static Daedalus getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
// Handle navigation view item clicks here.
|
// Handle navigation view item clicks here.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
|
@ -2,11 +2,13 @@ package org.itxtech.daedalus.fragment;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.VpnService;
|
import android.net.VpnService;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -83,6 +85,36 @@ public class MainFragment extends Fragment {
|
|||||||
} else {
|
} else {
|
||||||
onActivityResult(0, Activity.RESULT_OK, null);
|
onActivityResult(0, Activity.RESULT_OK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long activateCounter = Daedalus.configurations.getActivateCounter();
|
||||||
|
if (activateCounter == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activateCounter++;
|
||||||
|
Daedalus.configurations.setActivateCounter(activateCounter);
|
||||||
|
if (activateCounter % 20 == 0) {
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle("觉得还不错?")
|
||||||
|
.setMessage("您的支持是我动力来源!\n请考虑为我买杯咖啡醒醒脑,甚至其他…… ;)")
|
||||||
|
.setPositiveButton("为我买杯咖啡", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Daedalus.donate();
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setMessage("感谢您的支持!;)\n我会再接再厉!")
|
||||||
|
.setPositiveButton("确认", null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNeutralButton("不再显示", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Daedalus.configurations.setActivateCounter(-1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("取消", null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onActivityResult(int request, int result, Intent data) {
|
public void onActivityResult(int request, int result, Intent data) {
|
||||||
|
@ -234,8 +234,9 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
|||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
if (time - lastUpdate >= 1000) {
|
if (time - lastUpdate >= 1000) {
|
||||||
lastUpdate = time;
|
lastUpdate = time;
|
||||||
Log.i(TAG, "notify");
|
if (notification != null) {
|
||||||
notification.setContentTitle(getResources().getString(R.string.notification_queries) + " " + String.valueOf(provider.getDnsQueryTimes()));
|
notification.setContentTitle(getResources().getString(R.string.notification_queries) + " " + String.valueOf(provider.getDnsQueryTimes()));
|
||||||
|
}
|
||||||
|
|
||||||
NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
manager.notify(NOTIFICATION_ACTIVATED, notification.build());
|
manager.notify(NOTIFICATION_ACTIVATED, notification.build());
|
||||||
|
@ -30,6 +30,8 @@ public class Configurations {
|
|||||||
|
|
||||||
private int totalId;
|
private int totalId;
|
||||||
|
|
||||||
|
private long activateCounter;
|
||||||
|
|
||||||
int getNextId() {
|
int getNextId() {
|
||||||
if (totalId < CUSTOM_DNS_ID_START) {
|
if (totalId < CUSTOM_DNS_ID_START) {
|
||||||
totalId = CUSTOM_DNS_ID_START;
|
totalId = CUSTOM_DNS_ID_START;
|
||||||
@ -37,6 +39,14 @@ public class Configurations {
|
|||||||
return totalId++;
|
return totalId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getActivateCounter() {
|
||||||
|
return activateCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivateCounter(long activateCounter) {
|
||||||
|
this.activateCounter = activateCounter;
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<CustomDnsServer> getCustomDnsServers() {
|
public ArrayList<CustomDnsServer> getCustomDnsServers() {
|
||||||
if (customDnsServers == null) {
|
if (customDnsServers == null) {
|
||||||
customDnsServers = new ArrayList<>();
|
customDnsServers = new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user