<file_sep># MessageForwarder
Forward (WhatsApp) messages from secondary phone to primary phone (Signal)

With WhatsApp's new Terms of Service update approaching on May 15th I thought it might be useful to have a trustworthy application that forwards messages 
from a secondary phone to your primary phone so you do not miss out on (important) group chats. You might use your old phone just for WhatsApp 
or other questionable apps. It stays at home all the time, that way there is not much activity on it and the collection of meaningful data can be somewhat limited. 

At the moment the primary objective is to just forward messages from (group) chats to Signal.
This is what I personally need the most since it is utopian to expect all your work/uni/school/... colleagues to switch to Signal.
But if demand is there I would love to implement more options like WhatsApp to Telegram, Messenger to Signal, etc. and a reply funciton.

If you are interested in contributing to this project let me know, I would greatly appreciate your help!


Related articles:
(en) https://www.bbc.com/news/technology-55683745
(de) https://www.bayern3.de/whatsapp-datenschutz-aenderung-zustimmen-facebook-dsgvo
<file_sep>package com.example.messageforwarder.activities;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.messageforwarder.R;
import com.example.messageforwarder.onclicklisteners.AddForwardRule;
import com.example.messageforwarder.onclicklisteners.WhatsappToSignal;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

public class MainActivity extends AppCompatActivity {

    public static Context mainContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mainContext = getApplicationContext();

        //topbar layout
        setTopBarLayout();
        //icons layout
        ImageView arrowRight = findViewById(R.id.arrow_right);
        ImageView whatsapp = findViewById(R.id.whatsappIcon);
        ImageView signal = findViewById(R.id.signalIcon);
        TextView whatsappToSignalLayer = findViewById(R.id.whatsappToSignalLayer);
        setForwardRuleLayout(arrowRight, whatsapp, signal, whatsappToSignalLayer);

        //add forward rule (display)
        Boolean optionsDisplayed = new Boolean(false);
        FloatingActionButton addForwardRuleBtn = findViewById(R.id.addForwardRule);
        addForwardRuleBtn.setOnClickListener(new AddForwardRule(optionsDisplayed, arrowRight, whatsapp, signal, whatsappToSignalLayer));
        //Rule:WhatsApp to Signal
        whatsappToSignalLayer.setOnClickListener(new WhatsappToSignal(mainContext));
    }

    private int getScreenHeight() {
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        return metrics.heightPixels;
    }

    private int getScreenWidth() {
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        return metrics.widthPixels;
    }

    private void setTopBarLayout() {
        int screenHeight = getScreenHeight();
        TextView topBar = findViewById(R.id.topBar);
        RelativeLayout.LayoutParams topBarParams = (RelativeLayout.LayoutParams)topBar.getLayoutParams();
        topBarParams.height = screenHeight / 6;
        topBar.setTextSize(screenHeight/(float)60);
    }

    private void setForwardRuleLayout(ImageView arrowRight, ImageView whatsapp, ImageView signal, TextView whatsappToSignalLayer) {
        int screenHeight = getScreenHeight();
        //load icons and set their layout
        //arrow
        RelativeLayout.LayoutParams iconParams = (RelativeLayout.LayoutParams)arrowRight.getLayoutParams();
        iconParams.height = screenHeight / 9;
        iconParams.width = getScreenHeight() / 9;
        //whatsapp
        iconParams = (RelativeLayout.LayoutParams)whatsapp.getLayoutParams();
        iconParams.height = screenHeight / 9;
        iconParams.width = getScreenHeight() / 9;
        //signal
        iconParams = (RelativeLayout.LayoutParams)signal.getLayoutParams();
        iconParams.height = screenHeight / 9;
        iconParams.width = getScreenHeight() / 9;
        //WhatsApp to Signal Layer
        iconParams = (RelativeLayout.LayoutParams)whatsappToSignalLayer.getLayoutParams();
        iconParams.height = screenHeight / 9;
        iconParams.width = screenHeight / 3 + 30; //30sp offset for margin between icons --> make relative
    }


}
<file_sep>package com.example.messageforwarder.activities;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.example.messageforwarder.R;

public class NewRule extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_rule);
    }
}
<file_sep>rootProject.name='MessageForwarder'
include ':app'
<file_sep>package com.example.messageforwarder.onclicklisteners;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class AddForwardRule implements View.OnClickListener {

    private Boolean optionsDisplayed;
    private ImageView arrowRight;
    private ImageView whatsapp;
    private ImageView signal;
    private TextView whatsappToSignalLayer;

    public AddForwardRule(Boolean optionsDisplayed, ImageView arrowRight, ImageView whatsapp,
                          ImageView signal, TextView whatsappToSignalLayer) {
        this.optionsDisplayed = optionsDisplayed;
        this.arrowRight = arrowRight;
        this.whatsapp = whatsapp;
        this.signal = signal;
        this.whatsappToSignalLayer = whatsappToSignalLayer;
    }

    @Override
    public void onClick(View v) {
        displayWhatsappToSignal();
    }

    private void displayWhatsappToSignal() {
        //set icon visibility based on if already displayed
        if (optionsDisplayed) {
            arrowRight.setVisibility(View.INVISIBLE);
            whatsapp.setVisibility(View.INVISIBLE);
            signal.setVisibility(View.INVISIBLE);
            whatsappToSignalLayer.setVisibility(View.INVISIBLE);
            whatsappToSignalLayer.setClickable(false);
        } else {
            arrowRight.setVisibility(View.VISIBLE);
            whatsapp.setVisibility(View.VISIBLE);
            signal.setVisibility(View.VISIBLE);
            whatsappToSignalLayer.setVisibility(View.VISIBLE);
            whatsappToSignalLayer.setClickable(true);
        }
        optionsDisplayed = !optionsDisplayed;
    }
}
