Browse Source

Fix various layout issues.

pull/11/head
Eric Kok 12 years ago
parent
commit
b46bac998a
  1. 16
      core/res/drawable/loading_progress.xml
  2. 4
      core/res/layout/dialog_about.xml
  3. 11
      core/res/layout/fragment_details.xml
  4. 17
      core/res/layout/fragment_torrents.xml
  5. 2
      core/res/menu/activity_torrents.xml
  6. 12
      core/res/menu/fragment_details_file.xml
  7. 10
      core/res/values/strings.xml
  8. 8
      core/res/xml/pref_system.xml
  9. 22
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  10. 67
      core/src/org/transdroid/core/gui/TorrentsFragment.java
  11. 1
      core/src/org/transdroid/core/gui/lists/TorrentDetailsView.java
  12. 4
      core/src/org/transdroid/core/gui/lists/TorrentFileView.java
  13. 28
      core/src/org/transdroid/core/gui/navigation/NavigationHelper.java
  14. 18
      core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  15. 2
      full/AndroidManifest.xml
  16. 2
      lite/AndroidManifest.xml

16
core/res/drawable/loading_progress.xml

@ -1,13 +1,5 @@ @@ -1,13 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/progress"
android:duration="100">
<rotate
android:drawable="@drawable/ic_empty_details"
android:pivotX="50%"
android:pivotY="50%" />
</item>
</animation-list>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_empty_details"
android:pivotX="50%"
android:pivotY="50%" />

4
core/res/layout/dialog_about.xml

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
android:layout_marginTop="@dimen/margin_default"
android:fontFamily="sans-serif-condensed"
android:gravity="center"
android:text="@string/app_developer"
android:text="@string/system_developer"
android:textColor="@android:color/white"
android:textSize="18sp" />
@ -43,6 +43,6 @@ @@ -43,6 +43,6 @@
android:layout_marginBottom="@dimen/margin_default"
android:layout_marginTop="4dip"
android:gravity="center"
android:text="@string/app_license" />
android:text="@string/system_license" />
</LinearLayout>

11
core/res/layout/fragment_details.xml

@ -8,9 +8,9 @@ @@ -8,9 +8,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="multipleChoiceModal"
android:listSelector="@drawable/selectable_background_transdroid"
android:divider="@null"
android:dividerHeight="0dip"
android:listSelector="@drawable/selectable_background_transdroid"
android:visibility="gone" />
<ProgressBar
@ -20,17 +20,18 @@ @@ -20,17 +20,18 @@
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/loading_progress"
android:visibility="gone" />
<TextView
android:id="@+id/empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableTop="@drawable/ic_empty_details"
android:drawablePadding="8dip"
android:text="@string/navigation_emptydetails"
android:drawableTop="@drawable/ic_empty_details"
android:gravity="center"
android:padding="@dimen/margin_default"
android:text="@string/navigation_emptydetails"
android:textIsSelectable="false"
android:visibility="visible" />
</FrameLayout>

17
core/res/layout/fragment_torrents.xml

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateOnly="true"
android:indeterminateDrawable="@drawable/loading_progress"
android:indeterminateOnly="true"
android:visibility="visible" />
<TextView
@ -30,10 +30,24 @@ @@ -30,10 +30,24 @@
android:drawableTop="@drawable/ic_empty_details"
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:text="@string/navigation_emptytorrents"
android:textIsSelectable="false"
android:visibility="gone" />
<TextView
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="8dip"
android:drawableTop="@drawable/ic_empty_details"
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:textIsSelectable="false"
android:visibility="gone" />
<TextView
android:id="@+id/nosettings_text"
android:layout_width="wrap_content"
@ -43,6 +57,7 @@ @@ -43,6 +57,7 @@
android:drawableTop="@drawable/ic_empty_details"
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:text="@string/navigation_nosettings"
android:textIsSelectable="false"
android:visibility="gone" />

2
core/res/menu/activity_torrents.xml

@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:showAsAction="always"
android:title="@string/action_settings"/>
android:title="@string/action_search"/>
<item
android:id="@+id/action_rss"
android:icon="@drawable/ic_action_rss"

12
core/res/menu/fragment_details_file.xml

@ -2,27 +2,27 @@ @@ -2,27 +2,27 @@
<item
android:id="@+id/action_off"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:title="@string/action_priority_off" />
<item
android:id="@+id/action_priority_low"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:title="@string/action_priority_low" />
<item
android:id="@+id/action_priority_normal"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:title="@string/action_priority_normal" />
<item
android:id="@+id/action_priority_high"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:title="@string/action_priority_high" />
<item
android:id="@+id/action_remoteplay"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:title="@string/action_remoteplay" />
<item
android:id="@+id/action_download"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:title="@string/action_download" />
</menu>

10
core/res/values/strings.xml

@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
<string name="navigation_status_onlyactive">Active</string>
<string name="navigation_status_onlyinactive">Inactive</string>
<string name="status_status">Status: %1%s</string>
<string name="status_status">Status: %1$s</string>
<string name="status_waiting">Waiting to check&#8230;</string>
<string name="status_checking">Verifying local data&#8230;</string>
<string name="status_waitingtodl">Waiting to download %s</string>
@ -103,7 +103,6 @@ @@ -103,7 +103,6 @@
<string name="search_torrentsearch">Torrent search</string>
<string name="search_hint">Search for torrents</string>
<string name="search_"></string>
<string name="pref_servers">Servers</string>
<string name="pref_addserver">Add new server</string>
@ -257,10 +256,9 @@ @@ -257,10 +256,9 @@
<string name="error_no_valid_settings_file">File does not seem to contain Transdroid settings</string>
<string name="error_file_not_found">There is no settings file found</string>
<string name="app_name" translatable="false">Transdroid</string>
<string name="app_developer" translatable="false">\u00A9 Eric Kok, 2312 development</string>
<string name="app_license" translatable="false">Published under GNU General Public License v3</string>
<string name="system_name" translatable="false">Transdroid</string>
<string name="system_developer" translatable="false">\u00A9 Eric Kok, 2312 development</string>
<string name="system_license" translatable="false">Published under GNU General Public License v3</string>
<string name="system_description">Manage your torrents from your Android device</string>
<string name="system_libraries">LIBRARIES</string>
</resources>

8
core/res/xml/pref_system.xml

@ -16,6 +16,14 @@ @@ -16,6 +16,14 @@
android:key="system_installhelp"
android:title="@string/pref_installhelp" />
<Preference
android:key="system_importsettings"
android:title="@string/pref_import" />
<Preference
android:key="system_exportsettings"
android:title="@string/pref_export" />
<Preference
android:key="system_changelog"
android:title="@string/pref_changelog" />

22
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -261,7 +261,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -261,7 +261,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Update connection to the newly selected server and refresh
currentConnection = server.createServerAdapter();
applicationSettings.setLastUsedServer(server);
clearScreens();
// Clear the currently shown list of torrent and perhaps the details
fragmentTorrents.clear();
if (fragmentDetails != null) {
fragmentDetails.clear();
}
updateFragmentVisibility(true);
refreshTorrents();
return;
@ -311,7 +315,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -311,7 +315,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@OptionsItem(resName = "action_refresh")
protected void refreshScreen() {
refreshTorrents();
getAdditionalStats();
if (Daemon.supportsStats(currentConnection.getType()))
getAdditionalStats();
}
@OptionsItem(resName = "action_enableturtle")
@ -334,14 +339,6 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -334,14 +339,6 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.transdroid.org/download/")));
}
private void clearScreens() {
// Clear the currently shown list of torrent and perhaps the details
fragmentTorrents.clear();
if (fragmentDetails != null) {
fragmentDetails.clear();
}
}
@Background
protected void refreshTorrents() {
fragmentTorrents.updateIsLoading(true);
@ -479,8 +476,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -479,8 +476,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@UiThread
protected void onCommunicationError(DaemonTaskFailureResult result) {
Log.i(this, result.getException().toString());
Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())),
navigationHelper.CROUTON_ERROR_STYLE);
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
Crouton.showText(this, error, navigationHelper.CROUTON_ERROR_STYLE);
fragmentTorrents.updateError(error);
}
@UiThread

67
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -25,7 +25,7 @@ import com.actionbarsherlock.view.MenuItem; @@ -25,7 +25,7 @@ import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.SherlockListView;
import com.actionbarsherlock.view.SherlockListView.MultiChoiceModeListenerCompat;
@EFragment(resName="fragment_torrents")
@EFragment(resName = "fragment_torrents")
public class TorrentsFragment extends SherlockFragment {
// Local data
@ -36,16 +36,20 @@ public class TorrentsFragment extends SherlockFragment { @@ -36,16 +36,20 @@ public class TorrentsFragment extends SherlockFragment {
@InstanceState
protected boolean hasAConnection = false;
@InstanceState
protected boolean isLoading = false;
protected boolean isLoading = true;
@InstanceState
protected String connectionErrorMessage = null;
// Views
@ViewById(resName="torrent_list")
@ViewById(resName = "torrent_list")
protected SherlockListView torrentsList;
@ViewById
protected TextView emptyText;
@ViewById
protected TextView nosettingsText;
@ViewById
protected TextView errorText;
@ViewById
protected ProgressBar loadingProgress;
@AfterViews
@ -69,6 +73,7 @@ public class TorrentsFragment extends SherlockFragment { @@ -69,6 +73,7 @@ public class TorrentsFragment extends SherlockFragment {
* Clear currently visible list of torrents
*/
public void clear() {
this.connectionErrorMessage = null;
updateTorrents(null);
}
@ -89,26 +94,26 @@ public class TorrentsFragment extends SherlockFragment { @@ -89,26 +94,26 @@ public class TorrentsFragment extends SherlockFragment {
}
updateViewVisibility();
}
private MultiChoiceModeListenerCompat onTorrentsSelected = new MultiChoiceModeListenerCompat() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Show contextual action bar to start/stop/remove/etc. torrents in batch mode
mode.getMenuInflater().inflate(R.menu.fragment_torrents_cab, menu);
return true;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
// Get checked torrents
List<Torrent> checked = new ArrayList<Torrent>();
for (int i = 0; i < torrentsList.getCheckedItemPositions().size(); i++) {
if (torrentsList.getCheckedItemPositions().get(i))
checked.add((Torrent) torrentsList.getAdapter().getItem(i));
}
int itemId = item.getItemId();
if (itemId == R.id.action_resume) {
for (Torrent torrent : checked) {
@ -142,7 +147,7 @@ public class TorrentsFragment extends SherlockFragment { @@ -142,7 +147,7 @@ public class TorrentsFragment extends SherlockFragment {
return false;
}
}
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
// TODO: Update title or otherwise show number of selected torrents?
@ -152,14 +157,14 @@ public class TorrentsFragment extends SherlockFragment { @@ -152,14 +157,14 @@ public class TorrentsFragment extends SherlockFragment {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
};
@ItemClick(resName="torrent_list")
@ItemClick(resName = "torrent_list")
protected void torrentsListClicked(Torrent torrent) {
DetailsActivity_.intent(getActivity()).torrent(torrent).start();
}
@ -171,8 +176,11 @@ public class TorrentsFragment extends SherlockFragment { @@ -171,8 +176,11 @@ public class TorrentsFragment extends SherlockFragment {
*/
public void updateConnectionStatus(boolean hasAConnection) {
this.hasAConnection = hasAConnection;
if (!hasAConnection)
clear();
if (!hasAConnection) {
clear(); // Indirectly also calls updateViewVisibility()
} else {
updateViewVisibility();
}
}
/**
@ -181,8 +189,26 @@ public class TorrentsFragment extends SherlockFragment { @@ -181,8 +189,26 @@ public class TorrentsFragment extends SherlockFragment {
*/
public void updateIsLoading(boolean isLoading) {
this.isLoading = isLoading;
if (isLoading)
clear();
if (isLoading) {
clear(); // Indirectly also calls updateViewVisibility()
} else {
updateViewVisibility();
}
}
/**
* Updates the shown screen depending on whether a connection error occurred
* @param connectionErrorMessage The error message from the last failed connection attempt, or null to clear the
* visible error text
*/
public void updateError(String connectionErrorMessage) {
this.connectionErrorMessage = connectionErrorMessage;
errorText.setText(connectionErrorMessage);
if (connectionErrorMessage != null) {
clear(); // Indirectly also calls updateViewVisibility()
} else {
updateViewVisibility();
}
}
@UiThread
@ -191,14 +217,17 @@ public class TorrentsFragment extends SherlockFragment { @@ -191,14 +217,17 @@ public class TorrentsFragment extends SherlockFragment {
torrentsList.setVisibility(View.GONE);
emptyText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
nosettingsText.setVisibility(View.VISIBLE);
return;
}
boolean isEmpty = torrents == null || torrentsList.getAdapter().isEmpty();
boolean hasError = connectionErrorMessage == null;
nosettingsText.setVisibility(View.GONE);
torrentsList.setVisibility(!isLoading && !isEmpty? View.GONE: View.VISIBLE);
loadingProgress.setVisibility(isLoading? View.VISIBLE: View.GONE);
emptyText.setVisibility(!isLoading && isEmpty? View.VISIBLE: View.GONE);
errorText.setVisibility(hasError? View.VISIBLE : View.GONE);
torrentsList.setVisibility(!hasError && !isLoading && !isEmpty ? View.GONE : View.VISIBLE);
loadingProgress.setVisibility(!hasError && isLoading ? View.VISIBLE : View.GONE);
emptyText.setVisibility(!hasError && !isLoading && isEmpty ? View.VISIBLE : View.GONE);
}
/**

1
core/src/org/transdroid/core/gui/lists/TorrentDetailsView.java

@ -63,6 +63,7 @@ public class TorrentDetailsView extends RelativeLayout { @@ -63,6 +63,7 @@ public class TorrentDetailsView extends RelativeLayout {
} else {
dateaddedText.setVisibility(View.INVISIBLE);
}
statusText.setText(getResources().getString(R.string.status_status, local.getProgressStatusEta(getResources())));
ratioText.setText(getResources().getString(R.string.status_ratio, local.getRatioString()));
// TODO: Implement separate numbers of seeders and leechers

4
core/src/org/transdroid/core/gui/lists/TorrentFileView.java

@ -33,11 +33,11 @@ public class TorrentFileView extends CheckableRelativeLayout { @@ -33,11 +33,11 @@ public class TorrentFileView extends CheckableRelativeLayout {
switch (torrentFile.getPriority()) {
case Off:
priorityImage.setImageResource(R.drawable.ic_priority_off);
priorityImage.setContentDescription(getResources().getString(R.string.status_priority_low));
priorityImage.setContentDescription(getResources().getString(R.string.status_priority_off));
break;
case Low:
priorityImage.setImageResource(R.drawable.ic_priority_low);
priorityImage.setContentDescription(getResources().getString(R.string.status_priority_normal));
priorityImage.setContentDescription(getResources().getString(R.string.status_priority_low));
break;
case Normal:
priorityImage.setImageResource(R.drawable.ic_priority_normal);

28
core/src/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -5,11 +5,10 @@ import org.androidannotations.annotations.RootContext; @@ -5,11 +5,10 @@ import org.androidannotations.annotations.RootContext;
import org.transdroid.core.R;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
/**
@ -24,10 +23,17 @@ public class NavigationHelper { @@ -24,10 +23,17 @@ public class NavigationHelper {
@RootContext
protected Context context;
/**
* Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display error messages.
*/
public Style CROUTON_ERROR_STYLE = new Style.Builder().setBackgroundColor(R.color.crouton_error).setTextSize(13)
.build();
.setDuration(2500).build();
/**
* Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display info messages.
*/
public Style CROUTON_INFO_STYLE = new Style.Builder().setBackgroundColor(R.color.crouton_info).setTextSize(13)
.build();
.setDuration(1500).build();
/**
* Whether any search-related UI components should be shown in the interface. At the moment returns false only if we
@ -72,18 +78,4 @@ public class NavigationHelper { @@ -72,18 +78,4 @@ public class NavigationHelper {
return !context.getPackageName().equals("org.transdroid.lite");
}
/**
* Whether the navigation of server types and labels as filter are shown in a separate fragment.
* @return True if navigation is in a separate fragment, false if the items are shown in the action bar spinner
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public boolean showFiltersInFragment() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
if (context.getResources().getConfiguration().screenWidthDp >= 600) {
return true;
}
}
return false;
}
}

18
core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java

@ -40,6 +40,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -40,6 +40,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick);
findPreference("system_installhelp").setOnPreferenceClickListener(onInstallHelpClick);
findPreference("system_changelog").setOnPreferenceClickListener(onChangeLogClick);
findPreference("system_importsettings").setOnPreferenceClickListener(onImportSettingsClick);
findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick);
findPreference("system_about").setOnPreferenceClickListener(onAboutClick);
}
@ -59,6 +61,22 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -59,6 +61,22 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
}
};
private OnPreferenceClickListener onImportSettingsClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// TODO: Allow import of settings
return true;
}
};
private OnPreferenceClickListener onExportSettingsClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// TODO: Allow export of settings
return true;
}
};
private OnPreferenceClickListener onChangeLogClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation")
@Override

2
full/AndroidManifest.xml

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:label="@string/system_name"
android:theme="@style/Theme.Sherlock" >
<!-- Main activities -->

2
lite/AndroidManifest.xml

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:label="@string/system_name"
android:theme="@style/Theme.Sherlock" >
<!-- Main activities -->

Loading…
Cancel
Save