Search in sources :

Example 1 with AppConfig

use of com.amaze.filemanager.application.AppConfig in project AmazeFileManager by TeamAmaze.

the class CopyService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, final int startId) {
    Bundle b = new Bundle();
    isRootExplorer = intent.getBooleanExtra(TAG_IS_ROOT_EXPLORER, false);
    ArrayList<HybridFileParcelable> files = intent.getParcelableArrayListExtra(TAG_COPY_SOURCES);
    String targetPath = intent.getStringExtra(TAG_COPY_TARGET);
    int mode = intent.getIntExtra(TAG_COPY_OPEN_MODE, OpenMode.UNKNOWN.ordinal());
    final boolean move = intent.getBooleanExtra(TAG_COPY_MOVE, false);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(c);
    accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference().getCurrentUserColorPreferences(this, sharedPreferences).getAccent();
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt(TAG_COPY_START_ID, startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small);
    customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big);
    Intent stopIntent = new Intent(TAG_BROADCAST_COPY_CANCEL);
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(c, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_content_copy_white_36dp, getString(R.string.stop_ftp), stopPendingIntent);
    mBuilder = new NotificationCompat.Builder(c, NotificationConstants.CHANNEL_NORMAL_ID).setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_content_copy_white_36dp).setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews).setCustomHeadsUpContentView(customSmallContentViews).setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true).setColor(accentColor);
    // set default notification views text
    NotificationConstants.setMetadata(c, mBuilder, NotificationConstants.TYPE_NORMAL);
    startForeground(NotificationConstants.COPY_ID, mBuilder.build());
    initNotificationViews();
    b.putBoolean(TAG_COPY_MOVE, move);
    b.putString(TAG_COPY_TARGET, targetPath);
    b.putInt(TAG_COPY_OPEN_MODE, mode);
    b.putParcelableArrayList(TAG_COPY_SOURCES, files);
    super.onStartCommand(intent, flags, startId);
    super.progressHalted();
    // going async
    new DoInBackground(isRootExplorer).execute(b);
    // If we get killed, after returning from here, restart
    return START_NOT_STICKY;
}
Also used : AppConfig(com.amaze.filemanager.application.AppConfig) Bundle(android.os.Bundle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) RemoteViews(android.widget.RemoteViews) NotificationCompat(androidx.core.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 2 with AppConfig

use of com.amaze.filemanager.application.AppConfig in project AmazeFileManager by TeamAmaze.

the class EncryptService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    baseFile = intent.getParcelableExtra(TAG_SOURCE);
    targetFilename = intent.getStringExtra(TAG_ENCRYPT_TARGET);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference().getCurrentUserColorPreferences(this, sharedPreferences).getAccent();
    OpenMode openMode = OpenMode.values()[intent.getIntExtra(TAG_OPEN_MODE, OpenMode.UNKNOWN.ordinal())];
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small);
    customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big);
    Intent stopIntent = new Intent(TAG_BROADCAST_CRYPT_CANCEL);
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_folder_lock_white_36dp, getString(R.string.stop_ftp), stopPendingIntent);
    notificationBuilder = new NotificationCompat.Builder(this, NotificationConstants.CHANNEL_NORMAL_ID);
    notificationBuilder.setContentIntent(pendingIntent).setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews).setCustomHeadsUpContentView(customSmallContentViews).setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setColor(accentColor).setOngoing(true).setSmallIcon(R.drawable.ic_folder_lock_white_36dp);
    NotificationConstants.setMetadata(getApplicationContext(), notificationBuilder, NotificationConstants.TYPE_NORMAL);
    startForeground(NotificationConstants.ENCRYPT_ID, notificationBuilder.build());
    initNotificationViews();
    super.onStartCommand(intent, flags, startId);
    super.progressHalted();
    new BackgroundTask().execute();
    return START_NOT_STICKY;
}
Also used : AppConfig(com.amaze.filemanager.application.AppConfig) RemoteViews(android.widget.RemoteViews) NotificationCompat(androidx.core.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode)

Example 3 with AppConfig

use of com.amaze.filemanager.application.AppConfig in project AmazeFileManager by TeamAmaze.

the class ExtractService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, final int startId) {
    String file = intent.getStringExtra(KEY_PATH_ZIP);
    String extractPath = intent.getStringExtra(KEY_PATH_EXTRACT);
    String[] entries = intent.getStringArrayExtra(KEY_ENTRIES_ZIP);
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference().getCurrentUserColorPreferences(this, sharedPreferences).getAccent();
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small);
    customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big);
    Intent stopIntent = new Intent(TAG_BROADCAST_EXTRACT_CANCEL);
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_zip_box_grey, getString(R.string.stop_ftp), stopPendingIntent);
    mBuilder = new NotificationCompat.Builder(context, NotificationConstants.CHANNEL_NORMAL_ID);
    mBuilder.setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_zip_box_grey).setContentIntent(pendingIntent).setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews).setCustomHeadsUpContentView(customSmallContentViews).setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setAutoCancel(true).setOngoing(true).setColor(accentColor);
    NotificationConstants.setMetadata(getApplicationContext(), mBuilder, NotificationConstants.TYPE_NORMAL);
    startForeground(NotificationConstants.EXTRACT_ID, mBuilder.build());
    initNotificationViews();
    long totalSize = getTotalSize(file);
    progressHandler.setSourceSize(1);
    progressHandler.setTotalSize(totalSize);
    progressHandler.setProgressListener((speed) -> publishResults(speed, false, false));
    super.onStartCommand(intent, flags, startId);
    super.progressHalted();
    new DoWork(this, progressHandler, file, extractPath, entries).execute();
    return START_NOT_STICKY;
}
Also used : AppConfig(com.amaze.filemanager.application.AppConfig) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RemoteViews(android.widget.RemoteViews) NotificationCompat(androidx.core.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 4 with AppConfig

use of com.amaze.filemanager.application.AppConfig in project AmazeFileManager by TeamAmaze.

the class DecryptService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    baseFile = intent.getParcelableExtra(TAG_SOURCE);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference().getCurrentUserColorPreferences(this, sharedPreferences).getAccent();
    OpenMode openMode = OpenMode.values()[intent.getIntExtra(TAG_OPEN_MODE, OpenMode.UNKNOWN.ordinal())];
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small);
    customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big);
    Intent stopIntent = new Intent(TAG_BROADCAST_CRYPT_CANCEL);
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_folder_lock_open_white_36dp, getString(R.string.stop_ftp), stopPendingIntent);
    notificationBuilder = new NotificationCompat.Builder(this, NotificationConstants.CHANNEL_NORMAL_ID);
    notificationBuilder.setContentIntent(pendingIntent).setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews).setCustomHeadsUpContentView(customSmallContentViews).setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true).setColor(accentColor);
    decryptPath = intent.getStringExtra(TAG_DECRYPT_PATH);
    notificationBuilder.setSmallIcon(R.drawable.ic_folder_lock_open_white_36dp);
    NotificationConstants.setMetadata(context, notificationBuilder, NotificationConstants.TYPE_NORMAL);
    startForeground(NotificationConstants.DECRYPT_ID, notificationBuilder.build());
    initNotificationViews();
    super.onStartCommand(intent, flags, startId);
    super.progressHalted();
    new DecryptService.BackgroundTask().execute();
    return START_NOT_STICKY;
}
Also used : AppConfig(com.amaze.filemanager.application.AppConfig) RemoteViews(android.widget.RemoteViews) NotificationCompat(androidx.core.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode)

Aggregations

PendingIntent (android.app.PendingIntent)4 Intent (android.content.Intent)4 RemoteViews (android.widget.RemoteViews)4 NotificationCompat (androidx.core.app.NotificationCompat)4 AppConfig (com.amaze.filemanager.application.AppConfig)4 OpenMode (com.amaze.filemanager.file_operations.filesystem.OpenMode)2 Bundle (android.os.Bundle)1 HybridFileParcelable (com.amaze.filemanager.filesystem.HybridFileParcelable)1