code cleanup

layout fix
dm fix
This commit is contained in:
NudeDude 2018-08-30 19:17:48 +02:00
parent d0bc730146
commit ea7c090718
12 changed files with 97 additions and 76 deletions

View File

@ -25,7 +25,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -27,10 +27,10 @@ dependencies {
implementation 'org.twitter4j:twitter4j-core:4.0.7'
implementation 'com.github.QuadFlask:colorpicker:0.0.13'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:appcompat-v7:28+'
implementation 'com.android.support:cardview-v7:28+'
implementation 'com.android.support:support-vector-drawable:28+'
implementation 'com.android.support:design:28+'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
repositories {

View File

@ -6,7 +6,6 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/shitter"
@ -16,7 +15,6 @@
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -2,7 +2,6 @@ package org.nuclearfog.twidda;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.support.v7.app.AppCompatActivity;
@ -40,6 +39,7 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
private MenuItem profile, tweet, search, setting;
private GlobalSettings settings;
private MainPage home, trend, mention;
private SearchView searchQuery;
private View lastTab;
private Toolbar toolbar;
private TabHost tabhost;
@ -118,7 +118,7 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
tweet = m.findItem(R.id.action_tweet);
search = m.findItem(R.id.action_search);
setting = m.findItem(R.id.action_settings);
SearchView searchQuery = (SearchView) MenuItemCompat.getActionView(m.findItem(R.id.action_search));
searchQuery = (SearchView) search.getActionView();
searchQuery.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
@ -154,7 +154,7 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
case R.id.action_settings:
settingChanged = true;
MenuItemCompat.collapseActionView(search);
search.collapseActionView();
intent = new Intent(this, AppSettings.class);
startActivity(intent);
return true;
@ -228,11 +228,11 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
switch(tabId) {
case "timeline":
MenuItemCompat.collapseActionView(search);
profile.setVisible(true);
search.setVisible(false);
tweet.setVisible(true);
setting.setVisible(false);
search.collapseActionView();
break;
case "trends":
@ -243,11 +243,12 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
break;
case "mention":
MenuItemCompat.collapseActionView(search);
searchQuery.onActionViewCollapsed();
profile.setVisible(false);
search.setVisible(false);
tweet.setVisible(false);
setting.setVisible(true);
search.collapseActionView();
break;
}
}
@ -349,25 +350,27 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
private void animate() {
final int ANIM_DUR = 300;
final int DIMENS = Animation.RELATIVE_TO_PARENT;
Animation leftIn = new TranslateAnimation(DIMENS,-1.0f,DIMENS,0.0f,DIMENS,0.0f,DIMENS,0.0f);
Animation rightIn = new TranslateAnimation(DIMENS,1.0f,DIMENS,0.0f,DIMENS,0.0f,DIMENS,0.0f);
Animation leftOut = new TranslateAnimation(DIMENS,0.0f,DIMENS, -1.0f,DIMENS, 0.0f,DIMENS,0.0f);
Animation rightOut = new TranslateAnimation(DIMENS,0.0f,DIMENS, 1.0f,DIMENS, 0.0f,DIMENS,0.0f);
leftIn.setDuration(ANIM_DUR);
rightIn.setDuration(ANIM_DUR);
leftOut.setDuration(ANIM_DUR);
rightOut.setDuration(ANIM_DUR);
final int DIMENS = Animation.RELATIVE_TO_PARENT;
final float LEFT = -1.0f;
final float RIGHT = 1.0f;
final float NULL = 0.0f;
Animation lIn = new TranslateAnimation(DIMENS, LEFT, DIMENS, NULL, DIMENS, NULL, DIMENS, NULL);
Animation rIn = new TranslateAnimation(DIMENS, RIGHT, DIMENS, NULL, DIMENS, NULL, DIMENS, NULL);
Animation lOut = new TranslateAnimation(DIMENS, NULL, DIMENS, LEFT, DIMENS, NULL, DIMENS, NULL);
Animation rOut = new TranslateAnimation(DIMENS, NULL, DIMENS, RIGHT, DIMENS, NULL, DIMENS, NULL);
lIn.setDuration(ANIM_DUR);
rIn.setDuration(ANIM_DUR);
lOut.setDuration(ANIM_DUR);
rOut.setDuration(ANIM_DUR);
View currentTab = tabhost.getCurrentView();
if( tabhost.getCurrentTab() > tabIndex ) {
lastTab.setAnimation(leftOut);
currentTab.setAnimation(rightIn);
lastTab.setAnimation(lOut);
currentTab.setAnimation(rIn);
} else {
lastTab.setAnimation(rightOut);
currentTab.setAnimation(leftIn);
lastTab.setAnimation(rOut);
currentTab.setAnimation(lIn);
}
lastTab = tabhost.getCurrentView();
}

View File

@ -616,9 +616,16 @@ public class TwitterEngine {
* @return dm item
*/
private Message getMessage(DirectMessage dm) throws TwitterException {
TwitterUser sender = getUser(twitter.showUser(dm.getSenderId()));
TwitterUser receiver = getUser(twitter.showUser(dm.getRecipientId()));
TwitterUser sender, receiver;
sender = getUser(twitter.showUser(dm.getSenderId()));
if (dm.getSenderId() != dm.getRecipientId()) {
receiver = getUser(twitter.showUser(dm.getRecipientId()));
} else {
receiver = sender;
}
long time = dm.getCreatedAt().getTime();
return new Message(dm.getId(), sender, receiver, time, dm.getText());
}

View File

@ -13,7 +13,6 @@ import com.squareup.picasso.Picasso;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.listitems.Message;
import org.nuclearfog.twidda.backend.listitems.TwitterUser;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -75,16 +74,12 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageH
@Override
public void onBindViewHolder(@NonNull MessageHolder vh, int index) {
Message message = messages.get(index);
TwitterUser sender = message.sender;
String name = sender.username + ' ' + sender.screenname;
String time = stringTime(message.time);
vh.message.setText(message.message);
vh.username.setText(name);
vh.createdAt.setText(time);
vh.username.setText(message.sender.username);
vh.screenname.setText(message.sender.screenname);
vh.createdAt.setText(stringTime(message.time));
if (loadImage)
Picasso.get().load(sender.profileImg + "_mini").into(vh.profile_img);
Picasso.get().load(message.sender.profileImg + "_mini").into(vh.profile_img);
}
private String stringTime(long mills) {
@ -119,6 +114,7 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageH
class MessageHolder extends ViewHolder {
final ImageView profile_img;
final TextView username;
final TextView screenname;
final TextView createdAt;
final TextView message;
@ -126,6 +122,7 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageH
super(v);
profile_img = v.findViewById(R.id.dm_profileImg);
username = v.findViewById(R.id.dm_username);
screenname = v.findViewById(R.id.dm_screenname);
createdAt = v.findViewById(R.id.dm_time);
message = v.findViewById(R.id.dm_message);
}

View File

@ -3,7 +3,6 @@ package org.nuclearfog.twidda.window;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.support.v7.app.AppCompatActivity;
@ -96,7 +95,8 @@ public class SearchPage extends AppCompatActivity implements UserAdapter.OnItemC
@Override
public boolean onCreateOptionsMenu(Menu m) {
getMenuInflater().inflate(R.menu.search, m);
final SearchView searchQuery = (SearchView) MenuItemCompat.getActionView(m.findItem(R.id.new_search));
MenuItem mSearch = m.findItem(R.id.new_search);
SearchView searchQuery = (SearchView) mSearch.getActionView();
searchQuery.setQueryHint(search);
searchQuery.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
@ -116,17 +116,13 @@ public class SearchPage extends AppCompatActivity implements UserAdapter.OnItemC
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
int id = item.getItemId();
switch(id) {
case R.id.search_tweet:
intent = new Intent(this, TweetPopup.class);
if (item.getItemId() == R.id.search_tweet) {
Intent intent = new Intent(this, TweetPopup.class);
intent.putExtra("TweetID", -1);
if (search.startsWith("#")) {
intent.putExtra("Addition", search);
}
startActivity(intent);
break;
}
return true;
}

View File

@ -38,7 +38,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
private RecyclerView homeList, favoriteList;
private TabHost mTab;
private View lastView;
private View lastTab;
private boolean home;
private long userId = 0;
private int tabIndex = 0;
@ -236,32 +236,34 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
tab2.setContent(R.id.homefavorits);
tab2.setIndicator("",getDrawable(R.drawable.favorite));
mTab.addTab(tab2);
lastView = mTab.getCurrentView();
lastTab = mTab.getCurrentView();
}
private void animate() {
final int ANIM_DUR = 300;
final int DIMENS = Animation.RELATIVE_TO_PARENT;
Animation leftIn = new TranslateAnimation(DIMENS,-1.0f,DIMENS,0.0f,DIMENS,0.0f,DIMENS,0.0f);
Animation rightIn = new TranslateAnimation(DIMENS,1.0f,DIMENS,0.0f,DIMENS,0.0f,DIMENS,0.0f);
Animation leftOut = new TranslateAnimation(DIMENS, 0.0f, DIMENS, -1.0f, DIMENS, 0.0f, DIMENS, 0.0f);
Animation rightOut = new TranslateAnimation(DIMENS, 0.0f, DIMENS, 1.0f, DIMENS, 0.0f, DIMENS, 0.0f);
leftIn.setDuration(ANIM_DUR);
rightIn.setDuration(ANIM_DUR);
leftOut.setDuration(ANIM_DUR);
rightOut.setDuration(ANIM_DUR);
final int DIMENS = Animation.RELATIVE_TO_PARENT;
final float LEFT = -1.0f;
final float RIGHT = 1.0f;
final float NULL = 0.0f;
Animation lIn = new TranslateAnimation(DIMENS, LEFT, DIMENS, NULL, DIMENS, NULL, DIMENS, NULL);
Animation rIn = new TranslateAnimation(DIMENS, RIGHT, DIMENS, NULL, DIMENS, NULL, DIMENS, NULL);
Animation lOut = new TranslateAnimation(DIMENS, NULL, DIMENS, LEFT, DIMENS, NULL, DIMENS, NULL);
Animation rOut = new TranslateAnimation(DIMENS, NULL, DIMENS, RIGHT, DIMENS, NULL, DIMENS, NULL);
lIn.setDuration(ANIM_DUR);
rIn.setDuration(ANIM_DUR);
lOut.setDuration(ANIM_DUR);
rOut.setDuration(ANIM_DUR);
View currentTab = mTab.getCurrentView();
if( mTab.getCurrentTab() > tabIndex ) {
lastView.setAnimation(leftOut);
currentTab.setAnimation(rightIn);
lastTab.setAnimation(lOut);
currentTab.setAnimation(rIn);
} else {
lastView.setAnimation(rightOut);
currentTab.setAnimation(leftIn);
lastTab.setAnimation(rOut);
currentTab.setAnimation(lIn);
}
lastView = mTab.getCurrentView();
lastTab = mTab.getCurrentView();
}
private void getProfileTweets() {

View File

@ -14,7 +14,6 @@
<android.support.v7.widget.CardView
android:layout_width="@dimen/profile_small"
android:layout_height="@dimen/profile_small"
android:layout_marginEnd="10dp"
app:cardCornerRadius="5dp">
<ImageView
@ -22,27 +21,48 @@
android:layout_width="@dimen/profile_small"
android:layout_height="@dimen/profile_small"
android:contentDescription="@string/profile_image" />
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/dm_username"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:singleLine="true"
android:textSize="11sp" />
android:textSize="12sp" />
<TextView
android:id="@+id/dm_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:singleLine="true"
android:textSize="11sp" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:textAlignment="gravity"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="@+id/dm_screenname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<TextView

View File

@ -55,7 +55,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_weight="1"
android:layout_weight="2"
android:gravity="start"
android:singleLine="true" />

View File

@ -28,7 +28,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout

View File

@ -1,6 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()