-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Wolfsohn
committed
Oct 5, 2019
1 parent
8388905
commit d20bcbe
Showing
15 changed files
with
413 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":3,"versionName":"1.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"1.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:toolsNs="http://schemas.android.com/tools" | ||
package="com.jpwolfso.privdnsqt"> | ||
|
||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" toolsNs:ignore="ProtectedPermissions"/> | ||
<uses-permission | ||
android:name="android.permission.WRITE_SECURE_SETTINGS" | ||
toolsNs:ignore="ProtectedPermissions" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@android:style/Theme.Translucent.NoTitleBar"> | ||
|
||
<service | ||
android:name=".PrivateDnsTileService" | ||
android:enabled="true" | ||
android:exported="true" | ||
android:icon="@drawable/ic_dnsauto" | ||
android:label="@string/qt_default" | ||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> | ||
<intent-filter> | ||
<action android:name="android.service.quicksettings.action.QS_TILE" /> | ||
</intent-filter> | ||
</service> | ||
android:theme="@android:style/Theme.DeviceDefault.Dialog"> | ||
|
||
<activity | ||
android:name=".HelperActivity" | ||
android:name=".PrivateDnsConfigActivity" | ||
android:excludeFromRecents="true" | ||
android:noHistory="true"> | ||
android:label="Private DNS Quick Tile Modes"> | ||
<intent-filter> | ||
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
|
||
<service | ||
android:name=".PrivateDnsTileService" | ||
android:enabled="true" | ||
android:exported="true" | ||
android:icon="@drawable/ic_dnsauto" | ||
android:label="@string/qt_default" | ||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> | ||
<intent-filter> | ||
<action android:name="android.service.quicksettings.action.QS_TILE" /> | ||
</intent-filter> | ||
</service> | ||
|
||
</application> | ||
|
||
</manifest> | ||
|
||
</manifest> |
19 changes: 0 additions & 19 deletions
19
app/src/main/java/com/jpwolfso/privdnsqt/HelperActivity.java
This file was deleted.
Oops, something went wrong.
118 changes: 118 additions & 0 deletions
118
app/src/main/java/com/jpwolfso/privdnsqt/PrivateDnsConfigActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package com.jpwolfso.privdnsqt; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.content.pm.PackageManager; | ||
import android.os.Bundle; | ||
import android.provider.Settings; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.CheckBox; | ||
import android.widget.CompoundButton; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
public class PrivateDnsConfigActivity extends Activity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_private_dns_config); | ||
|
||
final SharedPreferences togglestates = getSharedPreferences("togglestates", Context.MODE_PRIVATE); | ||
final SharedPreferences.Editor editor = togglestates.edit(); | ||
|
||
final CheckBox checkoff = findViewById(R.id.check_off); | ||
final CheckBox checkauto = findViewById(R.id.check_auto); | ||
final CheckBox checkon = findViewById(R.id.check_on); | ||
|
||
final EditText texthostname = findViewById(R.id.text_hostname); | ||
|
||
final Button okbutton = findViewById(R.id.button_ok); | ||
|
||
if (togglestates.getBoolean("toggle_off", true)) { | ||
checkoff.setChecked(true); | ||
} | ||
|
||
if (togglestates.getBoolean("toggle_auto", true)) { | ||
checkauto.setChecked(true); | ||
} | ||
|
||
if (togglestates.getBoolean("toggle_on", true)) { | ||
checkon.setChecked(true); | ||
texthostname.setEnabled(true); | ||
} else { | ||
texthostname.setEnabled(false); | ||
|
||
} | ||
|
||
String dnsprovider = Settings.Global.getString(getContentResolver(), "private_dns_specifier"); | ||
if (dnsprovider != null) { | ||
texthostname.setText(dnsprovider); | ||
} | ||
|
||
checkoff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | ||
@Override | ||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | ||
if (checkoff.isChecked()) { | ||
editor.putBoolean("toggle_off", true); | ||
} else { | ||
editor.putBoolean("toggle_off", false); | ||
} | ||
} | ||
}); | ||
|
||
checkauto.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | ||
@Override | ||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | ||
if (checkauto.isChecked()) { | ||
editor.putBoolean("toggle_auto", true); | ||
} else { | ||
editor.putBoolean("toggle_auto", false); | ||
} | ||
} | ||
}); | ||
|
||
checkon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | ||
@Override | ||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | ||
if (checkon.isChecked()) { | ||
editor.putBoolean("toggle_on", true); | ||
texthostname.setEnabled(true); | ||
} else { | ||
editor.putBoolean("toggle_on", false); | ||
texthostname.setEnabled(false); | ||
} | ||
} | ||
}); | ||
|
||
okbutton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (hasPermission()) { | ||
if (checkon.isChecked()) { | ||
if (texthostname.getText().toString().isEmpty()) { | ||
Toast.makeText(PrivateDnsConfigActivity.this, "DNS provider not configured", Toast.LENGTH_SHORT).show(); | ||
return; | ||
} else { | ||
Settings.Global.putString(getContentResolver(), "private_dns_specifier", texthostname.getText().toString()); | ||
} | ||
} | ||
editor.commit(); | ||
finish(); | ||
} else { | ||
Toast.makeText(PrivateDnsConfigActivity.this, getString(R.string.toast_permission), Toast.LENGTH_SHORT).show(); | ||
return; | ||
} | ||
} | ||
}); | ||
|
||
|
||
} | ||
|
||
public boolean hasPermission() { | ||
return checkCallingOrSelfPermission("android.permission.WRITE_SECURE_SETTINGS") != PackageManager.PERMISSION_DENIED; | ||
} | ||
|
||
} |
Oops, something went wrong.