bug fixes

moved settings
This commit is contained in:
Mariotaku Lee 2015-06-27 17:43:54 +08:00
parent af522bfb12
commit a13dd300db
12 changed files with 234 additions and 181 deletions

View File

@ -35,11 +35,9 @@ import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v4.util.Pair;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.ShareActionProvider;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@ -133,7 +131,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
mPagerAdapter = new MediaPagerAdapter(this);
mViewPager.setAdapter(mPagerAdapter);
mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.element_spacing_normal));
mViewPager.setOnPageChangeListener(this);
mViewPager.addOnPageChangeListener(this);
final Intent intent = getIntent();
final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1);
final ParcelableMedia[] media = Utils.newParcelableArray(intent.getParcelableArrayExtra(EXTRA_MEDIA), ParcelableMedia.CREATOR);
@ -427,13 +425,12 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
if (callback.first.isDetached()) return;
final Menu menu = callback.second;
final boolean hasImage = result.first;
MenuUtils.setMenuItemAvailability(menu, R.id.refresh, !hasImage && !isLoading);
MenuUtils.setMenuItemAvailability(menu, R.id.share, hasImage && !isLoading);
MenuUtils.setMenuItemAvailability(menu, R.id.save, hasImage && !isLoading);
MenuUtils.setMenuItemAvailability(menu, MENU_REFRESH, !hasImage && !isLoading);
MenuUtils.setMenuItemAvailability(menu, MENU_SHARE, hasImage && !isLoading);
MenuUtils.setMenuItemAvailability(menu, MENU_SAVE, hasImage && !isLoading);
if (!hasImage) return;
final MenuItem shareItem = menu.findItem(R.id.share);
final ShareActionProvider shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
shareProvider.setShareIntent(result.second);
final MenuItem shareItem = menu.findItem(MENU_SHARE);
shareItem.setIntent(Intent.createChooser(result.second, callback.first.getString(R.string.share)));
}
};
checkState.setParams(mImageFile);
@ -445,9 +442,6 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_media_viewer_image_page, menu);
final MenuItem shareItem = menu.findItem(R.id.share);
final ShareActionProvider shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
shareProvider.setShareHistoryFileName(null);
}
@ -889,12 +883,11 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
final Pair<String, String> linkAndType = mVideoUrlAndType;
final boolean isLoading = linkAndType != null && mVideoLoader.isLoading(linkAndType.first);
final boolean hasVideo = file != null && file.exists() && linkAndType != null;
MenuUtils.setMenuItemAvailability(menu, R.id.refresh, !hasVideo && !isLoading);
MenuUtils.setMenuItemAvailability(menu, R.id.share, hasVideo && !isLoading);
MenuUtils.setMenuItemAvailability(menu, R.id.save, hasVideo && !isLoading);
MenuUtils.setMenuItemAvailability(menu, MENU_REFRESH, !hasVideo && !isLoading);
MenuUtils.setMenuItemAvailability(menu, MENU_SHARE, hasVideo && !isLoading);
MenuUtils.setMenuItemAvailability(menu, MENU_SAVE, hasVideo && !isLoading);
if (!hasVideo) return;
final MenuItem shareItem = menu.findItem(R.id.share);
final ShareActionProvider shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
final MenuItem shareItem = menu.findItem(MENU_SHARE);
final Intent intent = new Intent(Intent.ACTION_SEND);
final Uri fileUri = Uri.fromFile(file);
intent.setDataAndType(fileUri, linkAndType.second);
@ -905,7 +898,7 @@ public final class MediaViewerActivity extends BaseAppCompatActivity implements
intent.putExtra(Intent.EXTRA_TEXT, Utils.getStatusShareText(activity, status));
intent.putExtra(Intent.EXTRA_SUBJECT, Utils.getStatusShareSubject(activity, status));
}
shareProvider.setShareIntent(intent);
shareItem.setIntent(Intent.createChooser(intent, getString(R.string.share)));
}

View File

@ -181,6 +181,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
}
protected void reloadStatuses() {
if (getActivity() == null || isDetached()) return;
final Bundle args = new Bundle(), fragmentArgs = getArguments();
if (fragmentArgs != null) {
args.putAll(fragmentArgs);

View File

@ -30,7 +30,6 @@ import android.view.ViewGroup;
import android.widget.TextView;
import com.db.chart.model.BarSet;
import com.db.chart.model.ChartSet;
import com.db.chart.view.AxisController;
import com.db.chart.view.StackBarChartView;
import com.desmond.asyncmanager.AsyncManager;
@ -42,7 +41,6 @@ import org.mariotaku.twidere.model.RequestType;
import org.mariotaku.twidere.util.MathUtils;
import org.mariotaku.twidere.util.Utils;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@ -51,9 +49,8 @@ import java.util.Date;
*/
public class NetworkUsageSummaryPreferences extends Preference {
private StackBarChartView mChartView;
private NetworkUsageInfo mUsage;
private TextView mTotalUsage;
private TextView mTotalUsage, mTotalUsageSent, mTotalUsageReceived;
private TextView mDayUsageMax;
private TextView mDayMin, mDayMid, mDayMax;
@ -74,17 +71,14 @@ public class NetworkUsageSummaryPreferences extends Preference {
@Override
protected View onCreateView(ViewGroup parent) {
final View view = super.onCreateView(parent);
mChartView = (StackBarChartView) view.findViewById(R.id.chart);
mTotalUsage = (TextView) view.findViewById(R.id.total_usage);
mTotalUsageSent = (TextView) view.findViewById(R.id.total_usage_sent);
mTotalUsageReceived = (TextView) view.findViewById(R.id.total_usage_received);
mDayUsageMax = (TextView) view.findViewById(R.id.day_usage_max);
mDayMin = (TextView) view.findViewById(R.id.day_min);
mDayMid = (TextView) view.findViewById(R.id.day_mid);
mDayMax = (TextView) view.findViewById(R.id.day_max);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0x20000000);
mChartView.setYLabels(AxisController.LabelPosition.NONE);
mChartView.setXLabels(AxisController.LabelPosition.NONE);
return view;
}
@ -150,13 +144,9 @@ public class NetworkUsageSummaryPreferences extends Preference {
mediaSet.setColor(Color.GREEN);
usageStatisticsSet.setColor(Color.BLUE);
final ArrayList<ChartSet> data = new ArrayList<>();
data.add(apiSet);
data.add(mediaSet);
data.add(usageStatisticsSet);
mChartView.addData(data);
mChartView.show();
mTotalUsage.setText(Utils.calculateProperSize((usage.getTotalSent() + usage.getTotalReceived()) * 1024));
mTotalUsageSent.setText(Utils.calculateProperSize(usage.getTotalSent() * 1024));
mTotalUsageReceived.setText(Utils.calculateProperSize(usage.getTotalReceived() * 1024));
mDayUsageMax.setText(Utils.calculateProperSize((usage.getDayUsageMax()) * 1024));
mDayMin.setText(String.valueOf(usage.getDayMin()));
mDayMid.setText(String.valueOf((usage.getDayMin() + usage.getDayMax()) / 2));

View File

@ -26,20 +26,79 @@
android:padding="@dimen/element_spacing_normal">
<TextView
android:id="@+id/total_usage"
android:layout_marginTop="@dimen/element_spacing_large"
android:layout_marginBottom="@dimen/element_spacing_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="?android:textColorPrimary"
tools:text="124.50mb" />
<GridLayout
<LinearLayout
android:id="@+id/total_usage_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/total_usage">
android:layout_margin="@dimen/element_spacing_large"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/total_usage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceLarge"
android:textColor="?android:textColorPrimary"
tools:text="124.50mb" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/this_month" />
</LinearLayout>
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="vertical">
<TextView
android:id="@+id/total_usage_sent"
android:layout_column="0"
android:layout_row="0"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
tools:text="24.50mb" />
<TextView
android:layout_column="1"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginStart="@dimen/element_spacing_normal"
android:layout_row="0"
android:text="@string/usage_label_sent" />
<TextView
android:id="@+id/total_usage_received"
android:layout_column="0"
android:layout_row="1"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
tools:text="100mb" />
<TextView
android:layout_column="1"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginStart="@dimen/element_spacing_normal"
android:layout_row="1"
android:text="@string/usage_label_received" />
</GridLayout>
</LinearLayout>
<GridLayout
android:id="@+id/usage_chart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/total_usage_container"
android:visibility="gone">
<TextView

View File

@ -54,6 +54,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"
tools:text="text1" />
@ -63,6 +64,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorSecondary"
tools:text="text2" />
</LinearLayout>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
@ -19,24 +18,23 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/refresh"
android:icon="@drawable/ic_action_refresh"
android:title="@string/refresh"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@id/share"
android:icon="@drawable/ic_action_share"
android:title="@string/share"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@id/save"
android:icon="@drawable/ic_action_save"
android:title="@string/save_to_gallery"/>
android:title="@string/save_to_gallery" />
<item
android:id="@id/open_in_browser"
android:icon="@drawable/ic_action_web"
android:title="@string/open_in_browser"/>
android:title="@string/open_in_browser" />
</menu>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
@ -19,20 +18,19 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/refresh"
android:icon="@drawable/ic_action_refresh"
app:showAsAction="ifRoom"
android:title="@string/refresh"/>
android:title="@string/refresh"
app:showAsAction="ifRoom" />
<item
android:id="@id/share"
android:icon="@drawable/ic_action_share"
app:showAsAction="ifRoom"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
android:title="@string/share"/>
android:title="@string/share"
app:showAsAction="ifRoom" />
<item
android:id="@id/save"
android:icon="@drawable/ic_action_save"
android:title="@string/save_to_gallery"/>
android:title="@string/save_to_gallery" />
</menu>

View File

@ -764,4 +764,8 @@
<string name="wizard_hint_summary_location_requirement">Twidere needs location permission when you send tweet containing location.</string>
<string name="scrapyard">Scrapyard</string>
<string name="crop_image">Crop image</string>
<string name="usage_label_sent">Sent</string>
<string name="usage_label_received">Received</string>
<string name="this_month">This month</string>
<string name="media_preload">Media preload</string>
</resources>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/network">
<PreferenceCategory
android:key="category_connectivity"
android:title="@string/connectivity">
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="true"
android:key="fast_image_loading"
android:summary="@string/fast_image_loading_summary"
android:title="@string/fast_image_loading"/>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="tcp_dns_query"
android:summary="@string/tcp_dns_query_summary"
android:title="@string/tcp_dns_query"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:defaultValue="8.8.8.8"
android:dialogTitle="@string/dns_server"
android:inputType="textVisiblePassword"
android:key="dns_server"
android:singleLine="true"
android:summary="@string/dns_server_summary"
android:title="@string/dns_server"/>
<Preference
android:fragment="org.mariotaku.twidere.fragment.HostMappingsListFragment"
android:key="custom_host_mapping"
android:summary="@string/custom_host_mapping_summary"
android:title="@string/custom_host_mapping"/>
</PreferenceCategory>
<PreferenceCategory
android:key="category_proxy"
android:title="@string/proxy">
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:disableDependentsState="false"
android:key="enable_proxy"
android:summary="@string/http_proxy_summary"
android:title="@string/http_proxy"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="enable_proxy"
android:key="proxy_host"
android:singleLine="true"
android:title="@string/proxy_host"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="enable_proxy"
android:inputType="number"
android:key="proxy_port"
android:singleLine="true"
android:title="@string/proxy_port"/>
</PreferenceCategory>
<PreferenceCategory
android:key="category_api"
android:title="@string/api">
<org.mariotaku.twidere.preference.DefaultAPIPreference
android:summary="@string/default_api_settings_summary"
android:title="@string/default_api_settings"/>
</PreferenceCategory>
<PreferenceCategory
android:key="category_tumbor"
android:title="@string/thumbor_integration">
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="thumbor_enabled"
android:title="@string/thumbor_integration"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="thumbor_enabled"
android:inputType="textUri"
android:key="thumbor_address"
android:title="@string/server_address"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="thumbor_enabled"
android:inputType="textVisiblePassword"
android:key="thumbor_security_key"
android:title="@string/security_key"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -4,27 +4,6 @@
android:key="settings_content"
android:title="@string/content_and_storage">
<!--<org.mariotaku.twidere.preference.NetworkUsageSummaryPreferences-->
<!--android:key="network_usage_summary"/>-->
<PreferenceCategory
android:key="category_multimedia_contents"
android:title="@string/multimedia_contents">
<org.mariotaku.twidere.preference.MediaUploaderPreference
android:defaultValue=""
android:key="media_uploader"
android:summary="%s"
android:title="@string/image_uploader" />
<org.mariotaku.twidere.preference.ImagePreloadPreference
android:key="image_preload_options"
android:title="@string/image_preload_options" />
<CheckBoxPreference
android:defaultValue="true"
android:key="preload_wifi_only"
android:title="@string/preload_wifi_only" />
</PreferenceCategory>
<PreferenceCategory
android:key="category_content"
android:title="@string/content">
@ -38,12 +17,6 @@
app:min="10"
app:step="5" />
<org.mariotaku.twidere.preference.TimelineSyncPreference
android:defaultValue=""
android:key="timeline_sync_service"
android:summary="%s"
android:title="@string/timeline_sync_service" />
<CheckBoxPreference
android:defaultValue="true"
android:key="remember_position"
@ -72,6 +45,19 @@
android:fragment="org.mariotaku.twidere.fragment.KeyboardShortcutsFragment"
android:title="@string/keyboard_shortcuts" />
</PreferenceCategory>
<org.mariotaku.twidere.preference.MediaUploaderPreference
android:defaultValue=""
android:key="media_uploader"
android:summary="%s"
android:title="@string/image_uploader" />
<org.mariotaku.twidere.preference.TimelineSyncPreference
android:defaultValue=""
android:key="timeline_sync_service"
android:summary="%s"
android:title="@string/timeline_sync_service" />
<PreferenceCategory
android:key="category_safety"
android:title="@string/safety">

View File

@ -1,90 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/network">
<PreferenceCategory
android:key="category_connectivity"
android:title="@string/connectivity">
<org.mariotaku.twidere.preference.NetworkUsageSummaryPreferences />
<org.mariotaku.twidere.preference.ImagePreloadPreference
android:key="image_preload_options"
android:title="@string/media_preload" />
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="true"
android:key="fast_image_loading"
android:summary="@string/fast_image_loading_summary"
android:title="@string/fast_image_loading"/>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="tcp_dns_query"
android:summary="@string/tcp_dns_query_summary"
android:title="@string/tcp_dns_query"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:defaultValue="8.8.8.8"
android:dialogTitle="@string/dns_server"
android:inputType="textVisiblePassword"
android:key="dns_server"
android:singleLine="true"
android:summary="@string/dns_server_summary"
android:title="@string/dns_server"/>
<Preference
android:fragment="org.mariotaku.twidere.fragment.HostMappingsListFragment"
android:key="custom_host_mapping"
android:summary="@string/custom_host_mapping_summary"
android:title="@string/custom_host_mapping"/>
</PreferenceCategory>
<PreferenceCategory
android:key="category_proxy"
android:title="@string/proxy">
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:disableDependentsState="false"
android:key="enable_proxy"
android:summary="@string/http_proxy_summary"
android:title="@string/http_proxy"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="enable_proxy"
android:key="proxy_host"
android:singleLine="true"
android:title="@string/proxy_host"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="enable_proxy"
android:inputType="number"
android:key="proxy_port"
android:singleLine="true"
android:title="@string/proxy_port"/>
</PreferenceCategory>
<PreferenceCategory
android:key="category_api"
android:title="@string/api">
<org.mariotaku.twidere.preference.DefaultAPIPreference
android:summary="@string/default_api_settings_summary"
android:title="@string/default_api_settings"/>
</PreferenceCategory>
<PreferenceCategory
android:key="category_tumbor"
android:title="@string/thumbor_integration">
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="thumbor_enabled"
android:title="@string/thumbor_integration"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="thumbor_enabled"
android:inputType="textUri"
android:key="thumbor_address"
android:title="@string/server_address"/>
<org.mariotaku.twidere.preference.SummaryEditTextPreference
android:dependency="thumbor_enabled"
android:inputType="textVisiblePassword"
android:key="thumbor_security_key"
android:title="@string/security_key"/>
</PreferenceCategory>
<CheckBoxPreference
android:defaultValue="true"
android:key="preload_wifi_only"
android:title="@string/preload_wifi_only" />
<Preference
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:title="@string/advanced">
<extra
android:name="resid"
android:value="@xml/preferences_advanced_network" />
</Preference>
</PreferenceScreen>

View File

@ -43,6 +43,14 @@
android:name="resid"
android:value="@xml/preferences_notifications" />
</header>
<header
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:icon="@drawable/ic_action_server"
android:title="@string/network">
<extra
android:name="resid"
android:value="@xml/preferences_network" />
</header>
<header
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:icon="@drawable/ic_action_status_compose"
@ -67,14 +75,6 @@
android:name="resid"
android:value="@xml/preferences_storage" />
</header>
<header
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:icon="@drawable/ic_action_server"
android:title="@string/network">
<extra
android:name="resid"
android:value="@xml/preferences_network" />
</header>
<header
android:fragment="org.mariotaku.twidere.fragment.SettingsDetailsFragment"
android:icon="@drawable/ic_action_more_horizontal"