Skip to content

Commit 22585d6

Browse files
committed
Added Rate Us, feedback, share app option; fixed crash in deleteAll files; optimized layout
1 parent 0129223 commit 22585d6

File tree

15 files changed

+223
-112
lines changed

15 files changed

+223
-112
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
vectorDrawables.useSupportLibrary = true
1010
minSdkVersion 19
1111
targetSdkVersion 27
12-
versionCode 4
13-
versionName "2.1"
12+
versionCode 6
13+
versionName "2.3"
1414
}
1515
buildTypes {
1616
release {

app/src/main/java/swati4star/createpdf/activity/MainActivity.java

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package swati4star.createpdf.activity;
22

3+
import android.content.DialogInterface;
34
import android.content.Intent;
5+
import android.net.Uri;
46
import android.os.Bundle;
57
import android.support.annotation.NonNull;
68
import android.support.design.widget.NavigationView;
@@ -9,6 +11,7 @@
911
import android.support.v4.view.GravityCompat;
1012
import android.support.v4.widget.DrawerLayout;
1113
import android.support.v7.app.ActionBarDrawerToggle;
14+
import android.support.v7.app.AlertDialog;
1215
import android.support.v7.app.AppCompatActivity;
1316
import android.support.v7.widget.Toolbar;
1417
import android.view.MenuItem;
@@ -75,6 +78,12 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
7578
case R.id.nav_feedback:
7679
getFeedback();
7780
break;
81+
case R.id.nav_share:
82+
shareApplication();
83+
break;
84+
case R.id.nav_rate_us:
85+
rateUs();
86+
break;
7887
}
7988

8089
DrawerLayout drawer = findViewById(R.id.drawer_layout);
@@ -83,16 +92,57 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
8392
}
8493

8594
private void getFeedback() {
86-
Intent i = new Intent(Intent.ACTION_SEND);
87-
i.setType("message/rfc822");
88-
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"swari4star@gmail.com"});
89-
i.putExtra(Intent.EXTRA_SUBJECT, R.string.feedback_subject);
90-
i.putExtra(Intent.EXTRA_TEXT , R.string.feedback_text);
95+
Intent intent = new Intent(Intent.ACTION_SEND);
96+
intent.setType("message/rfc822");
97+
intent.putExtra(Intent.EXTRA_EMAIL , new String[]{"swari4star@gmail.com"});
98+
intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.feedback_subject));
99+
intent.putExtra(Intent.EXTRA_TEXT , getResources().getString(R.string.feedback_text));
91100
try {
92-
startActivity(Intent.createChooser(i, "Send mail..."));
101+
startActivity(Intent.createChooser(intent, getString(R.string.feedback_chooser)));
93102
} catch (android.content.ActivityNotFoundException ex) {
94-
Toast.makeText(MainActivity.this, R.string.toast_no_email_clients, Toast.LENGTH_SHORT).show();
103+
Toast.makeText(MainActivity.this, getString(R.string.toast_no_email_clients), Toast.LENGTH_SHORT).show();
95104
}
96105
}
97106

107+
private void shareApplication() {
108+
Intent intent = new Intent(Intent.ACTION_SEND);
109+
intent.setType("text/plain");
110+
intent.putExtra(Intent.EXTRA_TEXT , getResources().getString(R.string.rate_us_text));
111+
try {
112+
startActivity(Intent.createChooser(intent, getString(R.string.share_chooser)));
113+
} catch (android.content.ActivityNotFoundException ex) {
114+
Toast.makeText(MainActivity.this, getString(R.string.toast_no_share_app), Toast.LENGTH_SHORT).show();
115+
}
116+
}
117+
118+
private void rateUs() {
119+
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
120+
builder.setTitle(getString(R.string.rate_title))
121+
.setMessage(getString(R.string.rate_dialog_text))
122+
.setNegativeButton(getString(R.string.rate_negative), new DialogInterface.OnClickListener() {
123+
124+
@Override
125+
public void onClick(DialogInterface dialogInterface, int i) {
126+
dialogInterface.cancel();
127+
}
128+
})
129+
.setPositiveButton(getString(R.string.rate_positive), new DialogInterface.OnClickListener() {
130+
@Override
131+
public void onClick(DialogInterface dialogInterface, int i) {
132+
try {
133+
startActivity(new Intent(Intent.ACTION_VIEW,
134+
Uri.parse("market://details?id=" +
135+
getApplicationContext().getPackageName())));
136+
} catch (Exception e) {
137+
Toast.makeText(MainActivity.this,
138+
getString(R.string.playstore_not_installed),
139+
Toast.LENGTH_SHORT).show();
140+
}
141+
dialogInterface.dismiss();
142+
143+
}
144+
});
145+
builder.create().show();
146+
147+
}
98148
}

app/src/main/java/swati4star/createpdf/adapter/ViewFilesAdapter.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,20 @@ private void deleteFile(String name, int position) {
253253

254254
// iterate through filelist and remove all elements
255255
public void deleteFiles() {
256-
ArrayList<File> newList = new ArrayList<>(mFileList);
257256
for (int position : mDeleteNames) {
258-
String fileName = newList.get(position).getPath();
257+
String fileName = mFileList.get(position).getPath();
259258
File fdelete = new File(fileName);
260259
if (fdelete.exists()) {
261-
if (fdelete.delete()) {
262-
newList.remove(position);
263-
} else {
260+
if (!fdelete.delete())
264261
Toast.makeText(mContext, R.string.toast_file_not_deleted, Toast.LENGTH_LONG).show();
265-
}
266262
}
267263
}
264+
265+
ArrayList<File> newList = new ArrayList<>();
266+
for (int position = 0; position < mFileList.size(); position++)
267+
if (!mDeleteNames.contains(position))
268+
newList.add(mFileList.get(position));
269+
268270
mDeleteNames.clear();
269271
if (newList.size() == 0)
270272
ViewFilesFragment.emptyStatusTextView.setVisibility(View.VISIBLE);

app/src/main/java/swati4star/createpdf/fragment/HomeFragment.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import android.view.LayoutInflater;
2525
import android.view.View;
2626
import android.view.ViewGroup;
27-
import android.widget.TextView;
2827
import android.widget.Toast;
2928

3029
import com.afollestad.materialdialogs.MaterialDialog;

app/src/main/java/swati4star/createpdf/fragment/ViewFilesFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private void populateListView() {
252252
ArrayList<File> pdfFiles = new ArrayList<>();
253253
final File[] files = getOrCreatePdfDirectory().listFiles();
254254
if (files == null)
255-
Toast.makeText(mActivity, R.string.toast_no_pdfs, Toast.LENGTH_LONG).show();
255+
Toast.makeText(mActivity, getResources().getString(R.string.toast_no_pdfs), Toast.LENGTH_LONG).show();
256256
else {
257257
pdfFiles = getPdfsFromPdfFolder();
258258
}
230 Bytes
Loading
169 Bytes
Loading
Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
@@ -14,83 +14,82 @@
1414
tools:context=".fragment.HomeFragment"
1515
tools:ignore="Overdraw">
1616

17-
<com.dd.morphingbutton.MorphingButton
18-
android:id="@+id/addImages"
19-
android:layout_width="fill_parent"
17+
<LinearLayout
18+
android:layout_width="match_parent"
2019
android:layout_height="wrap_content"
21-
android:layout_gravity="center"
22-
android:layout_margin="10dp"
23-
android:layout_weight="0"
24-
android:gravity="center"
25-
android:padding="10dp"
26-
android:text="@string/select_images_text"
27-
android:textColor="@color/mb_white" />
20+
android:orientation="vertical">
2821

29-
<com.dd.morphingbutton.MorphingButton
30-
android:id="@+id/pdfOpen"
31-
android:layout_width="fill_parent"
32-
android:layout_height="wrap_content"
33-
android:layout_gravity="center"
34-
android:layout_margin="10dp"
35-
android:layout_weight="0"
36-
android:gravity="center"
37-
android:padding="10dp"
38-
android:text="@string/open_pdf_text"
39-
android:textColor="@color/mb_white"
40-
android:visibility="gone" />
22+
<com.dd.morphingbutton.MorphingButton
23+
android:id="@+id/addImages"
24+
android:layout_width="fill_parent"
25+
android:layout_height="wrap_content"
26+
android:layout_gravity="center"
27+
android:gravity="center"
28+
android:padding="10dp"
29+
android:text="@string/select_images_text"
30+
android:textColor="@color/mb_white" />
4131

42-
<com.dd.morphingbutton.MorphingButton
43-
android:id="@+id/pdfCreate"
44-
android:layout_width="fill_parent"
45-
android:layout_height="wrap_content"
46-
android:layout_gravity="center"
47-
android:layout_margin="10dp"
48-
android:layout_weight="0"
49-
android:gravity="center"
50-
android:padding="10dp"
51-
android:text="@string/create_pdf_text"
52-
android:textColor="@color/mb_white" />
32+
33+
<com.dd.morphingbutton.MorphingButton
34+
android:id="@+id/pdfOpen"
35+
android:layout_width="fill_parent"
36+
android:layout_height="wrap_content"
37+
android:layout_gravity="center"
38+
android:layout_marginTop="10dp"
39+
android:gravity="center"
40+
android:padding="10dp"
41+
android:text="@string/open_pdf_text"
42+
android:textColor="@color/mb_white"
43+
android:visibility="gone" />
44+
45+
<com.dd.morphingbutton.MorphingButton
46+
android:id="@+id/pdfCreate"
47+
android:layout_width="fill_parent"
48+
android:layout_height="wrap_content"
49+
android:layout_gravity="center"
50+
android:layout_marginTop="10dp"
51+
android:gravity="center"
52+
android:padding="10dp"
53+
android:text="@string/create_pdf_text"
54+
android:textColor="@color/mb_white" />
55+
56+
</LinearLayout>
5357

5458
<LinearLayout
5559
android:layout_width="match_parent"
56-
android:layout_height="0dp"
57-
android:layout_weight="1"
60+
android:layout_height="wrap_content"
61+
android:layout_alignParentBottom="true"
62+
android:layout_centerHorizontal="true"
63+
android:layout_gravity="bottom"
64+
android:layout_marginBottom="10dp"
65+
android:background="@drawable/home_imageoptions_border"
5866
android:elevation="1dp"
5967
android:gravity="bottom|center"
6068
android:orientation="vertical"
69+
android:padding="30dp"
6170
tools:targetApi="lollipop">
6271

63-
<LinearLayout
64-
android:layout_width="match_parent"
72+
<TextView
73+
android:layout_width="wrap_content"
6574
android:layout_height="wrap_content"
66-
android:background="@drawable/home_imageoptions_border"
67-
android:orientation="vertical"
68-
android:padding="30dp">
75+
android:layout_gravity="center"
76+
android:layout_marginBottom="10dp"
77+
android:text="@string/image_options_text"
78+
android:textAllCaps="false"
79+
android:textSize="18sp"
80+
android:textStyle="bold" />
6981

70-
<TextView
71-
android:layout_width="wrap_content"
72-
android:layout_height="wrap_content"
73-
android:layout_gravity="center"
74-
android:layout_marginBottom="20dp"
75-
android:text="@string/image_options_text"
76-
android:textAllCaps="false"
77-
android:textSize="18sp"
78-
android:textStyle="bold" />
79-
80-
<com.dd.morphingbutton.MorphingButton
81-
android:id="@+id/cropImages"
82-
android:layout_width="wrap_content"
83-
android:layout_height="0dp"
84-
android:layout_gravity="center"
85-
android:layout_margin="10dp"
86-
android:layout_weight="0"
87-
android:gravity="center"
88-
android:padding="10dp"
89-
android:text="@string/crop_images_text"
90-
android:textColor="@color/mb_white" />
91-
</LinearLayout>
82+
<com.dd.morphingbutton.MorphingButton
83+
android:id="@+id/cropImages"
84+
android:layout_width="wrap_content"
85+
android:layout_height="wrap_content"
86+
android:layout_gravity="center"
87+
android:layout_margin="5dp"
88+
android:gravity="center"
89+
android:padding="10dp"
90+
android:text="@string/crop_images_text"
91+
android:textColor="@color/mb_white" />
9292

9393

9494
</LinearLayout>
95-
96-
</LinearLayout>
95+
</RelativeLayout>
Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
66
android:layout_marginTop="20dp"
77
android:background="@color/mb_white"
88
android:orientation="vertical"
9-
tools:context=".fragment.HomeFragment"
10-
tools:ignore="Overdraw">
9+
tools:context=".fragment.HomeFragment">
1110

12-
<FrameLayout
11+
<android.support.v4.widget.SwipeRefreshLayout
12+
android:id="@+id/swipe"
1313
android:layout_width="match_parent"
1414
android:layout_height="match_parent">
1515

16-
<android.support.v4.widget.SwipeRefreshLayout
17-
android:id="@+id/swipe"
16+
<android.support.v7.widget.RecyclerView
17+
android:id="@+id/filesRecyclerView"
1818
android:layout_width="match_parent"
19-
android:layout_height="match_parent">
19+
android:layout_height="match_parent" />
2020

21-
<android.support.v7.widget.RecyclerView
22-
android:id="@+id/filesRecyclerView"
23-
android:layout_width="match_parent"
24-
android:layout_height="match_parent" />
21+
</android.support.v4.widget.SwipeRefreshLayout>
2522

26-
</android.support.v4.widget.SwipeRefreshLayout>
27-
28-
<TextView
29-
android:id="@+id/emptyStatusTextView"
30-
android:layout_width="match_parent"
31-
android:layout_height="wrap_content"
32-
android:layout_marginTop="25dp"
33-
android:gravity="center"
34-
android:text="@string/toast_no_pdfs"
35-
android:textSize="17sp"
36-
android:visibility="gone" />
37-
38-
</FrameLayout>
23+
<TextView
24+
android:id="@+id/emptyStatusTextView"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:layout_marginTop="25dp"
28+
android:gravity="center"
29+
android:text="@string/toast_no_pdfs"
30+
android:textSize="17sp"
31+
android:visibility="gone" />
3932

40-
</LinearLayout>
33+
</FrameLayout>

app/src/main/res/menu/activity_main_drawer.xml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@
1010
android:id="@+id/nav_gallery"
1111
android:icon="@drawable/ic_menu_gallery"
1212
android:title="@string/viewFiles" />
13-
<item
14-
android:id="@+id/nav_feedback"
15-
android:icon="@drawable/ic_menu_send"
16-
android:title="@string/feedback" />
13+
1714
</group>
1815

16+
<item android:title="@string/extras">
17+
<menu>
18+
<item
19+
android:id="@+id/nav_feedback"
20+
android:icon="@drawable/ic_menu_send"
21+
android:title="@string/feedback" />
22+
<item
23+
android:id="@+id/nav_share"
24+
android:icon="@drawable/baseline_share_black_18dp"
25+
android:title="@string/share" />
26+
<item
27+
android:id="@+id/nav_rate_us"
28+
android:icon="@drawable/baseline_star_rate_black_18dp"
29+
android:title="@string/rate_us" />
30+
31+
</menu>
32+
</item>
1933

2034

2135
</menu>

0 commit comments

Comments
 (0)