Skip to content

Commit

Permalink
fixes issue #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Kojouharov committed Dec 22, 2015
1 parent b314a36 commit 65c8f45
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 50 deletions.
10 changes: 5 additions & 5 deletions gearshift/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'android'

android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
buildToolsVersion '23.0.2'

defaultConfig {
minSdkVersion 16
Expand Down Expand Up @@ -46,10 +46,10 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:support-v4:23.0.+'
compile 'com.android.support:appcompat-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.3.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.0'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.0'
Expand Down
35 changes: 18 additions & 17 deletions gearshift/gearshift.iml
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,30 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes-proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/mockable-android-22.jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/mockable-android-23.jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
Expand All @@ -103,16 +104,16 @@
<orderEntry type="library" exported="" scope="TEST" name="asm-5.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockable-android-23" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="shadows-core-3.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockito-all-1.10.19" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="asm-util-5.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="bcprov-jdk16-1.46" level="project" />
<orderEntry type="library" exported="" name="jackson-annotations-2.3.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="icu4j-53.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="robolectric-resources-3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="robolectric-annotations-3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="sqlite4java-0.282" level="project" />
Expand All @@ -121,8 +122,8 @@
<orderEntry type="library" exported="" scope="TEST" name="robolectric-utils-3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="asm-analysis-5.0.1" level="project" />
<orderEntry type="library" exported="" name="jackson-databind-2.3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="vtd-xml-2.11" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="robolectric-3.0" level="project" />
</component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import org.sugr.gearshift.G;
import org.sugr.gearshift.R;
import org.sugr.gearshift.core.Torrent;
import org.sugr.gearshift.core.TransmissionProfile;
import org.sugr.gearshift.core.TransmissionSession;
import org.sugr.gearshift.core.Torrent;
import org.sugr.gearshift.datasource.DataSource;
import org.sugr.gearshift.datasource.TorrentNameStatus;
import org.sugr.gearshift.service.DataService;
Expand Down Expand Up @@ -178,24 +176,24 @@ public boolean onOptionsItemSelected(final MenuItem item) {
G.TorrentAction action;
switch (item.getItemId()) {
case R.id.remove:
ViewGroup v = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.remove_torrent_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setCancelable(false)
.setView(v)
.setNegativeButton(android.R.string.no, null);

((TextView) v.findViewById(R.id.remove_torrent_text)).setText(
String.format(getString(R.string.remove_current_confirmation),
G.trimTrailingWhitespace(Html.fromHtml(currentTorrentName))));
builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override public void onClick(DialogInterface dialog, int id) {
manager.removeTorrent(hashStrings, false);
context.setRefreshing(true, DataService.Requests.REMOVE_TORRENT);
}
}).setNeutralButton(R.string.remove_with_data, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
manager.removeTorrent(hashStrings, true);
boolean removeData =
((CheckBox) ((AlertDialog) dialog).findViewById(R.id.remove_data))
.isChecked();
manager.removeTorrent(hashStrings, removeData);
context.setRefreshing(true, DataService.Requests.REMOVE_TORRENT);
}
}).setMessage(String.format(getString(R.string.remove_current_confirmation),
G.trimTrailingWhitespace(Html.fromHtml(currentTorrentName))))
.show();
}).show();
return true;
case R.id.resume:
switch(currentTorrentStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,17 @@ public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
manager.removeTorrent(hashStrings, false);
boolean removeData =
((CheckBox) ((AlertDialog) dialog).findViewById(R.id.remove_data))
.isChecked();
manager.removeTorrent(hashStrings, removeData);
((TransmissionSessionInterface) getActivity()).setRefreshing(true,
DataService.Requests.REMOVE_TORRENT);

mode.finish();
}
})
.setNeutralButton(R.string.remove_with_data,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
manager.removeTorrent(hashStrings, true);
((TransmissionSessionInterface) getActivity()).setRefreshing(true,
DataService.Requests.REMOVE_TORRENT);

mode.finish();

}
})
.setMessage(R.string.remove_selected_confirmation)
.setView(getActivity().getLayoutInflater().inflate(R.layout.remove_torrent_dialog, null))
.show();
return true;
case R.id.resume:
Expand Down
23 changes: 23 additions & 0 deletions gearshift/src/main/res/layout/remove_torrent_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical" >

<TextView
android:id="@+id/remove_torrent_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/remove_selected_confirmation"
android:fontFamily="sans-serif-medium"/>

<CheckBox
android:id="@+id/remove_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/remove_with_data" />

</LinearLayout>

0 comments on commit 65c8f45

Please sign in to comment.