Skip to content

Commit

Permalink
Remove "offline watching" functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MizzleDK committed Feb 2, 2016
1 parent 642dfa1 commit 65d22cb
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 626 deletions.
11 changes: 0 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
<service android:name="com.miz.service.MoveFilesService" />
<service android:name="com.miz.service.TraktMoviesSyncService" />
<service android:name="com.miz.service.TraktTvShowsSyncService" />
<service android:name="com.miz.service.MakeAvailableOffline" />
<service android:name="com.miz.service.MovieLibraryUpdate" />
<service android:name="com.miz.service.TvShowsLibraryUpdate" />
<service android:name="com.miz.service.WireUpnpService" />
Expand Down Expand Up @@ -454,16 +453,6 @@
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.miz.mizuu.CancelOfflineDownload"
android:excludeFromRecents="true"
android:exported="false"
android:noHistory="true"
android:theme="@style/Mizuu.Theme.Transparent.Dialog" >
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.miz.mizuu.CancelLibraryUpdate"
android:excludeFromRecents="true"
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/java/com/miz/functions/MizLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@
import com.miz.mizuu.R;
import com.miz.mizuu.TvShow;
import com.miz.mizuu.fragments.ScheduledUpdatesFragment;
import com.miz.service.MakeAvailableOffline;
import com.miz.service.MovieLibraryUpdate;
import com.miz.service.TvShowsLibraryUpdate;
import com.miz.utils.FileUtils;
import com.miz.utils.ViewUtils;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
Expand All @@ -100,7 +98,6 @@
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -1330,18 +1327,6 @@ public static boolean isTvShowLibraryBeingUpdated(Context c) {
return false;
}

public static boolean isLocalCopyBeingDownloaded(Context c) {
ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);
int count = services.size();
for (int i = 0; i < count; i++) {
if (MakeAvailableOffline.class.getName().equals(services.get(i).service.getClassName())) {
return true;
}
}
return false;
}

public static final int HEIGHT = 100, WIDTH = 110;

public static int getDisplaySize(Context c, int type) {
Expand Down
53 changes: 0 additions & 53 deletions app/src/main/java/com/miz/mizuu/CancelOfflineDownload.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import com.miz.mizuu.MovieCoverFanartBrowser;
import com.miz.mizuu.R;
import com.miz.service.DeleteFile;
import com.miz.service.MakeAvailableOffline;
import com.miz.utils.IntentUtils;
import com.miz.utils.LocalBroadcastUtils;
import com.miz.utils.MovieDatabaseUtils;
Expand Down Expand Up @@ -500,18 +499,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

// Only allow the user to browse artwork if it's a valid TMDb movie
menu.findItem(R.id.change_cover).setVisible(MizLib.isValidTmdbId(mMovie.getTmdbId()));

// Go through filepaths and find a network file for offline watching
for (Filepath path : mMovie.getFilepaths()) {
if (path.isNetworkFile()) {
menu.findItem(R.id.watchOffline)
.setVisible(true)
.setTitle(mMovie.hasOfflineCopy(path) ?
R.string.removeOfflineCopy : R.string.watchOffline);

break;
}
}
}

@Override
Expand Down Expand Up @@ -544,9 +531,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
tmdbIntent.setData(Uri.parse("http://www.themoviedb.org/movie/" + mMovie.getTmdbId()));
startActivity(tmdbIntent);
return true;
case R.id.watchOffline:
watchOffline();
return true;
case R.id.change_cover:
searchCover();
return true;
Expand Down Expand Up @@ -776,69 +760,6 @@ public void run() {
}.start();
}

public void watchOffline() {
if (mMovie.getFilepaths().size() == 1) {
watchOffline(mMovie.getFilepaths().get(0));
} else {
MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
watchOffline(mMovie.getFilepaths().get(which));

// Dismiss the dialog
dialog.dismiss();
}
});
}
}

public void watchOffline(final Filepath path) {
if (mMovie.hasOfflineCopy(path)) {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setMessage(getString(R.string.areYouSure))
.setTitle(getString(R.string.removeOfflineCopy))
.setCancelable(false)
.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
boolean success = mMovie.getOfflineCopyFile(path).delete();
if (!success)
mMovie.getOfflineCopyFile(path).delete();
getActivity().invalidateOptionsMenu();
}
})
.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.create().show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setMessage(getString(R.string.downloadOfflineCopy))
.setTitle(getString(R.string.watchOffline))
.setCancelable(false)
.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (MizLib.isLocalCopyBeingDownloaded(mContext))
Toast.makeText(mContext, R.string.addedToDownloadQueue, Toast.LENGTH_SHORT).show();

Intent i = new Intent(mContext, MakeAvailableOffline.class);
i.putExtra(MakeAvailableOffline.FILEPATH, path.getFilepath());
i.putExtra(MakeAvailableOffline.TYPE, MizLib.TYPE_MOVIE);
i.putExtra("thumb", mMovie.getThumbnail().getAbsolutePath());
i.putExtra("backdrop", mMovie.getBackdrop().getAbsolutePath());
mContext.startService(i);
}
})
.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.create().show();
}
}

public void searchCover() {
if (MizLib.isOnline(mContext)) { // Make sure that the device is connected to the web
Intent intent = new Intent(mContext, MovieCoverFanartBrowser.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import com.miz.mizuu.R;
import com.miz.mizuu.TvShowEpisode;
import com.miz.service.DeleteFile;
import com.miz.service.MakeAvailableOffline;
import com.miz.utils.LocalBroadcastUtils;
import com.miz.utils.TvShowDatabaseUtils;
import com.miz.utils.TypefaceUtils;
Expand Down Expand Up @@ -474,23 +473,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
} else {
menu.findItem(R.id.watched).setTitle(R.string.stringMarkAsWatched);
}

for (Filepath path : mEpisode.getFilepaths()) {
if (path.isNetworkFile()) {

// Set the menu item visibility
menu.findItem(R.id.watchOffline).setVisible(true);

if (mEpisode.hasOfflineCopy(path))
// There's already an offline copy, so let's allow the user to remove it
menu.findItem(R.id.watchOffline).setTitle(R.string.removeOfflineCopy);
else
// There's no offline copy, so let the user download one
menu.findItem(R.id.watchOffline).setTitle(R.string.watchOffline);

break;
}
}
} catch (Exception e) {}
}

Expand All @@ -506,9 +488,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.identify:
identifyEpisode();
break;
case R.id.watchOffline:
watchOffline();
break;
case R.id.editTvShowEpisode:
editEpisode();
break;
Expand All @@ -524,70 +503,6 @@ private void editEpisode() {
startActivityForResult(intent, 0);
}

public void watchOffline() {

if (mEpisode.getFilepaths().size() == 1) {
watchOffline(mEpisode.getFilepaths().get(0));
} else {
MizLib.showSelectFileDialog(getActivity(), mEpisode.getFilepaths(), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
watchOffline(mEpisode.getFilepaths().get(which));

// Dismiss the dialog
dialog.dismiss();
}
});
}
}

private void watchOffline(final Filepath path) {
if (mEpisode.hasOfflineCopy(path)) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.areYouSure))
.setTitle(getString(R.string.removeOfflineCopy))
.setCancelable(false)
.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
boolean success = mEpisode.getOfflineCopyFile(path).delete();
if (!success)
mEpisode.getOfflineCopyFile(path).delete();
getActivity().invalidateOptionsMenu();
}
})
.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.create().show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.downloadOfflineCopy))
.setTitle(getString(R.string.watchOffline))
.setCancelable(false)
.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (MizLib.isLocalCopyBeingDownloaded(getActivity()))
Toast.makeText(getActivity(), R.string.addedToDownloadQueue, Toast.LENGTH_SHORT).show();

Intent i = new Intent(getActivity(), MakeAvailableOffline.class);
i.putExtra(MakeAvailableOffline.FILEPATH, path.getFilepath());
i.putExtra(MakeAvailableOffline.TYPE, MizLib.TYPE_SHOWS);
i.putExtra("thumb", mEpisode.getThumbnail().getAbsolutePath());
i.putExtra("backdrop", mEpisode.getEpisodePhoto().getAbsolutePath());
getActivity().startService(i);
}
})
.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.create().show();
}
}

private void identifyEpisode() {
if (mEpisode.getFilepaths().size() == 1) {
getActivity().startActivityForResult(getIdentifyIntent(mEpisode.getFilepaths().get(0).getFullFilepath()), 0);
Expand Down
Loading

0 comments on commit 65d22cb

Please sign in to comment.