Skip to content

Commit

Permalink
Add intentservice to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
newhinton committed Jan 2, 2020
1 parent d8118d5 commit ea638e7
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 212 deletions.
99 changes: 0 additions & 99 deletions .idea/assetWizardSettings.xml

This file was deleted.

Binary file removed .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

34 changes: 0 additions & 34 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Features
- Customizable primary and accent colors
- Supports ARM and x86 devices
- Supports SDK 21+ (Lollipop 5.0)
- Intentservice to start tasks via third party apps!

TODO
------------
Expand Down Expand Up @@ -46,6 +47,21 @@ Grab the [latest version](https://github.com/kaczmarkiewiczp/rcloneExplorer/rele
- For x86 devices download RcloneExplorer-x86.apk
- Ultimately, RcloneExplorer.apk will work with both ARM and x86 devices.



Intentservice
-------------
This app includes the ability to launch an intent! Create a task to sync to a remote, and copy it's id (via the treedot-menu)
The intent needs the following:

| Intent | Content | |
| :------------- | :-------------: | -------------: |
| packageName | ca.pkay.rcloneexplorer | |
| className | ca.pkay.rcloneexplorer.Services.TaskStartService | |
| Action | START_TASK | |
| Integer Extra | task | idOfTask |


Credits/Libraries
-----------------
- [Android Support Libraries](https://developer.android.com/topic/libraries/support-library)
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/java/ca/pkay/rcloneexplorer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand Down Expand Up @@ -36,8 +37,6 @@
import android.view.View;
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.google.firebase.messaging.FirebaseMessaging;

import java.io.File;
import java.io.IOException;
Expand All @@ -53,7 +52,6 @@
import ca.pkay.rcloneexplorer.Items.RemoteItem;
import ca.pkay.rcloneexplorer.Settings.SettingsActivity;
import es.dmoral.toasty.Toasty;
import io.fabric.sdk.android.Fabric;

public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener,
Expand Down Expand Up @@ -97,7 +95,6 @@ protected void onCreate(Bundle savedInstanceState) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean enableCrashReports = sharedPreferences.getBoolean(getString(R.string.pref_key_crash_reports), false);
if (enableCrashReports) {
Fabric.with(this, new Crashlytics());
}

applyTheme();
Expand Down Expand Up @@ -130,7 +127,6 @@ public void onClick(View v) {

boolean appUpdates = sharedPreferences.getBoolean(getString(R.string.pref_key_app_updates), false);
if (appUpdates) {
FirebaseMessaging.getInstance().subscribeToTopic(getString(R.string.firebase_msg_app_updates_topic));
}

Intent intent = getIntent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ca.pkay.rcloneexplorer.Services;

import com.google.firebase.iid.FirebaseInstanceIdService;

public class FirebaseIdService extends FirebaseInstanceIdService {
public class FirebaseIdService {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,15 @@
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;

import com.google.firebase.messaging.RemoteMessage;

import ca.pkay.rcloneexplorer.R;

public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
public class FirebaseMessagingService {

private final String CHANNEL_ID = "ca.pkay.rcexplorer.app_updates";
private final String CHANNEL_NAME = "App updates";

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
setNotificationChannel();

Uri uri = Uri.parse(getString(R.string.app_latest_release_url));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(R.string.app_update_notification_title))
.setPriority(NotificationCompat.PRIORITY_LOW)
.setContentIntent(pendingIntent)
.setAutoCancel(true);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(33, builder.build());
}

private void setNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand All @@ -46,10 +27,7 @@ private void setNotificationChannel() {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW);
channel.setDescription("App updates notification");
// Register the channel with the system
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import android.widget.Switch;
import android.widget.Toast;

import com.google.firebase.messaging.FirebaseMessaging;

import ca.pkay.rcloneexplorer.R;
import es.dmoral.toasty.Toasty;
Expand Down Expand Up @@ -151,10 +150,8 @@ private void onNotificationsClicked() {

private void onAppUpdatesClicked(boolean isChecked) {
if (isChecked) {
FirebaseMessaging.getInstance().subscribeToTopic(getString(R.string.firebase_msg_app_updates_topic));
betaAppUpdatesElement.setVisibility(View.VISIBLE);
} else {
FirebaseMessaging.getInstance().unsubscribeFromTopic(getString(R.string.firebase_msg_app_updates_topic));
betaAppUpdatesSwitch.setChecked(false);
betaAppUpdatesElement.setVisibility(View.GONE);
}
Expand All @@ -166,11 +163,6 @@ private void onAppUpdatesClicked(boolean isChecked) {
}

private void onBetaAppUpdatesClicked(boolean isChecked) {
if (isChecked) {
FirebaseMessaging.getInstance().subscribeToTopic(getString(R.string.firebase_msg_beta_app_updates_topic));
} else {
FirebaseMessaging.getInstance().unsubscribeFromTopic(getString(R.string.firebase_msg_beta_app_updates_topic));
}

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sharedPreferences.edit();
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
classpath 'io.fabric.tools:gradle:1.25.4'


// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit ea638e7

Please sign in to comment.