Skip to content

Commit

Permalink
releasing version 10.0.4 fixing restore, stopping fa from service ins…
Browse files Browse the repository at this point in the history
…tead of long press and opening app base on component name.
  • Loading branch information
Kosh committed Dec 28, 2016
1 parent bea2e61 commit aff39c3
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 263 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "com.styleme.floating.toolbox.pro"
minSdkVersion 18
targetSdkVersion 25
versionCode 103
versionName "10.0.3"
versionCode 104
versionName "10.0.4"
buildConfigField "String", "FA_HOST", '"k0shk0sh.github.io/FastAccess"'
buildConfigField "String", "SHARED_URI", '"sharedUri"'
signingConfig signingConfigs.signing
Expand Down Expand Up @@ -55,8 +55,8 @@ repositories {
}
dependencies {
ext {
supportVerion = "25.0.1"
firebase = "10.0.0"
supportVerion = "25.1.0"
firebase = "10.0.1"
}
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${supportVerion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ public static void notifyWithImage(@NonNull Context context, @NonNull String tit
notificationManager.notify(NOTIFICATION_ID, notification);
}

public static Notification getNonCancellableNotification(@NonNull Context content, @NonNull String title, @NonNull String msg,
@DrawableRes int iconId, @NonNull PendingIntent pendingIntent) {
return new NotificationCompat.Builder(content)
public static Notification getNonCancellableNotification(@NonNull Context context, @NonNull String title, @NonNull String msg,
@DrawableRes int iconId, @NonNull PendingIntent pendingIntent,
@NonNull PendingIntent stopServiceIntent) {
return new NotificationCompat.Builder(context)
.setAutoCancel(false)
.setOngoing(true)
.setContentTitle(title)
.setContentText(msg)
.setSmallIcon(iconId)
.addAction(R.drawable.ic_stop, context.getString(R.string.stop_service), stopServiceIntent)
.addAction(R.drawable.ic_fa_notification, context.getString(R.string.click_to_open_fa), pendingIntent)
.setContentIntent(pendingIntent)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class FloatingService extends Service {
private FloatingVHView floatingVHView;
private FloatingFoldersView floatingFoldersView;
public static final String STOP_FLAG = "stop_flag";

@Override public void onCreate() {
super.onCreate();
Expand All @@ -40,10 +41,13 @@ public class FloatingService extends Service {
} else {
floatingVHView = FloatingVHView.with(this, PrefConstant.isHorizontal());
}
startForeground(NotificationHelper.NOTIFICATION_ID, NotificationHelper.getNonCancellableNotification(this,
getString(R.string.app_name), getString(R.string.click_to_open_fa),
PrefHelper.getBoolean(PrefConstant.STATUS_BAR_HIDDEN) ? R.drawable.ic_notification : R.drawable.ic_fa_notification,
PendingIntent.getActivity(this, 0, new Intent(this, MainView.class), PendingIntent.FLAG_UPDATE_CURRENT)));
Intent stopServiceIntent = new Intent(this, FloatingService.class);
stopServiceIntent.putExtra(STOP_FLAG, true);
startForeground(NotificationHelper.NOTIFICATION_ID,
NotificationHelper.getNonCancellableNotification(this, getString(R.string.app_name), getString(R.string.click_to_open_fa),
PrefHelper.getBoolean(PrefConstant.STATUS_BAR_HIDDEN) ? R.drawable.ic_notification : R.drawable.ic_fa_notification,
PendingIntent.getActivity(this, 0, new Intent(this, MainView.class), PendingIntent.FLAG_UPDATE_CURRENT),
PendingIntent.getService(this, 0, stopServiceIntent, PendingIntent.FLAG_UPDATE_CURRENT)));
}

@Nullable @Override public IBinder onBind(Intent intent) {
Expand All @@ -52,6 +56,10 @@ public class FloatingService extends Service {

@Override public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
if (intent != null && intent.getBooleanExtra(STOP_FLAG, false)) {
stopForeground(true);
stopSelf();
}
return START_STICKY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.Logger;
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
import com.fastaccess.ui.modules.cloud.backup.BackupView;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
Expand Down Expand Up @@ -42,18 +41,15 @@ public static RestorePresenter with(@NonNull RestoreMvp.View view) {
} else {
getView().onShowProgress();
Query query = databaseReference
.child(BackupView.BACKUP_DATABASE_NAME)
.child(userId)
.limitToFirst(1);
.child(userId);
query.keepSynced(true);
query.addListenerForSingleValueEvent(this);
}
}

@Override public void onDataChange(DataSnapshot dataSnapshot) {
if (!isAttached()) return;
if (dataSnapshot != null) {
Logger.e(dataSnapshot);
if (dataSnapshot != null && dataSnapshot.hasChildren()) {
FirebaseUser user = getView().user();
if (InputHelper.isEmpty(userId)) {
if (user != null) userId = user.getUid();
Expand All @@ -64,9 +60,8 @@ public static RestorePresenter with(@NonNull RestoreMvp.View view) {
getView().finishOnError();
return;
}
if (dataSnapshot.hasChildren()) {
BackupRestoreModel.restore(dataSnapshot.getValue(BackupRestoreModel.class));
}
Logger.e(dataSnapshot);
BackupRestoreModel.restore(dataSnapshot.getValue(BackupRestoreModel.class));
getView().onHideProgress();
getView().onRestoreCompleted();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fastaccess.R;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.ui.base.BaseActivity;
import com.fastaccess.ui.modules.cloud.backup.BackupView;
import com.fastaccess.ui.widgets.dialog.MessageDialogView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
Expand Down Expand Up @@ -129,7 +130,7 @@ private ProgressDialog getProgressDialog() {

private DatabaseReference getDatabase() {
if (database == null) {
database = FirebaseDatabase.getInstance().getReference();
database = FirebaseDatabase.getInstance().getReference(BackupView.BACKUP_DATABASE_NAME);
}
return database;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.fastaccess.data.dao.FolderModel;
import com.fastaccess.data.dao.events.FloatingEventModel;
import com.fastaccess.data.dao.events.ThemePackEventModel;
import com.fastaccess.helper.NotificationHelper;
import com.fastaccess.helper.PermissionsHelper;
import com.fastaccess.helper.PrefConstant;
import com.fastaccess.helper.PrefHelper;
Expand Down Expand Up @@ -104,7 +103,7 @@ public abstract class BaseFloatingView<M> implements BaseFloatingMvp.BaseView<M>
}

@Override public void onLongPressed() {
NotificationHelper.collapseFAService(context, getAdapter().getItemCount());
// NotificationHelper.collapseFAService(context, getAdapter().getItemCount());
}

@Override public void onDoubleTapped() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fastaccess.ui.modules.floating.apps;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.view.View;

Expand All @@ -28,9 +28,9 @@ public static FloatingVHPresenter with(@NonNull BaseFloatingMvp.BaseView<AppsMod
@Override public void onItemClick(int position, View v, AppsModel item) {
try {
Context context = v.getContext();
PackageManager manager = context.getPackageManager();
Intent intent = manager.getLaunchIntentForPackage(item.getPackageName());
intent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent intent = new Intent();
intent.setComponent(new ComponentName(item.getPackageName(), item.getActivityInfoName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {// app uninstalled/not found
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fastaccess.ui.modules.floating.folders.drawer;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.v4.content.Loader;
import android.view.View;
Expand Down Expand Up @@ -33,9 +33,9 @@ public static FloatingDrawPresenter with(@NonNull FloatingDrawerMvp.View view) {
@Override public void onItemClick(int position, View v, AppsModel item) {
try {
Context context = v.getContext();
PackageManager manager = context.getPackageManager();
Intent intent = manager.getLaunchIntentForPackage(item.getPackageName());
intent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent intent = new Intent();
intent.setComponent(new ComponentName(item.getPackageName(), item.getActivityInfoName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {// app uninstalled/not found
e.printStackTrace();
Expand Down
Loading

0 comments on commit aff39c3

Please sign in to comment.