This commit is contained in:
NudeDude 2017-12-29 18:37:55 +01:00
parent 3427aa4d9e
commit 430e0dc798
20 changed files with 247 additions and 45 deletions

View File

@ -37,5 +37,9 @@
android:theme="@style/AppTheme"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".Window.Tweet"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
</application>
</manifest>

View File

@ -16,6 +16,7 @@ public class TweetDatabase {
public static final int HOME_TL = 0;
public static final int FAV_TL = 1;
public static final int USER_TL = 2;
public static final int GET_TWEET = 3;
private AppDatabase dataHelper;
private List<String> user,tweet,noRT,noFav,noAns,pbLink;
@ -34,7 +35,7 @@ public class TweetDatabase {
* @param CurrentId current User ID
* @see #HOME_TL#FAV_TL#USER_TL
*/
public TweetDatabase(List<Status> stats, Context context, int mode,long CurrentId) {
public TweetDatabase(List<Status> stats, Context context, final int mode,long CurrentId) {
this.stats=stats;
this.CurrentId = CurrentId;
this.mode=mode;
@ -49,9 +50,9 @@ public class TweetDatabase {
* Read Data
* @param context MainActivity Context
* @param mode which type of data should be loaded
* @param CurrentId current User's ID
* @param CurrentId current ID (USER OR TWEET)
*/
public TweetDatabase(Context context, int mode, long CurrentId) {
public TweetDatabase(Context context, final int mode, long CurrentId) {
this.CurrentId=CurrentId;
this.mode=mode;
dataHelper = AppDatabase.getInstance(context);
@ -124,6 +125,9 @@ public class TweetDatabase {
} else if(mode==USER_TL) {
SQL_GET_HOME = "SELECT * FROM user INNER JOIN tweet ON user.userID = tweet.userID " +
"WHERE user.userID = "+CurrentId+" ORDER BY tweet.time DESC";
} else if(mode==GET_TWEET) {
SQL_GET_HOME = "SELECT * FROM user INNER JOIN tweet ON user.userID = tweet.userID " +
"WHERE tweet.tweetID = "+CurrentId+" ORDER BY tweet.time DESC";
}
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);

View File

@ -51,8 +51,8 @@ public class ProfileInformation extends AsyncTask<Long,Void,Void>
Twitter twitter = mTwitter.getTwitter();
try {
User user = twitter.showUser(args[0]);
screenName = user.getScreenName();
username = "@"+ user.getName();
screenName = '@'+ user.getScreenName();
username = user.getName();
description = user.getDescription();
location = user.getLocation();
follower = "Follower: "+ user.getFollowersCount();

View File

@ -44,10 +44,10 @@ public class ProfileTweets extends AsyncTask<Long, Void, Void> {
Twitter twitter = twitterStore.getTwitter();
if(id[1] == 0) {
TweetDatabase hTweets = new TweetDatabase(twitter.getUserTimeline(userId), context,TweetDatabase.USER_TL,userId);
homeTl = new TimelineAdapter(context,R.layout.tweet,hTweets);
homeTl = new TimelineAdapter(context,hTweets);
} else if(id[1] == 1) {
TweetDatabase fTweets = new TweetDatabase(twitter.getFavorites(userId), context,TweetDatabase.FAV_TL,userId);
homeFav = new TimelineAdapter(context,R.layout.tweet,fTweets);
homeFav = new TimelineAdapter(context,fTweets);
}
} catch(Exception err){err.printStackTrace();}
return null;

View File

@ -57,16 +57,17 @@ public class TwitterEngine extends AsyncTask<Integer, Void, Void>
try {
if(args[0]==0) {
TweetDatabase mTweets = new TweetDatabase(twitter.getHomeTimeline(), context,TweetDatabase.HOME_TL,0);
timelineAdapter = new TimelineAdapter(context,R.layout.tweet,mTweets);
timelineAdapter = new TimelineAdapter(context,mTweets);
}
else if(args[0]==1) {
TrendDatabase trend = new TrendDatabase(twitter.getPlaceTrends(23424829),context); //Germany by default
trendsAdapter = new TrendsAdapter(context,R.layout.trend,trend);
trendsAdapter = new TrendsAdapter(context,trend);
}
else if(args[0]==2) { //TODO
// twitter.getMentionsTimeline()
}
} catch (TwitterException e) {
Toast.makeText(context, ERR_MSG, Toast.LENGTH_SHORT).show();
Toast.makeText(context, ERR_MSG, Toast.LENGTH_LONG).show();
} catch (Exception e){ e.printStackTrace(); }
return null;
}

View File

@ -9,9 +9,14 @@ import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@ -26,6 +31,7 @@ import org.nuclearfog.twidda.ViewAdapter.TimelineAdapter;
import org.nuclearfog.twidda.ViewAdapter.TrendsAdapter;
import org.nuclearfog.twidda.Window.Profile;
import org.nuclearfog.twidda.Window.Settings;
import org.nuclearfog.twidda.Window.Tweet;
import org.nuclearfog.twidda.Window.TweetWindow;
public class MainActivity extends AppCompatActivity
@ -33,6 +39,8 @@ public class MainActivity extends AppCompatActivity
private SwipeRefreshLayout timelineReload,trendReload,mentionReload;
private ListView timelineList, trendList,mentionList;
private SharedPreferences settings;
private TweetDatabase tweetDeck;
private TrendDatabase trendDeck;
private EditText pin;
private Context con;
private Toolbar toolbar;
@ -152,17 +160,17 @@ public class MainActivity extends AppCompatActivity
// Tab #1
TabSpec tab1 = tabhost.newTabSpec("timeline");
tab1.setContent(R.id.timeline);
tab1.setIndicator("Timeline");
tab1.setIndicator("",getResources().getDrawable(R.drawable.timeline_icon));
tabhost.addTab(tab1);
// Tab #2
TabSpec tab2 = tabhost.newTabSpec("trends");
tab2.setContent(R.id.trends);
tab2.setIndicator("Trend");
tab2.setIndicator("",getResources().getDrawable(R.drawable.trends_icon));
tabhost.addTab(tab2);
// Tab #3
TabSpec tab3 = tabhost.newTabSpec("mention");
tab3.setContent(R.id.mention);
tab3.setIndicator("Mention");
tab3.setIndicator("",getResources().getDrawable(R.drawable.mention_icon));
tabhost.addTab(tab3);
tabhost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
@ -180,11 +188,11 @@ public class MainActivity extends AppCompatActivity
* separate THREAD
*/
private void setTabContent() {
TweetDatabase tweetDeck = new TweetDatabase(con,TweetDatabase.HOME_TL, 0L);
TimelineAdapter tlAdapt = new TimelineAdapter(con,R.layout.tweet,tweetDeck);
tweetDeck = new TweetDatabase(con,TweetDatabase.HOME_TL, 0L);
trendDeck = new TrendDatabase(con);
TimelineAdapter tlAdapt = new TimelineAdapter(con,tweetDeck);
TrendsAdapter trendAdp = new TrendsAdapter(con,trendDeck);
timelineList.setAdapter(tlAdapt);
TrendDatabase trendDeck = new TrendDatabase(con);
TrendsAdapter trendAdp = new TrendsAdapter(con,R.layout.trend,trendDeck);
trendList.setAdapter(trendAdp);
}
@ -216,23 +224,30 @@ public class MainActivity extends AppCompatActivity
}
private void setListViewListener() {
timelineList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
System.out.println("id: "+id+"\nPos: "+position);
if(!timelineReload.isRefreshing()) {
int index = timelineList.getPositionForView(view);
long tweetID = tweetDeck.getTweetId(index);
Intent intent = new Intent(con, Tweet.class);
Bundle bundle = new Bundle();
bundle.putLong("tweetID",tweetID);
intent.putExtras(bundle);
startActivity(intent);
}
}
});
trendList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
System.out.println("Trend klick: "+position); //TODO
System.out.println("1 klick: "+position); //TODO
}
});
mentionList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
System.out.println("Mention klick"); //TODO
System.out.println("2 klick"+position); //TODO
}
});
}
@ -260,4 +275,5 @@ public class MainActivity extends AppCompatActivity
break;
}
}
}

View File

@ -17,9 +17,10 @@ import org.nuclearfog.twidda.DataBase.TweetDatabase;
public class TimelineAdapter extends ArrayAdapter {
private TweetDatabase mTweets;
private Context context;
private ViewGroup p;
public TimelineAdapter(Context context, int layout, TweetDatabase mTweets) {
super(context, layout);
public TimelineAdapter(Context context, TweetDatabase mTweets) {
super(context, R.layout.tweet);
this.mTweets = mTweets;
this.context = context;
}
@ -31,6 +32,7 @@ public class TimelineAdapter extends ArrayAdapter {
@Override
public View getView(int position, View v, ViewGroup parent) {
p = parent;
if(v == null) {
LayoutInflater inf=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inf.inflate(R.layout.tweet, parent,false);
@ -41,12 +43,20 @@ public class TimelineAdapter extends ArrayAdapter {
((TextView) v.findViewById(R.id.retweet_number)).setText(mTweets.getRetweet(position));
((TextView) v.findViewById(R.id.favorite_number)).setText(mTweets.getFavorite(position));
((TextView) v.findViewById(R.id.time)).setText(mTweets.getDate(position));
/* ImageView imgView = v.findViewById(R.id.tweetPb);
ImageView imgView = v.findViewById(R.id.tweetPb);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((ListView)p).performItemClick(v,0,0);
}
});
if(mTweets.loadImages()) {
ImageDownloader imgDl = new ImageDownloader(imgView);
imgDl.execute(mTweets.getPbImg(position));
}*/
}
return v;
}
}

View File

@ -14,8 +14,8 @@ public class TrendsAdapter extends ArrayAdapter {
private TrendDatabase trend;
private Context context;
public TrendsAdapter(Context context, int layout, TrendDatabase trend) {
super(context, layout);
public TrendsAdapter(Context context, TrendDatabase trend) {
super(context, R.layout.trend);//test
this.trend = trend;
this.context = context;
}
@ -35,4 +35,4 @@ public class TrendsAdapter extends ArrayAdapter {
((TextView) v.findViewById(R.id.trendname)).setText(trendName);
return v;
}
}
}

View File

@ -73,11 +73,13 @@ public class Profile extends AppCompatActivity {
mTab.setup();
// Tab #1
TabHost.TabSpec tab1 = mTab.newTabSpec("tweets");
tab1.setIndicator("Tweets").setContent(R.id.hometweets);
tab1.setContent(R.id.hometweets);
tab1.setIndicator("",getResources().getDrawable(R.drawable.timeline_icon));
mTab.addTab(tab1);
// Tab #2
TabHost.TabSpec tab2 = mTab.newTabSpec("favorites");
tab2.setIndicator("Favorits").setContent(R.id.homefavorits);
tab2.setContent(R.id.homefavorits);
tab2.setIndicator("",getResources().getDrawable(R.drawable.favorite_icon));
mTab.addTab(tab2);
// Listener
mTab.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@ -114,10 +116,10 @@ public class Profile extends AppCompatActivity {
@Override
public void run(){
TweetDatabase mTweet = new TweetDatabase(Profile.this, TweetDatabase.USER_TL, userId);
TimelineAdapter tl = new TimelineAdapter(Profile.this,R.layout.tweet,mTweet);
TimelineAdapter tl = new TimelineAdapter(Profile.this,mTweet);
homeTweets.setAdapter(tl);
TweetDatabase fTweet = new TweetDatabase(Profile.this, TweetDatabase.FAV_TL, userId);
TimelineAdapter fl = new TimelineAdapter(Profile.this,R.layout.tweet,fTweet);
TimelineAdapter fl = new TimelineAdapter(Profile.this,fTweet);
homeFavorits.setAdapter(fl);
}
}.run();

View File

@ -0,0 +1,44 @@
package org.nuclearfog.twidda.Window;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.TextView;
import org.nuclearfog.twidda.DataBase.TweetDatabase;
import org.nuclearfog.twidda.R;
public class Tweet extends AppCompatActivity {
private TweetDatabase mTweet;
private TextView tweet, username;
private long tweetID;
@Override
protected void onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.tweet_detail);
tweet = (TextView) findViewById(R.id.tweetdetail);
username = (TextView) findViewById(R.id.usernamedetail);
ImageView pb = (ImageView) findViewById(R.id.profileimage_detail);
tweetID = getIntent().getExtras().getLong("tweetID");
setContent();
}
private void setContent() {
mTweet = new TweetDatabase(getApplicationContext(),TweetDatabase.GET_TWEET,tweetID);
tweet.setText(mTweet.getTweet(0));
username.setText(mTweet.getUsername(0));
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/favorite" />
</selector>

View File

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="20.0"
android:viewportWidth="20.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M10,0.4c-5.303,0 -9.601,4.298 -9.601,9.6c0,5.303 4.298,9.601 9.601,9.601c5.301,0 9.6,-4.298 9.6,-9.601C19.6,4.698 15.301,0.4 10,0.4zM11,17.525V13H9v4.525C5.604,17.079 2.92,14.396 2.473,11H7V9H2.473C2.92,5.604 5.604,2.921 9,2.475V7h2V2.475c3.394,0.447 6.078,3.13 6.525,6.525H13v2h4.525C17.078,14.394 14.394,17.078 11,17.525z"/>
</vector>

View File

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="20.0"
android:viewportWidth="20.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M18.672,11H17v6c0,0.445 -0.194,1 -1,1h-4v-6H8v6H4c-0.806,0 -1,-0.555 -1,-1v-6H1.328c-0.598,0 -0.47,-0.324 -0.06,-0.748L9.292,2.22C9.487,2.018 9.743,1.918 10,1.908c0.257,0.01 0.513,0.109 0.708,0.312l8.023,8.031C19.142,10.676 19.27,11 18.672,11z"/>
</vector>

View File

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="20.0"
android:viewportWidth="20.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M14.608,12.172c0,0.84 0.239,1.175 0.864,1.175c1.393,0 2.28,-1.775 2.28,-4.727c0,-4.512 -3.288,-6.672 -7.393,-6.672c-4.223,0 -8.064,2.832 -8.064,8.184c0,5.112 3.36,7.896 8.52,7.896c1.752,0 2.928,-0.192 4.727,-0.792l0.386,1.607c-1.776,0.577 -3.674,0.744 -5.137,0.744c-6.768,0 -10.393,-3.72 -10.393,-9.456c0,-5.784 4.201,-9.72 9.985,-9.72c6.024,0 9.215,3.6 9.215,8.016c0,3.744 -1.175,6.6 -4.871,6.6c-1.681,0 -2.784,-0.672 -2.928,-2.161c-0.432,1.656 -1.584,2.161 -3.145,2.161c-2.088,0 -3.84,-1.609 -3.84,-4.848c0,-3.264 1.537,-5.28 4.297,-5.28c1.464,0 2.376,0.576 2.782,1.488l0.697,-1.272h2.016v7.057C14.606,12.172 14.608,12.172 14.608,12.172zM11.657,9.004c0,-1.319 -0.985,-1.872 -1.801,-1.872c-0.888,0 -1.871,0.719 -1.871,2.832c0,1.68 0.744,2.616 1.871,2.616c0.792,0 1.801,-0.504 1.801,-1.896V9.004z"/>
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/mention" />
</selector>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_home" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/hash" />
</selector>

View File

@ -46,16 +46,17 @@
android:orientation="horizontal">
<TextView
android:id="@+id/profile_screenname"
android:id="@+id/profile_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/profile_username"
android:id="@+id/profile_screenname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<TextView

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/profileimage_detail"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_margin="5dp"
android:contentDescription="@string/profile_image"
app:srcCompat="@mipmap/pb" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/usernamedetail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/timedetail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tweetdetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp" />
<LinearLayout
android:id="@+id/actionbar"
android:layout_width="match_parent"
android:layout_height="20dp"
android:addStatesFromChildren="false"
android:gravity="right"
android:orientation="horizontal">
<Button
android:id="@+id/answer"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="@drawable/chat" />
<TextView
android:id="@+id/answer_number"
android:layout_width="64dp"
android:layout_height="match_parent"
android:ems="10" />
<Button
android:id="@+id/retweet"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="@drawable/retweet" />
<TextView
android:id="@+id/retweet_number"
android:layout_width="64dp"
android:layout_height="match_parent"
android:ems="10" />
<Button
android:id="@+id/favorite"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="@drawable/favorite" />
<TextView
android:id="@+id/favorite_number"
android:layout_width="64dp"
android:layout_height="match_parent"
android:ems="10" />
</LinearLayout>
<ListView
android:id="@+id/answer_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:displayOptions">showHome</item>
<item name="android:navigationBarColor">?android:attr/colorEdgeEffect</item>
</style>
</resources>