added option to disable auto answer load

bug fix
This commit is contained in:
NudeDude 2019-01-19 11:53:12 +01:00
parent 74165dd7df
commit d5b632ecd7
17 changed files with 113 additions and 69 deletions

View File

@ -3,6 +3,9 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$USER_HOME$/Gradle/gradle-4.10.2" />

View File

@ -5,7 +5,7 @@
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<list size="10">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
@ -13,18 +13,24 @@
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<list size="9">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
</list>
</value>
</option>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.nuclearfog.twidda">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@ -26,16 +25,14 @@
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*.twitter.com"
android:pathPattern="\\/.*\\/status\\/.*"
android:scheme="https" />
</intent-filter>
</activity>
<activity

View File

@ -125,10 +125,10 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
root.setBackgroundColor(settings.getBackgroundColor());
timelineAdapter.setColor(settings.getHighlightColor(), settings.getFontColor());
timelineAdapter.toggleImage(settings.loadImages());
timelineAdapter.toggleImage(settings.getImageLoad());
trendsAdapter.setColor(settings.getFontColor());
mentionAdapter.setColor(settings.getHighlightColor(), settings.getFontColor());
mentionAdapter.toggleImage(settings.loadImages());
mentionAdapter.toggleImage(settings.getImageLoad());
timelineList.setAdapter(timelineAdapter);
trendList.setAdapter(trendsAdapter);
@ -168,10 +168,6 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
}
break;
case SETTING:
home = null;
break;
case TWEET:
if (returnCode == TWEET_REMOVED)
home = null;
@ -258,6 +254,10 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
break;
case R.id.action_settings:
if (home != null && home.getStatus() == RUNNING) {
home.cancel(true);
home = null;
}
Intent settings = new Intent(this, AppSettings.class);
startActivityForResult(settings, SETTING);
break;

View File

@ -77,7 +77,7 @@ public class ProfileLoader extends AsyncTask<Long, Long, Long> {
formatter = NumberFormat.getIntegerInstance();
database = new DatabaseAdapter(context);
sdf = settings.getDateFormatter();
imgEnabled = settings.loadImages();
imgEnabled = settings.getImageLoad();
homeId = settings.getUserId();
highlight = settings.getHighlightColor();

View File

@ -35,9 +35,10 @@ import static org.nuclearfog.twidda.window.TweetDetail.TWEET_REMOVED;
public class StatusLoader extends AsyncTask<Long, Void, Long> {
public static final long LOAD = 0;
public static final long RETWEET = 1;
public static final long FAVORITE = 2;
public static final long DELETE = 3;
public static final long ANS = 1;
public static final long RETWEET = 2;
public static final long FAVORITE = 3;
public static final long DELETE = 4;
private static final long ERROR = -1;
private TwitterEngine mTwitter;
@ -50,7 +51,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
private List<Tweet> answers;
private Tweet tweet;
private int highlight, font_color;
private boolean toggleImg;
private boolean toggleImg, toggleAns;
public StatusLoader(TweetDetail context) {
@ -60,7 +61,8 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
formatter = NumberFormat.getIntegerInstance();
font_color = settings.getFontColor();
highlight = settings.getHighlightColor();
toggleImg = settings.loadImages();
toggleImg = settings.getImageLoad();
toggleAns = settings.getAnswerLoad();
ui = new WeakReference<>(context);
answers = new ArrayList<>();
RecyclerView replyList = context.findViewById(R.id.answer_list);
@ -79,16 +81,18 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
long sinceId = TWEETID;
try {
if (MODE == LOAD) {
if (MODE == LOAD || MODE == ANS) {
if (database.containStatus(TWEETID) && answerAdapter.getItemCount() == 0) {
tweet = database.getStatus(TWEETID);
answers = database.getAnswers(TWEETID);
publishProgress();
}
tweet = mTwitter.getStatus(TWEETID);
if (toggleAns || MODE == ANS) {
if (answerAdapter.getItemCount() > 0)
sinceId = answerAdapter.getItemId(0);
answers = mTwitter.getAnswers(tweet.getUser().getScreenname(), TWEETID, sinceId);
}
publishProgress();
if (database.containStatus(TWEETID)) {
database.updateStatus(tweet);

View File

@ -21,6 +21,7 @@ public class GlobalSettings {
private int tweet_color;
private boolean loadImage;
private boolean loadAnswer;
private boolean loggedIn;
private boolean customWorldId;
private int row;
@ -31,7 +32,6 @@ public class GlobalSettings {
private String key1, key2;
private long userId;
private GlobalSettings(Context context) {
settings = context.getSharedPreferences("settings", 0);
woeId = settings.getInt("world_id", 1);
@ -43,6 +43,7 @@ public class GlobalSettings {
tweet_color = settings.getInt("tweet_color", 0xff19aae8);
row = settings.getInt("preload", 20);
loadImage = settings.getBoolean("image_load", true);
loadAnswer = settings.getBoolean("answer_load", true);
loggedIn = settings.getBoolean("login", false);
key1 = settings.getString("key1", "");
key2 = settings.getString("key2", "");
@ -101,10 +102,28 @@ public class GlobalSettings {
edit.apply();
}
public boolean loadImages() {
public boolean getImageLoad() {
return loadImage;
}
public void setImageLoad(boolean image) {
loadImage = image;
Editor edit = settings.edit();
edit.putBoolean("image_load", image);
edit.apply();
}
public boolean getAnswerLoad() {
return loadAnswer;
}
public void setAnswerLoad(boolean loadAnswer) {
this.loadAnswer = loadAnswer;
Editor edit = settings.edit();
edit.putBoolean("answer_load", loadAnswer);
edit.apply();
}
public int getWoeId() {
return woeId;
}
@ -116,10 +135,6 @@ public class GlobalSettings {
edit.apply();
}
public boolean customWoeIdset() {
return customWorldId;
}
public int getWoeIdSelection() {
return woeIdPos;
}
@ -131,6 +146,17 @@ public class GlobalSettings {
edit.apply();
}
public boolean getCustomWidSet() {
return customWorldId;
}
public void setCustomWidSet(boolean customWoeId) {
customWorldId = customWoeId;
Editor edit = settings.edit();
edit.putBoolean("custom_woeId", customWoeId);
edit.apply();
}
public int getRowLimit() {
return row;
}
@ -161,20 +187,6 @@ public class GlobalSettings {
return sdf;
}
public void setImageLoad(boolean image) {
loadImage = image;
Editor edit = settings.edit();
edit.putBoolean("image_load", image);
edit.apply();
}
public void setCustomWoeId(boolean customWoeId) {
customWorldId = customWoeId;
Editor edit = settings.edit();
edit.putBoolean("custom_woeId", customWoeId);
edit.apply();
}
public void setConnection(String key1, String key2, Long userId) {
loggedIn = true;
this.key1 = key1;

View File

@ -37,13 +37,12 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
private GlobalSettings settings;
private Button colorButton1, colorButton2, colorButton3, colorButton4;
private CheckBox toggleImg;
private CheckBox toggleImg, toggleAns;
private EditText woeIdText;
private Spinner woeId;
private View root;
private int mode = 0;
@Override
protected void onCreate(Bundle savedInst) {
super.onCreate(savedInst);
@ -64,6 +63,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
colorButton3 = findViewById(R.id.color_tweet);
colorButton4 = findViewById(R.id.highlight_color);
toggleImg = findViewById(R.id.toggleImg);
toggleAns = findViewById(R.id.toggleAns);
woeIdText = findViewById(R.id.woe_id);
woeId = findViewById(R.id.woeid);
root = findViewById(R.id.settings_layout);
@ -72,7 +72,6 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
load_popup.setOnClickListener(this);
delButton.setOnClickListener(this);
logout.setOnClickListener(this);
toggleImg.setOnCheckedChangeListener(this);
colorButton1.setOnClickListener(this);
colorButton2.setOnClickListener(this);
colorButton3.setOnClickListener(this);
@ -84,25 +83,27 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
@Override
protected void onStart() {
super.onStart();
toggleImg.setChecked(settings.loadImages());
toggleImg.setChecked(settings.getImageLoad());
toggleAns.setChecked(settings.getAnswerLoad());
woeId.setAdapter(new WorldIdAdapter(this));
woeId.setSelection(settings.getWoeIdSelection());
colorButton1.setBackgroundColor(settings.getBackgroundColor());
colorButton2.setBackgroundColor(settings.getFontColor());
colorButton3.setBackgroundColor(settings.getTweetColor());
colorButton4.setBackgroundColor(settings.getHighlightColor());
if (settings.customWoeIdset()) {
if (settings.getCustomWidSet()) {
String text = Long.toString(settings.getWoeId());
woeIdText.setVisibility(View.VISIBLE);
woeIdText.setText(text);
}
toggleImg.setOnCheckedChangeListener(this);
toggleAns.setOnCheckedChangeListener(this);
}
@Override
public void onBackPressed() {
if (settings.customWoeIdset()) {
if (settings.getCustomWidSet()) {
String woeText = woeIdText.getText().toString();
if (!woeText.isEmpty())
settings.setWoeId(Long.parseLong(woeText));
@ -215,12 +216,12 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position == parent.getCount() - 1) {
woeIdText.setVisibility(View.VISIBLE);
settings.setCustomWoeId(true);
settings.setCustomWidSet(true);
settings.setWoeId(1);
} else {
woeIdText.setVisibility(View.INVISIBLE);
woeIdText.setText("");
settings.setCustomWoeId(false);
settings.setCustomWidSet(false);
settings.setWoeId(id);
}
settings.setWoeIdSelection(position);
@ -235,7 +236,14 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
@Override
public void onCheckedChanged(CompoundButton c, boolean checked) {
switch (c.getId()) {
case R.id.toggleImg:
settings.setImageLoad(checked);
break;
case R.id.toggleAns:
settings.setAnswerLoad(checked);
break;
}
}

View File

@ -65,7 +65,7 @@ public class DirectMessage extends AppCompatActivity implements OnRefreshListene
if (mLoader == null) {
mAdapter = new MessageAdapter(this);
mAdapter.setColor(settings.getFontColor(), settings.getHighlightColor());
mAdapter.setImageLoad(settings.loadImages());
mAdapter.setImageLoad(settings.getImageLoad());
dmList.setAdapter(mAdapter);
refresh.setRefreshing(true);
mLoader = new MessageLoader(this);

View File

@ -98,11 +98,11 @@ public class SearchPage extends AppCompatActivity implements OnRefreshListener,
if (mSearch == null) {
TimelineAdapter searchAdapter = new TimelineAdapter(this);
searchAdapter.setColor(settings.getHighlightColor(), settings.getFontColor());
searchAdapter.toggleImage(settings.loadImages());
searchAdapter.toggleImage(settings.getImageLoad());
tweetSearch.setAdapter(searchAdapter);
UserAdapter userAdapter = new UserAdapter(this);
userAdapter.toggleImage(settings.loadImages());
userAdapter.toggleImage(settings.getImageLoad());
userAdapter.setColor(settings.getFontColor());
userSearch.setAdapter(userAdapter);

View File

@ -103,7 +103,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
super.onStart();
if (mStat == null) {
TimelineAdapter answerAdapter = new TimelineAdapter(this);
answerAdapter.toggleImage(settings.loadImages());
answerAdapter.toggleImage(settings.getImageLoad());
answerAdapter.setColor(settings.getHighlightColor(), settings.getFontColor());
answer_list.setAdapter(answerAdapter);
@ -260,7 +260,7 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener,
@Override
public void onRefresh() {
mStat = new StatusLoader(this);
mStat.execute(tweetID, StatusLoader.LOAD);
mStat.execute(tweetID, StatusLoader.ANS);
}

View File

@ -68,7 +68,7 @@ public class UserDetail extends AppCompatActivity implements OnItemClickListener
super.onStart();
if (uList == null) {
UserAdapter usrAdp = new UserAdapter(this);
usrAdp.toggleImage(settings.loadImages());
usrAdp.toggleImage(settings.getImageLoad());
usrAdp.setColor(settings.getFontColor());
userList.setAdapter(usrAdp);

View File

@ -116,12 +116,12 @@ public class UserProfile extends AppCompatActivity implements OnRefreshListener,
if (mProfile == null) {
TimelineAdapter homeTl = new TimelineAdapter(this);
homeTl.setColor(settings.getHighlightColor(), settings.getFontColor());
homeTl.toggleImage(settings.loadImages());
homeTl.toggleImage(settings.getImageLoad());
homeList.setAdapter(homeTl);
TimelineAdapter homeFav = new TimelineAdapter(this);
homeFav.setColor(settings.getHighlightColor(), settings.getFontColor());
homeFav.toggleImage(settings.loadImages());
homeFav.toggleImage(settings.getImageLoad());
favoriteList.setAdapter(homeFav);
mProfile = new ProfileLoader(this);

View File

@ -111,7 +111,8 @@
android:layout_width="0dp"
android:layout_height="@dimen/settings_button"
android:layout_weight="1"
android:text="@string/load_factor" />
android:text="@string/load_factor"
android:textSize="10sp" />
<CheckBox
android:id="@+id/toggleImg"
@ -120,7 +121,18 @@
android:layout_marginStart="@dimen/side_padding"
android:layout_marginLeft="@dimen/side_padding"
android:layout_weight="1"
android:text="@string/image" />
android:text="@string/image"
android:textSize="10sp" />
<CheckBox
android:id="@+id/toggleAns"
android:layout_width="0dp"
android:layout_height="@dimen/settings_button"
android:layout_marginStart="@dimen/side_padding"
android:layout_marginLeft="@dimen/side_padding"
android:layout_weight="1"
android:text="@string/toggle_answer"
android:textSize="10sp" />
</LinearLayout>

View File

@ -108,4 +108,5 @@
<string name="edit_empty_name">Name leer!</string>
<string name="upload_button">hochladen</string>
<string name="exit_confirm">Änderungen verwerfen?</string>
<string name="toggle_answer">Antworten laden</string>
</resources>

View File

@ -116,4 +116,5 @@
<string name="edit_empty_name">Empty user name!</string>
<string name="upload_button">upload</string>
<string name="exit_confirm">discard changes?</string>
<string name="toggle_answer">Load answer</string>
</resources>

View File

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.0'
}
}