forked from MokoBeacon/mokoBeacon_Android
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 8bbcadf
Showing
60 changed files
with
1,446 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
/*/build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
.idea | ||
*.iml |
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,29 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
/*/build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
.idea | ||
*.iml |
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,55 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.moko.beacon" | ||
minSdkVersion 18 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
sourceSets { | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
signingConfigs { | ||
release { | ||
keyAlias 'mokoBeacon' | ||
keyPassword 'moko123456' | ||
storeFile file('D:\\AndroidStudioProjects\\MokoBeacon\\app\\keystore\\mokoBeacon.jks') | ||
storePassword 'moko123456' | ||
} | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
signingConfig signingConfigs.release | ||
} | ||
} | ||
applicationVariants.all { variant -> | ||
variant.outputs.each { output -> | ||
def outputFile = output.outputFile | ||
if (outputFile != null && outputFile.name.endsWith('.apk')) { | ||
//这里修改apk文件名 | ||
def fileName = "MokoBeacon-${defaultConfig.versionName}.apk" | ||
if (outputFile.name.contains('debug')) { | ||
fileName = "MokoBeacon-${defaultConfig.versionName}-debug.apk" | ||
} | ||
output.outputFile = new File(outputFile.parent, fileName) | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: '*.jar', dir: 'libs') | ||
compile 'com.jakewharton:butterknife:7.0.1' | ||
compile 'com.android.support:support-v4:23.1.0' | ||
compile project(path: ':beaconsupport') | ||
|
||
} |
Binary file not shown.
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,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in D:\adt-bundle-windows-x86\android-sdk-windows/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.moko.beacon"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".BaseApplication" | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/LaunchActivityTheme"> | ||
|
||
<activity android:name=".activity.GuideActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name=".activity.MainActivity" | ||
android:screenOrientation="portrait" | ||
android:windowSoftInputMode="adjustPan" /> | ||
<activity | ||
android:name=".activity.AboutActivity" | ||
android:screenOrientation="portrait" | ||
android:windowSoftInputMode="adjustPan" /> | ||
</application> | ||
|
||
</manifest> |
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,21 @@ | ||
package com.moko.beacon; | ||
|
||
import android.app.Application; | ||
import android.content.Intent; | ||
|
||
import com.moko.beacon.service.BeaconService; | ||
|
||
/** | ||
* @Date 2017/12/7 0007 | ||
* @Author wenzheng.liu | ||
* @Description | ||
* @ClassPath com.moko.beacon.BaseApplication | ||
*/ | ||
public class BaseApplication extends Application { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
// 启动蓝牙服务 | ||
startService(new Intent(this, BeaconService.class)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/moko/beacon/activity/AboutActivity.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,44 @@ | ||
package com.moko.beacon.activity; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
|
||
import com.moko.beacon.R; | ||
|
||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
|
||
/** | ||
* @Date 2017/12/7 0007 | ||
* @Author wenzheng.liu | ||
* @Description | ||
* @ClassPath com.moko.beacon.activity.AboutActivity | ||
*/ | ||
public class AboutActivity extends Activity { | ||
|
||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_about); | ||
ButterKnife.bind(this); | ||
} | ||
|
||
@OnClick({R.id.tv_back, R.id.tv_moko_url}) | ||
public void onClick(View view) { | ||
switch (view.getId()) { | ||
case R.id.tv_back: | ||
finish(); | ||
break; | ||
case R.id.tv_moko_url: | ||
Uri uri = Uri.parse("https://www.mokosmart.com"); | ||
Intent intent = new Intent(Intent.ACTION_VIEW, uri); | ||
startActivity(intent); | ||
break; | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
app/src/main/java/com/moko/beacon/activity/GuideActivity.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,81 @@ | ||
package com.moko.beacon.activity; | ||
|
||
import android.Manifest; | ||
import android.app.Activity; | ||
import android.content.Intent; | ||
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 com.moko.beacon.R; | ||
import com.moko.beacon.utils.ToastUtils; | ||
|
||
/** | ||
* @Date 2017/12/7 0007 | ||
* @Author wenzheng.liu | ||
* @Description | ||
* @ClassPath com.moko.beacon.activity.GuideActivity | ||
*/ | ||
public class GuideActivity extends Activity { | ||
|
||
private static final int PERMISSION_REQUEST_CODE = 1; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_guide); | ||
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { | ||
finish(); | ||
return; | ||
} | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED | ||
|| ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(this, new String[]{ | ||
Manifest.permission.ACCESS_COARSE_LOCATION | ||
, Manifest.permission.WRITE_EXTERNAL_STORAGE} | ||
, PERMISSION_REQUEST_CODE); | ||
return; | ||
} | ||
} | ||
delayGotoMain(); | ||
} | ||
|
||
@Override | ||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | ||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
switch (requestCode) { | ||
case PERMISSION_REQUEST_CODE: { | ||
for (int i = 0; i < grantResults.length; i++) { | ||
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { | ||
ToastUtils.showToast(GuideActivity.this, "This app needs these permissions!"); | ||
GuideActivity.this.finish(); | ||
return; | ||
} | ||
} | ||
delayGotoMain(); | ||
} | ||
} | ||
} | ||
|
||
private void delayGotoMain() { | ||
new Thread() { | ||
public void run() { | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
runOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
startActivity(new Intent(GuideActivity.this, MainActivity.class)); | ||
GuideActivity.this.finish(); | ||
} | ||
}); | ||
} | ||
}.start(); | ||
} | ||
} |
Oops, something went wrong.