-
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
Showing
37 changed files
with
862 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,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,28 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 26 | ||
buildToolsVersion "26.0.1" | ||
defaultConfig { | ||
applicationId "edu.cs4730.boradcastboot2" | ||
minSdkVersion 16 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:26.0.2' | ||
compile 'com.android.support:support-compat:26.0.2' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.2' | ||
compile 'com.android.support:support-v4:26.+' | ||
} |
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 C:\Android\android-sdk/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:https://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,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
package="edu.cs4730.boradcastboot2"> | ||
|
||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
|
||
<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="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<receiver | ||
android:name=".MyReceiver" | ||
android:enabled="true" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.BOOT_COMPLETED" /> | ||
</intent-filter> | ||
</receiver> | ||
|
||
<service | ||
android:name=".MyJobIntentService" | ||
android:exported="true" | ||
android:permission="android.permission.BIND_JOB_SERVICE" /> | ||
</application> | ||
|
||
</manifest> |
66 changes: 66 additions & 0 deletions
66
BoradcastBoot2/app/src/main/java/edu/cs4730/boradcastboot2/MainActivity.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,66 @@ | ||
package edu.cs4730.boradcastboot2; | ||
|
||
import android.app.NotificationChannel; | ||
import android.app.NotificationManager; | ||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
final String TAG = "MainActivity"; | ||
public static String id = "test_channel_01"; | ||
MainFragment mFragment; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
String info = "Nothing"; | ||
Bundle extras = getIntent().getExtras(); | ||
if (extras != null) { | ||
info = extras.getString("mText"); | ||
} | ||
Log.wtf(TAG, "info is " + info); | ||
mFragment = MainFragment.newInstance(info); | ||
|
||
if (savedInstanceState == null) { | ||
getSupportFragmentManager().beginTransaction() | ||
.add(R.id.container, mFragment).commit(); | ||
} else { | ||
getSupportFragmentManager().beginTransaction() | ||
.replace(R.id.container, mFragment).commit(); | ||
} | ||
|
||
|
||
createchannel(); | ||
|
||
} | ||
|
||
|
||
/* | ||
* for API 26+ create notification channels | ||
*/ | ||
private void createchannel() { | ||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { | ||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | ||
NotificationChannel mChannel = new NotificationChannel(id, | ||
getString(R.string.channel_name), //name of the channel | ||
NotificationManager.IMPORTANCE_DEFAULT); //importance level | ||
//important level: default is is high on the phone. high is urgent on the phone. low is medium, so none is low? | ||
// Configure the notification channel. | ||
mChannel.setDescription(getString(R.string.channel_description)); | ||
mChannel.enableLights(true); | ||
// Sets the notification light color for notifications posted to this channel, if the device supports this feature. | ||
mChannel.setLightColor(Color.RED); | ||
mChannel.enableVibration(true); | ||
mChannel.setShowBadge(true); | ||
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); | ||
nm.createNotificationChannel(mChannel); | ||
|
||
} | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
BoradcastBoot2/app/src/main/java/edu/cs4730/boradcastboot2/MainFragment.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,63 @@ | ||
package edu.cs4730.boradcastboot2; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
/** | ||
* All this fragment does is display information. | ||
* <p> | ||
* It also has a button to "jump start" the process. Basically the first message. | ||
*/ | ||
|
||
public class MainFragment extends Fragment { | ||
private static final String ARG_PARAM1 = "param1"; | ||
|
||
String info = ""; | ||
TextView logger; | ||
|
||
public MainFragment() { | ||
// Required empty public constructor | ||
} | ||
|
||
public static MainFragment newInstance(String param1) { | ||
MainFragment fragment = new MainFragment(); | ||
Bundle args = new Bundle(); | ||
args.putString(ARG_PARAM1, param1); | ||
fragment.setArguments(args); | ||
return fragment; | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
if (getArguments() != null) { | ||
info = getArguments().getString(ARG_PARAM1); | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
// Inflate the layout for this fragment | ||
View myView = inflater.inflate(R.layout.fragment_main, container, false); | ||
logger = myView.findViewById(R.id.textView2); | ||
logger.setText(info); | ||
|
||
myView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Intent intent = new Intent(); | ||
//normally this intent should have something, like data... | ||
MyJobIntentService.enqueueWork(getContext(),intent); | ||
} | ||
}); | ||
return myView; | ||
} | ||
|
||
} |
Oops, something went wrong.