-
Notifications
You must be signed in to change notification settings - Fork 33
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
Showing
14 changed files
with
106 additions
and
138 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
.DS_Store | ||
/build | ||
/captures | ||
.idea/ | ||
.idea | ||
signing.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,42 +1,42 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
compileSdkVersion 28 | ||
|
||
defaultConfig { | ||
applicationId "rikka.smscodehelper" | ||
minSdkVersion 15 | ||
targetSdkVersion 23 | ||
versionCode 10006 | ||
versionName "1.0.7" | ||
targetSdkVersion 28 | ||
versionCode 10008 | ||
versionName "1.0.8" | ||
} | ||
signingConfigs { | ||
sign | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
buildTypes { | ||
debug { | ||
signingConfig signingConfigs.sign | ||
} | ||
release { | ||
minifyEnabled false | ||
signingConfig signingConfigs.sign | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
testOptions { | ||
unitTests.returnDefaultValues = true | ||
} | ||
} | ||
|
||
applicationVariants.all { variant -> | ||
variant.outputs.each { output -> | ||
if (output.outputFile != null && output.outputFile.name.endsWith('.apk')) { | ||
output.outputFile = file("${output.outputFile.parent}/smscodehelper" + | ||
"-${variant.buildType.name.toLowerCase()}" + | ||
"-${variant.versionName}" + | ||
".apk") | ||
} | ||
} | ||
android.applicationVariants.all { variant -> | ||
variant.outputs.all { | ||
outputFileName = "sms-code-helper-${variant.versionCode}.apk" | ||
} | ||
} | ||
|
||
apply from: rootProject.file('signing.gradle') | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
// Unit testing dependencies | ||
testCompile 'junit:junit:4.12' | ||
testCompile "org.mockito:mockito-core:1.9.5" | ||
compile 'com.android.support:appcompat-v7:23.1.1' | ||
} | ||
implementation 'androidx.core:core:1.0.0-rc01' | ||
} |
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,91 +1,70 @@ | ||
package rikka.smscodehelper; | ||
|
||
import android.Manifest; | ||
import android.content.DialogInterface; | ||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.content.pm.PackageManager; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.support.v4.app.ActivityCompat; | ||
import android.support.v4.content.ContextCompat; | ||
import android.support.v7.app.AlertDialog; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.core.app.ActivityCompat; | ||
import androidx.core.content.ContextCompat; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
public class MainActivity extends Activity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle); | ||
AlertDialog.Builder builder = new AlertDialog.Builder(this) | ||
.setOnCancelListener(dialog -> finish()) | ||
.setCancelable(false); | ||
|
||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() { | ||
@Override | ||
public void onCancel(DialogInterface dialog) { | ||
finish(); | ||
} | ||
}); | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && | ||
ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS) != PackageManager.PERMISSION_GRANTED) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M | ||
&& ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS) != PackageManager.PERMISSION_GRANTED) { | ||
builder.setMessage(R.string.tip_m); | ||
builder.setPositiveButton(R.string.get_permission, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
getPermission(Manifest.permission.RECEIVE_SMS); | ||
} | ||
}); | ||
builder.setPositiveButton(R.string.get_permission, (dialog, which) -> requestPermission()); | ||
builder.setNegativeButton(R.string.exit, (dialog, which) -> finish()); | ||
} else { | ||
builder.setMessage(getString(R.string.tip)); | ||
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
hideLauncher(); | ||
finish(); | ||
} | ||
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> { | ||
hideFromLauncher(); | ||
finish(); | ||
}); | ||
} | ||
|
||
AlertDialog alertDialog = builder.create(); | ||
alertDialog.setCanceledOnTouchOutside(false); | ||
alertDialog.show(); | ||
builder.show(); | ||
} | ||
|
||
private void getPermission(String permission) { | ||
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(this, new String[]{permission}, 0); | ||
private void requestPermission() { | ||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS) != PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECEIVE_SMS}, 0); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | ||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
switch (requestCode) { | ||
case 0: | ||
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) { | ||
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle); | ||
AlertDialog.Builder builder = new AlertDialog.Builder(this); | ||
|
||
builder.setTitle("OAQ"); | ||
builder.setMessage(R.string.permission_denied); | ||
builder.setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
finish(); | ||
} | ||
}); | ||
builder.create().show(); | ||
builder.setPositiveButton(R.string.exit, (dialog, which) -> finish()); | ||
builder.show(); | ||
} else { | ||
hideFromLauncher(); | ||
finish(); | ||
hideLauncher(); | ||
} | ||
break; | ||
default: | ||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
} | ||
} | ||
|
||
private void hideLauncher() { | ||
PackageManager p = getApplicationContext().getPackageManager(); | ||
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); | ||
private void hideFromLauncher() { | ||
PackageManager pm = getApplicationContext().getPackageManager(); | ||
pm.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); | ||
} | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<resources>> | ||
|
||
<style name="AppTheme.NoActionBar"> | ||
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="AppTheme.Transparent" parent="AppTheme"> | ||
<item name="android:windowNoTitle">true</item> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<item name="android:windowIsTranslucent">true</item> | ||
<item name="android:windowIsFloating">true</item> | ||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> | ||
<item name="android:statusBarColor">@android:color/transparent</item> | ||
</style> | ||
</resources> | ||
</resources> |
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,14 +1,9 @@ | ||
<resources> | ||
<string name="app_name">验证码复制器</string> | ||
|
||
<string name="toast_format" formatted="false">%s 已被复制到剪贴板</string> | ||
|
||
<string name="tip_m">在 Android 6.0 以上需要由用户授予权限,点击获取后,如果没有权限将弹出授权窗口。\n授权后应用将会从启动器隐藏。</string> | ||
<string name="tip">点击确认后应用将会从启动器隐藏。</string> | ||
|
||
<string name="get_permission">获取权限</string> | ||
<string name="ok">确认</string> | ||
<string name="get_permission">授予权限</string> | ||
<string name="exit">退出</string> | ||
<string name="permission_denied">被拒绝了..</string> | ||
|
||
</resources> |
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,12 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">驗證碼複製器</string> | ||
<string name="toast_format">%s 已複製到剪貼簿</string> | ||
<string name="exit">退出</string> | ||
<string name="get_permission">取得權限</string> | ||
<string name="ok">確定</string> | ||
<string name="get_permission">授予權限</string> | ||
<string name="permission_denied">被拒絕了..</string> | ||
<string name="tip">點擊確定後App將會被隱藏</string> | ||
<string name="tip_m">"Android 6.0以上需要由使用者授予權限,點擊授予後,如果沒有權限將跳出授權視窗。 | ||
授權後App將會被隱藏。"</string> | ||
<string name="toast_format">%s 已複製到剪貼簿</string> | ||
</resources> |
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,14 +1,9 @@ | ||
<resources> | ||
<string name="app_name">SmsCodeHelper</string> | ||
|
||
<string name="toast_format" formatted="false">%s has been copied to clipboard.</string> | ||
|
||
<string name="tip_m">After Android 6.0, permission should be authorized by user.\nApp will be hide from launcher if authorized.</string> | ||
<string name="tip">App will be hide from launcher.</string> | ||
|
||
<string name="get_permission">GET PERMISSION</string> | ||
<string name="ok">OK</string> | ||
<string name="get_permission">Grant permission</string> | ||
<string name="exit">Exit</string> | ||
<string name="permission_denied">Denied..</string> | ||
|
||
</resources> |
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,31 +1,12 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
<style name="AppTheme" parent="android:Theme.DeviceDefault"/> | ||
|
||
<style name="Transparent" parent="AppTheme"> | ||
<item name="windowNoTitle">true</item> | ||
<style name="AppTheme.Transparent" parent="AppTheme"> | ||
<item name="android:windowNoTitle">true</item> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<item name="android:windowIsTranslucent">true</item> | ||
<item name="android:windowIsFloating">true</item> | ||
</style> | ||
|
||
<style name="DialogStyle" parent="Theme.AppCompat.Light.Dialog"> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
<style name="AppTheme.NoActionBar"> | ||
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
</style> | ||
|
||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | ||
|
||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | ||
|
||
</resources> |
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
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,6 +1,5 @@ | ||
#Wed Oct 21 11:34:03 PDT 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip |
Oops, something went wrong.