Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion"

//utils
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0@aar'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.0'
implementation "com.jakewharton:butterknife:$rootProject.butterknifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterknifeVersion"
implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
Expand Down
94 changes: 43 additions & 51 deletions app/src/main/java/org/fossasia/phimpme/base/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.fossasia.phimpme.base;

import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle;
Expand All @@ -13,16 +13,16 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetSequence;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import org.fossasia.phimpme.R;
import org.fossasia.phimpme.accounts.AccountActivity;
import org.fossasia.phimpme.gallery.activities.LFMainActivity;
import org.fossasia.phimpme.gallery.util.PermissionUtils;
import org.fossasia.phimpme.gallery.util.PreferenceUtil;
import org.fossasia.phimpme.opencamera.Camera.CameraActivity;
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseSequence;
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;
import uk.co.deanwild.materialshowcaseview.ShowcaseConfig;

public abstract class BaseActivity extends AppCompatActivity
implements BottomNavigationView.OnNavigationItemSelectedListener {
Expand Down Expand Up @@ -62,12 +62,11 @@ protected void onCreate(Bundle savedInstanceState) {
nav_cam = findViewById(R.id.navigation_camera);
nav_acc = findViewById(R.id.navigation_accounts);

int checkStoragePermission =
ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE);
if (checkStoragePermission == PackageManager.PERMISSION_GRANTED)
presentShowcaseSequence(); // one second delay

SP = PreferenceUtil.getInstance(getApplicationContext());

if (PermissionUtils.checkPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
&& SP.getBoolean(getResources().getString(R.string.first_time_showcase), true))
presentShowcaseSequence();
}

@Override
Expand All @@ -76,54 +75,47 @@ protected void onResume() {
isSWNavBarChecked = SP.getBoolean(getString(R.string.preference_colored_nav_bar), true);
}

private void presentShowcaseSequence() {

ShowcaseConfig config = new ShowcaseConfig();
config.setDelay(500); // half second between each showcase view

MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(this, SHOWCASE_ID);

sequence.setOnItemShownListener(
new MaterialShowcaseSequence.OnSequenceItemShownListener() {
@Override
public void onShow(MaterialShowcaseView itemView, int position) {
// Toast.makeText(itemView.getContext(), "Item #" + position,
// Toast.LENGTH_SHORT).show();
}
});

sequence.setConfig(config);

sequence.addSequenceItem(
nav_home,
getResources().getString(R.string.home_button),
getResources().getString(R.string.ok_button));

sequence.addSequenceItem(
new MaterialShowcaseView.Builder(this)
.setTarget(nav_cam)
.setDismissText(getResources().getString(R.string.ok_button))
.setContentText(getResources().getString(R.string.camera_button))
.setDismissOnTouch(true)
.build());

sequence.addSequenceItem(
new MaterialShowcaseView.Builder(this)
.setTarget(nav_acc)
.setDismissText(getResources().getString(R.string.ok_button))
.setContentText(getResources().getString(R.string.accounts_button))
.setDismissOnTouch(true)
.build());

sequence.start();
}

@Override
protected void onStart() {
super.onStart();
updateNavigationBarState();
}

private void presentShowcaseSequence() {
new TapTargetSequence(this)
.targets(
TapTarget.forView(nav_home, getResources().getString(R.string.home_button))
.cancelable(true)
.outerCircleAlpha(0.7f)
.textColor(R.color.white)
.transparentTarget(true),
TapTarget.forView(nav_cam, getResources().getString(R.string.camera_button))
.cancelable(true)
.outerCircleAlpha(0.7f)
.textColor(R.color.white)
.transparentTarget(true),
TapTarget.forView(nav_acc, getResources().getString(R.string.accounts_button))
.outerCircleAlpha(0.7f)
.textColor(R.color.white)
.transparentTarget(true))
.listener(
new TapTargetSequence.Listener() {
@Override
public void onSequenceFinish() {
SP.putBoolean(getResources().getString(R.string.first_time_showcase), false);
}

@Override
public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {}

@Override
public void onSequenceCanceled(TapTarget lastTarget) {
SP.putBoolean(getResources().getString(R.string.first_time_showcase), false);
}
})
.start();
}

// Remove inter-activity transition to avoid screen tossing on tapping bottom navigation items
@Override
public void onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import android.view.WindowManager;
import android.widget.Toast;
import androidx.core.content.ContextCompat;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetView;
import com.google.android.material.snackbar.Snackbar;
import java.text.DecimalFormat;
import java.util.ArrayList;
Expand All @@ -69,7 +71,6 @@
import org.fossasia.phimpme.opencamera.Preview.CameraSurface.MyTextureView;
import org.fossasia.phimpme.opencamera.UI.PopupView;
import org.fossasia.phimpme.utilities.SnackBarHandler;
import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;

/**
* This class was originally named due to encapsulating the camera preview, but in practice it's
Expand Down Expand Up @@ -1422,20 +1423,18 @@ public void onFaceDetection(CameraController.Face[] faces) {
@Override
public void onClick(View v) {
SharedPreferences sharedPreferences = getDefaultSharedPreferences(activity);
Boolean firstClick =
sharedPreferences.getBoolean(activity.getString(R.string.first_click), true);
if (firstClick) {
MaterialShowcaseView.resetSingleUse(activity, SHOWCASE_ID);
new MaterialShowcaseView.Builder(activity)
.setTarget(toggle)
.setTitleText(R.string.toggle_button)
.setDismissText(R.string.ok_button)
.setContentText(
R.string.toggle_info) // optional but starting animations immediately in
// onCreate can make them choppy
.singleUse(
SHOWCASE_ID) // provide a unique ID used to ensure it is only shown once
.show();
if (sharedPreferences.getBoolean(activity.getString(R.string.first_click), true)) {
TapTargetView.showFor(
activity,
TapTarget.forView(toggle, getResources().getString(R.string.toggle_info))
.cancelable(true)
.outerCircleAlpha(0.7f)
.textColor(R.color.white)
.transparentTarget(true),
null);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(activity.getString(R.string.first_click), false);
editor.apply();
} else {
try {
final List<String> colorEffect = getSupportedColorEffects();
Expand All @@ -1459,9 +1458,6 @@ public void onClick(View v) {
Log.e(TAG, "ColorEffect List Size Is Null ");
}
}
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(activity.getString(R.string.first_click), false);
editor.apply();
}
});

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1232,12 +1232,10 @@
<string name="home_button">Find all your photos in the device</string>
<string name="accounts_button">Add Multiple Accounts to share amazing photos</string>
<string name="camera_button">Click Amazing Pictures</string>
<string name="ok_button">GOT IT</string>
<string name="speech_not_supported">Sorry! Your device doesn\'t support speech input.</string>
<string name="paint_color_title">Paint Color</string>
<string name="upload_history">Upload History</string>
<string name="trash_bin">Trash Bin</string>
<string name="toggle_button">Toggle Button</string>
<string name="empty_upload_msg">You haven\'t shared anything.</string>
<string name="empty_trashbin_mssg">No Items present currently</string>
<string name="trashbin_mssg">Only images deleted in the Phimpme Android app are present here.</string>
Expand All @@ -1258,6 +1256,7 @@
<string name="text_view">TextView</string>
<string name="version_one">v1.0</string>
<string name="pdf">PDF</string>
<string name="first_time_showcase">first time showcase</string>

<!-- Links -->
<string name="phimpme_website">http://phimp.me/</string>
Expand Down