Statistics per toot #274
This commit is contained in:
parent
4a763abccc
commit
8af6d9de07
|
@ -67,12 +67,15 @@ import app.fedilab.android.R;
|
||||||
import app.fedilab.android.asynctasks.RetrieveNotificationChartsAsyncTask;
|
import app.fedilab.android.asynctasks.RetrieveNotificationChartsAsyncTask;
|
||||||
import app.fedilab.android.client.Entities.Account;
|
import app.fedilab.android.client.Entities.Account;
|
||||||
import app.fedilab.android.client.Entities.NotificationCharts;
|
import app.fedilab.android.client.Entities.NotificationCharts;
|
||||||
|
import app.fedilab.android.client.Entities.Status;
|
||||||
import app.fedilab.android.helper.Helper;
|
import app.fedilab.android.helper.Helper;
|
||||||
import app.fedilab.android.interfaces.OnRetrieveNotificationChartsInterface;
|
import app.fedilab.android.interfaces.OnRetrieveNotificationChartsInterface;
|
||||||
import app.fedilab.android.sqlite.AccountDAO;
|
import app.fedilab.android.sqlite.AccountDAO;
|
||||||
import app.fedilab.android.sqlite.NotificationCacheDAO;
|
import app.fedilab.android.sqlite.NotificationCacheDAO;
|
||||||
import app.fedilab.android.sqlite.Sqlite;
|
import app.fedilab.android.sqlite.Sqlite;
|
||||||
|
import app.fedilab.android.sqlite.StatusCacheDAO;
|
||||||
|
|
||||||
|
import static app.fedilab.android.sqlite.StatusCacheDAO.NOTIFICATION_CACHE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +93,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
private int theme;
|
private int theme;
|
||||||
private RelativeLayout loader;
|
private RelativeLayout loader;
|
||||||
private ImageButton validate;
|
private ImageButton validate;
|
||||||
|
private String status_id;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -110,6 +114,10 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
default:
|
default:
|
||||||
setTheme(R.style.AppThemeDark);
|
setTheme(R.style.AppThemeDark);
|
||||||
}
|
}
|
||||||
|
Bundle b = getIntent().getExtras();
|
||||||
|
status_id = null;
|
||||||
|
if(b != null)
|
||||||
|
status_id = b.getString("status_id");
|
||||||
if( getSupportActionBar() != null)
|
if( getSupportActionBar() != null)
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
@ -156,10 +164,22 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
settings_time_to = findViewById(R.id.settings_time_to);
|
settings_time_to = findViewById(R.id.settings_time_to);
|
||||||
loader = findViewById(R.id.loader);
|
loader = findViewById(R.id.loader);
|
||||||
validate = findViewById(R.id.validate);
|
validate = findViewById(R.id.validate);
|
||||||
|
LinearLayout date_container = findViewById(R.id.date_container);
|
||||||
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(OwnerNotificationChartsActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
dateIni = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getSmallerDate();
|
if( status_id == null) {
|
||||||
dateEnd = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getGreaterDate();
|
dateIni = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getSmallerDate();
|
||||||
|
dateEnd = new NotificationCacheDAO(OwnerNotificationChartsActivity.this, db).getGreaterDate();
|
||||||
|
}else{
|
||||||
|
Status status = new StatusCacheDAO(getApplicationContext(), db).getStatus(status_id);
|
||||||
|
if( status == null){
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
dateIni = status.getCreated_at();
|
||||||
|
dateEnd = dateIni;
|
||||||
|
date_container.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int style;
|
int style;
|
||||||
|
@ -171,7 +191,9 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
style = R.style.Dialog;
|
style = R.style.Dialog;
|
||||||
}
|
}
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
c.setTime(dateIni);
|
if(dateIni != null) {
|
||||||
|
c.setTime(dateIni);
|
||||||
|
}
|
||||||
int yearIni = c.get(Calendar.YEAR);
|
int yearIni = c.get(Calendar.YEAR);
|
||||||
int monthIni = c.get(Calendar.MONTH);
|
int monthIni = c.get(Calendar.MONTH);
|
||||||
int dayIni = c.get(Calendar.DAY_OF_MONTH);
|
int dayIni = c.get(Calendar.DAY_OF_MONTH);
|
||||||
|
@ -185,51 +207,51 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if( dateIni != null) {
|
||||||
|
Calendar ce = Calendar.getInstance();
|
||||||
|
c.setTime(dateEnd);
|
||||||
|
int yearEnd = ce.get(Calendar.YEAR);
|
||||||
|
int monthEnd = ce.get(Calendar.MONTH);
|
||||||
|
int dayEnd = ce.get(Calendar.DAY_OF_MONTH);
|
||||||
|
final DatePickerDialog dateEndPickerDialog = new DatePickerDialog(
|
||||||
|
OwnerNotificationChartsActivity.this, style, endDateSetListener, yearEnd, monthEnd, dayEnd);
|
||||||
|
settings_time_to.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dateEndPickerDialog.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Calendar ce = Calendar.getInstance();
|
dateIniPickerDialog.getDatePicker().setMinDate(dateIni.getTime());
|
||||||
c.setTime(dateEnd);
|
dateIniPickerDialog.getDatePicker().setMaxDate(dateEnd.getTime());
|
||||||
int yearEnd = ce.get(Calendar.YEAR);
|
|
||||||
int monthEnd = ce.get(Calendar.MONTH);
|
dateEndPickerDialog.getDatePicker().setMinDate(dateIni.getTime());
|
||||||
int dayEnd = ce.get(Calendar.DAY_OF_MONTH);
|
dateEndPickerDialog.getDatePicker().setMaxDate(dateEnd.getTime());
|
||||||
final DatePickerDialog dateEndPickerDialog = new DatePickerDialog(
|
|
||||||
OwnerNotificationChartsActivity.this, style, endDateSetListener, yearEnd, monthEnd, dayEnd);
|
Calendar cal = Calendar.getInstance();
|
||||||
settings_time_to.setOnClickListener(new View.OnClickListener() {
|
cal.setTime(dateEnd);
|
||||||
@Override
|
cal.add(Calendar.MONTH, -1);
|
||||||
public void onClick(View v) {
|
Date result = cal.getTime();
|
||||||
dateEndPickerDialog.show();
|
if (result.after(dateIni))
|
||||||
|
dateIni = result;
|
||||||
|
|
||||||
|
if (dateIni == null) {
|
||||||
|
dateIni = new Date();
|
||||||
|
}
|
||||||
|
if (dateEnd == null) {
|
||||||
|
dateEnd = new Date();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
dateIniPickerDialog.getDatePicker().setMinDate(dateIni.getTime());
|
|
||||||
dateIniPickerDialog.getDatePicker().setMaxDate(dateEnd.getTime());
|
|
||||||
|
|
||||||
dateEndPickerDialog.getDatePicker().setMinDate(dateIni.getTime());
|
|
||||||
dateEndPickerDialog.getDatePicker().setMaxDate(dateEnd.getTime());
|
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(dateEnd);
|
|
||||||
cal.add(Calendar.MONTH, -1);
|
|
||||||
Date result = cal.getTime();
|
|
||||||
if (result.after(dateIni))
|
|
||||||
dateIni = result;
|
|
||||||
|
|
||||||
if (dateIni == null) {
|
|
||||||
dateIni = new Date();
|
|
||||||
}
|
|
||||||
if (dateEnd == null) {
|
|
||||||
dateEnd = new Date();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CustomMarkerView mv = new CustomMarkerView(getApplicationContext(), R.layout.markerview);
|
CustomMarkerView mv = new CustomMarkerView(getApplicationContext(), R.layout.markerview);
|
||||||
chart.setMarkerView(mv);
|
chart.setMarkerView(mv);
|
||||||
|
|
||||||
|
validate.setOnClickListener(v -> {
|
||||||
|
loadGraph(dateIni, dateEnd);
|
||||||
|
});
|
||||||
|
|
||||||
validate.setOnClickListener(v->{
|
|
||||||
loadGraph(dateIni, dateEnd);
|
loadGraph(dateIni, dateEnd);
|
||||||
});
|
}
|
||||||
|
|
||||||
loadGraph(dateIni, dateEnd);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,13 +294,13 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Entry> pollEntry = new ArrayList<>();
|
/*List<Entry> pollEntry = new ArrayList<>();
|
||||||
it = charts.getFollows().entrySet().iterator();
|
it = charts.getFollows().entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry pair = (Map.Entry)it.next();
|
Map.Entry pair = (Map.Entry)it.next();
|
||||||
pollEntry.add(new Entry((long)pair.getKey(), (int)pair.getValue()));
|
pollEntry.add(new Entry((long)pair.getKey(), (int)pair.getValue()));
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,7 +314,11 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
dataSetBoosts.setDrawCircles(false);
|
dataSetBoosts.setDrawCircles(false);
|
||||||
dataSetBoosts.setDrawCircleHole(false);
|
dataSetBoosts.setDrawCircleHole(false);
|
||||||
dataSetBoosts.setLineWidth(2f);
|
dataSetBoosts.setLineWidth(2f);
|
||||||
dataSetBoosts.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
if( status_id == null) {
|
||||||
|
dataSetBoosts.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
}else{
|
||||||
|
dataSetBoosts.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
|
||||||
|
}
|
||||||
|
|
||||||
LineDataSet dateSetFavorites = new LineDataSet(favEntry, getString(R.string.favourite));
|
LineDataSet dateSetFavorites = new LineDataSet(favEntry, getString(R.string.favourite));
|
||||||
dateSetFavorites.setColor(ContextCompat.getColor(OwnerNotificationChartsActivity.this, R.color.chart_notif_fav));
|
dateSetFavorites.setColor(ContextCompat.getColor(OwnerNotificationChartsActivity.this, R.color.chart_notif_fav));
|
||||||
|
@ -304,7 +330,11 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
dateSetFavorites.setDrawCircles(false);
|
dateSetFavorites.setDrawCircles(false);
|
||||||
dateSetFavorites.setDrawCircleHole(false);
|
dateSetFavorites.setDrawCircleHole(false);
|
||||||
dateSetFavorites.setLineWidth(2f);
|
dateSetFavorites.setLineWidth(2f);
|
||||||
dateSetFavorites.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
if( status_id == null) {
|
||||||
|
dateSetFavorites.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
}else{
|
||||||
|
dateSetFavorites.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
|
||||||
|
}
|
||||||
|
|
||||||
LineDataSet dataSetMention = new LineDataSet(mentionEntry, getString(R.string.mention));
|
LineDataSet dataSetMention = new LineDataSet(mentionEntry, getString(R.string.mention));
|
||||||
dataSetMention.setColor(ContextCompat.getColor(OwnerNotificationChartsActivity.this, R.color.chart_notif_mention));
|
dataSetMention.setColor(ContextCompat.getColor(OwnerNotificationChartsActivity.this, R.color.chart_notif_mention));
|
||||||
|
@ -316,7 +346,11 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
dataSetMention.setDrawCircles(false);
|
dataSetMention.setDrawCircles(false);
|
||||||
dataSetMention.setDrawCircleHole(false);
|
dataSetMention.setDrawCircleHole(false);
|
||||||
dataSetMention.setLineWidth(2f);
|
dataSetMention.setLineWidth(2f);
|
||||||
dataSetMention.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
if( status_id == null) {
|
||||||
|
dataSetMention.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
}else{
|
||||||
|
dataSetMention.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LineDataSet dataSetFollow = new LineDataSet(followEntry, getString(R.string.follow));
|
LineDataSet dataSetFollow = new LineDataSet(followEntry, getString(R.string.follow));
|
||||||
|
@ -329,7 +363,11 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
dataSetFollow.setDrawCircles(false);
|
dataSetFollow.setDrawCircles(false);
|
||||||
dataSetFollow.setDrawCircleHole(false);
|
dataSetFollow.setDrawCircleHole(false);
|
||||||
dataSetFollow.setLineWidth(2f);
|
dataSetFollow.setLineWidth(2f);
|
||||||
dataSetFollow.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
if( status_id == null) {
|
||||||
|
dataSetFollow.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
}else{
|
||||||
|
dataSetFollow.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -343,7 +381,9 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
dataSetPolls.setDrawCircles(false);
|
dataSetPolls.setDrawCircles(false);
|
||||||
dataSetPolls.setDrawCircleHole(false);
|
dataSetPolls.setDrawCircleHole(false);
|
||||||
dataSetPolls.setLineWidth(2f);
|
dataSetPolls.setLineWidth(2f);
|
||||||
dataSetPolls.setMode(LineDataSet.Mode.CUBIC_BEZIER);*/
|
if( status_id == null) {
|
||||||
|
dataSetPolls.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
List<ILineDataSet> dataSets = new ArrayList<>();
|
List<ILineDataSet> dataSets = new ArrayList<>();
|
||||||
|
@ -494,7 +534,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
chart.setVisibility(View.GONE);
|
chart.setVisibility(View.GONE);
|
||||||
loader.setVisibility(View.VISIBLE);
|
loader.setVisibility(View.VISIBLE);
|
||||||
validate.setEnabled(false);
|
validate.setEnabled(false);
|
||||||
new RetrieveNotificationChartsAsyncTask(OwnerNotificationChartsActivity.this, null, dateIni, dateEnd, OwnerNotificationChartsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new RetrieveNotificationChartsAsyncTask(OwnerNotificationChartsActivity.this, status_id, dateIni, dateEnd, OwnerNotificationChartsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +550,11 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
|
||||||
private Date mDate;
|
private Date mDate;
|
||||||
|
|
||||||
MyXAxisValueFormatter() {
|
MyXAxisValueFormatter() {
|
||||||
this.mDataFormat = new SimpleDateFormat("dd.MM", Locale.getDefault());
|
if( status_id == null) {
|
||||||
|
this.mDataFormat = new SimpleDateFormat("dd.MM", Locale.getDefault());
|
||||||
|
}else{
|
||||||
|
this.mDataFormat = new SimpleDateFormat("hh'h'", Locale.getDefault());
|
||||||
|
}
|
||||||
this.mDate = new Date();
|
this.mDate = new Date();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -72,6 +72,7 @@ import java.util.TimerTask;
|
||||||
|
|
||||||
import app.fedilab.android.activities.AccountReportActivity;
|
import app.fedilab.android.activities.AccountReportActivity;
|
||||||
import app.fedilab.android.activities.BaseMainActivity;
|
import app.fedilab.android.activities.BaseMainActivity;
|
||||||
|
import app.fedilab.android.activities.OwnerNotificationChartsActivity;
|
||||||
import app.fedilab.android.client.API;
|
import app.fedilab.android.client.API;
|
||||||
import app.fedilab.android.client.APIResponse;
|
import app.fedilab.android.client.APIResponse;
|
||||||
import app.fedilab.android.client.Entities.Account;
|
import app.fedilab.android.client.Entities.Account;
|
||||||
|
@ -890,7 +891,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PopupMenu popup = new PopupMenu(context, attached);
|
PopupMenu popup = new PopupMenu(context, attached);
|
||||||
assert status != null;
|
assert status != null;
|
||||||
final boolean isOwner = status.getAccount().getId().equals(userId);
|
final boolean isOwner = status.getReblog()!=null?status.getReblog().getAccount().getId().equals(userId):status.getAccount().getId().equals(userId);
|
||||||
popup.getMenuInflater()
|
popup.getMenuInflater()
|
||||||
.inflate(R.menu.option_toot, popup.getMenu());
|
.inflate(R.menu.option_toot, popup.getMenu());
|
||||||
if( notification.getType().equals("mention"))
|
if( notification.getType().equals("mention"))
|
||||||
|
@ -910,7 +911,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
|
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
|
||||||
popup.getMenu().findItem(R.id.action_report).setVisible(false);
|
popup.getMenu().findItem(R.id.action_report).setVisible(false);
|
||||||
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
|
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
|
||||||
|
if( social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||||
|
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
|
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
|
||||||
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
|
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
|
||||||
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
|
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
|
||||||
}
|
}
|
||||||
|
@ -978,6 +983,13 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_stats:
|
||||||
|
intent = new Intent(context, OwnerNotificationChartsActivity.class);
|
||||||
|
b = new Bundle();
|
||||||
|
b.putString("status_id", status.getReblog()!=null?status.getReblog().getId():status.getId());
|
||||||
|
intent.putExtras(b);
|
||||||
|
context.startActivity(intent);
|
||||||
|
return true;
|
||||||
case R.id.action_info:
|
case R.id.action_info:
|
||||||
intent = new Intent(context, TootInfoActivity.class);
|
intent = new Intent(context, TootInfoActivity.class);
|
||||||
b = new Bundle();
|
b = new Bundle();
|
||||||
|
|
|
@ -111,6 +111,7 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import app.fedilab.android.activities.AccountReportActivity;
|
import app.fedilab.android.activities.AccountReportActivity;
|
||||||
|
import app.fedilab.android.activities.OwnerNotificationChartsActivity;
|
||||||
import app.fedilab.android.asynctasks.PostStatusAsyncTask;
|
import app.fedilab.android.asynctasks.PostStatusAsyncTask;
|
||||||
import app.fedilab.android.asynctasks.RetrieveRelationshipQuickReplyAsyncTask;
|
import app.fedilab.android.asynctasks.RetrieveRelationshipQuickReplyAsyncTask;
|
||||||
import app.fedilab.android.client.API;
|
import app.fedilab.android.client.API;
|
||||||
|
@ -2302,7 +2303,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
holder.spark_button_reblog.setVisibility(View.GONE);
|
holder.spark_button_reblog.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case "private":
|
case "private":
|
||||||
boolean isOwner = status.getAccount().getId().equals(userId);
|
final boolean isOwner = status.getReblog()!=null?status.getReblog().getAccount().getId().equals(userId):status.getAccount().getId().equals(userId);
|
||||||
if (isOwner) {
|
if (isOwner) {
|
||||||
holder.status_reblog_count.setVisibility(View.VISIBLE);
|
holder.status_reblog_count.setVisibility(View.VISIBLE);
|
||||||
holder.spark_button_reblog.setVisibility(View.VISIBLE);
|
holder.spark_button_reblog.setVisibility(View.VISIBLE);
|
||||||
|
@ -2369,7 +2370,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
else
|
else
|
||||||
Helper.changeDrawableColor(context, R.drawable.ic_reply, R.color.action_light);
|
Helper.changeDrawableColor(context, R.drawable.ic_reply, R.color.action_light);
|
||||||
|
|
||||||
boolean isOwner = status.getAccount().getId().equals(userId);
|
final boolean isOwner = status.getReblog()!=null?status.getReblog().getAccount().getId().equals(userId):status.getAccount().getId().equals(userId);
|
||||||
|
|
||||||
// Pinning toots is only available on Mastodon 1._6_.0 instances.
|
// Pinning toots is only available on Mastodon 1._6_.0 instances.
|
||||||
if (isOwner && Helper.canPin && (status.getVisibility().equals("public") || status.getVisibility().equals("unlisted")) && status.getReblog() == null) {
|
if (isOwner && Helper.canPin && (status.getVisibility().equals("public") || status.getVisibility().equals("unlisted")) && status.getReblog() == null) {
|
||||||
|
@ -2986,7 +2987,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PopupMenu popup = new PopupMenu(context, attached);
|
PopupMenu popup = new PopupMenu(context, attached);
|
||||||
final boolean isOwner = status.getAccount().getId().equals(userId);
|
final boolean isOwner = status.getReblog()!=null?status.getReblog().getAccount().getId().equals(userId):status.getAccount().getId().equals(userId);
|
||||||
popup.getMenuInflater()
|
popup.getMenuInflater()
|
||||||
.inflate(R.menu.option_toot, popup.getMenu());
|
.inflate(R.menu.option_toot, popup.getMenu());
|
||||||
if (status.getVisibility().equals("private") || status.getVisibility().equals("direct")) {
|
if (status.getVisibility().equals("private") || status.getVisibility().equals("direct")) {
|
||||||
|
@ -3012,7 +3013,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
popup.getMenu().findItem(R.id.action_timed_mute).setVisible(false);
|
popup.getMenu().findItem(R.id.action_timed_mute).setVisible(false);
|
||||||
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
|
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
|
||||||
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
|
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
|
||||||
|
if( social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||||
|
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
|
||||||
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
|
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
|
||||||
//popup.getMenu().findItem(R.id.action_mute_conversation).setVisible(false);
|
//popup.getMenu().findItem(R.id.action_mute_conversation).setVisible(false);
|
||||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator)) {
|
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator)) {
|
||||||
|
@ -3160,6 +3165,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_stats:
|
||||||
|
intent = new Intent(context, OwnerNotificationChartsActivity.class);
|
||||||
|
b = new Bundle();
|
||||||
|
b.putString("status_id", status.getReblog()!=null?status.getReblog().getId():status.getId());
|
||||||
|
intent.putExtras(b);
|
||||||
|
context.startActivity(intent);
|
||||||
|
return true;
|
||||||
case R.id.action_timed_mute:
|
case R.id.action_timed_mute:
|
||||||
timedMuteAction(status);
|
timedMuteAction(status);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import app.fedilab.android.client.Entities.Charts;
|
|
||||||
import app.fedilab.android.client.Entities.Notification;
|
import app.fedilab.android.client.Entities.Notification;
|
||||||
import app.fedilab.android.client.Entities.NotificationCharts;
|
import app.fedilab.android.client.Entities.NotificationCharts;
|
||||||
import app.fedilab.android.client.Entities.StatisticsNotification;
|
import app.fedilab.android.client.Entities.StatisticsNotification;
|
||||||
|
@ -76,6 +75,9 @@ public class NotificationCacheDAO {
|
||||||
}else {
|
}else {
|
||||||
id = status.getDb_id();
|
id = status.getDb_id();
|
||||||
}
|
}
|
||||||
|
if( notification.getType().equals("mention")){
|
||||||
|
values.put(Sqlite.COL_IN_REPLY_TO_ID, notification.getStatus().getIn_reply_to_id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
values.put(Sqlite.COL_STATUS_ID_CACHE, id);
|
values.put(Sqlite.COL_STATUS_ID_CACHE, id);
|
||||||
values.put(Sqlite.COL_ACCOUNT, Helper.accountToStringStorage(notification.getAccount()));
|
values.put(Sqlite.COL_ACCOUNT, Helper.accountToStringStorage(notification.getAccount()));
|
||||||
|
@ -173,6 +175,9 @@ public class NotificationCacheDAO {
|
||||||
}else {
|
}else {
|
||||||
id = status.getDb_id();
|
id = status.getDb_id();
|
||||||
}
|
}
|
||||||
|
if( notification.getType().equals("mention")){
|
||||||
|
values.put(Sqlite.COL_IN_REPLY_TO_ID, notification.getStatus().getIn_reply_to_id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
values.put(Sqlite.COL_STATUS_ID_CACHE, id);
|
values.put(Sqlite.COL_STATUS_ID_CACHE, id);
|
||||||
values.put(Sqlite.COL_ACCOUNT, Helper.accountToStringStorage(notification.getAccount()));
|
values.put(Sqlite.COL_ACCOUNT, Helper.accountToStringStorage(notification.getAccount()));
|
||||||
|
@ -579,7 +584,10 @@ public class NotificationCacheDAO {
|
||||||
end.set(Calendar.MINUTE, 59);
|
end.set(Calendar.MINUTE, 59);
|
||||||
end.set(Calendar.SECOND, 59);
|
end.set(Calendar.SECOND, 59);
|
||||||
}else{
|
}else{
|
||||||
|
start.setTime(dateIni);
|
||||||
|
|
||||||
|
end.setTime(dateIni);
|
||||||
|
end.add(Calendar.HOUR, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
long msDiff = end.getTimeInMillis() - start.getTimeInMillis();
|
long msDiff = end.getTimeInMillis() - start.getTimeInMillis();
|
||||||
|
@ -598,55 +606,55 @@ public class NotificationCacheDAO {
|
||||||
int mentionCount = 0;
|
int mentionCount = 0;
|
||||||
Date smallestDate = getSmallerDate();
|
Date smallestDate = getSmallerDate();
|
||||||
int minYVal = 0;
|
int minYVal = 0;
|
||||||
StringBuilder selection = new StringBuilder(Sqlite.COL_INSTANCE + " = '" + instance + "' AND " + Sqlite.COL_USER_ID + " = '" + userId + "'");
|
|
||||||
selection.append(" AND " + Sqlite.COL_CREATED_AT + " >= '").append(Helper.dateToString(smallestDate)).append("'");
|
|
||||||
selection.append(" AND " + Sqlite.COL_CREATED_AT + " <= '").append(Helper.dateToString(start.getTime())).append("'");
|
|
||||||
if( status_id != null ){
|
|
||||||
selection.append(" AND " + Sqlite.COL_STATUS_ID + " = '").append(status_id).append("'");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
|
||||||
+ " where " + selection.toString() + " AND "
|
|
||||||
+ Sqlite.COL_TYPE + " = 'reblog'"
|
|
||||||
, null);
|
|
||||||
mCount.moveToFirst();
|
|
||||||
reblogCount = mCount.getInt(0);
|
|
||||||
mCount.close();
|
|
||||||
minYVal = reblogCount;
|
|
||||||
|
|
||||||
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
if( status_id == null) {
|
||||||
+ " where " + selection.toString() + " AND "
|
StringBuilder selection = new StringBuilder(Sqlite.COL_INSTANCE + " = '" + instance + "' AND " + Sqlite.COL_USER_ID + " = '" + userId + "'");
|
||||||
+ Sqlite.COL_TYPE + " = 'favourite'"
|
selection.append(" AND " + Sqlite.COL_CREATED_AT + " >= '").append(Helper.dateToString(smallestDate)).append("'");
|
||||||
, null);
|
selection.append(" AND " + Sqlite.COL_CREATED_AT + " <= '").append(Helper.dateToString(start.getTime())).append("'");
|
||||||
mCount.moveToFirst();
|
|
||||||
favCount = mCount.getInt(0);
|
|
||||||
mCount.close();
|
|
||||||
if( favCount < minYVal){
|
|
||||||
minYVal = favCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
try {
|
||||||
+ " where " + selection.toString() + " AND "
|
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ Sqlite.COL_TYPE + " = 'mention'"
|
+ " where " + selection.toString() + " AND "
|
||||||
, null);
|
+ Sqlite.COL_TYPE + " = 'reblog'"
|
||||||
mCount.moveToFirst();
|
, null);
|
||||||
mentionCount = mCount.getInt(0);
|
mCount.moveToFirst();
|
||||||
mCount.close();
|
reblogCount = mCount.getInt(0);
|
||||||
if( mentionCount < minYVal){
|
mCount.close();
|
||||||
minYVal = mentionCount;
|
minYVal = reblogCount;
|
||||||
}
|
|
||||||
|
|
||||||
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
+ Sqlite.COL_TYPE + " = 'follow'"
|
+ Sqlite.COL_TYPE + " = 'favourite'"
|
||||||
, null);
|
, null);
|
||||||
mCount.moveToFirst();
|
mCount.moveToFirst();
|
||||||
mCount.moveToFirst();
|
favCount = mCount.getInt(0);
|
||||||
followCount = mCount.getInt(0);
|
mCount.close();
|
||||||
mCount.close();
|
if (favCount < minYVal) {
|
||||||
if( followCount < minYVal){
|
minYVal = favCount;
|
||||||
minYVal = followCount;
|
}
|
||||||
}
|
|
||||||
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selection.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'mention'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
mentionCount = mCount.getInt(0);
|
||||||
|
mCount.close();
|
||||||
|
if (mentionCount < minYVal) {
|
||||||
|
minYVal = mentionCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selection.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'follow'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
mCount.moveToFirst();
|
||||||
|
followCount = mCount.getInt(0);
|
||||||
|
mCount.close();
|
||||||
|
if (followCount < minYVal) {
|
||||||
|
minYVal = followCount;
|
||||||
|
}
|
||||||
|
|
||||||
/* mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
/* mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
|
@ -659,64 +667,64 @@ public class NotificationCacheDAO {
|
||||||
if( pollCount < minYVal){
|
if( pollCount < minYVal){
|
||||||
minYVal = pollCount;
|
minYVal = pollCount;
|
||||||
}*/
|
}*/
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
for (Date date = start.getTime(); start.before(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
|
for (Date date = start.getTime(); start.before(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
|
||||||
Calendar startTmp = Calendar.getInstance();
|
Calendar startTmp = Calendar.getInstance();
|
||||||
startTmp.setTime(date);
|
startTmp.setTime(date);
|
||||||
startTmp.set(Calendar.HOUR_OF_DAY,0);
|
startTmp.set(Calendar.HOUR_OF_DAY,0);
|
||||||
startTmp.set(Calendar.MINUTE,0);
|
startTmp.set(Calendar.MINUTE,0);
|
||||||
startTmp.set(Calendar.SECOND,0);
|
startTmp.set(Calendar.SECOND,0);
|
||||||
|
|
||||||
Calendar endTmp = Calendar.getInstance();
|
Calendar endTmp = Calendar.getInstance();
|
||||||
endTmp.setTime(date);
|
endTmp.setTime(date);
|
||||||
endTmp.set(Calendar.HOUR_OF_DAY,23);
|
endTmp.set(Calendar.HOUR_OF_DAY,23);
|
||||||
endTmp.set(Calendar.MINUTE,59);
|
endTmp.set(Calendar.MINUTE,59);
|
||||||
endTmp.set(Calendar.SECOND,59);
|
endTmp.set(Calendar.SECOND,59);
|
||||||
|
|
||||||
|
|
||||||
selection = new StringBuilder(Sqlite.COL_INSTANCE + " = '" + instance + "' AND " + Sqlite.COL_USER_ID + " = '" + userId + "'");
|
selection = new StringBuilder(Sqlite.COL_INSTANCE + " = '" + instance + "' AND " + Sqlite.COL_USER_ID + " = '" + userId + "'");
|
||||||
selection.append(" AND " + Sqlite.COL_CREATED_AT + " >= '").append(Helper.dateToString(startTmp.getTime())).append("'");
|
selection.append(" AND " + Sqlite.COL_CREATED_AT + " >= '").append(Helper.dateToString(startTmp.getTime())).append("'");
|
||||||
selection.append(" AND " + Sqlite.COL_CREATED_AT + " <= '").append(Helper.dateToString(endTmp.getTime())).append("'");
|
selection.append(" AND " + Sqlite.COL_CREATED_AT + " <= '").append(Helper.dateToString(endTmp.getTime())).append("'");
|
||||||
try {
|
try {
|
||||||
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
+ Sqlite.COL_TYPE + " = 'reblog'"
|
+ Sqlite.COL_TYPE + " = 'reblog'"
|
||||||
, null);
|
, null);
|
||||||
mCount.moveToFirst();
|
mCount.moveToFirst();
|
||||||
reblogCount += mCount.getInt(0);
|
reblogCount += mCount.getInt(0);
|
||||||
charts.getReblogs().put(date.getTime(), reblogCount);
|
charts.getReblogs().put(date.getTime(), reblogCount);
|
||||||
mCount.close();
|
mCount.close();
|
||||||
|
|
||||||
|
|
||||||
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
+ Sqlite.COL_TYPE + " = 'favourite'"
|
+ Sqlite.COL_TYPE + " = 'favourite'"
|
||||||
, null);
|
, null);
|
||||||
mCount.moveToFirst();
|
mCount.moveToFirst();
|
||||||
favCount += mCount.getInt(0);
|
favCount += mCount.getInt(0);
|
||||||
charts.getFavourites().put(date.getTime(),favCount);
|
charts.getFavourites().put(date.getTime(),favCount);
|
||||||
mCount.close();
|
mCount.close();
|
||||||
|
|
||||||
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
+ Sqlite.COL_TYPE + " = 'mention'"
|
+ Sqlite.COL_TYPE + " = 'mention'"
|
||||||
, null);
|
, null);
|
||||||
mCount.moveToFirst();
|
mCount.moveToFirst();
|
||||||
mentionCount += mCount.getInt(0);
|
mentionCount += mCount.getInt(0);
|
||||||
charts.getMentions().put(date.getTime(), mentionCount);
|
charts.getMentions().put(date.getTime(), mentionCount);
|
||||||
mCount.close();
|
mCount.close();
|
||||||
|
|
||||||
|
|
||||||
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
+ Sqlite.COL_TYPE + " = 'follow'"
|
+ Sqlite.COL_TYPE + " = 'follow'"
|
||||||
, null);
|
, null);
|
||||||
mCount.moveToFirst();
|
mCount.moveToFirst();
|
||||||
followCount += mCount.getInt(0);
|
followCount += mCount.getInt(0);
|
||||||
charts.getFollows().put(date.getTime(),followCount);
|
charts.getFollows().put(date.getTime(),followCount);
|
||||||
mCount.close();
|
mCount.close();
|
||||||
|
|
||||||
/* mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
/* mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
+ " where " + selection.toString() + " AND "
|
+ " where " + selection.toString() + " AND "
|
||||||
|
@ -727,10 +735,87 @@ public class NotificationCacheDAO {
|
||||||
charts.getPolls().put(date.getTime(), pollCount);
|
charts.getPolls().put(date.getTime(), pollCount);
|
||||||
mCount.close();*/
|
mCount.close();*/
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
start.add(Calendar.HOUR, -1);
|
||||||
|
charts.getReblogs().put(start.getTimeInMillis(), 0);
|
||||||
|
charts.getFavourites().put(start.getTimeInMillis(), 0);
|
||||||
|
charts.getMentions().put(start.getTimeInMillis(), 0);
|
||||||
|
charts.getFollows().put(start.getTimeInMillis(), 0);
|
||||||
|
start.add(Calendar.HOUR, 1);
|
||||||
|
for (Date date = start.getTime(); start.before(end); start.add(Calendar.HOUR, 1), date = start.getTime()) {
|
||||||
|
Calendar startTmp = Calendar.getInstance();
|
||||||
|
startTmp.setTime(date);
|
||||||
|
Calendar endTmp = Calendar.getInstance();
|
||||||
|
endTmp.setTime(date);
|
||||||
|
endTmp.add(Calendar.MINUTE, 59);
|
||||||
|
endTmp.add(Calendar.SECOND, 59);
|
||||||
|
StringBuilder selection = new StringBuilder(Sqlite.COL_INSTANCE + " = '" + instance + "' AND " + Sqlite.COL_USER_ID + " = '" + userId + "'");
|
||||||
|
selection.append(" AND " + Sqlite.COL_CREATED_AT + " >= '").append(Helper.dateToString(startTmp.getTime())).append("'");
|
||||||
|
selection.append(" AND " + Sqlite.COL_CREATED_AT + " <= '").append(Helper.dateToString(endTmp.getTime())).append("'");
|
||||||
|
selection.append(" AND (" + Sqlite.COL_STATUS_ID + " = '").append(status_id).append("'").append( " OR ");
|
||||||
|
selection.append(Sqlite.COL_IN_REPLY_TO_ID + " = '").append(status_id).append("'").append( " ) ");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selection.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'reblog'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
reblogCount += mCount.getInt(0);
|
||||||
|
charts.getReblogs().put(date.getTime(), reblogCount);
|
||||||
|
mCount.close();
|
||||||
|
|
||||||
|
|
||||||
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selection.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'favourite'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
favCount += mCount.getInt(0);
|
||||||
|
charts.getFavourites().put(date.getTime(),favCount);
|
||||||
|
mCount.close();
|
||||||
|
|
||||||
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selection.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'mention'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
mentionCount += mCount.getInt(0);
|
||||||
|
charts.getMentions().put(date.getTime(), mentionCount);
|
||||||
|
mCount.close();
|
||||||
|
|
||||||
|
StringBuilder selectionFollow = new StringBuilder(Sqlite.COL_INSTANCE + " = '" + instance + "' AND " + Sqlite.COL_USER_ID + " = '" + userId + "'");
|
||||||
|
selectionFollow.append(" AND " + Sqlite.COL_CREATED_AT + " >= '").append(Helper.dateToString(startTmp.getTime())).append("'");
|
||||||
|
selectionFollow.append(" AND " + Sqlite.COL_CREATED_AT + " <= '").append(Helper.dateToString(endTmp.getTime())).append("'");
|
||||||
|
|
||||||
|
mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selectionFollow.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'follow'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
followCount += mCount.getInt(0);
|
||||||
|
charts.getFollows().put(date.getTime(),followCount);
|
||||||
|
mCount.close();
|
||||||
|
|
||||||
|
/* mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_NOTIFICATION_CACHE
|
||||||
|
+ " where " + selection.toString() + " AND "
|
||||||
|
+ Sqlite.COL_TYPE + " = 'poll'"
|
||||||
|
, null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
pollCount += mCount.getInt(0);
|
||||||
|
charts.getPolls().put(date.getTime(), pollCount);
|
||||||
|
mCount.close();*/
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
charts.setMinYVal(minYVal);
|
charts.setMinYVal(minYVal);
|
||||||
charts.setxLabels(xLabel);
|
charts.setxLabels(xLabel);
|
||||||
return charts;
|
return charts;
|
||||||
|
|
|
@ -315,6 +315,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
||||||
+ COL_ACCOUNT + " TEXT NOT NULL, "
|
+ COL_ACCOUNT + " TEXT NOT NULL, "
|
||||||
+ COL_TYPE + " TEXT NOT NULL, "
|
+ COL_TYPE + " TEXT NOT NULL, "
|
||||||
+ COL_STATUS_ID + " TEXT, "
|
+ COL_STATUS_ID + " TEXT, "
|
||||||
|
+ COL_IN_REPLY_TO_ID + " TEXT, "
|
||||||
+ COL_STATUS_ID_CACHE + " INTEGER, "
|
+ COL_STATUS_ID_CACHE + " INTEGER, "
|
||||||
+ COL_CREATED_AT + " TEXT NOT NULL)";
|
+ COL_CREATED_AT + " TEXT NOT NULL)";
|
||||||
|
|
||||||
|
|
|
@ -476,6 +476,21 @@ public class StatusCacheDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a cached status by id in db
|
||||||
|
* @return stored status StoredStatus
|
||||||
|
*/
|
||||||
|
public Status getStatus(String id){
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
String instance = Helper.getLiveInstance(context);
|
||||||
|
try {
|
||||||
|
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_STATUS_ID + " = '" + id + "' AND " + Sqlite.COL_INSTANCE + " = '" + instance +"' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, null, null);
|
||||||
|
return cursorToStoredStatus(c);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Charts getCharts(Date dateIni, Date dateEnd){
|
public Charts getCharts(Date dateIni, Date dateEnd){
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:id="@+id/date_container"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
android:id="@+id/action_admin"
|
android:id="@+id/action_admin"
|
||||||
android:title="@string/administration"
|
android:title="@string/administration"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_stats"
|
||||||
|
android:title="@string/action_stats"
|
||||||
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_info"
|
android:id="@+id/action_info"
|
||||||
android:title="@string/information"
|
android:title="@string/information"
|
||||||
|
|
Loading…
Reference in New Issue