8 커밋 7838430b15 ... d353d3d4a2

작성자 SHA1 메시지 날짜
  Nathan van Beelen d353d3d4a2 Update 'README.md' 6 년 전
  Nathan van Beelen b8f508c58a Change version number for new release 6 년 전
  Nathan van Beelen 69bd84586d Update Dutch translation 6 년 전
  Nathan van Beelen 1cfa590880 Add preference to save the version code 6 년 전
  Nathan van Beelen b10368ea35 Remove date specification for the filter end date 6 년 전
  Nathan van Beelen 2e68521c68 Fix searching and filtering in fragments 6 년 전
  Nathan van Beelen 3e401d3be7 Merge branch 'fix-getcorpos' of wwwutz/MovieDB into master 6 년 전
  Peter Marquardt c05e701fbb fix getCorrectedPosition() to return corrected position 6 년 전

+ 3 - 0
README.md

@@ -5,6 +5,9 @@ MovieDB is an offline movie database android application. The movies are request
 
 **Get it on [F-Droid](https://f-droid.org/repository/browse/?fdid=org.notabug.lifeuser.moviedb)!**
 
+
+From version 2.0.0 onwards MovieDB makes use of [Semver](https://semver.org).
+
 ## Build instructions
 
 This application can be compiled in android studio.

+ 2 - 2
app/build.gradle

@@ -26,8 +26,8 @@ android {
         applicationId "org.notabug.lifeuser.moviedb"
         minSdkVersion 15
         targetSdkVersion 25
-        versionCode 190
-        versionName "1.9.0"
+        versionCode 200
+        versionName "2.0.0"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {

+ 1 - 0
app/release/output.json

@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":200,"versionName":"2.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

+ 0 - 4
app/src/main/java/org/notabug/lifeuser/moviedb/activity/FilterActivity.java

@@ -526,7 +526,6 @@ public class FilterActivity extends AppCompatActivity {
         final DatePicker datePicker = (DatePicker) dialogView.findViewById(R.id.movieDatePicker);
 
         // Retrieve the date from SharedPreferences and set it in the DatePicker.
-        // If not available, use today (or 2000).
         if (view.getTag().equals("start_date")) {
             String startDate;
             if ((startDate = sharedPreferences.getString(FILTER_START_DATE, null)) != null) {
@@ -538,9 +537,6 @@ public class FilterActivity extends AppCompatActivity {
             String endDate;
             if ((endDate = sharedPreferences.getString(FILTER_END_DATE, null)) != null) {
                 setDatePickerDate(datePicker, endDate);
-            } else {
-                // Set the date to 2000.
-                setDatePickerDate(datePicker, "01-01-2000");
             }
         }
 

+ 25 - 9
app/src/main/java/org/notabug/lifeuser/moviedb/activity/MainActivity.java

@@ -19,7 +19,6 @@
 
 package org.notabug.lifeuser.moviedb.activity;
 
-import android.annotation.SuppressLint;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -72,6 +71,7 @@ public class MainActivity extends BaseActivity {
     private final static int REQUEST_CODE_ASK_PERMISSIONS_IMPORT = 124;
     private final static String LIVE_SEARCH_PREFERENCE = "key_live_search";
     private final static String REWATCHED_FIELD_CHANGE_PREFERENCE = "key_rewatched_field_change";
+    private final static String PREVIOUS_APPLICATION_VERSION_PREFERENCE = "key_application_version";
     /**
      * The {@link android.support.v4.view.PagerAdapter} that will provide
      * fragments for each of the sections. We use a
@@ -86,6 +86,7 @@ public class MainActivity extends BaseActivity {
     private boolean isSearchOpened = false;
     private EditText editSearch;
     private SharedPreferences preferences;
+    ViewPager mViewPager;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -106,17 +107,24 @@ public class MainActivity extends BaseActivity {
         /*
       The {@link ViewPager} that will host the section contents.
      */
-        ViewPager mViewPager = (ViewPager) findViewById(R.id.container);
+        mViewPager = (ViewPager) findViewById(R.id.container);
         mViewPager.setAdapter(mSectionsPagerAdapter);
 
         TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
         tabLayout.setupWithViewPager(mViewPager);
 
         preferences = PreferenceManager.getDefaultSharedPreferences(this);
+        int versionNumber;
+        try {
+            versionNumber = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+            versionNumber = -1;
+        }
 
         // The rewatched field has changed to watched, notify users that make use of the database
         // of this change and also tell them that the value is automatically increased by one.
-        if (!preferences.getBoolean(REWATCHED_FIELD_CHANGE_PREFERENCE, false)) {
+        if (!preferences.getBoolean(REWATCHED_FIELD_CHANGE_PREFERENCE, false) && preferences.getInt(PREVIOUS_APPLICATION_VERSION_PREFERENCE, versionNumber) < 190) {
             File dbFile = getDatabasePath(MovieDatabaseHelper.getDatabaseFileName());
 
             // If there is a database.
@@ -174,6 +182,10 @@ public class MainActivity extends BaseActivity {
                 preferences.edit().putBoolean(REWATCHED_FIELD_CHANGE_PREFERENCE, true).apply();
             }
         }
+
+        if (versionNumber != -1) {
+            preferences.edit().putInt(PREVIOUS_APPLICATION_VERSION_PREFERENCE, versionNumber).commit();
+        }
     }
 
     @Override
@@ -223,8 +235,10 @@ public class MainActivity extends BaseActivity {
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         // Needs to be explicitly called otherwise
         // onActivityResult won't trigger in the Fragment.
-        Fragment mCurrentFragment = getSupportFragmentManager().getFragments()
-                .get(mSectionsPagerAdapter.getCurrentFragmentPosition());
+
+        // This is a hack
+        Fragment mCurrentFragment = getSupportFragmentManager()
+                .findFragmentByTag("android:switcher:" + R.id.container + ":" + mViewPager.getCurrentItem());
         mCurrentFragment.onActivityResult(requestCode, resultCode, data);
 
         super.onActivityResult(requestCode, resultCode, data);
@@ -359,8 +373,9 @@ public class MainActivity extends BaseActivity {
      * @param query the search query.
      */
     private void searchInFragment(String query) {
-        @SuppressLint("RestrictedApi") Fragment mCurrentFragment = getSupportFragmentManager()
-                .getFragments().get(mSectionsPagerAdapter.getCurrentFragmentPosition());
+        // This is a hack
+        Fragment mCurrentFragment = getSupportFragmentManager()
+                .findFragmentByTag("android:switcher:" + R.id.container + ":" + mViewPager.getCurrentItem());
 
         if (mCurrentFragment != null) {
             if (mCurrentFragment instanceof ShowFragment) {
@@ -381,8 +396,9 @@ public class MainActivity extends BaseActivity {
      * Cancel the searching process in the fragment.
      */
     private void cancelSearchInFragment() {
-        @SuppressLint("RestrictedApi") Fragment mCurrentFragment = getSupportFragmentManager()
-                .getFragments().get(mSectionsPagerAdapter.getCurrentFragmentPosition());
+        // This is a hack
+        Fragment mCurrentFragment = getSupportFragmentManager()
+                .findFragmentByTag("android:switcher:" + R.id.container + ":" + mViewPager.getCurrentItem());
 
         if (mCurrentFragment != null) {
             if (mCurrentFragment instanceof ShowFragment) {

+ 26 - 43
app/src/main/java/org/notabug/lifeuser/moviedb/adapter/SectionsPagerAdapter.java

@@ -25,7 +25,6 @@ import android.preference.PreferenceManager;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentPagerAdapter;
-import android.view.ViewGroup;
 
 import org.notabug.lifeuser.moviedb.R;
 import org.notabug.lifeuser.moviedb.fragment.ListFragment;
@@ -43,7 +42,6 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
     private final String seriesTabTitle;
     private final String savedTabTitle;
     private final String personTabTitle;
-    private int currentFragmentPosition;
 
     /**
      * Determines the (amount of) Pages to be shown.
@@ -121,21 +119,6 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
         }
     }
 
-    @Override
-    public void setPrimaryItem(ViewGroup container, int position, Object object) {
-        currentFragmentPosition = position;
-        super.setPrimaryItem(container, position, object);
-    }
-
-    /**
-     * Gets the fragment position from the setPrimaryItem method.
-     *
-     * @return the position of the current fragment.
-     */
-    public int getCurrentFragmentPosition() {
-        return currentFragmentPosition;
-    }
-
     /**
      * Returns position based on the Pages that are visible.
      *
@@ -143,31 +126,31 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
      * @return the position of the case that the switch goes to.
      */
     private int getCorrectedPosition(int position) {
-        boolean moviesHidden = preferences.getBoolean(HIDE_MOVIES_PREFERENCE, false);
-        boolean seriesHidden = preferences.getBoolean(HIDE_SERIES_PREFERENCE, false);
-        boolean savedHidden = preferences.getBoolean(HIDE_SAVED_PREFERENCE, false);
-        boolean personHidden = preferences.getBoolean(HIDE_PERSON_PREFERENCE, false);
-
-        switch (position) {
-            case 0:
-                if (!moviesHidden) {
-                    return 0;
-                }
-            case 1:
-                if ((position == 0 || !moviesHidden) && !seriesHidden) {
-                    return 1;
-                }
-            case 2:
-                if ((position < 2 || (!moviesHidden && !seriesHidden)) && !savedHidden) {
-                    return 2;
-                }
-            case 3:
-                if ((position < 3 || (!moviesHidden && !seriesHidden && !savedHidden))
-                        && !personHidden) {
-                    return 3;
-                }
-            default:
-                return -1;
-        }
+        int index = 0;
+        index += preferences.getBoolean(HIDE_MOVIES_PREFERENCE, false) ? 8 : 0;
+        index += preferences.getBoolean(HIDE_SERIES_PREFERENCE, false) ? 4 : 0;
+        index += preferences.getBoolean(HIDE_SAVED_PREFERENCE, false) ? 2 : 0;
+        index += preferences.getBoolean(HIDE_PERSON_PREFERENCE, false) ? 1 : 0;
+
+        int[][] corpos = {
+                {0, 1, 2, 3},    // MOV SER SAV PER
+                {0, 1, 2, -1},   // MOV SER SAV ---
+                {0, 1, 3, -1},   // MOV SER PER ---
+                {0, 1, -1, -1},  // MOV SER --- ---
+                {0, 2, 3, -1},   // MOV SAV PER ---
+                {0, 2, -1, -1},  // MOV SAV --- ---
+                {0, 3, -1, -1},  // MOV PER --- ---
+                {0, -1, -1, -1}, // MOV --- --- ---
+                {1, 2, 3, -1},   // SER SAV PER ---
+                {1, 2, -1, -1},  // SER SAV --- ---
+                {1, 3, -1, -1},  // SER PER --- ---
+                {1, -1, -1, -1}, // SER --- --- ---
+                {2, 3, -1, -1},  // SAV PER --- ---
+                {2, -1, -1, -1}, // SAV --- --- ---
+                {3, -1, -1, -1}, // PER --- --- ---
+                {-1, -1, -1, -1},// --- --- --- ---
+        };
+        // magic!
+        return corpos[index][position];
     }
 }

+ 8 - 8
app/src/main/res/values-nl/strings.xml

@@ -71,7 +71,7 @@
     <string name="best_rated">Beste score</string>
     <string name="release_date">Verschijningsdatum</string>
     <string name="alphabetic_order">Alfabetische volgorde</string>
-    <string name="categories">Categories</string>
+    <string name="categories">Categorieën</string>
     <string name="watching">Nu aan het kijken</string>
     <string name="plan_to_watch">Van plan om te kijken</string>
     <string name="watched">Gezien</string>
@@ -82,7 +82,7 @@
     <string name="end_date">\"Einddatum: \"</string>
     <string name="genres">Genres</string>
     <string name="advanced">Geavanceerd</string>
-    <string name="keyword_text">je kan sleutelwoorden toevoegen of uitsluiten door de bijhorende ids in het juiste tekstveld te zetten. logica wordt toegepast als volgt:\n* gebruik , (komma) om aan te geven dat je beide sleutelwoorden bedoelt.\n* gebruik | (pipe) om aan te geven dat de show maar één van beide hoeft te bevatten.</string>
+    <string name="keyword_text">Je kan sleutelwoorden toevoegen of uitsluiten door de bijhorende ids in het juiste tekstveld te zetten. logica wordt toegepast als volgt:\n* gebruik , (komma) om aan te geven dat je beide sleutelwoorden bedoelt.\n* gebruik | (pipe) om aan te geven dat de show maar één van beide hoeft te bevatten.</string>
     <string name="with_keywords_hint">Shows met de volgende sleutelwoorden toevoegen…</string>
     <string name="without_keywords_hint">Shows met de volgende sleutelwoorden uitsleten…</string>
 
@@ -118,7 +118,7 @@
     <string name="action_save">Opslaan</string>
 
     <!-- Preferences -->
-    <string name="title_general">General</string>
+    <string name="title_general">Algemeen</string>
     <string name="title_show_cast">Cast weergeven</string>
     <string name="title_show_crew">Crew weergeven</string>
     <string name="title_show_similar_shows">Soortgelijke shows weergeven</string>
@@ -145,9 +145,9 @@
     <string name="no_internet_connection">Er is geen internetverbinding</string>
 
     <!-- Image content descriptions -->
-    <string name="collapse_icon_description">Collapses or expands the view</string>
-    <string name="image_description">Poster of the show</string>
-    <string name="person_image_description">Picture of the person</string>
-    <string name="movie_image_description">Image from the show</string>
-    <string name="edit_icon_description">Enables edit mode</string>
+    <string name="collapse_icon_description">Opent of sluit geavanceerd</string>
+    <string name="image_description">Poster van de show</string>
+    <string name="person_image_description">Afbeelding van het persoon</string>
+    <string name="movie_image_description">Afbeelding van de show</string>
+    <string name="edit_icon_description">Zet bewerken aan </string>
 </resources>