Skip to content

Commit

Permalink
improvement of sharing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed Nov 2, 2016
1 parent 82ce5fd commit 2000354
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 128 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/.idea/
/app/StyleMe
/app/src/main/res/values/secrets.xml
/gradle.properties
8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: "com.neenbedankt.android-apt"

android {
signingConfigs {
signing {
keyAlias 'styleme'
keyPassword 'koshkosh1'
keyAlias ANDROID_KEY_ALIAS
keyPassword ANDROID_STORE_PASSWORD
storeFile file('StyleMe')
storePassword 'koshkosh1'
storePassword ANDROID_STORE_PASSWORD
}
}
compileSdkVersion 25
Expand Down Expand Up @@ -89,7 +88,6 @@ dependencies {
compile 'org.adw.library:discrete-seekbar:1.0.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile 'pub.devrel:easypermissions:0.2.1'
compile 'com.github.iammert:MaterialIntroView:1.5.2'
apt 'frankiesardo:icepick-processor:3.1.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
Expand Down
46 changes: 0 additions & 46 deletions app/src/main/java/com/fastaccess/helper/ViewHelper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fastaccess.helper;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
Expand All @@ -17,7 +16,6 @@
import android.graphics.drawable.shapes.RoundRectShape;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.NavigationView;
import android.support.v4.content.ContextCompat;
Expand All @@ -35,11 +33,6 @@

import java.util.Arrays;

import co.mobiwise.materialintro.animation.MaterialIntroListener;
import co.mobiwise.materialintro.shape.Focus;
import co.mobiwise.materialintro.shape.FocusGravity;
import co.mobiwise.materialintro.view.MaterialIntroView;


/**
* Created by kosh20111 on 10/7/2015 10:42 PM
Expand Down Expand Up @@ -158,45 +151,6 @@ public static void showTooltip(@NonNull final View view, @StringRes int titleRes
showTooltip(view, titleResId, tag, Gravity.BOTTOM);
}

public static void showMaterialIntroView(@NonNull Context context, @NonNull View view, @StringRes int resId,
boolean showAnimation, @Nullable MaterialIntroListener listener) {
Activity activity = ActivityHelper.getActivity(context);
if (activity == null) {
activity = ActivityHelper.getActivity(view.getContext());
if (activity == null) {
showTooltip(view, resId, String.valueOf(resId));
return;
}
}
new MaterialIntroView.Builder(activity)
.enableDotAnimation(showAnimation)
.enableIcon(true)
.setFocusGravity(FocusGravity.CENTER)
.setFocusType(Focus.MINIMUM)
.setDelayMillis(1500)
.enableFadeAnimation(true)
.setInfoText(activity.getResources().getString(resId))
.performClick(true)
.setTarget(view)
.setListener(listener)
.setUsageId(view.getId() != 0 ? String.valueOf(view.getId()) : String.valueOf(resId))
.show();
}

public static void showMaterialIntroView(@NonNull Context context, @NonNull View view, @StringRes int resId,
@Nullable MaterialIntroListener listener) {
showMaterialIntroView(context, view, resId, false, listener);

}

public static void showMaterialIntroView(@NonNull Context context, @NonNull View view, @StringRes int resId, boolean showAnimation) {
showMaterialIntroView(context, view, resId, showAnimation, null);
}

public static void showMaterialIntroView(@NonNull Context context, @NonNull View view, @StringRes int resId) {
showMaterialIntroView(context, view, resId, null);
}

public static Rect getLayoutPosition(@NonNull View view) {
Rect myViewRect = new Rect();
view.getGlobalVisibleRect(myViewRect);
Expand Down
50 changes: 25 additions & 25 deletions app/src/main/java/com/fastaccess/ui/adapter/DeviceAppsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ public DeviceAppsAdapter(@NonNull List<AppsModel> data, @Nullable DeviceAppsView
}
}

@Override public Filter getFilter() {
return new Filter() {
@Override protected FilterResults performFiltering(CharSequence charSequence) {
final FilterResults oReturn = new FilterResults();
final List<AppsModel> results = new ArrayList<>();
if (!InputHelper.isEmpty(charSequence)) {
if (!getData().isEmpty()) {
for (AppsModel appInfo : getData()) {
if (appInfo.getAppName().toLowerCase().contains(charSequence.toString())) {
results.add(appInfo);
}
}
}
oReturn.values = results;
oReturn.count = results.size();
}
return oReturn;
}

@SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) {
insertItems((List<AppsModel>) results.values);
}
};
}

public void select(String packageName, int position, boolean select) {
if (select) selection.put(packageName, getItem(position));
else selection.remove(packageName);
Expand Down Expand Up @@ -69,29 +94,4 @@ public List<AppsModel> getSelections() {
return new ArrayList<>(selection.values());
}

@Override public Filter getFilter() {
return new Filter() {
@Override protected FilterResults performFiltering(CharSequence charSequence) {
final FilterResults oReturn = new FilterResults();
final List<AppsModel> results = new ArrayList<>();
if (!InputHelper.isEmpty(charSequence)) {
if (!getData().isEmpty()) {
for (AppsModel appInfo : getData()) {
if (appInfo.getAppName().toLowerCase().contains(charSequence.toString())) {
results.add(appInfo);
}
}
}
oReturn.values = results;
oReturn.count = results.size();
}
return oReturn;
}

@SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) {
insertItems((List<AppsModel>) results.values);
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
public class DeviceAppsViewHolder extends BaseViewHolder<AppsModel> implements ItemTouchHelperViewHolder {
@BindView(R.id.appIcon) ImageView appIcon;
@BindView(R.id.cardView) CardView cardView;
@ColorInt private int selectedColor;
@ColorInt private int normalColor;
@ColorInt private final int selectedColor;
@ColorInt private final int normalColor;
private boolean selected;

public DeviceAppsViewHolder(@NonNull View itemView, @Nullable BaseRecyclerAdapter adapter) {
Expand Down
56 changes: 31 additions & 25 deletions app/src/main/java/com/fastaccess/ui/base/BaseBottomSheetDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@
public abstract class BaseBottomSheetDialog extends BottomSheetDialogFragment {

protected BottomSheetBehavior<View> bottomSheetBehavior;
private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() {
@Override public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
isAlreadyHidden = true;
onHidden();
}
}

@Override public void onSlide(@NonNull View bottomSheet, float slideOffset) {
if (slideOffset == -1.0) {
isAlreadyHidden = true;
onDismissedByScrolling();
}
}
};
protected boolean isAlreadyHidden;
@Nullable private Unbinder unbinder;

Expand All @@ -52,22 +67,8 @@ public abstract class BaseBottomSheetDialog extends BottomSheetDialogFragment {
View parent = ((View) contentView.getParent());
bottomSheetBehavior = BottomSheetBehavior.from(parent);
if (bottomSheetBehavior != null) {
bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
isAlreadyHidden = true;
onHidden();
}
}

@Override public void onSlide(@NonNull View bottomSheet, float slideOffset) {
if (slideOffset == -1.0) {
isAlreadyHidden = true;
onDismissedByScrolling();
}
}
});
}
unbinder = ButterKnife.bind(this, contentView);
onViewCreated(contentView);
Expand All @@ -80,15 +81,18 @@ public abstract class BaseBottomSheetDialog extends BottomSheetDialogFragment {

@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
final Dialog dialog = super.onCreateDialog(savedInstanceState);
if (ViewHelper.isTablet(getContext())) {
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override public void onShow(DialogInterface dialogINterface) {
if (dialog.getWindow() != null) dialog.getWindow().setLayout(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override public void onShow(DialogInterface dialogINterface) {
if (ViewHelper.isTablet(getContext())) {
if (dialog.getWindow() != null) {
dialog.getWindow().setLayout(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT);
}
}
});
}
onDialogIsVisible();
}
});
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Expand Down Expand Up @@ -116,8 +120,10 @@ public abstract class BaseBottomSheetDialog extends BottomSheetDialogFragment {

protected void onHidden() {
dismiss();
}
}//helper method to notify dialogs

protected void onDismissedByScrolling() {}//helper method to notify dialogs

protected void onDismissedByScrolling() {}
protected void onDialogIsVisible() {}//helper method to notify dialogs

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@

public class MainPresenter extends BasePresenter<MainMvp.View> implements MainMvp.Presenter {

public static MainPresenter with(MainMvp.View view) {
return new MainPresenter(view);
private MainPresenter(@NonNull MainMvp.View view) {
super(view);
}

protected MainPresenter(@NonNull MainMvp.View view) {
super(view);
public static MainPresenter with(MainMvp.View view) {
return new MainPresenter(view);
}

@Override public void onActivityStarted(@Nullable Bundle savedInstance,
Expand Down Expand Up @@ -181,11 +181,11 @@ protected MainPresenter(@NonNull MainMvp.View view) {
.appendQueryParameter("link", Uri.parse(deepLinkBuilder.toString()).toString())
.appendQueryParameter("apn", packageName);
ShareCompat.IntentBuilder.from(mainView)
.setType("message/rfc822")
.setType("message/*")
.setSubject(mainView.getString(R.string.sharing_backup))
.setChooserTitle(mainView.getString(R.string.share_my_backup))
.setHtmlText("<a href='" + Uri.decode(builder.toString()) + "'>" + mainView.getString(R.string.click_here_html) +
"</a></br><b>~" + mainView.getString(R.string.app_name) + "</b>").startChooser();
"</a><br/><b>~" + mainView.getString(R.string.app_name) + "</b>").startChooser();
}

@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class MainView extends BaseActivity<MainMvp.View, MainPresenter> implemen
@BindView(R.id.drawerLayout) DrawerLayout drawerLayout;
@BindView(R.id.bottomNavigation) BottomNavigation bottomNavigation;
@BindView(R.id.fab) FloatingActionButton fab;

private MainPresenter presenter;
private BadgeProvider badgeProvider;
private GoogleApiClient mGoogleApiClient;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<item name="android:colorEdgeEffect">?colorPrimary</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:windowContentTransitions">true</item>m>
<item name="android:windowContentTransitions">true</item>
</style>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<string name="required_field">Required</string>
<string name="apps">Apps</string>
<string name="delete">Delete</string>
<string name="color_picker_hint_folder">Click here to change color</string>
<string name="color_picker_hint_folder">Click here to change the folder color</string>
<string name="select_apps">Select Apps</string>
<string name="add_all">Add All</string>
<string name="remove_all">Remove All</string>
Expand Down Expand Up @@ -119,4 +119,5 @@
<string name="sharing_backup">Hello there!, I\'m sharing my FA backup with you.</string>
<string name="restore_function_not_available">Restore functionality is not available</string>
<string name="click_here_html">Click here to restore my FA backup.</string>
<string name="drag_and_drop_hint"><![CDATA[Drag & Drop to sort the selected apps.]]></string>
</resources>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

20 changes: 3 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
ANDROID_STORE_PASSWORD=koshkosh1
ANDROID_KEY_PASSWORD=koshkosh1
ANDROID_KEY_ALIAS=styleme

0 comments on commit 2000354

Please sign in to comment.