Skip to content

Commit

Permalink
feat: privacy policy activity, fix: npe on close during movies downlo…
Browse files Browse the repository at this point in the history
…ading
  • Loading branch information
dmytroKarataiev committed Mar 11, 2017
1 parent 9a5db80 commit 9db579c
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 39 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ if (project.hasProperty(propertyConfig)

ext {
compatLibVersion = '25.2.0'
butterknife = '8.4.0'
butterknife = '8.5.1'
retrofit = '2.1.0'
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':license-release')
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$compatLibVersion"
compile "com.android.support:design:$compatLibVersion"
Expand Down
36 changes: 18 additions & 18 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
~ SOFTWARE.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adkdevelopment.moviesdb">
package="com.adkdevelopment.moviesdb">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!-- Needed to check when the network connection changes -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:name="com.adkdevelopment.moviesdb.App"
Expand All @@ -42,7 +42,7 @@
android:name=".data.database.MovieProvider"
android:authorities="com.adkdevelopment.moviesdb"
android:enabled="true"
android:exported="false" />
android:exported="false"/>

<activity
android:name="com.adkdevelopment.moviesdb.ui.DetailActivity"
Expand All @@ -51,15 +51,15 @@
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity" />
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity"/>
</activity>
<activity
android:name="com.adkdevelopment.moviesdb.ui.settings.SettingsActivity"
android:label="@string/pref_sort"
android:parentActivityName="com.adkdevelopment.moviesdb.ui.PagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity" />
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity"/>
</activity>
<activity
android:name="com.adkdevelopment.moviesdb.ui.ActorActivity"
Expand All @@ -68,28 +68,28 @@
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity" />
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity"/>
</activity>
<activity
android:name="com.adkdevelopment.moviesdb.ui.PagerActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<!-- to be searchable by Google -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<data
android:host="adkdevelopment.com"
android:scheme="http" />
android:scheme="http"/>
</intent-filter>
</activity>
<activity
Expand All @@ -100,7 +100,7 @@

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity" />
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity"/>
</activity>
<activity
android:name=".ui.AboutActivity"
Expand All @@ -109,12 +109,12 @@
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity" />
android:value="com.adkdevelopment.moviesdb.ui.PagerActivity"/>
</activity>
<activity android:name=".ui.base.BaseActivity" />
<activity android:name=".ui.base.BaseActivity"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="ca849bf6cdd88797c30d095ddef12b71cc2ce64c" />
android:value="ca849bf6cdd88797c30d095ddef12b71cc2ce64c"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public class MoviesFragment extends BaseFragment
private boolean mAddSearchMovies;
private boolean mIsClearedSearch;
private String mSearchParameter = "";
private FetchMovies mAsyncFetchMovie;
private OkHttpClient mOkhttpClient;

/**
* Returns a new instance of this fragment for the given section
Expand Down Expand Up @@ -304,8 +306,8 @@ public void onPause() {
* @param sort to fetch data sorted with the parameter
*/
private void fetchMovies(String sort) {
FetchMovies fetchMovie = new FetchMovies(mIsSearch, mCurrentPage);
fetchMovie.execute(sort);
mAsyncFetchMovie = new FetchMovies(mIsSearch, mCurrentPage);
mAsyncFetchMovie.execute(sort);
}

/**
Expand Down Expand Up @@ -340,8 +342,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}
}

// TODO: 6/2/16 change to Rx

// TODO: 6/2/16 change to Rx
/**
* Class to retrieve MovieObjects from JSON on background thread
*/
Expand Down Expand Up @@ -373,7 +374,7 @@ protected ArrayList<MovieObject> doInBackground(String... params) {
}

// Network Client
OkHttpClient client = new OkHttpClient();
mOkhttpClient = new OkHttpClient();

// Will contain the raw JSON response as a string.
String movieJsonStr = "";
Expand All @@ -387,7 +388,8 @@ protected ArrayList<MovieObject> doInBackground(String... params) {
Request request = new Request.Builder()
.url(url)
.build();
Response responses = client.newCall(request).execute();

Response responses = mOkhttpClient.newCall(request).execute();
movieJsonStr = responses.body().string();
responses.body().close();
} catch (IOException e) {
Expand Down Expand Up @@ -495,6 +497,12 @@ public void showSortMenu(View view) {
@Override
public void onDestroy() {
super.onDestroy();
if (mOkhttpClient != null) {
mOkhttpClient.dispatcher().cancelAll();
}
if (mAsyncFetchMovie != null && !mAsyncFetchMovie.isCancelled()) {
mAsyncFetchMovie.cancel(true);
}
mUnbinder.unbind();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import android.widget.ImageView;
import android.widget.TextView;

import com.adkdevelopment.license.ui.LicenseActivity;
import com.adkdevelopment.moviesdb.R;
import com.adkdevelopment.moviesdb.ui.adapters.PagerAdapter;
import com.adkdevelopment.moviesdb.ui.base.BaseActivity;
Expand Down Expand Up @@ -302,6 +303,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_about:
startActivity(new Intent(this, AboutActivity.class));
return true;
case R.id.action_license:
startActivity(new Intent(this, LicenseActivity.class));
return true;
}

return super.onOptionsItemSelected(item);
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/java/com/adkdevelopment/moviesdb/utils/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,9 @@ public static String[] posterSize(Context context) {
* @return current sort preference
*/
public static String getSort(Context context) {
if (context != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getString(context.getString(R.string.pref_sort_key),
context.getString(R.string.pref_sort_default));
} else {
return "";
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getString(context.getString(R.string.pref_sort_key),
context.getString(R.string.pref_sort_default));
}

/**
Expand Down
21 changes: 15 additions & 6 deletions app/src/main/res/menu/menu_pager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.adkdevelopment.moviesdb.ui.MainActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.adkdevelopment.moviesdb.ui.MainActivity">

<item
android:id="@+id/action_settings"
android:orderInCategory="200"
android:orderInCategory="2"
android:title="@string/action_settings"
app:showAsAction="never" />
app:showAsAction="never"/>

<item
android:id="@+id/action_about"
android:orderInCategory="1"
android:title="@string/title_activity_about"
app:showAsAction="never" />
app:showAsAction="never"/>

<item
android:id="@+id/action_license"
android:orderInCategory="3"
android:title="@string/title_activity_license"
app:showAsAction="never"/>

</menu>
90 changes: 90 additions & 0 deletions app/src/main/res/values/license.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ The MIT License (MIT)
~
~ Copyright (c) 2017. Dmytro Karataiev
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<resources>

<string name="license">
<![CDATA[
<body><h2>Privacy Policy</h2>
<p> Dmytro Karataiev built the The Movie Database app as an Open Source app. This SERVICE is provided by Dmytro
Karataiev at no cost and is intended for use as is. </p>
<p>This page is used to inform website visitors regarding my policies with the collection, use, and disclosure of
Personal Information if anyone decided to use my Service. </p>
<p>If you choose to use my Service, then you agree to the collection and use of information in relation to this policy.
The Personal Information that I collect is used for providing and improving the Service. I will not use or share
your information with anyone except as described in this Privacy Policy. </p>
<p>The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at
The Movie Database unless otherwise defined in this Privacy Policy. </p>
<p><strong>Information Collection and Use</strong></p>
<p>For a better experience, while using our Service, I may require you to provide us with certain personally
identifiable information, including but not limited to Nothing. The information that I request is retained on your
device and is not collected by me in any way </p>
<p>The app does use third party services that may collect information used to identify you. </p>
<p><strong>Log Data</strong></p>
<p> I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and
information (through third party products) on your phone called Log Data. This Log Data may include information such
as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app
when utilizing my Service, the time and date of your use of the Service, and other statistics. </p>
<p><strong>Cookies</strong></p>
<p>Cookies are files with small amount of data that is commonly used an anonymous unique identifier. These are sent to
your browser from the website that you visit and are stored on your device internal memory. </p>
<p>This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that
use “cookies” to collection information and to improve their services. You have the option to either accept or
refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you
may not be able to use some portions of this Service. </p>
<p><strong>Service Providers</strong></p>
<p> I may employ third-party companies and individuals due to the following reasons:</p>
<ul>
<li>To facilitate our Service;</li>
<li>To provide the Service on our behalf;</li>
<li>To perform Service-related services; or</li>
<li>To assist us in analyzing how our Service is used.</li>
</ul>
<p> I want to inform users of this Service that these third parties have access to your Personal Information. The reason
is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the
information for any other purpose. </p>
<p><strong>Security</strong></p>
<p> I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable
means of protecting it. But remember that no method of transmission over the internet, or method of electronic
storage is 100% secure and reliable, and I cannot guarantee its absolute security. </p>
<p><strong>Links to Other Sites</strong></p>
<p>This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site.
Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy
of these websites. I have no control over and assume no responsibility for the content, privacy policies, or
practices of any third-party sites or services. </p>
<p><strong>Children’s Privacy</strong></p>
<p>These Services do not address anyone under the age of 13. I do not knowingly collect personally identifiable
information from children under 13. In the case I discover that a child under 13 has provided me with personal
information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your
child has provided us with personal information, please contact me so that I will be able to do necessary
actions. </p>
<p><strong>Changes to This Privacy Policy</strong></p>
<p> I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any
changes. I will notify you of any changes by posting the new Privacy Policy on this page. These changes are
effective immediately after they are posted on this page. </p>
</body>
]]>
</string>
</resources>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file added license-release/app-release.aar
Binary file not shown.
2 changes: 2 additions & 0 deletions license-release/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
configurations.maybeCreate("default")
artifacts.add("default", file('app-release.aar'))
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
* SOFTWARE.
*/

include ':app'
include ':app', ':license-release'

0 comments on commit 9db579c

Please sign in to comment.