This commit is contained in:
NudeDude 2018-02-10 00:42:23 +01:00
parent 1efcdda713
commit 49cc4b24b9
13 changed files with 83 additions and 44 deletions

View File

@ -8,8 +8,8 @@ android {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary=true
versionName '1.1'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
@ -19,6 +19,8 @@ android {
zipAlignEnabled false
}
}
productFlavors {
}
}
dependencies {

View File

@ -10,10 +10,11 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
android:label="@string/app_name">
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -23,37 +24,31 @@
<activity
android:name=".window.SearchWindow"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
<activity
android:name=".window.UserProfile"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
<activity
android:name=".window.TweetPopup"
android:theme="@style/Transparency"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait"
android:theme="@style/Transparency"/>
<activity
android:name=".window.AppSettings"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
<activity
android:name=".window.TweetDetail"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
<activity
android:name=".window.UserDetail"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
<activity
android:name=".window.LoginPage"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"/>
</application>

View File

@ -107,7 +107,6 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
bundle.putBoolean("home", true);
intent.putExtras(bundle);
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
return true;
case R.id.action_tweet:
intent = new Intent(this, TweetPopup.class);
@ -115,7 +114,6 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
b.putLong("TweetID", -1);
intent.putExtras(b);
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
return true;
case R.id.action_settings:
intent = new Intent(this, AppSettings.class);

View File

@ -34,6 +34,7 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
public static final long RETWEET = 0;
public static final long FAVORITE = 1;
public static final long DELETE = 2;
private Context c;
private ListView replyList;
@ -116,7 +117,8 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
}
return true;
} else {
if(id[1]==RETWEET) {
long mode = id[1];
if(mode==RETWEET) {
if(retweeted) {
mTwitter.retweet(tweetID, true);
// TODO del Retweet
@ -124,7 +126,7 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
mTwitter.retweet(tweetID, false);
retweeted = true;
}
} else if(id[1]==FAVORITE) {
} else if(mode==FAVORITE) {
if(favorited) {
mTwitter.favorite(tweetID, true);
favorited = false;
@ -132,6 +134,8 @@ public class ShowStatus extends AsyncTask<Long, Void, Boolean> {
mTwitter.favorite(tweetID, false);
favorited = true;
}
} else if(mode==DELETE){
mTwitter.deleteTweet(tweetID);
}
return false;
}

View File

@ -387,6 +387,13 @@ public class TwitterEngine {
}
}
/**
* @param id Tweet ID
*/
public void deleteTweet(long id) throws TwitterException {
twitter.destroyStatus(id);
}
/**
* check if User ID is home ID
* @param id User ID

View File

@ -88,6 +88,10 @@ public class TweetDatabase {
insertNew(stats);
}
public void delete(long id) {
//TODO
}
private void store(List<Status> stats) {
SQLiteDatabase db = dataHelper.getWritableDatabase();
ContentValues user = new ContentValues();

View File

@ -87,7 +87,6 @@ public class SearchWindow extends AppCompatActivity implements AdapterView.OnIte
}
intent.putExtras(b);
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
}
return true;

View File

@ -1,7 +1,10 @@
package org.nuclearfog.twidda.window;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
@ -16,11 +19,15 @@ import org.nuclearfog.twidda.database.TweetDatabase;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.viewadapter.TimelineAdapter;
import static android.content.DialogInterface.BUTTON_NEGATIVE;
import static android.content.DialogInterface.BUTTON_POSITIVE;
/**
* Detailed Tweet Window
* @see ShowStatus
*/
public class TweetDetail extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemClickListener {
public class TweetDetail extends AppCompatActivity implements View.OnClickListener,
AdapterView.OnItemClickListener, DialogInterface.OnClickListener {
private ListView answer_list;
private long tweetID;
@ -32,15 +39,21 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
setContentView(R.layout.tweet_detail);
tweetID = getIntent().getExtras().getLong("tweetID");
userID = getIntent().getExtras().getLong("userID");
SharedPreferences settings = getApplicationContext().getSharedPreferences("settings", 0);
boolean home = userID == settings.getLong("userID", -1);
answer_list = (ListView) findViewById(R.id.answer_list);
Button answer = (Button) findViewById(R.id.answer_button);
Button retweet = (Button) findViewById(R.id.rt_button_detail);
Button favorite = (Button) findViewById(R.id.fav_button_detail);
Button delete = (Button) findViewById(R.id.delete);
ImageView pb = (ImageView) findViewById(R.id.profileimage_detail);
TextView txtRt = (TextView) findViewById(R.id.no_rt_detail);
TextView txtFav = (TextView) findViewById(R.id.no_fav_detail);
if(home) {
delete.setVisibility(View.VISIBLE);
}
answer_list.setOnItemClickListener(this);
favorite.setOnClickListener(this);
@ -48,6 +61,7 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
answer.setOnClickListener(this);
txtFav.setOnClickListener(this);
txtRt.setOnClickListener(this);
delete.setOnClickListener(this);
pb.setOnClickListener(this);
setContent();
}
@ -68,7 +82,6 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
bundle.putLong("TweetID", tweetID);
intent.putExtras(bundle);
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
case R.id.rt_button_detail:
mStat.execute(tweetID, ShowStatus.RETWEET);
@ -98,6 +111,24 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
intent.putExtras(bundle);
startActivity(intent);
break;
case R.id.delete:
AlertDialog.Builder alerta = new AlertDialog.Builder(this);
alerta.setMessage("Tweet löschen?");
alerta.setPositiveButton(R.string.yes_confirm, this);
alerta.setNegativeButton(R.string.no_confirm, this);
alerta.show();
break;
}
}
@Override
public void onClick(DialogInterface d, int id) {
switch(id){
case BUTTON_NEGATIVE:
break;
case BUTTON_POSITIVE:
new ShowStatus(this).execute(tweetID,ShowStatus.DELETE);
break;
}
}

View File

@ -4,7 +4,6 @@ import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
@ -23,8 +22,8 @@ import org.nuclearfog.twidda.R;
*/
public class TweetPopup extends AppCompatActivity implements View.OnClickListener {
private EditText tweetfield;
private ImageView tweetImg1,tweetImg2,tweetImg3,tweetImg4;
private EditText tweetfield;
private long inReplyId;
private String imgPath, hashtag="";
@ -59,11 +58,6 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
tweetfield.setText(hashtag);
}
@Override
protected void onDestroy() {
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
super.onDestroy();
}
@Override
public void onClick(View v) {
@ -76,7 +70,7 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
break;
case R.id.image:
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_FIRST_USER );
startActivityForResult(i, 0);
break;
}
}
@ -85,10 +79,9 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
protected void onActivityResult(int reqCode, int returnCode, Intent i) {
super.onActivityResult(reqCode,returnCode,i);
if(returnCode == RESULT_OK){
Uri imageInput = i.getData();
String[] filepath = {MediaStore.Images.Media.DATA};
Cursor c = getContentResolver().query(imageInput,filepath,null,null,null);
if(c != null)
Cursor c = getContentResolver().query(i.getData(),filepath,null,null,null);
if(c != null) {
if(c.moveToFirst()) {
int index = c.getColumnIndex(filepath[0]);
imgPath = c.getString(index);
@ -96,16 +89,11 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
tweetImg1.setImageBitmap(img);
tweetImg1.setVisibility(View.VISIBLE);
}
c.close();
c.close();
}
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
private void send() {
String tweet = tweetfield.getText().toString();
SendStatus sendTweet;

View File

@ -76,12 +76,6 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
getContent();
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
@Override
public boolean onCreateOptionsMenu(Menu m) {
getMenuInflater().inflate(R.menu.profile, m);
@ -107,7 +101,6 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
}
intent.putExtras(b);
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
return true;
case R.id.profile_follow:
if(!home) {

View File

@ -184,6 +184,14 @@
android:layout_marginStart="5dp"
android:ems="10" />
<Button
android:id="@+id/delete"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="10dp"
android:background="@drawable/ic_cross"
android:visibility="invisible" />
</LinearLayout>
<ListView

View File

@ -37,4 +37,6 @@
<string name="refresh_dummy">Aktualisieren</string>
<string name="highlight">Highlight</string>
<string name="verify">Verifiziert</string>
<string name="yes_confirm">Ja</string>
<string name="no_confirm">Nein</string>
</resources>

View File

@ -4,9 +4,17 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:displayOptions">showHome</item>
<item name="android:windowAnimationStyle">@style/TransactionPending</item>
</style>
<style name="Transparency" parent="Theme.AppCompat.NoActionBar">
<style name="Transparency" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="TransactionPending" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@android:anim/fade_in</item>
<item name="android:activityOpenExitAnimation">@android:anim/fade_out</item>
<item name="android:activityCloseEnterAnimation">@android:anim/fade_in</item>
<item name="android:activityCloseExitAnimation">@android:anim/fade_out</item>
</style>
</resources>