remove unused imports etc

This commit is contained in:
David-Development 2013-09-26 22:24:55 +02:00
parent 76c4e83554
commit c0d41d956b
15 changed files with 421 additions and 263 deletions

View file

@ -2,14 +2,7 @@
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<notImportedProperties>
<property>MANIFEST_FILE_PATH</property>
<property>RESOURCES_DIR_PATH</property>
<property>ASSETS_DIR_PATH</property>
<property>NATIVE_LIBS_DIR_PATH</property>
</notImportedProperties>
</configuration>
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
@ -18,10 +11,14 @@
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Android 4.2.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="actionbarsherlock" exported="" />
<orderEntry type="library" name="android-support-v4" level="project" />
<orderEntry type="library" name="libs" level="project" />
<orderEntry type="module" module-name="actionbarsherlock" />
<orderEntry type="module" module-name="library" />
<orderEntry type="module" module-name="AppRater" />
<orderEntry type="module" module-name="main" />
<orderEntry type="module" module-name="MessageBar" />
</component>
</module>

View file

@ -3,20 +3,21 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17"
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
minSdkVersion 7
targetSdkVersion 17
}
sourceSets {
@ -30,6 +31,6 @@ android {
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
//instrumentTest.setRoot('tests')
}
}

View file

@ -12,5 +12,8 @@
# Project target.
target=android-17
android.library.reference.1=../../workspace_juno/actionbarsherlock
android.library.reference.1=../ActionBarSherlock/actionbarsherlock
android.library.reference.2=../Android-PullToRefresh/library
android.library.reference.3=../AppRater/AppRater
android.library.reference.4=../changeloglib/ChangeLogLibrary/src/main
android.library.reference.5=../MessageBar

View file

@ -1,3 +1,4 @@
<!--
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
@ -7,3 +8,26 @@
android:layout_height="match_parent" >
</WebView>
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<de.luhmer.owncloudnewsreader.helper.AutoResizeTextView
android:id="@+id/tv_androidAppVersion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="30dp"
android:gravity="center_horizontal|center_vertical" />
<view xmlns:android="http://schemas.android.com/apk/res/android"
class="it.gmariotti.changelibs.library.view.ChangeLogListView"
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoLink="web"
android:textIsSelectable="false" />
</LinearLayout>

View file

@ -1,49 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
<!--EMAIL-->
<!--Action Bar Items-->
<!--Strings related to login-->
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
<!--<string name="pref_default_username">admin</string>-->
<!--Toast Messages-->
<!--Strings related to Settings-->
<!--General settings-->
<!--<string-array name="pref_general_sort_order_values">
<item>desc</item>
<item>asc</item>
</string-array>-->
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
<!--MemorizingTrustManager-->
<!--Settings for Display-->
<!--Login Dialog-->
<!--Data & Sync-->
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
<string-array name="pref_sync_frequency_titles">
<item>15 minutes</item>
<item>30 minutes</item>
<item>1 hour</item>
<item>3 hours</item>
<item>6 hours</item>
<item>Never</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>15</item>
<item>30</item>
<item>60</item>
<item>180</item>
<item>360</item>
<item>-1</item>
</string-array>-->
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
<!--Example settings for Notifications-->
<!--<string name="pref_header_notifications">Notifications</string>
<string name="pref_title_new_message_notifications">New message notifications</string>
<string name="pref_title_ringtone">Ringtone</string>
<string name="pref_ringtone_silent">Silent</string>
<string name="pref_title_vibrate">Vibrate</string>-->
</resources>

View file

@ -1,50 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
<!--EMAIL-->
<!--Action Bar Items-->
<!--Strings related to login-->
<string name="pref_title_password">Secret Code</string>
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
<!--<string name="pref_default_username">admin</string>-->
<!--Toast Messages-->
<!--Strings related to Settings-->
<!--General settings-->
<!--<string-array name="pref_general_sort_order_values">
<item>desc</item>
<item>asc</item>
</string-array>-->
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
<!--MemorizingTrustManager-->
<!--Settings for Display-->
<!--Login Dialog-->
<!--Data & Sync-->
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
<string-array name="pref_sync_frequency_titles">
<item>15 minutes</item>
<item>30 minutes</item>
<item>1 hour</item>
<item>3 hours</item>
<item>6 hours</item>
<item>Never</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>15</item>
<item>30</item>
<item>60</item>
<item>180</item>
<item>360</item>
<item>-1</item>
</string-array>-->
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
<!--Example settings for Notifications-->
<!--<string name="pref_header_notifications">Notifications</string>
<string name="pref_title_new_message_notifications">New message notifications</string>
<string name="pref_title_ringtone">Ringtone</string>
<string name="pref_ringtone_silent">Silent</string>
<string name="pref_title_vibrate">Vibrate</string>-->
</resources>

View file

@ -1,5 +0,0 @@
<resources>
<string name="pref_title_AutoSyncOnStart">synchroniser automatiquement avec le démarrage du programme</string>
</resources>

View file

@ -1,49 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<!--<string name="non_sorted_articles">Nicht zugeordnete Artikel</string>-->
<!--EMAIL-->
<!--Action Bar Items-->
<!--Strings related to login-->
<!--<string name="pref_title_owncloudRootPath">ownCloud root address</string>-->
<!--<string name="pref_default_username">admin</string>-->
<!--Toast Messages-->
<!--Strings related to Settings-->
<!--General settings-->
<!--<string-array name="pref_general_sort_order_values">
<item>desc</item>
<item>asc</item>
</string-array>-->
<!--<string name="pref_title_social_recommendations">Enable social recommendations</string>
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message history</string>-->
<!--<string name="pref_title_AllowAllSSLCertificates">Allow all SSL Certificates</string>-->
<!--MemorizingTrustManager-->
<!--Settings for Display-->
<!--Login Dialog-->
<!--Data & Sync-->
<!--<string name="pref_title_data_sync_max_items">Max number of items to sync</string>-->
<!--<string name="pref_title_sync_frequency">Sync frequency</string>
<string-array name="pref_sync_frequency_titles">
<item>15 minutes</item>
<item>30 minutes</item>
<item>1 hour</item>
<item>3 hours</item>
<item>6 hours</item>
<item>Never</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>15</item>
<item>30</item>
<item>60</item>
<item>180</item>
<item>360</item>
<item>-1</item>
</string-array>-->
<!--<string name="pref_title_system_sync_settings">System sync settings</string>-->
<!--Example settings for Notifications-->
<!--<string name="pref_header_notifications">Notifications</string>
<string name="pref_title_new_message_notifications">New message notifications</string>
<string name="pref_title_ringtone">Ringtone</string>
<string name="pref_ringtone_silent">Silent</string>
<string name="pref_title_vibrate">Vibrate</string>-->
</resources>

View file

@ -1,5 +0,0 @@
<resources>
<string name="pref_title_AutoSyncOnStart">автоматической синхронизации c начала программы</string>
</resources>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="slider_listview_background_color">#525252</color>
<!-- <color name="slider_listview_background_color">#525252</color> -->
<color name="slider_listview_background_color">#383d43</color>
<color name="slider_listview_text_color">#F0F0F0</color>
<color name="divider_row_color">#292929</color>
</resources>

View file

@ -43,6 +43,8 @@ import com.actionbarsherlock.view.MenuItem;
import com.handmark.pulltorefresh.library.BlockingExpandableListView;
import com.handmark.pulltorefresh.library.PullToRefreshExpandableListView;
import org.codechimp.apprater.AppRater;
import de.luhmer.owncloudnewsreader.LoginDialogFragment.LoginSuccessfullListener;
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
import de.luhmer.owncloudnewsreader.authentication.AccountGeneral;
@ -54,12 +56,7 @@ import de.luhmer.owncloudnewsreader.services.IOwnCloudSyncService;
/**
* An activity representing a list of NewsReader. This activity has different
* presentations for handset and tablet-size devices. On handsets, the activity
* presents a list of items, which when touched, lead to a
* {@link NewsReaderDetailActivity} representing item details. On tablets, the
* activity presents the list of items and item details side-by-side using two
* vertical panes.
* <p>
* presentations for handset and tablet-size devices.
* The activity makes heavy use of fragments. The list of items is a
* {@link NewsReaderListFragment} and the item details (if present) is a
* {@link NewsReaderDetailFragment}.
@ -213,6 +210,9 @@ public class NewsReaderListActivity extends MenuUtilsSherlockFragmentActivity im
StartDetailFragmentNow();
}
AppRater.app_launched(this);
//AppRater.rateNow(this);
//onTopItemClicked(SubscriptionExpandableListAdapter.ALL_UNREAD_ITEMS, true, null);
}
@ -539,7 +539,7 @@ public class NewsReaderListActivity extends MenuUtilsSherlockFragmentActivity im
//getSupportMenuInflater().inflate(R.menu.news_reader, menu);
super.onCreateOptionsMenu(menu, getSupportMenuInflater(), true, this);
super.onCreateOptionsMenu(menu, getSupportMenuInflater(), this);
UpdateButtonSyncLayout();

View file

@ -21,9 +21,6 @@
package de.luhmer.owncloudnewsreader;
import org.apache.http.client.HttpResponseException;
import org.apache.http.conn.HttpHostConnectException;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
@ -37,6 +34,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcelable;
import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.util.Log;
@ -55,6 +53,12 @@ import com.handmark.pulltorefresh.library.BlockingExpandableListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshExpandableListView;
import com.michaelflisar.messagebar.MessageBar;
import com.michaelflisar.messagebar.messages.BaseMessage;
import com.michaelflisar.messagebar.messages.TextMessage;
import org.apache.http.client.HttpResponseException;
import org.apache.http.conn.HttpHostConnectException;
import de.luhmer.owncloudnewsreader.Constants.SYNC_TYPES;
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
@ -154,13 +158,16 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
refresh.post(new Runnable() {
public void run() {
lvAdapter.ReloadAdapter();
NewsReaderListActivity nlActivity = (NewsReaderListActivity) getActivity();
if (nlActivity != null)
nlActivity.UpdateItemList();
MessageBar messageBar = new MessageBar(getActivity(), true);
TextMessage textMessage = new TextMessage("New Messages available", "Reload", R.drawable.ic_menu_refresh);
textMessage.setClickListener(mListener);
messageBar.show(textMessage);
}
});
break;
}
}
@ -232,6 +239,8 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
//AsyncUpdateFinished asyncUpdateFinished;
ServiceConnection mConnection = null;
private BaseMessage.OnMessageClickListener mListener = null;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
@ -265,6 +274,24 @@ public class NewsReaderListFragment extends SherlockFragment implements OnCreate
//if(_Reader == null)
// _Reader = new OwnCloud_Reader();
mListener = new BaseMessage.OnMessageClickListener()
{
@Override
public void onButton2Click(Parcelable data)
{
}
@Override
public void onButton1Click(Parcelable data)
{
//Toast.makeText(getActivity(), "button 1 pressed", 3000).show();
NewsReaderDetailFragment ndf = ((NewsReaderDetailFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.content_frame));
if(ndf != null)
ndf.UpdateCursor();
}
};
}
catch(Exception ex)
{

View file

@ -21,21 +21,17 @@
package de.luhmer.owncloudnewsreader;
import java.io.InputStream;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockDialogFragment;
@ -45,8 +41,6 @@ import com.actionbarsherlock.app.SherlockDialogFragment;
*/
public class VersionInfoDialogFragment extends SherlockDialogFragment {
private static String web_template = null;
@SuppressLint("SetJavaScriptEnabled")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
@ -54,28 +48,15 @@ public class VersionInfoDialogFragment extends SherlockDialogFragment {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_version_info, null);
builder.setView(view)
/*
// Add action buttons
.setPositiveButton(R.string.action_sign_in_short, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//attemptLogin();
}
})
.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
LoginDialogFragment.this.getDialog().cancel();
}
})*/
.setTitle(getString(R.string.menu_About_Changelog));
builder.setView(view).setTitle(getString(R.string.menu_About_Changelog));
init_webTemplate(getActivity());
WebView webView = (WebView) view;
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.loadDataWithBaseURL("", web_template, "text/html", "UTF-8", "");
try {
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
String version = pInfo.versionName;
((TextView)view.findViewById(R.id.tv_androidAppVersion)).setText("You're using Version " + version);
} catch (Exception ex) {
ex.printStackTrace();
}
return builder.create();
}
@ -83,7 +64,6 @@ public class VersionInfoDialogFragment extends SherlockDialogFragment {
/* (non-Javadoc)
* @see android.support.v4.app.DialogFragment#onStart()
*/
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.FROYO)
@Override
public void onStart() {
@ -98,29 +78,4 @@ public class VersionInfoDialogFragment extends SherlockDialogFragment {
super.onStart();
}
private void init_webTemplate(Context context)
{
if(web_template == null)
{
InputStream input = null;
try {
//Activity act = getActivity();
input = context.getAssets().open("version_changelog_web_template.html");
int size = input.available();
byte[] buffer = new byte[size];
input.read(buffer);
input.close();
// byte buffer into a string
web_template = new String(buffer);
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
String version = pInfo.versionName;
web_template = web_template.replace("X_VERSION", version);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

View file

@ -0,0 +1,310 @@
package de.luhmer.owncloudnewsreader.helper;
/**
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004
*
* Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
* as the name is changed.
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
*
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*/
import android.content.Context;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
/**
* Text view that auto adjusts text size to fit within the view.
* If the text size equals the minimum text size and still does not
* fit, append with an ellipsis.
*
* @author Chase Colburn
* @since Apr 4, 2011
*/
public class AutoResizeTextView extends TextView {
// Minimum text size for this text view
public static final float MIN_TEXT_SIZE = 20;
// Interface for resize notifications
public interface OnTextResizeListener {
public void onTextResize(TextView textView, float oldSize, float newSize);
}
// Our ellipse string
private static final String mEllipsis = "...";
// Registered resize listener
private OnTextResizeListener mTextResizeListener;
// Flag for text and/or size changes to force a resize
private boolean mNeedsResize = false;
// Text size that is set from code. This acts as a starting point for resizing
private float mTextSize;
// Temporary upper bounds on the starting text size
private float mMaxTextSize = 0;
// Lower bounds for text size
private float mMinTextSize = MIN_TEXT_SIZE;
// Text view line spacing multiplier
private float mSpacingMult = 1.0f;
// Text view additional line spacing
private float mSpacingAdd = 0.0f;
// Add ellipsis to text that overflows at the smallest text size
private boolean mAddEllipsis = true;
// Default constructor override
public AutoResizeTextView(Context context) {
this(context, null);
}
// Default constructor when inflating from XML file
public AutoResizeTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
// Default constructor override
public AutoResizeTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mTextSize = getTextSize();
}
/**
* When text changes, set the force resize flag to true and reset the text size.
*/
@Override
protected void onTextChanged(final CharSequence text, final int start, final int before, final int after) {
mNeedsResize = true;
// Since this view may be reused, it is good to reset the text size
resetTextSize();
}
/**
* If the text view size changed, set the force resize flag to true
*/
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (w != oldw || h != oldh) {
mNeedsResize = true;
}
}
/**
* Register listener to receive resize notifications
* @param listener
*/
public void setOnResizeListener(OnTextResizeListener listener) {
mTextResizeListener = listener;
}
/**
* Override the set text size to update our internal reference values
*/
@Override
public void setTextSize(float size) {
super.setTextSize(size);
mTextSize = getTextSize();
}
/**
* Override the set text size to update our internal reference values
*/
@Override
public void setTextSize(int unit, float size) {
super.setTextSize(unit, size);
mTextSize = getTextSize();
}
/**
* Override the set line spacing to update our internal reference values
*/
@Override
public void setLineSpacing(float add, float mult) {
super.setLineSpacing(add, mult);
mSpacingMult = mult;
mSpacingAdd = add;
}
/**
* Set the upper text size limit and invalidate the view
* @param maxTextSize
*/
public void setMaxTextSize(float maxTextSize) {
mMaxTextSize = maxTextSize;
requestLayout();
invalidate();
}
/**
* Return upper text size limit
* @return
*/
public float getMaxTextSize() {
return mMaxTextSize;
}
/**
* Set the lower text size limit and invalidate the view
* @param minTextSize
*/
public void setMinTextSize(float minTextSize) {
mMinTextSize = minTextSize;
requestLayout();
invalidate();
}
/**
* Return lower text size limit
* @return
*/
public float getMinTextSize() {
return mMinTextSize;
}
/**
* Set flag to add ellipsis to text that overflows at the smallest text size
* @param addEllipsis
*/
public void setAddEllipsis(boolean addEllipsis) {
mAddEllipsis = addEllipsis;
}
/**
* Return flag to add ellipsis to text that overflows at the smallest text size
* @return
*/
public boolean getAddEllipsis() {
return mAddEllipsis;
}
/**
* Reset the text to the original size
*/
public void resetTextSize() {
if(mTextSize > 0) {
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
mMaxTextSize = mTextSize;
}
}
/**
* Resize text after measuring
*/
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if(changed || mNeedsResize) {
int widthLimit = (right - left) - getCompoundPaddingLeft() - getCompoundPaddingRight();
int heightLimit = (bottom - top) - getCompoundPaddingBottom() - getCompoundPaddingTop();
resizeText(widthLimit, heightLimit);
}
super.onLayout(changed, left, top, right, bottom);
}
/**
* Resize the text size with default width and height
*/
public void resizeText() {
int heightLimit = getHeight() - getPaddingBottom() - getPaddingTop();
int widthLimit = getWidth() - getPaddingLeft() - getPaddingRight();
resizeText(widthLimit, heightLimit);
}
/**
* Resize the text size with specified width and height
* @param width
* @param height
*/
public void resizeText(int width, int height) {
CharSequence text = getText();
// Do not resize if the view does not have dimensions or there is no text
if(text == null || text.length() == 0 || height <= 0 || width <= 0 || mTextSize == 0) {
return;
}
// Get the text view's paint object
TextPaint textPaint = getPaint();
// Store the current text size
float oldTextSize = textPaint.getTextSize();
// If there is a max text size set, use the lesser of that and the default text size
float targetTextSize = mMaxTextSize > 0 ? Math.min(mTextSize, mMaxTextSize) : mTextSize;
// Get the required text height
int textHeight = getTextHeight(text, textPaint, width, targetTextSize);
// Until we either fit within our text view or we had reached our min text size, incrementally try smaller sizes
while(textHeight > height && targetTextSize > mMinTextSize) {
targetTextSize = Math.max(targetTextSize - 2, mMinTextSize);
textHeight = getTextHeight(text, textPaint, width, targetTextSize);
}
// If we had reached our minimum text size and still don't fit, append an ellipsis
if(mAddEllipsis && targetTextSize == mMinTextSize && textHeight > height) {
// Draw using a static layout
StaticLayout layout = new StaticLayout(text, textPaint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false);
// Check that we have a least one line of rendered text
if(layout.getLineCount() > 0) {
// Since the line at the specific vertical position would be cut off,
// we must trim up to the previous line
int lastLine = layout.getLineForVertical(height) - 1;
// If the text would not even fit on a single line, clear it
if(lastLine < 0) {
setText("");
}
// Otherwise, trim to the previous line and add an ellipsis
else {
int start = layout.getLineStart(lastLine);
int end = layout.getLineEnd(lastLine);
float lineWidth = layout.getLineWidth(lastLine);
float ellipseWidth = textPaint.measureText(mEllipsis);
// Trim characters off until we have enough room to draw the ellipsis
while(width < lineWidth + ellipseWidth) {
lineWidth = textPaint.measureText(text.subSequence(start, --end + 1).toString());
}
setText(text.subSequence(0, end) + mEllipsis);
}
}
}
// Some devices try to auto adjust line spacing, so force default line spacing
// and invalidate the layout as a side effect
textPaint.setTextSize(targetTextSize);
setLineSpacing(mSpacingAdd, mSpacingMult);
// Notify the listener if registered
if(mTextResizeListener != null) {
mTextResizeListener.onTextResize(this, oldTextSize, targetTextSize);
}
// Reset force resize flag
mNeedsResize = false;
}
// Set the text size of the text paint object and use a static layout to render text off screen before measuring
private int getTextHeight(CharSequence source, TextPaint paint, int width, float textSize) {
// Update the text paint object
paint.setTextSize(textSize);
// Measure using a static layout
StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
return layout.getHeight();
}
}

View file

@ -22,8 +22,6 @@
package de.luhmer.owncloudnewsreader.helper;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
@ -41,7 +39,6 @@ import de.luhmer.owncloudnewsreader.NewsReaderDetailFragment;
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
import de.luhmer.owncloudnewsreader.R;
import de.luhmer.owncloudnewsreader.VersionInfoDialogFragment;
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
import de.luhmer.owncloudnewsreader.reader.IReader;
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
@ -90,7 +87,7 @@ public class MenuUtilsSherlockFragmentActivity extends SherlockFragmentActivity
}
public static void onCreateOptionsMenu(Menu menu, MenuInflater inflater, boolean mTwoPane, FragmentActivity act) {
public static void onCreateOptionsMenu(Menu menu, MenuInflater inflater, FragmentActivity act) {
inflater.inflate(R.menu.news_reader, menu);
activity = act;
@ -168,6 +165,7 @@ public class MenuUtilsSherlockFragmentActivity extends SherlockFragmentActivity
private static void DownloadMoreItems()
{
/*
DatabaseConnection dbConn = new DatabaseConnection(activity);
int count = dbConn.getCountFeedsForFolder(SubscriptionExpandableListAdapter.ALL_ITEMS, false);
if(count >= Constants.maxItemsCount)
@ -187,7 +185,7 @@ public class MenuUtilsSherlockFragmentActivity extends SherlockFragmentActivity
//Toast.makeText(activity, text, Toast.LENGTH_LONG).show();
}
else
{
{*/
String username = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getString("edt_username", "");
String password = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getString("edt_password", "");
@ -197,7 +195,7 @@ public class MenuUtilsSherlockFragmentActivity extends SherlockFragmentActivity
Toast.makeText(activity, activity.getString(R.string.toast_GettingMoreItems), Toast.LENGTH_SHORT).show();
}
}
//}
}
static OnAsyncTaskCompletedListener onAsyncTaskGetVersionFinished = new OnAsyncTaskCompletedListener() {