@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
/* |
||||
* 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.gui; |
||||
|
||||
import android.content.Context; |
||||
import android.widget.RelativeLayout; |
||||
import android.widget.TextView; |
||||
|
||||
import org.androidannotations.annotations.EViewGroup; |
||||
import org.androidannotations.annotations.ViewById; |
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.NavigationFilter; |
||||
import org.transdroid.daemon.IDaemonAdapter; |
||||
|
||||
@EViewGroup(R.layout.actionbar_serverselection) |
||||
public class ServerSelectionView extends RelativeLayout { |
||||
|
||||
@ViewById |
||||
protected TextView filterText, serverText; |
||||
|
||||
public ServerSelectionView(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
public ServerSelectionView(TorrentsActivity activity) { |
||||
super(activity.torrentsToolbar.getContext()); |
||||
} |
||||
|
||||
/** |
||||
* Updates the name of the current connected server. |
||||
* @param currentServer The server currently connected to |
||||
*/ |
||||
public void updateCurrentServer(IDaemonAdapter currentServer) { |
||||
serverText.setText(currentServer.getSettings().getName()); |
||||
} |
||||
|
||||
/** |
||||
* Updates the name of the selected filter. |
||||
* @param currentFilter The filter that is currently selected |
||||
*/ |
||||
public void updateCurrentFilter(NavigationFilter currentFilter) { |
||||
filterText.setText(currentFilter.getName()); |
||||
} |
||||
|
||||
} |
@ -1,17 +0,0 @@
@@ -1,17 +0,0 @@
|
||||
package org.transdroid.core.gui.lists; |
||||
|
||||
import org.transdroid.R; |
||||
|
||||
import uk.co.senab.actionbarpulltorefresh.library.DefaultHeaderTransformer; |
||||
import android.app.Activity; |
||||
import android.view.View; |
||||
|
||||
public class NoProgressHeaderTransformer extends DefaultHeaderTransformer { |
||||
|
||||
@Override |
||||
public void onViewCreated(Activity activity, View headerView) { |
||||
super.onViewCreated(activity, headerView); |
||||
setProgressBarColor(activity.getResources().getColor(R.color.green)); |
||||
} |
||||
|
||||
} |
@ -1,70 +0,0 @@
@@ -1,70 +0,0 @@
|
||||
/* |
||||
* 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.gui.navigation; |
||||
|
||||
import org.androidannotations.annotations.EBean; |
||||
import org.transdroid.daemon.IDaemonAdapter; |
||||
|
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
/** |
||||
* List adapter that holds filter items, that is, servers, view types and labels and is displayed as content to a |
||||
* Spinner instead of a ListView. |
||||
* @author Eric Kok |
||||
*/ |
||||
@EBean |
||||
public class FilterListDropDownAdapter extends FilterListAdapter { |
||||
|
||||
protected NavigationSelectionView navigationSelectionView = null; |
||||
private String currentServer = null; |
||||
private String currentFilter = null; |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
// This returns the singleton navigation spinner view
|
||||
if (navigationSelectionView == null) { |
||||
navigationSelectionView = NavigationSelectionView_.build(context); |
||||
} |
||||
navigationSelectionView.bind(currentServer, currentFilter); |
||||
return navigationSelectionView; |
||||
} |
||||
|
||||
@Override |
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) { |
||||
// This returns the item to show in the drop down list
|
||||
return super.getView(position, convertView, parent); |
||||
} |
||||
|
||||
public void updateCurrentFilter(NavigationFilter currentFilter) { |
||||
this.currentFilter = currentFilter.getName(); |
||||
if (navigationSelectionView != null) |
||||
navigationSelectionView.bind(this.currentServer, this.currentFilter); |
||||
} |
||||
|
||||
public void updateCurrentServer(IDaemonAdapter currentConnection) { |
||||
this.currentServer = currentConnection.getSettings().getName(); |
||||
if (navigationSelectionView != null) |
||||
navigationSelectionView.bind(this.currentServer, this.currentFilter); |
||||
} |
||||
|
||||
public void hideServersLabel() { |
||||
serverSeparator.setViewVisibility(View.GONE); |
||||
notifyDataSetInvalidated(); |
||||
} |
||||
|
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
/* |
||||
* 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.gui.navigation; |
||||
|
||||
import org.androidannotations.annotations.EViewGroup; |
||||
import org.androidannotations.annotations.ViewById; |
||||
|
||||
import android.content.Context; |
||||
import android.widget.LinearLayout; |
||||
import android.widget.TextView; |
||||
|
||||
/** |
||||
* View that displays the user-selected server and display filter inside the action bar list navigation spinner |
||||
* @author Eric Kok |
||||
*/ |
||||
@EViewGroup(resName="actionbar_navigation") |
||||
public class NavigationSelectionView extends LinearLayout { |
||||
|
||||
@ViewById |
||||
protected TextView filterText; |
||||
@ViewById |
||||
protected TextView serverText; |
||||
|
||||
public NavigationSelectionView(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
/** |
||||
* Binds the names of the current connected server and selected filter to this navigation view. |
||||
* @param currentServer The name of the server currently connected to |
||||
* @param currentFilter The name of the filter that is currently selected |
||||
*/ |
||||
public void bind(String currentServer, String currentFilter) { |
||||
serverText.setText(currentServer); |
||||
filterText.setText(currentFilter); |
||||
} |
||||
|
||||
} |
@ -1,117 +0,0 @@
@@ -1,117 +0,0 @@
|
||||
package org.transdroid.core.gui.settings; |
||||
|
||||
import org.transdroid.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.selectable_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,65 @@
@@ -0,0 +1,65 @@
|
||||
package org.transdroid.core.gui.settings; |
||||
|
||||
import android.content.res.Configuration; |
||||
import android.os.Bundle; |
||||
import android.preference.PreferenceActivity; |
||||
import android.support.v7.app.ActionBar; |
||||
import android.support.v7.app.AppCompatCallback; |
||||
import android.support.v7.app.AppCompatDelegate; |
||||
import android.support.v7.view.ActionMode; |
||||
|
||||
public class PreferenceCompatActivity extends PreferenceActivity implements AppCompatCallback { |
||||
|
||||
private AppCompatDelegate acd; |
||||
|
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
acd = AppCompatDelegate.create(this, this); |
||||
acd.onCreate(savedInstanceState); |
||||
} |
||||
|
||||
@Override |
||||
protected void onPostCreate(Bundle savedInstanceState) { |
||||
super.onPostCreate(savedInstanceState); |
||||
acd.onPostCreate(savedInstanceState); |
||||
} |
||||
|
||||
@Override |
||||
public void onConfigurationChanged(Configuration newConfig) { |
||||
super.onConfigurationChanged(newConfig); |
||||
acd.onConfigurationChanged(newConfig); |
||||
} |
||||
|
||||
@Override |
||||
public void setTitle(CharSequence title) { |
||||
super.setTitle(title); |
||||
acd.setTitle(title); |
||||
} |
||||
|
||||
@Override |
||||
protected void onStop() { |
||||
super.onStop(); |
||||
acd.onStop(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onDestroy() { |
||||
super.onDestroy(); |
||||
acd.onDestroy(); |
||||
} |
||||
|
||||
public ActionBar getSupportActionBar() { |
||||
return acd.getSupportActionBar(); |
||||
} |
||||
|
||||
@Override |
||||
public void onSupportActionModeStarted(ActionMode actionMode) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onSupportActionModeFinished(ActionMode actionMode) { |
||||
|
||||
} |
||||
} |
Before Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 75 B |
Before Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 223 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 287 B |