Eric Kok
11 years ago
43 changed files with 1547 additions and 36 deletions
After Width: | Height: | Size: 342 B |
After Width: | Height: | Size: 216 B |
After Width: | Height: | Size: 355 B |
After Width: | Height: | Size: 617 B |
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" > |
||||||
|
|
||||||
|
<ImageButton |
||||||
|
android:id="@+id/overflow_button" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_gravity="right|center_vertical" |
||||||
|
android:background="@drawable/abs__item_background_holo_light" |
||||||
|
android:contentDescription="@string/pref_addseedbox" |
||||||
|
android:padding="5dp" |
||||||
|
android:src="@drawable/ic_action_overflow" /> |
||||||
|
|
||||||
|
</FrameLayout> |
@ -0,0 +1,39 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<!-- |
||||||
|
Copyright 2010-2013 Eric Kok et al. |
||||||
|
|
||||||
|
Transdroid is free software: you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation, either version 3 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
Transdroid is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
--> |
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > |
||||||
|
|
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_seedstuff_name" |
||||||
|
android:title="@string/pref_name" |
||||||
|
android:summary="@string/pref_name_optional" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_seedstuff_server" |
||||||
|
android:title="@string/pref_seedbox_server" |
||||||
|
android:summary="@string/pref_seedbox_seedstuffhint" |
||||||
|
android:inputType="textUri" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_seedstuff_user" |
||||||
|
android:title="@string/pref_user" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_seedstuff_pass" |
||||||
|
android:title="@string/pref_pass" |
||||||
|
android:inputType="textPassword" /> |
||||||
|
|
||||||
|
</PreferenceScreen> |
@ -0,0 +1,45 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<!-- |
||||||
|
Copyright 2010-2013 Eric Kok et al. |
||||||
|
|
||||||
|
Transdroid is free software: you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation, either version 3 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
Transdroid is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
--> |
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > |
||||||
|
|
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirvikdedi_name" |
||||||
|
android:title="@string/pref_name" |
||||||
|
android:summary="@string/pref_name_optional" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<ListPreference |
||||||
|
android:key="seedbox_xirvikdedi_client" |
||||||
|
android:title="@string/pref_seedbox_client" |
||||||
|
android:summary="@string/pref_seedbox_client_info" |
||||||
|
android:entries="@array/pref_seedbox_xirvikclients" |
||||||
|
android:entryValues="@array/pref_seedbox_xirviktypes" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirvikdedi_server" |
||||||
|
android:title="@string/pref_seedbox_server" |
||||||
|
android:summary="@string/pref_seedbox_xirvikhint" |
||||||
|
android:inputType="textUri" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirvikdedi_user" |
||||||
|
android:title="@string/pref_user" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirvikdedi_pass" |
||||||
|
android:title="@string/pref_pass" |
||||||
|
android:inputType="textPassword" /> |
||||||
|
|
||||||
|
</PreferenceScreen> |
@ -0,0 +1,39 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<!-- |
||||||
|
Copyright 2010-2013 Eric Kok et al. |
||||||
|
|
||||||
|
Transdroid is free software: you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation, either version 3 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
Transdroid is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
--> |
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > |
||||||
|
|
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_name" |
||||||
|
android:title="@string/pref_name" |
||||||
|
android:summary="@string/pref_name_optional" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_server" |
||||||
|
android:title="@string/pref_seedbox_server" |
||||||
|
android:summary="@string/pref_seedbox_xirvikhint2" |
||||||
|
android:inputType="textUri" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_user" |
||||||
|
android:title="@string/pref_user" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_pass" |
||||||
|
android:title="@string/pref_pass" |
||||||
|
android:inputType="textPassword" /> |
||||||
|
|
||||||
|
</PreferenceScreen> |
@ -0,0 +1,39 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<!-- |
||||||
|
Copyright 2010-2013 Eric Kok et al. |
||||||
|
|
||||||
|
Transdroid is free software: you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation, either version 3 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
Transdroid is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
--> |
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > |
||||||
|
|
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_name" |
||||||
|
android:title="@string/pref_name" |
||||||
|
android:summary="@string/pref_name_optional" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_server" |
||||||
|
android:title="@string/pref_seedbox_server" |
||||||
|
android:summary="@string/pref_seedbox_xirvikhint2" |
||||||
|
android:inputType="textUri" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_user" |
||||||
|
android:title="@string/pref_user" |
||||||
|
android:inputType="textNoSuggestions" /> |
||||||
|
<EditTextPreference |
||||||
|
android:key="seedbox_xirviksemi_pass" |
||||||
|
android:title="@string/pref_pass" |
||||||
|
android:inputType="textPassword" /> |
||||||
|
|
||||||
|
</PreferenceScreen> |
@ -0,0 +1,117 @@ |
|||||||
|
package org.transdroid.core.gui.settings; |
||||||
|
|
||||||
|
import org.transdroid.core.R; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.preference.Preference; |
||||||
|
import android.util.AttributeSet; |
||||||
|
import android.view.View; |
||||||
|
import android.view.View.OnClickListener; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.widget.ImageButton; |
||||||
|
|
||||||
|
/** |
||||||
|
* A {@link Preference} item that shows an extra overflow button at the right side of the screen. The action attached to |
||||||
|
* this button is set using {@link #setOnOverflowClickedListener(OnOverflowClicked)}. Normal clicks on this preference |
||||||
|
* are handled in the standard way. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public class OverflowPreference extends Preference { |
||||||
|
|
||||||
|
private OnPreferenceClickListener onPreferenceClickListener = null; |
||||||
|
private OnOverflowClicked onOverflowClickedListener = null; |
||||||
|
private ImageButton overflowButton = null; |
||||||
|
|
||||||
|
public OverflowPreference(Context context) { |
||||||
|
super(context); |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
public OverflowPreference(Context context, AttributeSet attrs) { |
||||||
|
super(context, attrs); |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
public OverflowPreference(Context context, AttributeSet attrs, int defStyle) { |
||||||
|
super(context, attrs, defStyle); |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected View onCreateView(ViewGroup parent) { |
||||||
|
View layout = super.onCreateView(parent); |
||||||
|
// Since the Preference layout is now created, we can attach the proper click listeners
|
||||||
|
layout.setClickable(true); |
||||||
|
layout.setFocusable(true); |
||||||
|
// When setting the background drawable the padding on this Preference layout disappears, so add it again
|
||||||
|
int bottom = layout.getPaddingBottom(); |
||||||
|
int top = layout.getPaddingTop(); |
||||||
|
int right = layout.getPaddingRight(); |
||||||
|
int left = layout.getPaddingLeft(); |
||||||
|
layout.setBackgroundResource(R.drawable.abs__item_background_holo_light); |
||||||
|
layout.setPadding(left, top, right, bottom); |
||||||
|
layout.setOnClickListener(new OnClickListener() { |
||||||
|
@Override |
||||||
|
public void onClick(View v) { |
||||||
|
if (onPreferenceClickListener != null) |
||||||
|
onPreferenceClickListener.onPreferenceClick(OverflowPreference.this); |
||||||
|
} |
||||||
|
}); |
||||||
|
overflowButton = (ImageButton) layout.findViewById(R.id.overflow_button); |
||||||
|
overflowButton.setOnClickListener(new OnClickListener() { |
||||||
|
@Override |
||||||
|
public void onClick(View v) { |
||||||
|
if (onOverflowClickedListener != null) |
||||||
|
onOverflowClickedListener.onOverflowClicked(v); |
||||||
|
} |
||||||
|
}); |
||||||
|
return layout; |
||||||
|
} |
||||||
|
|
||||||
|
public void init() { |
||||||
|
// Load an overflow-style image button as custom widget in the right of this Preference layout
|
||||||
|
setWidgetLayoutResource(R.layout.pref_withoverflow); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Hides the overflow button (on the right side of the Preference) from the UI. |
||||||
|
*/ |
||||||
|
public void hideOverflowButton() { |
||||||
|
if (overflowButton != null) { |
||||||
|
overflowButton.setVisibility(View.GONE); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Shows (after hiding it) the overflow button (on the right side of the Preference) in the UI. |
||||||
|
*/ |
||||||
|
public void showOverflowButton() { |
||||||
|
if (overflowButton != null) { |
||||||
|
overflowButton.setVisibility(View.VISIBLE); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener) { |
||||||
|
// Instead of the build-in list item click behaviour, we have to manually assign the click listener to this
|
||||||
|
// Preference item, as we stole the focus behaviour when we added a Button to the Preference layout
|
||||||
|
this.onPreferenceClickListener = onPreferenceClickListener; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Registers the listener for clicks on the overflow button contained in this preference. |
||||||
|
* @param onOverflowClickedListener The overflow button click listener |
||||||
|
*/ |
||||||
|
public void setOnOverflowClickedListener(OnOverflowClicked onOverflowClickedListener) { |
||||||
|
this.onOverflowClickedListener = onOverflowClickedListener; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* An interface to be implemented by any activity (or otherwise) that wants to handle events when the contained |
||||||
|
* overflow button is clicked. |
||||||
|
*/ |
||||||
|
public interface OnOverflowClicked { |
||||||
|
public void onOverflowClicked(View overflowButton); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,98 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
import org.transdroid.core.gui.settings.ServerPreference; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.preference.Preference; |
||||||
|
|
||||||
|
/** |
||||||
|
* Represents a {@link ServerSetting} in a preferences screen, as constructed for a specific {@link SeedboxProvider}. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public class SeedboxPreference extends ServerPreference { |
||||||
|
|
||||||
|
private SeedboxProvider provider = null; |
||||||
|
private OnSeedboxClickedListener onSeedboxClickedListener = null; |
||||||
|
private int onSeedboxClickedListenerOffset = 0; |
||||||
|
|
||||||
|
public SeedboxPreference(Context context) { |
||||||
|
super(context); |
||||||
|
setOnPreferenceClickListener(onSeedboxPreferenceClicked); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the seedbox provider that this server settings object is constructed for. |
||||||
|
* @param provider The seedbox provider type |
||||||
|
* @return Itself, for method chaining |
||||||
|
*/ |
||||||
|
public SeedboxPreference setProvider(SeedboxProvider provider) { |
||||||
|
this.provider = provider; |
||||||
|
setSummary(provider.getSettings().getName()); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the server settings object that is bound to this preference item. This seedbox=specific implementation does |
||||||
|
* not show the human readable server connection string, but the seedbox provider name. |
||||||
|
* @param serverSetting The server settings |
||||||
|
* @return Itself, for method chaining |
||||||
|
*/ |
||||||
|
public SeedboxPreference setServerSetting(ServerSetting serverSetting) { |
||||||
|
super.setServerSetting(serverSetting); |
||||||
|
if (this.provider != null) |
||||||
|
setSummary(provider.getSettings().getName()); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the seedbox provider for which this server is constructed. |
||||||
|
* @return The seedbox provider type of this server |
||||||
|
*/ |
||||||
|
public SeedboxProvider getSeedboxProvider() { |
||||||
|
return provider; |
||||||
|
} |
||||||
|
|
||||||
|
private OnPreferenceClickListener onSeedboxPreferenceClicked = new OnPreferenceClickListener() { |
||||||
|
@Override |
||||||
|
public boolean onPreferenceClick(Preference preference) { |
||||||
|
if (onSeedboxClickedListener != null) |
||||||
|
onSeedboxClickedListener.onSeedboxClicked(serverSetting, provider, onSeedboxClickedListenerOffset); |
||||||
|
return true; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Set a listener that will be notified of click events on this preference |
||||||
|
* @param onSeedboxClickedListener The click listener to register |
||||||
|
* @return Itself, for method chaining |
||||||
|
*/ |
||||||
|
public ServerPreference setOnSeedboxClickedListener(OnSeedboxClickedListener onSeedboxClickedListener, |
||||||
|
int seedboxOffset) { |
||||||
|
this.onSeedboxClickedListener = onSeedboxClickedListener; |
||||||
|
this.onSeedboxClickedListenerOffset = seedboxOffset; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public interface OnSeedboxClickedListener { |
||||||
|
public void onSeedboxClicked(ServerSetting serverSetting, SeedboxProvider provider, |
||||||
|
int onSeedboxClickedListenerOffset); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.transdroid.core.gui.settings.KeyBoundPreferencesActivity; |
||||||
|
|
||||||
|
/** |
||||||
|
* Enumeration of all available seedbox types. Every type needs a {@link SeedboxSettings} implementation to access and |
||||||
|
* modify settings, which includes a {@link KeyBoundPreferencesActivity} to allow a user to configure the settings. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public enum SeedboxProvider { |
||||||
|
|
||||||
|
Seedstuff { |
||||||
|
@Override |
||||||
|
public SeedboxSettings getSettings() { |
||||||
|
return new SeedstuffSettings(); |
||||||
|
} |
||||||
|
}, |
||||||
|
XirvikShared { |
||||||
|
@Override |
||||||
|
public SeedboxSettings getSettings() { |
||||||
|
return new XirvikSharedSettings(); |
||||||
|
} |
||||||
|
}, |
||||||
|
XirvikSemi { |
||||||
|
@Override |
||||||
|
public SeedboxSettings getSettings() { |
||||||
|
return new XirvikSemiSettings(); |
||||||
|
} |
||||||
|
}, |
||||||
|
XirvikDedi { |
||||||
|
@Override |
||||||
|
public SeedboxSettings getSettings() { |
||||||
|
return new XirvikDediSettings(); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
public abstract SeedboxSettings getSettings(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,82 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
|
||||||
|
/** |
||||||
|
* Interface to implement by any seedbox type (as appears in the {@link SeedboxProvider} enum) to access and modify |
||||||
|
* seedbox settings for a certain seedbox provider. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public interface SeedboxSettings { |
||||||
|
|
||||||
|
/** |
||||||
|
* Should return the name of the seedbox (and perhaps the seedbox type) |
||||||
|
* @return A human-readable name of this seedbox provider |
||||||
|
*/ |
||||||
|
public String getName(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should return the order number of the last specified seedbox of this type (regardless of other seedbox types). |
||||||
|
* @param prefs The shared preferences to load the settings from |
||||||
|
* @return The order number (id) of the last configured seedbox, or -1 if none are configured. |
||||||
|
*/ |
||||||
|
public int getMaxSeedboxOrder(SharedPreferences prefs); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should return a {@link ServerSetting} object that can connect to the seedbox as identified by the given seedbox |
||||||
|
* provider-unique order. |
||||||
|
* @param prefs The shared preferences to load the settings from |
||||||
|
* @param orderOffset An offset integer to add to the normal order number to assign a app-unique server id to this |
||||||
|
* seedbox |
||||||
|
* @param order The seedbox provider-specific order id referring to the specific seedbox to load settings for |
||||||
|
* @return A server settings object corresponding to the user's seedbox settings for the specified order id |
||||||
|
*/ |
||||||
|
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should return a list of all the {@link ServerSetting}s available for this seedbox type. |
||||||
|
* @param prefs The shared preferences to load the settings from |
||||||
|
* @param orderOffset An offset integer to add to the normal order number to assign a app-unique server id to this |
||||||
|
* seedbox |
||||||
|
* @return A list of all server settings objects that are stored for this seedbox type |
||||||
|
*/ |
||||||
|
public List<ServerSetting> getAllServerSettings(SharedPreferences prefs, int orderOffset); |
||||||
|
|
||||||
|
/** |
||||||
|
* Should remove the settings of a specific seedbox specification as identified by its seedbox provider-unique order |
||||||
|
* number. |
||||||
|
* @param prefs The shared preferences to remove the settings from |
||||||
|
* @param order The id referring to a specific seedbox order number within this type of seedbox |
||||||
|
*/ |
||||||
|
public void removeServerSetting(SharedPreferences prefs, int order); |
||||||
|
|
||||||
|
/** |
||||||
|
* The settings activity in which the user can supply and edit its settings for this specific seedbox type. |
||||||
|
* @param context The activity context from where the settings activity will be started |
||||||
|
* @return An already prepared intent that points to the settings activity for this specific type of seedbox |
||||||
|
*/ |
||||||
|
public Intent getSettingsActivityIntent(Context context); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,95 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Collections; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
|
||||||
|
import android.content.SharedPreferences; |
||||||
|
import android.content.SharedPreferences.Editor; |
||||||
|
|
||||||
|
/** |
||||||
|
* Abstract class that acts as a helper for actual {@link SeedboxSettings} implementations by implementing some |
||||||
|
* functions (partially) to do away with boileplate code. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public abstract class SeedboxSettingsImpl implements SeedboxSettings { |
||||||
|
|
||||||
|
/** |
||||||
|
* Helper method to look up the seedbox type-unique order number of the last configured seedbox. |
||||||
|
* @param prefs The shared preferences object to remove settings from |
||||||
|
* @param uniqueKeyBase The base of the key that is used as identifying (unique) key, for example |
||||||
|
* 'seedbox_myseedbox_name_' |
||||||
|
* @return The order number of the configured seedbox, or 01 if no seedbox is configured of this type |
||||||
|
*/ |
||||||
|
public int getMaxSeedboxOrder(SharedPreferences prefs, String uniqueKeyBase) { |
||||||
|
for (int i = 0; true; i++) { |
||||||
|
if (prefs.getString(uniqueKeyBase + i, null) == null) { |
||||||
|
return i - 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Helper method to remove some seedbox setting as identified by the order number. |
||||||
|
* @param prefs The shared preferences object to remove settings from |
||||||
|
* @param uniqueKeyBase The base of the key that is used as identifying (unique) key, for example |
||||||
|
* 'seedbox_myseedbox_name_' |
||||||
|
* @param removeKeyBases The keys of the stored preferences to remove, for example new String[] { |
||||||
|
* 'seedbox_myseedbox_name_', 'seedbox_myseedbox_address_' } |
||||||
|
* @param order The seedbox-unique order number (id) of the seedbox settings to remove |
||||||
|
*/ |
||||||
|
public void removeServerSetting(SharedPreferences prefs, String uniqueKeyBase, String[] removeKeyBases, int order) { |
||||||
|
if (prefs.getString(uniqueKeyBase + order, null) == null) |
||||||
|
return; |
||||||
|
Editor edit = prefs.edit(); |
||||||
|
int max = getMaxSeedboxOrder(prefs, uniqueKeyBase); |
||||||
|
// Move all settings 'higher' than the one to be removed 'down' one place
|
||||||
|
for (int i = order; i < max; i++) { |
||||||
|
for (String keyBase : removeKeyBases) { |
||||||
|
edit.putString(keyBase + i, prefs.getString(keyBase + (i + 1), null)); |
||||||
|
} |
||||||
|
} |
||||||
|
// Remove the last seedbox settings, of which we are now sure are no longer required
|
||||||
|
for (String keyBase : removeKeyBases) { |
||||||
|
edit.remove(keyBase + max); |
||||||
|
} |
||||||
|
edit.commit(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Helper method to provide server settings for every configured seedbox of this type. |
||||||
|
* @param prefs The shared preferences object to remove settings from |
||||||
|
* @param orderOffset The offset to use when assigning unique ids to the server settings object (added to the |
||||||
|
* seedbox-unique internal order number) |
||||||
|
*/ |
||||||
|
public List<ServerSetting> getAllServerSettings(SharedPreferences prefs, int orderOffset) { |
||||||
|
List<ServerSetting> servers = new ArrayList<ServerSetting>(); |
||||||
|
for (int i = 0; true; i++) { |
||||||
|
ServerSetting settings = getServerSetting(prefs, orderOffset, i); |
||||||
|
if (settings != null) |
||||||
|
servers.add(settings); |
||||||
|
else |
||||||
|
break; |
||||||
|
} |
||||||
|
return Collections.unmodifiableList(servers); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
import org.transdroid.daemon.Daemon; |
||||||
|
import org.transdroid.daemon.OS; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
|
||||||
|
/** |
||||||
|
* Implementation of {@link SeedboxSettings} for Seedstuff seedboxes. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public class SeedstuffSettings extends SeedboxSettingsImpl implements SeedboxSettings { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "Seedstuff"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) { |
||||||
|
// @formatter:off
|
||||||
|
String server = prefs.getString("seedbox_seedstuff_server_" + order, null); |
||||||
|
if (server == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
String user = prefs.getString("seedbox_seedstuff_user_" + order, null); |
||||||
|
String pass = prefs.getString("seedbox_seedstuff_pass_" + order, null); |
||||||
|
return new ServerSetting( |
||||||
|
orderOffset + order, |
||||||
|
prefs.getString("seedbox_seedstuff_name_" + order, null), |
||||||
|
Daemon.rTorrent, |
||||||
|
server, |
||||||
|
null, |
||||||
|
443, |
||||||
|
null, |
||||||
|
443, |
||||||
|
true, |
||||||
|
true, |
||||||
|
null, |
||||||
|
"/user/" + user, |
||||||
|
true, |
||||||
|
user, |
||||||
|
pass, |
||||||
|
null, |
||||||
|
OS.Linux, |
||||||
|
"/rtorrent/downloads", |
||||||
|
"ftp://" + user + "@" + server + ":32001/rtorrent/downloads", |
||||||
|
pass, |
||||||
|
6, |
||||||
|
true, |
||||||
|
true, |
||||||
|
true); |
||||||
|
// @formatter:on
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Intent getSettingsActivityIntent(Context context) { |
||||||
|
return SeedstuffSettingsActivity_.intent(context).get(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMaxSeedboxOrder(SharedPreferences prefs) { |
||||||
|
return getMaxSeedboxOrder(prefs, "seedbox_seedstuff_server_"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void removeServerSetting(SharedPreferences prefs, int order) { |
||||||
|
removeServerSetting(prefs, "seedbox_seedstuff_server_", new String[] { "seedbox_seedstuff_name_", |
||||||
|
"seedbox_seedstuff_server_", "seedbox_seedstuff_user_", "seedbox_seedstuff_pass_" }, order); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.androidannotations.annotations.EActivity; |
||||||
|
import org.androidannotations.annotations.OptionsItem; |
||||||
|
import org.androidannotations.annotations.OptionsMenu; |
||||||
|
import org.transdroid.core.R; |
||||||
|
import org.transdroid.core.gui.settings.*; |
||||||
|
|
||||||
|
import android.annotation.TargetApi; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
import android.os.Build; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.preference.PreferenceManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* Activity that allows for the configuration of a Seedstuff seedbox. The key can be supplied to update an |
||||||
|
* existing server setting instead of creating a new one. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
@EActivity |
||||||
|
@OptionsMenu(resName = "activity_deleteableprefs") |
||||||
|
public class SeedstuffSettingsActivity extends KeyBoundPreferencesActivity { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCreate(Bundle savedInstanceState) { |
||||||
|
super.onCreate(savedInstanceState); |
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||||
|
|
||||||
|
// Load the raw preferences to show in this screen
|
||||||
|
init(R.xml.pref_seedbox_seedstuff, |
||||||
|
SeedboxProvider.Seedstuff.getSettings().getMaxSeedboxOrder( |
||||||
|
PreferenceManager.getDefaultSharedPreferences(this))); |
||||||
|
initTextPreference("seedbox_seedstuff_name"); |
||||||
|
initTextPreference("seedbox_seedstuff_server"); |
||||||
|
initTextPreference("seedbox_seedstuff_user"); |
||||||
|
initTextPreference("seedbox_seedstuff_pass"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
||||||
|
@OptionsItem(android.R.id.home) |
||||||
|
protected void navigateUp() { |
||||||
|
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); |
||||||
|
} |
||||||
|
|
||||||
|
@OptionsItem(resName = "action_removesettings") |
||||||
|
protected void removeSettings() { |
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
||||||
|
SeedboxProvider.Seedstuff.getSettings().removeServerSetting(prefs, key); |
||||||
|
finish(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
import org.transdroid.daemon.Daemon; |
||||||
|
import org.transdroid.daemon.OS; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
|
||||||
|
/** |
||||||
|
* Implementation of {@link SeedboxSettings} for the Xirvik dedicated seedbox. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSettings { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "Xirvik dedicated"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) { |
||||||
|
// @formatter:off
|
||||||
|
String server = prefs.getString("seedbox_xirvikdedi_server_" + order, null); |
||||||
|
if (server == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikdedi_client_" + order, null)); |
||||||
|
String user = prefs.getString("seedbox_xirvikdedi_user_" + order, null); |
||||||
|
String pass = prefs.getString("seedbox_xirvikdedi_pass_" + order, null); |
||||||
|
return new ServerSetting( |
||||||
|
orderOffset + order, |
||||||
|
prefs.getString("seedbox_xirvikdedi_name_" + order, null), |
||||||
|
type, |
||||||
|
server, |
||||||
|
null, |
||||||
|
0, |
||||||
|
null, |
||||||
|
type == Daemon.uTorrent? 5010: 443, |
||||||
|
type == Daemon.uTorrent? false: true, |
||||||
|
type == Daemon.uTorrent? false: true, |
||||||
|
null, |
||||||
|
type == Daemon.Deluge? "/deluge": null, |
||||||
|
true, |
||||||
|
user, |
||||||
|
pass, |
||||||
|
type == Daemon.Deluge? "deluge": null, |
||||||
|
OS.Linux, |
||||||
|
type == Daemon.uTorrent? "/downloads": null, |
||||||
|
"ftp://" + user + "@" + server + "/downloads", |
||||||
|
pass, |
||||||
|
6, |
||||||
|
true, |
||||||
|
true, |
||||||
|
true); |
||||||
|
// @formatter:on
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Intent getSettingsActivityIntent(Context context) { |
||||||
|
return XirvikDediSettingsActivity_.intent(context).get(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMaxSeedboxOrder(SharedPreferences prefs) { |
||||||
|
return getMaxSeedboxOrder(prefs, "seedbox_xirvikdedi_server_"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void removeServerSetting(SharedPreferences prefs, int order) { |
||||||
|
removeServerSetting(prefs, "seedbox_xirvikdedi_server_", new String[] { "seedbox_xirvikdedi_name_", |
||||||
|
"seedbox_xirvikdedi_server_", "seedbox_xirvikdedi_client_", "seedbox_xirvikdedi_user_", |
||||||
|
"seedbox_xirvikdedi_pass_" }, order); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.androidannotations.annotations.EActivity; |
||||||
|
import org.androidannotations.annotations.OptionsItem; |
||||||
|
import org.androidannotations.annotations.OptionsMenu; |
||||||
|
import org.transdroid.core.R; |
||||||
|
import org.transdroid.core.gui.settings.*; |
||||||
|
|
||||||
|
import android.annotation.TargetApi; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
import android.os.Build; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.preference.PreferenceManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* Activity that allows for the configuration of a Xirvik dedicated seedbox. The key can be supplied to update an |
||||||
|
* existing server setting instead of creating a new one. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
@EActivity |
||||||
|
@OptionsMenu(resName = "activity_deleteableprefs") |
||||||
|
public class XirvikDediSettingsActivity extends KeyBoundPreferencesActivity { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCreate(Bundle savedInstanceState) { |
||||||
|
super.onCreate(savedInstanceState); |
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||||
|
|
||||||
|
// Load the raw preferences to show in this screen
|
||||||
|
init(R.xml.pref_seedbox_xirvikdedi, |
||||||
|
SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder( |
||||||
|
PreferenceManager.getDefaultSharedPreferences(this))); |
||||||
|
initTextPreference("seedbox_xirvikdedi_name"); |
||||||
|
initListPreference("seedbox_xirvikdedi_client"); |
||||||
|
initTextPreference("seedbox_xirvikdedi_server"); |
||||||
|
initTextPreference("seedbox_xirvikdedi_user"); |
||||||
|
initTextPreference("seedbox_xirvikdedi_pass"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
||||||
|
@OptionsItem(android.R.id.home) |
||||||
|
protected void navigateUp() { |
||||||
|
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); |
||||||
|
} |
||||||
|
|
||||||
|
@OptionsItem(resName = "action_removesettings") |
||||||
|
protected void removeSettings() { |
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
||||||
|
SeedboxProvider.XirvikDedi.getSettings().removeServerSetting(prefs, key); |
||||||
|
finish(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
import org.transdroid.daemon.Daemon; |
||||||
|
import org.transdroid.daemon.OS; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
|
||||||
|
/** |
||||||
|
* Implementation of {@link SeedboxSettings} for a Xirvik semi-dedicated seedbox. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSettings { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "Xirvik semi-dedi"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) { |
||||||
|
// @formatter:off
|
||||||
|
String server = prefs.getString("seedbox_xirviksemi_server_" + order, null); |
||||||
|
if (server == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
String user = prefs.getString("seedbox_xirviksemi_user_" + order, null); |
||||||
|
String pass = prefs.getString("seedbox_xirviksemi_pass_" + order, null); |
||||||
|
return new ServerSetting( |
||||||
|
orderOffset + order, |
||||||
|
prefs.getString("seedbox_xirviksemi_name_" + order, null), |
||||||
|
Daemon.rTorrent, |
||||||
|
server, |
||||||
|
null, |
||||||
|
0, |
||||||
|
null, |
||||||
|
443, |
||||||
|
true, |
||||||
|
true, |
||||||
|
null, |
||||||
|
"/RPC2", |
||||||
|
true, |
||||||
|
user, |
||||||
|
pass, |
||||||
|
null, |
||||||
|
OS.Linux, |
||||||
|
null, |
||||||
|
"ftp://" + user + "@" + server + "/downloads", |
||||||
|
pass, |
||||||
|
6, |
||||||
|
true, |
||||||
|
true, |
||||||
|
true); |
||||||
|
// @formatter:on
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Intent getSettingsActivityIntent(Context context) { |
||||||
|
return XirvikSemiSettingsActivity_.intent(context).get(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMaxSeedboxOrder(SharedPreferences prefs) { |
||||||
|
return getMaxSeedboxOrder(prefs, "seedbox_xirviksemi_server_"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void removeServerSetting(SharedPreferences prefs, int order) { |
||||||
|
removeServerSetting(prefs, "seedbox_xirviksemi_server_", new String[] { "seedbox_xirviksemi_name_", |
||||||
|
"seedbox_xirviksemi_server_", "seedbox_xirviksemi_user_", "seedbox_xirviksemi_pass_" }, order); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.androidannotations.annotations.EActivity; |
||||||
|
import org.androidannotations.annotations.OptionsItem; |
||||||
|
import org.androidannotations.annotations.OptionsMenu; |
||||||
|
import org.transdroid.core.R; |
||||||
|
import org.transdroid.core.gui.settings.*; |
||||||
|
|
||||||
|
import android.annotation.TargetApi; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
import android.os.Build; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.preference.PreferenceManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* Activity that allows for the configuration of a Xirvik semi-dedicated seedbox. The key can be supplied to update an |
||||||
|
* existing server setting instead of creating a new one. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
@EActivity |
||||||
|
@OptionsMenu(resName = "activity_deleteableprefs") |
||||||
|
public class XirvikSemiSettingsActivity extends KeyBoundPreferencesActivity { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCreate(Bundle savedInstanceState) { |
||||||
|
super.onCreate(savedInstanceState); |
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||||
|
|
||||||
|
// Load the raw preferences to show in this screen
|
||||||
|
init(R.xml.pref_seedbox_xirviksemi, |
||||||
|
SeedboxProvider.XirvikSemi.getSettings().getMaxSeedboxOrder( |
||||||
|
PreferenceManager.getDefaultSharedPreferences(this))); |
||||||
|
initTextPreference("seedbox_xirviksemi_name"); |
||||||
|
initTextPreference("seedbox_xirviksemi_server"); |
||||||
|
initTextPreference("seedbox_xirviksemi_user"); |
||||||
|
initTextPreference("seedbox_xirviksemi_pass"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
||||||
|
@OptionsItem(android.R.id.home) |
||||||
|
protected void navigateUp() { |
||||||
|
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); |
||||||
|
} |
||||||
|
|
||||||
|
@OptionsItem(resName = "action_removesettings") |
||||||
|
protected void removeSettings() { |
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
||||||
|
SeedboxProvider.XirvikSemi.getSettings().removeServerSetting(prefs, key); |
||||||
|
finish(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.transdroid.core.app.settings.ServerSetting; |
||||||
|
import org.transdroid.daemon.Daemon; |
||||||
|
import org.transdroid.daemon.OS; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
|
||||||
|
/** |
||||||
|
* Implementation of {@link SeedboxSettings} for a Xirvik shared seedbox. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
public class XirvikSharedSettings extends SeedboxSettingsImpl implements SeedboxSettings { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "Xirvik shared"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) { |
||||||
|
// @formatter:off
|
||||||
|
String server = prefs.getString("seedbox_xirvikshared_server_" + order, null); |
||||||
|
if (server == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
String user = prefs.getString("seedbox_xirvikshared_user_" + order, null); |
||||||
|
String pass = prefs.getString("seedbox_xirvikshared_pass_" + order, null); |
||||||
|
return new ServerSetting( |
||||||
|
orderOffset + order, |
||||||
|
prefs.getString("seedbox_xirvikshared_name_" + order, null), |
||||||
|
Daemon.rTorrent, |
||||||
|
server, |
||||||
|
null, |
||||||
|
0, |
||||||
|
null, |
||||||
|
443, |
||||||
|
true, |
||||||
|
true, |
||||||
|
null, |
||||||
|
"/RPC2", |
||||||
|
true, |
||||||
|
user, |
||||||
|
pass, |
||||||
|
null, |
||||||
|
OS.Linux, |
||||||
|
null, |
||||||
|
"ftp://" + user + "@" + server + "/downloads", |
||||||
|
pass, |
||||||
|
6, |
||||||
|
true, |
||||||
|
true, |
||||||
|
true); |
||||||
|
// @formatter:on
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Intent getSettingsActivityIntent(Context context) { |
||||||
|
return XirvikSharedSettingsActivity_.intent(context).get(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getMaxSeedboxOrder(SharedPreferences prefs) { |
||||||
|
return getMaxSeedboxOrder(prefs, "seedbox_xirvikshared_server_"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void removeServerSetting(SharedPreferences prefs, int order) { |
||||||
|
removeServerSetting(prefs, "seedbox_xirvikshared_server_", new String[] { "seedbox_xirvikshared_name_", |
||||||
|
"seedbox_xirvikshared_server_", "seedbox_xirvikshared_user_", "seedbox_xirvikshared_pass_" }, order); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2010-2013 Eric Kok et al. |
||||||
|
* |
||||||
|
* Transdroid is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Transdroid is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.transdroid.core.seedbox; |
||||||
|
|
||||||
|
import org.androidannotations.annotations.EActivity; |
||||||
|
import org.androidannotations.annotations.OptionsItem; |
||||||
|
import org.androidannotations.annotations.OptionsMenu; |
||||||
|
import org.transdroid.core.R; |
||||||
|
import org.transdroid.core.gui.settings.*; |
||||||
|
|
||||||
|
import android.annotation.TargetApi; |
||||||
|
import android.content.Intent; |
||||||
|
import android.content.SharedPreferences; |
||||||
|
import android.os.Build; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.preference.PreferenceManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* Activity that allows for the configuration of a Xirvik shared seedbox. The key can be supplied to update an |
||||||
|
* existing server setting instead of creating a new one. |
||||||
|
* @author Eric Kok |
||||||
|
*/ |
||||||
|
@EActivity |
||||||
|
@OptionsMenu(resName = "activity_deleteableprefs") |
||||||
|
public class XirvikSharedSettingsActivity extends KeyBoundPreferencesActivity { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onCreate(Bundle savedInstanceState) { |
||||||
|
super.onCreate(savedInstanceState); |
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
||||||
|
|
||||||
|
// Load the raw preferences to show in this screen
|
||||||
|
init(R.xml.pref_seedbox_xirvikshared, |
||||||
|
SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder( |
||||||
|
PreferenceManager.getDefaultSharedPreferences(this))); |
||||||
|
initTextPreference("seedbox_xirvikshared_name"); |
||||||
|
initTextPreference("seedbox_xirvikshared_server"); |
||||||
|
initTextPreference("seedbox_xirvikshared_user"); |
||||||
|
initTextPreference("seedbox_xirvikshared_pass"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
||||||
|
@OptionsItem(android.R.id.home) |
||||||
|
protected void navigateUp() { |
||||||
|
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); |
||||||
|
} |
||||||
|
|
||||||
|
@OptionsItem(resName = "action_removesettings") |
||||||
|
protected void removeSettings() { |
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
||||||
|
SeedboxProvider.XirvikShared.getSettings().removeServerSetting(prefs, key); |
||||||
|
finish(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<!-- |
||||||
|
Copyright 2010-2013 Eric Kok et al. |
||||||
|
|
||||||
|
Transdroid is free software: you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation, either version 3 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
Transdroid is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
--> |
||||||
|
<resources> |
||||||
|
|
||||||
|
<!-- Used to enable the search UI --> |
||||||
|
<bool name="search_available">true</bool> |
||||||
|
<!-- Used to enable the RSS UI and background service --> |
||||||
|
<bool name="rss_available">true</bool> |
||||||
|
<!-- Used to allow adding of seedboxes via easy server setup --> |
||||||
|
<bool name="seedboxes_available">true</bool> |
||||||
|
|
||||||
|
</resources> |
@ -0,0 +1,27 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<!-- |
||||||
|
Copyright 2010-2013 Eric Kok et al. |
||||||
|
|
||||||
|
Transdroid is free software: you can redistribute it and/or modify |
||||||
|
it under the terms of the GNU General Public License as published by |
||||||
|
the Free Software Foundation, either version 3 of the License, or |
||||||
|
(at your option) any later version. |
||||||
|
|
||||||
|
Transdroid is distributed in the hope that it will be useful, |
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
GNU General Public License for more details. |
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License |
||||||
|
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||||
|
--> |
||||||
|
<resources> |
||||||
|
|
||||||
|
<!-- Used to enable the search UI --> |
||||||
|
<bool name="search_available">false</bool> |
||||||
|
<!-- Used to enable the RSS UI and background service --> |
||||||
|
<bool name="rss_available">false</bool> |
||||||
|
<!-- Used to allow adding of seedboxes via easy server setup --> |
||||||
|
<bool name="seedboxes_available">true</bool> |
||||||
|
|
||||||
|
</resources> |
Loading…
Reference in new issue