Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #321 #341

Merged
merged 19 commits into from
Aug 4, 2018
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
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ dependencies {
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.eftimoff:android-viewpager-transformers:1.0.1@aar'
}

preBuild.dependsOn('checkstyle')
assemble.dependsOn('lint')
check.dependsOn('checkstyle')
35 changes: 35 additions & 0 deletions app/src/main/java/swati4star/createpdf/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
Expand All @@ -14,6 +15,7 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Toast;

import java.util.ArrayList;

Expand Down Expand Up @@ -45,6 +47,9 @@ public class MainActivity extends AppCompatActivity
private FeedbackUtils mFeedbackUtils;
private NavigationView mNavigationView;

private boolean mDoubleBackToExitPressedOnce = false;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -170,8 +175,38 @@ public void onBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
if (getCurrentFragment() instanceof ImageToPdfFragment) {
checkDoubleBackPress();
} else {
Fragment fragment = new ImageToPdfFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.content, fragment).commit();
setDefaultMenuSelected(0);
}
}
}

private void checkDoubleBackPress() {
if (mDoubleBackToExitPressedOnce) {
super.onBackPressed();
return;
}

this.mDoubleBackToExitPressedOnce = true;
Toast.makeText(this, R.string.confirm_exit_message, Toast.LENGTH_SHORT).show();

new Handler().postDelayed(new Runnable() {

@Override
public void run() {
mDoubleBackToExitPressedOnce = false;
}
}, 1500);
}

Fragment getCurrentFragment() {
Fragment currentFragment = getSupportFragmentManager()
.findFragmentById(R.id.content);
return currentFragment;
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@
<string name="image_rearranging_options">Image Rearranging Options</string>
<string name="filter_file_name">%s_%s.jpg</string>
<string name="reset">Reset</string>

<string name="confirm_exit_message">Presione de nuevo para salir</string>
<string name="border">Add Image Border</string>
<string name="enable_doodle_effect">Enable Doodle Effect</string>
<string name="disable_doodle_effect">Disable Doodle Effect</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@
<string name="image_rearranging_options">Image Rearranging Options</string>
<string name="filter_file_name">%s_%s.jpg</string>
<string name="reset">Reset</string>

<string name="confirm_exit_message">Appuyez à nouveau pour quitter</string>
<string name="border">Add Image Border</string>
<string name="enable_doodle_effect">Enable Doodle Effect</string>
<string name="disable_doodle_effect">Disable Doodle Effect</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
<string name="image_rearranging_options">Image Rearranging Options</string>
<string name="filter_file_name">%s_%s.jpg</string>
<string name="reset">Reset</string>

<string name="confirm_exit_message">もう一度戻ると終了します。</string>
<string name="border">Add Image Border</string>
<string name="enable_doodle_effect">Enable Doodle Effect</string>
<string name="disable_doodle_effect">Disable Doodle Effect</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@
<string name="image_rearranging_options">Image Rearranging Options</string>
<string name="filter_file_name">%s_%s.jpg</string>
<string name="reset">Reset</string>

<string name="confirm_exit_message">Press back again to exit</string>

<string name="border">Add Image Border</string>
<string name="enable_doodle_effect">Enable Doodle Effect</string>
<string name="disable_doodle_effect">Disable Doodle Effect</string>
Expand Down